@choice-ui/react 1.9.6 → 1.9.8
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/button/dist/index.d.ts +9 -2
- package/dist/components/button/dist/index.js +19 -45
- package/dist/components/checkbox/dist/index.d.ts +1 -10
- package/dist/components/checkbox/dist/index.js +5 -49
- package/dist/components/code-block/dist/index.d.ts +14 -11
- package/dist/components/code-block/dist/index.js +93 -120
- package/dist/components/colors/dist/index.d.ts +6 -39
- package/dist/components/colors/src/color-image-paint/color-image-paint.js +2 -2
- package/dist/components/dropdown/dist/index.d.ts +0 -6
- package/dist/components/dropdown/dist/index.js +10 -20
- package/dist/components/emoji-picker/dist/index.d.ts +1 -30
- package/dist/components/emoji-picker/dist/index.js +44 -148
- package/dist/components/form/src/adapters/range-adapter.js +2 -2
- package/dist/components/icon-button/dist/index.d.ts +1 -1
- package/dist/components/icon-button/dist/index.js +0 -39
- package/dist/components/list/dist/index.d.ts +1 -1
- package/dist/components/md-render/dist/index.d.ts +1 -2
- package/dist/components/md-render/dist/index.js +9 -5
- package/dist/components/menus/dist/index.d.ts +0 -5
- package/dist/components/menus/dist/index.js +3 -32
- package/dist/components/modal/dist/index.js +2 -2
- package/dist/components/notifications/dist/index.d.ts +5 -1
- package/dist/components/numeric-input/dist/index.d.ts +10 -25
- package/dist/components/numeric-input/dist/index.js +10 -68
- package/dist/components/numeric-input/src/context/numeric-input-context.d.ts +1 -0
- package/dist/components/numeric-input/src/hooks/use-input-interactions.d.ts +3 -1
- package/dist/components/numeric-input/src/hooks/use-numeric-input.d.ts +1 -0
- package/dist/components/numeric-input/src/hooks/use-numeric-input.js +36 -13
- package/dist/components/numeric-input/src/numeric-input.d.ts +1 -0
- package/dist/components/numeric-input/src/numeric-input.js +4 -0
- package/dist/components/panel/dist/index.d.ts +16 -16
- package/dist/components/picture-preview/dist/index.d.ts +0 -5
- package/dist/components/picture-preview/dist/index.js +140 -287
- package/dist/components/popover/dist/index.d.ts +0 -5
- package/dist/components/popover/dist/index.js +2 -21
- package/dist/components/radio/dist/index.d.ts +1 -9
- package/dist/components/radio/dist/index.js +6 -50
- package/dist/components/range/dist/index.d.ts +20 -276
- package/dist/components/range/dist/index.js +616 -1044
- package/dist/components/scroll-area/dist/index.d.ts +27 -4
- package/dist/components/scroll-area/dist/index.js +123 -96
- package/dist/components/separator/dist/index.d.ts +8 -1
- package/dist/components/splitter/dist/index.d.ts +1 -1
- package/dist/components/text-field/dist/index.d.ts +3 -2
- package/dist/components/text-field/dist/index.js +19 -4
- package/dist/components/textarea/dist/index.js +1 -3
- package/dist/components/tooltip/dist/index.d.ts +0 -2
- package/dist/components/tooltip/dist/index.js +5 -23
- package/package.json +1 -1
- package/dist/components/toast/dist/index.d.ts +0 -274
- package/dist/components/virtual-select/dist/index.d.ts +0 -48
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { memo, useState, useEffect
|
|
1
|
+
import React__default, { memo, useState, useEffect } from "react";
|
|
2
2
|
import { useStickToBottom } from "use-stick-to-bottom";
|
|
3
3
|
import { codeToHtml } from "shiki";
|
|
4
4
|
import { useEventCallback } from "usehooks-ts";
|
|
@@ -34,34 +34,13 @@ function useCodeBlock({
|
|
|
34
34
|
if (!code || typeof code !== "string") {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const onSuccess = () => {
|
|
38
|
-
setCopied(true);
|
|
39
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
40
|
-
};
|
|
41
|
-
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
42
|
-
try {
|
|
43
|
-
await navigator.clipboard.writeText(code);
|
|
44
|
-
onSuccess();
|
|
45
|
-
return;
|
|
46
|
-
} catch {
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const textArea = document.createElement("textarea");
|
|
50
37
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
textArea.select();
|
|
56
|
-
const successful = document.execCommand("copy");
|
|
57
|
-
if (successful) {
|
|
58
|
-
onSuccess();
|
|
59
|
-
}
|
|
60
|
-
} catch {
|
|
61
|
-
} finally {
|
|
62
|
-
if (textArea.parentNode) {
|
|
63
|
-
textArea.parentNode.removeChild(textArea);
|
|
38
|
+
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
39
|
+
await navigator.clipboard.writeText(code);
|
|
40
|
+
setCopied(true);
|
|
41
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
64
42
|
}
|
|
43
|
+
} catch (error) {
|
|
65
44
|
}
|
|
66
45
|
});
|
|
67
46
|
return {
|
|
@@ -77,15 +56,12 @@ function useScrollDetection({
|
|
|
77
56
|
scrollRef,
|
|
78
57
|
contentRef,
|
|
79
58
|
isExpanded,
|
|
80
|
-
codeExpanded
|
|
59
|
+
codeExpanded,
|
|
60
|
+
children
|
|
81
61
|
}) {
|
|
82
62
|
const [needsScroll, setNeedsScroll] = useState(false);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (debounceRef.current) {
|
|
86
|
-
clearTimeout(debounceRef.current);
|
|
87
|
-
}
|
|
88
|
-
debounceRef.current = setTimeout(() => {
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const checkScrollNeeded = () => {
|
|
89
65
|
if (!scrollRef.current || !contentRef.current) {
|
|
90
66
|
setNeedsScroll(false);
|
|
91
67
|
return;
|
|
@@ -95,30 +71,50 @@ function useScrollDetection({
|
|
|
95
71
|
const content = contentRef.current;
|
|
96
72
|
const hasScroll = content.scrollHeight > viewport.clientHeight;
|
|
97
73
|
setNeedsScroll(hasScroll);
|
|
98
|
-
} catch {
|
|
74
|
+
} catch (error) {
|
|
99
75
|
setNeedsScroll(false);
|
|
100
76
|
}
|
|
101
|
-
}
|
|
102
|
-
}, [scrollRef, contentRef]);
|
|
103
|
-
useEffect(() => {
|
|
77
|
+
};
|
|
104
78
|
const timeoutId = setTimeout(checkScrollNeeded, 100);
|
|
105
79
|
window.addEventListener("resize", checkScrollNeeded);
|
|
106
80
|
let resizeObserver = null;
|
|
107
|
-
if (typeof ResizeObserver !== "undefined"
|
|
81
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
108
82
|
resizeObserver = new ResizeObserver(checkScrollNeeded);
|
|
109
|
-
|
|
83
|
+
if (contentRef.current) {
|
|
84
|
+
resizeObserver.observe(contentRef.current);
|
|
85
|
+
}
|
|
110
86
|
}
|
|
111
87
|
return () => {
|
|
112
88
|
clearTimeout(timeoutId);
|
|
113
|
-
if (debounceRef.current) {
|
|
114
|
-
clearTimeout(debounceRef.current);
|
|
115
|
-
}
|
|
116
89
|
window.removeEventListener("resize", checkScrollNeeded);
|
|
117
90
|
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
118
91
|
};
|
|
119
|
-
}, [
|
|
92
|
+
}, [scrollRef, contentRef, isExpanded, codeExpanded, children]);
|
|
120
93
|
return needsScroll;
|
|
121
94
|
}
|
|
95
|
+
function useLineCount(children) {
|
|
96
|
+
const [lineCount, setLineCount] = useState(0);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
try {
|
|
99
|
+
const codeContent = React__default.Children.toArray(children).map((child) => {
|
|
100
|
+
var _a;
|
|
101
|
+
if (React__default.isValidElement(child) && ((_a = child.props) == null ? void 0 : _a.code) && typeof child.props.code === "string") {
|
|
102
|
+
return child.props.code;
|
|
103
|
+
}
|
|
104
|
+
return "";
|
|
105
|
+
}).join("");
|
|
106
|
+
if (codeContent) {
|
|
107
|
+
const lines = codeContent.split("\n").length;
|
|
108
|
+
setLineCount(lines);
|
|
109
|
+
} else {
|
|
110
|
+
setLineCount(0);
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
setLineCount(0);
|
|
114
|
+
}
|
|
115
|
+
}, [children]);
|
|
116
|
+
return lineCount;
|
|
117
|
+
}
|
|
122
118
|
function useTheme() {
|
|
123
119
|
const [theme, setTheme] = useState(() => {
|
|
124
120
|
if (typeof window === "undefined") return "light";
|
|
@@ -180,46 +176,34 @@ var codeBlockCodeTv = tcv({
|
|
|
180
176
|
base: "text-message-code w-fit min-w-full bg-transparent font-mono [&>pre]:!bg-transparent [&>pre]:px-4 [&>pre]:py-4"
|
|
181
177
|
});
|
|
182
178
|
var CodeBlockCode = memo(function CodeBlockCode2(props) {
|
|
183
|
-
const {
|
|
179
|
+
const { code, language = "tsx", className, variant: variantProp, codeBlock, ...rest } = props;
|
|
184
180
|
const systemTheme = useTheme();
|
|
185
181
|
const resolvedVariant = variantProp ?? ((codeBlock == null ? void 0 : codeBlock.variant) === "default" ? void 0 : codeBlock == null ? void 0 : codeBlock.variant);
|
|
186
182
|
const theme = resolvedVariant ?? systemTheme;
|
|
187
183
|
const [highlightedHtml, setHighlightedHtml] = useState(null);
|
|
188
184
|
useEffect(() => {
|
|
189
|
-
let isMounted = true;
|
|
190
185
|
async function highlight() {
|
|
191
|
-
if (!
|
|
192
|
-
|
|
186
|
+
if (!code) {
|
|
187
|
+
setHighlightedHtml("<pre><code></code></pre>");
|
|
193
188
|
return;
|
|
194
189
|
}
|
|
195
190
|
const resolvedLang = resolveLanguage(language);
|
|
196
|
-
const themeConfig = theme === "light" ? "github-light" : "github-dark";
|
|
197
191
|
try {
|
|
198
|
-
const html = await codeToHtml(
|
|
192
|
+
const html = await codeToHtml(code, {
|
|
199
193
|
lang: resolvedLang,
|
|
200
|
-
theme:
|
|
194
|
+
theme: theme === "light" ? "github-light" : "github-dark"
|
|
201
195
|
});
|
|
202
|
-
|
|
196
|
+
setHighlightedHtml(html);
|
|
203
197
|
} catch {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (isMounted) setHighlightedHtml(html);
|
|
210
|
-
} catch {
|
|
211
|
-
if (isMounted) {
|
|
212
|
-
const escaped = children.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
213
|
-
setHighlightedHtml(`<pre><code>${escaped}</code></pre>`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
198
|
+
const html = await codeToHtml(code, {
|
|
199
|
+
lang: "text",
|
|
200
|
+
theme: theme === "light" ? "github-light" : "github-dark"
|
|
201
|
+
});
|
|
202
|
+
setHighlightedHtml(html);
|
|
216
203
|
}
|
|
217
204
|
}
|
|
218
205
|
highlight();
|
|
219
|
-
|
|
220
|
-
isMounted = false;
|
|
221
|
-
};
|
|
222
|
-
}, [children, language, theme]);
|
|
206
|
+
}, [code, language, theme]);
|
|
223
207
|
const classNames = codeBlockCodeTv({ className });
|
|
224
208
|
return highlightedHtml ? /* @__PURE__ */ jsx(
|
|
225
209
|
"div",
|
|
@@ -233,29 +217,10 @@ var CodeBlockCode = memo(function CodeBlockCode2(props) {
|
|
|
233
217
|
{
|
|
234
218
|
className: tcx("min-w-0", classNames),
|
|
235
219
|
...rest,
|
|
236
|
-
children: /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children }) })
|
|
220
|
+
children: /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: code }) })
|
|
237
221
|
}
|
|
238
222
|
);
|
|
239
223
|
});
|
|
240
|
-
function extractCodeFromChildren(children) {
|
|
241
|
-
if (!children) return "";
|
|
242
|
-
try {
|
|
243
|
-
return React__default.Children.toArray(children).map((child) => {
|
|
244
|
-
var _a, _b;
|
|
245
|
-
if (React__default.isValidElement(child)) {
|
|
246
|
-
if (((_a = child.props) == null ? void 0 : _a.code) && typeof child.props.code === "string") {
|
|
247
|
-
return child.props.code;
|
|
248
|
-
}
|
|
249
|
-
if (((_b = child.props) == null ? void 0 : _b.children) && typeof child.props.children === "string") {
|
|
250
|
-
return child.props.children;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return "";
|
|
254
|
-
}).filter(Boolean).join("");
|
|
255
|
-
} catch {
|
|
256
|
-
return "";
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
224
|
var icons = {
|
|
260
225
|
js: /* @__PURE__ */ jsxs(
|
|
261
226
|
"svg",
|
|
@@ -943,8 +908,9 @@ var CodeBlockHeader = memo(function CodeBlockHeader2(props) {
|
|
|
943
908
|
handleCopy,
|
|
944
909
|
variant
|
|
945
910
|
} = codeBlock;
|
|
946
|
-
|
|
947
|
-
|
|
911
|
+
if (!handleExpand || !handleCopy) {
|
|
912
|
+
return null;
|
|
913
|
+
}
|
|
948
914
|
const tv = codeBlockHeaderTv({ isExpanded, variant });
|
|
949
915
|
let icon = null;
|
|
950
916
|
try {
|
|
@@ -968,17 +934,17 @@ var CodeBlockHeader = memo(function CodeBlockHeader2(props) {
|
|
|
968
934
|
children
|
|
969
935
|
] }),
|
|
970
936
|
/* @__PURE__ */ jsxs("div", { className: tv.actions(), children: [
|
|
971
|
-
isExpanded &&
|
|
937
|
+
isExpanded && /* @__PURE__ */ jsx(
|
|
972
938
|
IconButton,
|
|
973
939
|
{
|
|
974
940
|
className: tv.button(),
|
|
975
941
|
variant: variant === "dark" ? "dark" : "ghost",
|
|
976
|
-
onClick: () => handleCopy
|
|
942
|
+
onClick: () => handleCopy(),
|
|
977
943
|
tooltip: { content: copyTooltipContent },
|
|
978
944
|
children: copied ? /* @__PURE__ */ jsx(Check, { className: "text-success-foreground" }) : /* @__PURE__ */ jsx(ClipboardSmall, {})
|
|
979
945
|
}
|
|
980
946
|
),
|
|
981
|
-
expandable &&
|
|
947
|
+
expandable && /* @__PURE__ */ jsx(
|
|
982
948
|
IconButton,
|
|
983
949
|
{
|
|
984
950
|
className: tv.button(),
|
|
@@ -1006,10 +972,9 @@ var codeBlockFooterTv = tcv({
|
|
|
1006
972
|
},
|
|
1007
973
|
false: {
|
|
1008
974
|
footer: [
|
|
1009
|
-
"bg-secondary-background/
|
|
975
|
+
"bg-secondary-background/90 absolute inset-x-0 bottom-0 z-3",
|
|
1010
976
|
"opacity-0 group-hover:opacity-100",
|
|
1011
|
-
"hover:bg-tertiary-background"
|
|
1012
|
-
"backdrop-blur-xs"
|
|
977
|
+
"hover:bg-tertiary-background"
|
|
1013
978
|
]
|
|
1014
979
|
}
|
|
1015
980
|
}
|
|
@@ -1023,7 +988,7 @@ var CodeBlockFooter = memo(function CodeBlockFooter2(props) {
|
|
|
1023
988
|
if (!codeBlock) return null;
|
|
1024
989
|
const { isExpanded, codeExpanded, handleCodeExpand, lineCount, lineThreshold, needsScroll } = codeBlock;
|
|
1025
990
|
const tv = codeBlockFooterTv({ codeExpanded });
|
|
1026
|
-
if (
|
|
991
|
+
if (!(lineCount > lineThreshold || needsScroll || codeExpanded) || !isExpanded) {
|
|
1027
992
|
return null;
|
|
1028
993
|
}
|
|
1029
994
|
return /* @__PURE__ */ jsx(
|
|
@@ -1035,26 +1000,24 @@ var CodeBlockFooter = memo(function CodeBlockFooter2(props) {
|
|
|
1035
1000
|
}
|
|
1036
1001
|
);
|
|
1037
1002
|
});
|
|
1038
|
-
var LINE_HEIGHT_PX = 16;
|
|
1039
|
-
var HEIGHT_PADDING_PX = 32 + 40;
|
|
1040
1003
|
var codeBlockTv = tcv({
|
|
1041
1004
|
slots: {
|
|
1042
|
-
code: "overflow-hidden
|
|
1005
|
+
code: "overflow-hidden",
|
|
1043
1006
|
content: "flex w-fit flex-col overflow-clip p-[inherit]"
|
|
1044
1007
|
}
|
|
1045
1008
|
});
|
|
1046
|
-
|
|
1047
|
-
const { className, codeBlock, withScrollArea = true
|
|
1009
|
+
function CodeBlockContent(props) {
|
|
1010
|
+
const { code, className, codeBlock, withScrollArea = true } = props;
|
|
1048
1011
|
if (!codeBlock) return null;
|
|
1049
1012
|
const { language, isExpanded, codeExpanded, scrollRef, contentRef, lineCount, lineThreshold } = codeBlock;
|
|
1050
1013
|
if (!isExpanded) {
|
|
1051
1014
|
return null;
|
|
1052
1015
|
}
|
|
1053
|
-
if (typeof
|
|
1016
|
+
if (typeof code !== "string") {
|
|
1054
1017
|
return null;
|
|
1055
1018
|
}
|
|
1056
1019
|
const tv = codeBlockTv();
|
|
1057
|
-
const shouldLimitHeight =
|
|
1020
|
+
const shouldLimitHeight = lineCount > lineThreshold && !codeExpanded;
|
|
1058
1021
|
return /* @__PURE__ */ jsx(Fragment, { children: withScrollArea ? /* @__PURE__ */ jsx(
|
|
1059
1022
|
ScrollArea,
|
|
1060
1023
|
{
|
|
@@ -1067,7 +1030,7 @@ var CodeBlockContent = memo(function CodeBlockContent2(props) {
|
|
|
1067
1030
|
{
|
|
1068
1031
|
ref: scrollRef,
|
|
1069
1032
|
style: {
|
|
1070
|
-
maxHeight: shouldLimitHeight ? `${lineThreshold *
|
|
1033
|
+
maxHeight: shouldLimitHeight ? `${lineThreshold * 14 + 32}px` : "none"
|
|
1071
1034
|
},
|
|
1072
1035
|
children: /* @__PURE__ */ jsx(
|
|
1073
1036
|
ScrollArea.Content,
|
|
@@ -1077,9 +1040,9 @@ var CodeBlockContent = memo(function CodeBlockContent2(props) {
|
|
|
1077
1040
|
children: /* @__PURE__ */ jsx(
|
|
1078
1041
|
CodeBlockCode,
|
|
1079
1042
|
{
|
|
1043
|
+
code,
|
|
1080
1044
|
language,
|
|
1081
|
-
codeBlock
|
|
1082
|
-
children
|
|
1045
|
+
codeBlock
|
|
1083
1046
|
}
|
|
1084
1047
|
)
|
|
1085
1048
|
}
|
|
@@ -1090,19 +1053,19 @@ var CodeBlockContent = memo(function CodeBlockContent2(props) {
|
|
|
1090
1053
|
) : /* @__PURE__ */ jsx("div", { className: tcx(tv.content(), className), children: /* @__PURE__ */ jsx(
|
|
1091
1054
|
CodeBlockCode,
|
|
1092
1055
|
{
|
|
1056
|
+
code,
|
|
1093
1057
|
language,
|
|
1094
|
-
codeBlock
|
|
1095
|
-
children
|
|
1058
|
+
codeBlock
|
|
1096
1059
|
}
|
|
1097
1060
|
) }) });
|
|
1098
|
-
}
|
|
1061
|
+
}
|
|
1099
1062
|
var CodeBlockRoot = memo(function CodeBlock(props) {
|
|
1100
1063
|
const {
|
|
1101
1064
|
children,
|
|
1102
1065
|
className,
|
|
1103
1066
|
filename,
|
|
1104
1067
|
language = "code",
|
|
1105
|
-
lineThreshold,
|
|
1068
|
+
lineThreshold = 20,
|
|
1106
1069
|
expandable = true,
|
|
1107
1070
|
defaultExpanded = true,
|
|
1108
1071
|
defaultCodeExpanded = false,
|
|
@@ -1114,6 +1077,7 @@ var CodeBlockRoot = memo(function CodeBlock(props) {
|
|
|
1114
1077
|
resize: "smooth",
|
|
1115
1078
|
initial: "smooth"
|
|
1116
1079
|
});
|
|
1080
|
+
const codeContentRef = React__default.useRef("");
|
|
1117
1081
|
const {
|
|
1118
1082
|
isExpanded,
|
|
1119
1083
|
codeExpanded,
|
|
@@ -1128,25 +1092,34 @@ var CodeBlockRoot = memo(function CodeBlock(props) {
|
|
|
1128
1092
|
onCodeExpandChange,
|
|
1129
1093
|
scrollToBottom
|
|
1130
1094
|
});
|
|
1131
|
-
const codeContent = React__default.useMemo(() => extractCodeFromChildren(children), [children]);
|
|
1132
|
-
const lineCount = React__default.useMemo(
|
|
1133
|
-
() => codeContent ? codeContent.split("\n").length : 0,
|
|
1134
|
-
[codeContent]
|
|
1135
|
-
);
|
|
1136
1095
|
const handleCopy = React__default.useCallback(
|
|
1137
1096
|
(code) => {
|
|
1138
|
-
const codeToUse = code ||
|
|
1097
|
+
const codeToUse = code || codeContentRef.current;
|
|
1139
1098
|
if (codeToUse) {
|
|
1140
1099
|
originalHandleCopy(codeToUse);
|
|
1141
1100
|
}
|
|
1142
1101
|
},
|
|
1143
|
-
[originalHandleCopy
|
|
1102
|
+
[originalHandleCopy]
|
|
1144
1103
|
);
|
|
1104
|
+
React__default.useEffect(() => {
|
|
1105
|
+
try {
|
|
1106
|
+
React__default.Children.forEach(children, (child) => {
|
|
1107
|
+
if (React__default.isValidElement(child) && child.props) {
|
|
1108
|
+
if (child.props.code && typeof child.props.code === "string") {
|
|
1109
|
+
codeContentRef.current = child.props.code;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
} catch {
|
|
1114
|
+
}
|
|
1115
|
+
}, [children]);
|
|
1116
|
+
const lineCount = useLineCount(children);
|
|
1145
1117
|
const needsScroll = useScrollDetection({
|
|
1146
1118
|
scrollRef,
|
|
1147
1119
|
contentRef,
|
|
1148
1120
|
isExpanded,
|
|
1149
|
-
codeExpanded
|
|
1121
|
+
codeExpanded,
|
|
1122
|
+
children
|
|
1150
1123
|
});
|
|
1151
1124
|
const contextValue = React__default.useMemo(
|
|
1152
1125
|
() => ({
|
|
@@ -1205,7 +1178,7 @@ var CodeBlockRoot = memo(function CodeBlock(props) {
|
|
|
1205
1178
|
"div",
|
|
1206
1179
|
{
|
|
1207
1180
|
className: tcx(
|
|
1208
|
-
"group/code-block relative
|
|
1181
|
+
"group/code-block relative overflow-hidden rounded-lg",
|
|
1209
1182
|
variant === "default" && "bg-secondary-background",
|
|
1210
1183
|
variant === "light" && "bg-gray-100",
|
|
1211
1184
|
variant === "dark" && "bg-gray-700",
|
|
@@ -452,37 +452,8 @@ interface ColorAreaProps {
|
|
|
452
452
|
}
|
|
453
453
|
declare const ColorArea: react.MemoExoticComponent<react.ForwardRefExoticComponent<ColorAreaProps & react.RefAttributes<HTMLDivElement>>>;
|
|
454
454
|
|
|
455
|
-
interface ColorSliderThumbProps {
|
|
456
|
-
className?: string;
|
|
457
|
-
size?: number;
|
|
458
|
-
}
|
|
459
|
-
declare function ColorSliderThumb(props: ColorSliderThumbProps): react_jsx_runtime.JSX.Element;
|
|
460
|
-
declare namespace ColorSliderThumb {
|
|
461
|
-
var displayName: string;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
interface ColorSliderTrackProps {
|
|
465
|
-
className?: string;
|
|
466
|
-
children?: React.ReactNode;
|
|
467
|
-
/**
|
|
468
|
-
* Height of the track in pixels.
|
|
469
|
-
* This prop is extracted by the parent ColorSlider and passed via context.
|
|
470
|
-
*/
|
|
471
|
-
height?: number;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* ColorSliderTrack - The track background of the color slider.
|
|
475
|
-
* Renders the gradient background based on slider type (hue, alpha, etc.)
|
|
476
|
-
* Can contain custom children for additional visual elements.
|
|
477
|
-
*/
|
|
478
|
-
declare function ColorSliderTrack(props: ColorSliderTrackProps): react_jsx_runtime.JSX.Element;
|
|
479
|
-
declare namespace ColorSliderTrack {
|
|
480
|
-
var displayName: string;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
455
|
interface ColorSliderProps {
|
|
484
456
|
backgroundStyle?: CSSProperties;
|
|
485
|
-
children?: React.ReactNode;
|
|
486
457
|
className?: string;
|
|
487
458
|
disabled?: boolean;
|
|
488
459
|
hue?: number;
|
|
@@ -490,18 +461,14 @@ interface ColorSliderProps {
|
|
|
490
461
|
onChangeEnd?: () => void;
|
|
491
462
|
onChangeStart?: () => void;
|
|
492
463
|
position: number;
|
|
464
|
+
thumbSize?: number;
|
|
465
|
+
trackSize?: {
|
|
466
|
+
height?: number;
|
|
467
|
+
width?: number;
|
|
468
|
+
};
|
|
493
469
|
type: PickerSliderType;
|
|
494
|
-
/**
|
|
495
|
-
* Width of the slider track in pixels.
|
|
496
|
-
* If not provided (undefined or false), the width will be auto-calculated from the container.
|
|
497
|
-
*/
|
|
498
|
-
width?: number | boolean;
|
|
499
|
-
}
|
|
500
|
-
interface ColorSliderComponent extends React.MemoExoticComponent<React.ForwardRefExoticComponent<ColorSliderProps & React.RefAttributes<HTMLDivElement>>> {
|
|
501
|
-
Thumb: typeof ColorSliderThumb;
|
|
502
|
-
Track: typeof ColorSliderTrack;
|
|
503
470
|
}
|
|
504
|
-
declare const ColorSlider:
|
|
471
|
+
declare const ColorSlider: react.MemoExoticComponent<react.ForwardRefExoticComponent<ColorSliderProps & react.RefAttributes<HTMLDivElement>>>;
|
|
505
472
|
|
|
506
473
|
interface ColorSwatchProps extends Omit<HTMLProps<HTMLDivElement>, "color"> {
|
|
507
474
|
alpha?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button } from "../../../button/dist/index.js";
|
|
3
|
-
import { Range
|
|
3
|
+
import { Range } from "../../../range/dist/index.js";
|
|
4
4
|
import React__default, { memo, useState, useRef, useMemo, useEffect, useCallback } from "react";
|
|
5
5
|
import { useEventCallback } from "usehooks-ts";
|
|
6
6
|
import { ColorImageToolbar } from "./color-image-toolbar.js";
|
|
@@ -209,7 +209,7 @@ const ColorImagePaint = memo(function ColorImagePaint2(props) {
|
|
|
209
209
|
return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
|
|
210
210
|
/* @__PURE__ */ jsx("span", { className: styles.adjustLabel(), children: (_a2 = features == null ? void 0 : features.labels) == null ? void 0 : _a2[filterName] }),
|
|
211
211
|
/* @__PURE__ */ jsx(
|
|
212
|
-
|
|
212
|
+
Range,
|
|
213
213
|
{
|
|
214
214
|
min: -100,
|
|
215
215
|
max: 100,
|
|
@@ -7,12 +7,6 @@ interface DropdownProps {
|
|
|
7
7
|
* @default true
|
|
8
8
|
*/
|
|
9
9
|
autoSelectFirstItem?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Whether to avoid collisions by flipping or shifting the dropdown position.
|
|
12
|
-
* When false, the dropdown will strictly follow the placement direction.
|
|
13
|
-
* @default true
|
|
14
|
-
*/
|
|
15
|
-
avoidCollisions?: boolean;
|
|
16
10
|
children?: React.ReactNode;
|
|
17
11
|
disabledNested?: boolean;
|
|
18
12
|
focusManagerProps?: Partial<FloatingFocusManagerProps>;
|
|
@@ -13,7 +13,6 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
13
13
|
const {
|
|
14
14
|
children,
|
|
15
15
|
autoSelectFirstItem = true,
|
|
16
|
-
avoidCollisions = true,
|
|
17
16
|
disabledNested = false,
|
|
18
17
|
offset: offsetDistance = DEFAULT_OFFSET,
|
|
19
18
|
placement = "bottom-start",
|
|
@@ -54,7 +53,7 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
54
53
|
}
|
|
55
54
|
onOpenChange == null ? void 0 : onOpenChange(newOpen);
|
|
56
55
|
});
|
|
57
|
-
const { nodeId, item, isNested
|
|
56
|
+
const { nodeId, item, isNested } = useMenuTree({
|
|
58
57
|
disabledNested,
|
|
59
58
|
handleOpenChange,
|
|
60
59
|
isControlledOpen
|
|
@@ -78,14 +77,11 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
78
77
|
});
|
|
79
78
|
});
|
|
80
79
|
const lastPositionRef = useRef(null);
|
|
81
|
-
const middleware = useMemo(
|
|
82
|
-
|
|
83
|
-
offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 })
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
baseMiddleware.push(flip(), shift());
|
|
87
|
-
}
|
|
88
|
-
baseMiddleware.push(
|
|
80
|
+
const middleware = useMemo(
|
|
81
|
+
() => [
|
|
82
|
+
offset({ mainAxis: isNested ? 10 : offsetDistance, alignmentAxis: isNested ? -4 : 0 }),
|
|
83
|
+
flip(),
|
|
84
|
+
shift(),
|
|
89
85
|
size({
|
|
90
86
|
padding: 4,
|
|
91
87
|
apply({ elements, availableHeight, rects }) {
|
|
@@ -108,9 +104,9 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
})
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
],
|
|
108
|
+
[isNested, offsetDistance, matchTriggerWidth, scrollRef]
|
|
109
|
+
);
|
|
114
110
|
const { refs, floatingStyles, context, isPositioned } = useFloating({
|
|
115
111
|
nodeId,
|
|
116
112
|
open: isControlledOpen,
|
|
@@ -169,17 +165,11 @@ var DropdownComponent = memo(function DropdownComponent2(props) {
|
|
|
169
165
|
bubbles: true,
|
|
170
166
|
escapeKey: true
|
|
171
167
|
});
|
|
172
|
-
const handleNavigate = useEventCallback((index) => {
|
|
173
|
-
setActiveIndex(index);
|
|
174
|
-
if (tree && index !== null) {
|
|
175
|
-
tree.events.emit("navigate", { nodeId, index });
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
168
|
const listNavigation = useListNavigation(context, {
|
|
179
169
|
listRef: elementsRef,
|
|
180
170
|
activeIndex,
|
|
181
171
|
nested: isNested,
|
|
182
|
-
onNavigate:
|
|
172
|
+
onNavigate: setActiveIndex,
|
|
183
173
|
loop: true
|
|
184
174
|
});
|
|
185
175
|
const typeahead = useTypeahead(context, {
|
|
@@ -15,24 +15,12 @@ type VirtualItem = {
|
|
|
15
15
|
emojis: EmojiData[];
|
|
16
16
|
type: "emojis";
|
|
17
17
|
};
|
|
18
|
-
interface CategoryNames {
|
|
19
|
-
activities: string;
|
|
20
|
-
animalsNature: string;
|
|
21
|
-
flags: string;
|
|
22
|
-
foodDrink: string;
|
|
23
|
-
frequentlyUsed: string;
|
|
24
|
-
objects: string;
|
|
25
|
-
smileysPeople: string;
|
|
26
|
-
symbols: string;
|
|
27
|
-
travelPlaces: string;
|
|
28
|
-
}
|
|
29
18
|
interface UseEmojiDataProps {
|
|
30
|
-
categoryNames?: CategoryNames;
|
|
31
19
|
columns: number;
|
|
32
20
|
searchQuery: string;
|
|
33
21
|
showFrequentlyUsed: boolean;
|
|
34
22
|
}
|
|
35
|
-
declare function useEmojiData({ searchQuery, columns, showFrequentlyUsed
|
|
23
|
+
declare function useEmojiData({ searchQuery, columns, showFrequentlyUsed }: UseEmojiDataProps): {
|
|
36
24
|
categorizedData: VirtualItem[];
|
|
37
25
|
categoryIndexMap: Map<EmojiCategory, number>;
|
|
38
26
|
searchResults: {
|
|
@@ -61,25 +49,8 @@ interface EmojiPickerProps {
|
|
|
61
49
|
showCategories?: boolean;
|
|
62
50
|
showFrequentlyUsed?: boolean;
|
|
63
51
|
showSearch?: boolean;
|
|
64
|
-
showFooter?: boolean;
|
|
65
52
|
value?: EmojiData | null;
|
|
66
53
|
variant?: "default" | "dark" | "light";
|
|
67
|
-
i18n?: {
|
|
68
|
-
noEmojisFoundTitle?: string;
|
|
69
|
-
noEmojisFoundDescription?: string;
|
|
70
|
-
footerPickAnEmoji?: string;
|
|
71
|
-
categories?: {
|
|
72
|
-
frequentlyUsed: string;
|
|
73
|
-
smileysPeople: string;
|
|
74
|
-
animalsNature: string;
|
|
75
|
-
foodDrink: string;
|
|
76
|
-
travelPlaces: string;
|
|
77
|
-
activities: string;
|
|
78
|
-
objects: string;
|
|
79
|
-
symbols: string;
|
|
80
|
-
flags: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
54
|
}
|
|
84
55
|
declare const EmojiPicker: React.NamedExoticComponent<EmojiPickerProps>;
|
|
85
56
|
|