@particle-academy/react-fancy 3.4.3 → 4.0.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/README.md +4 -3
- package/dist/index.cjs +103 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -112
- package/dist/index.d.ts +162 -112
- package/dist/index.js +103 -9
- package/dist/index.js.map +1 -1
- package/docs/Action.md +15 -3
- package/docs/Button.md +91 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, createContext, useId, useRef, useEffect, useState, useCallback, useMemo, Children, isValidElement, cloneElement, useContext, Fragment as Fragment$1
|
|
1
|
+
import { forwardRef, createContext, useId, useRef, useEffect, useState, useCallback, useMemo, Children, isValidElement, useLayoutEffect, cloneElement, useContext, Fragment as Fragment$1 } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import * as LucideIcons from 'lucide-react';
|
|
@@ -2323,7 +2323,7 @@ function parseSortOrder(sort) {
|
|
|
2323
2323
|
}
|
|
2324
2324
|
return valid;
|
|
2325
2325
|
}
|
|
2326
|
-
var
|
|
2326
|
+
var Button = forwardRef(
|
|
2327
2327
|
({
|
|
2328
2328
|
children,
|
|
2329
2329
|
className,
|
|
@@ -2486,12 +2486,13 @@ var Action = forwardRef(
|
|
|
2486
2486
|
trailingElements
|
|
2487
2487
|
] });
|
|
2488
2488
|
const safeHref = sanitizeHref(href);
|
|
2489
|
-
const buttonEl = safeHref && !disabled ? /* @__PURE__ */ jsx("a", { href: safeHref, className: classes, "data-react-fancy-action": "", children: content }) : /* @__PURE__ */ jsx(
|
|
2489
|
+
const buttonEl = safeHref && !disabled ? /* @__PURE__ */ jsx("a", { href: safeHref, className: classes, "data-react-fancy-button": "", "data-react-fancy-action": "", children: content }) : /* @__PURE__ */ jsx(
|
|
2490
2490
|
"button",
|
|
2491
2491
|
{
|
|
2492
2492
|
ref,
|
|
2493
2493
|
className: classes,
|
|
2494
2494
|
disabled: disabled || loading,
|
|
2495
|
+
"data-react-fancy-button": "",
|
|
2495
2496
|
"data-react-fancy-action": "",
|
|
2496
2497
|
...props,
|
|
2497
2498
|
children: content
|
|
@@ -2555,7 +2556,8 @@ var Action = forwardRef(
|
|
|
2555
2556
|
return buttonEl;
|
|
2556
2557
|
}
|
|
2557
2558
|
);
|
|
2558
|
-
|
|
2559
|
+
Button.displayName = "Button";
|
|
2560
|
+
var Action = Button;
|
|
2559
2561
|
function useControllableState(controlledValue, defaultValue, onChange) {
|
|
2560
2562
|
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
2561
2563
|
const isControlled = controlledValue !== void 0;
|
|
@@ -6392,6 +6394,98 @@ var Callout = forwardRef(
|
|
|
6392
6394
|
}
|
|
6393
6395
|
);
|
|
6394
6396
|
Callout.displayName = "Callout";
|
|
6397
|
+
var DOT_COLORS = ["bg-rose-300", "bg-amber-300", "bg-green-300"];
|
|
6398
|
+
var FauxClient = forwardRef(
|
|
6399
|
+
({
|
|
6400
|
+
variant = "browser",
|
|
6401
|
+
url,
|
|
6402
|
+
meta,
|
|
6403
|
+
dots = true,
|
|
6404
|
+
width,
|
|
6405
|
+
scale = "fit",
|
|
6406
|
+
className,
|
|
6407
|
+
barClassName,
|
|
6408
|
+
bodyClassName,
|
|
6409
|
+
children,
|
|
6410
|
+
...rest
|
|
6411
|
+
}, ref) => {
|
|
6412
|
+
const scaled = typeof width === "number";
|
|
6413
|
+
const viewportRef = useRef(null);
|
|
6414
|
+
const stageRef = useRef(null);
|
|
6415
|
+
const [s, setS] = useState(typeof scale === "number" ? scale : 1);
|
|
6416
|
+
const [contentHeight, setContentHeight] = useState(void 0);
|
|
6417
|
+
useLayoutEffect(() => {
|
|
6418
|
+
if (!scaled) return;
|
|
6419
|
+
const viewport = viewportRef.current;
|
|
6420
|
+
const stage = stageRef.current;
|
|
6421
|
+
if (!viewport || !stage) return;
|
|
6422
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
6423
|
+
const measure = () => {
|
|
6424
|
+
const avail = viewport.clientWidth;
|
|
6425
|
+
const next = scale === "fit" ? width && width > 0 ? avail / width : 1 : scale;
|
|
6426
|
+
const naturalHeight = stage.offsetHeight;
|
|
6427
|
+
setS(next);
|
|
6428
|
+
setContentHeight(naturalHeight * next);
|
|
6429
|
+
};
|
|
6430
|
+
measure();
|
|
6431
|
+
const ro = new ResizeObserver(measure);
|
|
6432
|
+
ro.observe(viewport);
|
|
6433
|
+
ro.observe(stage);
|
|
6434
|
+
return () => ro.disconnect();
|
|
6435
|
+
}, [scaled, scale, width]);
|
|
6436
|
+
const isBrowser = variant === "browser";
|
|
6437
|
+
const isDevice = variant === "device";
|
|
6438
|
+
return /* @__PURE__ */ jsxs(
|
|
6439
|
+
"div",
|
|
6440
|
+
{
|
|
6441
|
+
ref,
|
|
6442
|
+
"data-react-fancy-faux-client": "",
|
|
6443
|
+
className: cn(
|
|
6444
|
+
"overflow-hidden bg-white dark:bg-zinc-900",
|
|
6445
|
+
isBrowser && "rounded-2xl border border-zinc-200 shadow-xl dark:border-zinc-800",
|
|
6446
|
+
isDevice && "rounded-[2rem] border-[10px] border-zinc-800 shadow-2xl dark:border-zinc-700",
|
|
6447
|
+
variant === "bare" && "rounded-lg border border-zinc-200 dark:border-zinc-800",
|
|
6448
|
+
className
|
|
6449
|
+
),
|
|
6450
|
+
...rest,
|
|
6451
|
+
children: [
|
|
6452
|
+
isBrowser && /* @__PURE__ */ jsxs(
|
|
6453
|
+
"div",
|
|
6454
|
+
{
|
|
6455
|
+
className: cn(
|
|
6456
|
+
"flex items-center gap-2 border-b border-zinc-200 bg-zinc-50 px-3.5 py-2.5 font-mono text-[11.5px] text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950 dark:text-zinc-400",
|
|
6457
|
+
barClassName
|
|
6458
|
+
),
|
|
6459
|
+
children: [
|
|
6460
|
+
dots && /* @__PURE__ */ jsx("div", { className: "mr-1.5 flex gap-[5px]", children: DOT_COLORS.map((color, i) => /* @__PURE__ */ jsx("span", { className: cn("h-[9px] w-[9px] rounded-full", color) }, i)) }),
|
|
6461
|
+
url != null && /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: url }),
|
|
6462
|
+
meta != null && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-zinc-400 dark:text-zinc-500", children: meta })
|
|
6463
|
+
]
|
|
6464
|
+
}
|
|
6465
|
+
),
|
|
6466
|
+
/* @__PURE__ */ jsx(
|
|
6467
|
+
"div",
|
|
6468
|
+
{
|
|
6469
|
+
ref: viewportRef,
|
|
6470
|
+
className: cn("relative overflow-hidden", bodyClassName),
|
|
6471
|
+
style: scaled ? { height: contentHeight } : void 0,
|
|
6472
|
+
children: scaled ? /* @__PURE__ */ jsx(
|
|
6473
|
+
"div",
|
|
6474
|
+
{
|
|
6475
|
+
ref: stageRef,
|
|
6476
|
+
className: "absolute left-0 top-0 origin-top-left",
|
|
6477
|
+
style: { width, transform: `scale(${s})` },
|
|
6478
|
+
children
|
|
6479
|
+
}
|
|
6480
|
+
) : children
|
|
6481
|
+
}
|
|
6482
|
+
)
|
|
6483
|
+
]
|
|
6484
|
+
}
|
|
6485
|
+
);
|
|
6486
|
+
}
|
|
6487
|
+
);
|
|
6488
|
+
FauxClient.displayName = "FauxClient";
|
|
6395
6489
|
var colorClasses5 = {
|
|
6396
6490
|
yellow: "bg-amber-100 text-amber-950 dark:bg-amber-200 dark:text-amber-950",
|
|
6397
6491
|
blue: "bg-sky-100 text-sky-950 dark:bg-sky-200 dark:text-sky-950",
|
|
@@ -12147,7 +12241,7 @@ function ReasonTag({
|
|
|
12147
12241
|
/* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wider text-zinc-400", children: "sources" }),
|
|
12148
12242
|
/* @__PURE__ */ jsx("ul", { className: "mt-0.5 space-y-0.5 text-[12px]", children: sources.map((s, i) => /* @__PURE__ */ jsx("li", { children: s.href ? /* @__PURE__ */ jsx("a", { className: "text-violet-600 hover:underline", href: s.href, children: s.label }) : /* @__PURE__ */ jsx("span", { className: "text-zinc-600 dark:text-zinc-300", children: s.label }) }, i)) })
|
|
12149
12243
|
] }),
|
|
12150
|
-
onFollowUp && /* @__PURE__ */ jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx(
|
|
12244
|
+
onFollowUp && /* @__PURE__ */ jsx("div", { className: "flex justify-end pt-1", children: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: onFollowUp, children: "ask follow-up" }) })
|
|
12151
12245
|
] }) })
|
|
12152
12246
|
] });
|
|
12153
12247
|
}
|
|
@@ -12587,7 +12681,7 @@ function PromptInput({
|
|
|
12587
12681
|
] }),
|
|
12588
12682
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-t border-zinc-200 bg-zinc-50/60 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/40", children: [
|
|
12589
12683
|
/* @__PURE__ */ jsx(Tooltip, { content: "Drop files here, or click", children: /* @__PURE__ */ jsx(
|
|
12590
|
-
|
|
12684
|
+
Button,
|
|
12591
12685
|
{
|
|
12592
12686
|
variant: "ghost",
|
|
12593
12687
|
size: "sm",
|
|
@@ -12620,7 +12714,7 @@ function PromptInput({
|
|
|
12620
12714
|
" ",
|
|
12621
12715
|
"to send"
|
|
12622
12716
|
] }),
|
|
12623
|
-
/* @__PURE__ */ jsx(
|
|
12717
|
+
/* @__PURE__ */ jsx(Button, { color: "violet", size: "sm", onClick: submit, children: "send \u2192" })
|
|
12624
12718
|
] })
|
|
12625
12719
|
] })
|
|
12626
12720
|
]
|
|
@@ -13238,7 +13332,7 @@ function Wand({
|
|
|
13238
13332
|
] })
|
|
13239
13333
|
] }),
|
|
13240
13334
|
actions.map((a) => /* @__PURE__ */ jsxs(
|
|
13241
|
-
|
|
13335
|
+
Button,
|
|
13242
13336
|
{
|
|
13243
13337
|
size: "sm",
|
|
13244
13338
|
variant: "ghost",
|
|
@@ -13314,6 +13408,6 @@ function caretRect(ta, start, end) {
|
|
|
13314
13408
|
return { x, y };
|
|
13315
13409
|
}
|
|
13316
13410
|
|
|
13317
|
-
export { Accordion, AccordionPanel, AccordionPanelContent, AccordionPanelSection, AccordionPanelTrigger, Action, Autocomplete, Avatar, Badge, Brand, Breadcrumbs, Calendar, Callout, Card, Carousel, Chart, ChatDrawer, Checkbox, CheckboxGroup, ColorPicker, Command, Composer, ContentRenderer, ContextMenu, DatePicker, Dropdown, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, Emoji, EmojiSelect, Field, FileUpload, Heading, Icon, Input, InputTag, Kanban, MagicWand, Menu2 as Menu, MobileMenu, Modal, MoodMeter, MultiSwitch, Navbar, OtpInput, Pagination, Pillbox, Popover, Portal, Profile, Progress, PromptInput, RadioGroup, ReasonTag, SKIN_TONES, Select, Separator, Sidebar, Skeleton, Slider, StickyNote, Switch, Table, Tabs, Text, Textarea, TimeGrid, TimePicker, Timeline, Toast, Tooltip, TreeNav, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId12 as useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
13411
|
+
export { Accordion, AccordionPanel, AccordionPanelContent, AccordionPanelSection, AccordionPanelTrigger, Action, Autocomplete, Avatar, Badge, Brand, Breadcrumbs, Button, Calendar, Callout, Card, Carousel, Chart, ChatDrawer, Checkbox, CheckboxGroup, ColorPicker, Command, Composer, ContentRenderer, ContextMenu, DatePicker, Dropdown, EMOJI_CATEGORY_ORDER, EMOJI_DATA, EMOJI_ENTRIES, Editor, Emoji, EmojiSelect, FauxClient, Field, FileUpload, Heading, Icon, Input, InputTag, Kanban, MagicWand, Menu2 as Menu, MobileMenu, Modal, MoodMeter, MultiSwitch, Navbar, OtpInput, Pagination, Pillbox, Popover, Portal, Profile, Progress, PromptInput, RadioGroup, ReasonTag, SKIN_TONES, Select, Separator, Sidebar, Skeleton, Slider, StickyNote, Switch, Table, Tabs, Text, Textarea, TimeGrid, TimePicker, Timeline, Toast, Tooltip, TreeNav, applyTone, cn, configureIcons, contentEditableAdapter, controlledAdapter, find, hasSkinTones, inputAdapter, registerExtension, registerExtensions, registerIconSet, registerIcons, resolve, sanitizeHref, sanitizeHtml, search, skinTones, textareaAdapter, useAccordion, useAccordionPanel, useAccordionSection, useAnimation, useCarousel, useCommand, useContextMenu, useControllableState, useDropdown, useEditor, useEscapeKey, useFileUpload, useFloatingPosition, useFocusTrap, useId12 as useId, useKanban, useMenu, useMobileMenu, useModal, useNavbar, useNodeRegistry, useOutsideClick, usePanZoom, usePopover, useSidebar, useTabs, useToast, useTreeNav };
|
|
13318
13412
|
//# sourceMappingURL=index.js.map
|
|
13319
13413
|
//# sourceMappingURL=index.js.map
|