@designa8/vibedesign-v6 1.14.0 → 1.15.3
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 +1 -1
- package/dist/index.cjs +212 -6
- package/dist/index.js +212 -6
- package/dist/styles.css +46 -0
- package/package.json +1 -1
- package/src/atoms/CodeEditor/CodeEditor.tsx +182 -1
- package/src/atoms/FilterTabBar/FilterTabBar.tsx +23 -4
- package/src/atoms/FilterTabBar/preview.tsx +43 -53
- package/src/atoms/Icon/icons.data.ts +6 -0
- package/src/tokens.css +16 -0
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3597,7 +3597,13 @@ var ICON_REGISTRY = {
|
|
|
3597
3597
|
"close": { viewBox: "0 0 24 24", paths: ["M18 6 6 18", "M6 6l12 12"] },
|
|
3598
3598
|
"chevron-down": { viewBox: "0 0 24 24", paths: ["M6 9l6 6 6-6"] },
|
|
3599
3599
|
"copy-clipboard": { viewBox: "0 0 24 24", paths: ["M9 9h10v10H9z", "M5 15V5h10"] },
|
|
3600
|
-
"check-checkmark": { viewBox: "0 0 24 24", paths: ["M5 13l4 4L19 7"] }
|
|
3600
|
+
"check-checkmark": { viewBox: "0 0 24 24", paths: ["M5 13l4 4L19 7"] },
|
|
3601
|
+
"grid": { viewBox: "0 0 24 24", paths: ["M4 4h6v6H4z", "M14 4h6v6h-6z", "M4 14h6v6H4z", "M14 14h6v6h-6z"] },
|
|
3602
|
+
"atom": { viewBox: "0 0 24 24", paths: ["M12 12m-1.5 0a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0", "M12 3.5c4 0 8 3.6 8 8.5s-4 8.5-8 8.5", "M12 3.5c-4 1.8-8 5.6-8 8.5s4 6.7 8 8.5", "M4 8.5c1.8-4 5.6-5 8-5s6.2 1 8 5"] },
|
|
3603
|
+
"layers": { viewBox: "0 0 24 24", paths: ["M12 3l8 4.5-8 4.5-8-4.5 8-4.5z", "M4 12l8 4.5 8-4.5", "M4 16.5l8 4.5 8-4.5"] },
|
|
3604
|
+
"star": { viewBox: "0 0 24 24", paths: ["M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6-4.5-4.2 6.1-.7L12 3z"] },
|
|
3605
|
+
"archive": { viewBox: "0 0 24 24", paths: ["M3 4h18v4H3z", "M4.5 8v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V8", "M10 12.5h4"] },
|
|
3606
|
+
"list-view": { viewBox: "0 0 24 24", paths: ["M4 6h16", "M4 12h16", "M4 18h16"] }
|
|
3601
3607
|
};
|
|
3602
3608
|
|
|
3603
3609
|
// virtual-pkg:src/atoms/Icon/Icon.tsx
|
|
@@ -3640,6 +3646,200 @@ var LANG_LABEL = {
|
|
|
3640
3646
|
function LangBadge({ language }) {
|
|
3641
3647
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-flex h-lg min-w-[1.6rem] items-center justify-center rounded-xs bg-surface-strong px-xxs text-caption text-muted", children: LANG_LABEL[language] });
|
|
3642
3648
|
}
|
|
3649
|
+
var SYNTAX_CLASS = {
|
|
3650
|
+
plain: "text-ink",
|
|
3651
|
+
comment: "text-syntax-comment italic",
|
|
3652
|
+
string: "text-syntax-string",
|
|
3653
|
+
number: "text-syntax-number",
|
|
3654
|
+
keyword: "text-syntax-keyword",
|
|
3655
|
+
function: "text-syntax-function",
|
|
3656
|
+
type: "text-syntax-type",
|
|
3657
|
+
tag: "text-syntax-tag",
|
|
3658
|
+
property: "text-syntax-property",
|
|
3659
|
+
punctuation: "text-muted"
|
|
3660
|
+
};
|
|
3661
|
+
var JS_KEYWORDS = /* @__PURE__ */ new Set([
|
|
3662
|
+
"import",
|
|
3663
|
+
"export",
|
|
3664
|
+
"default",
|
|
3665
|
+
"from",
|
|
3666
|
+
"const",
|
|
3667
|
+
"let",
|
|
3668
|
+
"var",
|
|
3669
|
+
"function",
|
|
3670
|
+
"return",
|
|
3671
|
+
"interface",
|
|
3672
|
+
"type",
|
|
3673
|
+
"extends",
|
|
3674
|
+
"implements",
|
|
3675
|
+
"class",
|
|
3676
|
+
"new",
|
|
3677
|
+
"this",
|
|
3678
|
+
"if",
|
|
3679
|
+
"else",
|
|
3680
|
+
"for",
|
|
3681
|
+
"while",
|
|
3682
|
+
"switch",
|
|
3683
|
+
"case",
|
|
3684
|
+
"break",
|
|
3685
|
+
"continue",
|
|
3686
|
+
"true",
|
|
3687
|
+
"false",
|
|
3688
|
+
"null",
|
|
3689
|
+
"undefined",
|
|
3690
|
+
"void",
|
|
3691
|
+
"async",
|
|
3692
|
+
"await",
|
|
3693
|
+
"of",
|
|
3694
|
+
"in",
|
|
3695
|
+
"as",
|
|
3696
|
+
"public",
|
|
3697
|
+
"private",
|
|
3698
|
+
"protected",
|
|
3699
|
+
"readonly",
|
|
3700
|
+
"static",
|
|
3701
|
+
"enum",
|
|
3702
|
+
"namespace",
|
|
3703
|
+
"declare",
|
|
3704
|
+
"try",
|
|
3705
|
+
"catch",
|
|
3706
|
+
"finally",
|
|
3707
|
+
"throw",
|
|
3708
|
+
"yield",
|
|
3709
|
+
"typeof",
|
|
3710
|
+
"instanceof",
|
|
3711
|
+
"super"
|
|
3712
|
+
]);
|
|
3713
|
+
var TS_TYPES = /* @__PURE__ */ new Set([
|
|
3714
|
+
"string",
|
|
3715
|
+
"number",
|
|
3716
|
+
"boolean",
|
|
3717
|
+
"any",
|
|
3718
|
+
"unknown",
|
|
3719
|
+
"never",
|
|
3720
|
+
"object",
|
|
3721
|
+
"React",
|
|
3722
|
+
"Record",
|
|
3723
|
+
"Partial",
|
|
3724
|
+
"Readonly",
|
|
3725
|
+
"Promise",
|
|
3726
|
+
"HTMLDivElement",
|
|
3727
|
+
"HTMLButtonElement"
|
|
3728
|
+
]);
|
|
3729
|
+
var JS_TOKEN_RE = /(\/\/.*)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`)|(\b\d+(?:\.\d+)?\b)|(<\/?[A-Za-z][\w.]*)|([A-Za-z_$][\w$]*)/g;
|
|
3730
|
+
function tokenizeJs(line) {
|
|
3731
|
+
const tokens = [];
|
|
3732
|
+
let lastIndex = 0;
|
|
3733
|
+
let match;
|
|
3734
|
+
JS_TOKEN_RE.lastIndex = 0;
|
|
3735
|
+
while ((match = JS_TOKEN_RE.exec(line)) !== null) {
|
|
3736
|
+
if (match.index > lastIndex) {
|
|
3737
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3738
|
+
}
|
|
3739
|
+
if (match[1] !== void 0) {
|
|
3740
|
+
tokens.push({ text: match[1], type: "comment" });
|
|
3741
|
+
} else if (match[2] !== void 0) {
|
|
3742
|
+
tokens.push({ text: match[2], type: "string" });
|
|
3743
|
+
} else if (match[3] !== void 0) {
|
|
3744
|
+
tokens.push({ text: match[3], type: "number" });
|
|
3745
|
+
} else if (match[4] !== void 0) {
|
|
3746
|
+
tokens.push({ text: match[4], type: "tag" });
|
|
3747
|
+
} else if (match[5] !== void 0) {
|
|
3748
|
+
const word = match[5];
|
|
3749
|
+
const after = line.slice(JS_TOKEN_RE.lastIndex).match(/^\s*\(/);
|
|
3750
|
+
if (JS_KEYWORDS.has(word)) {
|
|
3751
|
+
tokens.push({ text: word, type: "keyword" });
|
|
3752
|
+
} else if (TS_TYPES.has(word)) {
|
|
3753
|
+
tokens.push({ text: word, type: "type" });
|
|
3754
|
+
} else if (after) {
|
|
3755
|
+
tokens.push({ text: word, type: "function" });
|
|
3756
|
+
} else {
|
|
3757
|
+
tokens.push({ text: word, type: "plain" });
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
lastIndex = JS_TOKEN_RE.lastIndex;
|
|
3761
|
+
}
|
|
3762
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3763
|
+
return tokens;
|
|
3764
|
+
}
|
|
3765
|
+
var CSS_TOKEN_RE = /(\/\*[\s\S]*?\*\/)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*")|(@[a-zA-Z-]+)|(#[0-9a-fA-F]{3,8}\b)|(-?\d+\.?\d*(?:px|em|rem|%|deg|s|ms|vh|vw)?\b)|([a-zA-Z-]+)(?=\s*:)/g;
|
|
3766
|
+
function tokenizeCss(line) {
|
|
3767
|
+
const tokens = [];
|
|
3768
|
+
let lastIndex = 0;
|
|
3769
|
+
let match;
|
|
3770
|
+
CSS_TOKEN_RE.lastIndex = 0;
|
|
3771
|
+
while ((match = CSS_TOKEN_RE.exec(line)) !== null) {
|
|
3772
|
+
if (match.index > lastIndex) {
|
|
3773
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3774
|
+
}
|
|
3775
|
+
if (match[1] !== void 0) tokens.push({ text: match[1], type: "comment" });
|
|
3776
|
+
else if (match[2] !== void 0) tokens.push({ text: match[2], type: "string" });
|
|
3777
|
+
else if (match[3] !== void 0) tokens.push({ text: match[3], type: "keyword" });
|
|
3778
|
+
else if (match[4] !== void 0) tokens.push({ text: match[4], type: "number" });
|
|
3779
|
+
else if (match[5] !== void 0) tokens.push({ text: match[5], type: "number" });
|
|
3780
|
+
else if (match[6] !== void 0) tokens.push({ text: match[6], type: "property" });
|
|
3781
|
+
lastIndex = CSS_TOKEN_RE.lastIndex;
|
|
3782
|
+
}
|
|
3783
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3784
|
+
return tokens;
|
|
3785
|
+
}
|
|
3786
|
+
var JSON_TOKEN_RE = /("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?)|\b(true|false|null)\b/g;
|
|
3787
|
+
function tokenizeJson(line) {
|
|
3788
|
+
const tokens = [];
|
|
3789
|
+
let lastIndex = 0;
|
|
3790
|
+
let match;
|
|
3791
|
+
JSON_TOKEN_RE.lastIndex = 0;
|
|
3792
|
+
while ((match = JSON_TOKEN_RE.exec(line)) !== null) {
|
|
3793
|
+
if (match.index > lastIndex) {
|
|
3794
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3795
|
+
}
|
|
3796
|
+
if (match[1] !== void 0) {
|
|
3797
|
+
const hasColon = match[2] !== void 0;
|
|
3798
|
+
tokens.push({ text: match[1], type: hasColon ? "property" : "string" });
|
|
3799
|
+
if (hasColon) tokens.push({ text: match[2], type: "punctuation" });
|
|
3800
|
+
} else if (match[3] !== void 0) {
|
|
3801
|
+
tokens.push({ text: match[3], type: "number" });
|
|
3802
|
+
} else if (match[4] !== void 0) {
|
|
3803
|
+
tokens.push({ text: match[4], type: "keyword" });
|
|
3804
|
+
}
|
|
3805
|
+
lastIndex = JSON_TOKEN_RE.lastIndex;
|
|
3806
|
+
}
|
|
3807
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3808
|
+
return tokens;
|
|
3809
|
+
}
|
|
3810
|
+
var MD_TOKEN_RE = /(^#{1,6}\s.*)|(`[^`]*`)/g;
|
|
3811
|
+
function tokenizeMd(line) {
|
|
3812
|
+
const tokens = [];
|
|
3813
|
+
let lastIndex = 0;
|
|
3814
|
+
let match;
|
|
3815
|
+
MD_TOKEN_RE.lastIndex = 0;
|
|
3816
|
+
while ((match = MD_TOKEN_RE.exec(line)) !== null) {
|
|
3817
|
+
if (match.index > lastIndex) {
|
|
3818
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3819
|
+
}
|
|
3820
|
+
if (match[1] !== void 0) tokens.push({ text: match[1], type: "keyword" });
|
|
3821
|
+
else if (match[2] !== void 0) tokens.push({ text: match[2], type: "string" });
|
|
3822
|
+
lastIndex = MD_TOKEN_RE.lastIndex;
|
|
3823
|
+
}
|
|
3824
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3825
|
+
return tokens;
|
|
3826
|
+
}
|
|
3827
|
+
function tokenizeLine(line, language) {
|
|
3828
|
+
if (line.length === 0) return [{ text: " ", type: "plain" }];
|
|
3829
|
+
switch (language) {
|
|
3830
|
+
case "tsx":
|
|
3831
|
+
case "ts":
|
|
3832
|
+
return tokenizeJs(line);
|
|
3833
|
+
case "css":
|
|
3834
|
+
return tokenizeCss(line);
|
|
3835
|
+
case "json":
|
|
3836
|
+
return tokenizeJson(line);
|
|
3837
|
+
case "md":
|
|
3838
|
+
return tokenizeMd(line);
|
|
3839
|
+
default:
|
|
3840
|
+
return [{ text: line, type: "plain" }];
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3643
3843
|
var CodeEditor = import_react14.default.forwardRef(
|
|
3644
3844
|
({
|
|
3645
3845
|
files,
|
|
@@ -3746,7 +3946,7 @@ var CodeEditor = import_react14.default.forwardRef(
|
|
|
3746
3946
|
] }),
|
|
3747
3947
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "flex-1 overflow-auto bg-canvas", children: readOnly || streaming ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("pre", { className: "m-0 p-0 text-body-sm leading-[1.55] text-ink", children: lines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex", children: [
|
|
3748
3948
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "select-none px-md text-right text-caption text-muted-soft", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "inline-block min-w-[2ch]", children: i + 1 }) }),
|
|
3749
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex-1 whitespace-pre pr-xl font-mono", children: line || " " })
|
|
3949
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "flex-1 whitespace-pre pr-xl font-mono", children: current ? tokenizeLine(line, current.language).map((tok, ti) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: SYNTAX_CLASS[tok.type], children: tok.text }, ti)) : line || " " })
|
|
3750
3950
|
] }, i)) }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex min-h-full", children: [
|
|
3751
3951
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "select-none px-md py-sm text-right text-caption text-muted-soft", children: lines.map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { children: i + 1 }, i)) }),
|
|
3752
3952
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -4357,7 +4557,8 @@ ExportDesignMdModal.displayName = "ExportDesignMdModal";
|
|
|
4357
4557
|
var import_react19 = __toESM(require("react"));
|
|
4358
4558
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4359
4559
|
var FilterTabBar = import_react19.default.forwardRef(
|
|
4360
|
-
({ tabs, value, onChange, className = "", ...rest }, ref) => {
|
|
4560
|
+
({ tabs, value, onChange, size = "md", className = "", ...rest }, ref) => {
|
|
4561
|
+
const isSm = size === "sm";
|
|
4361
4562
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4362
4563
|
"div",
|
|
4363
4564
|
{
|
|
@@ -4365,13 +4566,14 @@ var FilterTabBar = import_react19.default.forwardRef(
|
|
|
4365
4566
|
role: "tablist",
|
|
4366
4567
|
"aria-label": "Filter tabs",
|
|
4367
4568
|
className: [
|
|
4368
|
-
"inline-flex
|
|
4369
|
-
"
|
|
4569
|
+
"inline-flex bg-canvas border border-hairline shadow-sm",
|
|
4570
|
+
isSm ? "items-stretch h-8 p-xxs rounded-lg gap-xxs" : "items-center p-xs rounded-xl gap-xs",
|
|
4370
4571
|
className
|
|
4371
4572
|
].filter(Boolean).join(" "),
|
|
4372
4573
|
...rest,
|
|
4373
4574
|
children: tabs.map((tab) => {
|
|
4374
4575
|
const isActive = tab.value === value;
|
|
4576
|
+
const isIconOnly = Boolean(tab.icon) && !tab.label;
|
|
4375
4577
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
4376
4578
|
Button,
|
|
4377
4579
|
{
|
|
@@ -4381,7 +4583,11 @@ var FilterTabBar = import_react19.default.forwardRef(
|
|
|
4381
4583
|
variant: isActive ? "primary" : "ghost",
|
|
4382
4584
|
size: "sm",
|
|
4383
4585
|
onClick: () => onChange(tab.value),
|
|
4384
|
-
className:
|
|
4586
|
+
className: [
|
|
4587
|
+
"gap-xs leading-none",
|
|
4588
|
+
isSm ? "!h-full !py-0" : "",
|
|
4589
|
+
isIconOnly ? isSm ? "!px-xxs aspect-square" : "p-xs aspect-square" : ""
|
|
4590
|
+
].filter(Boolean).join(" "),
|
|
4385
4591
|
children: [
|
|
4386
4592
|
tab.icon && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "inline-flex items-center justify-center shrink-0", "aria-hidden": "true", children: tab.icon }),
|
|
4387
4593
|
tab.label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { children: tab.label }),
|
package/dist/index.js
CHANGED
|
@@ -3540,7 +3540,13 @@ var ICON_REGISTRY = {
|
|
|
3540
3540
|
"close": { viewBox: "0 0 24 24", paths: ["M18 6 6 18", "M6 6l12 12"] },
|
|
3541
3541
|
"chevron-down": { viewBox: "0 0 24 24", paths: ["M6 9l6 6 6-6"] },
|
|
3542
3542
|
"copy-clipboard": { viewBox: "0 0 24 24", paths: ["M9 9h10v10H9z", "M5 15V5h10"] },
|
|
3543
|
-
"check-checkmark": { viewBox: "0 0 24 24", paths: ["M5 13l4 4L19 7"] }
|
|
3543
|
+
"check-checkmark": { viewBox: "0 0 24 24", paths: ["M5 13l4 4L19 7"] },
|
|
3544
|
+
"grid": { viewBox: "0 0 24 24", paths: ["M4 4h6v6H4z", "M14 4h6v6h-6z", "M4 14h6v6H4z", "M14 14h6v6h-6z"] },
|
|
3545
|
+
"atom": { viewBox: "0 0 24 24", paths: ["M12 12m-1.5 0a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0", "M12 3.5c4 0 8 3.6 8 8.5s-4 8.5-8 8.5", "M12 3.5c-4 1.8-8 5.6-8 8.5s4 6.7 8 8.5", "M4 8.5c1.8-4 5.6-5 8-5s6.2 1 8 5"] },
|
|
3546
|
+
"layers": { viewBox: "0 0 24 24", paths: ["M12 3l8 4.5-8 4.5-8-4.5 8-4.5z", "M4 12l8 4.5 8-4.5", "M4 16.5l8 4.5 8-4.5"] },
|
|
3547
|
+
"star": { viewBox: "0 0 24 24", paths: ["M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6-4.5-4.2 6.1-.7L12 3z"] },
|
|
3548
|
+
"archive": { viewBox: "0 0 24 24", paths: ["M3 4h18v4H3z", "M4.5 8v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V8", "M10 12.5h4"] },
|
|
3549
|
+
"list-view": { viewBox: "0 0 24 24", paths: ["M4 6h16", "M4 12h16", "M4 18h16"] }
|
|
3544
3550
|
};
|
|
3545
3551
|
|
|
3546
3552
|
// virtual-pkg:src/atoms/Icon/Icon.tsx
|
|
@@ -3583,6 +3589,200 @@ var LANG_LABEL = {
|
|
|
3583
3589
|
function LangBadge({ language }) {
|
|
3584
3590
|
return /* @__PURE__ */ jsx15("span", { className: "inline-flex h-lg min-w-[1.6rem] items-center justify-center rounded-xs bg-surface-strong px-xxs text-caption text-muted", children: LANG_LABEL[language] });
|
|
3585
3591
|
}
|
|
3592
|
+
var SYNTAX_CLASS = {
|
|
3593
|
+
plain: "text-ink",
|
|
3594
|
+
comment: "text-syntax-comment italic",
|
|
3595
|
+
string: "text-syntax-string",
|
|
3596
|
+
number: "text-syntax-number",
|
|
3597
|
+
keyword: "text-syntax-keyword",
|
|
3598
|
+
function: "text-syntax-function",
|
|
3599
|
+
type: "text-syntax-type",
|
|
3600
|
+
tag: "text-syntax-tag",
|
|
3601
|
+
property: "text-syntax-property",
|
|
3602
|
+
punctuation: "text-muted"
|
|
3603
|
+
};
|
|
3604
|
+
var JS_KEYWORDS = /* @__PURE__ */ new Set([
|
|
3605
|
+
"import",
|
|
3606
|
+
"export",
|
|
3607
|
+
"default",
|
|
3608
|
+
"from",
|
|
3609
|
+
"const",
|
|
3610
|
+
"let",
|
|
3611
|
+
"var",
|
|
3612
|
+
"function",
|
|
3613
|
+
"return",
|
|
3614
|
+
"interface",
|
|
3615
|
+
"type",
|
|
3616
|
+
"extends",
|
|
3617
|
+
"implements",
|
|
3618
|
+
"class",
|
|
3619
|
+
"new",
|
|
3620
|
+
"this",
|
|
3621
|
+
"if",
|
|
3622
|
+
"else",
|
|
3623
|
+
"for",
|
|
3624
|
+
"while",
|
|
3625
|
+
"switch",
|
|
3626
|
+
"case",
|
|
3627
|
+
"break",
|
|
3628
|
+
"continue",
|
|
3629
|
+
"true",
|
|
3630
|
+
"false",
|
|
3631
|
+
"null",
|
|
3632
|
+
"undefined",
|
|
3633
|
+
"void",
|
|
3634
|
+
"async",
|
|
3635
|
+
"await",
|
|
3636
|
+
"of",
|
|
3637
|
+
"in",
|
|
3638
|
+
"as",
|
|
3639
|
+
"public",
|
|
3640
|
+
"private",
|
|
3641
|
+
"protected",
|
|
3642
|
+
"readonly",
|
|
3643
|
+
"static",
|
|
3644
|
+
"enum",
|
|
3645
|
+
"namespace",
|
|
3646
|
+
"declare",
|
|
3647
|
+
"try",
|
|
3648
|
+
"catch",
|
|
3649
|
+
"finally",
|
|
3650
|
+
"throw",
|
|
3651
|
+
"yield",
|
|
3652
|
+
"typeof",
|
|
3653
|
+
"instanceof",
|
|
3654
|
+
"super"
|
|
3655
|
+
]);
|
|
3656
|
+
var TS_TYPES = /* @__PURE__ */ new Set([
|
|
3657
|
+
"string",
|
|
3658
|
+
"number",
|
|
3659
|
+
"boolean",
|
|
3660
|
+
"any",
|
|
3661
|
+
"unknown",
|
|
3662
|
+
"never",
|
|
3663
|
+
"object",
|
|
3664
|
+
"React",
|
|
3665
|
+
"Record",
|
|
3666
|
+
"Partial",
|
|
3667
|
+
"Readonly",
|
|
3668
|
+
"Promise",
|
|
3669
|
+
"HTMLDivElement",
|
|
3670
|
+
"HTMLButtonElement"
|
|
3671
|
+
]);
|
|
3672
|
+
var JS_TOKEN_RE = /(\/\/.*)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`)|(\b\d+(?:\.\d+)?\b)|(<\/?[A-Za-z][\w.]*)|([A-Za-z_$][\w$]*)/g;
|
|
3673
|
+
function tokenizeJs(line) {
|
|
3674
|
+
const tokens = [];
|
|
3675
|
+
let lastIndex = 0;
|
|
3676
|
+
let match;
|
|
3677
|
+
JS_TOKEN_RE.lastIndex = 0;
|
|
3678
|
+
while ((match = JS_TOKEN_RE.exec(line)) !== null) {
|
|
3679
|
+
if (match.index > lastIndex) {
|
|
3680
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3681
|
+
}
|
|
3682
|
+
if (match[1] !== void 0) {
|
|
3683
|
+
tokens.push({ text: match[1], type: "comment" });
|
|
3684
|
+
} else if (match[2] !== void 0) {
|
|
3685
|
+
tokens.push({ text: match[2], type: "string" });
|
|
3686
|
+
} else if (match[3] !== void 0) {
|
|
3687
|
+
tokens.push({ text: match[3], type: "number" });
|
|
3688
|
+
} else if (match[4] !== void 0) {
|
|
3689
|
+
tokens.push({ text: match[4], type: "tag" });
|
|
3690
|
+
} else if (match[5] !== void 0) {
|
|
3691
|
+
const word = match[5];
|
|
3692
|
+
const after = line.slice(JS_TOKEN_RE.lastIndex).match(/^\s*\(/);
|
|
3693
|
+
if (JS_KEYWORDS.has(word)) {
|
|
3694
|
+
tokens.push({ text: word, type: "keyword" });
|
|
3695
|
+
} else if (TS_TYPES.has(word)) {
|
|
3696
|
+
tokens.push({ text: word, type: "type" });
|
|
3697
|
+
} else if (after) {
|
|
3698
|
+
tokens.push({ text: word, type: "function" });
|
|
3699
|
+
} else {
|
|
3700
|
+
tokens.push({ text: word, type: "plain" });
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
lastIndex = JS_TOKEN_RE.lastIndex;
|
|
3704
|
+
}
|
|
3705
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3706
|
+
return tokens;
|
|
3707
|
+
}
|
|
3708
|
+
var CSS_TOKEN_RE = /(\/\*[\s\S]*?\*\/)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*")|(@[a-zA-Z-]+)|(#[0-9a-fA-F]{3,8}\b)|(-?\d+\.?\d*(?:px|em|rem|%|deg|s|ms|vh|vw)?\b)|([a-zA-Z-]+)(?=\s*:)/g;
|
|
3709
|
+
function tokenizeCss(line) {
|
|
3710
|
+
const tokens = [];
|
|
3711
|
+
let lastIndex = 0;
|
|
3712
|
+
let match;
|
|
3713
|
+
CSS_TOKEN_RE.lastIndex = 0;
|
|
3714
|
+
while ((match = CSS_TOKEN_RE.exec(line)) !== null) {
|
|
3715
|
+
if (match.index > lastIndex) {
|
|
3716
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3717
|
+
}
|
|
3718
|
+
if (match[1] !== void 0) tokens.push({ text: match[1], type: "comment" });
|
|
3719
|
+
else if (match[2] !== void 0) tokens.push({ text: match[2], type: "string" });
|
|
3720
|
+
else if (match[3] !== void 0) tokens.push({ text: match[3], type: "keyword" });
|
|
3721
|
+
else if (match[4] !== void 0) tokens.push({ text: match[4], type: "number" });
|
|
3722
|
+
else if (match[5] !== void 0) tokens.push({ text: match[5], type: "number" });
|
|
3723
|
+
else if (match[6] !== void 0) tokens.push({ text: match[6], type: "property" });
|
|
3724
|
+
lastIndex = CSS_TOKEN_RE.lastIndex;
|
|
3725
|
+
}
|
|
3726
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3727
|
+
return tokens;
|
|
3728
|
+
}
|
|
3729
|
+
var JSON_TOKEN_RE = /("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?)|\b(true|false|null)\b/g;
|
|
3730
|
+
function tokenizeJson(line) {
|
|
3731
|
+
const tokens = [];
|
|
3732
|
+
let lastIndex = 0;
|
|
3733
|
+
let match;
|
|
3734
|
+
JSON_TOKEN_RE.lastIndex = 0;
|
|
3735
|
+
while ((match = JSON_TOKEN_RE.exec(line)) !== null) {
|
|
3736
|
+
if (match.index > lastIndex) {
|
|
3737
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3738
|
+
}
|
|
3739
|
+
if (match[1] !== void 0) {
|
|
3740
|
+
const hasColon = match[2] !== void 0;
|
|
3741
|
+
tokens.push({ text: match[1], type: hasColon ? "property" : "string" });
|
|
3742
|
+
if (hasColon) tokens.push({ text: match[2], type: "punctuation" });
|
|
3743
|
+
} else if (match[3] !== void 0) {
|
|
3744
|
+
tokens.push({ text: match[3], type: "number" });
|
|
3745
|
+
} else if (match[4] !== void 0) {
|
|
3746
|
+
tokens.push({ text: match[4], type: "keyword" });
|
|
3747
|
+
}
|
|
3748
|
+
lastIndex = JSON_TOKEN_RE.lastIndex;
|
|
3749
|
+
}
|
|
3750
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3751
|
+
return tokens;
|
|
3752
|
+
}
|
|
3753
|
+
var MD_TOKEN_RE = /(^#{1,6}\s.*)|(`[^`]*`)/g;
|
|
3754
|
+
function tokenizeMd(line) {
|
|
3755
|
+
const tokens = [];
|
|
3756
|
+
let lastIndex = 0;
|
|
3757
|
+
let match;
|
|
3758
|
+
MD_TOKEN_RE.lastIndex = 0;
|
|
3759
|
+
while ((match = MD_TOKEN_RE.exec(line)) !== null) {
|
|
3760
|
+
if (match.index > lastIndex) {
|
|
3761
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
3762
|
+
}
|
|
3763
|
+
if (match[1] !== void 0) tokens.push({ text: match[1], type: "keyword" });
|
|
3764
|
+
else if (match[2] !== void 0) tokens.push({ text: match[2], type: "string" });
|
|
3765
|
+
lastIndex = MD_TOKEN_RE.lastIndex;
|
|
3766
|
+
}
|
|
3767
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
3768
|
+
return tokens;
|
|
3769
|
+
}
|
|
3770
|
+
function tokenizeLine(line, language) {
|
|
3771
|
+
if (line.length === 0) return [{ text: " ", type: "plain" }];
|
|
3772
|
+
switch (language) {
|
|
3773
|
+
case "tsx":
|
|
3774
|
+
case "ts":
|
|
3775
|
+
return tokenizeJs(line);
|
|
3776
|
+
case "css":
|
|
3777
|
+
return tokenizeCss(line);
|
|
3778
|
+
case "json":
|
|
3779
|
+
return tokenizeJson(line);
|
|
3780
|
+
case "md":
|
|
3781
|
+
return tokenizeMd(line);
|
|
3782
|
+
default:
|
|
3783
|
+
return [{ text: line, type: "plain" }];
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3586
3786
|
var CodeEditor = React15.forwardRef(
|
|
3587
3787
|
({
|
|
3588
3788
|
files,
|
|
@@ -3689,7 +3889,7 @@ var CodeEditor = React15.forwardRef(
|
|
|
3689
3889
|
] }),
|
|
3690
3890
|
/* @__PURE__ */ jsx15("div", { className: "flex-1 overflow-auto bg-canvas", children: readOnly || streaming ? /* @__PURE__ */ jsx15("pre", { className: "m-0 p-0 text-body-sm leading-[1.55] text-ink", children: lines.map((line, i) => /* @__PURE__ */ jsxs14("div", { className: "flex", children: [
|
|
3691
3891
|
/* @__PURE__ */ jsx15("span", { className: "select-none px-md text-right text-caption text-muted-soft", children: /* @__PURE__ */ jsx15("span", { className: "inline-block min-w-[2ch]", children: i + 1 }) }),
|
|
3692
|
-
/* @__PURE__ */ jsx15("span", { className: "flex-1 whitespace-pre pr-xl font-mono", children: line || " " })
|
|
3892
|
+
/* @__PURE__ */ jsx15("span", { className: "flex-1 whitespace-pre pr-xl font-mono", children: current ? tokenizeLine(line, current.language).map((tok, ti) => /* @__PURE__ */ jsx15("span", { className: SYNTAX_CLASS[tok.type], children: tok.text }, ti)) : line || " " })
|
|
3693
3893
|
] }, i)) }) : /* @__PURE__ */ jsxs14("div", { className: "flex min-h-full", children: [
|
|
3694
3894
|
/* @__PURE__ */ jsx15("div", { className: "select-none px-md py-sm text-right text-caption text-muted-soft", children: lines.map((_, i) => /* @__PURE__ */ jsx15("div", { children: i + 1 }, i)) }),
|
|
3695
3895
|
/* @__PURE__ */ jsx15(
|
|
@@ -4300,7 +4500,8 @@ ExportDesignMdModal.displayName = "ExportDesignMdModal";
|
|
|
4300
4500
|
import React20 from "react";
|
|
4301
4501
|
import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4302
4502
|
var FilterTabBar = React20.forwardRef(
|
|
4303
|
-
({ tabs, value, onChange, className = "", ...rest }, ref) => {
|
|
4503
|
+
({ tabs, value, onChange, size = "md", className = "", ...rest }, ref) => {
|
|
4504
|
+
const isSm = size === "sm";
|
|
4304
4505
|
return /* @__PURE__ */ jsx20(
|
|
4305
4506
|
"div",
|
|
4306
4507
|
{
|
|
@@ -4308,13 +4509,14 @@ var FilterTabBar = React20.forwardRef(
|
|
|
4308
4509
|
role: "tablist",
|
|
4309
4510
|
"aria-label": "Filter tabs",
|
|
4310
4511
|
className: [
|
|
4311
|
-
"inline-flex
|
|
4312
|
-
"
|
|
4512
|
+
"inline-flex bg-canvas border border-hairline shadow-sm",
|
|
4513
|
+
isSm ? "items-stretch h-8 p-xxs rounded-lg gap-xxs" : "items-center p-xs rounded-xl gap-xs",
|
|
4313
4514
|
className
|
|
4314
4515
|
].filter(Boolean).join(" "),
|
|
4315
4516
|
...rest,
|
|
4316
4517
|
children: tabs.map((tab) => {
|
|
4317
4518
|
const isActive = tab.value === value;
|
|
4519
|
+
const isIconOnly = Boolean(tab.icon) && !tab.label;
|
|
4318
4520
|
return /* @__PURE__ */ jsxs18(
|
|
4319
4521
|
Button,
|
|
4320
4522
|
{
|
|
@@ -4324,7 +4526,11 @@ var FilterTabBar = React20.forwardRef(
|
|
|
4324
4526
|
variant: isActive ? "primary" : "ghost",
|
|
4325
4527
|
size: "sm",
|
|
4326
4528
|
onClick: () => onChange(tab.value),
|
|
4327
|
-
className:
|
|
4529
|
+
className: [
|
|
4530
|
+
"gap-xs leading-none",
|
|
4531
|
+
isSm ? "!h-full !py-0" : "",
|
|
4532
|
+
isIconOnly ? isSm ? "!px-xxs aspect-square" : "p-xs aspect-square" : ""
|
|
4533
|
+
].filter(Boolean).join(" "),
|
|
4328
4534
|
children: [
|
|
4329
4535
|
tab.icon && /* @__PURE__ */ jsx20("span", { className: "inline-flex items-center justify-center shrink-0", "aria-hidden": "true", children: tab.icon }),
|
|
4330
4536
|
tab.label && /* @__PURE__ */ jsx20("span", { children: tab.label }),
|
package/dist/styles.css
CHANGED
|
@@ -94,6 +94,14 @@
|
|
|
94
94
|
--color-kind-template-text: #B45309;
|
|
95
95
|
--color-kind-template-border: #FBD98A;
|
|
96
96
|
--color-semantic-info-soft: #EAE8FB;
|
|
97
|
+
--color-syntax-keyword: #0000FF;
|
|
98
|
+
--color-syntax-string: #A31515;
|
|
99
|
+
--color-syntax-number: #098658;
|
|
100
|
+
--color-syntax-comment: #008000;
|
|
101
|
+
--color-syntax-function: #795E26;
|
|
102
|
+
--color-syntax-type: #267F99;
|
|
103
|
+
--color-syntax-tag: #800000;
|
|
104
|
+
--color-syntax-property: #001080;
|
|
97
105
|
--font-body: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
98
106
|
--text-display-lg: 48px;
|
|
99
107
|
--text-display-lg--font-weight: 700;
|
|
@@ -480,6 +488,9 @@
|
|
|
480
488
|
.inline-flex {
|
|
481
489
|
display: inline-flex;
|
|
482
490
|
}
|
|
491
|
+
.aspect-square {
|
|
492
|
+
aspect-ratio: 1 / 1;
|
|
493
|
+
}
|
|
483
494
|
.size-3 {
|
|
484
495
|
width: calc(var(--spacing) * 3);
|
|
485
496
|
height: calc(var(--spacing) * 3);
|
|
@@ -1183,6 +1194,9 @@
|
|
|
1183
1194
|
.\!px-xs {
|
|
1184
1195
|
padding-inline: var(--spacing-xs) !important;
|
|
1185
1196
|
}
|
|
1197
|
+
.\!px-xxs {
|
|
1198
|
+
padding-inline: var(--spacing-xxs) !important;
|
|
1199
|
+
}
|
|
1186
1200
|
.px-base {
|
|
1187
1201
|
padding-inline: var(--spacing-base);
|
|
1188
1202
|
}
|
|
@@ -1428,6 +1442,30 @@
|
|
|
1428
1442
|
.text-semantic-warning {
|
|
1429
1443
|
color: var(--color-semantic-warning);
|
|
1430
1444
|
}
|
|
1445
|
+
.text-syntax-comment {
|
|
1446
|
+
color: var(--color-syntax-comment);
|
|
1447
|
+
}
|
|
1448
|
+
.text-syntax-function {
|
|
1449
|
+
color: var(--color-syntax-function);
|
|
1450
|
+
}
|
|
1451
|
+
.text-syntax-keyword {
|
|
1452
|
+
color: var(--color-syntax-keyword);
|
|
1453
|
+
}
|
|
1454
|
+
.text-syntax-number {
|
|
1455
|
+
color: var(--color-syntax-number);
|
|
1456
|
+
}
|
|
1457
|
+
.text-syntax-property {
|
|
1458
|
+
color: var(--color-syntax-property);
|
|
1459
|
+
}
|
|
1460
|
+
.text-syntax-string {
|
|
1461
|
+
color: var(--color-syntax-string);
|
|
1462
|
+
}
|
|
1463
|
+
.text-syntax-tag {
|
|
1464
|
+
color: var(--color-syntax-tag);
|
|
1465
|
+
}
|
|
1466
|
+
.text-syntax-type {
|
|
1467
|
+
color: var(--color-syntax-type);
|
|
1468
|
+
}
|
|
1431
1469
|
.capitalize {
|
|
1432
1470
|
text-transform: capitalize;
|
|
1433
1471
|
}
|
|
@@ -1897,6 +1935,14 @@
|
|
|
1897
1935
|
--color-semantic-warning-soft: #3A2A0A;
|
|
1898
1936
|
--color-semantic-error-soft: #3A1414;
|
|
1899
1937
|
--color-semantic-info-soft: #28234F;
|
|
1938
|
+
--color-syntax-keyword: #569CD6;
|
|
1939
|
+
--color-syntax-string: #CE9178;
|
|
1940
|
+
--color-syntax-number: #B5CEA8;
|
|
1941
|
+
--color-syntax-comment: #6A9955;
|
|
1942
|
+
--color-syntax-function: #DCDCAA;
|
|
1943
|
+
--color-syntax-type: #4EC9B0;
|
|
1944
|
+
--color-syntax-tag: #569CD6;
|
|
1945
|
+
--color-syntax-property: #9CDCFE;
|
|
1900
1946
|
}
|
|
1901
1947
|
@property --tw-translate-x {
|
|
1902
1948
|
syntax: "*";
|
package/package.json
CHANGED
|
@@ -41,6 +41,179 @@ function LangBadge({ language }: { language: CodeEditorLanguage }) {
|
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/* ---------------------------------------------------------------------- */
|
|
45
|
+
/* Syntax highlighting — vivid, VS Code-style token coloring. */
|
|
46
|
+
/* Presentational only: a small line-scoped regex tokenizer per language. */
|
|
47
|
+
/* ---------------------------------------------------------------------- */
|
|
48
|
+
|
|
49
|
+
type SyntaxTokenType =
|
|
50
|
+
| "plain"
|
|
51
|
+
| "comment"
|
|
52
|
+
| "string"
|
|
53
|
+
| "number"
|
|
54
|
+
| "keyword"
|
|
55
|
+
| "function"
|
|
56
|
+
| "type"
|
|
57
|
+
| "tag"
|
|
58
|
+
| "property"
|
|
59
|
+
| "punctuation";
|
|
60
|
+
|
|
61
|
+
const SYNTAX_CLASS: Record<SyntaxTokenType, string> = {
|
|
62
|
+
plain: "text-ink",
|
|
63
|
+
comment: "text-syntax-comment italic",
|
|
64
|
+
string: "text-syntax-string",
|
|
65
|
+
number: "text-syntax-number",
|
|
66
|
+
keyword: "text-syntax-keyword",
|
|
67
|
+
function: "text-syntax-function",
|
|
68
|
+
type: "text-syntax-type",
|
|
69
|
+
tag: "text-syntax-tag",
|
|
70
|
+
property: "text-syntax-property",
|
|
71
|
+
punctuation: "text-muted",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type SyntaxToken = { text: string; type: SyntaxTokenType };
|
|
75
|
+
|
|
76
|
+
const JS_KEYWORDS = new Set([
|
|
77
|
+
"import", "export", "default", "from", "const", "let", "var", "function",
|
|
78
|
+
"return", "interface", "type", "extends", "implements", "class", "new",
|
|
79
|
+
"this", "if", "else", "for", "while", "switch", "case", "break", "continue",
|
|
80
|
+
"true", "false", "null", "undefined", "void", "async", "await", "of", "in",
|
|
81
|
+
"as", "public", "private", "protected", "readonly", "static", "enum",
|
|
82
|
+
"namespace", "declare", "try", "catch", "finally", "throw", "yield",
|
|
83
|
+
"typeof", "instanceof", "super",
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const TS_TYPES = new Set([
|
|
87
|
+
"string", "number", "boolean", "any", "unknown", "never", "object",
|
|
88
|
+
"React", "Record", "Partial", "Readonly", "Promise", "HTMLDivElement",
|
|
89
|
+
"HTMLButtonElement",
|
|
90
|
+
]);
|
|
91
|
+
|
|
92
|
+
const JS_TOKEN_RE =
|
|
93
|
+
/(\/\/.*)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`)|(\b\d+(?:\.\d+)?\b)|(<\/?[A-Za-z][\w.]*)|([A-Za-z_$][\w$]*)/g;
|
|
94
|
+
|
|
95
|
+
function tokenizeJs(line: string): SyntaxToken[] {
|
|
96
|
+
const tokens: SyntaxToken[] = [];
|
|
97
|
+
let lastIndex = 0;
|
|
98
|
+
let match: RegExpExecArray | null;
|
|
99
|
+
JS_TOKEN_RE.lastIndex = 0;
|
|
100
|
+
while ((match = JS_TOKEN_RE.exec(line)) !== null) {
|
|
101
|
+
if (match.index > lastIndex) {
|
|
102
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
103
|
+
}
|
|
104
|
+
if (match[1] !== undefined) {
|
|
105
|
+
tokens.push({ text: match[1], type: "comment" });
|
|
106
|
+
} else if (match[2] !== undefined) {
|
|
107
|
+
tokens.push({ text: match[2], type: "string" });
|
|
108
|
+
} else if (match[3] !== undefined) {
|
|
109
|
+
tokens.push({ text: match[3], type: "number" });
|
|
110
|
+
} else if (match[4] !== undefined) {
|
|
111
|
+
tokens.push({ text: match[4], type: "tag" });
|
|
112
|
+
} else if (match[5] !== undefined) {
|
|
113
|
+
const word = match[5];
|
|
114
|
+
const after = line.slice(JS_TOKEN_RE.lastIndex).match(/^\s*\(/);
|
|
115
|
+
if (JS_KEYWORDS.has(word)) {
|
|
116
|
+
tokens.push({ text: word, type: "keyword" });
|
|
117
|
+
} else if (TS_TYPES.has(word)) {
|
|
118
|
+
tokens.push({ text: word, type: "type" });
|
|
119
|
+
} else if (after) {
|
|
120
|
+
tokens.push({ text: word, type: "function" });
|
|
121
|
+
} else {
|
|
122
|
+
tokens.push({ text: word, type: "plain" });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
lastIndex = JS_TOKEN_RE.lastIndex;
|
|
126
|
+
}
|
|
127
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
128
|
+
return tokens;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const CSS_TOKEN_RE =
|
|
132
|
+
/(\/\*[\s\S]*?\*\/)|('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*")|(@[a-zA-Z-]+)|(#[0-9a-fA-F]{3,8}\b)|(-?\d+\.?\d*(?:px|em|rem|%|deg|s|ms|vh|vw)?\b)|([a-zA-Z-]+)(?=\s*:)/g;
|
|
133
|
+
|
|
134
|
+
function tokenizeCss(line: string): SyntaxToken[] {
|
|
135
|
+
const tokens: SyntaxToken[] = [];
|
|
136
|
+
let lastIndex = 0;
|
|
137
|
+
let match: RegExpExecArray | null;
|
|
138
|
+
CSS_TOKEN_RE.lastIndex = 0;
|
|
139
|
+
while ((match = CSS_TOKEN_RE.exec(line)) !== null) {
|
|
140
|
+
if (match.index > lastIndex) {
|
|
141
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
142
|
+
}
|
|
143
|
+
if (match[1] !== undefined) tokens.push({ text: match[1], type: "comment" });
|
|
144
|
+
else if (match[2] !== undefined) tokens.push({ text: match[2], type: "string" });
|
|
145
|
+
else if (match[3] !== undefined) tokens.push({ text: match[3], type: "keyword" });
|
|
146
|
+
else if (match[4] !== undefined) tokens.push({ text: match[4], type: "number" });
|
|
147
|
+
else if (match[5] !== undefined) tokens.push({ text: match[5], type: "number" });
|
|
148
|
+
else if (match[6] !== undefined) tokens.push({ text: match[6], type: "property" });
|
|
149
|
+
lastIndex = CSS_TOKEN_RE.lastIndex;
|
|
150
|
+
}
|
|
151
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
152
|
+
return tokens;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const JSON_TOKEN_RE = /("(?:\\.|[^"\\])*")(\s*:)?|(-?\d+(?:\.\d+)?)|\b(true|false|null)\b/g;
|
|
156
|
+
|
|
157
|
+
function tokenizeJson(line: string): SyntaxToken[] {
|
|
158
|
+
const tokens: SyntaxToken[] = [];
|
|
159
|
+
let lastIndex = 0;
|
|
160
|
+
let match: RegExpExecArray | null;
|
|
161
|
+
JSON_TOKEN_RE.lastIndex = 0;
|
|
162
|
+
while ((match = JSON_TOKEN_RE.exec(line)) !== null) {
|
|
163
|
+
if (match.index > lastIndex) {
|
|
164
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
165
|
+
}
|
|
166
|
+
if (match[1] !== undefined) {
|
|
167
|
+
const hasColon = match[2] !== undefined;
|
|
168
|
+
tokens.push({ text: match[1], type: hasColon ? "property" : "string" });
|
|
169
|
+
if (hasColon) tokens.push({ text: match[2] as string, type: "punctuation" });
|
|
170
|
+
} else if (match[3] !== undefined) {
|
|
171
|
+
tokens.push({ text: match[3], type: "number" });
|
|
172
|
+
} else if (match[4] !== undefined) {
|
|
173
|
+
tokens.push({ text: match[4], type: "keyword" });
|
|
174
|
+
}
|
|
175
|
+
lastIndex = JSON_TOKEN_RE.lastIndex;
|
|
176
|
+
}
|
|
177
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
178
|
+
return tokens;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const MD_TOKEN_RE = /(^#{1,6}\s.*)|(`[^`]*`)/g;
|
|
182
|
+
|
|
183
|
+
function tokenizeMd(line: string): SyntaxToken[] {
|
|
184
|
+
const tokens: SyntaxToken[] = [];
|
|
185
|
+
let lastIndex = 0;
|
|
186
|
+
let match: RegExpExecArray | null;
|
|
187
|
+
MD_TOKEN_RE.lastIndex = 0;
|
|
188
|
+
while ((match = MD_TOKEN_RE.exec(line)) !== null) {
|
|
189
|
+
if (match.index > lastIndex) {
|
|
190
|
+
tokens.push({ text: line.slice(lastIndex, match.index), type: "plain" });
|
|
191
|
+
}
|
|
192
|
+
if (match[1] !== undefined) tokens.push({ text: match[1], type: "keyword" });
|
|
193
|
+
else if (match[2] !== undefined) tokens.push({ text: match[2], type: "string" });
|
|
194
|
+
lastIndex = MD_TOKEN_RE.lastIndex;
|
|
195
|
+
}
|
|
196
|
+
if (lastIndex < line.length) tokens.push({ text: line.slice(lastIndex), type: "plain" });
|
|
197
|
+
return tokens;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function tokenizeLine(line: string, language: CodeEditorLanguage): SyntaxToken[] {
|
|
201
|
+
if (line.length === 0) return [{ text: " ", type: "plain" }];
|
|
202
|
+
switch (language) {
|
|
203
|
+
case "tsx":
|
|
204
|
+
case "ts":
|
|
205
|
+
return tokenizeJs(line);
|
|
206
|
+
case "css":
|
|
207
|
+
return tokenizeCss(line);
|
|
208
|
+
case "json":
|
|
209
|
+
return tokenizeJson(line);
|
|
210
|
+
case "md":
|
|
211
|
+
return tokenizeMd(line);
|
|
212
|
+
default:
|
|
213
|
+
return [{ text: line, type: "plain" }];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
44
217
|
export const CodeEditor = React.forwardRef<HTMLDivElement, CodeEditorProps>(
|
|
45
218
|
(
|
|
46
219
|
{
|
|
@@ -155,7 +328,15 @@ export const CodeEditor = React.forwardRef<HTMLDivElement, CodeEditorProps>(
|
|
|
155
328
|
<span className="select-none px-md text-right text-caption text-muted-soft">
|
|
156
329
|
<span className="inline-block min-w-[2ch]">{i + 1}</span>
|
|
157
330
|
</span>
|
|
158
|
-
<span className="flex-1 whitespace-pre pr-xl font-mono">
|
|
331
|
+
<span className="flex-1 whitespace-pre pr-xl font-mono">
|
|
332
|
+
{current
|
|
333
|
+
? tokenizeLine(line, current.language).map((tok, ti) => (
|
|
334
|
+
<span key={ti} className={SYNTAX_CLASS[tok.type]}>
|
|
335
|
+
{tok.text}
|
|
336
|
+
</span>
|
|
337
|
+
))
|
|
338
|
+
: line || " "}
|
|
339
|
+
</span>
|
|
159
340
|
</div>
|
|
160
341
|
))}
|
|
161
342
|
</pre>
|
|
@@ -12,24 +12,36 @@ export interface FilterTab {
|
|
|
12
12
|
icon?: React.ReactNode;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
export type FilterTabBarSize = "sm" | "md";
|
|
16
|
+
|
|
15
17
|
export interface FilterTabBarProps
|
|
16
18
|
extends Omit<React.ComponentPropsWithoutRef<"div">, "onChange"> {
|
|
17
19
|
tabs: FilterTab[];
|
|
18
20
|
/** Currently active tab value */
|
|
19
21
|
value: string;
|
|
20
22
|
onChange: (value: string) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Compact "sm" matches Input size="sm" total height (h-8 / 32px including
|
|
25
|
+
* border) so an icon-only tab bar can sit flush next to a sm input.
|
|
26
|
+
* Defaults to "md".
|
|
27
|
+
*/
|
|
28
|
+
size?: FilterTabBarSize;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
export const FilterTabBar = React.forwardRef<HTMLDivElement, FilterTabBarProps>(
|
|
24
|
-
({ tabs, value, onChange, className = "", ...rest }, ref) => {
|
|
32
|
+
({ tabs, value, onChange, size = "md", className = "", ...rest }, ref) => {
|
|
33
|
+
const isSm = size === "sm";
|
|
34
|
+
|
|
25
35
|
return (
|
|
26
36
|
<div
|
|
27
37
|
ref={ref}
|
|
28
38
|
role="tablist"
|
|
29
39
|
aria-label="Filter tabs"
|
|
30
40
|
className={[
|
|
31
|
-
"inline-flex
|
|
32
|
-
|
|
41
|
+
"inline-flex bg-canvas border border-hairline shadow-sm",
|
|
42
|
+
isSm
|
|
43
|
+
? "items-stretch h-8 p-xxs rounded-lg gap-xxs"
|
|
44
|
+
: "items-center p-xs rounded-xl gap-xs",
|
|
33
45
|
className,
|
|
34
46
|
]
|
|
35
47
|
.filter(Boolean)
|
|
@@ -38,6 +50,7 @@ export const FilterTabBar = React.forwardRef<HTMLDivElement, FilterTabBarProps>(
|
|
|
38
50
|
>
|
|
39
51
|
{tabs.map((tab) => {
|
|
40
52
|
const isActive = tab.value === value;
|
|
53
|
+
const isIconOnly = Boolean(tab.icon) && !tab.label;
|
|
41
54
|
|
|
42
55
|
return (
|
|
43
56
|
<Button
|
|
@@ -48,7 +61,13 @@ export const FilterTabBar = React.forwardRef<HTMLDivElement, FilterTabBarProps>(
|
|
|
48
61
|
variant={isActive ? "primary" : "ghost"}
|
|
49
62
|
size="sm"
|
|
50
63
|
onClick={() => onChange(tab.value)}
|
|
51
|
-
className=
|
|
64
|
+
className={[
|
|
65
|
+
"gap-xs leading-none",
|
|
66
|
+
isSm ? "!h-full !py-0" : "",
|
|
67
|
+
isIconOnly ? (isSm ? "!px-xxs aspect-square" : "p-xs aspect-square") : "",
|
|
68
|
+
]
|
|
69
|
+
.filter(Boolean)
|
|
70
|
+
.join(" ")}
|
|
52
71
|
>
|
|
53
72
|
{tab.icon && (
|
|
54
73
|
<span className="inline-flex items-center justify-center shrink-0" aria-hidden="true">
|
|
@@ -1,46 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { FilterTabBar } from "./FilterTabBar";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const IconGrid = () => (
|
|
6
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
7
|
-
<rect x="1" y="1" width="6" height="6" rx="1.5" fill="currentColor" />
|
|
8
|
-
<rect x="9" y="1" width="6" height="6" rx="1.5" fill="currentColor" />
|
|
9
|
-
<rect x="1" y="9" width="6" height="6" rx="1.5" fill="currentColor" />
|
|
10
|
-
<rect x="9" y="9" width="6" height="6" rx="1.5" fill="currentColor" />
|
|
11
|
-
</svg>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
const IconAtom = () => (
|
|
15
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
16
|
-
<circle cx="8" cy="8" r="2" fill="currentColor" />
|
|
17
|
-
<ellipse cx="8" cy="8" rx="7" ry="3" stroke="currentColor" strokeWidth="1.25" fill="none" />
|
|
18
|
-
<ellipse cx="8" cy="8" rx="7" ry="3" stroke="currentColor" strokeWidth="1.25" fill="none" transform="rotate(60 8 8)" />
|
|
19
|
-
<ellipse cx="8" cy="8" rx="7" ry="3" stroke="currentColor" strokeWidth="1.25" fill="none" transform="rotate(120 8 8)" />
|
|
20
|
-
</svg>
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const IconLayers = () => (
|
|
24
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
25
|
-
<path d="M8 1L15 5L8 9L1 5L8 1Z" fill="currentColor" opacity="0.4" />
|
|
26
|
-
<path d="M1 8L8 12L15 8" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" fill="none" />
|
|
27
|
-
<path d="M1 11L8 15L15 11" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" fill="none" />
|
|
28
|
-
</svg>
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const IconStar = () => (
|
|
32
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
|
|
33
|
-
<path d="M8 1l1.854 4.146H14l-3.427 2.708 1.31 4.146L8 9.764l-3.883 2.236 1.31-4.146L2 5.146h4.146L8 1z" />
|
|
34
|
-
</svg>
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const IconArchive = () => (
|
|
38
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
39
|
-
<rect x="1" y="1" width="14" height="3" rx="1" fill="currentColor" opacity="0.5" />
|
|
40
|
-
<path d="M2 5h12v8a1 1 0 01-1 1H3a1 1 0 01-1-1V5z" fill="currentColor" opacity="0.3" />
|
|
41
|
-
<path d="M6 8h4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
42
|
-
</svg>
|
|
43
|
-
);
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
import { Input } from "../Input";
|
|
44
5
|
|
|
45
6
|
const tabsWithCounts = [
|
|
46
7
|
{ value: "all", label: "All", count: 15 },
|
|
@@ -50,15 +11,9 @@ const tabsWithCounts = [
|
|
|
50
11
|
];
|
|
51
12
|
|
|
52
13
|
const tabsWithIcons = [
|
|
53
|
-
{ value: "all", label: "All", icon: <
|
|
54
|
-
{ value: "atoms", label: "Atoms", icon: <
|
|
55
|
-
{ value: "molecules", label: "Molecules", icon: <
|
|
56
|
-
];
|
|
57
|
-
|
|
58
|
-
const tabsIconOnly = [
|
|
59
|
-
{ value: "all", icon: <IconGrid />, label: "All" },
|
|
60
|
-
{ value: "starred", icon: <IconStar />, label: "Starred" },
|
|
61
|
-
{ value: "archived", icon: <IconArchive />, label: "Archived" },
|
|
14
|
+
{ value: "all", label: "All", icon: <Icon name="grid" size={14} /> },
|
|
15
|
+
{ value: "atoms", label: "Atoms", icon: <Icon name="atom" size={14} />, count: 8 },
|
|
16
|
+
{ value: "molecules", label: "Molecules", icon: <Icon name="layers" size={14} />, count: 2 },
|
|
62
17
|
];
|
|
63
18
|
|
|
64
19
|
export default function FilterTabBarPreview() {
|
|
@@ -66,6 +21,8 @@ export default function FilterTabBarPreview() {
|
|
|
66
21
|
const [active2, setActive2] = useState("all");
|
|
67
22
|
const [active3, setActive3] = useState("all");
|
|
68
23
|
const [active4, setActive4] = useState("all");
|
|
24
|
+
const [active5, setActive5] = useState("all");
|
|
25
|
+
const [view, setView] = useState("grid");
|
|
69
26
|
|
|
70
27
|
return (
|
|
71
28
|
<div className="w-full max-w-3xl mx-auto p-xl flex flex-col items-start gap-xl bg-canvas py-xxl">
|
|
@@ -86,9 +43,9 @@ export default function FilterTabBarPreview() {
|
|
|
86
43
|
<p className="text-caption text-muted uppercase tracking-wide">Icon + label + count</p>
|
|
87
44
|
<FilterTabBar
|
|
88
45
|
tabs={[
|
|
89
|
-
{ value: "all", label: "All", icon: <
|
|
90
|
-
{ value: "atoms", label: "Atoms", icon: <
|
|
91
|
-
{ value: "molecules", label: "Molecules", icon: <
|
|
46
|
+
{ value: "all", label: "All", icon: <Icon name="grid" size={14} />, count: 15 },
|
|
47
|
+
{ value: "atoms", label: "Atoms", icon: <Icon name="atom" size={14} />, count: 8 },
|
|
48
|
+
{ value: "molecules", label: "Molecules", icon: <Icon name="layers" size={14} />, count: 2 },
|
|
92
49
|
]}
|
|
93
50
|
value={active3}
|
|
94
51
|
onChange={setActive3}
|
|
@@ -108,6 +65,39 @@ export default function FilterTabBarPreview() {
|
|
|
108
65
|
onChange={setActive4}
|
|
109
66
|
/>
|
|
110
67
|
</div>
|
|
68
|
+
|
|
69
|
+
{/* Icon only, no label (compact square tabs — matches labeled tab height) */}
|
|
70
|
+
<div className="flex flex-col gap-sm w-full">
|
|
71
|
+
<p className="text-caption text-muted uppercase tracking-wide">Icon only (compact)</p>
|
|
72
|
+
<FilterTabBar
|
|
73
|
+
tabs={[
|
|
74
|
+
{ value: "all", icon: <Icon name="grid" size={14} /> },
|
|
75
|
+
{ value: "starred", icon: <Icon name="star" size={14} /> },
|
|
76
|
+
{ value: "archived", icon: <Icon name="archive" size={14} /> },
|
|
77
|
+
]}
|
|
78
|
+
value={active5}
|
|
79
|
+
onChange={setActive5}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
{/* size="sm" — icon-only view switcher sharing the same 32px edge as Input size="sm" */}
|
|
84
|
+
<div className="flex flex-col gap-sm w-full">
|
|
85
|
+
<p className="text-caption text-muted uppercase tracking-wide">
|
|
86
|
+
size="sm" (flush with Input size="sm")
|
|
87
|
+
</p>
|
|
88
|
+
<div className="flex items-center gap-sm w-full">
|
|
89
|
+
<Input size="sm" placeholder="Search components..." className="flex-1" />
|
|
90
|
+
<FilterTabBar
|
|
91
|
+
size="sm"
|
|
92
|
+
tabs={[
|
|
93
|
+
{ value: "grid", icon: <Icon name="grid" size={14} /> },
|
|
94
|
+
{ value: "list", icon: <Icon name="list-view" size={14} /> },
|
|
95
|
+
]}
|
|
96
|
+
value={view}
|
|
97
|
+
onChange={setView}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
111
101
|
</div>
|
|
112
102
|
);
|
|
113
103
|
}
|
|
@@ -3,6 +3,12 @@ export const ICON_REGISTRY = {
|
|
|
3
3
|
"chevron-down": { viewBox: "0 0 24 24", paths: ["M6 9l6 6 6-6"] },
|
|
4
4
|
"copy-clipboard": { viewBox: "0 0 24 24", paths: ["M9 9h10v10H9z", "M5 15V5h10"] },
|
|
5
5
|
"check-checkmark": { viewBox: "0 0 24 24", paths: ["M5 13l4 4L19 7"] },
|
|
6
|
+
"grid": { viewBox: "0 0 24 24", paths: ["M4 4h6v6H4z", "M14 4h6v6h-6z", "M4 14h6v6H4z", "M14 14h6v6h-6z"] },
|
|
7
|
+
"atom": { viewBox: "0 0 24 24", paths: ["M12 12m-1.5 0a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0", "M12 3.5c4 0 8 3.6 8 8.5s-4 8.5-8 8.5", "M12 3.5c-4 1.8-8 5.6-8 8.5s4 6.7 8 8.5", "M4 8.5c1.8-4 5.6-5 8-5s6.2 1 8 5"] },
|
|
8
|
+
"layers": { viewBox: "0 0 24 24", paths: ["M12 3l8 4.5-8 4.5-8-4.5 8-4.5z", "M4 12l8 4.5 8-4.5", "M4 16.5l8 4.5 8-4.5"] },
|
|
9
|
+
"star": { viewBox: "0 0 24 24", paths: ["M12 3l2.6 5.6 6.1.7-4.5 4.2 1.2 6-5.4-3-5.4 3 1.2-6-4.5-4.2 6.1-.7L12 3z"] },
|
|
10
|
+
"archive": { viewBox: "0 0 24 24", paths: ["M3 4h18v4H3z", "M4.5 8v11a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1V8", "M10 12.5h4"] },
|
|
11
|
+
"list-view": { viewBox: "0 0 24 24", paths: ["M4 6h16", "M4 12h16", "M4 18h16"] },
|
|
6
12
|
} as const;
|
|
7
13
|
|
|
8
14
|
export type IconName = keyof typeof ICON_REGISTRY;
|
package/src/tokens.css
CHANGED
|
@@ -49,6 +49,14 @@
|
|
|
49
49
|
--color-kind-template-text: #B45309;
|
|
50
50
|
--color-kind-template-border: #FBD98A;
|
|
51
51
|
--color-semantic-info-soft: #EAE8FB;
|
|
52
|
+
--color-syntax-keyword: #0000FF;
|
|
53
|
+
--color-syntax-string: #A31515;
|
|
54
|
+
--color-syntax-number: #098658;
|
|
55
|
+
--color-syntax-comment: #008000;
|
|
56
|
+
--color-syntax-function: #795E26;
|
|
57
|
+
--color-syntax-type: #267F99;
|
|
58
|
+
--color-syntax-tag: #800000;
|
|
59
|
+
--color-syntax-property: #001080;
|
|
52
60
|
--font-body: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
53
61
|
--font-heading: var(--font-body);
|
|
54
62
|
--font-display-lg: var(--font-body);
|
|
@@ -179,4 +187,12 @@
|
|
|
179
187
|
--color-semantic-warning-soft: #3A2A0A;
|
|
180
188
|
--color-semantic-error-soft: #3A1414;
|
|
181
189
|
--color-semantic-info-soft: #28234F;
|
|
190
|
+
--color-syntax-keyword: #569CD6;
|
|
191
|
+
--color-syntax-string: #CE9178;
|
|
192
|
+
--color-syntax-number: #B5CEA8;
|
|
193
|
+
--color-syntax-comment: #6A9955;
|
|
194
|
+
--color-syntax-function: #DCDCAA;
|
|
195
|
+
--color-syntax-type: #4EC9B0;
|
|
196
|
+
--color-syntax-tag: #569CD6;
|
|
197
|
+
--color-syntax-property: #9CDCFE;
|
|
182
198
|
}
|