@neasg/design-system 0.4.31 → 0.4.33
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/multi-select.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface MultiSelectProps {
|
|
|
20
20
|
searchPlaceholder?: string;
|
|
21
21
|
/** Cap how many selected tags render in the trigger; the rest collapse into a `+N` badge. */
|
|
22
22
|
maxVisibleTags?: number;
|
|
23
|
+
/** Show a "Clear" button in the dropdown footer when items are selected. */
|
|
24
|
+
clearable?: boolean;
|
|
23
25
|
className?: string;
|
|
24
26
|
triggerClassName?: string;
|
|
25
27
|
labelClassName?: string;
|
|
@@ -27,5 +29,5 @@ export interface MultiSelectProps {
|
|
|
27
29
|
errorClassName?: string;
|
|
28
30
|
id?: string;
|
|
29
31
|
}
|
|
30
|
-
declare function MultiSelect({ label, options, value, onValueChange, placeholder, description, error, invalid, disabled, hideLabel, searchable, searchPlaceholder, maxVisibleTags, className, triggerClassName, labelClassName, descriptionClassName, errorClassName, id, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
declare function MultiSelect({ label, options, value, onValueChange, placeholder, description, error, invalid, disabled, hideLabel, searchable, searchPlaceholder, maxVisibleTags, clearable, className, triggerClassName, labelClassName, descriptionClassName, errorClassName, id, }: MultiSelectProps): import("react/jsx-runtime").JSX.Element;
|
|
31
33
|
export { MultiSelect };
|
package/dist/multi-select.js
CHANGED
|
@@ -8,10 +8,10 @@ import { Field, FieldDescription, FieldError, FieldLabel } from "./field";
|
|
|
8
8
|
import { Checkbox } from "./checkbox";
|
|
9
9
|
import { cn } from "./lib/utils";
|
|
10
10
|
import { Popover } from "./popover";
|
|
11
|
-
import { PopoverMenuSearch } from "./popover-menu";
|
|
11
|
+
import { PopoverMenuFooter, PopoverMenuFooterAction, PopoverMenuSearch } from "./popover-menu";
|
|
12
12
|
import { Typography } from "./typography";
|
|
13
13
|
import { SearchHighlight } from "./use-search-highlight";
|
|
14
|
-
function MultiSelect({ label, options, value, onValueChange, placeholder = "Select options", description, error, invalid = false, disabled = false, hideLabel = false, searchable = false, searchPlaceholder = "Search...", maxVisibleTags = 2, className, triggerClassName, labelClassName, descriptionClassName, errorClassName, id, }) {
|
|
14
|
+
function MultiSelect({ label, options, value, onValueChange, placeholder = "Select options", description, error, invalid = false, disabled = false, hideLabel = false, searchable = false, searchPlaceholder = "Search...", maxVisibleTags = 2, clearable = false, className, triggerClassName, labelClassName, descriptionClassName, errorClassName, id, }) {
|
|
15
15
|
const generatedId = React.useId();
|
|
16
16
|
const selectId = id !== null && id !== void 0 ? id : `multi-select-${generatedId}`;
|
|
17
17
|
const labelId = `${selectId}-label`;
|
|
@@ -179,6 +179,6 @@ function MultiSelect({ label, options, value, onValueChange, placeholder = "Sele
|
|
|
179
179
|
const isSelected = value.includes(option.value);
|
|
180
180
|
return (_jsxs("button", { type: "button", role: "option", "aria-selected": isSelected, disabled: option.disabled, tabIndex: -1, onClick: () => toggleOption(option.value), className: cn("flex min-h-8 w-full cursor-pointer items-center gap-1.5 rounded-sm px-2 py-1.5 text-left text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50", isSelected &&
|
|
181
181
|
"bg-highlight text-highlight-foreground hover:bg-highlight/80 hover:text-highlight-foreground focus:bg-highlight/80 focus:text-highlight-foreground"), children: [_jsx(Checkbox, { checked: isSelected, disabled: option.disabled, tabIndex: -1, readOnly: true, "aria-hidden": "true", className: "mt-0.5" }), _jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsx(SearchHighlight, { text: option.label, query: searchQuery }), option.description ? (_jsx(Typography, { as: "span", variant: "caption", children: _jsx(SearchHighlight, { text: option.description, query: searchQuery }) })) : null] })] }, option.value));
|
|
182
|
-
})) : (_jsx("div", { className: "px-2.5 py-1.5 text-center text-sm text-muted-foreground", children: "No options found." })) })] }), showDescription ? (_jsx(FieldDescription, { id: descriptionId, className: descriptionClassName, children: description })) : null, _jsx(FieldError, { id: errorId, className: errorClassName, children: error })] }));
|
|
182
|
+
})) : (_jsx("div", { className: "px-2.5 py-1.5 text-center text-sm text-muted-foreground", children: "No options found." })) }), clearable && value.length > 0 ? (_jsx(PopoverMenuFooter, { children: _jsx(PopoverMenuFooterAction, { onClick: () => onValueChange([]), children: "Clear" }) })) : null] }), showDescription ? (_jsx(FieldDescription, { id: descriptionId, className: descriptionClassName, children: description })) : null, _jsx(FieldError, { id: errorId, className: errorClassName, children: error })] }));
|
|
183
183
|
}
|
|
184
184
|
export { MultiSelect };
|
package/dist/select-primitive.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
5
|
-
import { Check,
|
|
5
|
+
import { Check, ChevronUp } from "lucide-react";
|
|
6
|
+
import { ChevronDownIcon } from "./animated-icons/chevron-down";
|
|
6
7
|
import { cn } from "./lib/utils";
|
|
7
8
|
import { Typography } from "./typography";
|
|
8
9
|
function SelectRoot(props) {
|
|
@@ -14,11 +15,11 @@ function SelectGroup(props) {
|
|
|
14
15
|
function SelectValue(props) {
|
|
15
16
|
return _jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
16
17
|
}
|
|
17
|
-
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, "data-slot": "select-trigger", className: cn("flex h-control w-full cursor-pointer items-center justify-between gap-1.5 whitespace-nowrap rounded-control border border-input bg-background px-2.5 py-1.5 text-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(
|
|
18
|
+
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, "data-slot": "select-trigger", className: cn("flex h-control w-full cursor-pointer items-center justify-between gap-1.5 whitespace-nowrap rounded-control border border-input bg-background px-2.5 py-1.5 text-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-[invalid=true]:border-destructive aria-[invalid=true]:ring-destructive/20 data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1 [&_svg]:pointer-events-none [&_svg]:shrink-0", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDownIcon, { size: 16, className: "shrink-0 text-muted-foreground transition-transform duration-150 [[data-state=open]>&]:rotate-180" }) })] })));
|
|
18
19
|
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
19
20
|
const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, "data-slot": "select-scroll-up-button", className: cn("flex cursor-pointer items-center justify-center py-1", className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
|
|
20
21
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
21
|
-
const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, "data-slot": "select-scroll-down-button", className: cn("flex cursor-pointer items-center justify-center py-1", className), ...props, children: _jsx(
|
|
22
|
+
const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, "data-slot": "select-scroll-down-button", className: cn("flex cursor-pointer items-center justify-center py-1", className), ...props, children: _jsx(ChevronDownIcon, { size: 16 }) })));
|
|
22
23
|
SelectScrollDownButton.displayName =
|
|
23
24
|
SelectPrimitive.ScrollDownButton.displayName;
|
|
24
25
|
const SelectContent = React.forwardRef(({ className, children, header, position = "popper", viewportClassName, ...props }, ref) => {
|