@yuhuanowo/yunui 0.2.5 → 0.2.6
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 +5 -1
- package/dist/{chunk-THKP6TBK.js → chunk-D2KGK2LY.js} +175 -12
- package/dist/chunk-D2KGK2LY.js.map +1 -0
- package/dist/index.d.ts +34 -2
- package/dist/index.js +1 -1
- package/dist/patterns.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-THKP6TBK.js.map +0 -1
package/README.md
CHANGED
|
@@ -85,9 +85,13 @@ Without a provider, YunUI uses zero-dependency defaults (`<a>` / `<img>` / ident
|
|
|
85
85
|
|
|
86
86
|
## Entry points
|
|
87
87
|
|
|
88
|
+
> See **[ARCHITECTURE.md](./ARCHITECTURE.md)** for the system design — the three
|
|
89
|
+
> layers (core / patterns / app-domain), the design-token system + runtime
|
|
90
|
+
> theming, the adapter pattern, and how to choose among overlapping components.
|
|
91
|
+
|
|
88
92
|
| Entry | Contents |
|
|
89
93
|
| --- | --- |
|
|
90
|
-
| `@yuhuanowo/yunui` | Atomic components: Button / IconButton / Input / Textarea / Card / Badge / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / Label; layout primitives Flex / Grid / Row / Column / Stack; data display Table / Breadcrumb / Pagination; interactive Accordion / RadioGroup / Switch / Checkbox / Combobox / CustomSelect / SegmentedSelect / NavTabs / Collapsible / Popover / Modal / Sheet / ConfirmModal / ThemeToggle; plus ShinyButton / Marquee / BentoGrid / AnimatedNumber and the MotionDiv · fadeIn · stagger animation presets |
|
|
94
|
+
| `@yuhuanowo/yunui` | Atomic components: Button / IconButton / Input / Textarea / PasswordInput / NumberInput / Card / Badge / Kbd / Dialog / Select / Slider / Progress / Tabs / Avatar / Tooltip / DropdownMenu / Skeleton / Spinner / PageLoader / EmptyState / Label; layout primitives Flex / Grid / Row / Column / Stack; data display Table / Breadcrumb / Pagination; interactive Accordion / RadioGroup / Switch / Checkbox / Combobox / CustomSelect / SegmentedSelect / NavTabs / Collapsible / Popover / Modal / Sheet / ConfirmModal / ThemeToggle; plus ShinyButton / Marquee / BentoGrid / AnimatedNumber and the MotionDiv · fadeIn · stagger animation presets |
|
|
91
95
|
| `@yuhuanowo/yunui/css` | Design-system stylesheet (token variables, `@theme` mappings, global `.btn` / `.card` / `.glass` classes, animation keyframes) |
|
|
92
96
|
| `@yuhuanowo/yunui/adapters` | `YunUIProvider` / `useYunUI` and the adapter interfaces |
|
|
93
97
|
| `@yuhuanowo/yunui/patterns` | Page-level components: FAQ, StatCard (`tone` / `inline` / `valueFirst` variants), BlogCard, CodeBlock, Sidebar, PageHeader, BackgroundEffects, and more |
|
|
@@ -12,7 +12,7 @@ import * as ProgressPrimitive from '@radix-ui/react-progress';
|
|
|
12
12
|
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
13
13
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
14
14
|
import { motion, AnimatePresence, useSpring, useTransform } from 'framer-motion';
|
|
15
|
-
import { Check, ChevronDown, ChevronLeft, ChevronRight, Loader2, AlertCircle, X, CheckCircle2, CheckCircle, Info, RefreshCw, Trash2, Search, ArrowRight, AlertTriangle } from 'lucide-react';
|
|
15
|
+
import { Check, ChevronDown, ChevronLeft, ChevronRight, Loader2, AlertCircle, EyeOff, Eye, Minus, Plus, X, CheckCircle2, CheckCircle, Info, RefreshCw, Trash2, Search, ArrowRight, AlertTriangle } from 'lucide-react';
|
|
16
16
|
import { createPortal } from 'react-dom';
|
|
17
17
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
18
18
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
@@ -85,6 +85,43 @@ function useModalBehavior(isOpen, onClose) {
|
|
|
85
85
|
useEscapeKey(onClose, isOpen);
|
|
86
86
|
useBodyScrollLock(isOpen);
|
|
87
87
|
}
|
|
88
|
+
var FOCUSABLE_SELECTOR = 'a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
89
|
+
function useFocusTrap(containerRef, enabled = true) {
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!enabled) return;
|
|
92
|
+
const container = containerRef.current;
|
|
93
|
+
if (!container) return;
|
|
94
|
+
const previouslyFocused = document.activeElement;
|
|
95
|
+
const getFocusable = () => Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
96
|
+
const initial = getFocusable();
|
|
97
|
+
(initial[0] ?? container).focus?.();
|
|
98
|
+
const onKeyDown = (event) => {
|
|
99
|
+
if (event.key !== "Tab") return;
|
|
100
|
+
const items = getFocusable();
|
|
101
|
+
if (items.length === 0) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const first = items[0];
|
|
106
|
+
const last = items[items.length - 1];
|
|
107
|
+
const active = document.activeElement;
|
|
108
|
+
if (event.shiftKey) {
|
|
109
|
+
if (active === first || !container.contains(active)) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
last.focus();
|
|
112
|
+
}
|
|
113
|
+
} else if (active === last || !container.contains(active)) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
first.focus();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
container.addEventListener("keydown", onKeyDown);
|
|
119
|
+
return () => {
|
|
120
|
+
container.removeEventListener("keydown", onKeyDown);
|
|
121
|
+
previouslyFocused?.focus?.();
|
|
122
|
+
};
|
|
123
|
+
}, [enabled, containerRef]);
|
|
124
|
+
}
|
|
88
125
|
|
|
89
126
|
// src/primitives/modal/constants.ts
|
|
90
127
|
var Z_INDEX = {
|
|
@@ -185,14 +222,7 @@ function Modal({
|
|
|
185
222
|
}, []);
|
|
186
223
|
useEscapeKey(handleClose, isOpen);
|
|
187
224
|
useBodyScrollLock(isOpen);
|
|
188
|
-
|
|
189
|
-
if (isOpen && modalRef.current) {
|
|
190
|
-
const timer = setTimeout(() => {
|
|
191
|
-
modalRef.current?.focus();
|
|
192
|
-
}, 0);
|
|
193
|
-
return () => clearTimeout(timer);
|
|
194
|
-
}
|
|
195
|
-
}, [isOpen]);
|
|
225
|
+
useFocusTrap(modalRef, isOpen);
|
|
196
226
|
useEffect(() => {
|
|
197
227
|
if (isOpen && internalIsClosing) {
|
|
198
228
|
setInternalIsClosing(false);
|
|
@@ -1382,6 +1412,139 @@ var Textarea = React7.forwardRef(
|
|
|
1382
1412
|
}
|
|
1383
1413
|
);
|
|
1384
1414
|
Textarea.displayName = "Textarea";
|
|
1415
|
+
var PasswordInput = React7.forwardRef(
|
|
1416
|
+
({ className, error, id, labels, "aria-describedby": describedBy, ...props }, ref) => {
|
|
1417
|
+
const [show, setShow] = React7.useState(false);
|
|
1418
|
+
const reactId = React7.useId();
|
|
1419
|
+
const fieldId = id ?? reactId;
|
|
1420
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
1421
|
+
const describedByIds = [describedBy, errorId].filter(Boolean).join(" ") || void 0;
|
|
1422
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1423
|
+
/* @__PURE__ */ jsx(
|
|
1424
|
+
"input",
|
|
1425
|
+
{
|
|
1426
|
+
ref,
|
|
1427
|
+
id: fieldId,
|
|
1428
|
+
type: show ? "text" : "password",
|
|
1429
|
+
"aria-invalid": error ? true : void 0,
|
|
1430
|
+
"aria-describedby": describedByIds,
|
|
1431
|
+
className: cn(
|
|
1432
|
+
"w-full h-10 px-4 pr-10 bg-background border rounded-xl text-sm outline-none transition-colors",
|
|
1433
|
+
"placeholder:text-muted-foreground focus:border-ring focus:ring-2 focus:ring-ring/20",
|
|
1434
|
+
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1435
|
+
error ? "border-red-300 focus:border-red-400 dark:border-red-700" : "border-border",
|
|
1436
|
+
className
|
|
1437
|
+
),
|
|
1438
|
+
...props
|
|
1439
|
+
}
|
|
1440
|
+
),
|
|
1441
|
+
/* @__PURE__ */ jsx(
|
|
1442
|
+
"button",
|
|
1443
|
+
{
|
|
1444
|
+
type: "button",
|
|
1445
|
+
onClick: () => setShow((s) => !s),
|
|
1446
|
+
"aria-label": show ? labels?.hide ?? "Hide password" : labels?.show ?? "Show password",
|
|
1447
|
+
"aria-pressed": show,
|
|
1448
|
+
tabIndex: -1,
|
|
1449
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1450
|
+
children: show ? /* @__PURE__ */ jsx(EyeOff, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx(Eye, { className: "w-4 h-4" })
|
|
1451
|
+
}
|
|
1452
|
+
),
|
|
1453
|
+
error && /* @__PURE__ */ jsxs("p", { id: errorId, className: "mt-1.5 text-xs text-red-500 flex items-center gap-1", children: [
|
|
1454
|
+
/* @__PURE__ */ jsx(AlertCircle, { "aria-hidden": "true", className: "w-3 h-3" }),
|
|
1455
|
+
error
|
|
1456
|
+
] })
|
|
1457
|
+
] });
|
|
1458
|
+
}
|
|
1459
|
+
);
|
|
1460
|
+
PasswordInput.displayName = "PasswordInput";
|
|
1461
|
+
var NumberInput = React7.forwardRef(
|
|
1462
|
+
({ className, value, onChange, min, max, step = 1, error, disabled, labels, id, "aria-describedby": describedBy, ...props }, ref) => {
|
|
1463
|
+
const reactId = React7.useId();
|
|
1464
|
+
const fieldId = id ?? reactId;
|
|
1465
|
+
const errorId = error ? `${fieldId}-error` : void 0;
|
|
1466
|
+
const describedByIds = [describedBy, errorId].filter(Boolean).join(" ") || void 0;
|
|
1467
|
+
const clamp = (n) => Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n));
|
|
1468
|
+
const base = typeof value === "number" && !Number.isNaN(value) ? value : 0;
|
|
1469
|
+
const bump = (delta) => onChange?.(clamp(base + delta));
|
|
1470
|
+
const atMin = min != null && base <= min;
|
|
1471
|
+
const atMax = max != null && base >= max;
|
|
1472
|
+
const stepBtn = "flex h-10 w-10 shrink-0 items-center justify-center text-muted-foreground hover:text-foreground disabled:opacity-40 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
1473
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1474
|
+
/* @__PURE__ */ jsxs(
|
|
1475
|
+
"div",
|
|
1476
|
+
{
|
|
1477
|
+
className: cn(
|
|
1478
|
+
"relative flex items-stretch rounded-xl border bg-background transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring/20",
|
|
1479
|
+
error ? "border-red-300 dark:border-red-700" : "border-border",
|
|
1480
|
+
disabled && "opacity-50",
|
|
1481
|
+
className
|
|
1482
|
+
),
|
|
1483
|
+
children: [
|
|
1484
|
+
/* @__PURE__ */ jsx(
|
|
1485
|
+
"button",
|
|
1486
|
+
{
|
|
1487
|
+
type: "button",
|
|
1488
|
+
onClick: () => bump(-step),
|
|
1489
|
+
disabled: disabled || atMin,
|
|
1490
|
+
"aria-label": labels?.decrement ?? "Decrease",
|
|
1491
|
+
className: cn(stepBtn, "rounded-l-xl"),
|
|
1492
|
+
children: /* @__PURE__ */ jsx(Minus, { className: "w-4 h-4" })
|
|
1493
|
+
}
|
|
1494
|
+
),
|
|
1495
|
+
/* @__PURE__ */ jsx(
|
|
1496
|
+
"input",
|
|
1497
|
+
{
|
|
1498
|
+
ref,
|
|
1499
|
+
id: fieldId,
|
|
1500
|
+
type: "number",
|
|
1501
|
+
inputMode: "numeric",
|
|
1502
|
+
value: typeof value === "number" ? value : "",
|
|
1503
|
+
onChange: (e) => onChange?.(e.target.value === "" ? base : clamp(Number(e.target.value))),
|
|
1504
|
+
min,
|
|
1505
|
+
max,
|
|
1506
|
+
step,
|
|
1507
|
+
disabled,
|
|
1508
|
+
"aria-invalid": error ? true : void 0,
|
|
1509
|
+
"aria-describedby": describedByIds,
|
|
1510
|
+
className: "w-full min-w-0 bg-transparent px-1 text-center text-sm outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
1511
|
+
...props
|
|
1512
|
+
}
|
|
1513
|
+
),
|
|
1514
|
+
/* @__PURE__ */ jsx(
|
|
1515
|
+
"button",
|
|
1516
|
+
{
|
|
1517
|
+
type: "button",
|
|
1518
|
+
onClick: () => bump(step),
|
|
1519
|
+
disabled: disabled || atMax,
|
|
1520
|
+
"aria-label": labels?.increment ?? "Increase",
|
|
1521
|
+
className: cn(stepBtn, "rounded-r-xl"),
|
|
1522
|
+
children: /* @__PURE__ */ jsx(Plus, { className: "w-4 h-4" })
|
|
1523
|
+
}
|
|
1524
|
+
)
|
|
1525
|
+
]
|
|
1526
|
+
}
|
|
1527
|
+
),
|
|
1528
|
+
error && /* @__PURE__ */ jsxs("p", { id: errorId, className: "mt-1.5 text-xs text-red-500 flex items-center gap-1", children: [
|
|
1529
|
+
/* @__PURE__ */ jsx(AlertCircle, { "aria-hidden": "true", className: "w-3 h-3" }),
|
|
1530
|
+
error
|
|
1531
|
+
] })
|
|
1532
|
+
] });
|
|
1533
|
+
}
|
|
1534
|
+
);
|
|
1535
|
+
NumberInput.displayName = "NumberInput";
|
|
1536
|
+
function Kbd({ className, ...props }) {
|
|
1537
|
+
return /* @__PURE__ */ jsx(
|
|
1538
|
+
"kbd",
|
|
1539
|
+
{
|
|
1540
|
+
className: cn(
|
|
1541
|
+
"inline-flex h-5 min-w-5 items-center justify-center rounded border border-border bg-muted px-1.5 font-mono text-[11px] font-medium text-muted-foreground",
|
|
1542
|
+
className
|
|
1543
|
+
),
|
|
1544
|
+
...props
|
|
1545
|
+
}
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1385
1548
|
var Card = React7.forwardRef(
|
|
1386
1549
|
({ className, hover, ...props }, ref) => {
|
|
1387
1550
|
return /* @__PURE__ */ jsx(
|
|
@@ -2547,6 +2710,6 @@ function useYunUITheme(defaults = {}) {
|
|
|
2547
2710
|
return [theme, update];
|
|
2548
2711
|
}
|
|
2549
2712
|
|
|
2550
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AnimatedNumber, Avatar, AvatarFallback, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Column, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, Input, Label2 as Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, PageLoader, Pagination, Popover, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, YUNUI_PALETTES, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useModalBehavior, useYunUITheme };
|
|
2551
|
-
//# sourceMappingURL=chunk-
|
|
2552
|
-
//# sourceMappingURL=chunk-
|
|
2713
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, AnimatedNumber, Avatar, AvatarFallback, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Column, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, Input, Kbd, Label2 as Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, NumberInput, PageLoader, Pagination, PasswordInput, Popover, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, YUNUI_PALETTES, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme };
|
|
2714
|
+
//# sourceMappingURL=chunk-D2KGK2LY.js.map
|
|
2715
|
+
//# sourceMappingURL=chunk-D2KGK2LY.js.map
|