@yuhuanowo/yunui 0.2.8 → 0.2.9
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.
|
@@ -624,7 +624,9 @@ function Combobox({
|
|
|
624
624
|
className = "",
|
|
625
625
|
disabled = false,
|
|
626
626
|
allowCustom = true,
|
|
627
|
-
creatableText
|
|
627
|
+
creatableText,
|
|
628
|
+
creatableFilter,
|
|
629
|
+
creatableIcon
|
|
628
630
|
}) {
|
|
629
631
|
const { Image: Image2, useT } = useYunUI();
|
|
630
632
|
const t = useT("common.combobox");
|
|
@@ -650,9 +652,9 @@ function Combobox({
|
|
|
650
652
|
const filteredOptions = inputValue ? options.filter(
|
|
651
653
|
(o) => o.label.toLowerCase().includes(inputValue.toLowerCase()) || o.value.toLowerCase().includes(inputValue.toLowerCase())
|
|
652
654
|
) : options;
|
|
653
|
-
const canCreateNew = allowCustom && inputValue && !options.some(
|
|
655
|
+
const canCreateNew = allowCustom && !!inputValue && !options.some(
|
|
654
656
|
(o) => o.value.toLowerCase() === inputValue.toLowerCase() || o.label.toLowerCase() === inputValue.toLowerCase()
|
|
655
|
-
);
|
|
657
|
+
) && (!creatableFilter || creatableFilter(inputValue));
|
|
656
658
|
const handleSelect = (selectedValue) => {
|
|
657
659
|
onChange(selectedValue);
|
|
658
660
|
setIsOpen(false);
|
|
@@ -777,7 +779,7 @@ function Combobox({
|
|
|
777
779
|
onClick: () => handleSelect(inputValue),
|
|
778
780
|
className: "\n w-full px-3 py-2 text-left text-sm\n flex items-center gap-2\n text-primary hover:bg-muted/50\n transition-colors\n ",
|
|
779
781
|
children: [
|
|
780
|
-
/* @__PURE__ */ jsx("span", { className: "text-lg", children: "+" }),
|
|
782
|
+
/* @__PURE__ */ jsx("span", { className: "text-lg", children: creatableIcon ?? "+" }),
|
|
781
783
|
/* @__PURE__ */ jsx("span", { children: resolvedCreatableText.replace("{value}", inputValue) })
|
|
782
784
|
]
|
|
783
785
|
}
|
|
@@ -1546,7 +1548,7 @@ function Kbd({ className, ...props }) {
|
|
|
1546
1548
|
);
|
|
1547
1549
|
}
|
|
1548
1550
|
var SearchInput = React7.forwardRef(
|
|
1549
|
-
({ className, value, onChange, clearable = true, clearLabel, disabled, ...props }, ref) => {
|
|
1551
|
+
({ className, value, onChange, clearable = true, clearLabel, disabled, size = "md", ...props }, ref) => {
|
|
1550
1552
|
const innerRef = React7.useRef(null);
|
|
1551
1553
|
const setRef = React7.useCallback(
|
|
1552
1554
|
(node) => {
|
|
@@ -1561,12 +1563,16 @@ var SearchInput = React7.forwardRef(
|
|
|
1561
1563
|
onChange?.("");
|
|
1562
1564
|
innerRef.current?.focus();
|
|
1563
1565
|
};
|
|
1566
|
+
const sm = size === "sm";
|
|
1564
1567
|
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1565
1568
|
/* @__PURE__ */ jsx(
|
|
1566
1569
|
Search,
|
|
1567
1570
|
{
|
|
1568
1571
|
"aria-hidden": "true",
|
|
1569
|
-
className:
|
|
1572
|
+
className: cn(
|
|
1573
|
+
"absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none",
|
|
1574
|
+
sm ? "left-2.5" : "left-3"
|
|
1575
|
+
)
|
|
1570
1576
|
}
|
|
1571
1577
|
),
|
|
1572
1578
|
/* @__PURE__ */ jsx(
|
|
@@ -1579,11 +1585,12 @@ var SearchInput = React7.forwardRef(
|
|
|
1579
1585
|
onChange: (e) => onChange?.(e.target.value),
|
|
1580
1586
|
disabled,
|
|
1581
1587
|
className: cn(
|
|
1582
|
-
"w-full
|
|
1588
|
+
"w-full bg-background border border-border text-sm outline-none transition-colors",
|
|
1583
1589
|
"placeholder:text-muted-foreground",
|
|
1584
1590
|
"focus:border-ring focus:ring-2 focus:ring-ring/20",
|
|
1585
1591
|
"disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1586
|
-
|
|
1592
|
+
sm ? "h-8 rounded-lg pl-8" : "h-10 rounded-xl pl-10",
|
|
1593
|
+
sm ? showClear ? "pr-8" : "pr-3" : showClear ? "pr-10" : "pr-4",
|
|
1587
1594
|
className
|
|
1588
1595
|
),
|
|
1589
1596
|
...props
|
|
@@ -1595,7 +1602,10 @@ var SearchInput = React7.forwardRef(
|
|
|
1595
1602
|
type: "button",
|
|
1596
1603
|
onClick: handleClear,
|
|
1597
1604
|
"aria-label": clearLabel ?? "Clear search",
|
|
1598
|
-
className:
|
|
1605
|
+
className: cn(
|
|
1606
|
+
"absolute top-1/2 -translate-y-1/2 rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1607
|
+
sm ? "right-1.5" : "right-2.5"
|
|
1608
|
+
),
|
|
1599
1609
|
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
1600
1610
|
}
|
|
1601
1611
|
)
|
|
@@ -2948,5 +2958,5 @@ function useYunUITheme(defaults = {}) {
|
|
|
2948
2958
|
}
|
|
2949
2959
|
|
|
2950
2960
|
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, Avatar, AvatarFallback, AvatarGroup, 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, InlineCode, 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, SearchInput, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator2 as Separator, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, StatusIndicator, Steps, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, YUNUI_PALETTES, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme };
|
|
2951
|
-
//# sourceMappingURL=chunk-
|
|
2952
|
-
//# sourceMappingURL=chunk-
|
|
2961
|
+
//# sourceMappingURL=chunk-WJ56QWWZ.js.map
|
|
2962
|
+
//# sourceMappingURL=chunk-WJ56QWWZ.js.map
|