@particle-academy/react-fancy 5.9.0 → 5.11.0
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/index.cjs +44 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/dist/styles.css +12 -0
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -980,7 +980,15 @@ interface ProgressProps {
|
|
|
980
980
|
value?: number;
|
|
981
981
|
max?: number;
|
|
982
982
|
variant?: "bar" | "circular";
|
|
983
|
-
|
|
983
|
+
/**
|
|
984
|
+
* Named scale, or an explicit pixel diameter for `variant="circular"`.
|
|
985
|
+
*
|
|
986
|
+
* The scale topped out at 64px and was written inline, so a larger ring was
|
|
987
|
+
* impossible rather than merely awkward.
|
|
988
|
+
*/
|
|
989
|
+
size?: "sm" | "md" | "lg" | number;
|
|
990
|
+
/** Ring thickness in px (circular only). Derived from the diameter if unset. */
|
|
991
|
+
strokeWidth?: number;
|
|
984
992
|
color?: Color;
|
|
985
993
|
indeterminate?: boolean;
|
|
986
994
|
showValue?: boolean;
|
|
@@ -3672,6 +3680,16 @@ type PromptAttachment = {
|
|
|
3672
3680
|
id: string;
|
|
3673
3681
|
name: string;
|
|
3674
3682
|
bytes: number;
|
|
3683
|
+
/**
|
|
3684
|
+
* The file the user actually attached.
|
|
3685
|
+
*
|
|
3686
|
+
* Optional because an attachment restored from a server has no File — but for
|
|
3687
|
+
* anything the user dropped or picked it is always present. Without it a host
|
|
3688
|
+
* can render a chip and nothing else: no POST, no FormData, no send-to-model.
|
|
3689
|
+
*/
|
|
3690
|
+
file?: File;
|
|
3691
|
+
/** MIME type. Hosts branch on this to decide whether a file can be sent as-is. */
|
|
3692
|
+
type?: string;
|
|
3675
3693
|
};
|
|
3676
3694
|
interface PromptInputProps {
|
|
3677
3695
|
/** Token budget for the meter. */
|
package/dist/index.d.ts
CHANGED
|
@@ -980,7 +980,15 @@ interface ProgressProps {
|
|
|
980
980
|
value?: number;
|
|
981
981
|
max?: number;
|
|
982
982
|
variant?: "bar" | "circular";
|
|
983
|
-
|
|
983
|
+
/**
|
|
984
|
+
* Named scale, or an explicit pixel diameter for `variant="circular"`.
|
|
985
|
+
*
|
|
986
|
+
* The scale topped out at 64px and was written inline, so a larger ring was
|
|
987
|
+
* impossible rather than merely awkward.
|
|
988
|
+
*/
|
|
989
|
+
size?: "sm" | "md" | "lg" | number;
|
|
990
|
+
/** Ring thickness in px (circular only). Derived from the diameter if unset. */
|
|
991
|
+
strokeWidth?: number;
|
|
984
992
|
color?: Color;
|
|
985
993
|
indeterminate?: boolean;
|
|
986
994
|
showValue?: boolean;
|
|
@@ -3672,6 +3680,16 @@ type PromptAttachment = {
|
|
|
3672
3680
|
id: string;
|
|
3673
3681
|
name: string;
|
|
3674
3682
|
bytes: number;
|
|
3683
|
+
/**
|
|
3684
|
+
* The file the user actually attached.
|
|
3685
|
+
*
|
|
3686
|
+
* Optional because an attachment restored from a server has no File — but for
|
|
3687
|
+
* anything the user dropped or picked it is always present. Without it a host
|
|
3688
|
+
* can render a chip and nothing else: no POST, no FormData, no send-to-model.
|
|
3689
|
+
*/
|
|
3690
|
+
file?: File;
|
|
3691
|
+
/** MIME type. Hosts branch on this to decide whether a file can be sent as-is. */
|
|
3692
|
+
type?: string;
|
|
3675
3693
|
};
|
|
3676
3694
|
interface PromptInputProps {
|
|
3677
3695
|
/** Token budget for the meter. */
|
package/dist/index.js
CHANGED
|
@@ -6737,6 +6737,7 @@ var circularSizeMap = {
|
|
|
6737
6737
|
md: 48,
|
|
6738
6738
|
lg: 64
|
|
6739
6739
|
};
|
|
6740
|
+
var namedStrokeWidth = { sm: 3, md: 4, lg: 5 };
|
|
6740
6741
|
var textSizeClasses = {
|
|
6741
6742
|
sm: "text-[8px]",
|
|
6742
6743
|
md: "text-[10px]",
|
|
@@ -6748,15 +6749,18 @@ var Progress = forwardRef(
|
|
|
6748
6749
|
max = 100,
|
|
6749
6750
|
variant = "bar",
|
|
6750
6751
|
size = "md",
|
|
6752
|
+
strokeWidth: strokeWidthProp,
|
|
6751
6753
|
color = "blue",
|
|
6752
6754
|
indeterminate = false,
|
|
6753
6755
|
showValue = false,
|
|
6754
6756
|
className
|
|
6755
6757
|
}, ref) => {
|
|
6758
|
+
const named = typeof size === "number" ? "md" : size;
|
|
6756
6759
|
const percentage = Math.min(100, Math.max(0, value / max * 100));
|
|
6757
6760
|
if (variant === "circular") {
|
|
6758
|
-
const
|
|
6759
|
-
const
|
|
6761
|
+
const pixelSize = typeof size === "number" ? size : null;
|
|
6762
|
+
const diameter = pixelSize ?? circularSizeMap[named];
|
|
6763
|
+
const strokeWidth = strokeWidthProp ?? (pixelSize === null ? namedStrokeWidth[named] : Math.max(3, Math.round(diameter * 0.075)));
|
|
6760
6764
|
const radius = (diameter - strokeWidth) / 2;
|
|
6761
6765
|
const circumference = 2 * Math.PI * radius;
|
|
6762
6766
|
const offset = indeterminate ? circumference * 0.75 : circumference - percentage / 100 * circumference;
|
|
@@ -6769,14 +6773,19 @@ var Progress = forwardRef(
|
|
|
6769
6773
|
"aria-valuemin": 0,
|
|
6770
6774
|
"aria-valuemax": max,
|
|
6771
6775
|
"data-react-fancy-progress": "",
|
|
6772
|
-
|
|
6773
|
-
|
|
6776
|
+
"data-size": pixelSize === null ? named : void 0,
|
|
6777
|
+
className: cn(
|
|
6778
|
+
"relative inline-flex items-center justify-center",
|
|
6779
|
+
className
|
|
6780
|
+
),
|
|
6781
|
+
style: pixelSize === null ? void 0 : { width: pixelSize, height: pixelSize },
|
|
6774
6782
|
children: [
|
|
6775
6783
|
/* @__PURE__ */ jsxs(
|
|
6776
6784
|
"svg",
|
|
6777
6785
|
{
|
|
6778
|
-
|
|
6779
|
-
|
|
6786
|
+
viewBox: `0 0 ${diameter} ${diameter}`,
|
|
6787
|
+
width: "100%",
|
|
6788
|
+
height: "100%",
|
|
6780
6789
|
className: cn(indeterminate && "animate-spin"),
|
|
6781
6790
|
children: [
|
|
6782
6791
|
/* @__PURE__ */ jsx(
|
|
@@ -6814,7 +6823,7 @@ var Progress = forwardRef(
|
|
|
6814
6823
|
className: cn(
|
|
6815
6824
|
"absolute font-medium",
|
|
6816
6825
|
progressText[color],
|
|
6817
|
-
textSizeClasses[
|
|
6826
|
+
textSizeClasses[named]
|
|
6818
6827
|
),
|
|
6819
6828
|
children: [
|
|
6820
6829
|
Math.round(percentage),
|
|
@@ -6842,7 +6851,7 @@ var Progress = forwardRef(
|
|
|
6842
6851
|
{
|
|
6843
6852
|
className: cn(
|
|
6844
6853
|
"w-full overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700",
|
|
6845
|
-
barHeightClasses[
|
|
6854
|
+
barHeightClasses[named]
|
|
6846
6855
|
),
|
|
6847
6856
|
children: /* @__PURE__ */ jsx(
|
|
6848
6857
|
"div",
|
|
@@ -15271,6 +15280,7 @@ function PromptInput({
|
|
|
15271
15280
|
const [attachments, setAttachments] = useState([]);
|
|
15272
15281
|
const [picker, setPicker] = useState(null);
|
|
15273
15282
|
const taRef = useRef(null);
|
|
15283
|
+
const fileRef = useRef(null);
|
|
15274
15284
|
const [dragOver, setDragOver] = useState(false);
|
|
15275
15285
|
const colors = mentionColor ?? DEFAULT_MENTION_COLOR;
|
|
15276
15286
|
const tokens = useMemo(
|
|
@@ -15377,19 +15387,25 @@ function PromptInput({
|
|
|
15377
15387
|
submit();
|
|
15378
15388
|
}
|
|
15379
15389
|
};
|
|
15380
|
-
const
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
const files = Array.from(e.dataTransfer.files);
|
|
15390
|
+
const attach = (list) => {
|
|
15391
|
+
const files = Array.from(list ?? []);
|
|
15392
|
+
if (files.length === 0) return;
|
|
15384
15393
|
setAttachments((cur) => [
|
|
15385
15394
|
...cur,
|
|
15386
15395
|
...files.map((f) => ({
|
|
15387
|
-
id:
|
|
15396
|
+
id: crypto.randomUUID(),
|
|
15388
15397
|
name: f.name,
|
|
15389
|
-
bytes: f.size
|
|
15398
|
+
bytes: f.size,
|
|
15399
|
+
file: f,
|
|
15400
|
+
type: f.type
|
|
15390
15401
|
}))
|
|
15391
15402
|
]);
|
|
15392
15403
|
};
|
|
15404
|
+
const onDrop = (e) => {
|
|
15405
|
+
e.preventDefault();
|
|
15406
|
+
setDragOver(false);
|
|
15407
|
+
attach(e.dataTransfer.files);
|
|
15408
|
+
};
|
|
15393
15409
|
return /* @__PURE__ */ jsxs(
|
|
15394
15410
|
"div",
|
|
15395
15411
|
{
|
|
@@ -15498,11 +15514,23 @@ function PromptInput({
|
|
|
15498
15514
|
variant: "ghost",
|
|
15499
15515
|
size: "sm",
|
|
15500
15516
|
className: "shrink-0",
|
|
15501
|
-
onClick: () =>
|
|
15502
|
-
},
|
|
15517
|
+
onClick: () => fileRef.current?.click(),
|
|
15503
15518
|
children: "\u{1F4CE} attach"
|
|
15504
15519
|
}
|
|
15505
15520
|
) }),
|
|
15521
|
+
/* @__PURE__ */ jsx(
|
|
15522
|
+
"input",
|
|
15523
|
+
{
|
|
15524
|
+
ref: fileRef,
|
|
15525
|
+
type: "file",
|
|
15526
|
+
multiple: true,
|
|
15527
|
+
className: "hidden",
|
|
15528
|
+
onChange: (e) => {
|
|
15529
|
+
attach(e.target.files);
|
|
15530
|
+
e.target.value = "";
|
|
15531
|
+
}
|
|
15532
|
+
}
|
|
15533
|
+
),
|
|
15506
15534
|
/* @__PURE__ */ jsxs("div", { className: "ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden", children: [
|
|
15507
15535
|
/* @__PURE__ */ jsx("div", { className: "h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsx(
|
|
15508
15536
|
"div",
|