@arcfusionz/arc-primitive-ui 0.2.12 → 0.2.13
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/dist/components/CodeBlock/CodeBlock.d.ts +69 -0
- package/dist/components/CodeBlock/CodeBlock.js +201 -0
- package/dist/components/CodeBlock/index.d.ts +2 -0
- package/dist/components/CodeBlock/index.js +2 -0
- package/dist/components/CodeBlock/sqlHighlight.js +218 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/lib/cn.js +2 -1
- package/package.json +1 -1
- package/src/styles/theme.css +23 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
//#region src/components/CodeBlock/CodeBlock.d.ts
|
|
4
|
+
interface CodeBlockVariantsOptions {
|
|
5
|
+
/** Additional classes merged after the Code Block frame recipe. */
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Class list for an element styled as a Code Block frame (dark `code` surface,
|
|
10
|
+
* 6px border, `font-code`). Useful when a consumer needs the same shell around
|
|
11
|
+
* a bespoke body that this component's props do not cover.
|
|
12
|
+
*/
|
|
13
|
+
declare function codeBlockVariants({ className }?: CodeBlockVariantsOptions): string;
|
|
14
|
+
interface CodeBlockProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "className" | "prefix"> {
|
|
15
|
+
/**
|
|
16
|
+
* The source text. Used as the copy payload and, unless `children` is
|
|
17
|
+
* provided, rendered as the code body — syntax-highlighted when `language`
|
|
18
|
+
* is a SQL dialect, otherwise plain. A single trailing newline is trimmed.
|
|
19
|
+
*/
|
|
20
|
+
code?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Custom body rendered in place of `code`, for pre-highlighted output from a
|
|
23
|
+
* full engine (Shiki/Prism) or any non-SQL language. SQL is highlighted
|
|
24
|
+
* in-house, so `children` is only needed to go beyond that. Copy still uses
|
|
25
|
+
* `code` when set, otherwise the rendered text. Line numbers and
|
|
26
|
+
* `highlightLines` do not apply to a custom `children` body.
|
|
27
|
+
*/
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Language label shown in the header, e.g. `"sql"`; also emitted as
|
|
31
|
+
* `data-language`. When it names a SQL dialect (`sql`, `postgres`, `mysql`,
|
|
32
|
+
* …) the code is colored by the built-in SQL highlighter — the only language
|
|
33
|
+
* highlighted in-house. Other languages render plain unless you pass
|
|
34
|
+
* highlighted `children`.
|
|
35
|
+
*/
|
|
36
|
+
language?: string;
|
|
37
|
+
/** File name shown as the header title; also becomes the code region's accessible name. */
|
|
38
|
+
filename?: string;
|
|
39
|
+
/** Render a line-number gutter. Applies to the `code` path (plain or SQL), not a custom `children` body. */
|
|
40
|
+
showLineNumbers?: boolean;
|
|
41
|
+
/** 1-based line numbers to emphasize with a band and left accent. Applies to the `code` path, not a custom `children` body. */
|
|
42
|
+
highlightLines?: number[];
|
|
43
|
+
/** Soft-wrap long lines instead of the default horizontal scroll. */
|
|
44
|
+
wrap?: boolean;
|
|
45
|
+
/** Show the copy-to-clipboard control. */
|
|
46
|
+
copyable?: boolean;
|
|
47
|
+
/** Accessible name for the copy control. */
|
|
48
|
+
copyLabel?: string;
|
|
49
|
+
/** Message announced (politely) once the copy succeeds. */
|
|
50
|
+
copiedLabel?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Accessible name for the scrollable code region when there is no `filename`
|
|
53
|
+
* to name it. Defaults to `"<language> code"` or `"Code snippet"`.
|
|
54
|
+
*/
|
|
55
|
+
codeLabel?: string;
|
|
56
|
+
/** Cap the code area height (number → px), enabling vertical scroll. */
|
|
57
|
+
maxHeight?: number | string;
|
|
58
|
+
/**
|
|
59
|
+
* Replace the default `div` root, e.g. `render={<figure />}`. The header and
|
|
60
|
+
* code region are provided as children; choose an element that fits the
|
|
61
|
+
* surrounding document.
|
|
62
|
+
*/
|
|
63
|
+
render?: useRender.RenderProp;
|
|
64
|
+
/** Additional classes merged after the Code Block frame recipe. */
|
|
65
|
+
className?: string;
|
|
66
|
+
}
|
|
67
|
+
declare const CodeBlock: import("react").ForwardRefExoticComponent<CodeBlockProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { CodeBlock, CodeBlockProps, CodeBlockVariantsOptions, codeBlockVariants };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import { highlightSqlLines } from "./sqlHighlight.js";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
//#region src/components/CodeBlock/CodeBlock.tsx
|
|
7
|
+
const containerClasses = "relative overflow-hidden rounded-md border border-slate-800 bg-code font-code text-sm text-code-foreground";
|
|
8
|
+
/**
|
|
9
|
+
* Class list for an element styled as a Code Block frame (dark `code` surface,
|
|
10
|
+
* 6px border, `font-code`). Useful when a consumer needs the same shell around
|
|
11
|
+
* a bespoke body that this component's props do not cover.
|
|
12
|
+
*/
|
|
13
|
+
function codeBlockVariants({ className } = {}) {
|
|
14
|
+
return cn(containerClasses, className);
|
|
15
|
+
}
|
|
16
|
+
const SQL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
17
|
+
"sql",
|
|
18
|
+
"postgres",
|
|
19
|
+
"postgresql",
|
|
20
|
+
"psql",
|
|
21
|
+
"plpgsql",
|
|
22
|
+
"mysql",
|
|
23
|
+
"mariadb",
|
|
24
|
+
"sqlite",
|
|
25
|
+
"tsql",
|
|
26
|
+
"mssql",
|
|
27
|
+
"plsql",
|
|
28
|
+
"oracle",
|
|
29
|
+
"bigquery",
|
|
30
|
+
"snowflake",
|
|
31
|
+
"redshift"
|
|
32
|
+
]);
|
|
33
|
+
function isSqlLanguage(language) {
|
|
34
|
+
return language != null && SQL_LANGUAGES.has(language.toLowerCase());
|
|
35
|
+
}
|
|
36
|
+
const sqlTokenClasses = {
|
|
37
|
+
keyword: "text-code-keyword",
|
|
38
|
+
function: "text-code-function",
|
|
39
|
+
string: "text-code-string",
|
|
40
|
+
number: "text-code-number",
|
|
41
|
+
comment: "text-code-comment italic",
|
|
42
|
+
punctuation: "text-code-punctuation",
|
|
43
|
+
identifier: "",
|
|
44
|
+
whitespace: ""
|
|
45
|
+
};
|
|
46
|
+
/** Render one line of SQL tokens as colored spans (or a space to hold height). */
|
|
47
|
+
function renderSqlLine(tokens) {
|
|
48
|
+
if (tokens.length === 0) return " ";
|
|
49
|
+
return tokens.map((token, index) => {
|
|
50
|
+
const className = sqlTokenClasses[token.type];
|
|
51
|
+
return className ? /* @__PURE__ */ jsx("span", {
|
|
52
|
+
className,
|
|
53
|
+
children: token.value
|
|
54
|
+
}, index) : /* @__PURE__ */ jsx("span", { children: token.value }, index);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function CopyIcon(props) {
|
|
58
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
59
|
+
viewBox: "0 0 24 24",
|
|
60
|
+
fill: "none",
|
|
61
|
+
stroke: "currentColor",
|
|
62
|
+
strokeWidth: 2,
|
|
63
|
+
strokeLinecap: "round",
|
|
64
|
+
strokeLinejoin: "round",
|
|
65
|
+
...props,
|
|
66
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
67
|
+
x: "9",
|
|
68
|
+
y: "9",
|
|
69
|
+
width: "13",
|
|
70
|
+
height: "13",
|
|
71
|
+
rx: "2"
|
|
72
|
+
}), /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function CheckIcon(props) {
|
|
76
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
77
|
+
viewBox: "0 0 24 24",
|
|
78
|
+
fill: "none",
|
|
79
|
+
stroke: "currentColor",
|
|
80
|
+
strokeWidth: 2,
|
|
81
|
+
strokeLinecap: "round",
|
|
82
|
+
strokeLinejoin: "round",
|
|
83
|
+
...props,
|
|
84
|
+
children: /* @__PURE__ */ jsx("path", { d: "m5 13 4 4L19 7" })
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function CopyButton({ getText, copyLabel, copiedLabel, floating = false }) {
|
|
88
|
+
const [copied, setCopied] = useState(false);
|
|
89
|
+
const resetTimer = useRef(void 0);
|
|
90
|
+
useEffect(() => () => clearTimeout(resetTimer.current), []);
|
|
91
|
+
const handleCopy = () => {
|
|
92
|
+
const write = navigator?.clipboard?.writeText;
|
|
93
|
+
if (!write) return;
|
|
94
|
+
write.call(navigator.clipboard, getText()).then(() => {
|
|
95
|
+
setCopied(true);
|
|
96
|
+
clearTimeout(resetTimer.current);
|
|
97
|
+
resetTimer.current = setTimeout(() => setCopied(false), 2e3);
|
|
98
|
+
}, () => {});
|
|
99
|
+
};
|
|
100
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
101
|
+
type: "button",
|
|
102
|
+
onClick: handleCopy,
|
|
103
|
+
"aria-label": copyLabel,
|
|
104
|
+
className: cn("inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-slate-400", "transition-colors hover:bg-background/10 hover:text-code-foreground", "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring", "[&_svg]:pointer-events-none [&_svg]:size-4", floating && "absolute right-2 top-2 z-10 bg-code/90 text-slate-300"),
|
|
105
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
className: "text-success-400"
|
|
108
|
+
}) : /* @__PURE__ */ jsx(CopyIcon, { "aria-hidden": "true" }), /* @__PURE__ */ jsx("span", {
|
|
109
|
+
className: "sr-only",
|
|
110
|
+
"aria-live": "polite",
|
|
111
|
+
children: copied ? copiedLabel : ""
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const CodeBlock = forwardRef(({ code, children, language, filename, showLineNumbers = false, highlightLines, wrap = false, copyable = true, copyLabel = "Copy code", copiedLabel = "Copied to clipboard", codeLabel, maxHeight, render, className, ...rest }, ref) => {
|
|
116
|
+
const preRef = useRef(null);
|
|
117
|
+
const filenameId = useId();
|
|
118
|
+
const getCopyText = useCallback(() => code ?? preRef.current?.textContent ?? "", [code]);
|
|
119
|
+
const trimmed = code == null ? null : code.replace(/\n$/, "");
|
|
120
|
+
const sqlMode = children == null && trimmed != null && isSqlLanguage(language);
|
|
121
|
+
const plainLines = useMemo(() => children == null && trimmed != null && !isSqlLanguage(language) ? trimmed.split("\n") : null, [
|
|
122
|
+
children,
|
|
123
|
+
trimmed,
|
|
124
|
+
language
|
|
125
|
+
]);
|
|
126
|
+
const codeLines = useMemo(() => sqlMode && trimmed != null ? highlightSqlLines(trimmed) : null, [sqlMode, trimmed]) ?? plainLines;
|
|
127
|
+
const highlightSet = useMemo(() => new Set(highlightLines ?? []), [highlightLines]);
|
|
128
|
+
const gutterMinWidth = codeLines ? `${String(codeLines.length).length}ch` : void 0;
|
|
129
|
+
const hasHeader = Boolean(filename) || Boolean(language);
|
|
130
|
+
const preStyle = maxHeight == null ? void 0 : { maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight };
|
|
131
|
+
const copyButton = copyable ? /* @__PURE__ */ jsx(CopyButton, {
|
|
132
|
+
getText: getCopyText,
|
|
133
|
+
copyLabel,
|
|
134
|
+
copiedLabel,
|
|
135
|
+
floating: !hasHeader
|
|
136
|
+
}) : null;
|
|
137
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [hasHeader && /* @__PURE__ */ jsxs("div", {
|
|
138
|
+
className: "flex items-center justify-between gap-3 border-b border-slate-800 bg-slate-950 px-4 py-2",
|
|
139
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
140
|
+
className: "flex min-w-0 items-center gap-2",
|
|
141
|
+
children: filename && /* @__PURE__ */ jsx("span", {
|
|
142
|
+
id: filenameId,
|
|
143
|
+
className: "truncate font-sans text-sm text-slate-300",
|
|
144
|
+
children: filename
|
|
145
|
+
})
|
|
146
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
147
|
+
className: "flex shrink-0 items-center gap-3",
|
|
148
|
+
children: [language && /* @__PURE__ */ jsx("span", {
|
|
149
|
+
className: "font-sans text-xs font-medium uppercase tracking-wider text-slate-400",
|
|
150
|
+
children: language
|
|
151
|
+
}), copyButton]
|
|
152
|
+
})]
|
|
153
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
154
|
+
className: "relative",
|
|
155
|
+
children: [!hasHeader && copyButton, /* @__PURE__ */ jsx("pre", {
|
|
156
|
+
ref: preRef,
|
|
157
|
+
tabIndex: 0,
|
|
158
|
+
"aria-labelledby": filename ? filenameId : void 0,
|
|
159
|
+
"aria-label": filename ? void 0 : codeLabel ?? (language ? `${language} code` : "Code snippet"),
|
|
160
|
+
style: preStyle,
|
|
161
|
+
className: cn("m-0 overflow-auto py-3 leading-relaxed whitespace-normal", "focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring"),
|
|
162
|
+
children: children != null ? /* @__PURE__ */ jsx("code", {
|
|
163
|
+
className: cn("block px-4", wrap ? "whitespace-pre-wrap break-words" : "whitespace-pre"),
|
|
164
|
+
children
|
|
165
|
+
}) : /* @__PURE__ */ jsx("code", {
|
|
166
|
+
className: "block",
|
|
167
|
+
children: codeLines?.map((line, index) => {
|
|
168
|
+
const lineNumber = index + 1;
|
|
169
|
+
const highlighted = highlightSet.has(lineNumber);
|
|
170
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
171
|
+
"data-line": lineNumber,
|
|
172
|
+
className: cn("flex items-start border-l-2 border-transparent", wrap ? "w-full" : "w-max min-w-full", highlighted && "border-primary-500 bg-background/10"),
|
|
173
|
+
children: [showLineNumbers && /* @__PURE__ */ jsx("span", {
|
|
174
|
+
"aria-hidden": "true",
|
|
175
|
+
style: { minWidth: gutterMinWidth },
|
|
176
|
+
className: "shrink-0 select-none pr-4 pl-4 text-right text-slate-400 tabular-nums",
|
|
177
|
+
children: lineNumber
|
|
178
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
179
|
+
className: cn("min-w-0", showLineNumbers ? "pr-4" : "px-4", wrap ? "whitespace-pre-wrap break-words" : "whitespace-pre"),
|
|
180
|
+
children: typeof line === "string" ? line.length ? line : " " : renderSqlLine(line)
|
|
181
|
+
})]
|
|
182
|
+
}, index);
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
})]
|
|
186
|
+
})] });
|
|
187
|
+
return useRender({
|
|
188
|
+
defaultTagName: "div",
|
|
189
|
+
render,
|
|
190
|
+
ref,
|
|
191
|
+
props: {
|
|
192
|
+
...rest,
|
|
193
|
+
"data-language": language,
|
|
194
|
+
className: codeBlockVariants({ className }),
|
|
195
|
+
children: content
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
CodeBlock.displayName = "CodeBlock";
|
|
200
|
+
//#endregion
|
|
201
|
+
export { CodeBlock, codeBlockVariants };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
//#region src/components/CodeBlock/sqlHighlight.ts
|
|
2
|
+
const KEYWORDS = /* @__PURE__ */ new Set([
|
|
3
|
+
"ADD",
|
|
4
|
+
"ALL",
|
|
5
|
+
"ALTER",
|
|
6
|
+
"AND",
|
|
7
|
+
"ANY",
|
|
8
|
+
"AS",
|
|
9
|
+
"ASC",
|
|
10
|
+
"BEGIN",
|
|
11
|
+
"BETWEEN",
|
|
12
|
+
"BY",
|
|
13
|
+
"CASCADE",
|
|
14
|
+
"CASE",
|
|
15
|
+
"CAST",
|
|
16
|
+
"CHECK",
|
|
17
|
+
"COLLATE",
|
|
18
|
+
"COLUMN",
|
|
19
|
+
"COMMIT",
|
|
20
|
+
"CONSTRAINT",
|
|
21
|
+
"CREATE",
|
|
22
|
+
"CROSS",
|
|
23
|
+
"CURRENT",
|
|
24
|
+
"DATABASE",
|
|
25
|
+
"DECLARE",
|
|
26
|
+
"DEFAULT",
|
|
27
|
+
"DELETE",
|
|
28
|
+
"DESC",
|
|
29
|
+
"DISTINCT",
|
|
30
|
+
"DO",
|
|
31
|
+
"DROP",
|
|
32
|
+
"ELSE",
|
|
33
|
+
"END",
|
|
34
|
+
"EXCEPT",
|
|
35
|
+
"EXISTS",
|
|
36
|
+
"EXPLAIN",
|
|
37
|
+
"FALSE",
|
|
38
|
+
"FETCH",
|
|
39
|
+
"FILTER",
|
|
40
|
+
"FIRST",
|
|
41
|
+
"FOLLOWING",
|
|
42
|
+
"FOR",
|
|
43
|
+
"FOREIGN",
|
|
44
|
+
"FROM",
|
|
45
|
+
"FULL",
|
|
46
|
+
"FUNCTION",
|
|
47
|
+
"GENERATED",
|
|
48
|
+
"GRANT",
|
|
49
|
+
"GROUP",
|
|
50
|
+
"HAVING",
|
|
51
|
+
"IF",
|
|
52
|
+
"ILIKE",
|
|
53
|
+
"IN",
|
|
54
|
+
"INDEX",
|
|
55
|
+
"INNER",
|
|
56
|
+
"INSERT",
|
|
57
|
+
"INTERSECT",
|
|
58
|
+
"INTO",
|
|
59
|
+
"IS",
|
|
60
|
+
"JOIN",
|
|
61
|
+
"KEY",
|
|
62
|
+
"LANGUAGE",
|
|
63
|
+
"LAST",
|
|
64
|
+
"LATERAL",
|
|
65
|
+
"LEFT",
|
|
66
|
+
"LIKE",
|
|
67
|
+
"LIMIT",
|
|
68
|
+
"MATERIALIZED",
|
|
69
|
+
"NATURAL",
|
|
70
|
+
"NEXT",
|
|
71
|
+
"NOT",
|
|
72
|
+
"NOTHING",
|
|
73
|
+
"NULL",
|
|
74
|
+
"NULLS",
|
|
75
|
+
"OFFSET",
|
|
76
|
+
"ON",
|
|
77
|
+
"ONLY",
|
|
78
|
+
"OR",
|
|
79
|
+
"ORDER",
|
|
80
|
+
"OUTER",
|
|
81
|
+
"OVER",
|
|
82
|
+
"PARTITION",
|
|
83
|
+
"PRECEDING",
|
|
84
|
+
"PRIMARY",
|
|
85
|
+
"PROCEDURE",
|
|
86
|
+
"RANGE",
|
|
87
|
+
"RECURSIVE",
|
|
88
|
+
"REFERENCES",
|
|
89
|
+
"RETURNING",
|
|
90
|
+
"RETURNS",
|
|
91
|
+
"REVOKE",
|
|
92
|
+
"RIGHT",
|
|
93
|
+
"ROLLBACK",
|
|
94
|
+
"ROW",
|
|
95
|
+
"ROWS",
|
|
96
|
+
"SCHEMA",
|
|
97
|
+
"SELECT",
|
|
98
|
+
"SEQUENCE",
|
|
99
|
+
"SET",
|
|
100
|
+
"SOME",
|
|
101
|
+
"TABLE",
|
|
102
|
+
"TEMP",
|
|
103
|
+
"TEMPORARY",
|
|
104
|
+
"THEN",
|
|
105
|
+
"TRANSACTION",
|
|
106
|
+
"TRIGGER",
|
|
107
|
+
"TRUE",
|
|
108
|
+
"TRUNCATE",
|
|
109
|
+
"UNBOUNDED",
|
|
110
|
+
"UNION",
|
|
111
|
+
"UNIQUE",
|
|
112
|
+
"UNKNOWN",
|
|
113
|
+
"UPDATE",
|
|
114
|
+
"USING",
|
|
115
|
+
"VALUES",
|
|
116
|
+
"VIEW",
|
|
117
|
+
"WHEN",
|
|
118
|
+
"WHERE",
|
|
119
|
+
"WINDOW",
|
|
120
|
+
"WITH",
|
|
121
|
+
"BIGINT",
|
|
122
|
+
"BIT",
|
|
123
|
+
"BOOL",
|
|
124
|
+
"BOOLEAN",
|
|
125
|
+
"BYTEA",
|
|
126
|
+
"CHAR",
|
|
127
|
+
"CLOB",
|
|
128
|
+
"BLOB",
|
|
129
|
+
"DATE",
|
|
130
|
+
"DECIMAL",
|
|
131
|
+
"DOUBLE",
|
|
132
|
+
"FLOAT",
|
|
133
|
+
"INT",
|
|
134
|
+
"INTEGER",
|
|
135
|
+
"INTERVAL",
|
|
136
|
+
"JSON",
|
|
137
|
+
"JSONB",
|
|
138
|
+
"MONEY",
|
|
139
|
+
"NCHAR",
|
|
140
|
+
"NUMERIC",
|
|
141
|
+
"NVARCHAR",
|
|
142
|
+
"PRECISION",
|
|
143
|
+
"REAL",
|
|
144
|
+
"SERIAL",
|
|
145
|
+
"SMALLINT",
|
|
146
|
+
"TEXT",
|
|
147
|
+
"TIME",
|
|
148
|
+
"TIMESTAMP",
|
|
149
|
+
"TIMESTAMPTZ",
|
|
150
|
+
"UUID",
|
|
151
|
+
"VARCHAR"
|
|
152
|
+
]);
|
|
153
|
+
const SQL_TOKEN_PATTERN = /(\/\*[\s\S]*?\*\/|--[^\n\r]*|#[^\n\r]*)|('(?:[^'\\]|\\.|'')*')|("(?:[^"\\]|\\.|"")*"|`(?:[^`]|``)*`)|((?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?)|(\w+)|(\s+)|([(),;.[\]{}]+|::|[-+*/%<>=!|&^~@?]+)|([\s\S])/g;
|
|
154
|
+
function classifyWord(word, source, nextIndex) {
|
|
155
|
+
if (KEYWORDS.has(word.toUpperCase())) return "keyword";
|
|
156
|
+
let index = nextIndex;
|
|
157
|
+
while (index < source.length && (source[index] === " " || source[index] === " ")) index += 1;
|
|
158
|
+
return source[index] === "(" ? "function" : "identifier";
|
|
159
|
+
}
|
|
160
|
+
function tokenizeSql(source) {
|
|
161
|
+
const tokens = [];
|
|
162
|
+
SQL_TOKEN_PATTERN.lastIndex = 0;
|
|
163
|
+
let match;
|
|
164
|
+
while ((match = SQL_TOKEN_PATTERN.exec(source)) !== null) {
|
|
165
|
+
const [full, comment, str, quotedIdentifier, num, word, whitespace, punctuation] = match;
|
|
166
|
+
if (comment != null) tokens.push({
|
|
167
|
+
type: "comment",
|
|
168
|
+
value: comment
|
|
169
|
+
});
|
|
170
|
+
else if (str != null) tokens.push({
|
|
171
|
+
type: "string",
|
|
172
|
+
value: str
|
|
173
|
+
});
|
|
174
|
+
else if (quotedIdentifier != null) tokens.push({
|
|
175
|
+
type: "identifier",
|
|
176
|
+
value: quotedIdentifier
|
|
177
|
+
});
|
|
178
|
+
else if (num != null) tokens.push({
|
|
179
|
+
type: "number",
|
|
180
|
+
value: num
|
|
181
|
+
});
|
|
182
|
+
else if (word != null) tokens.push({
|
|
183
|
+
type: classifyWord(word, source, SQL_TOKEN_PATTERN.lastIndex),
|
|
184
|
+
value: word
|
|
185
|
+
});
|
|
186
|
+
else if (whitespace != null) tokens.push({
|
|
187
|
+
type: "whitespace",
|
|
188
|
+
value: whitespace
|
|
189
|
+
});
|
|
190
|
+
else if (punctuation != null) tokens.push({
|
|
191
|
+
type: "punctuation",
|
|
192
|
+
value: punctuation
|
|
193
|
+
});
|
|
194
|
+
else tokens.push({
|
|
195
|
+
type: "identifier",
|
|
196
|
+
value: full
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return tokens;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Tokenize `source` and group the tokens by line. Multi-line tokens (block
|
|
203
|
+
* comments, multi-line strings) are split at newlines so each line renders
|
|
204
|
+
* independently. Returns one array of tokens per source line.
|
|
205
|
+
*/
|
|
206
|
+
function highlightSqlLines(source) {
|
|
207
|
+
const lines = [[]];
|
|
208
|
+
for (const token of tokenizeSql(source)) token.value.split("\n").forEach((part, index) => {
|
|
209
|
+
if (index > 0) lines.push([]);
|
|
210
|
+
if (part.length > 0) lines[lines.length - 1].push({
|
|
211
|
+
type: token.type,
|
|
212
|
+
value: part
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
return lines;
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
export { highlightSqlLines };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ import { Calendar, CalendarDateRange, CalendarMode, CalendarProps, CalendarState
|
|
|
22
22
|
import "./components/Calendar/index.js";
|
|
23
23
|
import { Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, CheckboxSize, CheckboxVariantsOptions, checkboxVariants } from "./components/Checkbox/Checkbox.js";
|
|
24
24
|
import "./components/Checkbox/index.js";
|
|
25
|
+
import { CodeBlock, CodeBlockProps, CodeBlockVariantsOptions, codeBlockVariants } from "./components/CodeBlock/CodeBlock.js";
|
|
26
|
+
import "./components/CodeBlock/index.js";
|
|
25
27
|
import { Select, SelectAlign, SelectGroup, SelectGroupLabel, SelectGroupLabelProps, SelectGroupProps, SelectItem, SelectItemProps, SelectLabel, SelectLabelProps, SelectPopup, SelectPopupProps, SelectProps, SelectSeparator, SelectSeparatorProps, SelectTrigger, SelectTriggerProps, SelectTriggerSize, SelectTriggerVariant, SelectTriggerVariantsOptions, SelectValue, SelectValueProps, selectTriggerVariants } from "./components/Select/Select.js";
|
|
26
28
|
import "./components/Select/index.js";
|
|
27
29
|
import { Combobox, ComboboxAlign, ComboboxChip, ComboboxChipProps, ComboboxChipRemove, ComboboxChipRemoveProps, ComboboxChips, ComboboxChipsProps, ComboboxClear, ComboboxClearProps, ComboboxCollection, ComboboxCollectionProps, ComboboxGroup, ComboboxGroupLabel, ComboboxGroupLabelProps, ComboboxGroupProps, ComboboxInput, ComboboxInputGroup, ComboboxInputGroupProps, ComboboxInputGroupVariantsOptions, ComboboxInputProps, ComboboxItem, ComboboxItemProps, ComboboxLabel, ComboboxLabelProps, ComboboxPopup, ComboboxPopupProps, ComboboxProps, ComboboxSeparator, ComboboxSeparatorProps, ComboboxSize, ComboboxTrigger, ComboboxTriggerProps, ComboboxTriggerSize, ComboboxTriggerVariant, ComboboxValue, ComboboxValueProps, comboboxInputGroupVariants, useComboboxFilter, useComboboxFilteredItems } from "./components/Combobox/Combobox.js";
|
|
@@ -78,4 +80,4 @@ import "./components/Tooltip/index.js";
|
|
|
78
80
|
import { Typography, TypographyProps, TypographyVariant, TypographyVariantsOptions, typographyVariants } from "./components/Typography/Typography.js";
|
|
79
81
|
import "./components/Typography/index.js";
|
|
80
82
|
import { cn } from "./lib/cn.js";
|
|
81
|
-
export { AILoader, type AILoaderProps, type AILoaderRenderState, type AILoaderSize, type AILoaderState, type AILoaderTone, Accordion, type AccordionChevronPosition, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, AccordionPanel, type AccordionPanelProps, type AccordionProps, type AccordionSize, AccordionTrigger, type AccordionTriggerProps, type AccordionVariant, Alert, type AlertAppearance, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogDescription, type AlertDialogDescriptionProps, AlertDialogFooter, type AlertDialogFooterProps, AlertDialogHeader, type AlertDialogHeaderProps, AlertDialogPopup, type AlertDialogPopupProps, type AlertDialogPopupVariantsOptions, type AlertDialogProps, type AlertDialogScrollBehavior, type AlertDialogSize, AlertDialogTitle, type AlertDialogTitleProps, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, type AlertVariant, type AlertVariantsOptions, Avatar, AvatarBadge, type AvatarBadgeProps, AvatarFallback, type AvatarFallbackProps, AvatarGroup, type AvatarGroupProps, AvatarImage, type AvatarImageProps, type AvatarProps, type AvatarShape, type AvatarSize, type AvatarVariantsOptions, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeVariant, type BadgeVariantsOptions, Box, type BoxBackground, type BoxPadding, type BoxProps, type BoxRadius, type BoxShadow, type BoxVariantsOptions, Breadcrumb, BreadcrumbEllipsis, type BreadcrumbEllipsisProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkProps, type BreadcrumbLinkVariantsOptions, BreadcrumbList, type BreadcrumbListProps, BreadcrumbPage, type BreadcrumbPageProps, type BreadcrumbProps, BreadcrumbSeparator, type BreadcrumbSeparatorProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarDateRange, type CalendarMode, type CalendarProps, type CalendarState, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type CheckboxSize, type CheckboxVariantsOptions, Combobox, type ComboboxAlign, ComboboxChip, type ComboboxChipProps, ComboboxChipRemove, type ComboboxChipRemoveProps, ComboboxChips, type ComboboxChipsProps, ComboboxClear, type ComboboxClearProps, ComboboxCollection, type ComboboxCollectionProps, ComboboxGroup, ComboboxGroupLabel, type ComboboxGroupLabelProps, type ComboboxGroupProps, ComboboxInput, ComboboxInputGroup, type ComboboxInputGroupProps, type ComboboxInputGroupVariantsOptions, type ComboboxInputProps, ComboboxItem, type ComboboxItemProps, ComboboxLabel, type ComboboxLabelProps, ComboboxPopup, type ComboboxPopupProps, type ComboboxProps, ComboboxSeparator, type ComboboxSeparatorProps, type ComboboxSize, ComboboxTrigger, type ComboboxTriggerProps, type ComboboxTriggerSize, type ComboboxTriggerVariant, ComboboxValue, type ComboboxValueProps, ContextMenu, type ContextMenuAlign, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuGroup, ContextMenuGroupLabel, type ContextMenuGroupLabelProps, type ContextMenuGroupProps, ContextMenuItem, type ContextMenuItemProps, type ContextMenuItemVariant, ContextMenuLinkItem, type ContextMenuLinkItemProps, ContextMenuPopup, type ContextMenuPopupProps, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, type ContextMenuSeparatorProps, ContextMenuShortcut, type ContextMenuShortcutProps, type ContextMenuSide, ContextMenuSubmenuRoot, type ContextMenuSubmenuRootProps, ContextMenuSubmenuTrigger, type ContextMenuSubmenuTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, DatePicker, type DatePickerCalendarProps, type DatePickerPopupProps, type DatePickerProps, type DatePickerSize, type DatePickerVariant, type DatePickerVariantsOptions, DateRangePicker, type DateRangePickerCalendarProps, type DateRangePickerPopupProps, type DateRangePickerProps, type DateRangePickerSize, type DateRangePickerVariant, type DateRangePickerVariantsOptions, Dialog, DialogClose, type DialogCloseProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderProps, DialogPopup, type DialogPopupProps, type DialogPopupVariantsOptions, type DialogProps, type DialogScrollBehavior, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, Divider, type DividerLabelPosition, type DividerOrientation, type DividerProps, type DividerVariant, type DividerVariantsOptions, Drawer, DrawerClose, type DrawerCloseProps, DrawerDescription, type DrawerDescriptionProps, DrawerFooter, type DrawerFooterProps, DrawerHeader, type DrawerHeaderProps, DrawerIndent, DrawerIndentBackground, type DrawerIndentBackgroundProps, type DrawerIndentProps, DrawerPopup, type DrawerPopupProps, type DrawerPopupVariantsOptions, type DrawerProps, DrawerProvider, type DrawerSide, type DrawerSize, DrawerSwipeArea, type DrawerSwipeAreaProps, DrawerTitle, type DrawerTitleProps, DrawerTrigger, type DrawerTriggerProps, DrawerVirtualKeyboardProvider, Field, type FieldControlProps, FieldDescription, type FieldDescriptionProps, FieldError, type FieldErrorProps, FieldItem, type FieldItemProps, FieldLabel, type FieldLabelProps, type FieldLabelVariantsOptions, type FieldOrientation, type FieldProps, FieldValidity, type FieldValidityProps, Fieldset, FieldsetDescription, type FieldsetDescriptionProps, FieldsetLegend, type FieldsetLegendProps, type FieldsetLegendVariant, type FieldsetProps, Form, type FormProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonProps, type InputGroupProps, type InputProps, type InputSize, type InputVariantsOptions, Menu, type MenuAlign, MenuCheckboxItem, type MenuCheckboxItemProps, MenuGroup, MenuGroupLabel, type MenuGroupLabelProps, type MenuGroupProps, type MenuHandle, MenuItem, type MenuItemProps, type MenuItemVariant, type MenuItemVariantsOptions, MenuLinkItem, type MenuLinkItemProps, MenuPopup, type MenuPopupProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuShortcut, type MenuShortcutProps, type MenuSide, MenuSubmenuRoot, type MenuSubmenuRootProps, MenuSubmenuTrigger, type MenuSubmenuTriggerProps, MenuTrigger, type MenuTriggerProps, Meter, type MeterIndicatorVariantsOptions, type MeterProps, type MeterSize, type MeterTrackVariantsOptions, type MeterVariant, Popover, type PopoverAlign, PopoverClose, type PopoverCloseProps, PopoverDescription, type PopoverDescriptionProps, type PopoverHandle, PopoverPopup, type PopoverPopupProps, type PopoverPopupVariantsOptions, type PopoverProps, type PopoverSide, PopoverTitle, type PopoverTitleProps, PopoverTrigger, type PopoverTriggerProps, Progress, type ProgressIndicatorVariantsOptions, type ProgressProps, type ProgressSize, type ProgressTrackVariantsOptions, type ProgressVariant, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadioSize, type RadioVariantsOptions, Select, type SelectAlign, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, type SelectGroupProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, SelectPopup, type SelectPopupProps, type SelectProps, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, type SelectTriggerSize, type SelectTriggerVariant, type SelectTriggerVariantsOptions, SelectValue, type SelectValueProps, Skeleton, type SkeletonAnimation, type SkeletonProps, type SkeletonRenderState, type SkeletonVariant, type SkeletonVariantsOptions, Stepper, StepperDescription, type StepperDescriptionProps, StepperIndicator, type StepperIndicatorProps, StepperItem, type StepperItemProps, type StepperOrientation, type StepperProps, StepperSeparator, type StepperSeparatorProps, type StepperSize, StepperTitle, type StepperTitleProps, StepperTrigger, type StepperTriggerProps, type StepperTriggerVariantsOptions, Switch, type SwitchLabelPosition, type SwitchProps, type SwitchSize, type SwitchVariantsOptions, SystemState, type SystemStateBackground, type SystemStateProps, type SystemStateRenderState, type SystemStateScope, type SystemStateTitleLevel, type SystemStateVariant, Table, TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, type TableCaptionRenderState, type TableCaptionSide, TableCell, type TableCellProps, TableContainer, type TableContainerProps, type TableContainerRenderState, type TableContainerVariant, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, type TableLayout, type TableProps, type TableRenderState, TableRow, type TableRowProps, type TableRowRenderState, type TableSize, Tabs, type TabsIndicatorPosition, TabsList, type TabsListProps, type TabsListVariantsOptions, TabsPanel, type TabsPanelProps, type TabsProps, type TabsSize, TabsTab, type TabsTabProps, type TabsTabVariantsOptions, type TabsVariant, Timeline, TimelineConnector, type TimelineConnectorProps, TimelineContent, type TimelineContentProps, TimelineDescription, type TimelineDescriptionProps, TimelineIndicator, type TimelineIndicatorAppearance, type TimelineIndicatorProps, type TimelineIndicatorVariant, TimelineItem, type TimelineItemProps, type TimelineProps, TimelineSeparator, type TimelineSeparatorProps, type TimelineSeparatorVariant, type TimelineSize, TimelineTime, type TimelineTimeProps, TimelineTitle, type TimelineTitleProps, type ToastData, type ToastManager, type ToastObject, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastType, type ToastUpdateOptions, Toaster, type ToasterProps, Toggle, ToggleGroup, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, type TooltipAlign, type TooltipHandle, TooltipPopup, type TooltipPopupProps, type TooltipPopupVariantsOptions, type TooltipProps, TooltipProvider, type TooltipProviderProps, type TooltipSide, TooltipTrigger, type TooltipTriggerProps, Typography, type TypographyProps, type TypographyVariant, type TypographyVariantsOptions, alertDialogPopupVariants, alertVariants, avatarVariants, badgeVariants, boxVariants, breadcrumbLinkVariants, buttonVariants, checkboxVariants, cn, comboboxInputGroupVariants, createAlertDialogHandle, createDrawerHandle, createMenuHandle, createPopoverHandle, createToastManager, createTooltipHandle, datePickerVariants, dateRangePickerVariants, dialogPopupVariants, dividerVariants, drawerPopupVariants, fieldLabelVariants, inputVariants, menuItemVariants, meterIndicatorVariants, meterTrackVariants, popoverPopupVariants, progressIndicatorVariants, progressTrackVariants, radioVariants, selectTriggerVariants, skeletonVariants, stepperTriggerVariants, switchVariants, tabsListVariants, tabsTabVariants, toast, toggleVariants, tooltipPopupVariants, typographyVariants, useComboboxFilter, useComboboxFilteredItems, useFieldControl };
|
|
83
|
+
export { AILoader, type AILoaderProps, type AILoaderRenderState, type AILoaderSize, type AILoaderState, type AILoaderTone, Accordion, type AccordionChevronPosition, AccordionHeader, type AccordionHeaderProps, AccordionItem, type AccordionItemProps, AccordionPanel, type AccordionPanelProps, type AccordionProps, type AccordionSize, AccordionTrigger, type AccordionTriggerProps, type AccordionVariant, Alert, type AlertAppearance, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogDescription, type AlertDialogDescriptionProps, AlertDialogFooter, type AlertDialogFooterProps, AlertDialogHeader, type AlertDialogHeaderProps, AlertDialogPopup, type AlertDialogPopupProps, type AlertDialogPopupVariantsOptions, type AlertDialogProps, type AlertDialogScrollBehavior, type AlertDialogSize, AlertDialogTitle, type AlertDialogTitleProps, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, type AlertVariant, type AlertVariantsOptions, Avatar, AvatarBadge, type AvatarBadgeProps, AvatarFallback, type AvatarFallbackProps, AvatarGroup, type AvatarGroupProps, AvatarImage, type AvatarImageProps, type AvatarProps, type AvatarShape, type AvatarSize, type AvatarVariantsOptions, Badge, type BadgeAppearance, type BadgeProps, type BadgeSize, type BadgeVariant, type BadgeVariantsOptions, Box, type BoxBackground, type BoxPadding, type BoxProps, type BoxRadius, type BoxShadow, type BoxVariantsOptions, Breadcrumb, BreadcrumbEllipsis, type BreadcrumbEllipsisProps, BreadcrumbItem, type BreadcrumbItemProps, BreadcrumbLink, type BreadcrumbLinkProps, type BreadcrumbLinkVariantsOptions, BreadcrumbList, type BreadcrumbListProps, BreadcrumbPage, type BreadcrumbPageProps, type BreadcrumbProps, BreadcrumbSeparator, type BreadcrumbSeparatorProps, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarDateRange, type CalendarMode, type CalendarProps, type CalendarState, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, type CheckboxSize, type CheckboxVariantsOptions, CodeBlock, type CodeBlockProps, type CodeBlockVariantsOptions, Combobox, type ComboboxAlign, ComboboxChip, type ComboboxChipProps, ComboboxChipRemove, type ComboboxChipRemoveProps, ComboboxChips, type ComboboxChipsProps, ComboboxClear, type ComboboxClearProps, ComboboxCollection, type ComboboxCollectionProps, ComboboxGroup, ComboboxGroupLabel, type ComboboxGroupLabelProps, type ComboboxGroupProps, ComboboxInput, ComboboxInputGroup, type ComboboxInputGroupProps, type ComboboxInputGroupVariantsOptions, type ComboboxInputProps, ComboboxItem, type ComboboxItemProps, ComboboxLabel, type ComboboxLabelProps, ComboboxPopup, type ComboboxPopupProps, type ComboboxProps, ComboboxSeparator, type ComboboxSeparatorProps, type ComboboxSize, ComboboxTrigger, type ComboboxTriggerProps, type ComboboxTriggerSize, type ComboboxTriggerVariant, ComboboxValue, type ComboboxValueProps, ContextMenu, type ContextMenuAlign, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuGroup, ContextMenuGroupLabel, type ContextMenuGroupLabelProps, type ContextMenuGroupProps, ContextMenuItem, type ContextMenuItemProps, type ContextMenuItemVariant, ContextMenuLinkItem, type ContextMenuLinkItemProps, ContextMenuPopup, type ContextMenuPopupProps, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, type ContextMenuSeparatorProps, ContextMenuShortcut, type ContextMenuShortcutProps, type ContextMenuSide, ContextMenuSubmenuRoot, type ContextMenuSubmenuRootProps, ContextMenuSubmenuTrigger, type ContextMenuSubmenuTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, DatePicker, type DatePickerCalendarProps, type DatePickerPopupProps, type DatePickerProps, type DatePickerSize, type DatePickerVariant, type DatePickerVariantsOptions, DateRangePicker, type DateRangePickerCalendarProps, type DateRangePickerPopupProps, type DateRangePickerProps, type DateRangePickerSize, type DateRangePickerVariant, type DateRangePickerVariantsOptions, Dialog, DialogClose, type DialogCloseProps, DialogDescription, type DialogDescriptionProps, DialogFooter, type DialogFooterProps, DialogHeader, type DialogHeaderProps, DialogPopup, type DialogPopupProps, type DialogPopupVariantsOptions, type DialogProps, type DialogScrollBehavior, type DialogSize, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, Divider, type DividerLabelPosition, type DividerOrientation, type DividerProps, type DividerVariant, type DividerVariantsOptions, Drawer, DrawerClose, type DrawerCloseProps, DrawerDescription, type DrawerDescriptionProps, DrawerFooter, type DrawerFooterProps, DrawerHeader, type DrawerHeaderProps, DrawerIndent, DrawerIndentBackground, type DrawerIndentBackgroundProps, type DrawerIndentProps, DrawerPopup, type DrawerPopupProps, type DrawerPopupVariantsOptions, type DrawerProps, DrawerProvider, type DrawerSide, type DrawerSize, DrawerSwipeArea, type DrawerSwipeAreaProps, DrawerTitle, type DrawerTitleProps, DrawerTrigger, type DrawerTriggerProps, DrawerVirtualKeyboardProvider, Field, type FieldControlProps, FieldDescription, type FieldDescriptionProps, FieldError, type FieldErrorProps, FieldItem, type FieldItemProps, FieldLabel, type FieldLabelProps, type FieldLabelVariantsOptions, type FieldOrientation, type FieldProps, FieldValidity, type FieldValidityProps, Fieldset, FieldsetDescription, type FieldsetDescriptionProps, FieldsetLegend, type FieldsetLegendProps, type FieldsetLegendVariant, type FieldsetProps, Form, type FormProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonProps, type InputGroupProps, type InputProps, type InputSize, type InputVariantsOptions, Menu, type MenuAlign, MenuCheckboxItem, type MenuCheckboxItemProps, MenuGroup, MenuGroupLabel, type MenuGroupLabelProps, type MenuGroupProps, type MenuHandle, MenuItem, type MenuItemProps, type MenuItemVariant, type MenuItemVariantsOptions, MenuLinkItem, type MenuLinkItemProps, MenuPopup, type MenuPopupProps, type MenuProps, MenuRadioGroup, type MenuRadioGroupProps, MenuRadioItem, type MenuRadioItemProps, MenuSeparator, type MenuSeparatorProps, MenuShortcut, type MenuShortcutProps, type MenuSide, MenuSubmenuRoot, type MenuSubmenuRootProps, MenuSubmenuTrigger, type MenuSubmenuTriggerProps, MenuTrigger, type MenuTriggerProps, Meter, type MeterIndicatorVariantsOptions, type MeterProps, type MeterSize, type MeterTrackVariantsOptions, type MeterVariant, Popover, type PopoverAlign, PopoverClose, type PopoverCloseProps, PopoverDescription, type PopoverDescriptionProps, type PopoverHandle, PopoverPopup, type PopoverPopupProps, type PopoverPopupVariantsOptions, type PopoverProps, type PopoverSide, PopoverTitle, type PopoverTitleProps, PopoverTrigger, type PopoverTriggerProps, Progress, type ProgressIndicatorVariantsOptions, type ProgressProps, type ProgressSize, type ProgressTrackVariantsOptions, type ProgressVariant, Radio, RadioGroup, type RadioGroupProps, type RadioProps, type RadioSize, type RadioVariantsOptions, Select, type SelectAlign, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, type SelectGroupProps, SelectItem, type SelectItemProps, SelectLabel, type SelectLabelProps, SelectPopup, type SelectPopupProps, type SelectProps, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, type SelectTriggerSize, type SelectTriggerVariant, type SelectTriggerVariantsOptions, SelectValue, type SelectValueProps, Skeleton, type SkeletonAnimation, type SkeletonProps, type SkeletonRenderState, type SkeletonVariant, type SkeletonVariantsOptions, Stepper, StepperDescription, type StepperDescriptionProps, StepperIndicator, type StepperIndicatorProps, StepperItem, type StepperItemProps, type StepperOrientation, type StepperProps, StepperSeparator, type StepperSeparatorProps, type StepperSize, StepperTitle, type StepperTitleProps, StepperTrigger, type StepperTriggerProps, type StepperTriggerVariantsOptions, Switch, type SwitchLabelPosition, type SwitchProps, type SwitchSize, type SwitchVariantsOptions, SystemState, type SystemStateBackground, type SystemStateProps, type SystemStateRenderState, type SystemStateScope, type SystemStateTitleLevel, type SystemStateVariant, Table, TableBody, type TableBodyProps, TableCaption, type TableCaptionProps, type TableCaptionRenderState, type TableCaptionSide, TableCell, type TableCellProps, TableContainer, type TableContainerProps, type TableContainerRenderState, type TableContainerVariant, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, TableHeader, type TableHeaderProps, type TableLayout, type TableProps, type TableRenderState, TableRow, type TableRowProps, type TableRowRenderState, type TableSize, Tabs, type TabsIndicatorPosition, TabsList, type TabsListProps, type TabsListVariantsOptions, TabsPanel, type TabsPanelProps, type TabsProps, type TabsSize, TabsTab, type TabsTabProps, type TabsTabVariantsOptions, type TabsVariant, Timeline, TimelineConnector, type TimelineConnectorProps, TimelineContent, type TimelineContentProps, TimelineDescription, type TimelineDescriptionProps, TimelineIndicator, type TimelineIndicatorAppearance, type TimelineIndicatorProps, type TimelineIndicatorVariant, TimelineItem, type TimelineItemProps, type TimelineProps, TimelineSeparator, type TimelineSeparatorProps, type TimelineSeparatorVariant, type TimelineSize, TimelineTime, type TimelineTimeProps, TimelineTitle, type TimelineTitleProps, type ToastData, type ToastManager, type ToastObject, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastType, type ToastUpdateOptions, Toaster, type ToasterProps, Toggle, ToggleGroup, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, type TooltipAlign, type TooltipHandle, TooltipPopup, type TooltipPopupProps, type TooltipPopupVariantsOptions, type TooltipProps, TooltipProvider, type TooltipProviderProps, type TooltipSide, TooltipTrigger, type TooltipTriggerProps, Typography, type TypographyProps, type TypographyVariant, type TypographyVariantsOptions, alertDialogPopupVariants, alertVariants, avatarVariants, badgeVariants, boxVariants, breadcrumbLinkVariants, buttonVariants, checkboxVariants, cn, codeBlockVariants, comboboxInputGroupVariants, createAlertDialogHandle, createDrawerHandle, createMenuHandle, createPopoverHandle, createToastManager, createTooltipHandle, datePickerVariants, dateRangePickerVariants, dialogPopupVariants, dividerVariants, drawerPopupVariants, fieldLabelVariants, inputVariants, menuItemVariants, meterIndicatorVariants, meterTrackVariants, popoverPopupVariants, progressIndicatorVariants, progressTrackVariants, radioVariants, selectTriggerVariants, skeletonVariants, stepperTriggerVariants, switchVariants, tabsListVariants, tabsTabVariants, toast, toggleVariants, tooltipPopupVariants, typographyVariants, useComboboxFilter, useComboboxFilteredItems, useFieldControl };
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, Breadcr
|
|
|
11
11
|
import { Button, buttonVariants } from "./components/Button/Button.js";
|
|
12
12
|
import { Calendar } from "./components/Calendar/Calendar.js";
|
|
13
13
|
import { Checkbox, CheckboxGroup, checkboxVariants } from "./components/Checkbox/Checkbox.js";
|
|
14
|
+
import { CodeBlock, codeBlockVariants } from "./components/CodeBlock/CodeBlock.js";
|
|
14
15
|
import { useFieldControl } from "./components/Field/FieldContext.js";
|
|
15
16
|
import { Input, InputGroup, InputGroupAddon, inputVariants } from "./components/Input/Input.js";
|
|
16
17
|
import { Select, SelectGroup, SelectGroupLabel, SelectItem, SelectLabel, SelectPopup, SelectSeparator, SelectTrigger, SelectValue, selectTriggerVariants } from "./components/Select/Select.js";
|
|
@@ -39,4 +40,4 @@ import { Toaster, createToastManager, toast } from "./components/Toast/Toast.js"
|
|
|
39
40
|
import { Toggle, ToggleGroup, toggleVariants } from "./components/Toggle/Toggle.js";
|
|
40
41
|
import { Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger, createTooltipHandle, tooltipPopupVariants } from "./components/Tooltip/Tooltip.js";
|
|
41
42
|
import { Typography, typographyVariants } from "./components/Typography/Typography.js";
|
|
42
|
-
export { AILoader, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarImage, Badge, Box, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Checkbox, CheckboxGroup, Combobox, ComboboxChip, ComboboxChipRemove, ComboboxChips, ComboboxClear, ComboboxCollection, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxInputGroup, ComboboxItem, ComboboxLabel, ComboboxPopup, ComboboxSeparator, ComboboxTrigger, ComboboxValue, ContextMenu, ContextMenuCheckboxItem, ContextMenuGroup, ContextMenuGroupLabel, ContextMenuItem, ContextMenuLinkItem, ContextMenuPopup, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSubmenuRoot, ContextMenuSubmenuTrigger, ContextMenuTrigger, DatePicker, DateRangePicker, Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogTitle, DialogTrigger, Divider, Drawer, DrawerClose, DrawerDescription, DrawerFooter, DrawerHeader, DrawerIndent, DrawerIndentBackground, DrawerPopup, DrawerProvider, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerVirtualKeyboardProvider, Field, FieldDescription, FieldError, FieldItem, FieldLabel, FieldValidity, Fieldset, FieldsetDescription, FieldsetLegend, Form, Input, InputGroup, InputGroupAddon, Menu, MenuCheckboxItem, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSubmenuRoot, MenuSubmenuTrigger, MenuTrigger, Meter, Popover, PopoverClose, PopoverDescription, PopoverPopup, PopoverTitle, PopoverTrigger, Progress, Radio, RadioGroup, Select, SelectGroup, SelectGroupLabel, SelectItem, SelectLabel, SelectPopup, SelectSeparator, SelectTrigger, SelectValue, Skeleton, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, StepperTrigger, Switch, SystemState, Table, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Timeline, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle, Toaster, Toggle, ToggleGroup, Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger, Typography, alertDialogPopupVariants, alertVariants, avatarVariants, badgeVariants, boxVariants, breadcrumbLinkVariants, buttonVariants, checkboxVariants, cn, comboboxInputGroupVariants, createAlertDialogHandle, createDrawerHandle, createMenuHandle, createPopoverHandle, createToastManager, createTooltipHandle, datePickerVariants, dateRangePickerVariants, dialogPopupVariants, dividerVariants, drawerPopupVariants, fieldLabelVariants, inputVariants, menuItemVariants, meterIndicatorVariants, meterTrackVariants, popoverPopupVariants, progressIndicatorVariants, progressTrackVariants, radioVariants, selectTriggerVariants, skeletonVariants, stepperTriggerVariants, switchVariants, tabsListVariants, tabsTabVariants, toast, toggleVariants, tooltipPopupVariants, typographyVariants, useComboboxFilter, useComboboxFilteredItems, useFieldControl };
|
|
43
|
+
export { AILoader, Accordion, AccordionHeader, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogPopup, AlertDialogTitle, AlertDialogTrigger, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarImage, Badge, Box, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Checkbox, CheckboxGroup, CodeBlock, Combobox, ComboboxChip, ComboboxChipRemove, ComboboxChips, ComboboxClear, ComboboxCollection, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxInputGroup, ComboboxItem, ComboboxLabel, ComboboxPopup, ComboboxSeparator, ComboboxTrigger, ComboboxValue, ContextMenu, ContextMenuCheckboxItem, ContextMenuGroup, ContextMenuGroupLabel, ContextMenuItem, ContextMenuLinkItem, ContextMenuPopup, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSubmenuRoot, ContextMenuSubmenuTrigger, ContextMenuTrigger, DatePicker, DateRangePicker, Dialog, DialogClose, DialogDescription, DialogFooter, DialogHeader, DialogPopup, DialogTitle, DialogTrigger, Divider, Drawer, DrawerClose, DrawerDescription, DrawerFooter, DrawerHeader, DrawerIndent, DrawerIndentBackground, DrawerPopup, DrawerProvider, DrawerSwipeArea, DrawerTitle, DrawerTrigger, DrawerVirtualKeyboardProvider, Field, FieldDescription, FieldError, FieldItem, FieldLabel, FieldValidity, Fieldset, FieldsetDescription, FieldsetLegend, Form, Input, InputGroup, InputGroupAddon, Menu, MenuCheckboxItem, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSubmenuRoot, MenuSubmenuTrigger, MenuTrigger, Meter, Popover, PopoverClose, PopoverDescription, PopoverPopup, PopoverTitle, PopoverTrigger, Progress, Radio, RadioGroup, Select, SelectGroup, SelectGroupLabel, SelectItem, SelectLabel, SelectPopup, SelectSeparator, SelectTrigger, SelectValue, Skeleton, Stepper, StepperDescription, StepperIndicator, StepperItem, StepperSeparator, StepperTitle, StepperTrigger, Switch, SystemState, Table, TableBody, TableCaption, TableCell, TableContainer, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Timeline, TimelineConnector, TimelineContent, TimelineDescription, TimelineIndicator, TimelineItem, TimelineSeparator, TimelineTime, TimelineTitle, Toaster, Toggle, ToggleGroup, Tooltip, TooltipPopup, TooltipProvider, TooltipTrigger, Typography, alertDialogPopupVariants, alertVariants, avatarVariants, badgeVariants, boxVariants, breadcrumbLinkVariants, buttonVariants, checkboxVariants, cn, codeBlockVariants, comboboxInputGroupVariants, createAlertDialogHandle, createDrawerHandle, createMenuHandle, createPopoverHandle, createToastManager, createTooltipHandle, datePickerVariants, dateRangePickerVariants, dialogPopupVariants, dividerVariants, drawerPopupVariants, fieldLabelVariants, inputVariants, menuItemVariants, meterIndicatorVariants, meterTrackVariants, popoverPopupVariants, progressIndicatorVariants, progressTrackVariants, radioVariants, selectTriggerVariants, skeletonVariants, stepperTriggerVariants, switchVariants, tabsListVariants, tabsTabVariants, toast, toggleVariants, tooltipPopupVariants, typographyVariants, useComboboxFilter, useComboboxFilteredItems, useFieldControl };
|
package/dist/lib/cn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
|
-
import {
|
|
2
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
3
3
|
//#region src/lib/cn.ts
|
|
4
|
+
const twMerge = extendTailwindMerge({ extend: { classGroups: { "font-family": [{ font: ["code"] }] } } });
|
|
4
5
|
/** Merge class names with Tailwind-aware conflict resolution. */
|
|
5
6
|
function cn(...inputs) {
|
|
6
7
|
return twMerge(clsx(inputs));
|
package/package.json
CHANGED
package/src/styles/theme.css
CHANGED
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
* Typography
|
|
25
25
|
* Headline: Poppins ("friendly but geometric") · Body/UI: Inter
|
|
26
26
|
* Formal documents: Noto Serif · Thai pairing: Noto Sans Thai / Sarabun
|
|
27
|
-
* Note: the brand
|
|
28
|
-
*
|
|
27
|
+
* Note: the brand ships no general monospace family — Tailwind's `font-mono`
|
|
28
|
+
* token stays disabled, and code-adjacent UI (kbd chips, inline code) uses
|
|
29
|
+
* `font-sans`. The one exception is the Code Block primitive, whose source
|
|
30
|
+
* needs true column alignment: `--font-code` provides a SYSTEM monospace
|
|
31
|
+
* stack (no web font is downloaded) surfaced only as the `font-code` utility.
|
|
29
32
|
* ------------------------------------------------------------------- */
|
|
30
33
|
--font-sans: "Inter", "Sarabun", ui-sans-serif, system-ui, sans-serif;
|
|
31
34
|
--font-heading: "Poppins", "Noto Sans Thai", ui-sans-serif, system-ui, sans-serif;
|
|
32
35
|
--font-serif: "Noto Serif", Georgia, serif;
|
|
33
36
|
--font-mono: initial;
|
|
37
|
+
--font-code: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
|
|
34
38
|
|
|
35
39
|
/* ---------------------------------------------------------------------
|
|
36
40
|
* Radius
|
|
@@ -318,6 +322,23 @@
|
|
|
318
322
|
overlays fade the whole layer via opacity without restating the color. */
|
|
319
323
|
--color-overlay: color-mix(in oklab, var(--color-slate-950) 50%, transparent);
|
|
320
324
|
|
|
325
|
+
/* Code surfaces are always dark — the brand's Slate 900, independent of the
|
|
326
|
+
surrounding light UI (the conventional treatment for source listings).
|
|
327
|
+
The paired foreground is near-white and clears WCAG AA at body-size code. */
|
|
328
|
+
--color-code: var(--color-slate-900);
|
|
329
|
+
--color-code-foreground: var(--color-slate-100);
|
|
330
|
+
|
|
331
|
+
/* SQL syntax palette (Code Block's built-in highlighter). Each hue is a light
|
|
332
|
+
ramp step so it clears WCAG AA (>= 6.5:1) on the dark `code` surface;
|
|
333
|
+
identifiers keep `code-foreground`. Only SQL is highlighted in-house —
|
|
334
|
+
other languages render plain unless the consumer passes highlighted nodes. */
|
|
335
|
+
--color-code-keyword: var(--color-navy-300);
|
|
336
|
+
--color-code-function: var(--color-primary-300);
|
|
337
|
+
--color-code-string: var(--color-success-300);
|
|
338
|
+
--color-code-number: var(--color-warning-300);
|
|
339
|
+
--color-code-comment: var(--color-slate-400);
|
|
340
|
+
--color-code-punctuation: var(--color-slate-300);
|
|
341
|
+
|
|
321
342
|
--color-primary: var(--color-primary-600);
|
|
322
343
|
--color-primary-foreground: #ffffff;
|
|
323
344
|
|