@ctrl-ui/react 0.9.12 → 0.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -7
- package/dist/blocks/design-canvas.js +16 -10
- package/dist/knob-contracts/field-knobs.d.ts +1 -1
- package/dist/knob-contracts/field-knobs.js +1 -0
- package/dist/knob-contracts/gradient-editor-knobs.d.ts +1 -1
- package/dist/knob-contracts/gradient-editor-knobs.js +1 -4
- package/dist/knob-contracts/popup-knobs.d.ts +1 -1
- package/dist/knob-contracts/popup-knobs.js +2 -0
- package/dist/lib/phone-input-format.js +1 -1
- package/dist/styles/recipes/card.css +8 -0
- package/dist/styles/recipes/color-picker-values.css +4 -18
- package/dist/styles/recipes/color-picker.css +3 -4
- package/dist/styles/recipes/field-parts.css +8 -1
- package/dist/styles/recipes/gradient-editor.css +3 -47
- package/dist/styles/recipes/markdown.css +5 -1
- package/dist/styles/recipes/popup-lists.css +17 -0
- package/dist/styles/recipes/popup.css +3 -0
- package/dist/styles/theme.css +4 -0
- package/dist/ui/autocomplete.d.ts +3 -0
- package/dist/ui/autocomplete.js +17 -2
- package/dist/ui/chart-cartesian.d.ts +60 -57
- package/dist/ui/chart-cartesian.js +7 -7
- package/dist/ui/chart-colors.d.ts +4 -2
- package/dist/ui/chart-colors.js +6 -2
- package/dist/ui/chart-marks.d.ts +4 -4
- package/dist/ui/chart-marks.js +14 -5
- package/dist/ui/chart-series.d.ts +9 -6
- package/dist/ui/chart-series.js +3 -2
- package/dist/ui/color-picker-swatches.d.ts +4 -3
- package/dist/ui/color-picker-swatches.js +7 -8
- package/dist/ui/command.d.ts +12 -0
- package/dist/ui/command.js +31 -1
- package/dist/ui/field.js +1 -1
- package/dist/ui/gradient-editor.d.ts +3 -2
- package/dist/ui/gradient-editor.js +7 -8
- package/dist/ui/markdown-components.d.ts +27 -0
- package/dist/ui/markdown-components.js +57 -0
- package/dist/ui/markdown-elements.d.ts +6 -25
- package/dist/ui/markdown-elements.js +19 -53
- package/dist/ui/markdown.d.ts +2 -7
- package/dist/ui/markdown.js +3 -20
- package/dist/ui/phone-input.js +2 -2
- package/lint/biome-preset.json +8 -1
- package/lint/class-policy.mjs +50 -1
- package/lint/eslint-plugin.mjs +98 -49
- package/lint/grit-rules.mjs +131 -42
- package/lint/no-component-part-css.grit +16 -0
- package/lint/no-component-style-classes.grit +66 -36
- package/lint/no-component-style-props.grit +51 -0
- package/lint/no-raw-type-classes.grit +1 -1
- package/package.json +5 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
|
|
1
2
|
import { ColorPickerKnobStyle } from "../knob-contracts/color-picker-knobs.js";
|
|
2
3
|
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
3
4
|
//#region src/ui/color-picker-swatches.d.ts
|
|
@@ -12,12 +13,12 @@ export type ColorPickerSwatchProps = Omit<Omit<ComponentProps<"button">, "color"
|
|
|
12
13
|
} & {
|
|
13
14
|
color: string;
|
|
14
15
|
};
|
|
15
|
-
export type ColorPickerSwatchAddProps = Omit<
|
|
16
|
-
style?: CSSProperties &
|
|
16
|
+
export type ColorPickerSwatchAddProps = Omit<ComponentProps<"button">, "onClick" | "style"> & {
|
|
17
|
+
style?: CSSProperties & ButtonKnobStyle;
|
|
17
18
|
} & {
|
|
18
19
|
onAdd?: (value: string) => void;
|
|
19
20
|
};
|
|
20
21
|
export declare function ColorPickerSwatches({ colors, label, className, children, ...props }: ColorPickerSwatchesProps): import("react").JSX.Element;
|
|
21
22
|
export declare function ColorPickerSwatch({ color, className, "aria-label": ariaLabel, ...props }: ColorPickerSwatchProps): import("react").JSX.Element;
|
|
22
|
-
export declare function ColorPickerSwatchAdd({ onAdd,
|
|
23
|
+
export declare function ColorPickerSwatchAdd({ onAdd, children, ...props }: ColorPickerSwatchAddProps): import("react").JSX.Element;
|
|
23
24
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
3
4
|
import { formatColor, parseColor } from "../lib/color.js";
|
|
4
5
|
import { useColorPicker } from "./color-picker-context.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -57,17 +58,16 @@ function ColorPickerSwatch({ color, className, "aria-label": ariaLabel, ...props
|
|
|
57
58
|
})]
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
|
-
function ColorPickerSwatchAdd({ onAdd,
|
|
61
|
+
function ColorPickerSwatchAdd({ onAdd, children, ...props }) {
|
|
61
62
|
const { valueString, disabled } = useColorPicker();
|
|
62
|
-
return /* @__PURE__ */ jsx(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"data-
|
|
63
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
64
|
+
variant: "dashed",
|
|
65
|
+
size: "xs",
|
|
66
|
+
iconOnly: true,
|
|
67
|
+
"data-color-picker-swatch-add": "true",
|
|
67
68
|
"aria-label": "Add current color",
|
|
68
69
|
disabled,
|
|
69
70
|
onClick: () => onAdd?.(valueString),
|
|
70
|
-
className: cn("relative flex shrink-0 cursor-pointer items-center justify-center disabled:cursor-not-allowed", className),
|
|
71
71
|
...props,
|
|
72
72
|
children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
|
|
73
73
|
});
|
|
@@ -81,7 +81,6 @@ function sameColor(a, b) {
|
|
|
81
81
|
function PlusIcon() {
|
|
82
82
|
return /* @__PURE__ */ jsx("svg", {
|
|
83
83
|
viewBox: "0 0 16 16",
|
|
84
|
-
className: "size-3.5",
|
|
85
84
|
fill: "none",
|
|
86
85
|
stroke: "currentColor",
|
|
87
86
|
strokeWidth: "1.5",
|
package/dist/ui/command.d.ts
CHANGED
|
@@ -46,6 +46,18 @@ export type CommandItemProps = Omit<ComponentProps<typeof Command$1.Item>, "styl
|
|
|
46
46
|
style?: CSSProperties & PopupKnobStyle;
|
|
47
47
|
};
|
|
48
48
|
export declare function CommandItem({ className, disabled, onSelect, ...props }: CommandItemProps): import("react").JSX.Element;
|
|
49
|
+
export type CommandItemContentProps = Omit<ComponentProps<"div">, "style"> & {
|
|
50
|
+
style?: CSSProperties & PopupKnobStyle;
|
|
51
|
+
};
|
|
52
|
+
export declare function CommandItemContent({ className, ...props }: CommandItemContentProps): import("react").JSX.Element;
|
|
53
|
+
export type CommandItemTitleProps = Omit<ComponentProps<"span">, "style"> & {
|
|
54
|
+
style?: CSSProperties & PopupKnobStyle;
|
|
55
|
+
};
|
|
56
|
+
export declare function CommandItemTitle({ className, ...props }: CommandItemTitleProps): import("react").JSX.Element;
|
|
57
|
+
export type CommandItemDescriptionProps = Omit<ComponentProps<"span">, "style"> & {
|
|
58
|
+
style?: CSSProperties & PopupKnobStyle;
|
|
59
|
+
};
|
|
60
|
+
export declare function CommandItemDescription({ className, ...props }: CommandItemDescriptionProps): import("react").JSX.Element;
|
|
49
61
|
export type CommandShortcutProps = Omit<ComponentProps<"span">, "style"> & {
|
|
50
62
|
style?: CSSProperties & PopupKnobStyle;
|
|
51
63
|
};
|
package/dist/ui/command.js
CHANGED
|
@@ -225,6 +225,36 @@ function CommandItem({ className, disabled, onSelect, ...props }) {
|
|
|
225
225
|
onSelect: handleSelect
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
+
function CommandItemContent({ className, ...props }) {
|
|
229
|
+
return /* @__PURE__ */ jsx("div", {
|
|
230
|
+
"data-control-ui": "command",
|
|
231
|
+
"data-popup-kind": "command",
|
|
232
|
+
"data-control-family": "popup",
|
|
233
|
+
"data-slot": "item-content",
|
|
234
|
+
className: cn("flex min-w-0 flex-1 flex-col", className),
|
|
235
|
+
...props
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function CommandItemTitle({ className, ...props }) {
|
|
239
|
+
return /* @__PURE__ */ jsx("span", {
|
|
240
|
+
"data-control-ui": "command",
|
|
241
|
+
"data-popup-kind": "command",
|
|
242
|
+
"data-control-family": "popup",
|
|
243
|
+
"data-slot": "item-title",
|
|
244
|
+
className: cn("truncate", className),
|
|
245
|
+
...props
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function CommandItemDescription({ className, ...props }) {
|
|
249
|
+
return /* @__PURE__ */ jsx("span", {
|
|
250
|
+
"data-control-ui": "command",
|
|
251
|
+
"data-popup-kind": "command",
|
|
252
|
+
"data-control-family": "popup",
|
|
253
|
+
"data-slot": "item-description",
|
|
254
|
+
className: cn("truncate", className),
|
|
255
|
+
...props
|
|
256
|
+
});
|
|
257
|
+
}
|
|
228
258
|
function CommandShortcut({ className, ...props }) {
|
|
229
259
|
return /* @__PURE__ */ jsx("span", {
|
|
230
260
|
"data-control-ui": "command",
|
|
@@ -238,4 +268,4 @@ function CommandShortcut({ className, ...props }) {
|
|
|
238
268
|
});
|
|
239
269
|
}
|
|
240
270
|
//#endregion
|
|
241
|
-
export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
|
|
271
|
+
export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandItemContent, CommandItemDescription, CommandItemTitle, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
|
package/dist/ui/field.js
CHANGED
|
@@ -53,7 +53,7 @@ function FieldLabel({ className, variant = "default", ...props }) {
|
|
|
53
53
|
"data-slot": "label",
|
|
54
54
|
"data-variant": variant,
|
|
55
55
|
"data-focus-ring": variant === "card" ? "within" : void 0,
|
|
56
|
-
className: cn(variant === "card" && "flex w-full cursor-pointer items-start gap-3 has-[[data-disabled]]:cursor-not-allowed [&>[data-control-family=choice]]:mt-[calc((1lh_-_var(--spacing)*4)/2)]", className),
|
|
56
|
+
className: cn(variant === "card" && "flex w-full cursor-pointer items-start gap-3 self-stretch has-[[data-disabled]]:cursor-not-allowed [&>[data-control-family=choice]]:mt-[calc((1lh_-_var(--spacing)*4)/2)]", className),
|
|
57
57
|
...props
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
|
|
1
2
|
import { GradientEditorKnobStyle } from "../knob-contracts/gradient-editor-knobs.js";
|
|
2
3
|
import { GradientInterpolation, GradientStop, GradientType, GradientValue } from "../lib/gradient.js";
|
|
3
4
|
import { CSSProperties, ComponentProps, RefObject } from "react";
|
|
@@ -20,7 +21,7 @@ export type GradientEditorStopProps = Omit<ComponentProps<"button">, "style"> &
|
|
|
20
21
|
style?: CSSProperties & GradientEditorKnobStyle;
|
|
21
22
|
};
|
|
22
23
|
export type GradientEditorStopAddProps = Omit<ComponentProps<"button">, "onClick" | "style"> & {
|
|
23
|
-
style?: CSSProperties &
|
|
24
|
+
style?: CSSProperties & ButtonKnobStyle;
|
|
24
25
|
};
|
|
25
26
|
type GradientEditorContextValue = GradientValue & {
|
|
26
27
|
gradient: string;
|
|
@@ -42,6 +43,6 @@ export declare function GradientEditor({ value: controlledValue, defaultValue, o
|
|
|
42
43
|
export declare function GradientEditorPreview({ className, style, "aria-label": ariaLabel, ...props }: GradientEditorPreviewProps): import("react").JSX.Element;
|
|
43
44
|
export declare function GradientEditorTrack({ className, children, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: GradientEditorTrackProps): import("react").JSX.Element;
|
|
44
45
|
export declare function GradientEditorStop({ stop, className, style, onPointerDown, onKeyDown, onFocus, onDoubleClick, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }: GradientEditorStopProps): import("react").JSX.Element;
|
|
45
|
-
export declare function GradientEditorStopAdd({
|
|
46
|
+
export declare function GradientEditorStopAdd({ children, ...props }: GradientEditorStopAddProps): import("react").JSX.Element;
|
|
46
47
|
//#endregion
|
|
47
48
|
export type { GradientInterpolation, GradientStop, GradientType, GradientValue };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { Button } from "./button.js";
|
|
3
4
|
import { useColorArea } from "../hooks/use-color-area.js";
|
|
4
5
|
import { formatGradient, gradientColorAt } from "../lib/gradient.js";
|
|
5
6
|
import { createContext, useContext, useRef, useState } from "react";
|
|
@@ -244,20 +245,18 @@ function GradientEditorStop({ stop, className, style, onPointerDown, onKeyDown,
|
|
|
244
245
|
...props
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
|
-
function GradientEditorStopAdd({
|
|
248
|
+
function GradientEditorStopAdd({ children, ...props }) {
|
|
248
249
|
const { addStop } = useGradientEditor();
|
|
249
|
-
return /* @__PURE__ */ jsx(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
"data-
|
|
250
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
251
|
+
variant: "dashed",
|
|
252
|
+
size: "xs",
|
|
253
|
+
iconOnly: true,
|
|
254
|
+
"data-gradient-editor-stop-add": "true",
|
|
254
255
|
"aria-label": "Add gradient stop",
|
|
255
256
|
onClick: () => addStop(.5),
|
|
256
|
-
className: cn("flex shrink-0 cursor-pointer items-center justify-center", className),
|
|
257
257
|
...props,
|
|
258
258
|
children: children ?? /* @__PURE__ */ jsx("svg", {
|
|
259
259
|
viewBox: "0 0 16 16",
|
|
260
|
-
className: "size-3.5",
|
|
261
260
|
fill: "none",
|
|
262
261
|
stroke: "currentColor",
|
|
263
262
|
strokeWidth: "1.5",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MarkdownA, MarkdownBlockquote, MarkdownCodeProps, MarkdownEm, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl } from "./markdown-elements.js";
|
|
2
|
+
//#region src/ui/markdown-components.d.ts
|
|
3
|
+
export declare function MarkdownCode({ className, children, node: _node, ...props }: MarkdownCodeProps): import("react").JSX.Element;
|
|
4
|
+
export declare const markdownComponents: {
|
|
5
|
+
input: typeof MarkdownInput;
|
|
6
|
+
code: typeof MarkdownCode;
|
|
7
|
+
inlineCode: typeof MarkdownInlineCode;
|
|
8
|
+
h1: typeof MarkdownH1;
|
|
9
|
+
h2: typeof MarkdownH2;
|
|
10
|
+
h3: typeof MarkdownH3;
|
|
11
|
+
h4: typeof MarkdownH4;
|
|
12
|
+
h5: typeof MarkdownH5;
|
|
13
|
+
h6: typeof MarkdownH6;
|
|
14
|
+
p: typeof MarkdownP;
|
|
15
|
+
ul: typeof MarkdownUl;
|
|
16
|
+
ol: typeof MarkdownOl;
|
|
17
|
+
li: typeof MarkdownLi;
|
|
18
|
+
a: typeof MarkdownA;
|
|
19
|
+
blockquote: typeof MarkdownBlockquote;
|
|
20
|
+
hr: typeof MarkdownHr;
|
|
21
|
+
strong: typeof MarkdownStrong;
|
|
22
|
+
em: typeof MarkdownEm;
|
|
23
|
+
table: typeof MarkdownTable;
|
|
24
|
+
th: typeof MarkdownTh;
|
|
25
|
+
td: typeof MarkdownTd;
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Code, CodeActions, CodeContent, CodeCopy, CodeHeader, CodeTitle } from "./code.js";
|
|
3
|
+
import { CodeDiff } from "./code-diff.js";
|
|
4
|
+
import { MarkdownA, MarkdownBlockquote, MarkdownEm, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl } from "./markdown-elements.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/ui/markdown-components.tsx
|
|
7
|
+
function textValue(children) {
|
|
8
|
+
return Array.isArray(children) ? children.join("") : String(children ?? "");
|
|
9
|
+
}
|
|
10
|
+
function languageFromClassName(className) {
|
|
11
|
+
return /language-([\w-]+)/.exec(className ?? "")?.[1];
|
|
12
|
+
}
|
|
13
|
+
function MarkdownCode({ className, children, node: _node, ...props }) {
|
|
14
|
+
const lang = languageFromClassName(className);
|
|
15
|
+
const rawValue = textValue(children);
|
|
16
|
+
if (!lang && !rawValue.includes("\n")) return /* @__PURE__ */ jsx(MarkdownInlineCode, {
|
|
17
|
+
className,
|
|
18
|
+
...props,
|
|
19
|
+
children
|
|
20
|
+
});
|
|
21
|
+
const value = rawValue.replace(/^\n/, "").replace(/\n$/, "");
|
|
22
|
+
if (lang === "diff" && value.includes("@@")) return /* @__PURE__ */ jsx(CodeDiff, {
|
|
23
|
+
patch: value,
|
|
24
|
+
lang: "diff",
|
|
25
|
+
diffStyle: "unified"
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsxs(Code, { children: [/* @__PURE__ */ jsxs(CodeHeader, { children: [lang ? /* @__PURE__ */ jsx(CodeTitle, { children: lang }) : null, /* @__PURE__ */ jsx(CodeActions, { children: /* @__PURE__ */ jsx(CodeCopy, { value }) })] }), /* @__PURE__ */ jsx(CodeContent, {
|
|
28
|
+
code: value,
|
|
29
|
+
lang,
|
|
30
|
+
highlight: lang ? "auto" : "none"
|
|
31
|
+
})] });
|
|
32
|
+
}
|
|
33
|
+
const markdownComponents = {
|
|
34
|
+
input: MarkdownInput,
|
|
35
|
+
code: MarkdownCode,
|
|
36
|
+
inlineCode: MarkdownInlineCode,
|
|
37
|
+
h1: MarkdownH1,
|
|
38
|
+
h2: MarkdownH2,
|
|
39
|
+
h3: MarkdownH3,
|
|
40
|
+
h4: MarkdownH4,
|
|
41
|
+
h5: MarkdownH5,
|
|
42
|
+
h6: MarkdownH6,
|
|
43
|
+
p: MarkdownP,
|
|
44
|
+
ul: MarkdownUl,
|
|
45
|
+
ol: MarkdownOl,
|
|
46
|
+
li: MarkdownLi,
|
|
47
|
+
a: MarkdownA,
|
|
48
|
+
blockquote: MarkdownBlockquote,
|
|
49
|
+
hr: MarkdownHr,
|
|
50
|
+
strong: MarkdownStrong,
|
|
51
|
+
em: MarkdownEm,
|
|
52
|
+
table: MarkdownTable,
|
|
53
|
+
th: MarkdownTh,
|
|
54
|
+
td: MarkdownTd
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { MarkdownCode, markdownComponents };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarkdownKnobStyle } from "../knob-contracts/markdown-knobs.js";
|
|
2
2
|
import { CSSProperties, ComponentProps, JSX } from "react";
|
|
3
3
|
//#region src/ui/markdown-elements.d.ts
|
|
4
|
-
type MarkdownCodeProps = ComponentProps<"code"> & {
|
|
4
|
+
export type MarkdownCodeProps = ComponentProps<"code"> & {
|
|
5
5
|
node?: unknown;
|
|
6
6
|
} & {
|
|
7
7
|
style?: CSSProperties & MarkdownKnobStyle;
|
|
@@ -11,10 +11,14 @@ type MarkdownElementProps<Tag extends keyof JSX.IntrinsicElements> = ComponentPr
|
|
|
11
11
|
} & {
|
|
12
12
|
style?: CSSProperties & MarkdownKnobStyle;
|
|
13
13
|
};
|
|
14
|
+
export type MarkdownRootProps = Omit<ComponentProps<"div">, "style"> & {
|
|
15
|
+
style?: CSSProperties & MarkdownKnobStyle;
|
|
16
|
+
};
|
|
17
|
+
export declare function MarkdownRoot({ className, ...props }: MarkdownRootProps): JSX.Element;
|
|
18
|
+
export declare function MarkdownFlow(props: MarkdownRootProps): JSX.Element;
|
|
14
19
|
export declare function MarkdownInput({ type, checked, className, node: _node, ...props }: MarkdownElementProps<"input">): JSX.Element;
|
|
15
20
|
export declare function MarkdownInlineCode({ className, children, node: _node, ...props }: MarkdownCodeProps): JSX.Element;
|
|
16
21
|
export declare function MarkdownPre({ children, node: _node }: MarkdownElementProps<"pre">): JSX.Element;
|
|
17
|
-
export declare function MarkdownCode({ className, children, node: _node, ...props }: MarkdownCodeProps): JSX.Element;
|
|
18
22
|
export declare function MarkdownH1({ className, node: _node, ...props }: MarkdownElementProps<"h1">): JSX.Element;
|
|
19
23
|
export declare function MarkdownH2({ className, node: _node, ...props }: MarkdownElementProps<"h2">): JSX.Element;
|
|
20
24
|
export declare function MarkdownH3({ className, node: _node, ...props }: MarkdownElementProps<"h3">): JSX.Element;
|
|
@@ -33,27 +37,4 @@ export declare function MarkdownEm({ className, node: _node, ...props }: Markdow
|
|
|
33
37
|
export declare function MarkdownTable({ className, children, node: _node, ...props }: MarkdownElementProps<"table">): JSX.Element;
|
|
34
38
|
export declare function MarkdownTh({ className, node: _node, ...props }: MarkdownElementProps<"th">): JSX.Element;
|
|
35
39
|
export declare function MarkdownTd({ className, node: _node, ...props }: MarkdownElementProps<"td">): JSX.Element;
|
|
36
|
-
export declare const markdownComponents: {
|
|
37
|
-
input: typeof MarkdownInput;
|
|
38
|
-
code: typeof MarkdownCode;
|
|
39
|
-
inlineCode: typeof MarkdownInlineCode;
|
|
40
|
-
h1: typeof MarkdownH1;
|
|
41
|
-
h2: typeof MarkdownH2;
|
|
42
|
-
h3: typeof MarkdownH3;
|
|
43
|
-
h4: typeof MarkdownH4;
|
|
44
|
-
h5: typeof MarkdownH5;
|
|
45
|
-
h6: typeof MarkdownH6;
|
|
46
|
-
p: typeof MarkdownP;
|
|
47
|
-
ul: typeof MarkdownUl;
|
|
48
|
-
ol: typeof MarkdownOl;
|
|
49
|
-
li: typeof MarkdownLi;
|
|
50
|
-
a: typeof MarkdownA;
|
|
51
|
-
blockquote: typeof MarkdownBlockquote;
|
|
52
|
-
hr: typeof MarkdownHr;
|
|
53
|
-
strong: typeof MarkdownStrong;
|
|
54
|
-
em: typeof MarkdownEm;
|
|
55
|
-
table: typeof MarkdownTable;
|
|
56
|
-
th: typeof MarkdownTh;
|
|
57
|
-
td: typeof MarkdownTd;
|
|
58
|
-
};
|
|
59
40
|
//#endregion
|
|
@@ -2,13 +2,28 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { ScrollArea } from "./scroll-area.js";
|
|
4
4
|
import { Heading } from "./typography.js";
|
|
5
|
-
import { Code, CodeActions, CodeContent, CodeCopy, CodeHeader, CodeTitle } from "./code.js";
|
|
6
5
|
import { Checkbox } from "./checkbox.js";
|
|
7
|
-
import { CodeDiff } from "./code-diff.js";
|
|
8
6
|
import { markdownHeadingAttributes } from "./markdown-heading.js";
|
|
9
7
|
import { createContext, use, useId } from "react";
|
|
10
|
-
import { Fragment as Fragment$1, jsx
|
|
8
|
+
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
11
9
|
//#region src/ui/markdown-elements.tsx
|
|
10
|
+
function MarkdownRoot({ className, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsx("div", {
|
|
12
|
+
"data-control-ui": "markdown",
|
|
13
|
+
"data-control-family": "markdown",
|
|
14
|
+
"data-slot": "root",
|
|
15
|
+
className: cn("[&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className),
|
|
16
|
+
...props
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function MarkdownFlow(props) {
|
|
20
|
+
return /* @__PURE__ */ jsx("div", {
|
|
21
|
+
"data-control-ui": "markdown",
|
|
22
|
+
"data-control-family": "markdown",
|
|
23
|
+
"data-slot": "flow",
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
}
|
|
12
27
|
const MarkdownTaskLabelContext = createContext(void 0);
|
|
13
28
|
function MarkdownInput({ type, checked, className, node: _node, ...props }) {
|
|
14
29
|
const labelId = use(MarkdownTaskLabelContext);
|
|
@@ -26,12 +41,6 @@ function MarkdownInput({ type, checked, className, node: _node, ...props }) {
|
|
|
26
41
|
"aria-labelledby": labelId
|
|
27
42
|
});
|
|
28
43
|
}
|
|
29
|
-
function textValue(children) {
|
|
30
|
-
return Array.isArray(children) ? children.join("") : String(children ?? "");
|
|
31
|
-
}
|
|
32
|
-
function languageFromClassName(className) {
|
|
33
|
-
return /language-([\w-]+)/.exec(className ?? "")?.[1];
|
|
34
|
-
}
|
|
35
44
|
function MarkdownInlineCode({ className, children, node: _node, ...props }) {
|
|
36
45
|
return /* @__PURE__ */ jsx("code", {
|
|
37
46
|
"data-control-ui": "markdown",
|
|
@@ -45,26 +54,6 @@ function MarkdownInlineCode({ className, children, node: _node, ...props }) {
|
|
|
45
54
|
function MarkdownPre({ children, node: _node }) {
|
|
46
55
|
return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
47
56
|
}
|
|
48
|
-
function MarkdownCode({ className, children, node: _node, ...props }) {
|
|
49
|
-
const lang = languageFromClassName(className);
|
|
50
|
-
const rawValue = textValue(children);
|
|
51
|
-
if (!lang && !rawValue.includes("\n")) return /* @__PURE__ */ jsx(MarkdownInlineCode, {
|
|
52
|
-
className,
|
|
53
|
-
...props,
|
|
54
|
-
children
|
|
55
|
-
});
|
|
56
|
-
const value = rawValue.replace(/^\n/, "").replace(/\n$/, "");
|
|
57
|
-
if (lang === "diff" && value.includes("@@")) return /* @__PURE__ */ jsx(CodeDiff, {
|
|
58
|
-
patch: value,
|
|
59
|
-
lang: "diff",
|
|
60
|
-
diffStyle: "unified"
|
|
61
|
-
});
|
|
62
|
-
return /* @__PURE__ */ jsxs(Code, { children: [/* @__PURE__ */ jsxs(CodeHeader, { children: [lang ? /* @__PURE__ */ jsx(CodeTitle, { children: lang }) : null, /* @__PURE__ */ jsx(CodeActions, { children: /* @__PURE__ */ jsx(CodeCopy, { value }) })] }), /* @__PURE__ */ jsx(CodeContent, {
|
|
63
|
-
code: value,
|
|
64
|
-
lang,
|
|
65
|
-
highlight: lang ? "auto" : "none"
|
|
66
|
-
})] });
|
|
67
|
-
}
|
|
68
57
|
function MarkdownH1({ className, node: _node, ...props }) {
|
|
69
58
|
const { class: headingClass } = markdownHeadingAttributes(1);
|
|
70
59
|
return /* @__PURE__ */ jsx(Heading, {
|
|
@@ -253,28 +242,5 @@ function MarkdownTd({ className, node: _node, ...props }) {
|
|
|
253
242
|
...props
|
|
254
243
|
});
|
|
255
244
|
}
|
|
256
|
-
const markdownComponents = {
|
|
257
|
-
input: MarkdownInput,
|
|
258
|
-
code: MarkdownCode,
|
|
259
|
-
inlineCode: MarkdownInlineCode,
|
|
260
|
-
h1: MarkdownH1,
|
|
261
|
-
h2: MarkdownH2,
|
|
262
|
-
h3: MarkdownH3,
|
|
263
|
-
h4: MarkdownH4,
|
|
264
|
-
h5: MarkdownH5,
|
|
265
|
-
h6: MarkdownH6,
|
|
266
|
-
p: MarkdownP,
|
|
267
|
-
ul: MarkdownUl,
|
|
268
|
-
ol: MarkdownOl,
|
|
269
|
-
li: MarkdownLi,
|
|
270
|
-
a: MarkdownA,
|
|
271
|
-
blockquote: MarkdownBlockquote,
|
|
272
|
-
hr: MarkdownHr,
|
|
273
|
-
strong: MarkdownStrong,
|
|
274
|
-
em: MarkdownEm,
|
|
275
|
-
table: MarkdownTable,
|
|
276
|
-
th: MarkdownTh,
|
|
277
|
-
td: MarkdownTd
|
|
278
|
-
};
|
|
279
245
|
//#endregion
|
|
280
|
-
export { MarkdownA, MarkdownBlockquote,
|
|
246
|
+
export { MarkdownA, MarkdownBlockquote, MarkdownEm, MarkdownFlow, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownPre, MarkdownRoot, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl };
|
package/dist/ui/markdown.d.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { MarkdownRootProps } from "./markdown-elements.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
3
|
//#region src/ui/markdown.d.ts
|
|
4
|
-
export type MarkdownRootProps = Omit<ComponentProps<"div">, "style"> & {
|
|
5
|
-
style?: CSSProperties & MarkdownKnobStyle;
|
|
6
|
-
};
|
|
7
4
|
export type MarkdownProps = Omit<MarkdownRootProps, "children"> & {
|
|
8
5
|
content: string;
|
|
9
6
|
mode?: "streaming" | "static";
|
|
10
7
|
};
|
|
11
|
-
export declare function MarkdownRoot({ className, ...props }: MarkdownRootProps): import("react").JSX.Element;
|
|
12
|
-
export declare function MarkdownFlow(props: MarkdownRootProps): import("react").JSX.Element;
|
|
13
8
|
export declare function Markdown({ content, mode, className, ...props }: MarkdownProps): import("react").JSX.Element;
|
|
14
9
|
export type MarkdownComponentProps = ComponentProps<typeof Markdown>;
|
|
15
10
|
//#endregion
|
package/dist/ui/markdown.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { markdownComponents } from "./markdown-
|
|
2
|
+
import { MarkdownFlow, MarkdownRoot } from "./markdown-elements.js";
|
|
3
|
+
import { markdownComponents } from "./markdown-components.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Streamdown } from "streamdown";
|
|
6
6
|
//#region src/ui/markdown.tsx
|
|
7
|
-
function MarkdownRoot({ className, ...props }) {
|
|
8
|
-
return /* @__PURE__ */ jsx("div", {
|
|
9
|
-
"data-control-ui": "markdown",
|
|
10
|
-
"data-control-family": "markdown",
|
|
11
|
-
"data-slot": "root",
|
|
12
|
-
className: cn("[&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className),
|
|
13
|
-
...props
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
function MarkdownFlow(props) {
|
|
17
|
-
return /* @__PURE__ */ jsx("div", {
|
|
18
|
-
"data-control-ui": "markdown",
|
|
19
|
-
"data-control-family": "markdown",
|
|
20
|
-
"data-slot": "flow",
|
|
21
|
-
...props
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
7
|
function Markdown({ content, mode = "streaming", className, ...props }) {
|
|
25
8
|
return /* @__PURE__ */ jsx(MarkdownRoot, {
|
|
26
9
|
className,
|
|
@@ -36,4 +19,4 @@ function Markdown({ content, mode = "streaming", className, ...props }) {
|
|
|
36
19
|
});
|
|
37
20
|
}
|
|
38
21
|
//#endregion
|
|
39
|
-
export { Markdown
|
|
22
|
+
export { Markdown };
|
package/dist/ui/phone-input.js
CHANGED
|
@@ -3,12 +3,12 @@ import { cn } from "../lib/cn.js";
|
|
|
3
3
|
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
4
4
|
import { InputGroup, InputGroupAddon } from "./input-group.js";
|
|
5
5
|
import { Input } from "./input.js";
|
|
6
|
-
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
7
6
|
import { normalizePhoneInputText, normalizePhoneInputValue } from "../lib/phone-input-format.js";
|
|
7
|
+
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import flags from "react-phone-number-input/flags";
|
|
11
10
|
import PhoneNumberInput, { getCountryCallingCode, parsePhoneNumber } from "react-phone-number-input/max";
|
|
11
|
+
import flags from "react-phone-number-input/flags";
|
|
12
12
|
//#region src/ui/phone-input.tsx
|
|
13
13
|
const FLAG_COMPONENTS = flags;
|
|
14
14
|
const PhoneNumberInputWithRef = PhoneNumberInput;
|
package/lint/biome-preset.json
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"plugins": [
|
|
2
|
+
"plugins": [
|
|
3
|
+
"./node_modules/@ctrl-ui/react/lint/no-component-style-classes.grit",
|
|
4
|
+
"./node_modules/@ctrl-ui/react/lint/no-component-style-props.grit",
|
|
5
|
+
{
|
|
6
|
+
"path": "./node_modules/@ctrl-ui/react/lint/no-component-part-css.grit",
|
|
7
|
+
"includes": ["**/*.css", "!**/components/control-ui/**"]
|
|
8
|
+
}
|
|
9
|
+
]
|
|
3
10
|
}
|
package/lint/class-policy.mjs
CHANGED
|
@@ -36,7 +36,47 @@ const textLayoutSuffixes = [
|
|
|
36
36
|
"clip",
|
|
37
37
|
];
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const paintProperties = [
|
|
40
|
+
"padding",
|
|
41
|
+
"background",
|
|
42
|
+
"color",
|
|
43
|
+
"font",
|
|
44
|
+
"line-height",
|
|
45
|
+
"letter-spacing",
|
|
46
|
+
"border",
|
|
47
|
+
"outline",
|
|
48
|
+
"box-shadow",
|
|
49
|
+
"text-shadow",
|
|
50
|
+
"text-decoration",
|
|
51
|
+
"text-underline",
|
|
52
|
+
"text-transform",
|
|
53
|
+
"opacity",
|
|
54
|
+
"filter",
|
|
55
|
+
"backdrop-filter",
|
|
56
|
+
"fill",
|
|
57
|
+
"stroke",
|
|
58
|
+
"caret-color",
|
|
59
|
+
"accent-color",
|
|
60
|
+
"mask",
|
|
61
|
+
"-webkit-mask",
|
|
62
|
+
"-webkit-font-smoothing",
|
|
63
|
+
"-moz-osx-font-smoothing",
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const camelCase = (property) =>
|
|
67
|
+
property.replace(/^-(\w)/, (_, first) => first.toUpperCase()).replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
|
|
68
|
+
|
|
69
|
+
export const paintProperty = String.raw`(?:${paintProperties.join("|")})(?:-[\w-]*)?`;
|
|
70
|
+
|
|
71
|
+
export const componentStyleKey = String.raw`["']?(?:(?:${paintProperties.map(camelCase).join("|")})(?:[A-Z]\w*)?|${paintProperty})["']?`;
|
|
72
|
+
|
|
73
|
+
const partAttribute = String.raw`data-(?:control|slot)\b`;
|
|
74
|
+
|
|
75
|
+
export const componentPartClass = String.raw`\[&[^${classDelimiter}]*?${partAttribute}|(?:^|[${classDelimiter}:])\*{1,2}:data-\[(?:control|slot)\b`;
|
|
76
|
+
|
|
77
|
+
export const componentPartSelector = String.raw`(?s).*\[${partAttribute}[^\s>+~]*\s*`;
|
|
78
|
+
|
|
79
|
+
export const componentStyleClass = String.raw`[^${classDelimiter}]!${classEnd}|(?:^|[${classDelimiter}])![\w\[-]|(?:^|[^\w-])(?:p[xytrblse]?-|bg-[\w\[]|text-${classSuffixOtherThan(textLayoutSuffixes)}|font-|leading-|tracking-|border|divide-|rounded|shadow|inset-shadow|drop-shadow|ring\b|ring-|inset-ring|outline|opacity-|backdrop-|fill-|stroke-|caret-|accent-|scheme-|mask-|decoration-|underline|no-underline|overline|line-through|italic|not-italic|uppercase|lowercase|capitalize|normal-case|antialiased|subpixel-antialiased|ordinal|slashed-zero|(?:normal|lining|oldstyle|proportional|tabular)-nums|(?:diagonal|stacked)-fractions|blur(?:-|${classEnd})|brightness-|contrast-[\d\[]|grayscale|hue-rotate-|invert|saturate-|sepia|(?:hover|focus|focus-visible|focus-within|active|disabled|enabled|open|checked|indeterminate|visited|target|invalid|valid|user-invalid|user-valid|required|optional|read-only|autofill|placeholder-shown|in-range|out-of-range|inert|starting|dark|placeholder|selection|marker|file|first-letter|first-line|backdrop|details-content|aria-[^:\s]*|data-[^:\s]*|group-[^:\s]*|peer-[^:\s]*|has-[^:\s]*|\*|\[&[^\s]*?\]):)|(?:^|[^\w-])\[${paintProperty}:`;
|
|
40
80
|
|
|
41
81
|
export const rawTypeClass = String.raw`(?:^|[^\w-])text-(?:micro|caption|label|body|body-lg|heading-[1-4]|display|xs|sm|base|lg|xl|[2-9]xl)\b|(?:^|[^\w-])text-\[\d[^\]]*\]`;
|
|
42
82
|
|
|
@@ -45,3 +85,12 @@ export const componentStyleMessage =
|
|
|
45
85
|
|
|
46
86
|
export const rawTypeMessage =
|
|
47
87
|
"Text size in className: render text through <Text>/<Heading> on the type scale, or size the control with its size prop or --cui-*-font-size knob.";
|
|
88
|
+
|
|
89
|
+
export const componentPartMessage =
|
|
90
|
+
"className styles a Control UI component's parts from outside through a data-slot or data-control selector. The component owns its parts: use its props, compose its parts, or set a --cui-* knob on it.";
|
|
91
|
+
|
|
92
|
+
export const componentStylePropMessage =
|
|
93
|
+
"Control UI component painted through style: color, type, padding, borders, radius, shadows and opacity belong to the component. Set a --cui-* knob in style or use its props; keep other style keys for layout.";
|
|
94
|
+
|
|
95
|
+
export const componentPartCssMessage =
|
|
96
|
+
"Stylesheet paints a Control UI part: color, type, padding, borders, radius, shadows and opacity belong to the component recipe. Set the part's --cui-* knobs here instead, or use the component's props.";
|