@alpic-ai/ui 0.0.0-dev.gb57f85a → 0.0.0-dev.gb81ad4e
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.
|
@@ -6,7 +6,7 @@ import * as _$class_variance_authority_types0 from "class-variance-authority/typ
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/avatar.d.ts
|
|
8
8
|
declare const avatarVariants: (props?: ({
|
|
9
|
-
size?: "
|
|
9
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
10
10
|
} & _$class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
11
11
|
type AvatarSize = NonNullable<VariantProps<typeof avatarVariants>["size"]>;
|
|
12
12
|
type AvatarStatus = "online";
|
|
@@ -11,6 +11,8 @@ interface ComboboxBaseProps {
|
|
|
11
11
|
open?: boolean;
|
|
12
12
|
defaultOpen?: boolean;
|
|
13
13
|
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
/** Resolves a selected value to a display label (e.g. for multi-select tags). Defaults to the value. */
|
|
15
|
+
getOptionLabel?: (value: string) => string;
|
|
14
16
|
}
|
|
15
17
|
interface ComboboxSingleProps extends ComboboxBaseProps {
|
|
16
18
|
multiple?: false;
|
|
@@ -15,7 +15,7 @@ function useComboboxContext() {
|
|
|
15
15
|
return context;
|
|
16
16
|
}
|
|
17
17
|
function Combobox(props) {
|
|
18
|
-
const { children, multiple = false, open: controlledOpen, defaultOpen = false, onOpenChange: controlledOnOpenChange } = props;
|
|
18
|
+
const { children, multiple = false, open: controlledOpen, defaultOpen = false, onOpenChange: controlledOnOpenChange, getOptionLabel } = props;
|
|
19
19
|
const [uncontrolledSingleValue, setUncontrolledSingleValue] = useState(!multiple ? props.defaultValue ?? null : null);
|
|
20
20
|
const [uncontrolledMultiValue, setUncontrolledMultiValue] = useState(multiple ? props.defaultValue ?? [] : []);
|
|
21
21
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
@@ -77,7 +77,8 @@ function Combobox(props) {
|
|
|
77
77
|
onDeselect,
|
|
78
78
|
isSelected,
|
|
79
79
|
open,
|
|
80
|
-
onOpenChange
|
|
80
|
+
onOpenChange,
|
|
81
|
+
getOptionLabel
|
|
81
82
|
}), [
|
|
82
83
|
multiple,
|
|
83
84
|
singleValue,
|
|
@@ -86,7 +87,8 @@ function Combobox(props) {
|
|
|
86
87
|
onDeselect,
|
|
87
88
|
isSelected,
|
|
88
89
|
open,
|
|
89
|
-
onOpenChange
|
|
90
|
+
onOpenChange,
|
|
91
|
+
getOptionLabel
|
|
90
92
|
]);
|
|
91
93
|
return /* @__PURE__ */ jsx(ComboboxContext.Provider, {
|
|
92
94
|
value: contextValue,
|
|
@@ -120,10 +122,11 @@ function ComboboxTrigger({ className, size, placeholder, children, ...props }) {
|
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
function ComboboxTags({ values, onDeselect }) {
|
|
125
|
+
const { getOptionLabel } = useComboboxContext();
|
|
123
126
|
return /* @__PURE__ */ jsx(Fragment, { children: values.map((tagValue) => /* @__PURE__ */ jsx(TagDismissible, {
|
|
124
127
|
onClick: (event) => event.stopPropagation(),
|
|
125
128
|
onDismiss: () => onDeselect(tagValue),
|
|
126
|
-
children: tagValue
|
|
129
|
+
children: getOptionLabel ? getOptionLabel(tagValue) : tagValue
|
|
127
130
|
}, tagValue)) });
|
|
128
131
|
}
|
|
129
132
|
function ComboboxContent({ className, children, filter, ...props }) {
|
package/package.json
CHANGED
|
@@ -21,6 +21,8 @@ interface ComboboxContextValue {
|
|
|
21
21
|
isSelected: (itemValue: string) => boolean;
|
|
22
22
|
open: boolean;
|
|
23
23
|
onOpenChange: (open: boolean) => void;
|
|
24
|
+
/** Resolves a selected value to a display label (e.g. for multi-select tags). Defaults to the value. */
|
|
25
|
+
getOptionLabel?: (value: string) => string;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const ComboboxContext = createContext<ComboboxContextValue | null>(null);
|
|
@@ -40,6 +42,8 @@ interface ComboboxBaseProps {
|
|
|
40
42
|
open?: boolean;
|
|
41
43
|
defaultOpen?: boolean;
|
|
42
44
|
onOpenChange?: (open: boolean) => void;
|
|
45
|
+
/** Resolves a selected value to a display label (e.g. for multi-select tags). Defaults to the value. */
|
|
46
|
+
getOptionLabel?: (value: string) => string;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
interface ComboboxSingleProps extends ComboboxBaseProps {
|
|
@@ -65,6 +69,7 @@ function Combobox(props: ComboboxProps) {
|
|
|
65
69
|
open: controlledOpen,
|
|
66
70
|
defaultOpen = false,
|
|
67
71
|
onOpenChange: controlledOnOpenChange,
|
|
72
|
+
getOptionLabel,
|
|
68
73
|
} = props;
|
|
69
74
|
|
|
70
75
|
// Single mode state
|
|
@@ -175,8 +180,9 @@ function Combobox(props: ComboboxProps) {
|
|
|
175
180
|
isSelected,
|
|
176
181
|
open,
|
|
177
182
|
onOpenChange,
|
|
183
|
+
getOptionLabel,
|
|
178
184
|
}),
|
|
179
|
-
[multiple, singleValue, multiValues, onSelect, onDeselect, isSelected, open, onOpenChange],
|
|
185
|
+
[multiple, singleValue, multiValues, onSelect, onDeselect, isSelected, open, onOpenChange, getOptionLabel],
|
|
180
186
|
);
|
|
181
187
|
|
|
182
188
|
return (
|
|
@@ -229,6 +235,7 @@ function ComboboxTrigger({ className, size, placeholder, children, ...props }: C
|
|
|
229
235
|
/* ── Tags (internal, for multi-select trigger) ────────────────────────────── */
|
|
230
236
|
|
|
231
237
|
function ComboboxTags({ values, onDeselect }: { values: string[]; onDeselect: (value: string) => void }) {
|
|
238
|
+
const { getOptionLabel } = useComboboxContext();
|
|
232
239
|
return (
|
|
233
240
|
<>
|
|
234
241
|
{values.map((tagValue) => (
|
|
@@ -237,7 +244,7 @@ function ComboboxTags({ values, onDeselect }: { values: string[]; onDeselect: (v
|
|
|
237
244
|
onClick={(event) => event.stopPropagation()}
|
|
238
245
|
onDismiss={() => onDeselect(tagValue)}
|
|
239
246
|
>
|
|
240
|
-
{tagValue}
|
|
247
|
+
{getOptionLabel ? getOptionLabel(tagValue) : tagValue}
|
|
241
248
|
</TagDismissible>
|
|
242
249
|
))}
|
|
243
250
|
</>
|