aktion-runtime 0.5.10 → 0.5.11
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/README.md +20 -10
- package/dist/aktion.iife.js +113 -136
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +4087 -3959
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +113 -136
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/language.js +1938 -1662
- package/dist/language.js.map +1 -1
- package/dist/system_prompt.txt +28 -26
- package/dist/system_prompt_chat.txt +11 -11
- package/dist/testing.js +358 -197
- package/dist/testing.js.map +1 -1
- package/dist/types/library/types.d.ts +50 -0
- package/dist/types/library/utils.d.ts +28 -0
- package/dist/types/library/validate.d.ts +2 -2
- package/dist/types/runtime/evaluator.d.ts +8 -0
- package/dist/types/theme/index.d.ts +3 -0
- package/dist/types/theme/styles.d.ts +1 -1
- package/dist/types/tooling/signature-help.d.ts +35 -0
- package/package.json +1 -1
package/dist/language.js
CHANGED
|
@@ -2197,33 +2197,6 @@ function getIndex(library) {
|
|
|
2197
2197
|
function findComponent(library, name) {
|
|
2198
2198
|
return getIndex(library).get(name);
|
|
2199
2199
|
}
|
|
2200
|
-
function findPositionalIndex(spec) {
|
|
2201
|
-
const explicit = spec.props.findIndex((p) => p.positional === true);
|
|
2202
|
-
if (explicit >= 0) return explicit;
|
|
2203
|
-
return spec.props.length > 0 ? 0 : -1;
|
|
2204
|
-
}
|
|
2205
|
-
function findPositionalProp(spec) {
|
|
2206
|
-
const idx = findPositionalIndex(spec);
|
|
2207
|
-
return idx >= 0 ? spec.props[idx] : void 0;
|
|
2208
|
-
}
|
|
2209
|
-
function assertOnePositionalMax(specs) {
|
|
2210
|
-
for (const spec of specs) {
|
|
2211
|
-
const positional = spec.props.filter((p) => p.positional === true);
|
|
2212
|
-
if (positional.length > 1) {
|
|
2213
|
-
const names = positional.map((p) => p.name).join(", ");
|
|
2214
|
-
throw new SyntaxError(
|
|
2215
|
-
`Component "${spec.name}" declares ${positional.length} positional props (${names}). Aktion 0.5 §19.1 allows at most one.`
|
|
2216
|
-
);
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
function mapPositionalArgs(spec, args) {
|
|
2221
|
-
const out = {};
|
|
2222
|
-
spec.props.forEach((prop, index) => {
|
|
2223
|
-
if (index < args.length) out[prop.name] = args[index];
|
|
2224
|
-
});
|
|
2225
|
-
return out;
|
|
2226
|
-
}
|
|
2227
2200
|
const SUPPORTED_VARIANTS = /* @__PURE__ */ new Set(["solid", "regular", "brands"]);
|
|
2228
2201
|
const DEFAULT_VARIANT = "solid";
|
|
2229
2202
|
function resolveIconClasses(value) {
|
|
@@ -2300,6 +2273,30 @@ function asNumber(value, fallback = 0) {
|
|
|
2300
2273
|
}
|
|
2301
2274
|
return fallback;
|
|
2302
2275
|
}
|
|
2276
|
+
const SPACING_TOKENS = ["none", "3xs", "2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
2277
|
+
const LEGACY_SIZE_TOKEN_ALIASES = {
|
|
2278
|
+
s: "sm",
|
|
2279
|
+
m: "md",
|
|
2280
|
+
l: "lg",
|
|
2281
|
+
small: "sm",
|
|
2282
|
+
normal: "md",
|
|
2283
|
+
large: "lg"
|
|
2284
|
+
};
|
|
2285
|
+
function canonicalSizeToken(value) {
|
|
2286
|
+
const raw = typeof value === "string" ? value.trim() : "";
|
|
2287
|
+
return LEGACY_SIZE_TOKEN_ALIASES[raw] ?? raw;
|
|
2288
|
+
}
|
|
2289
|
+
function normalizeSpacingToken(value, fallback = "") {
|
|
2290
|
+
const token = canonicalSizeToken(value);
|
|
2291
|
+
return SPACING_TOKENS.includes(token) ? token : fallback;
|
|
2292
|
+
}
|
|
2293
|
+
function spacingCssValue(value) {
|
|
2294
|
+
const token = normalizeSpacingToken(value);
|
|
2295
|
+
if (!token) return "";
|
|
2296
|
+
if (token === "none") return "0";
|
|
2297
|
+
const varKey = token === "sm" ? "s" : token === "md" ? "m" : token === "lg" ? "l" : token;
|
|
2298
|
+
return `var(--rui-spacing-${varKey})`;
|
|
2299
|
+
}
|
|
2303
2300
|
const RESPONSIVE_BREAKPOINTS = ["base", "sm", "md", "lg", "xl"];
|
|
2304
2301
|
function readResponsiveProp(value) {
|
|
2305
2302
|
if (value == null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -2478,13 +2475,135 @@ const UNIVERSAL_PROP_NAMES = /* @__PURE__ */ new Set([
|
|
|
2478
2475
|
"tooltip",
|
|
2479
2476
|
"hidden"
|
|
2480
2477
|
]);
|
|
2478
|
+
function findPositionalIndex(spec) {
|
|
2479
|
+
const explicit = spec.props.findIndex((p) => p.positional === true);
|
|
2480
|
+
if (explicit >= 0) return explicit;
|
|
2481
|
+
return spec.props.length > 0 ? 0 : -1;
|
|
2482
|
+
}
|
|
2483
|
+
function findPositionalProp(spec) {
|
|
2484
|
+
const idx = findPositionalIndex(spec);
|
|
2485
|
+
return idx >= 0 ? spec.props[idx] : void 0;
|
|
2486
|
+
}
|
|
2487
|
+
function assertOnePositionalMax(specs) {
|
|
2488
|
+
for (const spec of specs) {
|
|
2489
|
+
const positional = spec.props.filter((p) => p.positional === true);
|
|
2490
|
+
if (positional.length > 1) {
|
|
2491
|
+
const names = positional.map((p) => p.name).join(", ");
|
|
2492
|
+
throw new SyntaxError(
|
|
2493
|
+
`Component "${spec.name}" declares ${positional.length} positional props (${names}). Aktion 0.5 §19.1 allows at most one.`
|
|
2494
|
+
);
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
function propExpectsObject(prop) {
|
|
2499
|
+
return /\bobject\b|\bRecord\b|\{|\bany\b/i.test(prop.type);
|
|
2500
|
+
}
|
|
2501
|
+
function knownPropNames(spec) {
|
|
2502
|
+
const names = /* @__PURE__ */ new Set();
|
|
2503
|
+
for (const p of spec.props) {
|
|
2504
|
+
names.add(p.name);
|
|
2505
|
+
if (p.aliases) for (const alias of p.aliases) names.add(alias);
|
|
2506
|
+
}
|
|
2507
|
+
names.add("key");
|
|
2508
|
+
return names;
|
|
2509
|
+
}
|
|
2510
|
+
function slotForNthPositional(spec, n) {
|
|
2511
|
+
const positionalIndex = findPositionalIndex(spec);
|
|
2512
|
+
if (positionalIndex < 0) return null;
|
|
2513
|
+
const filled = /* @__PURE__ */ new Set();
|
|
2514
|
+
let target = -1;
|
|
2515
|
+
for (let i = 0; i <= n; i += 1) {
|
|
2516
|
+
if (i === 0) {
|
|
2517
|
+
target = positionalIndex;
|
|
2518
|
+
} else {
|
|
2519
|
+
let cursor = 0;
|
|
2520
|
+
while (cursor < spec.props.length && filled.has(cursor)) cursor += 1;
|
|
2521
|
+
if (cursor >= spec.props.length) return null;
|
|
2522
|
+
target = cursor;
|
|
2523
|
+
}
|
|
2524
|
+
filled.add(target);
|
|
2525
|
+
}
|
|
2526
|
+
return spec.props[target] ?? null;
|
|
2527
|
+
}
|
|
2528
|
+
function chooseNamedBagIndex(args, spec) {
|
|
2529
|
+
let lastObj = -1;
|
|
2530
|
+
for (let i = args.length - 1; i >= 0; i -= 1) {
|
|
2531
|
+
if (args[i].objectKeys !== null) {
|
|
2532
|
+
lastObj = i;
|
|
2533
|
+
break;
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
if (lastObj < 0) return -1;
|
|
2537
|
+
const keys = args[lastObj].objectKeys;
|
|
2538
|
+
const known = knownPropNames(spec);
|
|
2539
|
+
const knownCount = keys.reduce(
|
|
2540
|
+
(count, k) => count + (known.has(k) || UNIVERSAL_PROP_NAMES.has(k) ? 1 : 0),
|
|
2541
|
+
0
|
|
2542
|
+
);
|
|
2543
|
+
const allKnown = keys.length > 0 && knownCount === keys.length;
|
|
2544
|
+
const anyKnown = knownCount > 0;
|
|
2545
|
+
const positionalProp = findPositionalProp(spec);
|
|
2546
|
+
if (args.length === 1) {
|
|
2547
|
+
if (spec.props.length === 1) {
|
|
2548
|
+
return propExpectsObject(spec.props[0]) ? -1 : allKnown ? 0 : -1;
|
|
2549
|
+
}
|
|
2550
|
+
if (allKnown) return 0;
|
|
2551
|
+
if (!anyKnown && positionalProp && propExpectsObject(positionalProp)) return -1;
|
|
2552
|
+
return 0;
|
|
2553
|
+
}
|
|
2554
|
+
if (lastObj !== args.length - 1) {
|
|
2555
|
+
return anyKnown ? lastObj : -1;
|
|
2556
|
+
}
|
|
2557
|
+
if (anyKnown || keys.length === 0) return lastObj;
|
|
2558
|
+
const slot = slotForNthPositional(spec, args.length - 1);
|
|
2559
|
+
if (slot && propExpectsObject(slot)) return -1;
|
|
2560
|
+
return lastObj;
|
|
2561
|
+
}
|
|
2562
|
+
function callArgShapes(args) {
|
|
2563
|
+
return args.map((arg) => ({
|
|
2564
|
+
objectKeys: arg.kind === "Object" && arg.properties ? arg.properties.filter((p) => !p.spread).map((p) => p.key) : null
|
|
2565
|
+
}));
|
|
2566
|
+
}
|
|
2567
|
+
function mapPositionalArgs(spec, args) {
|
|
2568
|
+
const out = {};
|
|
2569
|
+
spec.props.forEach((prop, index) => {
|
|
2570
|
+
if (index < args.length) out[prop.name] = args[index];
|
|
2571
|
+
});
|
|
2572
|
+
return out;
|
|
2573
|
+
}
|
|
2481
2574
|
function validateProgramSchema(program, library) {
|
|
2482
2575
|
const errors = [];
|
|
2483
|
-
|
|
2484
|
-
|
|
2576
|
+
currentDeclaredComponents = collectDeclaredComponentNames(program);
|
|
2577
|
+
try {
|
|
2578
|
+
for (const stmt of program.statements) {
|
|
2579
|
+
walkStatement(stmt, library, errors);
|
|
2580
|
+
}
|
|
2581
|
+
} finally {
|
|
2582
|
+
currentDeclaredComponents = EMPTY_NAME_SET;
|
|
2485
2583
|
}
|
|
2486
2584
|
return errors;
|
|
2487
2585
|
}
|
|
2586
|
+
const EMPTY_NAME_SET = /* @__PURE__ */ new Set();
|
|
2587
|
+
let currentDeclaredComponents = EMPTY_NAME_SET;
|
|
2588
|
+
function collectDeclaredComponentNames(program) {
|
|
2589
|
+
const names = /* @__PURE__ */ new Set();
|
|
2590
|
+
const scan = (node) => {
|
|
2591
|
+
if (!node || typeof node !== "object") return;
|
|
2592
|
+
if (Array.isArray(node)) {
|
|
2593
|
+
for (const entry of node) scan(entry);
|
|
2594
|
+
return;
|
|
2595
|
+
}
|
|
2596
|
+
const rec = node;
|
|
2597
|
+
if (rec.kind === "ComponentDeclaration" && typeof rec.name === "string") {
|
|
2598
|
+
names.add(rec.name);
|
|
2599
|
+
}
|
|
2600
|
+
for (const key of Object.keys(rec)) {
|
|
2601
|
+
if (key !== "loc") scan(rec[key]);
|
|
2602
|
+
}
|
|
2603
|
+
};
|
|
2604
|
+
scan(program.statements);
|
|
2605
|
+
return names;
|
|
2606
|
+
}
|
|
2488
2607
|
function walkStatement(stmt, library, out) {
|
|
2489
2608
|
switch (stmt.kind) {
|
|
2490
2609
|
case "Assignment":
|
|
@@ -2494,6 +2613,9 @@ function walkStatement(stmt, library, out) {
|
|
|
2494
2613
|
walkExpression(stmt.expression, library, out);
|
|
2495
2614
|
return;
|
|
2496
2615
|
case "ComponentDeclaration":
|
|
2616
|
+
validateComponentDeclarationName(stmt, library, out);
|
|
2617
|
+
for (const inner of stmt.body.body) walkStatement(inner, library, out);
|
|
2618
|
+
return;
|
|
2497
2619
|
case "ActionDeclaration":
|
|
2498
2620
|
case "EffectDeclaration":
|
|
2499
2621
|
case "HookDeclaration":
|
|
@@ -2630,7 +2752,28 @@ function walkExpression(expr, library, out) {
|
|
|
2630
2752
|
return;
|
|
2631
2753
|
}
|
|
2632
2754
|
}
|
|
2755
|
+
function validateComponentDeclarationName(stmt, library, out) {
|
|
2756
|
+
if (!findComponent(library, stmt.name)) return;
|
|
2757
|
+
if (subtreeCallsName(stmt.body, stmt.name)) return;
|
|
2758
|
+
out.push({
|
|
2759
|
+
message: `function ${stmt.name}(...) — "${stmt.name}" is a built-in component name. Rename the custom component (e.g. "App${stmt.name}"), or call ${stmt.name}(...) inside the body to wrap the built-in (inside its own body the name refers to the built-in component).`,
|
|
2760
|
+
line: stmt.loc?.line ?? 0,
|
|
2761
|
+
column: stmt.loc?.column ?? 0
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
function subtreeCallsName(node, name) {
|
|
2765
|
+
if (!node || typeof node !== "object") return false;
|
|
2766
|
+
if (Array.isArray(node)) return node.some((entry) => subtreeCallsName(entry, name));
|
|
2767
|
+
const rec = node;
|
|
2768
|
+
if (rec.kind === "Call" && rec.callee === name) return true;
|
|
2769
|
+
for (const key of Object.keys(rec)) {
|
|
2770
|
+
if (key === "loc") continue;
|
|
2771
|
+
if (subtreeCallsName(rec[key], name)) return true;
|
|
2772
|
+
}
|
|
2773
|
+
return false;
|
|
2774
|
+
}
|
|
2633
2775
|
function validateCall(expr, library, out) {
|
|
2776
|
+
if (currentDeclaredComponents.has(expr.callee)) return;
|
|
2634
2777
|
const spec = findComponent(library, expr.callee);
|
|
2635
2778
|
if (!spec) return;
|
|
2636
2779
|
const propNames = /* @__PURE__ */ new Set();
|
|
@@ -2642,31 +2785,41 @@ function validateCall(expr, library, out) {
|
|
|
2642
2785
|
}
|
|
2643
2786
|
propNames.add("key");
|
|
2644
2787
|
const args = expr.arguments;
|
|
2645
|
-
|
|
2646
|
-
for (let i = args.length - 1; i >= 0; i -= 1) {
|
|
2647
|
-
if (args[i].kind === "Object") {
|
|
2648
|
-
trailingObjIdx = i;
|
|
2649
|
-
break;
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2788
|
+
const trailingObjIdx = chooseNamedBagIndex(callArgShapes(args), spec);
|
|
2652
2789
|
const trailingObj = trailingObjIdx >= 0 ? args[trailingObjIdx] : null;
|
|
2653
2790
|
const positionalArgs = [];
|
|
2654
2791
|
for (let i = 0; i < args.length; i++) {
|
|
2655
2792
|
if (i === trailingObjIdx) continue;
|
|
2656
2793
|
positionalArgs.push(args[i]);
|
|
2657
2794
|
}
|
|
2658
|
-
if (positionalArgs.length >
|
|
2659
|
-
const positionalProp = findPositionalProp(spec);
|
|
2660
|
-
const positionalName = positionalProp?.name ?? "(none)";
|
|
2661
|
-
const namedNames = collectNamedPropNames(args, trailingObj);
|
|
2662
|
-
const extras = spec.props.filter((p) => p.name !== positionalName && !namedNames.has(p.name)).slice(0, positionalArgs.length - 1).map((p) => p.name);
|
|
2663
|
-
const hints = extras.length > 0 ? extras.map((n) => `${n}: …`).join(", ") : "use a trailing { prop: value } object";
|
|
2795
|
+
if (positionalArgs.length > spec.props.length) {
|
|
2664
2796
|
out.push({
|
|
2665
|
-
message: `${expr.callee}(...) —
|
|
2797
|
+
message: `${expr.callee}(...) — takes at most ${spec.props.length} positional argument${spec.props.length === 1 ? "" : "s"} (${spec.props.map((p) => p.name).join(", ")}); got ${positionalArgs.length}.`,
|
|
2666
2798
|
line: expr.loc?.line ?? 0,
|
|
2667
2799
|
column: expr.loc?.column ?? 0
|
|
2668
2800
|
});
|
|
2669
2801
|
}
|
|
2802
|
+
positionalArgs.forEach((arg, n) => {
|
|
2803
|
+
const prop = slotForNthPositional(spec, n);
|
|
2804
|
+
if (!prop) return;
|
|
2805
|
+
if (prop.enum && arg.kind === "Literal" && typeof arg.value === "string") {
|
|
2806
|
+
const value = arg.value;
|
|
2807
|
+
if (!prop.enum.includes(value) && !prop.enum.includes(canonicalSizeToken(value))) {
|
|
2808
|
+
out.push({
|
|
2809
|
+
message: `<${expr.callee}> ${prop.name}="${value}" — must be one of ${prop.enum.map((v) => `"${v}"`).join(", ")}.`,
|
|
2810
|
+
line: arg.loc?.line ?? expr.loc?.line ?? 0,
|
|
2811
|
+
column: arg.loc?.column ?? expr.loc?.column ?? 0
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
if (arg.kind === "Object" && !propExpectsObject(prop)) {
|
|
2816
|
+
out.push({
|
|
2817
|
+
message: `<${expr.callee}> — object passed positionally for "${prop.name}" (${prop.type}). Use named props from: ${spec.props.map((p) => p.name).join(", ")}.`,
|
|
2818
|
+
line: arg.loc?.line ?? expr.loc?.line ?? 0,
|
|
2819
|
+
column: arg.loc?.column ?? expr.loc?.column ?? 0
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
});
|
|
2670
2823
|
const namedEntries = [];
|
|
2671
2824
|
if (trailingObj) {
|
|
2672
2825
|
for (const prop of trailingObj.properties) {
|
|
@@ -2693,7 +2846,7 @@ function validateCall(expr, library, out) {
|
|
|
2693
2846
|
);
|
|
2694
2847
|
if (prop?.enum && entry.value.kind === "Literal" && typeof entry.value.value === "string") {
|
|
2695
2848
|
const value = entry.value.value;
|
|
2696
|
-
if (!prop.enum.includes(value)) {
|
|
2849
|
+
if (!prop.enum.includes(value) && !prop.enum.includes(canonicalSizeToken(value))) {
|
|
2697
2850
|
out.push({
|
|
2698
2851
|
message: `<${expr.callee}> ${entry.name}="${value}" — must be one of ${prop.enum.map((v) => `"${v}"`).join(", ")}.`,
|
|
2699
2852
|
line: entry.loc?.line ?? expr.loc?.line ?? 0,
|
|
@@ -2703,15 +2856,6 @@ function validateCall(expr, library, out) {
|
|
|
2703
2856
|
}
|
|
2704
2857
|
}
|
|
2705
2858
|
}
|
|
2706
|
-
function collectNamedPropNames(_args, trailingObj) {
|
|
2707
|
-
const names = /* @__PURE__ */ new Set();
|
|
2708
|
-
if (trailingObj) {
|
|
2709
|
-
for (const prop of trailingObj.properties) {
|
|
2710
|
-
if (!prop.spread) names.add(prop.key);
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
return names;
|
|
2714
|
-
}
|
|
2715
2859
|
const STRUCTURED_THEME_GROUPS = /* @__PURE__ */ new Set(["colors", "radius", "font", "fonts", "spacing", "shadows", "gradients", "icons", "zIndex", "motion"]);
|
|
2716
2860
|
const THEME_METADATA_KEYS = /* @__PURE__ */ new Set(["name", "direction"]);
|
|
2717
2861
|
function validateThemeCall(expr, out) {
|
|
@@ -3320,1487 +3464,933 @@ function findBuiltin(bareName) {
|
|
|
3320
3464
|
function isBuiltinName(bareName) {
|
|
3321
3465
|
return builtinNames.has(bareName);
|
|
3322
3466
|
}
|
|
3323
|
-
const
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
return [
|
|
3340
|
-
...program.errors.map((e) => ({
|
|
3341
|
-
line: e.line,
|
|
3342
|
-
column: e.column,
|
|
3343
|
-
message: e.message,
|
|
3344
|
-
severity: "error"
|
|
3345
|
-
})),
|
|
3346
|
-
...schemaErrors.map((e) => ({
|
|
3347
|
-
line: e.line,
|
|
3348
|
-
column: e.column,
|
|
3349
|
-
message: e.message,
|
|
3350
|
-
severity: "error"
|
|
3351
|
-
}))
|
|
3352
|
-
];
|
|
3467
|
+
const GRID_COLUMNS = 12;
|
|
3468
|
+
const FLEX_ALIGN = {
|
|
3469
|
+
start: "flex-start",
|
|
3470
|
+
center: "center",
|
|
3471
|
+
end: "flex-end",
|
|
3472
|
+
stretch: "stretch"
|
|
3473
|
+
};
|
|
3474
|
+
const FLEX_JUSTIFY = {
|
|
3475
|
+
start: "flex-start",
|
|
3476
|
+
center: "center",
|
|
3477
|
+
end: "flex-end",
|
|
3478
|
+
between: "space-between",
|
|
3479
|
+
around: "space-around",
|
|
3480
|
+
evenly: "space-evenly"
|
|
3481
|
+
};
|
|
3482
|
+
function mapFlexAlign(token) {
|
|
3483
|
+
return FLEX_ALIGN[token] ?? "stretch";
|
|
3353
3484
|
}
|
|
3354
|
-
function
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
detail: b.summary
|
|
3369
|
-
}))
|
|
3370
|
-
];
|
|
3485
|
+
function mapFlexJustify(token) {
|
|
3486
|
+
return FLEX_JUSTIFY[token] ?? "flex-start";
|
|
3487
|
+
}
|
|
3488
|
+
function applyDirectionWithReverse(value, reverse) {
|
|
3489
|
+
if (!reverse) return value;
|
|
3490
|
+
if (value === "row") return "row-reverse";
|
|
3491
|
+
if (value === "column") return "column-reverse";
|
|
3492
|
+
if (value.endsWith("-reverse")) return value;
|
|
3493
|
+
return `${value}-reverse`;
|
|
3494
|
+
}
|
|
3495
|
+
function emitResponsiveSpacingVars(styleParts, prop, cssPrefix) {
|
|
3496
|
+
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
3497
|
+
const v = prop.values[bp];
|
|
3498
|
+
if (v) styleParts.push(`${cssPrefix}-${bp}:${spacingCssValue(v) || `var(--rui-spacing-${v}, ${v})`}`);
|
|
3371
3499
|
}
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3500
|
+
}
|
|
3501
|
+
function emitResponsiveFlexVars(styleParts, prop, cssPrefix, mapper) {
|
|
3502
|
+
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
3503
|
+
const v = prop.values[bp];
|
|
3504
|
+
if (v) styleParts.push(`${cssPrefix}-${bp}:${mapper(String(v))}`);
|
|
3376
3505
|
}
|
|
3377
|
-
return general;
|
|
3378
3506
|
}
|
|
3379
|
-
function
|
|
3380
|
-
const
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
detail: doc.summary,
|
|
3386
|
-
documentation: `${doc.syntax}
|
|
3387
|
-
|
|
3388
|
-
${doc.example}`
|
|
3389
|
-
});
|
|
3507
|
+
function applyResponsiveEnumProp(value, styleParts, attrs, options) {
|
|
3508
|
+
const parsed = readResponsiveProp(value);
|
|
3509
|
+
if (parsed.kind === "single") {
|
|
3510
|
+
const token = parsed.value ? String(parsed.value) : options.defaultToken;
|
|
3511
|
+
attrs[options.attrName] = token;
|
|
3512
|
+
return;
|
|
3390
3513
|
}
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3514
|
+
attrs[options.attrName] = "responsive";
|
|
3515
|
+
attrs[options.responsiveFlag] = "true";
|
|
3516
|
+
emitResponsiveFlexVars(styleParts, parsed, options.cssVarPrefix, options.mapper);
|
|
3517
|
+
}
|
|
3518
|
+
function isComponentNamed(value, name) {
|
|
3519
|
+
return Boolean(
|
|
3520
|
+
value && typeof value === "object" && value.__kind === "Component" && value.name === name
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
function stackBaseDirection(props) {
|
|
3524
|
+
const direction = readResponsiveProp(props.direction);
|
|
3525
|
+
if (direction.kind === "single") {
|
|
3526
|
+
return direction.value ? String(direction.value) : "column";
|
|
3395
3527
|
}
|
|
3396
|
-
return
|
|
3397
|
-
// Author-declared symbols first so they rank above the large library
|
|
3398
|
-
// list in editors that preserve provider order.
|
|
3399
|
-
...user.components.map((name) => ({
|
|
3400
|
-
label: name,
|
|
3401
|
-
kind: "component",
|
|
3402
|
-
detail: "Component declared in this file"
|
|
3403
|
-
})),
|
|
3404
|
-
...user.actions.map((name) => ({
|
|
3405
|
-
label: name,
|
|
3406
|
-
kind: "builtin",
|
|
3407
|
-
detail: "Action declared in this file"
|
|
3408
|
-
})),
|
|
3409
|
-
...user.atoms.map((name) => ({
|
|
3410
|
-
label: `$${name}`,
|
|
3411
|
-
kind: "state",
|
|
3412
|
-
detail: "Reactive atom declared in this file"
|
|
3413
|
-
})),
|
|
3414
|
-
...keywordItems.values(),
|
|
3415
|
-
...library.components.map((c) => ({
|
|
3416
|
-
label: c.name,
|
|
3417
|
-
kind: "component",
|
|
3418
|
-
detail: signaturePreview(c),
|
|
3419
|
-
documentation: c.description
|
|
3420
|
-
}))
|
|
3421
|
-
];
|
|
3528
|
+
return direction.values.base ? String(direction.values.base) : "column";
|
|
3422
3529
|
}
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
}
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
}
|
|
3442
|
-
function getHoverInfo(source, position, library) {
|
|
3443
|
-
const word = wordAt(source, position);
|
|
3444
|
-
if (!word) return null;
|
|
3445
|
-
const spec = findComponent(library, word);
|
|
3446
|
-
if (spec) {
|
|
3447
|
-
return {
|
|
3448
|
-
kind: "component",
|
|
3449
|
-
contents: `**${spec.name}** — ${spec.description ?? "Component."}
|
|
3450
|
-
|
|
3451
|
-
Signature: \`${signaturePreview(spec)}\``
|
|
3452
|
-
};
|
|
3453
|
-
}
|
|
3454
|
-
if (word.startsWith("$")) {
|
|
3455
|
-
const builtin = findBuiltin(word.slice(1));
|
|
3456
|
-
if (builtin) {
|
|
3457
|
-
return {
|
|
3458
|
-
kind: "builtin",
|
|
3459
|
-
contents: `**${builtin.sigil}** — ${builtin.summary}
|
|
3460
|
-
|
|
3461
|
-
Signature: \`${builtin.signature}\``
|
|
3462
|
-
};
|
|
3463
|
-
}
|
|
3464
|
-
return { kind: "state", contents: `**${word}** — reactive state atom` };
|
|
3465
|
-
}
|
|
3466
|
-
const doc = keywordDocs[word];
|
|
3467
|
-
if (doc) {
|
|
3468
|
-
return { kind: "unknown", contents: formatKeywordHover(word, doc) };
|
|
3469
|
-
}
|
|
3470
|
-
const kw = KEYWORDS$1.find((k) => k.label === word);
|
|
3471
|
-
if (kw) {
|
|
3472
|
-
return { kind: "unknown", contents: `**${word}** — ${kw.detail}` };
|
|
3473
|
-
}
|
|
3474
|
-
return null;
|
|
3475
|
-
}
|
|
3476
|
-
function formatKeywordHover(word, doc) {
|
|
3477
|
-
return `**${word}** — ${doc.summary}
|
|
3478
|
-
|
|
3479
|
-
**Syntax**
|
|
3480
|
-
|
|
3481
|
-
\`\`\`js
|
|
3482
|
-
${doc.syntax}
|
|
3483
|
-
\`\`\`
|
|
3484
|
-
|
|
3485
|
-
**Example**
|
|
3486
|
-
|
|
3487
|
-
\`\`\`js
|
|
3488
|
-
${doc.example}
|
|
3489
|
-
\`\`\``;
|
|
3490
|
-
}
|
|
3491
|
-
function analyseCursor(source, position) {
|
|
3492
|
-
const offset = lineColumnToOffset$1(source, position);
|
|
3493
|
-
const prefix = source.slice(0, offset);
|
|
3494
|
-
const afterDollar = /\$[A-Za-z_]*$/.test(prefix);
|
|
3495
|
-
const stack = [];
|
|
3496
|
-
for (let i = 0; i < prefix.length; i += 1) {
|
|
3497
|
-
const ch = prefix[i];
|
|
3498
|
-
if (ch === "/" && prefix[i + 1] === "/") {
|
|
3499
|
-
while (i < prefix.length && prefix[i] !== "\n") i += 1;
|
|
3500
|
-
continue;
|
|
3530
|
+
const StackItem = {
|
|
3531
|
+
name: "StackItem",
|
|
3532
|
+
description: "Per-child flex control inside a `Row`, `Column`, or `Stack`. Wraps one child so it can `grow` to fill leftover space, `shrink`, set a `basis`, override `alignSelf`, or change visual `order` — the building block for asymmetric rows like `Row([StackItem(searchInput, { grow: 1 }), saveButton])` (input expands, button hugs).",
|
|
3533
|
+
props: [
|
|
3534
|
+
{ name: "child", type: "Node", description: "Child node to wrap" },
|
|
3535
|
+
{ name: "grow", type: "number", optional: true, description: "flex-grow (0 or 1 typical)" },
|
|
3536
|
+
{ name: "shrink", type: "number", optional: true, description: "flex-shrink (0 or 1 typical)" },
|
|
3537
|
+
{ name: "basis", type: "string", optional: true, description: "flex-basis (`auto`, `0`, or CSS length)" },
|
|
3538
|
+
{ name: "alignSelf", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Per-item cross-axis alignment" },
|
|
3539
|
+
{ name: "order", type: "number", optional: true, description: "Visual order override" },
|
|
3540
|
+
{ name: "minWidth", type: "string", optional: true, description: "CSS min-width" },
|
|
3541
|
+
{ name: "maxWidth", type: "string", optional: true, description: "CSS max-width" }
|
|
3542
|
+
],
|
|
3543
|
+
render: (_node, props, helpers) => {
|
|
3544
|
+
const attrs = { class: "rui-stack-item" };
|
|
3545
|
+
const styleParts = [];
|
|
3546
|
+
if (props.grow !== void 0 && props.grow !== null) {
|
|
3547
|
+
attrs["data-grow"] = String(asNumber(props.grow, 0));
|
|
3501
3548
|
}
|
|
3502
|
-
if (
|
|
3503
|
-
|
|
3504
|
-
while (i < prefix.length && !(prefix[i] === "*" && prefix[i + 1] === "/")) i += 1;
|
|
3505
|
-
i += 1;
|
|
3506
|
-
continue;
|
|
3549
|
+
if (props.shrink !== void 0 && props.shrink !== null) {
|
|
3550
|
+
attrs["data-shrink"] = String(asNumber(props.shrink, 1));
|
|
3507
3551
|
}
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3552
|
+
const basis = asString(props.basis);
|
|
3553
|
+
if (basis === "auto" || basis === "0") {
|
|
3554
|
+
attrs["data-basis"] = basis;
|
|
3555
|
+
} else if (basis) {
|
|
3556
|
+
styleParts.push(`flex-basis:${sanitiseCssLength(basis, basis)}`);
|
|
3511
3557
|
}
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3558
|
+
const alignSelf = asString(props.alignSelf);
|
|
3559
|
+
if (alignSelf) attrs["data-align-self"] = alignSelf;
|
|
3560
|
+
if (props.order !== void 0 && props.order !== null) {
|
|
3561
|
+
const order = asNumber(props.order, 0);
|
|
3562
|
+
attrs["data-order"] = String(order);
|
|
3563
|
+
styleParts.push(`order:${order}`);
|
|
3516
3564
|
}
|
|
3565
|
+
const minWidth = asString(props.minWidth);
|
|
3566
|
+
if (minWidth) styleParts.push(`min-width:${sanitiseCssLength(minWidth, minWidth)}`);
|
|
3567
|
+
const maxWidth = asString(props.maxWidth);
|
|
3568
|
+
if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);
|
|
3569
|
+
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
3570
|
+
const root = el("div", attrs);
|
|
3571
|
+
root.append(helpers.renderNode(props.child));
|
|
3572
|
+
return root;
|
|
3517
3573
|
}
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3574
|
+
};
|
|
3575
|
+
function renderFlexContainer(directionValue, uniform, alignDefault, props, helpers) {
|
|
3576
|
+
const direction = readResponsiveProp(directionValue);
|
|
3577
|
+
const gap = readResponsiveProp(props.gap);
|
|
3578
|
+
const padding = readResponsiveProp(props.padding);
|
|
3579
|
+
const reverse = asBoolean(props.reverse);
|
|
3580
|
+
const attrs = {
|
|
3581
|
+
class: "rui-stack",
|
|
3582
|
+
"data-wrap": asBoolean(props.wrap) ? "true" : null,
|
|
3583
|
+
"data-reverse": reverse ? "true" : null,
|
|
3584
|
+
"data-uniform": uniform ? "true" : "false",
|
|
3585
|
+
"data-inline": asBoolean(props.inline) ? "true" : null
|
|
3586
|
+
};
|
|
3587
|
+
const styleParts = [];
|
|
3588
|
+
if (direction.kind === "single") {
|
|
3589
|
+
const dir = direction.value ? String(direction.value) : "column";
|
|
3590
|
+
attrs["data-direction"] = applyDirectionWithReverse(dir, reverse);
|
|
3591
|
+
} else {
|
|
3592
|
+
attrs["data-direction"] = "responsive";
|
|
3593
|
+
attrs["data-responsive-dir"] = "true";
|
|
3594
|
+
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
3595
|
+
const v = direction.values[bp];
|
|
3596
|
+
if (v) styleParts.push(`--rui-stack-dir-${bp}:${applyDirectionWithReverse(String(v), reverse)}`);
|
|
3527
3597
|
}
|
|
3528
3598
|
}
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
if (ch === "\\") {
|
|
3536
|
-
i += 2;
|
|
3537
|
-
continue;
|
|
3538
|
-
}
|
|
3539
|
-
if (ch === quote) return i;
|
|
3540
|
-
i += 1;
|
|
3599
|
+
if (gap.kind === "single") {
|
|
3600
|
+
attrs["data-gap"] = gap.value ? normalizeSpacingToken(gap.value, String(gap.value)) : "md";
|
|
3601
|
+
} else {
|
|
3602
|
+
attrs["data-gap"] = "responsive";
|
|
3603
|
+
attrs["data-responsive-gap"] = "true";
|
|
3604
|
+
emitResponsiveSpacingVars(styleParts, gap, "--rui-stack-gap");
|
|
3541
3605
|
}
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
const tagText = tags.length > 0 ? ` (${tags.join(", ")})` : "";
|
|
3566
|
-
return `${prop.type}${tagText}`;
|
|
3567
|
-
}
|
|
3568
|
-
function signaturePreview(spec) {
|
|
3569
|
-
const positional = findPositionalProp(spec);
|
|
3570
|
-
const positionalLabel = positional ? positional.name : "";
|
|
3571
|
-
const rest = spec.props.filter((p) => p.name !== positional?.name).map((p) => `${p.name}${p.optional || !p.required ? "?" : ""}: ${p.type}`).join(", ");
|
|
3572
|
-
if (positionalLabel === "" && rest === "") return `${spec.name}()`;
|
|
3573
|
-
if (positionalLabel === "") return `${spec.name}(${rest})`;
|
|
3574
|
-
if (rest === "") return `${spec.name}(${positionalLabel})`;
|
|
3575
|
-
return `${spec.name}(${positionalLabel}, ${rest})`;
|
|
3576
|
-
}
|
|
3577
|
-
function lineColumnToOffset$1(source, pos) {
|
|
3578
|
-
let line = 1;
|
|
3579
|
-
let col = 1;
|
|
3580
|
-
for (let i = 0; i < source.length; i += 1) {
|
|
3581
|
-
if (line === pos.line && col === pos.column) return i;
|
|
3582
|
-
if (source[i] === "\n") {
|
|
3583
|
-
line += 1;
|
|
3584
|
-
col = 1;
|
|
3585
|
-
} else {
|
|
3586
|
-
col += 1;
|
|
3587
|
-
}
|
|
3606
|
+
applyResponsiveEnumProp(props.align, styleParts, attrs, {
|
|
3607
|
+
attrName: "data-align",
|
|
3608
|
+
responsiveFlag: "data-responsive-align",
|
|
3609
|
+
cssVarPrefix: "--rui-stack-align",
|
|
3610
|
+
defaultToken: alignDefault,
|
|
3611
|
+
mapper: mapFlexAlign
|
|
3612
|
+
});
|
|
3613
|
+
applyResponsiveEnumProp(props.justify, styleParts, attrs, {
|
|
3614
|
+
attrName: "data-justify",
|
|
3615
|
+
responsiveFlag: "data-responsive-justify",
|
|
3616
|
+
cssVarPrefix: "--rui-stack-justify",
|
|
3617
|
+
defaultToken: "start",
|
|
3618
|
+
mapper: mapFlexJustify
|
|
3619
|
+
});
|
|
3620
|
+
const alignContent = asString(props.alignContent);
|
|
3621
|
+
if (alignContent) attrs["data-align-content"] = alignContent;
|
|
3622
|
+
if (padding.kind === "single") {
|
|
3623
|
+
const pad = padding.value ? normalizeSpacingToken(padding.value, String(padding.value)) : null;
|
|
3624
|
+
if (pad) attrs["data-padding"] = pad;
|
|
3625
|
+
} else {
|
|
3626
|
+
attrs["data-padding"] = "responsive";
|
|
3627
|
+
attrs["data-responsive-padding"] = "true";
|
|
3628
|
+
emitResponsiveSpacingVars(styleParts, padding, "--rui-stack-padding");
|
|
3588
3629
|
}
|
|
3589
|
-
|
|
3630
|
+
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
3631
|
+
const root = el("div", attrs);
|
|
3632
|
+
for (const child of asArray(props.children)) {
|
|
3633
|
+
root.append(helpers.renderNode(child));
|
|
3634
|
+
}
|
|
3635
|
+
return root;
|
|
3590
3636
|
}
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
}
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3637
|
+
const FLEX_GAP_PROP = { name: "gap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Spacing between children. May be a responsive map." };
|
|
3638
|
+
const FLEX_JUSTIFY_PROP = { name: "justify", type: "string | object", optional: true, enum: ["start", "center", "end", "between", "around", "evenly"], description: "Main-axis distribution. May be a responsive map." };
|
|
3639
|
+
const FLEX_WRAP_PROP = { name: "wrap", type: "boolean", optional: true, description: "Wrap children onto multiple lines when they overflow" };
|
|
3640
|
+
const FLEX_REVERSE_PROP = { name: "reverse", type: "boolean", optional: true, description: "Reverse the visual order of children" };
|
|
3641
|
+
const FLEX_PADDING_PROP = { name: "padding", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Inner padding token. May be a responsive map." };
|
|
3642
|
+
const FLEX_INLINE_PROP = { name: "inline", type: "boolean", optional: true, description: "Use inline-flex (shrink-to-fit) instead of a full-width block" };
|
|
3643
|
+
const FLEX_ALIGN_CONTENT_PROP = { name: "alignContent", type: "string", optional: true, enum: ["start", "center", "end", "between", "around", "stretch"], description: "Alignment of wrapped lines (only when `wrap` is on)" };
|
|
3644
|
+
const Row = {
|
|
3645
|
+
name: "Row",
|
|
3646
|
+
description: "Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",
|
|
3647
|
+
props: [
|
|
3648
|
+
{ name: "children", type: "Node[]", description: "Children laid out left → right" },
|
|
3649
|
+
{ name: "gap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Horizontal spacing between children (default `md`). May be a responsive map." },
|
|
3650
|
+
{ name: "align", type: "string | object", optional: true, enum: ["start", "center", "end", "stretch"], description: "Vertical alignment of children (default `center`). May be a responsive map." },
|
|
3651
|
+
{ ...FLEX_JUSTIFY_PROP },
|
|
3652
|
+
{ name: "grow", type: "boolean", optional: true, description: "Children share the row width equally (replaces the old `uniform`)" },
|
|
3653
|
+
{ ...FLEX_WRAP_PROP },
|
|
3654
|
+
{ ...FLEX_REVERSE_PROP },
|
|
3655
|
+
{ ...FLEX_PADDING_PROP },
|
|
3656
|
+
{ ...FLEX_INLINE_PROP },
|
|
3657
|
+
{ ...FLEX_ALIGN_CONTENT_PROP }
|
|
3658
|
+
],
|
|
3659
|
+
render: (_node, props, helpers) => renderFlexContainer("row", asBoolean(props.grow), "center", props, helpers)
|
|
3660
|
+
};
|
|
3661
|
+
const Column = {
|
|
3662
|
+
name: "Column",
|
|
3663
|
+
description: "Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",
|
|
3664
|
+
props: [
|
|
3665
|
+
{ name: "children", type: "Node[]", description: "Children laid out top → bottom" },
|
|
3666
|
+
{ name: "gap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Vertical spacing between children (default `md`). May be a responsive map." },
|
|
3667
|
+
{ name: "align", type: "string | object", optional: true, enum: ["start", "center", "end", "stretch"], description: "Horizontal alignment of children (default `stretch`). May be a responsive map." },
|
|
3668
|
+
{ ...FLEX_JUSTIFY_PROP },
|
|
3669
|
+
{ ...FLEX_WRAP_PROP },
|
|
3670
|
+
{ ...FLEX_REVERSE_PROP },
|
|
3671
|
+
{ ...FLEX_PADDING_PROP },
|
|
3672
|
+
{ ...FLEX_INLINE_PROP }
|
|
3673
|
+
],
|
|
3674
|
+
render: (_node, props, helpers) => renderFlexContainer("column", false, "stretch", props, helpers)
|
|
3675
|
+
};
|
|
3676
|
+
const Stack = {
|
|
3677
|
+
name: "Stack",
|
|
3678
|
+
description: 'Low-level flex container with a configurable, optionally responsive `direction`. Reach for `Row` or `Column` first — they are clearer for fixed-direction layouts. Use `Stack` when the direction itself must change across breakpoints, e.g. `direction: {base: "column", md: "row"}` for a sidebar that stacks on mobile. `gap`, `align`, `justify`, and `padding` also accept responsive maps. NOTE: a `row` Stack grows its children equally by default (`uniform=true`); set `uniform=false` for natural widths (this is `Row`\'s default).',
|
|
3679
|
+
props: [
|
|
3680
|
+
{ name: "children", type: "Node[]", description: "Child components to stack" },
|
|
3681
|
+
{ name: "direction", type: "string | object", optional: true, enum: ["column", "row"], description: 'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.' },
|
|
3682
|
+
{ ...FLEX_GAP_PROP },
|
|
3683
|
+
{ name: "align", type: "string | object", optional: true, enum: ["start", "center", "end", "stretch"], description: "Cross-axis alignment (default stretch). May be a responsive map." },
|
|
3684
|
+
{ ...FLEX_JUSTIFY_PROP },
|
|
3685
|
+
{ ...FLEX_ALIGN_CONTENT_PROP },
|
|
3686
|
+
{ ...FLEX_WRAP_PROP },
|
|
3687
|
+
{ ...FLEX_REVERSE_PROP },
|
|
3688
|
+
{ name: "uniform", type: "boolean", optional: true, description: "Row children share space equally (default true for row stacks; use `Row` for natural widths)" },
|
|
3689
|
+
{ ...FLEX_INLINE_PROP },
|
|
3690
|
+
{ ...FLEX_PADDING_PROP }
|
|
3691
|
+
],
|
|
3692
|
+
render: (_node, props, helpers) => {
|
|
3693
|
+
const baseDir = stackBaseDirection(props);
|
|
3694
|
+
const uniformDefault = baseDir === "row";
|
|
3695
|
+
const uniform = props.uniform === void 0 ? uniformDefault : asBoolean(props.uniform, uniformDefault);
|
|
3696
|
+
return renderFlexContainer(props.direction, uniform, "stretch", props, helpers);
|
|
3630
3697
|
}
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
}
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
if (!sym) return refs;
|
|
3650
|
-
return refs.filter((r) => !rangesEqual(r, sym.range));
|
|
3651
|
-
}
|
|
3652
|
-
function getDocumentHighlights(source, position) {
|
|
3653
|
-
return getReferences(source, position, { includeDeclaration: true });
|
|
3654
|
-
}
|
|
3655
|
-
function getRenameEdits(source, position, newName) {
|
|
3656
|
-
const tokens = tokenize(source);
|
|
3657
|
-
const tok = findNameTokenAt(tokens, position);
|
|
3658
|
-
if (!tok) return { edits: [], error: "No symbol to rename at this position." };
|
|
3659
|
-
const sym = resolveSymbol(tokens, tok);
|
|
3660
|
-
if (!sym) {
|
|
3661
|
-
return {
|
|
3662
|
-
edits: [],
|
|
3663
|
-
error: "Only file-scoped components, actions, hooks, and reactive atoms can be renamed."
|
|
3698
|
+
};
|
|
3699
|
+
const Center = {
|
|
3700
|
+
name: "Center",
|
|
3701
|
+
description: 'Centers its children on both axes — the easy way to drop a spinner, an empty state, a hero call-to-action, or a modal body into the middle of a region. Give it `minHeight` (e.g. `"60vh"`) to center vertically inside a tall area, or `axis` to center on only one axis. Multiple children stack in a column and are centered as a group.',
|
|
3702
|
+
props: [
|
|
3703
|
+
{ name: "children", type: "Node[]", description: "Content to center" },
|
|
3704
|
+
{ name: "axis", type: "string", optional: true, enum: ["both", "horizontal", "vertical"], description: "Which axis to center on (default both)" },
|
|
3705
|
+
{ name: "minHeight", type: "string", optional: true, description: "CSS min-height — set to center vertically inside a tall region (e.g. `60vh`, `400px`)" },
|
|
3706
|
+
{ name: "gap", type: "string", optional: true, enum: SPACING_TOKENS, description: "Spacing between stacked children (default `md`)" },
|
|
3707
|
+
{ name: "padding", type: "string", optional: true, enum: SPACING_TOKENS, description: "Inner padding token" },
|
|
3708
|
+
{ name: "inline", type: "boolean", optional: true, description: "Shrink to fit content instead of filling the available width" }
|
|
3709
|
+
],
|
|
3710
|
+
render: (_node, props, helpers) => {
|
|
3711
|
+
const attrs = {
|
|
3712
|
+
class: "rui-center",
|
|
3713
|
+
"data-axis": asString(props.axis, "both"),
|
|
3714
|
+
"data-gap": normalizeSpacingToken(props.gap, "md"),
|
|
3715
|
+
"data-inline": asBoolean(props.inline) ? "true" : null
|
|
3664
3716
|
};
|
|
3717
|
+
const padding = normalizeSpacingToken(props.padding, asString(props.padding));
|
|
3718
|
+
if (padding) attrs["data-padding"] = padding;
|
|
3719
|
+
const styleParts = [];
|
|
3720
|
+
const minHeight = asString(props.minHeight);
|
|
3721
|
+
if (minHeight) styleParts.push(`min-height:${sanitiseCssLength(minHeight, minHeight)}`);
|
|
3722
|
+
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
3723
|
+
const root = el("div", attrs);
|
|
3724
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
3725
|
+
return root;
|
|
3665
3726
|
}
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3727
|
+
};
|
|
3728
|
+
const Card = {
|
|
3729
|
+
name: "Card",
|
|
3730
|
+
description: "Vertical card container.",
|
|
3731
|
+
props: [
|
|
3732
|
+
{ name: "children", type: "Node[]", description: "Card contents" },
|
|
3733
|
+
{ name: "variant", type: "string", optional: true, enum: ["default", "outlined", "elevated"] }
|
|
3734
|
+
],
|
|
3735
|
+
render: (_node, props, helpers) => {
|
|
3736
|
+
const root = el("div", {
|
|
3737
|
+
class: "rui-card",
|
|
3738
|
+
"data-variant": asString(props.variant, "default")
|
|
3739
|
+
});
|
|
3740
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
3741
|
+
return root;
|
|
3669
3742
|
}
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
}
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
range: decl.range,
|
|
3685
|
-
selectionRange: decl.range
|
|
3686
|
-
}));
|
|
3687
|
-
}
|
|
3688
|
-
function resolveSymbol(tokens, tok) {
|
|
3689
|
-
const table = collectSymbols(tokens);
|
|
3690
|
-
if (tok.type === "StateIdentifier") return table.state.get(tok.value) ?? null;
|
|
3691
|
-
return table.ident.get(tok.value) ?? null;
|
|
3692
|
-
}
|
|
3693
|
-
function collectSymbols(tokens) {
|
|
3694
|
-
const table = { state: /* @__PURE__ */ new Map(), ident: /* @__PURE__ */ new Map(), all: [] };
|
|
3695
|
-
const add = (decl) => {
|
|
3696
|
-
const bucket = decl.sigil ? table.state : table.ident;
|
|
3697
|
-
if (bucket.has(decl.name)) return;
|
|
3698
|
-
bucket.set(decl.name, decl);
|
|
3699
|
-
table.all.push(decl);
|
|
3700
|
-
};
|
|
3701
|
-
let depth = 0;
|
|
3702
|
-
let stmtStart = true;
|
|
3703
|
-
for (let i = 0; i < tokens.length; i += 1) {
|
|
3704
|
-
const t = tokens[i];
|
|
3705
|
-
if (t.type === "Newline" || t.type === "Semicolon") {
|
|
3706
|
-
stmtStart = true;
|
|
3707
|
-
continue;
|
|
3708
|
-
}
|
|
3709
|
-
if (t.type === "EOF") break;
|
|
3710
|
-
if (t.type === "Keyword" && t.value === "import") {
|
|
3711
|
-
i = scanImport(tokens, i, add);
|
|
3712
|
-
stmtStart = true;
|
|
3713
|
-
continue;
|
|
3714
|
-
}
|
|
3715
|
-
if (t.type === "Keyword" && t.value === "function") {
|
|
3716
|
-
const nameTok = nextMeaningful$1(tokens, i + 1);
|
|
3717
|
-
if (nameTok) {
|
|
3718
|
-
if (nameTok.type === "StateIdentifier") {
|
|
3719
|
-
add({ name: nameTok.value, kind: "hook", sigil: true, range: tokenRange(nameTok) });
|
|
3720
|
-
} else if (nameTok.type === "Identifier") {
|
|
3721
|
-
add({
|
|
3722
|
-
name: nameTok.value,
|
|
3723
|
-
kind: isPascalCase(nameTok.value) ? "component" : "action",
|
|
3724
|
-
sigil: false,
|
|
3725
|
-
range: tokenRange(nameTok)
|
|
3726
|
-
});
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
}
|
|
3730
|
-
if (t.type === "StateIdentifier" && stmtStart && depth === 0) {
|
|
3731
|
-
const next = nextMeaningful$1(tokens, i + 1);
|
|
3732
|
-
if (next && next.type === "Operator" && next.value === "=") {
|
|
3733
|
-
add({ name: t.value, kind: "state", sigil: true, range: tokenRange(t) });
|
|
3734
|
-
}
|
|
3735
|
-
}
|
|
3736
|
-
if (t.type === "Punctuation" && t.value === "{") {
|
|
3737
|
-
depth += 1;
|
|
3738
|
-
stmtStart = true;
|
|
3739
|
-
} else if (t.type === "Punctuation" && t.value === "}") {
|
|
3740
|
-
depth = Math.max(0, depth - 1);
|
|
3741
|
-
stmtStart = true;
|
|
3742
|
-
} else if (t.type === "Keyword" && t.value === "export") ;
|
|
3743
|
-
else {
|
|
3744
|
-
stmtStart = false;
|
|
3745
|
-
}
|
|
3743
|
+
};
|
|
3744
|
+
const CardHeader = {
|
|
3745
|
+
name: "CardHeader",
|
|
3746
|
+
description: "Card header with title and optional subtitle.",
|
|
3747
|
+
props: [
|
|
3748
|
+
{ name: "title", type: "string" },
|
|
3749
|
+
{ name: "subtitle", type: "string", optional: true }
|
|
3750
|
+
],
|
|
3751
|
+
render: (_node, props) => {
|
|
3752
|
+
const root = el("header", { class: "rui-card-header" });
|
|
3753
|
+
root.append(el("h3", { class: "rui-card-title" }, [asString(props.title)]));
|
|
3754
|
+
const subtitle = asString(props.subtitle);
|
|
3755
|
+
if (subtitle) root.append(el("p", { class: "rui-card-subtitle" }, [subtitle]));
|
|
3756
|
+
return root;
|
|
3746
3757
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3758
|
+
};
|
|
3759
|
+
const CardFooter = {
|
|
3760
|
+
name: "CardFooter",
|
|
3761
|
+
description: "Card footer for actions.",
|
|
3762
|
+
props: [{ name: "children", type: "Node[]" }],
|
|
3763
|
+
render: (_node, props, helpers) => {
|
|
3764
|
+
const root = el("footer", { class: "rui-card-footer" });
|
|
3765
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
3766
|
+
return root;
|
|
3753
3767
|
}
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3768
|
+
};
|
|
3769
|
+
const Separator = {
|
|
3770
|
+
name: "Separator",
|
|
3771
|
+
description: "Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",
|
|
3772
|
+
props: [
|
|
3773
|
+
{ name: "orientation", type: "string", optional: true, enum: ["horizontal", "vertical"] },
|
|
3774
|
+
{ name: "label", type: "string", optional: true, description: "Optional label rendered in the middle (horizontal only)" },
|
|
3775
|
+
{ name: "decorative", type: "boolean", optional: true, description: "Hides the separator from assistive tech when true (default)" }
|
|
3776
|
+
],
|
|
3777
|
+
render: (_node, props) => {
|
|
3778
|
+
const orientation = asString(props.orientation, "horizontal");
|
|
3779
|
+
const decorative = asBoolean(props.decorative, true);
|
|
3780
|
+
const label = asString(props.label);
|
|
3781
|
+
if (label && orientation === "horizontal") {
|
|
3782
|
+
return el("div", {
|
|
3783
|
+
class: "rui-separator rui-separator-with-label",
|
|
3784
|
+
"data-orientation": orientation,
|
|
3785
|
+
role: decorative ? "presentation" : "separator",
|
|
3786
|
+
"aria-orientation": decorative ? null : orientation
|
|
3787
|
+
}, [
|
|
3788
|
+
el("span", { class: "rui-separator-line" }),
|
|
3789
|
+
el("span", { class: "rui-separator-label" }, [label]),
|
|
3790
|
+
el("span", { class: "rui-separator-line" })
|
|
3791
|
+
]);
|
|
3763
3792
|
}
|
|
3793
|
+
return el("div", {
|
|
3794
|
+
class: "rui-separator",
|
|
3795
|
+
"data-orientation": orientation,
|
|
3796
|
+
role: decorative ? "presentation" : "separator",
|
|
3797
|
+
"aria-orientation": decorative ? null : orientation
|
|
3798
|
+
});
|
|
3764
3799
|
}
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3800
|
+
};
|
|
3801
|
+
const renderStepLi = (title, details, active = false) => {
|
|
3802
|
+
const root = el("li", {
|
|
3803
|
+
class: "rui-steps-item",
|
|
3804
|
+
"data-active": active ? "true" : "false"
|
|
3805
|
+
});
|
|
3806
|
+
root.append(el("div", { class: "rui-steps-title" }, [title]));
|
|
3807
|
+
if (details) root.append(el("div", { class: "rui-steps-details" }, [details]));
|
|
3808
|
+
return root;
|
|
3809
|
+
};
|
|
3810
|
+
const Steps = {
|
|
3811
|
+
name: "Steps",
|
|
3812
|
+
description: "Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",
|
|
3813
|
+
props: [
|
|
3814
|
+
{ name: "items", type: "object[]" }
|
|
3815
|
+
],
|
|
3816
|
+
render: (_node, props, helpers) => {
|
|
3817
|
+
const root = el("ol", { class: "rui-steps" });
|
|
3818
|
+
for (const item of asArray(props.items)) {
|
|
3819
|
+
if (item && typeof item === "object" && item.__kind === "Component") {
|
|
3820
|
+
root.append(helpers.renderNode(item));
|
|
3821
|
+
continue;
|
|
3783
3822
|
}
|
|
3784
|
-
|
|
3823
|
+
if (item && typeof item === "object") {
|
|
3824
|
+
const data = item;
|
|
3825
|
+
root.append(renderStepLi(
|
|
3826
|
+
asString(data.title),
|
|
3827
|
+
asString(data.details),
|
|
3828
|
+
asBoolean(data.active)
|
|
3829
|
+
));
|
|
3830
|
+
continue;
|
|
3831
|
+
}
|
|
3832
|
+
root.append(renderStepLi(asString(item), ""));
|
|
3785
3833
|
}
|
|
3786
|
-
|
|
3787
|
-
if (t.type === "Identifier" || t.type === "StateIdentifier") names.push(t);
|
|
3834
|
+
return root;
|
|
3788
3835
|
}
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3836
|
+
};
|
|
3837
|
+
const TabItem = {
|
|
3838
|
+
name: "TabItem",
|
|
3839
|
+
description: "Single tab definition (used inside Tabs). Add `badge` for a count chip in the tab trigger, and `icon` for a leading Font Awesome icon.",
|
|
3840
|
+
props: [
|
|
3841
|
+
{ name: "value", type: "string", description: "Stable identifier for the tab" },
|
|
3842
|
+
{ name: "label", type: "string", description: "Display label" },
|
|
3843
|
+
{ name: "children", type: "Node[]", description: "Tab content" },
|
|
3844
|
+
{ name: "badge", type: "string", optional: true, description: "Trailing chip rendered in the tab trigger (count / status)" },
|
|
3845
|
+
{ name: "icon", type: "string", optional: true, description: "Optional Font Awesome icon name shown before the label" }
|
|
3846
|
+
],
|
|
3847
|
+
render: (_node, props, helpers) => {
|
|
3848
|
+
const wrapper = el("div", {
|
|
3849
|
+
class: "rui-tab-content",
|
|
3850
|
+
role: "tabpanel",
|
|
3851
|
+
"data-value": asString(props.value),
|
|
3852
|
+
"data-active": "false"
|
|
3853
|
+
});
|
|
3854
|
+
for (const child of asArray(props.children)) wrapper.append(helpers.renderNode(child));
|
|
3855
|
+
return wrapper;
|
|
3856
|
+
}
|
|
3857
|
+
};
|
|
3858
|
+
const Tabs = {
|
|
3859
|
+
name: "Tabs",
|
|
3860
|
+
description: 'Tabbed container. Children must be TabItem components. Supports `orientation="vertical"` for sidebar-style tabs and built-in keyboard navigation (←/→ or ↑/↓, Home, End). Provide `onChange` to react when the user switches tabs (called with the new tab\'s value).',
|
|
3861
|
+
props: [
|
|
3862
|
+
{ name: "items", type: "TabItem[]", description: "Tab definitions" },
|
|
3863
|
+
{ name: "defaultValue", type: "string", optional: true, description: "Initially active tab value" },
|
|
3864
|
+
{ name: "orientation", type: "string", optional: true, enum: ["horizontal", "vertical"], description: "Layout direction (default `horizontal`)" },
|
|
3865
|
+
{ name: "onChange", type: "callable", optional: true, aliases: ["onchange"], description: "Called with the newly-activated tab value when the user switches tabs" }
|
|
3866
|
+
],
|
|
3867
|
+
render: (_node, props, helpers) => {
|
|
3868
|
+
const items = asArray(props.items);
|
|
3869
|
+
const orientation = asString(props.orientation, "horizontal");
|
|
3870
|
+
const root = el("div", { class: "rui-tabs", "data-orientation": orientation });
|
|
3871
|
+
const tablist = el("div", {
|
|
3872
|
+
class: "rui-tab-list",
|
|
3873
|
+
role: "tablist",
|
|
3874
|
+
"aria-orientation": orientation
|
|
3875
|
+
});
|
|
3876
|
+
const panels = el("div", { class: "rui-tab-panels" });
|
|
3877
|
+
let fallbackValue = asString(props.defaultValue);
|
|
3878
|
+
if (!fallbackValue && items.length > 0) {
|
|
3879
|
+
const first = items[0];
|
|
3880
|
+
fallbackValue = asString(first?.args?.[0], "tab-0");
|
|
3881
|
+
}
|
|
3882
|
+
const activeSlot = helpers.useInstanceState("activeTab", fallbackValue);
|
|
3883
|
+
if (asString(props.defaultValue) && asString(props.defaultValue) !== fallbackValue) {
|
|
3884
|
+
activeSlot.set(asString(props.defaultValue));
|
|
3885
|
+
}
|
|
3886
|
+
const validValues = new Set(
|
|
3887
|
+
items.map((item, idx) => asString(item.args?.[0], `tab-${idx}`))
|
|
3888
|
+
);
|
|
3889
|
+
if (!validValues.has(activeSlot.get())) {
|
|
3890
|
+
activeSlot.set(fallbackValue);
|
|
3809
3891
|
}
|
|
3892
|
+
const setActive = (next, originBtn) => {
|
|
3893
|
+
const previous = activeSlot.get();
|
|
3894
|
+
activeSlot.set(next);
|
|
3895
|
+
const liveRoot = originBtn.closest(".rui-tabs");
|
|
3896
|
+
if (liveRoot) {
|
|
3897
|
+
liveRoot.querySelectorAll(".rui-tab-trigger").forEach((b) => {
|
|
3898
|
+
const isActive = b.getAttribute("data-value") === next;
|
|
3899
|
+
b.setAttribute("aria-selected", isActive ? "true" : "false");
|
|
3900
|
+
b.tabIndex = isActive ? 0 : -1;
|
|
3901
|
+
});
|
|
3902
|
+
liveRoot.querySelectorAll(".rui-tab-content").forEach((p) => {
|
|
3903
|
+
p.setAttribute("data-active", p.getAttribute("data-value") === next ? "true" : "false");
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3906
|
+
if (previous !== next) helpers.invoke(props.onChange, next);
|
|
3907
|
+
};
|
|
3908
|
+
items.forEach((item, idx) => {
|
|
3909
|
+
const tabNode = item;
|
|
3910
|
+
const value = asString(tabNode.args?.[0], `tab-${idx}`);
|
|
3911
|
+
const label = asString(tabNode.args?.[1], `Tab ${idx + 1}`);
|
|
3912
|
+
const badge = asString(tabNode.args?.[3]);
|
|
3913
|
+
const icon = asString(tabNode.args?.[4]);
|
|
3914
|
+
const isActive = value === activeSlot.get();
|
|
3915
|
+
const button = el(
|
|
3916
|
+
"button",
|
|
3917
|
+
{
|
|
3918
|
+
class: "rui-tab-trigger",
|
|
3919
|
+
role: "tab",
|
|
3920
|
+
type: "button",
|
|
3921
|
+
"data-value": value,
|
|
3922
|
+
"aria-selected": isActive ? "true" : "false",
|
|
3923
|
+
tabindex: isActive ? "0" : "-1"
|
|
3924
|
+
}
|
|
3925
|
+
);
|
|
3926
|
+
const iconNode = icon ? renderIconForTab(icon) : null;
|
|
3927
|
+
if (iconNode) button.append(iconNode);
|
|
3928
|
+
button.append(el("span", { class: "rui-tab-trigger-label" }, [label]));
|
|
3929
|
+
if (badge) button.append(el("span", { class: "rui-tab-trigger-badge" }, [badge]));
|
|
3930
|
+
button.onclick = (event) => {
|
|
3931
|
+
const origin = event.currentTarget ?? event.target;
|
|
3932
|
+
setActive(value, origin);
|
|
3933
|
+
};
|
|
3934
|
+
button.onkeydown = (event) => {
|
|
3935
|
+
const e = event;
|
|
3936
|
+
const horizontal = orientation !== "vertical";
|
|
3937
|
+
const isNext = horizontal ? e.key === "ArrowRight" : e.key === "ArrowDown";
|
|
3938
|
+
const isPrev = horizontal ? e.key === "ArrowLeft" : e.key === "ArrowUp";
|
|
3939
|
+
if (!isNext && !isPrev && e.key !== "Home" && e.key !== "End") return;
|
|
3940
|
+
e.preventDefault();
|
|
3941
|
+
const origin = e.currentTarget ?? e.target;
|
|
3942
|
+
const liveList = origin.closest(".rui-tab-list");
|
|
3943
|
+
if (!liveList) return;
|
|
3944
|
+
const triggers = Array.from(liveList.querySelectorAll(".rui-tab-trigger"));
|
|
3945
|
+
if (triggers.length === 0) return;
|
|
3946
|
+
const currentIdx = triggers.indexOf(origin);
|
|
3947
|
+
let nextIdx = currentIdx;
|
|
3948
|
+
if (e.key === "Home") nextIdx = 0;
|
|
3949
|
+
else if (e.key === "End") nextIdx = triggers.length - 1;
|
|
3950
|
+
else if (isNext) nextIdx = (currentIdx + 1) % triggers.length;
|
|
3951
|
+
else if (isPrev) nextIdx = (currentIdx - 1 + triggers.length) % triggers.length;
|
|
3952
|
+
const target = triggers[nextIdx];
|
|
3953
|
+
if (!target) return;
|
|
3954
|
+
target.focus();
|
|
3955
|
+
const nextValue = target.getAttribute("data-value") ?? "";
|
|
3956
|
+
if (nextValue) setActive(nextValue, target);
|
|
3957
|
+
};
|
|
3958
|
+
tablist.append(button);
|
|
3959
|
+
const panel = helpers.renderNode(item);
|
|
3960
|
+
panel.setAttribute("data-value", value);
|
|
3961
|
+
panel.setAttribute("data-active", isActive ? "true" : "false");
|
|
3962
|
+
panels.append(panel);
|
|
3963
|
+
});
|
|
3964
|
+
root.append(tablist, panels);
|
|
3965
|
+
return root;
|
|
3810
3966
|
}
|
|
3811
|
-
|
|
3967
|
+
};
|
|
3968
|
+
function renderIconForTab(iconName) {
|
|
3969
|
+
return renderIcon(iconName, { className: "rui-tab-trigger-icon" });
|
|
3812
3970
|
}
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
if (
|
|
3829
|
-
const
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
}
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
function nextMeaningful$1(tokens, from) {
|
|
3838
|
-
for (let i = from; i < tokens.length; i += 1) {
|
|
3839
|
-
const t = tokens[i];
|
|
3840
|
-
if (t.type === "Newline") continue;
|
|
3841
|
-
return t;
|
|
3842
|
-
}
|
|
3843
|
-
return null;
|
|
3844
|
-
}
|
|
3845
|
-
function tokenTextLength(t) {
|
|
3846
|
-
return t.type === "StateIdentifier" ? t.value.length + 1 : t.value.length;
|
|
3847
|
-
}
|
|
3848
|
-
function tokenRange(t) {
|
|
3849
|
-
const length = tokenTextLength(t);
|
|
3850
|
-
return {
|
|
3851
|
-
start: { line: t.line, column: t.column },
|
|
3852
|
-
end: { line: t.line, column: t.column + length }
|
|
3853
|
-
};
|
|
3854
|
-
}
|
|
3855
|
-
function rangesEqual(a, b) {
|
|
3856
|
-
return a.start.line === b.start.line && a.start.column === b.start.column && a.end.line === b.end.line && a.end.column === b.end.column;
|
|
3857
|
-
}
|
|
3858
|
-
function isPascalCase(name) {
|
|
3859
|
-
return /^[A-Z]/.test(name);
|
|
3860
|
-
}
|
|
3861
|
-
function detailFor(kind) {
|
|
3862
|
-
switch (kind) {
|
|
3863
|
-
case "component":
|
|
3864
|
-
return "component";
|
|
3865
|
-
case "action":
|
|
3866
|
-
return "action";
|
|
3867
|
-
case "hook":
|
|
3868
|
-
return "hook";
|
|
3869
|
-
case "state":
|
|
3870
|
-
return "reactive atom";
|
|
3871
|
-
case "import":
|
|
3872
|
-
return "import";
|
|
3873
|
-
default:
|
|
3874
|
-
return "";
|
|
3971
|
+
const AccordionItem = {
|
|
3972
|
+
name: "AccordionItem",
|
|
3973
|
+
description: "Single accordion section.",
|
|
3974
|
+
props: [
|
|
3975
|
+
{ name: "title", type: "string" },
|
|
3976
|
+
{ name: "children", type: "Node[]" },
|
|
3977
|
+
{ name: "open", type: "boolean", optional: true },
|
|
3978
|
+
{ name: "showArrow", type: "boolean", optional: true, description: "Show a chevron icon on the right (default false). Inherits from parent Accordion when unset." }
|
|
3979
|
+
],
|
|
3980
|
+
render: (_node, props, helpers) => {
|
|
3981
|
+
const explicit = props.showArrow !== void 0 && props.showArrow !== null;
|
|
3982
|
+
const details = el("details", {
|
|
3983
|
+
class: "rui-accordion-item",
|
|
3984
|
+
"data-show-arrow": explicit ? asBoolean(props.showArrow) ? "true" : "false" : null
|
|
3985
|
+
});
|
|
3986
|
+
if (asBoolean(props.open)) details.setAttribute("open", "");
|
|
3987
|
+
const summary = el("summary", { class: "rui-accordion-trigger" });
|
|
3988
|
+
summary.append(el("span", { class: "rui-accordion-title" }, [asString(props.title)]));
|
|
3989
|
+
summary.append(el("span", { class: "rui-accordion-chevron", "aria-hidden": "true" }));
|
|
3990
|
+
details.append(summary);
|
|
3991
|
+
const body = el("div", { class: "rui-accordion-body" });
|
|
3992
|
+
for (const child of asArray(props.children)) body.append(helpers.renderNode(child));
|
|
3993
|
+
details.append(body);
|
|
3994
|
+
return details;
|
|
3875
3995
|
}
|
|
3876
|
-
}
|
|
3877
|
-
const GRID_COLUMNS = 12;
|
|
3878
|
-
const FLEX_ALIGN = {
|
|
3879
|
-
start: "flex-start",
|
|
3880
|
-
center: "center",
|
|
3881
|
-
end: "flex-end",
|
|
3882
|
-
stretch: "stretch"
|
|
3883
|
-
};
|
|
3884
|
-
const FLEX_JUSTIFY = {
|
|
3885
|
-
start: "flex-start",
|
|
3886
|
-
center: "center",
|
|
3887
|
-
end: "flex-end",
|
|
3888
|
-
between: "space-between",
|
|
3889
|
-
around: "space-around",
|
|
3890
|
-
evenly: "space-evenly"
|
|
3891
3996
|
};
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
}
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
3907
|
-
const v = prop.values[bp];
|
|
3908
|
-
if (v) styleParts.push(`${cssPrefix}-${bp}:var(--rui-spacing-${v}, ${v})`);
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
function emitResponsiveFlexVars(styleParts, prop, cssPrefix, mapper) {
|
|
3912
|
-
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
3913
|
-
const v = prop.values[bp];
|
|
3914
|
-
if (v) styleParts.push(`${cssPrefix}-${bp}:${mapper(String(v))}`);
|
|
3997
|
+
const Accordion = {
|
|
3998
|
+
name: "Accordion",
|
|
3999
|
+
description: "Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",
|
|
4000
|
+
props: [
|
|
4001
|
+
{ name: "items", type: "AccordionItem[]" },
|
|
4002
|
+
{ name: "showArrow", type: "boolean", optional: true, description: "Show chevron icon on every item (default false)." }
|
|
4003
|
+
],
|
|
4004
|
+
render: (_node, props, helpers) => {
|
|
4005
|
+
const root = el("div", {
|
|
4006
|
+
class: "rui-accordion",
|
|
4007
|
+
"data-show-arrow": asBoolean(props.showArrow) ? "true" : "false"
|
|
4008
|
+
});
|
|
4009
|
+
for (const child of asArray(props.items)) root.append(helpers.renderNode(child));
|
|
4010
|
+
return root;
|
|
3915
4011
|
}
|
|
3916
|
-
}
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
if (
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4012
|
+
};
|
|
4013
|
+
const clampGridColumns = (n) => Math.max(1, Math.min(GRID_COLUMNS, Math.round(n)));
|
|
4014
|
+
function resolveSpan(span) {
|
|
4015
|
+
if (span == null || span === "") return 12;
|
|
4016
|
+
const raw = String(span).trim();
|
|
4017
|
+
if (raw.includes("/")) {
|
|
4018
|
+
const [numPart, denPart] = raw.split("/");
|
|
4019
|
+
const num = Number(numPart);
|
|
4020
|
+
const den = Number(denPart);
|
|
4021
|
+
if (Number.isFinite(num) && Number.isFinite(den) && den > 0) {
|
|
4022
|
+
return clampGridColumns(Math.round(GRID_COLUMNS * num / den));
|
|
4023
|
+
}
|
|
3923
4024
|
}
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
emitResponsiveFlexVars(styleParts, parsed, options.cssVarPrefix, options.mapper);
|
|
3927
|
-
}
|
|
3928
|
-
function isComponentNamed(value, name) {
|
|
3929
|
-
return Boolean(
|
|
3930
|
-
value && typeof value === "object" && value.__kind === "Component" && value.name === name
|
|
3931
|
-
);
|
|
4025
|
+
if (raw === "auto" || raw === "fit" || raw === "auto-fit" || raw === "full" || raw === "100%") return 12;
|
|
4026
|
+
return clampGridColumns(asNumber(span, 12));
|
|
3932
4027
|
}
|
|
3933
|
-
function
|
|
3934
|
-
const
|
|
3935
|
-
|
|
3936
|
-
return direction.value ? String(direction.value) : "column";
|
|
3937
|
-
}
|
|
3938
|
-
return direction.values.base ? String(direction.values.base) : "column";
|
|
4028
|
+
function gridMinChildWidth(props) {
|
|
4029
|
+
const width = asString(props.minChildWidth) || asString(props.minItemWidth);
|
|
4030
|
+
return sanitiseCssLength(width || "220px", "220px");
|
|
3939
4031
|
}
|
|
3940
|
-
const
|
|
3941
|
-
name: "
|
|
3942
|
-
description:
|
|
4032
|
+
const GridItem = {
|
|
4033
|
+
name: "GridItem",
|
|
4034
|
+
description: 'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',
|
|
3943
4035
|
props: [
|
|
3944
|
-
{ name: "child", type: "Node", description: "Child node to
|
|
3945
|
-
{ name: "
|
|
3946
|
-
{ name: "
|
|
3947
|
-
{ name: "
|
|
3948
|
-
{ name: "alignSelf", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Per-item cross-axis alignment" },
|
|
3949
|
-
{ name: "order", type: "number", optional: true, description: "Visual order override" },
|
|
3950
|
-
{ name: "minWidth", type: "string", optional: true, description: "CSS min-width" },
|
|
3951
|
-
{ name: "maxWidth", type: "string", optional: true, description: "CSS max-width" }
|
|
4036
|
+
{ name: "child", type: "Node", description: "Child node to place in the grid" },
|
|
4037
|
+
{ name: "span", type: "number | string", optional: true, description: 'Columns to span (1–12) or fraction like "1/2", "1/3"' },
|
|
4038
|
+
{ name: "offset", type: "number", optional: true, description: "Empty columns before this item (0–11)" },
|
|
4039
|
+
{ name: "spanAt", type: "object", optional: true, description: "Responsive span map `{sm: 12, md: 6, lg: 4}`" }
|
|
3952
4040
|
],
|
|
3953
4041
|
render: (_node, props, helpers) => {
|
|
3954
|
-
const
|
|
3955
|
-
const
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
}
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
} else if (basis) {
|
|
3966
|
-
styleParts.push(`flex-basis:${sanitiseCssLength(basis, basis)}`);
|
|
4042
|
+
const baseSpan = resolveSpan(props.span ?? 12);
|
|
4043
|
+
const spanAt = readResponsiveProp(props.spanAt);
|
|
4044
|
+
const offset = props.offset === void 0 || props.offset === null ? 0 : Math.max(0, Math.min(GRID_COLUMNS - 1, Math.round(asNumber(props.offset, 0))));
|
|
4045
|
+
const attrs = {
|
|
4046
|
+
class: "rui-grid-item",
|
|
4047
|
+
"data-span": String(baseSpan)
|
|
4048
|
+
};
|
|
4049
|
+
const styleParts = [`--rui-grid-item-span:${baseSpan}`];
|
|
4050
|
+
if (offset > 0) {
|
|
4051
|
+
attrs["data-offset"] = String(offset);
|
|
4052
|
+
styleParts.push(`--rui-grid-item-offset:${offset}`);
|
|
3967
4053
|
}
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
4054
|
+
if (spanAt.kind === "responsive") {
|
|
4055
|
+
attrs["data-responsive-span"] = "true";
|
|
4056
|
+
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
4057
|
+
const v = spanAt.values[bp];
|
|
4058
|
+
if (v !== void 0) {
|
|
4059
|
+
const resolved = resolveSpan(v);
|
|
4060
|
+
styleParts.push(`--rui-grid-item-span-${bp}:${resolved}`);
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
} else if (spanAt.kind === "single" && spanAt.value != null) {
|
|
4064
|
+
const resolved = resolveSpan(spanAt.value);
|
|
4065
|
+
styleParts.push(`--rui-grid-item-span:${resolved}`);
|
|
4066
|
+
attrs["data-span"] = String(resolved);
|
|
3974
4067
|
}
|
|
3975
|
-
|
|
3976
|
-
if (minWidth) styleParts.push(`min-width:${sanitiseCssLength(minWidth, minWidth)}`);
|
|
3977
|
-
const maxWidth = asString(props.maxWidth);
|
|
3978
|
-
if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);
|
|
3979
|
-
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
4068
|
+
attrs.style = styleParts.join(";");
|
|
3980
4069
|
const root = el("div", attrs);
|
|
3981
4070
|
root.append(helpers.renderNode(props.child));
|
|
3982
4071
|
return root;
|
|
3983
4072
|
}
|
|
3984
4073
|
};
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
const padding = readResponsiveProp(props.padding);
|
|
3989
|
-
const reverse = asBoolean(props.reverse);
|
|
3990
|
-
const attrs = {
|
|
3991
|
-
class: "rui-stack",
|
|
3992
|
-
"data-wrap": asBoolean(props.wrap) ? "true" : null,
|
|
3993
|
-
"data-reverse": reverse ? "true" : null,
|
|
3994
|
-
"data-uniform": uniform ? "true" : "false",
|
|
3995
|
-
"data-inline": asBoolean(props.inline) ? "true" : null
|
|
3996
|
-
};
|
|
3997
|
-
const styleParts = [];
|
|
3998
|
-
if (direction.kind === "single") {
|
|
3999
|
-
const dir = direction.value ? String(direction.value) : "column";
|
|
4000
|
-
attrs["data-direction"] = applyDirectionWithReverse(dir, reverse);
|
|
4001
|
-
} else {
|
|
4002
|
-
attrs["data-direction"] = "responsive";
|
|
4003
|
-
attrs["data-responsive-dir"] = "true";
|
|
4004
|
-
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
4005
|
-
const v = direction.values[bp];
|
|
4006
|
-
if (v) styleParts.push(`--rui-stack-dir-${bp}:${applyDirectionWithReverse(String(v), reverse)}`);
|
|
4007
|
-
}
|
|
4008
|
-
}
|
|
4009
|
-
if (gap.kind === "single") {
|
|
4010
|
-
attrs["data-gap"] = gap.value ? String(gap.value) : "m";
|
|
4011
|
-
} else {
|
|
4012
|
-
attrs["data-gap"] = "responsive";
|
|
4013
|
-
attrs["data-responsive-gap"] = "true";
|
|
4014
|
-
emitResponsiveSpacingVars(styleParts, gap, "--rui-stack-gap");
|
|
4015
|
-
}
|
|
4016
|
-
applyResponsiveEnumProp(props.align, styleParts, attrs, {
|
|
4017
|
-
attrName: "data-align",
|
|
4018
|
-
responsiveFlag: "data-responsive-align",
|
|
4019
|
-
cssVarPrefix: "--rui-stack-align",
|
|
4020
|
-
defaultToken: alignDefault,
|
|
4021
|
-
mapper: mapFlexAlign
|
|
4022
|
-
});
|
|
4023
|
-
applyResponsiveEnumProp(props.justify, styleParts, attrs, {
|
|
4024
|
-
attrName: "data-justify",
|
|
4025
|
-
responsiveFlag: "data-responsive-justify",
|
|
4026
|
-
cssVarPrefix: "--rui-stack-justify",
|
|
4027
|
-
defaultToken: "start",
|
|
4028
|
-
mapper: mapFlexJustify
|
|
4029
|
-
});
|
|
4030
|
-
const alignContent = asString(props.alignContent);
|
|
4031
|
-
if (alignContent) attrs["data-align-content"] = alignContent;
|
|
4032
|
-
if (padding.kind === "single") {
|
|
4033
|
-
const pad = padding.value ? String(padding.value) : null;
|
|
4034
|
-
if (pad) attrs["data-padding"] = pad;
|
|
4035
|
-
} else {
|
|
4036
|
-
attrs["data-padding"] = "responsive";
|
|
4037
|
-
attrs["data-responsive-padding"] = "true";
|
|
4038
|
-
emitResponsiveSpacingVars(styleParts, padding, "--rui-stack-padding");
|
|
4039
|
-
}
|
|
4040
|
-
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
4041
|
-
const root = el("div", attrs);
|
|
4042
|
-
for (const child of asArray(props.children)) {
|
|
4043
|
-
root.append(helpers.renderNode(child));
|
|
4044
|
-
}
|
|
4045
|
-
return root;
|
|
4046
|
-
}
|
|
4047
|
-
const FLEX_GAP_PROP = { name: "gap", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Spacing between children. May be a responsive map." };
|
|
4048
|
-
const FLEX_JUSTIFY_PROP = { name: "justify", type: "string | object", optional: true, enum: ["start", "center", "end", "between", "around", "evenly"], description: "Main-axis distribution. May be a responsive map." };
|
|
4049
|
-
const FLEX_WRAP_PROP = { name: "wrap", type: "boolean", optional: true, description: "Wrap children onto multiple lines when they overflow" };
|
|
4050
|
-
const FLEX_REVERSE_PROP = { name: "reverse", type: "boolean", optional: true, description: "Reverse the visual order of children" };
|
|
4051
|
-
const FLEX_PADDING_PROP = { name: "padding", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Inner padding token. May be a responsive map." };
|
|
4052
|
-
const FLEX_INLINE_PROP = { name: "inline", type: "boolean", optional: true, description: "Use inline-flex (shrink-to-fit) instead of a full-width block" };
|
|
4053
|
-
const FLEX_ALIGN_CONTENT_PROP = { name: "alignContent", type: "string", optional: true, enum: ["start", "center", "end", "between", "around", "stretch"], description: "Alignment of wrapped lines (only when `wrap` is on)" };
|
|
4054
|
-
const Row = {
|
|
4055
|
-
name: "Row",
|
|
4056
|
-
description: "Lay children out horizontally (left → right) with even spacing. The developer-friendly default: children keep their natural width and are vertically centered. Set `grow=true` to make children share the row equally (for equal-width columns prefer `Grid(columns: N)`); drop a `Spacer()` between children to push them apart; wrap a child in `StackItem` for per-child grow/shrink/alignment. Use `wrap=true` for chips/tags that should flow onto multiple lines.",
|
|
4057
|
-
props: [
|
|
4058
|
-
{ name: "children", type: "Node[]", description: "Children laid out left → right" },
|
|
4059
|
-
{ name: "gap", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Horizontal spacing between children (default `m`). May be a responsive map." },
|
|
4060
|
-
{ name: "align", type: "string | object", optional: true, enum: ["start", "center", "end", "stretch"], description: "Vertical alignment of children (default `center`). May be a responsive map." },
|
|
4061
|
-
{ ...FLEX_JUSTIFY_PROP },
|
|
4062
|
-
{ name: "grow", type: "boolean", optional: true, description: "Children share the row width equally (replaces the old `uniform`)" },
|
|
4063
|
-
{ ...FLEX_WRAP_PROP },
|
|
4064
|
-
{ ...FLEX_REVERSE_PROP },
|
|
4065
|
-
{ ...FLEX_PADDING_PROP },
|
|
4066
|
-
{ ...FLEX_INLINE_PROP },
|
|
4067
|
-
{ ...FLEX_ALIGN_CONTENT_PROP }
|
|
4068
|
-
],
|
|
4069
|
-
render: (_node, props, helpers) => renderFlexContainer("row", asBoolean(props.grow), "center", props, helpers)
|
|
4070
|
-
};
|
|
4071
|
-
const Column = {
|
|
4072
|
-
name: "Column",
|
|
4073
|
-
description: "Lay children out vertically (top → bottom) with even spacing — the most common page/section layout. Children stretch to the full width by default; set `align` to `start`/`center`/`end` to change that. This is the recommended root container for a page or a card body.",
|
|
4074
|
+
const Box = {
|
|
4075
|
+
name: "Box",
|
|
4076
|
+
description: "Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",
|
|
4074
4077
|
props: [
|
|
4075
|
-
{ name: "children", type: "Node[]"
|
|
4076
|
-
{ name: "
|
|
4077
|
-
{ name: "
|
|
4078
|
-
{
|
|
4079
|
-
{
|
|
4080
|
-
{
|
|
4081
|
-
{ ...FLEX_PADDING_PROP },
|
|
4082
|
-
{ ...FLEX_INLINE_PROP }
|
|
4078
|
+
{ name: "children", type: "Node[]" },
|
|
4079
|
+
{ name: "padding", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Inner padding. May be a responsive map." },
|
|
4080
|
+
{ name: "margin", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Outer margin. May be a responsive map." },
|
|
4081
|
+
{ name: "border", type: "string", optional: true, enum: ["none", "subtle", "default"], description: "Border preset (default none)" },
|
|
4082
|
+
{ name: "background", type: "string", optional: true, enum: ["none", "surface", "muted", "primary", "success", "warning", "danger", "info"], description: "Semantic background token" },
|
|
4083
|
+
{ name: "maxWidth", type: "string", optional: true, description: "CSS max-width" }
|
|
4083
4084
|
],
|
|
4084
|
-
render: (_node, props, helpers) =>
|
|
4085
|
+
render: (_node, props, helpers) => {
|
|
4086
|
+
const padding = readResponsiveProp(props.padding);
|
|
4087
|
+
const margin = readResponsiveProp(props.margin);
|
|
4088
|
+
const attrs = {
|
|
4089
|
+
class: "rui-box",
|
|
4090
|
+
"data-border": asString(props.border, "none"),
|
|
4091
|
+
"data-background": asString(props.background, "none")
|
|
4092
|
+
};
|
|
4093
|
+
const styleParts = [];
|
|
4094
|
+
const maxWidth = asString(props.maxWidth);
|
|
4095
|
+
if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);
|
|
4096
|
+
if (padding.kind === "single") {
|
|
4097
|
+
const pad = padding.value ? normalizeSpacingToken(padding.value, String(padding.value)) : null;
|
|
4098
|
+
if (pad) attrs["data-padding"] = pad;
|
|
4099
|
+
} else {
|
|
4100
|
+
attrs["data-padding"] = "responsive";
|
|
4101
|
+
attrs["data-responsive-padding"] = "true";
|
|
4102
|
+
emitResponsiveSpacingVars(styleParts, padding, "--rui-box-padding");
|
|
4103
|
+
}
|
|
4104
|
+
if (margin.kind === "single") {
|
|
4105
|
+
const mar = margin.value ? normalizeSpacingToken(margin.value, String(margin.value)) : null;
|
|
4106
|
+
if (mar) attrs["data-margin"] = mar;
|
|
4107
|
+
} else {
|
|
4108
|
+
attrs["data-margin"] = "responsive";
|
|
4109
|
+
attrs["data-responsive-margin"] = "true";
|
|
4110
|
+
emitResponsiveSpacingVars(styleParts, margin, "--rui-box-margin");
|
|
4111
|
+
}
|
|
4112
|
+
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
4113
|
+
const root = el("div", attrs);
|
|
4114
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4115
|
+
return root;
|
|
4116
|
+
}
|
|
4085
4117
|
};
|
|
4086
|
-
const
|
|
4087
|
-
name: "
|
|
4088
|
-
description:
|
|
4118
|
+
const Fragment = {
|
|
4119
|
+
name: "Fragment",
|
|
4120
|
+
description: "Groups several siblings into one value WITHOUT adding a layout box — the wrapper is `display: contents`, so the children participate in the parent's flex/grid layout directly. Use to return multiple nodes from a component, or to conditionally group siblings, without a stray `div` that would break a Grid/Stack's spacing.",
|
|
4089
4121
|
props: [
|
|
4090
|
-
{ name: "children", type: "Node[]", description: "
|
|
4091
|
-
{ name: "direction", type: "string | object", optional: true, enum: ["column", "row"], description: 'Layout direction (default column). May be a responsive map like `{base: "column", md: "row"}`.' },
|
|
4092
|
-
{ ...FLEX_GAP_PROP },
|
|
4093
|
-
{ name: "align", type: "string | object", optional: true, enum: ["start", "center", "end", "stretch"], description: "Cross-axis alignment (default stretch). May be a responsive map." },
|
|
4094
|
-
{ ...FLEX_JUSTIFY_PROP },
|
|
4095
|
-
{ ...FLEX_ALIGN_CONTENT_PROP },
|
|
4096
|
-
{ ...FLEX_WRAP_PROP },
|
|
4097
|
-
{ ...FLEX_REVERSE_PROP },
|
|
4098
|
-
{ name: "uniform", type: "boolean", optional: true, description: "Row children share space equally (default true for row stacks; use `Row` for natural widths)" },
|
|
4099
|
-
{ ...FLEX_INLINE_PROP },
|
|
4100
|
-
{ ...FLEX_PADDING_PROP }
|
|
4122
|
+
{ name: "children", type: "Node[]", description: "Sibling nodes to group" }
|
|
4101
4123
|
],
|
|
4102
4124
|
render: (_node, props, helpers) => {
|
|
4103
|
-
const
|
|
4104
|
-
const
|
|
4105
|
-
|
|
4106
|
-
return renderFlexContainer(props.direction, uniform, "stretch", props, helpers);
|
|
4125
|
+
const root = el("div", { class: "rui-fragment", style: "display:contents;" });
|
|
4126
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4127
|
+
return root;
|
|
4107
4128
|
}
|
|
4108
4129
|
};
|
|
4109
|
-
const
|
|
4110
|
-
name: "
|
|
4111
|
-
description: '
|
|
4130
|
+
const Grid = {
|
|
4131
|
+
name: "Grid",
|
|
4132
|
+
description: 'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',
|
|
4112
4133
|
props: [
|
|
4113
|
-
{ name: "children", type: "Node[]"
|
|
4114
|
-
{ name: "
|
|
4115
|
-
{ name: "
|
|
4116
|
-
{ name: "
|
|
4117
|
-
{ name: "
|
|
4118
|
-
{ name: "
|
|
4134
|
+
{ name: "children", type: "Node[]" },
|
|
4135
|
+
{ name: "columns", type: "number | object", optional: true, description: "Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`." },
|
|
4136
|
+
{ name: "gap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Gap on both axes (default `md`). May be a responsive map." },
|
|
4137
|
+
{ name: "rowGap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Row gap override. May be a responsive map." },
|
|
4138
|
+
{ name: "columnGap", type: "string | object", optional: true, enum: SPACING_TOKENS, description: "Column gap override. May be a responsive map." },
|
|
4139
|
+
{ name: "minChildWidth", type: "string", optional: true, aliases: ["minItemWidth"], description: 'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.' },
|
|
4140
|
+
{ name: "alignItems", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Vertical alignment of items within their cells" },
|
|
4141
|
+
{ name: "justifyItems", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Horizontal alignment of items within their cells" },
|
|
4142
|
+
{ name: "dense", type: "boolean", optional: true, description: "Dense auto-flow packing — let later items backfill earlier gaps" }
|
|
4119
4143
|
],
|
|
4120
4144
|
render: (_node, props, helpers) => {
|
|
4145
|
+
const children = asArray(props.children);
|
|
4146
|
+
const hasGridItems = children.some((child) => isComponentNamed(child, "GridItem"));
|
|
4147
|
+
const columns = readResponsiveProp(props.columns);
|
|
4148
|
+
const gap = readResponsiveProp(props.gap);
|
|
4149
|
+
const rowGap = readResponsiveProp(props.rowGap);
|
|
4150
|
+
const columnGap = readResponsiveProp(props.columnGap);
|
|
4121
4151
|
const attrs = {
|
|
4122
|
-
class: "rui-
|
|
4123
|
-
"data-axis": asString(props.axis, "both"),
|
|
4124
|
-
"data-gap": asString(props.gap, "m"),
|
|
4125
|
-
"data-inline": asBoolean(props.inline) ? "true" : null
|
|
4152
|
+
class: "rui-grid"
|
|
4126
4153
|
};
|
|
4127
|
-
const padding = asString(props.padding);
|
|
4128
|
-
if (padding) attrs["data-padding"] = padding;
|
|
4129
4154
|
const styleParts = [];
|
|
4130
|
-
|
|
4131
|
-
|
|
4155
|
+
let twelveColMode = false;
|
|
4156
|
+
let explicitNonTwelve = false;
|
|
4157
|
+
if (columns.kind === "single") {
|
|
4158
|
+
const requested = columns.value === null ? 0 : asNumber(columns.value, 0);
|
|
4159
|
+
const cols = requested > 0 ? clampGridColumns(requested) : 0;
|
|
4160
|
+
if (cols === GRID_COLUMNS) {
|
|
4161
|
+
twelveColMode = true;
|
|
4162
|
+
} else if (cols > 0) {
|
|
4163
|
+
explicitNonTwelve = true;
|
|
4164
|
+
}
|
|
4165
|
+
if (cols > 0) {
|
|
4166
|
+
attrs["data-columns"] = String(cols);
|
|
4167
|
+
const minChild = asString(props.minChildWidth) || asString(props.minItemWidth);
|
|
4168
|
+
if (minChild) {
|
|
4169
|
+
attrs["data-min-child-width"] = "true";
|
|
4170
|
+
styleParts.push(`--rui-grid-min-child:${sanitiseCssLength(minChild, "220px")}`);
|
|
4171
|
+
}
|
|
4172
|
+
} else {
|
|
4173
|
+
styleParts.push(`--rui-grid-min-item:${gridMinChildWidth(props)}`);
|
|
4174
|
+
}
|
|
4175
|
+
} else {
|
|
4176
|
+
attrs["data-responsive-cols"] = "true";
|
|
4177
|
+
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
4178
|
+
const v = columns.values[bp];
|
|
4179
|
+
if (v === void 0) continue;
|
|
4180
|
+
const cols = clampGridColumns(asNumber(v, 0));
|
|
4181
|
+
if (cols === GRID_COLUMNS) {
|
|
4182
|
+
twelveColMode = true;
|
|
4183
|
+
} else if (cols > 0) {
|
|
4184
|
+
explicitNonTwelve = true;
|
|
4185
|
+
}
|
|
4186
|
+
styleParts.push(`--rui-grid-cols-${bp}:${cols}`);
|
|
4187
|
+
}
|
|
4188
|
+
}
|
|
4189
|
+
if (hasGridItems && !explicitNonTwelve) twelveColMode = true;
|
|
4190
|
+
if (twelveColMode) attrs["data-grid-mode"] = "12";
|
|
4191
|
+
if (gap.kind === "single") {
|
|
4192
|
+
attrs["data-gap"] = gap.value ? normalizeSpacingToken(gap.value, String(gap.value)) : "md";
|
|
4193
|
+
} else {
|
|
4194
|
+
attrs["data-gap"] = "responsive";
|
|
4195
|
+
attrs["data-responsive-gap"] = "true";
|
|
4196
|
+
emitResponsiveSpacingVars(styleParts, gap, "--rui-grid-gap");
|
|
4197
|
+
}
|
|
4198
|
+
if (rowGap.kind === "single" && rowGap.value) {
|
|
4199
|
+
attrs["data-row-gap"] = normalizeSpacingToken(rowGap.value, String(rowGap.value));
|
|
4200
|
+
} else if (rowGap.kind === "responsive") {
|
|
4201
|
+
attrs["data-row-gap"] = "responsive";
|
|
4202
|
+
attrs["data-responsive-row-gap"] = "true";
|
|
4203
|
+
emitResponsiveSpacingVars(styleParts, rowGap, "--rui-grid-row-gap");
|
|
4204
|
+
}
|
|
4205
|
+
if (columnGap.kind === "single" && columnGap.value) {
|
|
4206
|
+
attrs["data-column-gap"] = normalizeSpacingToken(columnGap.value, String(columnGap.value));
|
|
4207
|
+
} else if (columnGap.kind === "responsive") {
|
|
4208
|
+
attrs["data-column-gap"] = "responsive";
|
|
4209
|
+
attrs["data-responsive-column-gap"] = "true";
|
|
4210
|
+
emitResponsiveSpacingVars(styleParts, columnGap, "--rui-grid-column-gap");
|
|
4211
|
+
}
|
|
4212
|
+
const alignItems = asString(props.alignItems);
|
|
4213
|
+
if (alignItems) attrs["data-align-items"] = alignItems;
|
|
4214
|
+
const justifyItems = asString(props.justifyItems);
|
|
4215
|
+
if (justifyItems) attrs["data-justify-items"] = justifyItems;
|
|
4216
|
+
if (asBoolean(props.dense)) attrs["data-dense"] = "true";
|
|
4132
4217
|
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
4133
4218
|
const root = el("div", attrs);
|
|
4134
|
-
for (const child of
|
|
4219
|
+
for (const child of children) root.append(helpers.renderNode(child));
|
|
4135
4220
|
return root;
|
|
4136
4221
|
}
|
|
4137
4222
|
};
|
|
4138
|
-
const
|
|
4139
|
-
name: "
|
|
4140
|
-
description: "
|
|
4223
|
+
const AspectRatio = {
|
|
4224
|
+
name: "AspectRatio",
|
|
4225
|
+
description: "Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",
|
|
4141
4226
|
props: [
|
|
4142
|
-
{ name: "
|
|
4143
|
-
{ name: "
|
|
4227
|
+
{ name: "ratio", type: "string", description: "`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`" },
|
|
4228
|
+
{ name: "children", type: "Node[]" }
|
|
4144
4229
|
],
|
|
4145
4230
|
render: (_node, props, helpers) => {
|
|
4231
|
+
const ratio = parseRatio$1(asString(props.ratio, "16:9"));
|
|
4146
4232
|
const root = el("div", {
|
|
4147
|
-
class: "rui-
|
|
4148
|
-
|
|
4233
|
+
class: "rui-aspect-ratio",
|
|
4234
|
+
style: `aspect-ratio:${ratio};`
|
|
4149
4235
|
});
|
|
4150
4236
|
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4151
4237
|
return root;
|
|
4152
4238
|
}
|
|
4153
4239
|
};
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
],
|
|
4161
|
-
render: (_node, props) => {
|
|
4162
|
-
const root = el("header", { class: "rui-card-header" });
|
|
4163
|
-
root.append(el("h3", { class: "rui-card-title" }, [asString(props.title)]));
|
|
4164
|
-
const subtitle = asString(props.subtitle);
|
|
4165
|
-
if (subtitle) root.append(el("p", { class: "rui-card-subtitle" }, [subtitle]));
|
|
4166
|
-
return root;
|
|
4167
|
-
}
|
|
4168
|
-
};
|
|
4169
|
-
const CardFooter = {
|
|
4170
|
-
name: "CardFooter",
|
|
4171
|
-
description: "Card footer for actions.",
|
|
4172
|
-
props: [{ name: "children", type: "Node[]" }],
|
|
4173
|
-
render: (_node, props, helpers) => {
|
|
4174
|
-
const root = el("footer", { class: "rui-card-footer" });
|
|
4175
|
-
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4176
|
-
return root;
|
|
4177
|
-
}
|
|
4178
|
-
};
|
|
4179
|
-
const Separator = {
|
|
4180
|
-
name: "Separator",
|
|
4181
|
-
description: "Visual divider between content sections. Supports horizontal or vertical orientation, and an optional center `label` (lifted from the legacy `Divider`). Use `decorative=false` to expose the separator to assistive tech.",
|
|
4182
|
-
props: [
|
|
4183
|
-
{ name: "orientation", type: "string", optional: true, enum: ["horizontal", "vertical"] },
|
|
4184
|
-
{ name: "label", type: "string", optional: true, description: "Optional label rendered in the middle (horizontal only)" },
|
|
4185
|
-
{ name: "decorative", type: "boolean", optional: true, description: "Hides the separator from assistive tech when true (default)" }
|
|
4186
|
-
],
|
|
4187
|
-
render: (_node, props) => {
|
|
4188
|
-
const orientation = asString(props.orientation, "horizontal");
|
|
4189
|
-
const decorative = asBoolean(props.decorative, true);
|
|
4190
|
-
const label = asString(props.label);
|
|
4191
|
-
if (label && orientation === "horizontal") {
|
|
4192
|
-
return el("div", {
|
|
4193
|
-
class: "rui-separator rui-separator-with-label",
|
|
4194
|
-
"data-orientation": orientation,
|
|
4195
|
-
role: decorative ? "presentation" : "separator",
|
|
4196
|
-
"aria-orientation": decorative ? null : orientation
|
|
4197
|
-
}, [
|
|
4198
|
-
el("span", { class: "rui-separator-line" }),
|
|
4199
|
-
el("span", { class: "rui-separator-label" }, [label]),
|
|
4200
|
-
el("span", { class: "rui-separator-line" })
|
|
4201
|
-
]);
|
|
4202
|
-
}
|
|
4203
|
-
return el("div", {
|
|
4204
|
-
class: "rui-separator",
|
|
4205
|
-
"data-orientation": orientation,
|
|
4206
|
-
role: decorative ? "presentation" : "separator",
|
|
4207
|
-
"aria-orientation": decorative ? null : orientation
|
|
4208
|
-
});
|
|
4240
|
+
function parseRatio$1(input) {
|
|
4241
|
+
if (input.includes(":")) {
|
|
4242
|
+
const [w, h] = input.split(":");
|
|
4243
|
+
const num = Number(w);
|
|
4244
|
+
const den = Number(h);
|
|
4245
|
+
if (Number.isFinite(num) && Number.isFinite(den) && den !== 0) return `${num} / ${den}`;
|
|
4209
4246
|
}
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
root.append(el("div", { class: "rui-steps-title" }, [title]));
|
|
4217
|
-
if (details) root.append(el("div", { class: "rui-steps-details" }, [details]));
|
|
4218
|
-
return root;
|
|
4219
|
-
};
|
|
4220
|
-
const Steps = {
|
|
4221
|
-
name: "Steps",
|
|
4222
|
-
description: "Numbered step-by-step guide. Pass items as `{title, details?, active?}` objects. Use `active` to mark the current step in a multi-step flow.",
|
|
4247
|
+
const n = Number(input);
|
|
4248
|
+
return Number.isFinite(n) && n > 0 ? `${n} / 1` : "16 / 9";
|
|
4249
|
+
}
|
|
4250
|
+
const ScrollArea = {
|
|
4251
|
+
name: "ScrollArea",
|
|
4252
|
+
description: "Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",
|
|
4223
4253
|
props: [
|
|
4224
|
-
{ name: "
|
|
4254
|
+
{ name: "children", type: "Node[]" },
|
|
4255
|
+
{ name: "maxHeight", type: "string", optional: true, aliases: ["height"], description: "CSS height (default 320px)" },
|
|
4256
|
+
{ name: "direction", type: "string", optional: true, enum: ["vertical", "horizontal", "both"] }
|
|
4225
4257
|
],
|
|
4226
4258
|
render: (_node, props, helpers) => {
|
|
4227
|
-
const root = el("
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
if (item && typeof item === "object") {
|
|
4234
|
-
const data = item;
|
|
4235
|
-
root.append(renderStepLi(
|
|
4236
|
-
asString(data.title),
|
|
4237
|
-
asString(data.details),
|
|
4238
|
-
asBoolean(data.active)
|
|
4239
|
-
));
|
|
4240
|
-
continue;
|
|
4241
|
-
}
|
|
4242
|
-
root.append(renderStepLi(asString(item), ""));
|
|
4243
|
-
}
|
|
4259
|
+
const root = el("div", {
|
|
4260
|
+
class: "rui-scroll-area",
|
|
4261
|
+
"data-direction": asString(props.direction, "vertical"),
|
|
4262
|
+
style: `max-height:${sanitiseCssLength(props.maxHeight, "320px")};`
|
|
4263
|
+
});
|
|
4264
|
+
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4244
4265
|
return root;
|
|
4245
4266
|
}
|
|
4246
4267
|
};
|
|
4247
|
-
const
|
|
4248
|
-
|
|
4249
|
-
|
|
4268
|
+
const MODAL_SIZES = ["sm", "md", "lg", "xl", "full"];
|
|
4269
|
+
const FOCUSABLE_SELECTOR$1 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
4270
|
+
let modalIdSeq = 0;
|
|
4271
|
+
function activeWithin(el2) {
|
|
4272
|
+
const root = el2.getRootNode();
|
|
4273
|
+
return root.activeElement ?? null;
|
|
4274
|
+
}
|
|
4275
|
+
const Modal = {
|
|
4276
|
+
name: "Modal",
|
|
4277
|
+
description: "Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",
|
|
4250
4278
|
props: [
|
|
4251
|
-
{ name: "
|
|
4252
|
-
{ name: "
|
|
4253
|
-
{ name: "children", type: "Node[]"
|
|
4254
|
-
{ name: "
|
|
4255
|
-
{ name: "
|
|
4279
|
+
{ name: "title", type: "string" },
|
|
4280
|
+
{ name: "open", type: "boolean", description: "Open/closed state — usually a $variable" },
|
|
4281
|
+
{ name: "children", type: "Node[]" },
|
|
4282
|
+
{ name: "size", type: "string", optional: true, enum: MODAL_SIZES, description: "Width preset (default `md`)" },
|
|
4283
|
+
{ name: "footer", type: "Node[]", optional: true, description: "Footer slot — typically a row of action Buttons" },
|
|
4284
|
+
{ name: "closable", type: "boolean", optional: true, description: "Render the header × button (default true)" },
|
|
4285
|
+
{ name: "closeOnBackdrop", type: "boolean", optional: true, description: "Close when the overlay is clicked (default false)" },
|
|
4286
|
+
{ name: "onClose", type: "callable", optional: true, aliases: ["onclose"], description: "Callable invoked when the modal is closed (× button or backdrop)" }
|
|
4256
4287
|
],
|
|
4257
|
-
render: (
|
|
4258
|
-
const
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
"
|
|
4262
|
-
"data-
|
|
4288
|
+
render: (node, props, helpers) => {
|
|
4289
|
+
const size = asString(props.size, "md");
|
|
4290
|
+
const closable = props.closable === void 0 ? true : asBoolean(props.closable);
|
|
4291
|
+
const overlay = el("div", {
|
|
4292
|
+
class: "rui-modal-overlay",
|
|
4293
|
+
"data-open": asBoolean(props.open) ? "true" : "false"
|
|
4263
4294
|
});
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
{ name: "onChange", type: "callable", optional: true, aliases: ["onchange"], description: "Called with the newly-activated tab value when the user switches tabs" }
|
|
4276
|
-
],
|
|
4277
|
-
render: (_node, props, helpers) => {
|
|
4278
|
-
const items = asArray(props.items);
|
|
4279
|
-
const orientation = asString(props.orientation, "horizontal");
|
|
4280
|
-
const root = el("div", { class: "rui-tabs", "data-orientation": orientation });
|
|
4281
|
-
const tablist = el("div", {
|
|
4282
|
-
class: "rui-tab-list",
|
|
4283
|
-
role: "tablist",
|
|
4284
|
-
"aria-orientation": orientation
|
|
4295
|
+
const titleIdSlot = helpers.useInstanceState("rui-modal-title-id", "");
|
|
4296
|
+
if (!titleIdSlot.get()) titleIdSlot.set(`rui-modal-title-${modalIdSeq += 1}`);
|
|
4297
|
+
const titleId = titleIdSlot.get();
|
|
4298
|
+
const dialog = el("div", {
|
|
4299
|
+
class: "rui-modal",
|
|
4300
|
+
role: "dialog",
|
|
4301
|
+
"aria-modal": "true",
|
|
4302
|
+
"aria-labelledby": titleId,
|
|
4303
|
+
// Focusable so we can move focus into the dialog on open.
|
|
4304
|
+
tabindex: "-1",
|
|
4305
|
+
"data-size": size
|
|
4285
4306
|
});
|
|
4286
|
-
const
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4307
|
+
const header = el("header", { class: "rui-modal-header" });
|
|
4308
|
+
header.append(el("h3", { class: "rui-modal-title", id: titleId }, [asString(props.title)]));
|
|
4309
|
+
const stateName = node.argMeta?.[1]?.stateRef;
|
|
4310
|
+
const closeModal = () => {
|
|
4311
|
+
if (stateName) helpers.setState(stateName, false);
|
|
4312
|
+
helpers.invoke(props.onClose);
|
|
4313
|
+
};
|
|
4314
|
+
if (closable) {
|
|
4315
|
+
const closeBtn = el("button", {
|
|
4316
|
+
type: "button",
|
|
4317
|
+
class: "rui-modal-close",
|
|
4318
|
+
"aria-label": "Close dialog"
|
|
4319
|
+
}, ["×"]);
|
|
4320
|
+
closeBtn.onclick = (event) => {
|
|
4321
|
+
event.stopPropagation();
|
|
4322
|
+
closeModal();
|
|
4323
|
+
};
|
|
4324
|
+
header.append(closeBtn);
|
|
4291
4325
|
}
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4326
|
+
dialog.append(header);
|
|
4327
|
+
const body = el("div", { class: "rui-modal-body" });
|
|
4328
|
+
for (const child of asArray(props.children)) body.append(helpers.renderNode(child));
|
|
4329
|
+
dialog.append(body);
|
|
4330
|
+
const footer = asArray(props.footer);
|
|
4331
|
+
if (footer.length > 0) {
|
|
4332
|
+
const footRow = el("footer", { class: "rui-modal-footer" });
|
|
4333
|
+
for (const item of footer) footRow.append(helpers.renderNode(item));
|
|
4334
|
+
dialog.append(footRow);
|
|
4295
4335
|
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4336
|
+
overlay.append(dialog);
|
|
4337
|
+
if (asBoolean(props.closeOnBackdrop)) {
|
|
4338
|
+
overlay.onclick = (event) => {
|
|
4339
|
+
if (event.target === overlay) closeModal();
|
|
4340
|
+
};
|
|
4301
4341
|
}
|
|
4302
|
-
const
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4342
|
+
const isOpen = asBoolean(props.open);
|
|
4343
|
+
dialog.addEventListener("keydown", (event) => {
|
|
4344
|
+
if (event.key === "Escape" && closable) {
|
|
4345
|
+
event.stopPropagation();
|
|
4346
|
+
closeModal();
|
|
4347
|
+
return;
|
|
4348
|
+
}
|
|
4349
|
+
if (event.key !== "Tab") return;
|
|
4350
|
+
const items = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR$1)];
|
|
4351
|
+
if (items.length === 0) {
|
|
4352
|
+
event.preventDefault();
|
|
4353
|
+
dialog.focus();
|
|
4354
|
+
return;
|
|
4355
|
+
}
|
|
4356
|
+
const first = items[0];
|
|
4357
|
+
const last = items[items.length - 1];
|
|
4358
|
+
const active = activeWithin(dialog);
|
|
4359
|
+
if (event.shiftKey && active === first) {
|
|
4360
|
+
event.preventDefault();
|
|
4361
|
+
last.focus();
|
|
4362
|
+
} else if (!event.shiftKey && active === last) {
|
|
4363
|
+
event.preventDefault();
|
|
4364
|
+
first.focus();
|
|
4315
4365
|
}
|
|
4316
|
-
if (previous !== next) helpers.invoke(props.onChange, next);
|
|
4317
|
-
};
|
|
4318
|
-
items.forEach((item, idx) => {
|
|
4319
|
-
const tabNode = item;
|
|
4320
|
-
const value = asString(tabNode.args?.[0], `tab-${idx}`);
|
|
4321
|
-
const label = asString(tabNode.args?.[1], `Tab ${idx + 1}`);
|
|
4322
|
-
const badge = asString(tabNode.args?.[3]);
|
|
4323
|
-
const icon = asString(tabNode.args?.[4]);
|
|
4324
|
-
const isActive = value === activeSlot.get();
|
|
4325
|
-
const button = el(
|
|
4326
|
-
"button",
|
|
4327
|
-
{
|
|
4328
|
-
class: "rui-tab-trigger",
|
|
4329
|
-
role: "tab",
|
|
4330
|
-
type: "button",
|
|
4331
|
-
"data-value": value,
|
|
4332
|
-
"aria-selected": isActive ? "true" : "false",
|
|
4333
|
-
tabindex: isActive ? "0" : "-1"
|
|
4334
|
-
}
|
|
4335
|
-
);
|
|
4336
|
-
const iconNode = icon ? renderIconForTab(icon) : null;
|
|
4337
|
-
if (iconNode) button.append(iconNode);
|
|
4338
|
-
button.append(el("span", { class: "rui-tab-trigger-label" }, [label]));
|
|
4339
|
-
if (badge) button.append(el("span", { class: "rui-tab-trigger-badge" }, [badge]));
|
|
4340
|
-
button.onclick = (event) => {
|
|
4341
|
-
const origin = event.currentTarget ?? event.target;
|
|
4342
|
-
setActive(value, origin);
|
|
4343
|
-
};
|
|
4344
|
-
button.onkeydown = (event) => {
|
|
4345
|
-
const e = event;
|
|
4346
|
-
const horizontal = orientation !== "vertical";
|
|
4347
|
-
const isNext = horizontal ? e.key === "ArrowRight" : e.key === "ArrowDown";
|
|
4348
|
-
const isPrev = horizontal ? e.key === "ArrowLeft" : e.key === "ArrowUp";
|
|
4349
|
-
if (!isNext && !isPrev && e.key !== "Home" && e.key !== "End") return;
|
|
4350
|
-
e.preventDefault();
|
|
4351
|
-
const origin = e.currentTarget ?? e.target;
|
|
4352
|
-
const liveList = origin.closest(".rui-tab-list");
|
|
4353
|
-
if (!liveList) return;
|
|
4354
|
-
const triggers = Array.from(liveList.querySelectorAll(".rui-tab-trigger"));
|
|
4355
|
-
if (triggers.length === 0) return;
|
|
4356
|
-
const currentIdx = triggers.indexOf(origin);
|
|
4357
|
-
let nextIdx = currentIdx;
|
|
4358
|
-
if (e.key === "Home") nextIdx = 0;
|
|
4359
|
-
else if (e.key === "End") nextIdx = triggers.length - 1;
|
|
4360
|
-
else if (isNext) nextIdx = (currentIdx + 1) % triggers.length;
|
|
4361
|
-
else if (isPrev) nextIdx = (currentIdx - 1 + triggers.length) % triggers.length;
|
|
4362
|
-
const target = triggers[nextIdx];
|
|
4363
|
-
if (!target) return;
|
|
4364
|
-
target.focus();
|
|
4365
|
-
const nextValue = target.getAttribute("data-value") ?? "";
|
|
4366
|
-
if (nextValue) setActive(nextValue, target);
|
|
4367
|
-
};
|
|
4368
|
-
tablist.append(button);
|
|
4369
|
-
const panel = helpers.renderNode(item);
|
|
4370
|
-
panel.setAttribute("data-value", value);
|
|
4371
|
-
panel.setAttribute("data-active", isActive ? "true" : "false");
|
|
4372
|
-
panels.append(panel);
|
|
4373
|
-
});
|
|
4374
|
-
root.append(tablist, panels);
|
|
4375
|
-
return root;
|
|
4376
|
-
}
|
|
4377
|
-
};
|
|
4378
|
-
function renderIconForTab(iconName) {
|
|
4379
|
-
return renderIcon(iconName, { className: "rui-tab-trigger-icon" });
|
|
4380
|
-
}
|
|
4381
|
-
const AccordionItem = {
|
|
4382
|
-
name: "AccordionItem",
|
|
4383
|
-
description: "Single accordion section.",
|
|
4384
|
-
props: [
|
|
4385
|
-
{ name: "title", type: "string" },
|
|
4386
|
-
{ name: "children", type: "Node[]" },
|
|
4387
|
-
{ name: "open", type: "boolean", optional: true },
|
|
4388
|
-
{ name: "showArrow", type: "boolean", optional: true, description: "Show a chevron icon on the right (default false). Inherits from parent Accordion when unset." }
|
|
4389
|
-
],
|
|
4390
|
-
render: (_node, props, helpers) => {
|
|
4391
|
-
const explicit = props.showArrow !== void 0 && props.showArrow !== null;
|
|
4392
|
-
const details = el("details", {
|
|
4393
|
-
class: "rui-accordion-item",
|
|
4394
|
-
"data-show-arrow": explicit ? asBoolean(props.showArrow) ? "true" : "false" : null
|
|
4395
|
-
});
|
|
4396
|
-
if (asBoolean(props.open)) details.setAttribute("open", "");
|
|
4397
|
-
const summary = el("summary", { class: "rui-accordion-trigger" });
|
|
4398
|
-
summary.append(el("span", { class: "rui-accordion-title" }, [asString(props.title)]));
|
|
4399
|
-
summary.append(el("span", { class: "rui-accordion-chevron", "aria-hidden": "true" }));
|
|
4400
|
-
details.append(summary);
|
|
4401
|
-
const body = el("div", { class: "rui-accordion-body" });
|
|
4402
|
-
for (const child of asArray(props.children)) body.append(helpers.renderNode(child));
|
|
4403
|
-
details.append(body);
|
|
4404
|
-
return details;
|
|
4405
|
-
}
|
|
4406
|
-
};
|
|
4407
|
-
const Accordion = {
|
|
4408
|
-
name: "Accordion",
|
|
4409
|
-
description: "Accordion container. Children must be AccordionItem components. Set `showArrow: true` to add a chevron indicator to every item; individual `AccordionItem`s can override via their own `showArrow` prop.",
|
|
4410
|
-
props: [
|
|
4411
|
-
{ name: "items", type: "AccordionItem[]" },
|
|
4412
|
-
{ name: "showArrow", type: "boolean", optional: true, description: "Show chevron icon on every item (default false)." }
|
|
4413
|
-
],
|
|
4414
|
-
render: (_node, props, helpers) => {
|
|
4415
|
-
const root = el("div", {
|
|
4416
|
-
class: "rui-accordion",
|
|
4417
|
-
"data-show-arrow": asBoolean(props.showArrow) ? "true" : "false"
|
|
4418
4366
|
});
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
const
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
}
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
function
|
|
4439
|
-
|
|
4440
|
-
return sanitiseCssLength(width || "220px", "220px");
|
|
4441
|
-
}
|
|
4442
|
-
const GridItem = {
|
|
4443
|
-
name: "GridItem",
|
|
4444
|
-
description: 'Wraps a child in a 12-column grid cell with `span`, `offset`, and responsive `spanAt` maps. Parent `Grid` auto-enables 12-column mode when any child is a `GridItem`. Fraction spans like `"1/3"` resolve against the 12-column track.',
|
|
4445
|
-
props: [
|
|
4446
|
-
{ name: "child", type: "Node", description: "Child node to place in the grid" },
|
|
4447
|
-
{ name: "span", type: "number | string", optional: true, description: 'Columns to span (1–12) or fraction like "1/2", "1/3"' },
|
|
4448
|
-
{ name: "offset", type: "number", optional: true, description: "Empty columns before this item (0–11)" },
|
|
4449
|
-
{ name: "spanAt", type: "object", optional: true, description: "Responsive span map `{sm: 12, md: 6, lg: 4}`" }
|
|
4450
|
-
],
|
|
4451
|
-
render: (_node, props, helpers) => {
|
|
4452
|
-
const baseSpan = resolveSpan(props.span ?? 12);
|
|
4453
|
-
const spanAt = readResponsiveProp(props.spanAt);
|
|
4454
|
-
const offset = props.offset === void 0 || props.offset === null ? 0 : Math.max(0, Math.min(GRID_COLUMNS - 1, Math.round(asNumber(props.offset, 0))));
|
|
4455
|
-
const attrs = {
|
|
4456
|
-
class: "rui-grid-item",
|
|
4457
|
-
"data-span": String(baseSpan)
|
|
4458
|
-
};
|
|
4459
|
-
const styleParts = [`--rui-grid-item-span:${baseSpan}`];
|
|
4460
|
-
if (offset > 0) {
|
|
4461
|
-
attrs["data-offset"] = String(offset);
|
|
4462
|
-
styleParts.push(`--rui-grid-item-offset:${offset}`);
|
|
4463
|
-
}
|
|
4464
|
-
if (spanAt.kind === "responsive") {
|
|
4465
|
-
attrs["data-responsive-span"] = "true";
|
|
4466
|
-
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
4467
|
-
const v = spanAt.values[bp];
|
|
4468
|
-
if (v !== void 0) {
|
|
4469
|
-
const resolved = resolveSpan(v);
|
|
4470
|
-
styleParts.push(`--rui-grid-item-span-${bp}:${resolved}`);
|
|
4471
|
-
}
|
|
4367
|
+
const focusSlot = helpers.useInstanceState(
|
|
4368
|
+
"rui-modal-focus",
|
|
4369
|
+
{ open: false, prev: null }
|
|
4370
|
+
);
|
|
4371
|
+
const prevState = focusSlot.get();
|
|
4372
|
+
if (isOpen && !prevState.open) {
|
|
4373
|
+
const previouslyFocused = activeWithin(dialog);
|
|
4374
|
+
focusSlot.set({ open: true, prev: previouslyFocused });
|
|
4375
|
+
const focusFirst = () => {
|
|
4376
|
+
const items = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR$1)];
|
|
4377
|
+
(items[0] ?? dialog).focus();
|
|
4378
|
+
};
|
|
4379
|
+
if (typeof queueMicrotask === "function") queueMicrotask(focusFirst);
|
|
4380
|
+
else void Promise.resolve().then(focusFirst);
|
|
4381
|
+
} else if (!isOpen && prevState.open) {
|
|
4382
|
+
const toRestore = prevState.prev;
|
|
4383
|
+
focusSlot.set({ open: false, prev: null });
|
|
4384
|
+
if (toRestore && typeof toRestore.focus === "function") {
|
|
4385
|
+
const restore = () => toRestore.focus();
|
|
4386
|
+
if (typeof queueMicrotask === "function") queueMicrotask(restore);
|
|
4387
|
+
else void Promise.resolve().then(restore);
|
|
4472
4388
|
}
|
|
4473
|
-
} else if (spanAt.kind === "single" && spanAt.value != null) {
|
|
4474
|
-
const resolved = resolveSpan(spanAt.value);
|
|
4475
|
-
styleParts.push(`--rui-grid-item-span:${resolved}`);
|
|
4476
|
-
attrs["data-span"] = String(resolved);
|
|
4477
|
-
}
|
|
4478
|
-
attrs.style = styleParts.join(";");
|
|
4479
|
-
const root = el("div", attrs);
|
|
4480
|
-
root.append(helpers.renderNode(props.child));
|
|
4481
|
-
return root;
|
|
4482
|
-
}
|
|
4483
|
-
};
|
|
4484
|
-
const Box = {
|
|
4485
|
-
name: "Box",
|
|
4486
|
-
description: "Spacing and surface wrapper for padding, margin, borders, semantic backgrounds, and max-width constraints. Use when a `Card` is too heavy but the content needs a subtle surface or inset.",
|
|
4487
|
-
props: [
|
|
4488
|
-
{ name: "children", type: "Node[]" },
|
|
4489
|
-
{ name: "padding", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Inner padding. May be a responsive map." },
|
|
4490
|
-
{ name: "margin", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Outer margin. May be a responsive map." },
|
|
4491
|
-
{ name: "border", type: "string", optional: true, enum: ["none", "subtle", "default"], description: "Border preset (default none)" },
|
|
4492
|
-
{ name: "background", type: "string", optional: true, enum: ["none", "surface", "muted", "primary", "success", "warning", "danger", "info"], description: "Semantic background token" },
|
|
4493
|
-
{ name: "maxWidth", type: "string", optional: true, description: "CSS max-width" }
|
|
4494
|
-
],
|
|
4495
|
-
render: (_node, props, helpers) => {
|
|
4496
|
-
const padding = readResponsiveProp(props.padding);
|
|
4497
|
-
const margin = readResponsiveProp(props.margin);
|
|
4498
|
-
const attrs = {
|
|
4499
|
-
class: "rui-box",
|
|
4500
|
-
"data-border": asString(props.border, "none"),
|
|
4501
|
-
"data-background": asString(props.background, "none")
|
|
4502
|
-
};
|
|
4503
|
-
const styleParts = [];
|
|
4504
|
-
const maxWidth = asString(props.maxWidth);
|
|
4505
|
-
if (maxWidth) styleParts.push(`max-width:${sanitiseCssLength(maxWidth, maxWidth)}`);
|
|
4506
|
-
if (padding.kind === "single") {
|
|
4507
|
-
const pad = padding.value ? String(padding.value) : null;
|
|
4508
|
-
if (pad) attrs["data-padding"] = pad;
|
|
4509
|
-
} else {
|
|
4510
|
-
attrs["data-padding"] = "responsive";
|
|
4511
|
-
attrs["data-responsive-padding"] = "true";
|
|
4512
|
-
emitResponsiveSpacingVars(styleParts, padding, "--rui-box-padding");
|
|
4513
|
-
}
|
|
4514
|
-
if (margin.kind === "single") {
|
|
4515
|
-
const mar = margin.value ? String(margin.value) : null;
|
|
4516
|
-
if (mar) attrs["data-margin"] = mar;
|
|
4517
|
-
} else {
|
|
4518
|
-
attrs["data-margin"] = "responsive";
|
|
4519
|
-
attrs["data-responsive-margin"] = "true";
|
|
4520
|
-
emitResponsiveSpacingVars(styleParts, margin, "--rui-box-margin");
|
|
4521
4389
|
}
|
|
4522
|
-
|
|
4523
|
-
const root = el("div", attrs);
|
|
4524
|
-
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4525
|
-
return root;
|
|
4526
|
-
}
|
|
4527
|
-
};
|
|
4528
|
-
const Fragment = {
|
|
4529
|
-
name: "Fragment",
|
|
4530
|
-
description: "Groups several siblings into one value WITHOUT adding a layout box — the wrapper is `display: contents`, so the children participate in the parent's flex/grid layout directly. Use to return multiple nodes from a component, or to conditionally group siblings, without a stray `div` that would break a Grid/Stack's spacing.",
|
|
4531
|
-
props: [
|
|
4532
|
-
{ name: "children", type: "Node[]", description: "Sibling nodes to group" }
|
|
4533
|
-
],
|
|
4534
|
-
render: (_node, props, helpers) => {
|
|
4535
|
-
const root = el("div", { class: "rui-fragment", style: "display:contents;" });
|
|
4536
|
-
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4537
|
-
return root;
|
|
4390
|
+
return overlay;
|
|
4538
4391
|
}
|
|
4539
4392
|
};
|
|
4540
|
-
const
|
|
4541
|
-
name: "Grid",
|
|
4542
|
-
description: 'Two-dimensional grid with three modes:\n 1. AUTO-FIT (default, no `columns`): wraps as many equal columns as fit, each at least `minChildWidth` wide (default 220px) — perfect for card/KPI grids that should reflow on their own.\n 2. FIXED (`columns: N`, 1–12): exactly N equal columns.\n 3. SPAN (`columns: 12` or any `GridItem` children): a 12-track grid where each `GridItem` sets its own `span` (a number 1–12 or a fraction like `"1/3"`) for dashboards and asymmetric layouts.\n`columns` and `gap` accept responsive maps like `{base: 1, md: 2, lg: 4}`.',
|
|
4543
|
-
props: [
|
|
4544
|
-
{ name: "children", type: "Node[]" },
|
|
4545
|
-
{ name: "columns", type: "number | object", optional: true, description: "Fixed column count 1–12. Omit for auto-fit; `12` (or `GridItem` children) enables the 12-track span system. May be a responsive map like `{base: 1, md: 3}`." },
|
|
4546
|
-
{ name: "gap", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Gap on both axes (default `m`). May be a responsive map." },
|
|
4547
|
-
{ name: "rowGap", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Row gap override. May be a responsive map." },
|
|
4548
|
-
{ name: "columnGap", type: "string | object", optional: true, enum: ["xs", "s", "m", "l", "xl"], description: "Column gap override. May be a responsive map." },
|
|
4549
|
-
{ name: "minChildWidth", type: "string", optional: true, aliases: ["minItemWidth"], description: 'Minimum column width for AUTO-FIT mode, e.g. `"240px"` (default 220px). Also caps the floor in FIXED mode.' },
|
|
4550
|
-
{ name: "alignItems", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Vertical alignment of items within their cells" },
|
|
4551
|
-
{ name: "justifyItems", type: "string", optional: true, enum: ["start", "center", "end", "stretch"], description: "Horizontal alignment of items within their cells" },
|
|
4552
|
-
{ name: "dense", type: "boolean", optional: true, description: "Dense auto-flow packing — let later items backfill earlier gaps" }
|
|
4553
|
-
],
|
|
4554
|
-
render: (_node, props, helpers) => {
|
|
4555
|
-
const children = asArray(props.children);
|
|
4556
|
-
const hasGridItems = children.some((child) => isComponentNamed(child, "GridItem"));
|
|
4557
|
-
const columns = readResponsiveProp(props.columns);
|
|
4558
|
-
const gap = readResponsiveProp(props.gap);
|
|
4559
|
-
const rowGap = readResponsiveProp(props.rowGap);
|
|
4560
|
-
const columnGap = readResponsiveProp(props.columnGap);
|
|
4561
|
-
const attrs = {
|
|
4562
|
-
class: "rui-grid"
|
|
4563
|
-
};
|
|
4564
|
-
const styleParts = [];
|
|
4565
|
-
let twelveColMode = false;
|
|
4566
|
-
let explicitNonTwelve = false;
|
|
4567
|
-
if (columns.kind === "single") {
|
|
4568
|
-
const requested = columns.value === null ? 0 : asNumber(columns.value, 0);
|
|
4569
|
-
const cols = requested > 0 ? clampGridColumns(requested) : 0;
|
|
4570
|
-
if (cols === GRID_COLUMNS) {
|
|
4571
|
-
twelveColMode = true;
|
|
4572
|
-
} else if (cols > 0) {
|
|
4573
|
-
explicitNonTwelve = true;
|
|
4574
|
-
}
|
|
4575
|
-
if (cols > 0) {
|
|
4576
|
-
attrs["data-columns"] = String(cols);
|
|
4577
|
-
const minChild = asString(props.minChildWidth) || asString(props.minItemWidth);
|
|
4578
|
-
if (minChild) {
|
|
4579
|
-
attrs["data-min-child-width"] = "true";
|
|
4580
|
-
styleParts.push(`--rui-grid-min-child:${sanitiseCssLength(minChild, "220px")}`);
|
|
4581
|
-
}
|
|
4582
|
-
} else {
|
|
4583
|
-
styleParts.push(`--rui-grid-min-item:${gridMinChildWidth(props)}`);
|
|
4584
|
-
}
|
|
4585
|
-
} else {
|
|
4586
|
-
attrs["data-responsive-cols"] = "true";
|
|
4587
|
-
for (const bp of RESPONSIVE_BREAKPOINTS) {
|
|
4588
|
-
const v = columns.values[bp];
|
|
4589
|
-
if (v === void 0) continue;
|
|
4590
|
-
const cols = clampGridColumns(asNumber(v, 0));
|
|
4591
|
-
if (cols === GRID_COLUMNS) {
|
|
4592
|
-
twelveColMode = true;
|
|
4593
|
-
} else if (cols > 0) {
|
|
4594
|
-
explicitNonTwelve = true;
|
|
4595
|
-
}
|
|
4596
|
-
styleParts.push(`--rui-grid-cols-${bp}:${cols}`);
|
|
4597
|
-
}
|
|
4598
|
-
}
|
|
4599
|
-
if (hasGridItems && !explicitNonTwelve) twelveColMode = true;
|
|
4600
|
-
if (twelveColMode) attrs["data-grid-mode"] = "12";
|
|
4601
|
-
if (gap.kind === "single") {
|
|
4602
|
-
attrs["data-gap"] = gap.value ? String(gap.value) : "m";
|
|
4603
|
-
} else {
|
|
4604
|
-
attrs["data-gap"] = "responsive";
|
|
4605
|
-
attrs["data-responsive-gap"] = "true";
|
|
4606
|
-
emitResponsiveSpacingVars(styleParts, gap, "--rui-grid-gap");
|
|
4607
|
-
}
|
|
4608
|
-
if (rowGap.kind === "single" && rowGap.value) {
|
|
4609
|
-
attrs["data-row-gap"] = String(rowGap.value);
|
|
4610
|
-
} else if (rowGap.kind === "responsive") {
|
|
4611
|
-
attrs["data-row-gap"] = "responsive";
|
|
4612
|
-
attrs["data-responsive-row-gap"] = "true";
|
|
4613
|
-
emitResponsiveSpacingVars(styleParts, rowGap, "--rui-grid-row-gap");
|
|
4614
|
-
}
|
|
4615
|
-
if (columnGap.kind === "single" && columnGap.value) {
|
|
4616
|
-
attrs["data-column-gap"] = String(columnGap.value);
|
|
4617
|
-
} else if (columnGap.kind === "responsive") {
|
|
4618
|
-
attrs["data-column-gap"] = "responsive";
|
|
4619
|
-
attrs["data-responsive-column-gap"] = "true";
|
|
4620
|
-
emitResponsiveSpacingVars(styleParts, columnGap, "--rui-grid-column-gap");
|
|
4621
|
-
}
|
|
4622
|
-
const alignItems = asString(props.alignItems);
|
|
4623
|
-
if (alignItems) attrs["data-align-items"] = alignItems;
|
|
4624
|
-
const justifyItems = asString(props.justifyItems);
|
|
4625
|
-
if (justifyItems) attrs["data-justify-items"] = justifyItems;
|
|
4626
|
-
if (asBoolean(props.dense)) attrs["data-dense"] = "true";
|
|
4627
|
-
if (styleParts.length > 0) attrs.style = styleParts.join(";");
|
|
4628
|
-
const root = el("div", attrs);
|
|
4629
|
-
for (const child of children) root.append(helpers.renderNode(child));
|
|
4630
|
-
return root;
|
|
4631
|
-
}
|
|
4632
|
-
};
|
|
4633
|
-
const AspectRatio = {
|
|
4634
|
-
name: "AspectRatio",
|
|
4635
|
-
description: "Container that constrains its child to a fixed aspect ratio (e.g. 16:9 for video embeds, 1:1 for thumbnails). The child fills the box.",
|
|
4636
|
-
props: [
|
|
4637
|
-
{ name: "ratio", type: "string", description: "`width:height` (e.g. `16:9`, `4:3`) or a decimal like `1.78`" },
|
|
4638
|
-
{ name: "children", type: "Node[]" }
|
|
4639
|
-
],
|
|
4640
|
-
render: (_node, props, helpers) => {
|
|
4641
|
-
const ratio = parseRatio$1(asString(props.ratio, "16:9"));
|
|
4642
|
-
const root = el("div", {
|
|
4643
|
-
class: "rui-aspect-ratio",
|
|
4644
|
-
style: `aspect-ratio:${ratio};`
|
|
4645
|
-
});
|
|
4646
|
-
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4647
|
-
return root;
|
|
4648
|
-
}
|
|
4649
|
-
};
|
|
4650
|
-
function parseRatio$1(input) {
|
|
4651
|
-
if (input.includes(":")) {
|
|
4652
|
-
const [w, h] = input.split(":");
|
|
4653
|
-
const num = Number(w);
|
|
4654
|
-
const den = Number(h);
|
|
4655
|
-
if (Number.isFinite(num) && Number.isFinite(den) && den !== 0) return `${num} / ${den}`;
|
|
4656
|
-
}
|
|
4657
|
-
const n = Number(input);
|
|
4658
|
-
return Number.isFinite(n) && n > 0 ? `${n} / 1` : "16 / 9";
|
|
4659
|
-
}
|
|
4660
|
-
const ScrollArea = {
|
|
4661
|
-
name: "ScrollArea",
|
|
4662
|
-
description: "Bounded scroll container. Use to clip long lists / logs / chat panels to a fixed max height with a clean scrollbar.",
|
|
4663
|
-
props: [
|
|
4664
|
-
{ name: "children", type: "Node[]" },
|
|
4665
|
-
{ name: "maxHeight", type: "string", optional: true, aliases: ["height"], description: "CSS height (default 320px)" },
|
|
4666
|
-
{ name: "direction", type: "string", optional: true, enum: ["vertical", "horizontal", "both"] }
|
|
4667
|
-
],
|
|
4668
|
-
render: (_node, props, helpers) => {
|
|
4669
|
-
const root = el("div", {
|
|
4670
|
-
class: "rui-scroll-area",
|
|
4671
|
-
"data-direction": asString(props.direction, "vertical"),
|
|
4672
|
-
style: `max-height:${sanitiseCssLength(props.maxHeight, "320px")};`
|
|
4673
|
-
});
|
|
4674
|
-
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
4675
|
-
return root;
|
|
4676
|
-
}
|
|
4677
|
-
};
|
|
4678
|
-
const MODAL_SIZES = ["sm", "md", "lg", "xl", "full"];
|
|
4679
|
-
const FOCUSABLE_SELECTOR$1 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
4680
|
-
let modalIdSeq = 0;
|
|
4681
|
-
function activeWithin(el2) {
|
|
4682
|
-
const root = el2.getRootNode();
|
|
4683
|
-
return root.activeElement ?? null;
|
|
4684
|
-
}
|
|
4685
|
-
const Modal = {
|
|
4686
|
-
name: "Modal",
|
|
4687
|
-
description: "Dialog overlay shown when `open` is true. Pass a `$variable` as `open` to control it. The header always renders a × close button (disable via `closable: false`); the optional `footer` slot is the canonical place for action buttons. `closeOnBackdrop=true` opts in to backdrop-click dismissal. `onClose` fires every time the modal closes (× button, backdrop, programmatic state write). Accessible by default: the dialog is labelled by its title, focus moves into it on open and is restored on close, Tab is trapped inside, and Escape closes it (unless `closable: false`).",
|
|
4688
|
-
props: [
|
|
4689
|
-
{ name: "title", type: "string" },
|
|
4690
|
-
{ name: "open", type: "boolean", description: "Open/closed state — usually a $variable" },
|
|
4691
|
-
{ name: "children", type: "Node[]" },
|
|
4692
|
-
{ name: "size", type: "string", optional: true, enum: MODAL_SIZES, description: "Width preset (default `md`)" },
|
|
4693
|
-
{ name: "footer", type: "Node[]", optional: true, description: "Footer slot — typically a row of action Buttons" },
|
|
4694
|
-
{ name: "closable", type: "boolean", optional: true, description: "Render the header × button (default true)" },
|
|
4695
|
-
{ name: "closeOnBackdrop", type: "boolean", optional: true, description: "Close when the overlay is clicked (default false)" },
|
|
4696
|
-
{ name: "onClose", type: "callable", optional: true, aliases: ["onclose"], description: "Callable invoked when the modal is closed (× button or backdrop)" }
|
|
4697
|
-
],
|
|
4698
|
-
render: (node, props, helpers) => {
|
|
4699
|
-
const size = asString(props.size, "md");
|
|
4700
|
-
const closable = props.closable === void 0 ? true : asBoolean(props.closable);
|
|
4701
|
-
const overlay = el("div", {
|
|
4702
|
-
class: "rui-modal-overlay",
|
|
4703
|
-
"data-open": asBoolean(props.open) ? "true" : "false"
|
|
4704
|
-
});
|
|
4705
|
-
const titleIdSlot = helpers.useInstanceState("rui-modal-title-id", "");
|
|
4706
|
-
if (!titleIdSlot.get()) titleIdSlot.set(`rui-modal-title-${modalIdSeq += 1}`);
|
|
4707
|
-
const titleId = titleIdSlot.get();
|
|
4708
|
-
const dialog = el("div", {
|
|
4709
|
-
class: "rui-modal",
|
|
4710
|
-
role: "dialog",
|
|
4711
|
-
"aria-modal": "true",
|
|
4712
|
-
"aria-labelledby": titleId,
|
|
4713
|
-
// Focusable so we can move focus into the dialog on open.
|
|
4714
|
-
tabindex: "-1",
|
|
4715
|
-
"data-size": size
|
|
4716
|
-
});
|
|
4717
|
-
const header = el("header", { class: "rui-modal-header" });
|
|
4718
|
-
header.append(el("h3", { class: "rui-modal-title", id: titleId }, [asString(props.title)]));
|
|
4719
|
-
const stateName = node.argMeta?.[1]?.stateRef;
|
|
4720
|
-
const closeModal = () => {
|
|
4721
|
-
if (stateName) helpers.setState(stateName, false);
|
|
4722
|
-
helpers.invoke(props.onClose);
|
|
4723
|
-
};
|
|
4724
|
-
if (closable) {
|
|
4725
|
-
const closeBtn = el("button", {
|
|
4726
|
-
type: "button",
|
|
4727
|
-
class: "rui-modal-close",
|
|
4728
|
-
"aria-label": "Close dialog"
|
|
4729
|
-
}, ["×"]);
|
|
4730
|
-
closeBtn.onclick = (event) => {
|
|
4731
|
-
event.stopPropagation();
|
|
4732
|
-
closeModal();
|
|
4733
|
-
};
|
|
4734
|
-
header.append(closeBtn);
|
|
4735
|
-
}
|
|
4736
|
-
dialog.append(header);
|
|
4737
|
-
const body = el("div", { class: "rui-modal-body" });
|
|
4738
|
-
for (const child of asArray(props.children)) body.append(helpers.renderNode(child));
|
|
4739
|
-
dialog.append(body);
|
|
4740
|
-
const footer = asArray(props.footer);
|
|
4741
|
-
if (footer.length > 0) {
|
|
4742
|
-
const footRow = el("footer", { class: "rui-modal-footer" });
|
|
4743
|
-
for (const item of footer) footRow.append(helpers.renderNode(item));
|
|
4744
|
-
dialog.append(footRow);
|
|
4745
|
-
}
|
|
4746
|
-
overlay.append(dialog);
|
|
4747
|
-
if (asBoolean(props.closeOnBackdrop)) {
|
|
4748
|
-
overlay.onclick = (event) => {
|
|
4749
|
-
if (event.target === overlay) closeModal();
|
|
4750
|
-
};
|
|
4751
|
-
}
|
|
4752
|
-
const isOpen = asBoolean(props.open);
|
|
4753
|
-
dialog.addEventListener("keydown", (event) => {
|
|
4754
|
-
if (event.key === "Escape" && closable) {
|
|
4755
|
-
event.stopPropagation();
|
|
4756
|
-
closeModal();
|
|
4757
|
-
return;
|
|
4758
|
-
}
|
|
4759
|
-
if (event.key !== "Tab") return;
|
|
4760
|
-
const items = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR$1)];
|
|
4761
|
-
if (items.length === 0) {
|
|
4762
|
-
event.preventDefault();
|
|
4763
|
-
dialog.focus();
|
|
4764
|
-
return;
|
|
4765
|
-
}
|
|
4766
|
-
const first = items[0];
|
|
4767
|
-
const last = items[items.length - 1];
|
|
4768
|
-
const active = activeWithin(dialog);
|
|
4769
|
-
if (event.shiftKey && active === first) {
|
|
4770
|
-
event.preventDefault();
|
|
4771
|
-
last.focus();
|
|
4772
|
-
} else if (!event.shiftKey && active === last) {
|
|
4773
|
-
event.preventDefault();
|
|
4774
|
-
first.focus();
|
|
4775
|
-
}
|
|
4776
|
-
});
|
|
4777
|
-
const focusSlot = helpers.useInstanceState(
|
|
4778
|
-
"rui-modal-focus",
|
|
4779
|
-
{ open: false, prev: null }
|
|
4780
|
-
);
|
|
4781
|
-
const prevState = focusSlot.get();
|
|
4782
|
-
if (isOpen && !prevState.open) {
|
|
4783
|
-
const previouslyFocused = activeWithin(dialog);
|
|
4784
|
-
focusSlot.set({ open: true, prev: previouslyFocused });
|
|
4785
|
-
const focusFirst = () => {
|
|
4786
|
-
const items = [...dialog.querySelectorAll(FOCUSABLE_SELECTOR$1)];
|
|
4787
|
-
(items[0] ?? dialog).focus();
|
|
4788
|
-
};
|
|
4789
|
-
if (typeof queueMicrotask === "function") queueMicrotask(focusFirst);
|
|
4790
|
-
else void Promise.resolve().then(focusFirst);
|
|
4791
|
-
} else if (!isOpen && prevState.open) {
|
|
4792
|
-
const toRestore = prevState.prev;
|
|
4793
|
-
focusSlot.set({ open: false, prev: null });
|
|
4794
|
-
if (toRestore && typeof toRestore.focus === "function") {
|
|
4795
|
-
const restore = () => toRestore.focus();
|
|
4796
|
-
if (typeof queueMicrotask === "function") queueMicrotask(restore);
|
|
4797
|
-
else void Promise.resolve().then(restore);
|
|
4798
|
-
}
|
|
4799
|
-
}
|
|
4800
|
-
return overlay;
|
|
4801
|
-
}
|
|
4802
|
-
};
|
|
4803
|
-
const KEYWORDS = {
|
|
4393
|
+
const KEYWORDS$1 = {
|
|
4804
4394
|
js: /* @__PURE__ */ new Set([
|
|
4805
4395
|
"const",
|
|
4806
4396
|
"let",
|
|
@@ -4909,7 +4499,7 @@ function highlightLine(line, lang, state) {
|
|
|
4909
4499
|
const family = langFamily(lang);
|
|
4910
4500
|
if (family === "html") return highlightHtmlLine(line);
|
|
4911
4501
|
const tokens = [];
|
|
4912
|
-
const keywords = KEYWORDS[family === "generic" ? "js" : family] ?? KEYWORDS.js;
|
|
4502
|
+
const keywords = KEYWORDS$1[family === "generic" ? "js" : family] ?? KEYWORDS$1.js;
|
|
4913
4503
|
let i = 0;
|
|
4914
4504
|
const n = line.length;
|
|
4915
4505
|
const push = (text, cls) => {
|
|
@@ -5075,6 +4665,7 @@ const TEXT_PROPS = [
|
|
|
5075
4665
|
{ name: "value", type: "string" },
|
|
5076
4666
|
{ name: "variant", type: "string", optional: true, enum: TEXT_VARIANTS },
|
|
5077
4667
|
{ name: "tone", type: "string", optional: true, enum: ["default", "muted", "primary", "success", "warning", "danger"], description: "Visual accent" },
|
|
4668
|
+
{ name: "align", type: "string", optional: true, enum: ["left", "center", "right"], description: "Horizontal text alignment — the text becomes its own block-level line" },
|
|
5078
4669
|
{
|
|
5079
4670
|
name: "style",
|
|
5080
4671
|
type: "string",
|
|
@@ -5085,17 +4676,19 @@ const TEXT_PROPS = [
|
|
|
5085
4676
|
const renderText = (_node, props) => {
|
|
5086
4677
|
const variant = asString(props.variant, "body");
|
|
5087
4678
|
const tone = asString(props.tone, "default");
|
|
4679
|
+
const align = asString(props.align);
|
|
5088
4680
|
const style = sanitiseInlineStyle$1(props.style);
|
|
5089
4681
|
return el("span", {
|
|
5090
4682
|
class: "rui-text",
|
|
5091
4683
|
"data-variant": variant,
|
|
5092
4684
|
"data-color": tone,
|
|
4685
|
+
"data-align": align || null,
|
|
5093
4686
|
style: style || null
|
|
5094
4687
|
}, [asString(props.value)]);
|
|
5095
4688
|
};
|
|
5096
4689
|
const Text = {
|
|
5097
4690
|
name: "Text",
|
|
5098
|
-
description: 'Renders plain text with a typographic variant. Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',
|
|
4691
|
+
description: 'Renders plain text with a typographic variant. `align` (left|center|right) sets the horizontal alignment (the text renders as its own block). Optional `style` prop accepts a CSS declaration string (e.g. "font-size: 16px; color: #000;") applied directly to the rendered element.',
|
|
5099
4692
|
props: TEXT_PROPS,
|
|
5100
4693
|
render: renderText
|
|
5101
4694
|
};
|
|
@@ -5494,13 +5087,13 @@ const Container = {
|
|
|
5494
5087
|
{ name: "children", type: "Node[]" },
|
|
5495
5088
|
{ name: "size", type: "string", optional: true, enum: ["sm", "md", "lg", "xl", "full"], description: "sm=640 / md=820 / lg=1040 / xl=1280 / full=100% (default lg)" },
|
|
5496
5089
|
{ name: "maxWidth", type: "string", optional: true, description: "Custom CSS max-width (overrides `size`)" },
|
|
5497
|
-
{ name: "padding", type: "string", optional: true, enum:
|
|
5090
|
+
{ name: "padding", type: "string", optional: true, enum: SPACING_TOKENS, description: "Horizontal padding (default md)" }
|
|
5498
5091
|
],
|
|
5499
5092
|
render: (_node, props, helpers) => {
|
|
5500
5093
|
const root = el("div", {
|
|
5501
5094
|
class: "rui-container",
|
|
5502
5095
|
"data-size": asString(props.size, "lg"),
|
|
5503
|
-
"data-padding":
|
|
5096
|
+
"data-padding": normalizeSpacingToken(props.padding, "md"),
|
|
5504
5097
|
style: props.maxWidth ? `max-width:${sanitiseCssLength(props.maxWidth, "auto")};` : null
|
|
5505
5098
|
});
|
|
5506
5099
|
for (const child of asArray(props.children)) root.append(helpers.renderNode(child));
|
|
@@ -5511,11 +5104,11 @@ const Spacer = {
|
|
|
5511
5104
|
name: "Spacer",
|
|
5512
5105
|
description: 'Explicit space element for fine layout control. By default acts as a flex spacer that pushes following content to the far edge (use inside `Stack(direction="row")`). Pass `size` to render a fixed vertical/horizontal gap instead.',
|
|
5513
5106
|
props: [
|
|
5514
|
-
{ name: "size", type: "string", optional: true, enum:
|
|
5107
|
+
{ name: "size", type: "string", optional: true, enum: SPACING_TOKENS, description: "Fixed gap; omit to flex-grow" },
|
|
5515
5108
|
{ name: "flex", type: "boolean", optional: true, description: "Flex-grow even when size is set (default true when size omitted)" }
|
|
5516
5109
|
],
|
|
5517
5110
|
render: (_node, props) => {
|
|
5518
|
-
const size = asString(props.size);
|
|
5111
|
+
const size = normalizeSpacingToken(props.size, asString(props.size));
|
|
5519
5112
|
const flex = props.flex === void 0 ? !size : asBoolean(props.flex);
|
|
5520
5113
|
return el("span", {
|
|
5521
5114
|
class: "rui-spacer",
|
|
@@ -6314,7 +5907,7 @@ function attachOnChange(element, callback, helpers, options) {
|
|
|
6314
5907
|
helpers.invoke(callback, options.getValue(element));
|
|
6315
5908
|
});
|
|
6316
5909
|
}
|
|
6317
|
-
const BUTTON_VARIANTS$1 = ["primary", "secondary", "ghost", "danger"];
|
|
5910
|
+
const BUTTON_VARIANTS$1 = ["primary", "secondary", "outline", "ghost", "link", "danger", "default"];
|
|
6318
5911
|
const BUTTON_SIZES$1 = ["xs", "sm", "md", "lg", "xl"];
|
|
6319
5912
|
const INPUT_TYPES = ["text", "email", "password", "number", "tel", "url", "date"];
|
|
6320
5913
|
function normaliseButtonSize$1(value) {
|
|
@@ -6342,7 +5935,7 @@ const Button = {
|
|
|
6342
5935
|
props: [
|
|
6343
5936
|
{ name: "label", type: "string" },
|
|
6344
5937
|
{ name: "onClick", type: "callable", optional: true, aliases: ["action", "onclick"], description: "Callable invoked when the button is clicked" },
|
|
6345
|
-
{ name: "variant", type: "string", optional: true, aliases: ["tone"], enum: BUTTON_VARIANTS$1 },
|
|
5938
|
+
{ name: "variant", type: "string", optional: true, aliases: ["tone"], enum: BUTTON_VARIANTS$1, description: "Visual style — `primary` solid brand button (`default` is its alias), `secondary` surface + border, `outline` transparent with primary border, `ghost` bare, `link` text-only (underlines on hover), `danger` destructive" },
|
|
6346
5939
|
{ name: "type", type: "string", optional: true, enum: ["button", "submit"], description: "HTML button type" },
|
|
6347
5940
|
{ name: "size", type: "string", optional: true, enum: BUTTON_SIZES$1, description: "Size token `xs|sm|md|lg|xl`" },
|
|
6348
5941
|
{ name: "icon", type: "string", optional: true, description: "Optional Font Awesome icon name" },
|
|
@@ -14006,11 +13599,11 @@ const MasonryGrid = {
|
|
|
14006
13599
|
props: [
|
|
14007
13600
|
{ name: "items", type: "Node[]" },
|
|
14008
13601
|
{ name: "columns", type: "number", optional: true, description: "Preferred column count (default 3)" },
|
|
14009
|
-
{ name: "gap", type: "string", optional: true, enum:
|
|
13602
|
+
{ name: "gap", type: "string", optional: true, enum: SPACING_TOKENS }
|
|
14010
13603
|
],
|
|
14011
13604
|
render: (_node, props, helpers) => {
|
|
14012
13605
|
const columns = Math.max(1, Math.min(6, Math.floor(asNumber(props.columns, 3))));
|
|
14013
|
-
const gap =
|
|
13606
|
+
const gap = normalizeSpacingToken(props.gap, "md");
|
|
14014
13607
|
const root = el("div", {
|
|
14015
13608
|
class: "rui-masonry-grid",
|
|
14016
13609
|
"data-columns": String(columns),
|
|
@@ -14193,7 +13786,7 @@ const NavLink = {
|
|
|
14193
13786
|
}
|
|
14194
13787
|
};
|
|
14195
13788
|
const BUTTON_VARIANTS = ["primary", "secondary", "ghost", "danger"];
|
|
14196
|
-
const BUTTON_SIZES = ["xs", "sm", "md", "lg", "xl"
|
|
13789
|
+
const BUTTON_SIZES = ["xs", "sm", "md", "lg", "xl"];
|
|
14197
13790
|
function normaliseButtonSize(value) {
|
|
14198
13791
|
const v = asString(value).trim().toLowerCase();
|
|
14199
13792
|
if (v === "xs" || v === "extra-small") return "xs";
|
|
@@ -15485,7 +15078,7 @@ const Section = {
|
|
|
15485
15078
|
{ name: "children", type: "Node[]", positional: true, required: true },
|
|
15486
15079
|
{ name: "background", type: "string", optional: true, enum: ["base", "soft", "surface", "muted", "brand"], aliases: ["bg"] },
|
|
15487
15080
|
{ name: "width", type: "string", optional: true, enum: ["sm", "md", "lg", "xl", "full"] },
|
|
15488
|
-
{ name: "padding", type: "string", optional: true, enum: ["sm", "md", "lg"] },
|
|
15081
|
+
{ name: "padding", type: "string", optional: true, enum: ["none", "xs", "sm", "md", "lg", "xl"], description: "Band padding preset (default md)" },
|
|
15489
15082
|
{ name: "align", type: "string", optional: true, enum: ["left", "center"] },
|
|
15490
15083
|
{ name: "eyebrow", type: "string", optional: true },
|
|
15491
15084
|
{ name: "title", type: "string | Node[]", optional: true },
|
|
@@ -15497,7 +15090,7 @@ const Section = {
|
|
|
15497
15090
|
const root = el("section", {
|
|
15498
15091
|
class: "rui-section",
|
|
15499
15092
|
"data-bg": bg !== "base" ? bg : null,
|
|
15500
|
-
"data-pad": asString(props.padding) || null,
|
|
15093
|
+
"data-pad": normalizeSpacingToken(props.padding, asString(props.padding)) || null,
|
|
15501
15094
|
"data-align": asString(props.align) || null,
|
|
15502
15095
|
id: asString(props.id) || null
|
|
15503
15096
|
});
|
|
@@ -15562,7 +15155,7 @@ const Brand = {
|
|
|
15562
15155
|
description: "Logo + product name (+ optional version pill), linking home. Use in NavBar/Footer.",
|
|
15563
15156
|
props: [
|
|
15564
15157
|
{ name: "name", type: "string", positional: true, required: true, aliases: ["label"] },
|
|
15565
|
-
{ name: "logo", type: "string", optional: true, description: "Logo image src" },
|
|
15158
|
+
{ name: "logo", type: "string", optional: true, description: "Logo image src URL, e.g. https://example.com/logo.png" },
|
|
15566
15159
|
{ name: "version", type: "string", optional: true },
|
|
15567
15160
|
{ name: "href", type: "string", optional: true }
|
|
15568
15161
|
],
|
|
@@ -16156,7 +15749,7 @@ const Backdrop = {
|
|
|
16156
15749
|
].filter(Boolean).join(";");
|
|
16157
15750
|
root.append(el("div", { class: "rui-backdrop-blob", style }));
|
|
16158
15751
|
});
|
|
16159
|
-
const count = Math.max(0, Math.min(120, Math.round(asNumber(props.particles, 0))));
|
|
15752
|
+
const count = Math.max(0, Math.min(120, Math.round(asNumber(props.particles || 50, 0))));
|
|
16160
15753
|
if (count > 0) {
|
|
16161
15754
|
const typeRaw = asString(props.type, "network");
|
|
16162
15755
|
const palette = asArray(props.particleColors).map((c) => safeCssColor(asString(c), "")).filter(Boolean).slice(0, 8);
|
|
@@ -16635,7 +16228,7 @@ const Split = {
|
|
|
16635
16228
|
{ name: "left", type: "Node", positional: true, required: true, aliases: ["primary"] },
|
|
16636
16229
|
{ name: "right", type: "Node", required: true, aliases: ["secondary"] },
|
|
16637
16230
|
{ name: "ratio", type: "string", optional: true, description: "Column ratio: 1/1, 3/2, 2/3, 1/3, 2/1, etc." },
|
|
16638
|
-
{ name: "gap", type: "string", optional: true, enum:
|
|
16231
|
+
{ name: "gap", type: "string", optional: true, enum: SPACING_TOKENS },
|
|
16639
16232
|
{ name: "divider", type: "boolean", optional: true },
|
|
16640
16233
|
{ name: "sticky", type: "string", optional: true, enum: ["left", "right"], description: "Pin one pane while the other scrolls" },
|
|
16641
16234
|
{ name: "stackAt", type: "string", optional: true, enum: ["sm", "md", "lg"], description: "Breakpoint below which it stacks (default md)" },
|
|
@@ -16643,8 +16236,7 @@ const Split = {
|
|
|
16643
16236
|
],
|
|
16644
16237
|
render: (_node, props, helpers) => {
|
|
16645
16238
|
const ratio = RATIO_MAP[asString(props.ratio, "1/1")] ?? "1fr 1fr";
|
|
16646
|
-
const
|
|
16647
|
-
const gap = gapKey === "none" ? "0" : `var(--rui-spacing-${gapKey === "s" ? "s" : gapKey === "m" ? "m" : gapKey === "xl" ? "xl" : "l"})`;
|
|
16239
|
+
const gap = spacingCssValue(asString(props.gap, "lg")) || "var(--rui-spacing-l)";
|
|
16648
16240
|
const root = el("div", {
|
|
16649
16241
|
class: "rui-split",
|
|
16650
16242
|
"data-divider": asBoolean(props.divider) ? "true" : null,
|
|
@@ -16688,10 +16280,10 @@ function parseBentoSpan(span) {
|
|
|
16688
16280
|
}
|
|
16689
16281
|
const BentoCell = {
|
|
16690
16282
|
name: "BentoCell",
|
|
16691
|
-
description: 'A single cell in a Bento grid. `span`
|
|
16283
|
+
description: 'A single cell in a Bento grid. `span` names a size — `tile` 1×1, `wide` 2×1 (2 columns), `tall` 1×2 (2 rows), `hero` 2×2, `full` (a whole row) — or use a "CxR" string ("2x1"), a bare column-span number, or `{ col, row }`; `rowSpan` adds rows to a named/numeric span. The child stretches to fill the cell, so images/cards crop to the cell\'s shape. Pick spans that tile the parent Bento with no leftover tracks.',
|
|
16692
16284
|
props: [
|
|
16693
16285
|
{ name: "child", type: "Node", positional: true, required: true, aliases: ["children"] },
|
|
16694
|
-
{ name: "span", type: "string | number | object", optional: true, description: 'tile|wide|tall|hero|full, "2x1", 2, or { col, row }' },
|
|
16286
|
+
{ name: "span", type: "string | number | object", optional: true, description: 'tile (1×1) | wide (2×1) | tall (1×2) | hero (2×2) | full (whole row), "2x1", 2, or { col, row }' },
|
|
16695
16287
|
{ name: "rowSpan", type: "number", optional: true, description: "Rows to span (combines with a numeric/named span)" }
|
|
16696
16288
|
],
|
|
16697
16289
|
render: (_node, props, helpers) => {
|
|
@@ -16710,18 +16302,17 @@ const BentoCell = {
|
|
|
16710
16302
|
};
|
|
16711
16303
|
const Bento = {
|
|
16712
16304
|
name: "Bento",
|
|
16713
|
-
description: "Asymmetric 'bento box' grid
|
|
16305
|
+
description: "Asymmetric 'bento box' grid — the marquee feature-section layout. Children must be BentoCell nodes (a plain node becomes a 1×1 tile). Two rules make it look right: (1) spans must tile the grid exactly — each row's column spans sum to `columns` and row-spans pair up with neighbouring cells, never leaving a dangling track (e.g. `columns: 3` with 4 cells: hero 2×2 + tall 1×2 fill rows 1–2, wide 2×1 + tile fill row 3); (2) set a fixed `rowHeight` (e.g. \"180px\") whenever cells hold images or cards — the default auto row stretches to the tallest cell and makes the mosaic ragged. Give 1–2 standout cells a big span (hero/wide/tall) and keep the rest 1×1 tiles. `dense` (default true) backfills gaps. Collapses to 2 columns below 920px and 1 below 640px.",
|
|
16714
16306
|
props: [
|
|
16715
16307
|
{ name: "items", type: "BentoCell[]", positional: true, required: true, aliases: ["children", "cells"] },
|
|
16716
|
-
{ name: "columns", type: "number", optional: true, description: "Track count 1–8 (default 6)" },
|
|
16717
|
-
{ name: "gap", type: "string", optional: true, enum:
|
|
16718
|
-
{ name: "rowHeight", type: "string", optional: true, description:
|
|
16308
|
+
{ name: "columns", type: "number", optional: true, description: "Track count 1–8 (default 6) — pick it so the cell spans in every row can sum to it" },
|
|
16309
|
+
{ name: "gap", type: "string", optional: true, enum: SPACING_TOKENS },
|
|
16310
|
+
{ name: "rowHeight", type: "string", optional: true, description: 'Fixed row track size, e.g. "180px" — set it whenever any cell spans rows or holds images (default minmax(110px, auto) stretches rows to content)' },
|
|
16719
16311
|
{ name: "dense", type: "boolean", optional: true, description: "Backfill holes with later cells (default true)" }
|
|
16720
16312
|
],
|
|
16721
16313
|
render: (_node, props, helpers) => {
|
|
16722
16314
|
const cols = Math.max(1, Math.min(8, Math.round(asNumber(props.columns, 6))));
|
|
16723
|
-
const
|
|
16724
|
-
const gapKey = ["s", "m", "l", "xl"].includes(gapRaw) ? gapRaw : "m";
|
|
16315
|
+
const gapKey = normalizeSpacingToken(props.gap, "md");
|
|
16725
16316
|
const rowHeight = sanitiseCssLength(props.rowHeight, "");
|
|
16726
16317
|
const dense = props.dense === void 0 ? true : asBoolean(props.dense);
|
|
16727
16318
|
const root = el("div", {
|
|
@@ -19163,7 +18754,7 @@ const componentGroups = [
|
|
|
19163
18754
|
"- `Container([...], { size })` centers a wide page within a comfortable max-width (sm/md/lg/xl/full) — landing pages, articles, marketing sections.",
|
|
19164
18755
|
"- `Box([...], { padding?, margin?, border?, background?, maxWidth? })` is a plain spacing/surface wrapper for when a `Card` is too heavy.",
|
|
19165
18756
|
'- `Separator(orientation?, label?)` adds a visual break between sections; pass a `label` for a centered "OR"-style divider.',
|
|
19166
|
-
"- `gap`/`padding` spacing tokens are `xs|
|
|
18757
|
+
"- `gap`/`padding` spacing tokens are `none|3xs|2xs|xs|sm|md|lg|xl|2xl|3xl` (`none` = 0); `align`/`justify`/`columns`/`direction`/`gap` all accept responsive maps like `{base: …, md: …, lg: …}`.",
|
|
19167
18758
|
"- Use `Drawer` for side-panel detail views and `Modal` for centered dialogs. `Sticky(children, side?, offset?)` pins a toolbar/banner while content scrolls. `ResizablePanels(primary, secondary)` gives a user-resizable two-pane split. `MasonryGrid([...])` is for Pinterest-style mixed-height walls."
|
|
19168
18759
|
]
|
|
19169
18760
|
},
|
|
@@ -19524,13 +19115,880 @@ const componentGroups = [
|
|
|
19524
19115
|
"- `Styles(css)` injects a `<style>` block containing the given CSS rules (e.g. `` Styles(`.hero { background: linear-gradient(...); }`) ``). Pair it with `HTMLTag` (or any built-in component's `class`-bearing wrapper) when scoping to a custom selector. Payloads containing `</style>`, `<script>`, `expression(`, `javascript:`, `behavior:`, or `@import` are dropped."
|
|
19525
19116
|
]
|
|
19526
19117
|
}
|
|
19527
|
-
];
|
|
19528
|
-
assertOnePositionalMax(components);
|
|
19529
|
-
const defaultLibrary = {
|
|
19530
|
-
root: "Column",
|
|
19531
|
-
components,
|
|
19532
|
-
componentGroups
|
|
19533
|
-
};
|
|
19118
|
+
];
|
|
19119
|
+
assertOnePositionalMax(components);
|
|
19120
|
+
const defaultLibrary = {
|
|
19121
|
+
root: "Column",
|
|
19122
|
+
components,
|
|
19123
|
+
componentGroups
|
|
19124
|
+
};
|
|
19125
|
+
const projectParam = (prop) => {
|
|
19126
|
+
const param = {
|
|
19127
|
+
name: prop.name,
|
|
19128
|
+
type: prop.type,
|
|
19129
|
+
required: !prop.optional
|
|
19130
|
+
};
|
|
19131
|
+
if (prop.description) param.description = prop.description;
|
|
19132
|
+
if (prop.enum && prop.enum.length > 0) param.enumValues = prop.enum;
|
|
19133
|
+
return param;
|
|
19134
|
+
};
|
|
19135
|
+
const buildSignature = (spec) => {
|
|
19136
|
+
const parts = spec.props.map((p) => p.optional ? `${p.name}?` : p.name);
|
|
19137
|
+
return `${spec.name}(${parts.join(", ")})`;
|
|
19138
|
+
};
|
|
19139
|
+
const buildGroupIndex = (library) => {
|
|
19140
|
+
const index = /* @__PURE__ */ new Map();
|
|
19141
|
+
for (const group of library.componentGroups ?? []) {
|
|
19142
|
+
for (const name of group.components) index.set(name, group.name);
|
|
19143
|
+
}
|
|
19144
|
+
return index;
|
|
19145
|
+
};
|
|
19146
|
+
function getComponentCatalog(library = defaultLibrary) {
|
|
19147
|
+
const groupOf = buildGroupIndex(library);
|
|
19148
|
+
return library.components.map((spec) => ({
|
|
19149
|
+
name: spec.name,
|
|
19150
|
+
group: groupOf.get(spec.name) ?? "Other",
|
|
19151
|
+
description: spec.description,
|
|
19152
|
+
params: spec.props.map(projectParam),
|
|
19153
|
+
signature: buildSignature(spec)
|
|
19154
|
+
}));
|
|
19155
|
+
}
|
|
19156
|
+
function indexCatalog(entries) {
|
|
19157
|
+
const out = {};
|
|
19158
|
+
for (const entry of entries) out[entry.name] = entry;
|
|
19159
|
+
return out;
|
|
19160
|
+
}
|
|
19161
|
+
function getSignatureHelp(source, position, library = defaultLibrary) {
|
|
19162
|
+
const call = findActiveCall(source, position);
|
|
19163
|
+
if (!call || !call.callee) return null;
|
|
19164
|
+
const spec = findComponent(library, call.callee);
|
|
19165
|
+
if (spec) {
|
|
19166
|
+
const signature2 = libraryComponentSignature(call.callee, library);
|
|
19167
|
+
if (!signature2) return null;
|
|
19168
|
+
const activeParameter2 = resolveActiveSlot(call, spec, signature2.parameters.length);
|
|
19169
|
+
return { signatures: [signature2], activeSignature: 0, activeParameter: activeParameter2 };
|
|
19170
|
+
}
|
|
19171
|
+
const signature = builtinSignature(call.callee) ?? userSignature(call.callee, source);
|
|
19172
|
+
if (!signature) return null;
|
|
19173
|
+
const activeParameter = resolveDeclaredParam(call, signature.parameters.map((p) => p.label));
|
|
19174
|
+
return { signatures: [signature], activeSignature: 0, activeParameter };
|
|
19175
|
+
}
|
|
19176
|
+
function resolveActiveSlot(call, spec, paramCount) {
|
|
19177
|
+
const noHighlight = paramCount;
|
|
19178
|
+
const bagIdx = chooseNamedBagIndex(call.args, spec);
|
|
19179
|
+
if (call.objectArg !== null && call.argIndex === bagIdx) {
|
|
19180
|
+
const key = call.objectArg.activeKey;
|
|
19181
|
+
if (!key) return noHighlight;
|
|
19182
|
+
const exact = spec.props.findIndex((p) => p.name === key || (p.aliases?.includes(key) ?? false));
|
|
19183
|
+
if (exact >= 0) return exact;
|
|
19184
|
+
const prefix = spec.props.findIndex((p) => p.name.startsWith(key));
|
|
19185
|
+
return prefix >= 0 ? prefix : noHighlight;
|
|
19186
|
+
}
|
|
19187
|
+
let n = call.argIndex;
|
|
19188
|
+
if (bagIdx >= 0 && bagIdx < call.argIndex) n -= 1;
|
|
19189
|
+
const slot = slotForNthPositional(spec, n);
|
|
19190
|
+
if (!slot) return noHighlight;
|
|
19191
|
+
const index = spec.props.indexOf(slot);
|
|
19192
|
+
return index >= 0 ? index : noHighlight;
|
|
19193
|
+
}
|
|
19194
|
+
function resolveDeclaredParam(call, paramLabels) {
|
|
19195
|
+
if (paramLabels.length === 0) return 0;
|
|
19196
|
+
const names = paramLabels.map((label) => label.replace(/^\.\.\./, "").replace(/\?$/, ""));
|
|
19197
|
+
if (call.objectArg !== null) {
|
|
19198
|
+
const key = call.objectArg.activeKey;
|
|
19199
|
+
if (key) {
|
|
19200
|
+
const exact = names.indexOf(key);
|
|
19201
|
+
if (exact >= 0) return exact;
|
|
19202
|
+
const prefix = names.findIndex((name) => name.startsWith(key));
|
|
19203
|
+
if (prefix >= 0) return prefix;
|
|
19204
|
+
}
|
|
19205
|
+
return paramLabels.length;
|
|
19206
|
+
}
|
|
19207
|
+
return Math.min(call.argIndex, paramLabels.length - 1);
|
|
19208
|
+
}
|
|
19209
|
+
let cachedCatalog = null;
|
|
19210
|
+
function catalogFor(library) {
|
|
19211
|
+
if (cachedCatalog && cachedCatalog.library === library) return cachedCatalog.byName;
|
|
19212
|
+
const byName = {};
|
|
19213
|
+
for (const entry of getComponentCatalog(library)) byName[entry.name] = entry;
|
|
19214
|
+
cachedCatalog = { library, byName };
|
|
19215
|
+
return byName;
|
|
19216
|
+
}
|
|
19217
|
+
function libraryComponentSignature(callee, library) {
|
|
19218
|
+
const entry = catalogFor(library)[callee];
|
|
19219
|
+
if (!entry) return null;
|
|
19220
|
+
return {
|
|
19221
|
+
label: entry.signature,
|
|
19222
|
+
documentation: entry.description,
|
|
19223
|
+
parameters: entry.params.map((p) => ({
|
|
19224
|
+
label: p.required ? p.name : `${p.name}?`,
|
|
19225
|
+
documentation: paramDoc(p.type, p.enumValues, p.description)
|
|
19226
|
+
}))
|
|
19227
|
+
};
|
|
19228
|
+
}
|
|
19229
|
+
function builtinSignature(callee) {
|
|
19230
|
+
if (!callee.startsWith("$")) return null;
|
|
19231
|
+
const builtin = findBuiltin(callee.slice(1));
|
|
19232
|
+
if (!builtin) return null;
|
|
19233
|
+
return { label: builtin.signature, documentation: builtin.summary, parameters: [] };
|
|
19234
|
+
}
|
|
19235
|
+
function userSignature(callee, source) {
|
|
19236
|
+
let program;
|
|
19237
|
+
try {
|
|
19238
|
+
program = parse(source);
|
|
19239
|
+
} catch {
|
|
19240
|
+
return null;
|
|
19241
|
+
}
|
|
19242
|
+
for (const stmt of program.statements) {
|
|
19243
|
+
const matches = (stmt.kind === "ComponentDeclaration" || stmt.kind === "ActionDeclaration" || stmt.kind === "HookDeclaration") && stmt.name === callee;
|
|
19244
|
+
if (!matches) continue;
|
|
19245
|
+
const decl = stmt;
|
|
19246
|
+
const params = decl.params.map((p) => ({
|
|
19247
|
+
label: paramLabel(p)
|
|
19248
|
+
}));
|
|
19249
|
+
const label = `${callee}(${params.map((p) => p.label).join(", ")})`;
|
|
19250
|
+
return { label, documentation: `Declared in this file (${kindLabel(stmt.kind)}).`, parameters: params };
|
|
19251
|
+
}
|
|
19252
|
+
return null;
|
|
19253
|
+
}
|
|
19254
|
+
function paramLabel(p) {
|
|
19255
|
+
if (p.rest) return `...${p.name}`;
|
|
19256
|
+
return p.optional ? `${p.name}?` : p.name;
|
|
19257
|
+
}
|
|
19258
|
+
function kindLabel(kind) {
|
|
19259
|
+
if (kind === "ComponentDeclaration") return "component";
|
|
19260
|
+
if (kind === "ActionDeclaration") return "action";
|
|
19261
|
+
return "hook";
|
|
19262
|
+
}
|
|
19263
|
+
function paramDoc(type, enumValues, description) {
|
|
19264
|
+
const parts = [type];
|
|
19265
|
+
if (enumValues && enumValues.length > 0) {
|
|
19266
|
+
parts.push(`enum: ${enumValues.map((e) => `"${e}"`).join(" | ")}`);
|
|
19267
|
+
}
|
|
19268
|
+
const head = parts.join(" — ");
|
|
19269
|
+
return description ? `${head}
|
|
19270
|
+
|
|
19271
|
+
${description}` : head;
|
|
19272
|
+
}
|
|
19273
|
+
function analyseCallContext(source, position) {
|
|
19274
|
+
return findActiveCall(source, position);
|
|
19275
|
+
}
|
|
19276
|
+
function findActiveCall(source, position) {
|
|
19277
|
+
const offset = lineColumnToOffset$1(source, position);
|
|
19278
|
+
const stack = [];
|
|
19279
|
+
const currentArg = (frame) => {
|
|
19280
|
+
while (frame.args.length <= frame.commas) frame.args.push({ objectKeys: null });
|
|
19281
|
+
return frame.args[frame.commas];
|
|
19282
|
+
};
|
|
19283
|
+
const flushPendingKey = (obj, asShorthand) => {
|
|
19284
|
+
if (obj.pendingKey && asShorthand) obj.keys.push(obj.pendingKey);
|
|
19285
|
+
obj.pendingKey = "";
|
|
19286
|
+
};
|
|
19287
|
+
for (let i = 0; i < offset; i += 1) {
|
|
19288
|
+
const ch = source[i];
|
|
19289
|
+
if (ch === "/" && source[i + 1] === "/") {
|
|
19290
|
+
while (i < offset && source[i] !== "\n") i += 1;
|
|
19291
|
+
continue;
|
|
19292
|
+
}
|
|
19293
|
+
if (ch === "/" && source[i + 1] === "*") {
|
|
19294
|
+
i += 2;
|
|
19295
|
+
while (i < offset && !(source[i] === "*" && source[i + 1] === "/")) i += 1;
|
|
19296
|
+
i += 1;
|
|
19297
|
+
continue;
|
|
19298
|
+
}
|
|
19299
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
19300
|
+
i = skipString(source, i, ch, offset);
|
|
19301
|
+
continue;
|
|
19302
|
+
}
|
|
19303
|
+
const top = stack[stack.length - 1];
|
|
19304
|
+
if (ch === "(" || ch === "[" || ch === "{") {
|
|
19305
|
+
const callee = ch === "(" ? identifierBefore$1(source, i) : "";
|
|
19306
|
+
let argRecord = null;
|
|
19307
|
+
let object = null;
|
|
19308
|
+
if (ch === "{") {
|
|
19309
|
+
object = { keys: [], valueKey: null, expectingKey: true, pendingKey: "" };
|
|
19310
|
+
if (top && top.bracket === "(") {
|
|
19311
|
+
const arg = currentArg(top);
|
|
19312
|
+
if (arg.objectKeys === null) arg.objectKeys = object.keys;
|
|
19313
|
+
argRecord = arg;
|
|
19314
|
+
}
|
|
19315
|
+
}
|
|
19316
|
+
stack.push({ bracket: ch, callee, commas: 0, args: [], object, argRecord });
|
|
19317
|
+
continue;
|
|
19318
|
+
}
|
|
19319
|
+
if (ch === ")" || ch === "]" || ch === "}") {
|
|
19320
|
+
const closing = stack.pop();
|
|
19321
|
+
if (closing?.bracket === "{" && closing.object) {
|
|
19322
|
+
flushPendingKey(closing.object, closing.object.expectingKey);
|
|
19323
|
+
}
|
|
19324
|
+
continue;
|
|
19325
|
+
}
|
|
19326
|
+
if (!top) continue;
|
|
19327
|
+
if (ch === ",") {
|
|
19328
|
+
top.commas += 1;
|
|
19329
|
+
if (top.bracket === "(") currentArg(top);
|
|
19330
|
+
if (top.object) {
|
|
19331
|
+
flushPendingKey(top.object, top.object.expectingKey);
|
|
19332
|
+
top.object.expectingKey = true;
|
|
19333
|
+
top.object.valueKey = null;
|
|
19334
|
+
}
|
|
19335
|
+
continue;
|
|
19336
|
+
}
|
|
19337
|
+
if (top.object) {
|
|
19338
|
+
const obj = top.object;
|
|
19339
|
+
if (obj.expectingKey) {
|
|
19340
|
+
if (/[\w$]/.test(ch)) {
|
|
19341
|
+
obj.pendingKey += ch;
|
|
19342
|
+
} else if (ch === ":") {
|
|
19343
|
+
obj.keys.push(obj.pendingKey);
|
|
19344
|
+
obj.valueKey = obj.pendingKey;
|
|
19345
|
+
obj.pendingKey = "";
|
|
19346
|
+
obj.expectingKey = false;
|
|
19347
|
+
} else if (ch === "." && source.slice(i, i + 3) === "...") {
|
|
19348
|
+
obj.pendingKey = "";
|
|
19349
|
+
obj.expectingKey = false;
|
|
19350
|
+
i += 2;
|
|
19351
|
+
} else if (!/\s/.test(ch)) {
|
|
19352
|
+
obj.pendingKey = "";
|
|
19353
|
+
}
|
|
19354
|
+
}
|
|
19355
|
+
continue;
|
|
19356
|
+
}
|
|
19357
|
+
}
|
|
19358
|
+
for (let i = stack.length - 1; i >= 0; i -= 1) {
|
|
19359
|
+
const frame = stack[i];
|
|
19360
|
+
if (frame.bracket !== "(") continue;
|
|
19361
|
+
while (frame.args.length <= frame.commas) frame.args.push({ objectKeys: null });
|
|
19362
|
+
let objectArg = null;
|
|
19363
|
+
const inner = stack[i + 1];
|
|
19364
|
+
if (inner && inner.bracket === "{" && inner.object && inner.argRecord) {
|
|
19365
|
+
const obj = inner.object;
|
|
19366
|
+
objectArg = { activeKey: obj.expectingKey ? obj.pendingKey : obj.valueKey ?? "" };
|
|
19367
|
+
}
|
|
19368
|
+
return {
|
|
19369
|
+
callee: frame.callee,
|
|
19370
|
+
argIndex: frame.commas,
|
|
19371
|
+
args: frame.args.map((a) => ({ objectKeys: a.objectKeys })),
|
|
19372
|
+
objectArg
|
|
19373
|
+
};
|
|
19374
|
+
}
|
|
19375
|
+
return null;
|
|
19376
|
+
}
|
|
19377
|
+
function skipString(source, start, quote, limit) {
|
|
19378
|
+
let i = start + 1;
|
|
19379
|
+
while (i < limit) {
|
|
19380
|
+
const ch = source[i];
|
|
19381
|
+
if (ch === "\\") {
|
|
19382
|
+
i += 2;
|
|
19383
|
+
continue;
|
|
19384
|
+
}
|
|
19385
|
+
if (ch === quote) return i;
|
|
19386
|
+
i += 1;
|
|
19387
|
+
}
|
|
19388
|
+
return limit - 1;
|
|
19389
|
+
}
|
|
19390
|
+
function identifierBefore$1(source, parenIndex) {
|
|
19391
|
+
let end = parenIndex;
|
|
19392
|
+
while (end > 0 && /\s/.test(source[end - 1])) end -= 1;
|
|
19393
|
+
let start = end;
|
|
19394
|
+
while (start > 0 && /[\w$]/.test(source[start - 1])) start -= 1;
|
|
19395
|
+
return source.slice(start, end);
|
|
19396
|
+
}
|
|
19397
|
+
function lineColumnToOffset$1(source, pos) {
|
|
19398
|
+
let line = 1;
|
|
19399
|
+
let col = 1;
|
|
19400
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
19401
|
+
if (line === pos.line && col === pos.column) return i;
|
|
19402
|
+
if (source[i] === "\n") {
|
|
19403
|
+
line += 1;
|
|
19404
|
+
col = 1;
|
|
19405
|
+
} else {
|
|
19406
|
+
col += 1;
|
|
19407
|
+
}
|
|
19408
|
+
}
|
|
19409
|
+
return source.length;
|
|
19410
|
+
}
|
|
19411
|
+
const KEYWORDS = [
|
|
19412
|
+
{ label: "function", detail: "Declare a component or action — either case works" },
|
|
19413
|
+
{ label: "$effect", detail: "Reactive side-effect: $effect(() => { ... }, [deps])" },
|
|
19414
|
+
{ label: "$router", detail: "pages = $router({ '/': Home(), default: NotFound() })" },
|
|
19415
|
+
{ label: "switch", detail: "switch (value) { case …: …; break; default: … }" },
|
|
19416
|
+
{ label: "for", detail: "for (let x of xs) { … }" },
|
|
19417
|
+
{ label: "if", detail: "if (condition) { … } else { … }" },
|
|
19418
|
+
{ label: "return", detail: "Return value from a component or action" },
|
|
19419
|
+
{ label: "let", detail: "Declare a variable (reactive if $-prefixed)" },
|
|
19420
|
+
{ label: "const", detail: "Declare a constant" },
|
|
19421
|
+
{ label: "$emit", detail: "$emit('name', detail) — dispatch a CustomEvent" },
|
|
19422
|
+
{ label: "cleanup", detail: "Register an effect teardown callback" }
|
|
19423
|
+
];
|
|
19424
|
+
function getDiagnostics(source, library) {
|
|
19425
|
+
const program = parse(source);
|
|
19426
|
+
const schemaErrors = validateProgramSchema(program, library);
|
|
19427
|
+
return [
|
|
19428
|
+
...program.errors.map((e) => ({
|
|
19429
|
+
line: e.line,
|
|
19430
|
+
column: e.column,
|
|
19431
|
+
message: e.message,
|
|
19432
|
+
severity: "error"
|
|
19433
|
+
})),
|
|
19434
|
+
...schemaErrors.map((e) => ({
|
|
19435
|
+
line: e.line,
|
|
19436
|
+
column: e.column,
|
|
19437
|
+
message: e.message,
|
|
19438
|
+
severity: "error"
|
|
19439
|
+
}))
|
|
19440
|
+
];
|
|
19441
|
+
}
|
|
19442
|
+
function getCompletions(source, position, library) {
|
|
19443
|
+
const ctx = analyseCursor(source, position);
|
|
19444
|
+
const user = collectUserSymbols(source);
|
|
19445
|
+
if (ctx.afterDollar) {
|
|
19446
|
+
return [
|
|
19447
|
+
...user.atoms.map((name) => ({
|
|
19448
|
+
label: `$${name}`,
|
|
19449
|
+
kind: "state",
|
|
19450
|
+
detail: "Reactive atom declared in this file"
|
|
19451
|
+
})),
|
|
19452
|
+
{ label: "$name = value", kind: "state", detail: "Declare or assign a reactive atom" },
|
|
19453
|
+
...builtinCatalog.map((b) => ({
|
|
19454
|
+
label: b.signature,
|
|
19455
|
+
kind: "builtin",
|
|
19456
|
+
detail: b.summary
|
|
19457
|
+
}))
|
|
19458
|
+
];
|
|
19459
|
+
}
|
|
19460
|
+
const general = generalCompletions(library, user);
|
|
19461
|
+
const call = analyseCallContext(source, position);
|
|
19462
|
+
if (ctx.objectCallee) {
|
|
19463
|
+
const spec = findComponent(library, ctx.objectCallee);
|
|
19464
|
+
if (spec) {
|
|
19465
|
+
const isNamedBag = !call || call.objectArg === null || chooseNamedBagIndex(call.args, spec) === call.argIndex;
|
|
19466
|
+
if (isNamedBag) return [...propCompletions(spec), ...general];
|
|
19467
|
+
}
|
|
19468
|
+
return general;
|
|
19469
|
+
}
|
|
19470
|
+
if (call?.callee && call.objectArg === null) {
|
|
19471
|
+
const spec = findComponent(library, call.callee);
|
|
19472
|
+
if (spec) {
|
|
19473
|
+
const bagIdx = chooseNamedBagIndex(call.args, spec);
|
|
19474
|
+
if (bagIdx !== call.argIndex) {
|
|
19475
|
+
let n = call.argIndex;
|
|
19476
|
+
if (bagIdx >= 0 && bagIdx < call.argIndex) n -= 1;
|
|
19477
|
+
const slot = slotForNthPositional(spec, n);
|
|
19478
|
+
if (slot?.enum && slot.enum.length > 0) {
|
|
19479
|
+
const prefix = source.slice(0, lineColumnToOffset(source, position));
|
|
19480
|
+
const inString = /["']([\w-]*)$/.test(prefix);
|
|
19481
|
+
const values = slot.enum.map((value) => ({
|
|
19482
|
+
label: inString ? value : `"${value}"`,
|
|
19483
|
+
kind: "prop",
|
|
19484
|
+
detail: `${slot.name} value (${call.callee})`,
|
|
19485
|
+
documentation: slot.description
|
|
19486
|
+
}));
|
|
19487
|
+
return [...values, ...general];
|
|
19488
|
+
}
|
|
19489
|
+
}
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
return general;
|
|
19493
|
+
}
|
|
19494
|
+
function generalCompletions(library, user) {
|
|
19495
|
+
const keywordItems = /* @__PURE__ */ new Map();
|
|
19496
|
+
for (const [label, doc] of Object.entries(keywordDocs)) {
|
|
19497
|
+
keywordItems.set(label, {
|
|
19498
|
+
label,
|
|
19499
|
+
kind: "keyword",
|
|
19500
|
+
detail: doc.summary,
|
|
19501
|
+
documentation: `${doc.syntax}
|
|
19502
|
+
|
|
19503
|
+
${doc.example}`
|
|
19504
|
+
});
|
|
19505
|
+
}
|
|
19506
|
+
for (const k of KEYWORDS) {
|
|
19507
|
+
if (!keywordItems.has(k.label)) {
|
|
19508
|
+
keywordItems.set(k.label, { label: k.label, kind: "keyword", detail: k.detail });
|
|
19509
|
+
}
|
|
19510
|
+
}
|
|
19511
|
+
return [
|
|
19512
|
+
// Author-declared symbols first so they rank above the large library
|
|
19513
|
+
// list in editors that preserve provider order.
|
|
19514
|
+
...user.components.map((name) => ({
|
|
19515
|
+
label: name,
|
|
19516
|
+
kind: "component",
|
|
19517
|
+
detail: "Component declared in this file"
|
|
19518
|
+
})),
|
|
19519
|
+
...user.actions.map((name) => ({
|
|
19520
|
+
label: name,
|
|
19521
|
+
kind: "builtin",
|
|
19522
|
+
detail: "Action declared in this file"
|
|
19523
|
+
})),
|
|
19524
|
+
...user.atoms.map((name) => ({
|
|
19525
|
+
label: `$${name}`,
|
|
19526
|
+
kind: "state",
|
|
19527
|
+
detail: "Reactive atom declared in this file"
|
|
19528
|
+
})),
|
|
19529
|
+
...keywordItems.values(),
|
|
19530
|
+
...library.components.map((c) => ({
|
|
19531
|
+
label: c.name,
|
|
19532
|
+
kind: "component",
|
|
19533
|
+
detail: signaturePreview(c),
|
|
19534
|
+
documentation: c.description
|
|
19535
|
+
}))
|
|
19536
|
+
];
|
|
19537
|
+
}
|
|
19538
|
+
function collectUserSymbols(source) {
|
|
19539
|
+
const atoms = /* @__PURE__ */ new Set();
|
|
19540
|
+
const components2 = /* @__PURE__ */ new Set();
|
|
19541
|
+
const actions = /* @__PURE__ */ new Set();
|
|
19542
|
+
try {
|
|
19543
|
+
const program = parse(source);
|
|
19544
|
+
for (const stmt of program.statements) {
|
|
19545
|
+
if (stmt.kind === "Assignment" && stmt.isState && stmt.identifier) {
|
|
19546
|
+
atoms.add(stmt.identifier);
|
|
19547
|
+
} else if (stmt.kind === "ComponentDeclaration" && stmt.name) {
|
|
19548
|
+
components2.add(stmt.name);
|
|
19549
|
+
} else if (stmt.kind === "ActionDeclaration" && stmt.name) {
|
|
19550
|
+
actions.add(stmt.name);
|
|
19551
|
+
}
|
|
19552
|
+
}
|
|
19553
|
+
} catch {
|
|
19554
|
+
}
|
|
19555
|
+
return { atoms: [...atoms], components: [...components2], actions: [...actions] };
|
|
19556
|
+
}
|
|
19557
|
+
function getHoverInfo(source, position, library) {
|
|
19558
|
+
const word = wordAt(source, position);
|
|
19559
|
+
if (!word) return null;
|
|
19560
|
+
const spec = findComponent(library, word);
|
|
19561
|
+
if (spec) {
|
|
19562
|
+
return {
|
|
19563
|
+
kind: "component",
|
|
19564
|
+
contents: `**${spec.name}** — ${spec.description ?? "Component."}
|
|
19565
|
+
|
|
19566
|
+
Signature: \`${signaturePreview(spec)}\``
|
|
19567
|
+
};
|
|
19568
|
+
}
|
|
19569
|
+
if (word.startsWith("$")) {
|
|
19570
|
+
const builtin = findBuiltin(word.slice(1));
|
|
19571
|
+
if (builtin) {
|
|
19572
|
+
return {
|
|
19573
|
+
kind: "builtin",
|
|
19574
|
+
contents: `**${builtin.sigil}** — ${builtin.summary}
|
|
19575
|
+
|
|
19576
|
+
Signature: \`${builtin.signature}\``
|
|
19577
|
+
};
|
|
19578
|
+
}
|
|
19579
|
+
return { kind: "state", contents: `**${word}** — reactive state atom` };
|
|
19580
|
+
}
|
|
19581
|
+
const doc = keywordDocs[word];
|
|
19582
|
+
if (doc) {
|
|
19583
|
+
return { kind: "unknown", contents: formatKeywordHover(word, doc) };
|
|
19584
|
+
}
|
|
19585
|
+
const kw = KEYWORDS.find((k) => k.label === word);
|
|
19586
|
+
if (kw) {
|
|
19587
|
+
return { kind: "unknown", contents: `**${word}** — ${kw.detail}` };
|
|
19588
|
+
}
|
|
19589
|
+
return null;
|
|
19590
|
+
}
|
|
19591
|
+
function formatKeywordHover(word, doc) {
|
|
19592
|
+
return `**${word}** — ${doc.summary}
|
|
19593
|
+
|
|
19594
|
+
**Syntax**
|
|
19595
|
+
|
|
19596
|
+
\`\`\`js
|
|
19597
|
+
${doc.syntax}
|
|
19598
|
+
\`\`\`
|
|
19599
|
+
|
|
19600
|
+
**Example**
|
|
19601
|
+
|
|
19602
|
+
\`\`\`js
|
|
19603
|
+
${doc.example}
|
|
19604
|
+
\`\`\``;
|
|
19605
|
+
}
|
|
19606
|
+
function analyseCursor(source, position) {
|
|
19607
|
+
const offset = lineColumnToOffset(source, position);
|
|
19608
|
+
const prefix = source.slice(0, offset);
|
|
19609
|
+
const afterDollar = /\$[A-Za-z_]*$/.test(prefix);
|
|
19610
|
+
const stack = [];
|
|
19611
|
+
for (let i = 0; i < prefix.length; i += 1) {
|
|
19612
|
+
const ch = prefix[i];
|
|
19613
|
+
if (ch === "/" && prefix[i + 1] === "/") {
|
|
19614
|
+
while (i < prefix.length && prefix[i] !== "\n") i += 1;
|
|
19615
|
+
continue;
|
|
19616
|
+
}
|
|
19617
|
+
if (ch === "/" && prefix[i + 1] === "*") {
|
|
19618
|
+
i += 2;
|
|
19619
|
+
while (i < prefix.length && !(prefix[i] === "*" && prefix[i + 1] === "/")) i += 1;
|
|
19620
|
+
i += 1;
|
|
19621
|
+
continue;
|
|
19622
|
+
}
|
|
19623
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
19624
|
+
i = skipStringLiteral(prefix, i, ch);
|
|
19625
|
+
continue;
|
|
19626
|
+
}
|
|
19627
|
+
if (ch === "(" || ch === "[" || ch === "{") {
|
|
19628
|
+
stack.push({ bracket: ch, callee: ch === "(" ? identifierBefore(prefix, i) : "" });
|
|
19629
|
+
} else if (ch === ")" || ch === "]" || ch === "}") {
|
|
19630
|
+
stack.pop();
|
|
19631
|
+
}
|
|
19632
|
+
}
|
|
19633
|
+
let objectCallee;
|
|
19634
|
+
const top = stack[stack.length - 1];
|
|
19635
|
+
if (top && top.bracket === "{") {
|
|
19636
|
+
for (let i = stack.length - 1; i >= 0; i -= 1) {
|
|
19637
|
+
if (stack[i].bracket === "(") {
|
|
19638
|
+
const callee = stack[i].callee;
|
|
19639
|
+
if (callee) objectCallee = callee;
|
|
19640
|
+
break;
|
|
19641
|
+
}
|
|
19642
|
+
}
|
|
19643
|
+
}
|
|
19644
|
+
return { objectCallee, afterDollar };
|
|
19645
|
+
}
|
|
19646
|
+
function skipStringLiteral(source, start, quote) {
|
|
19647
|
+
let i = start + 1;
|
|
19648
|
+
while (i < source.length) {
|
|
19649
|
+
const ch = source[i];
|
|
19650
|
+
if (ch === "\\") {
|
|
19651
|
+
i += 2;
|
|
19652
|
+
continue;
|
|
19653
|
+
}
|
|
19654
|
+
if (ch === quote) return i;
|
|
19655
|
+
i += 1;
|
|
19656
|
+
}
|
|
19657
|
+
return source.length - 1;
|
|
19658
|
+
}
|
|
19659
|
+
function identifierBefore(source, openIndex) {
|
|
19660
|
+
let end = openIndex;
|
|
19661
|
+
while (end > 0 && /\s/.test(source[end - 1])) end -= 1;
|
|
19662
|
+
let start = end;
|
|
19663
|
+
while (start > 0 && /[\w$]/.test(source[start - 1])) start -= 1;
|
|
19664
|
+
return source.slice(start, end);
|
|
19665
|
+
}
|
|
19666
|
+
function propCompletions(spec) {
|
|
19667
|
+
const positional = findPositionalProp(spec);
|
|
19668
|
+
return spec.props.map((prop) => ({
|
|
19669
|
+
label: `${prop.name}:`,
|
|
19670
|
+
kind: "prop",
|
|
19671
|
+
detail: propDetail(prop, positional?.name === prop.name),
|
|
19672
|
+
documentation: prop.description
|
|
19673
|
+
}));
|
|
19674
|
+
}
|
|
19675
|
+
function propDetail(prop, isPositional) {
|
|
19676
|
+
const tags = [];
|
|
19677
|
+
if (isPositional) tags.push("positional");
|
|
19678
|
+
if (prop.required) tags.push("required");
|
|
19679
|
+
if (prop.enum) tags.push(`enum: ${prop.enum.map((e) => `"${e}"`).join(" | ")}`);
|
|
19680
|
+
const tagText = tags.length > 0 ? ` (${tags.join(", ")})` : "";
|
|
19681
|
+
return `${prop.type}${tagText}`;
|
|
19682
|
+
}
|
|
19683
|
+
function signaturePreview(spec) {
|
|
19684
|
+
const positional = findPositionalProp(spec);
|
|
19685
|
+
const positionalLabel = positional ? positional.name : "";
|
|
19686
|
+
const rest = spec.props.filter((p) => p.name !== positional?.name).map((p) => `${p.name}${p.optional || !p.required ? "?" : ""}: ${p.type}`).join(", ");
|
|
19687
|
+
if (positionalLabel === "" && rest === "") return `${spec.name}()`;
|
|
19688
|
+
if (positionalLabel === "") return `${spec.name}(${rest})`;
|
|
19689
|
+
if (rest === "") return `${spec.name}(${positionalLabel})`;
|
|
19690
|
+
return `${spec.name}(${positionalLabel}, ${rest})`;
|
|
19691
|
+
}
|
|
19692
|
+
function lineColumnToOffset(source, pos) {
|
|
19693
|
+
let line = 1;
|
|
19694
|
+
let col = 1;
|
|
19695
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
19696
|
+
if (line === pos.line && col === pos.column) return i;
|
|
19697
|
+
if (source[i] === "\n") {
|
|
19698
|
+
line += 1;
|
|
19699
|
+
col = 1;
|
|
19700
|
+
} else {
|
|
19701
|
+
col += 1;
|
|
19702
|
+
}
|
|
19703
|
+
}
|
|
19704
|
+
return source.length;
|
|
19705
|
+
}
|
|
19706
|
+
function wordAt(source, pos) {
|
|
19707
|
+
const offset = lineColumnToOffset(source, pos);
|
|
19708
|
+
const isWord = (c) => /[\w$]/.test(c);
|
|
19709
|
+
let start = offset;
|
|
19710
|
+
while (start > 0 && isWord(source[start - 1])) start -= 1;
|
|
19711
|
+
let end = offset;
|
|
19712
|
+
while (end < source.length && isWord(source[end])) end += 1;
|
|
19713
|
+
if (start === end) return null;
|
|
19714
|
+
return source.slice(start, end);
|
|
19715
|
+
}
|
|
19716
|
+
function getDefinition(source, position) {
|
|
19717
|
+
const tokens = tokenize(source);
|
|
19718
|
+
const tok = findNameTokenAt(tokens, position);
|
|
19719
|
+
if (!tok) return null;
|
|
19720
|
+
const sym = resolveSymbol(tokens, tok);
|
|
19721
|
+
return sym ? sym.range : null;
|
|
19722
|
+
}
|
|
19723
|
+
function getDefinitionTarget(source, position) {
|
|
19724
|
+
const tokens = tokenize(source);
|
|
19725
|
+
const imports = parseImports(tokens);
|
|
19726
|
+
for (const clause of imports) {
|
|
19727
|
+
if (clause.sourceRange && positionInRange(position, clause.sourceRange)) {
|
|
19728
|
+
return { kind: "module", moduleSource: clause.source };
|
|
19729
|
+
}
|
|
19730
|
+
}
|
|
19731
|
+
const tok = findNameTokenAt(tokens, position);
|
|
19732
|
+
if (!tok) return null;
|
|
19733
|
+
const wantsState = tok.type === "StateIdentifier";
|
|
19734
|
+
for (const clause of imports) {
|
|
19735
|
+
for (const spec of clause.specifiers) {
|
|
19736
|
+
if (spec.local === tok.value && spec.isState === wantsState) {
|
|
19737
|
+
return {
|
|
19738
|
+
kind: "import-binding",
|
|
19739
|
+
imported: spec.imported,
|
|
19740
|
+
isState: spec.isState,
|
|
19741
|
+
moduleSource: clause.source
|
|
19742
|
+
};
|
|
19743
|
+
}
|
|
19744
|
+
}
|
|
19745
|
+
}
|
|
19746
|
+
const sym = resolveSymbol(tokens, tok);
|
|
19747
|
+
if (sym && sym.kind !== "import") return { kind: "local", range: sym.range };
|
|
19748
|
+
return null;
|
|
19749
|
+
}
|
|
19750
|
+
function findDeclaration(source, name, isState) {
|
|
19751
|
+
const table = collectSymbols(tokenize(source));
|
|
19752
|
+
const decl = isState ? table.state.get(name) : table.ident.get(name);
|
|
19753
|
+
if (!decl || decl.kind === "import") return null;
|
|
19754
|
+
return decl.range;
|
|
19755
|
+
}
|
|
19756
|
+
function getReferences(source, position, options = {}) {
|
|
19757
|
+
const includeDeclaration = options.includeDeclaration ?? true;
|
|
19758
|
+
const tokens = tokenize(source);
|
|
19759
|
+
const tok = findNameTokenAt(tokens, position);
|
|
19760
|
+
if (!tok) return [];
|
|
19761
|
+
const refs = occurrences(tokens, tok.type, tok.value);
|
|
19762
|
+
if (includeDeclaration) return refs;
|
|
19763
|
+
const sym = resolveSymbol(tokens, tok);
|
|
19764
|
+
if (!sym) return refs;
|
|
19765
|
+
return refs.filter((r) => !rangesEqual(r, sym.range));
|
|
19766
|
+
}
|
|
19767
|
+
function getDocumentHighlights(source, position) {
|
|
19768
|
+
return getReferences(source, position, { includeDeclaration: true });
|
|
19769
|
+
}
|
|
19770
|
+
function getRenameEdits(source, position, newName) {
|
|
19771
|
+
const tokens = tokenize(source);
|
|
19772
|
+
const tok = findNameTokenAt(tokens, position);
|
|
19773
|
+
if (!tok) return { edits: [], error: "No symbol to rename at this position." };
|
|
19774
|
+
const sym = resolveSymbol(tokens, tok);
|
|
19775
|
+
if (!sym) {
|
|
19776
|
+
return {
|
|
19777
|
+
edits: [],
|
|
19778
|
+
error: "Only file-scoped components, actions, hooks, and reactive atoms can be renamed."
|
|
19779
|
+
};
|
|
19780
|
+
}
|
|
19781
|
+
const bare = sym.sigil ? newName.replace(/^\$/, "") : newName;
|
|
19782
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(bare)) {
|
|
19783
|
+
return { edits: [], error: `"${newName}" is not a valid Aktion identifier.` };
|
|
19784
|
+
}
|
|
19785
|
+
const replacement = sym.sigil ? `$${bare}` : bare;
|
|
19786
|
+
const edits = occurrences(tokens, tok.type, tok.value).map((range) => ({
|
|
19787
|
+
range,
|
|
19788
|
+
newText: replacement
|
|
19789
|
+
}));
|
|
19790
|
+
return { edits };
|
|
19791
|
+
}
|
|
19792
|
+
function getDocumentSymbols(source) {
|
|
19793
|
+
const tokens = tokenize(source);
|
|
19794
|
+
const table = collectSymbols(tokens);
|
|
19795
|
+
return table.all.map((decl) => ({
|
|
19796
|
+
name: decl.sigil ? `$${decl.name}` : decl.name,
|
|
19797
|
+
detail: detailFor(decl.kind),
|
|
19798
|
+
kind: decl.kind,
|
|
19799
|
+
range: decl.range,
|
|
19800
|
+
selectionRange: decl.range
|
|
19801
|
+
}));
|
|
19802
|
+
}
|
|
19803
|
+
function resolveSymbol(tokens, tok) {
|
|
19804
|
+
const table = collectSymbols(tokens);
|
|
19805
|
+
if (tok.type === "StateIdentifier") return table.state.get(tok.value) ?? null;
|
|
19806
|
+
return table.ident.get(tok.value) ?? null;
|
|
19807
|
+
}
|
|
19808
|
+
function collectSymbols(tokens) {
|
|
19809
|
+
const table = { state: /* @__PURE__ */ new Map(), ident: /* @__PURE__ */ new Map(), all: [] };
|
|
19810
|
+
const add = (decl) => {
|
|
19811
|
+
const bucket = decl.sigil ? table.state : table.ident;
|
|
19812
|
+
if (bucket.has(decl.name)) return;
|
|
19813
|
+
bucket.set(decl.name, decl);
|
|
19814
|
+
table.all.push(decl);
|
|
19815
|
+
};
|
|
19816
|
+
let depth = 0;
|
|
19817
|
+
let stmtStart = true;
|
|
19818
|
+
for (let i = 0; i < tokens.length; i += 1) {
|
|
19819
|
+
const t = tokens[i];
|
|
19820
|
+
if (t.type === "Newline" || t.type === "Semicolon") {
|
|
19821
|
+
stmtStart = true;
|
|
19822
|
+
continue;
|
|
19823
|
+
}
|
|
19824
|
+
if (t.type === "EOF") break;
|
|
19825
|
+
if (t.type === "Keyword" && t.value === "import") {
|
|
19826
|
+
i = scanImport(tokens, i, add);
|
|
19827
|
+
stmtStart = true;
|
|
19828
|
+
continue;
|
|
19829
|
+
}
|
|
19830
|
+
if (t.type === "Keyword" && t.value === "function") {
|
|
19831
|
+
const nameTok = nextMeaningful$1(tokens, i + 1);
|
|
19832
|
+
if (nameTok) {
|
|
19833
|
+
if (nameTok.type === "StateIdentifier") {
|
|
19834
|
+
add({ name: nameTok.value, kind: "hook", sigil: true, range: tokenRange(nameTok) });
|
|
19835
|
+
} else if (nameTok.type === "Identifier") {
|
|
19836
|
+
add({
|
|
19837
|
+
name: nameTok.value,
|
|
19838
|
+
kind: isPascalCase(nameTok.value) ? "component" : "action",
|
|
19839
|
+
sigil: false,
|
|
19840
|
+
range: tokenRange(nameTok)
|
|
19841
|
+
});
|
|
19842
|
+
}
|
|
19843
|
+
}
|
|
19844
|
+
}
|
|
19845
|
+
if (t.type === "StateIdentifier" && stmtStart && depth === 0) {
|
|
19846
|
+
const next = nextMeaningful$1(tokens, i + 1);
|
|
19847
|
+
if (next && next.type === "Operator" && next.value === "=") {
|
|
19848
|
+
add({ name: t.value, kind: "state", sigil: true, range: tokenRange(t) });
|
|
19849
|
+
}
|
|
19850
|
+
}
|
|
19851
|
+
if (t.type === "Punctuation" && t.value === "{") {
|
|
19852
|
+
depth += 1;
|
|
19853
|
+
stmtStart = true;
|
|
19854
|
+
} else if (t.type === "Punctuation" && t.value === "}") {
|
|
19855
|
+
depth = Math.max(0, depth - 1);
|
|
19856
|
+
stmtStart = true;
|
|
19857
|
+
} else if (t.type === "Keyword" && t.value === "export") ;
|
|
19858
|
+
else {
|
|
19859
|
+
stmtStart = false;
|
|
19860
|
+
}
|
|
19861
|
+
}
|
|
19862
|
+
return table;
|
|
19863
|
+
}
|
|
19864
|
+
function scanImport(tokens, start, add) {
|
|
19865
|
+
const { clause, end } = readImportClause(tokens, start);
|
|
19866
|
+
for (const spec of clause.specifiers) {
|
|
19867
|
+
add({ name: spec.local, kind: "import", sigil: spec.isState, range: spec.localRange });
|
|
19868
|
+
}
|
|
19869
|
+
return end;
|
|
19870
|
+
}
|
|
19871
|
+
function parseImports(tokens) {
|
|
19872
|
+
const clauses = [];
|
|
19873
|
+
for (let i = 0; i < tokens.length; i += 1) {
|
|
19874
|
+
if (tokens[i].type === "Keyword" && tokens[i].value === "import") {
|
|
19875
|
+
const { clause, end } = readImportClause(tokens, i);
|
|
19876
|
+
clauses.push(clause);
|
|
19877
|
+
i = end;
|
|
19878
|
+
}
|
|
19879
|
+
}
|
|
19880
|
+
return clauses;
|
|
19881
|
+
}
|
|
19882
|
+
function readImportClause(tokens, start) {
|
|
19883
|
+
const names = [];
|
|
19884
|
+
let source = "";
|
|
19885
|
+
let sourceRange = null;
|
|
19886
|
+
let i = start + 1;
|
|
19887
|
+
for (; i < tokens.length; i += 1) {
|
|
19888
|
+
const t = tokens[i];
|
|
19889
|
+
if (t.type === "Newline" || t.type === "Semicolon" || t.type === "EOF") break;
|
|
19890
|
+
if (t.type === "Identifier" && t.value === "from") {
|
|
19891
|
+
const src = nextMeaningful$1(tokens, i + 1);
|
|
19892
|
+
if (src && src.type === "String") {
|
|
19893
|
+
source = src.value;
|
|
19894
|
+
sourceRange = {
|
|
19895
|
+
start: { line: src.line, column: src.column },
|
|
19896
|
+
end: { line: src.line, column: src.column + src.value.length + 2 }
|
|
19897
|
+
};
|
|
19898
|
+
}
|
|
19899
|
+
break;
|
|
19900
|
+
}
|
|
19901
|
+
if (t.type === "Punctuation") continue;
|
|
19902
|
+
if (t.type === "Identifier" || t.type === "StateIdentifier") names.push(t);
|
|
19903
|
+
}
|
|
19904
|
+
const specifiers = [];
|
|
19905
|
+
for (let n = 0; n < names.length; n += 1) {
|
|
19906
|
+
const nameTok = names[n];
|
|
19907
|
+
const asTok = names[n + 1];
|
|
19908
|
+
if (asTok && asTok.type === "Identifier" && asTok.value === "as" && names[n + 2]) {
|
|
19909
|
+
const aliasTok = names[n + 2];
|
|
19910
|
+
specifiers.push({
|
|
19911
|
+
imported: nameTok.value,
|
|
19912
|
+
local: aliasTok.value,
|
|
19913
|
+
isState: aliasTok.type === "StateIdentifier",
|
|
19914
|
+
localRange: tokenRange(aliasTok)
|
|
19915
|
+
});
|
|
19916
|
+
n += 2;
|
|
19917
|
+
} else {
|
|
19918
|
+
specifiers.push({
|
|
19919
|
+
imported: nameTok.value,
|
|
19920
|
+
local: nameTok.value,
|
|
19921
|
+
isState: nameTok.type === "StateIdentifier",
|
|
19922
|
+
localRange: tokenRange(nameTok)
|
|
19923
|
+
});
|
|
19924
|
+
}
|
|
19925
|
+
}
|
|
19926
|
+
return { clause: { source, sourceRange, specifiers }, end: i - 1 };
|
|
19927
|
+
}
|
|
19928
|
+
function positionInRange(position, range) {
|
|
19929
|
+
if (position.line !== range.start.line || position.line !== range.end.line) return false;
|
|
19930
|
+
return position.column >= range.start.column && position.column <= range.end.column;
|
|
19931
|
+
}
|
|
19932
|
+
function occurrences(tokens, type, value) {
|
|
19933
|
+
const out = [];
|
|
19934
|
+
for (const t of tokens) {
|
|
19935
|
+
if (t.type === type && t.value === value) out.push(tokenRange(t));
|
|
19936
|
+
}
|
|
19937
|
+
return out;
|
|
19938
|
+
}
|
|
19939
|
+
function findNameTokenAt(tokens, position) {
|
|
19940
|
+
let best = null;
|
|
19941
|
+
for (const t of tokens) {
|
|
19942
|
+
if (t.type !== "Identifier" && t.type !== "StateIdentifier") continue;
|
|
19943
|
+
if (t.line !== position.line) continue;
|
|
19944
|
+
const startCol = t.column;
|
|
19945
|
+
const endCol = t.column + tokenTextLength(t);
|
|
19946
|
+
if (position.column >= startCol && position.column <= endCol) {
|
|
19947
|
+
if (!best || t.column > best.column) best = t;
|
|
19948
|
+
}
|
|
19949
|
+
}
|
|
19950
|
+
return best;
|
|
19951
|
+
}
|
|
19952
|
+
function nextMeaningful$1(tokens, from) {
|
|
19953
|
+
for (let i = from; i < tokens.length; i += 1) {
|
|
19954
|
+
const t = tokens[i];
|
|
19955
|
+
if (t.type === "Newline") continue;
|
|
19956
|
+
return t;
|
|
19957
|
+
}
|
|
19958
|
+
return null;
|
|
19959
|
+
}
|
|
19960
|
+
function tokenTextLength(t) {
|
|
19961
|
+
return t.type === "StateIdentifier" ? t.value.length + 1 : t.value.length;
|
|
19962
|
+
}
|
|
19963
|
+
function tokenRange(t) {
|
|
19964
|
+
const length = tokenTextLength(t);
|
|
19965
|
+
return {
|
|
19966
|
+
start: { line: t.line, column: t.column },
|
|
19967
|
+
end: { line: t.line, column: t.column + length }
|
|
19968
|
+
};
|
|
19969
|
+
}
|
|
19970
|
+
function rangesEqual(a, b) {
|
|
19971
|
+
return a.start.line === b.start.line && a.start.column === b.start.column && a.end.line === b.end.line && a.end.column === b.end.column;
|
|
19972
|
+
}
|
|
19973
|
+
function isPascalCase(name) {
|
|
19974
|
+
return /^[A-Z]/.test(name);
|
|
19975
|
+
}
|
|
19976
|
+
function detailFor(kind) {
|
|
19977
|
+
switch (kind) {
|
|
19978
|
+
case "component":
|
|
19979
|
+
return "component";
|
|
19980
|
+
case "action":
|
|
19981
|
+
return "action";
|
|
19982
|
+
case "hook":
|
|
19983
|
+
return "hook";
|
|
19984
|
+
case "state":
|
|
19985
|
+
return "reactive atom";
|
|
19986
|
+
case "import":
|
|
19987
|
+
return "import";
|
|
19988
|
+
default:
|
|
19989
|
+
return "";
|
|
19990
|
+
}
|
|
19991
|
+
}
|
|
19534
19992
|
const semanticTokenTypes = [
|
|
19535
19993
|
"namespace",
|
|
19536
19994
|
"class",
|
|
@@ -19627,188 +20085,6 @@ function nextMeaningful(tokens, from) {
|
|
|
19627
20085
|
function tokenLength(t) {
|
|
19628
20086
|
return t.type === "StateIdentifier" ? t.value.length + 1 : t.value.length;
|
|
19629
20087
|
}
|
|
19630
|
-
const projectParam = (prop) => {
|
|
19631
|
-
const param = {
|
|
19632
|
-
name: prop.name,
|
|
19633
|
-
type: prop.type,
|
|
19634
|
-
required: !prop.optional
|
|
19635
|
-
};
|
|
19636
|
-
if (prop.description) param.description = prop.description;
|
|
19637
|
-
if (prop.enum && prop.enum.length > 0) param.enumValues = prop.enum;
|
|
19638
|
-
return param;
|
|
19639
|
-
};
|
|
19640
|
-
const buildSignature = (spec) => {
|
|
19641
|
-
const parts = spec.props.map((p) => p.optional ? `${p.name}?` : p.name);
|
|
19642
|
-
return `${spec.name}(${parts.join(", ")})`;
|
|
19643
|
-
};
|
|
19644
|
-
const buildGroupIndex = (library) => {
|
|
19645
|
-
const index = /* @__PURE__ */ new Map();
|
|
19646
|
-
for (const group of library.componentGroups ?? []) {
|
|
19647
|
-
for (const name of group.components) index.set(name, group.name);
|
|
19648
|
-
}
|
|
19649
|
-
return index;
|
|
19650
|
-
};
|
|
19651
|
-
function getComponentCatalog(library = defaultLibrary) {
|
|
19652
|
-
const groupOf = buildGroupIndex(library);
|
|
19653
|
-
return library.components.map((spec) => ({
|
|
19654
|
-
name: spec.name,
|
|
19655
|
-
group: groupOf.get(spec.name) ?? "Other",
|
|
19656
|
-
description: spec.description,
|
|
19657
|
-
params: spec.props.map(projectParam),
|
|
19658
|
-
signature: buildSignature(spec)
|
|
19659
|
-
}));
|
|
19660
|
-
}
|
|
19661
|
-
function indexCatalog(entries) {
|
|
19662
|
-
const out = {};
|
|
19663
|
-
for (const entry of entries) out[entry.name] = entry;
|
|
19664
|
-
return out;
|
|
19665
|
-
}
|
|
19666
|
-
function getSignatureHelp(source, position, library = defaultLibrary) {
|
|
19667
|
-
const call = findActiveCall(source, position);
|
|
19668
|
-
if (!call || !call.callee) return null;
|
|
19669
|
-
const signature = libraryComponentSignature(call.callee, library) ?? builtinSignature(call.callee) ?? userSignature(call.callee, source);
|
|
19670
|
-
if (!signature) return null;
|
|
19671
|
-
const activeParameter = signature.parameters.length > 0 ? Math.min(call.argIndex, signature.parameters.length - 1) : 0;
|
|
19672
|
-
return { signatures: [signature], activeSignature: 0, activeParameter };
|
|
19673
|
-
}
|
|
19674
|
-
let cachedCatalog = null;
|
|
19675
|
-
function catalogFor(library) {
|
|
19676
|
-
if (cachedCatalog && cachedCatalog.library === library) return cachedCatalog.byName;
|
|
19677
|
-
const byName = {};
|
|
19678
|
-
for (const entry of getComponentCatalog(library)) byName[entry.name] = entry;
|
|
19679
|
-
cachedCatalog = { library, byName };
|
|
19680
|
-
return byName;
|
|
19681
|
-
}
|
|
19682
|
-
function libraryComponentSignature(callee, library) {
|
|
19683
|
-
const entry = catalogFor(library)[callee];
|
|
19684
|
-
if (!entry) return null;
|
|
19685
|
-
return {
|
|
19686
|
-
label: entry.signature,
|
|
19687
|
-
documentation: entry.description,
|
|
19688
|
-
parameters: entry.params.map((p) => ({
|
|
19689
|
-
label: p.required ? p.name : `${p.name}?`,
|
|
19690
|
-
documentation: paramDoc(p.type, p.enumValues, p.description)
|
|
19691
|
-
}))
|
|
19692
|
-
};
|
|
19693
|
-
}
|
|
19694
|
-
function builtinSignature(callee) {
|
|
19695
|
-
if (!callee.startsWith("$")) return null;
|
|
19696
|
-
const builtin = findBuiltin(callee.slice(1));
|
|
19697
|
-
if (!builtin) return null;
|
|
19698
|
-
return { label: builtin.signature, documentation: builtin.summary, parameters: [] };
|
|
19699
|
-
}
|
|
19700
|
-
function userSignature(callee, source) {
|
|
19701
|
-
let program;
|
|
19702
|
-
try {
|
|
19703
|
-
program = parse(source);
|
|
19704
|
-
} catch {
|
|
19705
|
-
return null;
|
|
19706
|
-
}
|
|
19707
|
-
for (const stmt of program.statements) {
|
|
19708
|
-
const matches = (stmt.kind === "ComponentDeclaration" || stmt.kind === "ActionDeclaration" || stmt.kind === "HookDeclaration") && stmt.name === callee;
|
|
19709
|
-
if (!matches) continue;
|
|
19710
|
-
const decl = stmt;
|
|
19711
|
-
const params = decl.params.map((p) => ({
|
|
19712
|
-
label: paramLabel(p)
|
|
19713
|
-
}));
|
|
19714
|
-
const label = `${callee}(${params.map((p) => p.label).join(", ")})`;
|
|
19715
|
-
return { label, documentation: `Declared in this file (${kindLabel(stmt.kind)}).`, parameters: params };
|
|
19716
|
-
}
|
|
19717
|
-
return null;
|
|
19718
|
-
}
|
|
19719
|
-
function paramLabel(p) {
|
|
19720
|
-
if (p.rest) return `...${p.name}`;
|
|
19721
|
-
return p.optional ? `${p.name}?` : p.name;
|
|
19722
|
-
}
|
|
19723
|
-
function kindLabel(kind) {
|
|
19724
|
-
if (kind === "ComponentDeclaration") return "component";
|
|
19725
|
-
if (kind === "ActionDeclaration") return "action";
|
|
19726
|
-
return "hook";
|
|
19727
|
-
}
|
|
19728
|
-
function paramDoc(type, enumValues, description) {
|
|
19729
|
-
const parts = [type];
|
|
19730
|
-
if (enumValues && enumValues.length > 0) {
|
|
19731
|
-
parts.push(`enum: ${enumValues.map((e) => `"${e}"`).join(" | ")}`);
|
|
19732
|
-
}
|
|
19733
|
-
const head = parts.join(" — ");
|
|
19734
|
-
return description ? `${head}
|
|
19735
|
-
|
|
19736
|
-
${description}` : head;
|
|
19737
|
-
}
|
|
19738
|
-
function findActiveCall(source, position) {
|
|
19739
|
-
const offset = lineColumnToOffset(source, position);
|
|
19740
|
-
const stack = [];
|
|
19741
|
-
for (let i = 0; i < offset; i += 1) {
|
|
19742
|
-
const ch = source[i];
|
|
19743
|
-
if (ch === "/" && source[i + 1] === "/") {
|
|
19744
|
-
while (i < offset && source[i] !== "\n") i += 1;
|
|
19745
|
-
continue;
|
|
19746
|
-
}
|
|
19747
|
-
if (ch === "/" && source[i + 1] === "*") {
|
|
19748
|
-
i += 2;
|
|
19749
|
-
while (i < offset && !(source[i] === "*" && source[i + 1] === "/")) i += 1;
|
|
19750
|
-
i += 1;
|
|
19751
|
-
continue;
|
|
19752
|
-
}
|
|
19753
|
-
if (ch === '"' || ch === "'" || ch === "`") {
|
|
19754
|
-
i = skipString(source, i, ch, offset);
|
|
19755
|
-
continue;
|
|
19756
|
-
}
|
|
19757
|
-
if (ch === "(" || ch === "[" || ch === "{") {
|
|
19758
|
-
const callee = ch === "(" ? identifierBefore(source, i) : "";
|
|
19759
|
-
stack.push({ bracket: ch, callee, commas: 0 });
|
|
19760
|
-
continue;
|
|
19761
|
-
}
|
|
19762
|
-
if (ch === ")" || ch === "]" || ch === "}") {
|
|
19763
|
-
stack.pop();
|
|
19764
|
-
continue;
|
|
19765
|
-
}
|
|
19766
|
-
if (ch === "," && stack.length > 0) {
|
|
19767
|
-
stack[stack.length - 1].commas += 1;
|
|
19768
|
-
}
|
|
19769
|
-
}
|
|
19770
|
-
for (let i = stack.length - 1; i >= 0; i -= 1) {
|
|
19771
|
-
const frame = stack[i];
|
|
19772
|
-
if (frame.bracket === "(") {
|
|
19773
|
-
return { callee: frame.callee, argIndex: frame.commas };
|
|
19774
|
-
}
|
|
19775
|
-
}
|
|
19776
|
-
return null;
|
|
19777
|
-
}
|
|
19778
|
-
function skipString(source, start, quote, limit) {
|
|
19779
|
-
let i = start + 1;
|
|
19780
|
-
while (i < limit) {
|
|
19781
|
-
const ch = source[i];
|
|
19782
|
-
if (ch === "\\") {
|
|
19783
|
-
i += 2;
|
|
19784
|
-
continue;
|
|
19785
|
-
}
|
|
19786
|
-
if (ch === quote) return i;
|
|
19787
|
-
i += 1;
|
|
19788
|
-
}
|
|
19789
|
-
return limit - 1;
|
|
19790
|
-
}
|
|
19791
|
-
function identifierBefore(source, parenIndex) {
|
|
19792
|
-
let end = parenIndex;
|
|
19793
|
-
while (end > 0 && /\s/.test(source[end - 1])) end -= 1;
|
|
19794
|
-
let start = end;
|
|
19795
|
-
while (start > 0 && /[\w$]/.test(source[start - 1])) start -= 1;
|
|
19796
|
-
return source.slice(start, end);
|
|
19797
|
-
}
|
|
19798
|
-
function lineColumnToOffset(source, pos) {
|
|
19799
|
-
let line = 1;
|
|
19800
|
-
let col = 1;
|
|
19801
|
-
for (let i = 0; i < source.length; i += 1) {
|
|
19802
|
-
if (line === pos.line && col === pos.column) return i;
|
|
19803
|
-
if (source[i] === "\n") {
|
|
19804
|
-
line += 1;
|
|
19805
|
-
col = 1;
|
|
19806
|
-
} else {
|
|
19807
|
-
col += 1;
|
|
19808
|
-
}
|
|
19809
|
-
}
|
|
19810
|
-
return source.length;
|
|
19811
|
-
}
|
|
19812
20088
|
const baseFonts = {
|
|
19813
20089
|
fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
19814
20090
|
fontFamilyHeading: "system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",
|
|
@@ -20179,7 +20455,7 @@ const snippetCatalog = [
|
|
|
20179
20455
|
{
|
|
20180
20456
|
name: "Row",
|
|
20181
20457
|
description: "Horizontal toolbar — label on the left, actions pushed to the right.",
|
|
20182
|
-
template: 'toolbar${1} = Row([\n Text("${2:Section title}", { variant: "large-heavy" }),\n Spacer(),\n Button("${3:Action}", { variant: "primary" })\n], { gap: "
|
|
20458
|
+
template: 'toolbar${1} = Row([\n Text("${2:Section title}", { variant: "large-heavy" }),\n Spacer(),\n Button("${3:Action}", { variant: "primary" })\n], { gap: "md" })'
|
|
20183
20459
|
},
|
|
20184
20460
|
{
|
|
20185
20461
|
name: "Center",
|
|
@@ -20204,7 +20480,7 @@ const snippetCatalog = [
|
|
|
20204
20480
|
{
|
|
20205
20481
|
name: "GridLayout",
|
|
20206
20482
|
description: "12-column sidebar layout with named GridItem spans.",
|
|
20207
|
-
template: 'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\n$app(Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "
|
|
20483
|
+
template: 'sidebar${1} = Card([CardHeader("${2:Sidebar}")])\nmain${1} = Card([CardHeader("${3:Main}")])\n$app(Grid([\n GridItem(sidebar${1}, { span: "1/4" }),\n GridItem(main${1}, { span: "3/4" })\n], { columns: 12, gap: "lg" }))'
|
|
20208
20484
|
},
|
|
20209
20485
|
{
|
|
20210
20486
|
name: "KanbanBoard",
|
|
@@ -20219,7 +20495,7 @@ const snippetCatalog = [
|
|
|
20219
20495
|
{
|
|
20220
20496
|
name: "Router",
|
|
20221
20497
|
description: "Multi-page router via $router({…}) with NavLink sidebar.",
|
|
20222
|
-
template: 'pages = $router({\n "/": HomePage(),\n "/dashboard": DashboardPage(),\n "/users/:id": UserPage(params.id),\n "/docs/*": DocsPage(params._),\n default: NotFoundPage()\n})\n\nfunction HomePage() {\n return Card([CardHeader("Welcome")])\n}\nfunction DashboardPage() {\n return Card([CardHeader("Dashboard")])\n}\nfunction UserPage(id) {\n return Card([CardHeader(`User ${id}`)])\n}\nfunction DocsPage(rest) {\n return Card([CardHeader(`Docs · ${rest}`)])\n}\nfunction NotFoundPage() {\n return Callout("Not found", { variant: "warning", description: `We couldn\'t find ${route.path}.` })\n}\n\nnav${1} = Row([\n NavLink("Home", { to: "/", variant: "ghost", exact: true }),\n NavLink("Dashboard", { to: "/dashboard", variant: "ghost" }),\n NavLink("Users", { to: "/users", variant: "ghost" })\n], { gap: "
|
|
20498
|
+
template: 'pages = $router({\n "/": HomePage(),\n "/dashboard": DashboardPage(),\n "/users/:id": UserPage(params.id),\n "/docs/*": DocsPage(params._),\n default: NotFoundPage()\n})\n\nfunction HomePage() {\n return Card([CardHeader("Welcome")])\n}\nfunction DashboardPage() {\n return Card([CardHeader("Dashboard")])\n}\nfunction UserPage(id) {\n return Card([CardHeader(`User ${id}`)])\n}\nfunction DocsPage(rest) {\n return Card([CardHeader(`Docs · ${rest}`)])\n}\nfunction NotFoundPage() {\n return Callout("Not found", { variant: "warning", description: `We couldn\'t find ${route.path}.` })\n}\n\nnav${1} = Row([\n NavLink("Home", { to: "/", variant: "ghost", exact: true }),\n NavLink("Dashboard", { to: "/dashboard", variant: "ghost" }),\n NavLink("Users", { to: "/users", variant: "ghost" })\n], { gap: "sm" })'
|
|
20223
20499
|
},
|
|
20224
20500
|
{
|
|
20225
20501
|
name: "Effect",
|
|
@@ -20309,7 +20585,7 @@ const snippetCatalog = [
|
|
|
20309
20585
|
{
|
|
20310
20586
|
name: "ResponsiveGrid",
|
|
20311
20587
|
description: "Grid with a responsive column map per breakpoint.",
|
|
20312
|
-
template: 'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:
|
|
20588
|
+
template: 'cards${1} = Grid(${2:items}, { columns: {sm: 1, md: 2, lg: 4}, gap: "${3:lg}" })'
|
|
20313
20589
|
},
|
|
20314
20590
|
// ── New feature snippets ──────────────────────────────────────────────────
|
|
20315
20591
|
{
|
|
@@ -20350,12 +20626,12 @@ const snippetCatalog = [
|
|
|
20350
20626
|
{
|
|
20351
20627
|
name: "SxCard",
|
|
20352
20628
|
description: "Card using the sx styling channel — responsive, interaction states, gradient.",
|
|
20353
|
-
template: 'Card([Text("${1:Content}")], {\n sx: {\n p: "${2:
|
|
20629
|
+
template: 'Card([Text("${1:Content}")], {\n sx: {\n p: "${2:lg}",\n radius: "${3:lg}",\n bg: "${4:surface}",\n shadow: "${5:md}",\n states: { hover: { scale: ${6:1.03}, shadow: "${7:lg}" } }\n }\n})'
|
|
20354
20630
|
},
|
|
20355
20631
|
{
|
|
20356
20632
|
name: "SxResponsive",
|
|
20357
20633
|
description: "sx with responsive breakpoint maps + logical spacing (RTL-safe).",
|
|
20358
|
-
template: 'Box([${1:children}], {\n sx: {\n p: { base: "${2:
|
|
20634
|
+
template: 'Box([${1:children}], {\n sx: {\n p: { base: "${2:md}", md: "${3:xl}" },\n direction: { base: "column", lg: "row" },\n px: "${4:lg}",\n fontSize: "${5:lg}",\n weight: "${6:600}"\n }\n})'
|
|
20359
20635
|
},
|
|
20360
20636
|
{
|
|
20361
20637
|
name: "FormAsync",
|
|
@@ -20365,7 +20641,7 @@ const snippetCatalog = [
|
|
|
20365
20641
|
{
|
|
20366
20642
|
name: "SocketReconnect",
|
|
20367
20643
|
description: "$socket with auto-reconnect + status-driven UI.",
|
|
20368
|
-
template: '${1:$chat} = $socket({ url: "${2:wss://example.com/room}", reconnect: true })\n\nColumn([\n Badge(${1:$chat}.status, { tone: ${1:$chat}.status == "open" ? "success" : "warning" }),\n List(${1:$chat}.messages.map((m) => ListItem(m.text))),\n Row([\n Input("draft", { value: ${3:$draft} }),\n Button("Send", { onClick: () => { ${1:$chat}.send({ text: ${3:$draft} }); ${3:$draft} = "" } })\n ], { gap: "
|
|
20644
|
+
template: '${1:$chat} = $socket({ url: "${2:wss://example.com/room}", reconnect: true })\n\nColumn([\n Badge(${1:$chat}.status, { tone: ${1:$chat}.status == "open" ? "success" : "warning" }),\n List(${1:$chat}.messages.map((m) => ListItem(m.text))),\n Row([\n Input("draft", { value: ${3:$draft} }),\n Button("Send", { onClick: () => { ${1:$chat}.send({ text: ${3:$draft} }); ${3:$draft} = "" } })\n ], { gap: "sm" })\n])'
|
|
20369
20645
|
},
|
|
20370
20646
|
{
|
|
20371
20647
|
name: "MarketingSection",
|