@kushagradhawan/kookie-ui 0.1.65 → 0.1.67
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/components.css +27 -19
- package/dist/cjs/components/combobox.d.ts +45 -0
- package/dist/cjs/components/combobox.d.ts.map +1 -1
- package/dist/cjs/components/combobox.js +1 -1
- package/dist/cjs/components/combobox.js.map +3 -3
- package/dist/cjs/components/combobox.props.d.ts +26 -17
- package/dist/cjs/components/combobox.props.d.ts.map +1 -1
- package/dist/cjs/components/combobox.props.js +1 -1
- package/dist/cjs/components/combobox.props.js.map +2 -2
- package/dist/esm/components/combobox.d.ts +45 -0
- package/dist/esm/components/combobox.d.ts.map +1 -1
- package/dist/esm/components/combobox.js +1 -1
- package/dist/esm/components/combobox.js.map +3 -3
- package/dist/esm/components/combobox.props.d.ts +26 -17
- package/dist/esm/components/combobox.props.d.ts.map +1 -1
- package/dist/esm/components/combobox.props.js +1 -1
- package/dist/esm/components/combobox.props.js.map +2 -2
- package/package.json +1 -1
- package/schemas/base-button.json +1 -1
- package/schemas/button.json +1 -1
- package/schemas/icon-button.json +1 -1
- package/schemas/index.json +6 -6
- package/schemas/toggle-button.json +1 -1
- package/schemas/toggle-icon-button.json +1 -1
- package/src/components/chatbar.css +3 -3
- package/src/components/combobox.css +19 -9
- package/src/components/combobox.props.tsx +11 -2
- package/src/components/combobox.tsx +132 -27
- package/styles.css +27 -19
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combobox is a compound component built on top of Popover and cmdk's Command list.
|
|
3
|
+
* It mirrors the Select API while adding search-first behaviors including filtering,
|
|
4
|
+
* async-friendly state management, and design token support for trigger, content,
|
|
5
|
+
* and input variants.
|
|
6
|
+
*/
|
|
1
7
|
import * as React from 'react';
|
|
2
8
|
import { Command as CommandPrimitive } from 'cmdk';
|
|
3
9
|
import { comboboxRootPropDefs, comboboxTriggerPropDefs, comboboxContentPropDefs } from './combobox.props.js';
|
|
@@ -9,6 +15,9 @@ import type { GetPropDefTypes } from '../props/prop-def.js';
|
|
|
9
15
|
type TextFieldVariant = (typeof textFieldRootPropDefs.variant.values)[number];
|
|
10
16
|
type ComboboxValue = string | null;
|
|
11
17
|
type CommandFilter = (value: string, search: string, keywords?: string[]) => number;
|
|
18
|
+
/**
|
|
19
|
+
* Additional props supported by Combobox.Root beyond the Radix Popover surface.
|
|
20
|
+
*/
|
|
12
21
|
type ComboboxRootOwnProps = GetPropDefTypes<typeof comboboxRootPropDefs> & {
|
|
13
22
|
value?: ComboboxValue;
|
|
14
23
|
defaultValue?: ComboboxValue;
|
|
@@ -29,46 +38,82 @@ type ComboboxRootOwnProps = GetPropDefTypes<typeof comboboxRootPropDefs> & {
|
|
|
29
38
|
type PopoverRootProps = React.ComponentPropsWithoutRef<typeof Popover.Root>;
|
|
30
39
|
interface ComboboxRootProps extends PopoverRootProps, ComboboxRootOwnProps {
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Root component that wires up Popover behavior, controllable state,
|
|
43
|
+
* and shared context for trigger/content/input sub-components.
|
|
44
|
+
*/
|
|
32
45
|
declare const ComboboxRoot: React.FC<ComboboxRootProps>;
|
|
33
46
|
type ComboboxTriggerOwnProps = GetPropDefTypes<typeof comboboxTriggerPropDefs>;
|
|
34
47
|
type NativeTriggerProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'color'>;
|
|
35
48
|
interface ComboboxTriggerProps extends NativeTriggerProps, MarginProps, ComboboxTriggerOwnProps {
|
|
36
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Trigger behaves like a styled button that opens the Popover,
|
|
52
|
+
* syncing size/highContrast from Root while exposing select-like states.
|
|
53
|
+
*/
|
|
37
54
|
declare const ComboboxTrigger: React.ForwardRefExoticComponent<ComboboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
38
55
|
interface ComboboxValueProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
39
56
|
placeholder?: string;
|
|
40
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Value mirrors Select.Value by showing the selected item's label
|
|
60
|
+
* or falling back to placeholder text supplied by the consumer or context.
|
|
61
|
+
*/
|
|
41
62
|
declare const ComboboxValue: React.ForwardRefExoticComponent<ComboboxValueProps & React.RefAttributes<HTMLSpanElement>>;
|
|
42
63
|
type ComboboxContentOwnProps = GetPropDefTypes<typeof comboboxContentPropDefs> & {
|
|
43
64
|
container?: React.ComponentPropsWithoutRef<typeof Popover.Content>['container'];
|
|
44
65
|
};
|
|
45
66
|
interface ComboboxContentProps extends Omit<ComponentPropsWithout<typeof Popover.Content, RemovedProps>, 'size'>, ComboboxContentOwnProps {
|
|
46
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Content renders the dropdown surface, syncing tokens from the current Theme
|
|
70
|
+
* and instantiating cmdk's Command list for roving focus + filtering.
|
|
71
|
+
*/
|
|
47
72
|
declare const ComboboxContent: React.ForwardRefExoticComponent<ComboboxContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
48
73
|
interface ComboboxInputProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> {
|
|
49
74
|
startAdornment?: React.ReactNode;
|
|
50
75
|
endAdornment?: React.ReactNode;
|
|
51
76
|
variant?: TextFieldVariant;
|
|
52
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Input composes TextField tokens with cmdk's Command.Input to provide
|
|
80
|
+
* automatic focus management and optional adornments.
|
|
81
|
+
*/
|
|
53
82
|
declare const ComboboxInput: React.ForwardRefExoticComponent<ComboboxInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
54
83
|
interface ComboboxListProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.List> {
|
|
55
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* List wraps cmdk's Command.List to inherit base menu styles and provides ScrollArea for the items.
|
|
87
|
+
*/
|
|
56
88
|
declare const ComboboxList: React.ForwardRefExoticComponent<ComboboxListProps & React.RefAttributes<HTMLDivElement>>;
|
|
57
89
|
interface ComboboxEmptyProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> {
|
|
58
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Empty renders when no options match the search query.
|
|
93
|
+
*/
|
|
59
94
|
declare const ComboboxEmpty: React.ForwardRefExoticComponent<ComboboxEmptyProps & React.RefAttributes<HTMLDivElement>>;
|
|
60
95
|
interface ComboboxGroupProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group> {
|
|
61
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Group and Label mirror menu semantics for subheadings inside the list.
|
|
99
|
+
*/
|
|
62
100
|
declare const ComboboxGroup: React.ForwardRefExoticComponent<ComboboxGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
63
101
|
interface ComboboxLabelProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
64
102
|
}
|
|
65
103
|
declare const ComboboxLabel: React.ForwardRefExoticComponent<ComboboxLabelProps & React.RefAttributes<HTMLDivElement>>;
|
|
66
104
|
interface ComboboxSeparatorProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> {
|
|
67
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Separator visually divides logical sections of the option list.
|
|
108
|
+
*/
|
|
68
109
|
declare const ComboboxSeparator: React.ForwardRefExoticComponent<ComboboxSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
69
110
|
interface ComboboxItemProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item> {
|
|
70
111
|
label?: string;
|
|
71
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Item wires cmdk's selection handling with Kookie UI tokens and
|
|
115
|
+
* ensures labels are registered for displaying the current value.
|
|
116
|
+
*/
|
|
72
117
|
declare const ComboboxItem: React.ForwardRefExoticComponent<ComboboxItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
73
118
|
export { ComboboxRoot as Root, ComboboxTrigger as Trigger, ComboboxValue as Value, ComboboxContent as Content, ComboboxInput as Input, ComboboxList as List, ComboboxEmpty as Empty, ComboboxGroup as Group, ComboboxLabel as Label, ComboboxSeparator as Separator, ComboboxItem as Item, };
|
|
74
119
|
export type { ComboboxRootProps as RootProps, ComboboxTriggerProps as TriggerProps, ComboboxContentProps as ContentProps, ComboboxInputProps as InputProps, ComboboxListProps as ListProps, ComboboxEmptyProps as EmptyProps, ComboboxGroupProps as GroupProps, ComboboxLabelProps as LabelProps, ComboboxSeparatorProps as SeparatorProps, ComboboxItemProps as ItemProps, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../../src/components/combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAGnD,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAK7G,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,gBAAgB,GAAG,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9E,KAAK,aAAa,GAAG,MAAM,GAAG,IAAI,CAAC;AACnC,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;AAEpF,KAAK,oBAAoB,GAAG,eAAe,CAAC,OAAO,oBA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AU,EAChC,kBAAkB,IAAI,UAAU,EAChC,kBAAkB,IAAI,UAAU,EAChC,sBAAsB,IAAI,cAAc,EACxC,iBAAiB,IAAI,SAAS,GAC/B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import*as o from"react";import b from"classnames";import{useControllableState as
|
|
1
|
+
"use client";import*as o from"react";import b from"classnames";import{useControllableState as z}from"radix-ui/internal";import{Command as y}from"cmdk";import{extractProps as W}from"../helpers/extract-props.js";import{comboboxRootPropDefs as N,comboboxTriggerPropDefs as to,comboboxContentPropDefs as T}from"./combobox.props.js";import{marginPropDefs as ro}from"../props/margin.props.js";import{ChevronDownIcon as ao,ThickCheckIcon as no}from"./icons.js";import{Theme as so,useThemeContext as io}from"./theme.js";import{requireReactElement as lo}from"../helpers/require-react-element.js";import*as M from"./popover.js";import{ScrollArea as mo}from"./scroll-area.js";import{Slottable as bo}from"./slot.js";import"./text-field.props.js";const A=o.createContext(null),I=t=>{const r=o.useContext(A);if(!r)throw new Error(`${t} must be used within Combobox.Root`);return r},j=o.createContext(null),$=()=>o.useContext(j),H=t=>{const{children:r,size:e=N.size.default,highContrast:a=N.highContrast.default,value:p,defaultValue:i=null,onValueChange:c,open:l,defaultOpen:s=!1,onOpenChange:d,placeholder:C="Select an option",searchPlaceholder:u="Search options...",searchValue:x,defaultSearchValue:f="",onSearchValueChange:P,filter:m,shouldFilter:g=!0,loop:n=!0,disabled:h,...L}=t,[E,v]=z({prop:l,defaultProp:s,onChange:d}),[R,S]=z({prop:p,defaultProp:i,onChange:c}),[k,V]=z({prop:x,defaultProp:f,onChange:P}),D=o.useRef(new Map),F=o.useCallback((w,eo)=>{D.current.set(w,eo)},[]),G=R!=null?D.current.get(R):void 0,B=o.useCallback(w=>{S(w),v(!1),V("")},[v,V,S]),oo=o.useMemo(()=>({size:e,highContrast:a,placeholder:C,searchPlaceholder:u,filter:m,shouldFilter:g,loop:n,disabled:h,open:E,setOpen:v,value:R,setValue:S,searchValue:k,setSearchValue:V,selectedLabel:G,registerItemLabel:F,handleSelect:B}),[e,a,C,u,m,g,n,h,E,v,R,S,k,V,G,F,B]);return o.createElement(A.Provider,{value:oo},o.createElement(M.Root,{open:E,onOpenChange:v,...L},r))};H.displayName="Combobox.Root";const q=o.forwardRef((t,r)=>{const e=I("Combobox.Trigger"),{children:a,className:p,placeholder:i,disabled:c,readOnly:l,error:s,loading:d,color:C,radius:u,...x}=W({size:e.size,highContrast:e.highContrast,...t},{size:N.size,highContrast:N.highContrast},to,ro),{material:f,panelBackground:P}=t,m=c??e.disabled,g=o.useMemo(()=>({"aria-expanded":e.open,"aria-disabled":m||void 0,"aria-haspopup":"listbox"}),[e.open,m]),n=o.createElement(o.Fragment,null,o.createElement("span",{className:"rt-SelectTriggerInner"},o.createElement(O,{placeholder:i??e.placeholder})),d?o.createElement("div",{className:"rt-SelectIcon rt-SelectLoadingIcon","aria-hidden":"true"},o.createElement("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},o.createElement("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeDasharray:"6 34",strokeDashoffset:"0",className:"rt-SelectLoadingSpinner"}))):o.createElement(ao,{className:"rt-SelectIcon"})),{type:h,...L}=x,v=o.createElement("button",{"data-accent-color":C,"data-radius":u,"data-panel-background":P,"data-material":f,"data-error":s,"data-loading":d,"data-disabled":m||void 0,"data-read-only":l||void 0,...L,...g,type:h??"button",disabled:m,ref:r,className:b("rt-reset","rt-SelectTrigger","rt-ComboboxTrigger",p)},a?lo(a):n);return o.createElement(M.Trigger,{disabled:m},v)});q.displayName="Combobox.Trigger";const O=o.forwardRef(({placeholder:t,children:r,className:e,...a},p)=>{const i=I("Combobox.Value"),c=i.selectedLabel??i.value??void 0,l=t??i.placeholder;return o.createElement("span",{...a,ref:p,className:b("rt-ComboboxValue",e)},c??r??l)});O.displayName="Combobox.Value";const J=o.forwardRef((t,r)=>{const e=I("Combobox.Content"),a=io(),p=a.panelBackground,i=t.size??e.size??T.size.default,c=t.variant??T.variant.default,l=t.highContrast??e.highContrast??T.highContrast.default,{className:s,children:d,color:C,forceMount:u,container:x,...f}=W({...t,size:i,variant:c,highContrast:l},T),P=C||a.accentColor;let m=s;return typeof i=="string"&&(m=s?.split(/\s+/).filter(Boolean).filter(g=>!/^rt-r-size-\d$/.test(g)).join(" ")||void 0),o.createElement(M.Content,{size:i,"data-accent-color":P,"data-material":p,"data-panel-background":p,align:"start",sideOffset:4,collisionPadding:10,...f,forceMount:u,container:x,ref:r,className:b("rt-PopperContent","rt-BaseMenuContent","rt-ComboboxContent",m)},o.createElement(so,{asChild:!0},o.createElement(j.Provider,{value:{variant:c,size:String(i),color:P,material:p,highContrast:l}},o.createElement(y,{loop:e.loop,value:e.searchValue,onValueChange:e.setSearchValue,shouldFilter:e.shouldFilter,filter:e.filter,className:"rt-ComboboxCommand"},d))))});J.displayName="Combobox.Content";const K=o.forwardRef(({className:t,startAdornment:r,endAdornment:e,placeholder:a,variant:p,...i},c)=>{const l=I("Combobox.Input"),s=$(),d=s?.variant??"solid",C=s?.color,u=s?.material,x=p??(d==="solid"?"surface":"soft"),f=o.createElement("div",{className:b("rt-TextFieldRoot","rt-ComboboxInputRoot",`rt-r-size-${l.size}`,`rt-variant-${x}`),"data-accent-color":C,"data-material":u,"data-panel-background":u},r?o.createElement("div",{className:"rt-TextFieldSlot"},r):null,o.createElement(y.Input,{...i,ref:c,placeholder:a??l.searchPlaceholder,className:b("rt-reset","rt-TextFieldInput",t)}),e?o.createElement("div",{className:"rt-TextFieldSlot","data-side":"right"},e):null);return s?o.createElement("div",{className:"rt-ComboboxSearch"},f):f});K.displayName="Combobox.Input";const Q=o.forwardRef(({className:t,...r},e)=>o.createElement(mo,{type:"auto",className:"rt-ComboboxScrollArea",scrollbars:"vertical",size:"1"},o.createElement("div",{className:b("rt-BaseMenuViewport","rt-ComboboxViewport")},o.createElement(y.List,{...r,ref:e,className:b("rt-ComboboxList",t)}))));Q.displayName="Combobox.List";const U=o.forwardRef(({className:t,...r},e)=>o.createElement(y.Empty,{...r,ref:e,className:b("rt-ComboboxEmpty",t)}));U.displayName="Combobox.Empty";const X=o.forwardRef(({className:t,...r},e)=>o.createElement(y.Group,{...r,ref:e,className:b("rt-BaseMenuGroup","rt-ComboboxGroup",t)}));X.displayName="Combobox.Group";const Y=o.forwardRef(({className:t,...r},e)=>o.createElement("div",{...r,ref:e,className:b("rt-BaseMenuLabel","rt-ComboboxLabel",t)}));Y.displayName="Combobox.Label";const Z=o.forwardRef(({className:t,...r},e)=>o.createElement(y.Separator,{...r,ref:e,className:b("rt-BaseMenuSeparator","rt-ComboboxSeparator",t)}));Z.displayName="Combobox.Separator";const _=o.forwardRef(({className:t,children:r,label:e,value:a,disabled:p,onSelect:i,...c},l)=>{const s=I("Combobox.Item"),d=$(),C=e??(typeof r=="string"?r:String(a)),u=a!=null&&s.value===a,x=d?.size?`rt-r-size-${d.size}`:void 0;o.useEffect(()=>{a&&s.registerItemLabel(a,C)},[s,a,C]);const f=o.useCallback(n=>{s.handleSelect(n),i?.(n)},[s,i]),P=p??s.disabled??!1,m=o.useRef(null),g=o.useCallback(n=>{m.current=n,typeof l=="function"?l(n):l&&(l.current=n)},[l]);return o.useEffect(()=>{if(!P&&m.current){const n=m.current;(n.getAttribute("data-disabled")==="false"||n.getAttribute("data-disabled")==="")&&n.removeAttribute("data-disabled");const h=new MutationObserver(()=>{(n.getAttribute("data-disabled")==="false"||n.getAttribute("data-disabled")==="")&&n.removeAttribute("data-disabled")});return h.observe(n,{attributes:!0,attributeFilter:["data-disabled"]}),()=>h.disconnect()}},[P]),o.createElement(y.Item,{...c,value:a,...P?{disabled:!0}:{},ref:g,onSelect:f,className:b("rt-reset","rt-BaseMenuItem","rt-ComboboxItem",t)},u?o.createElement("span",{className:b("rt-BaseMenuItemIndicator","rt-ComboboxItemIndicator",x)},o.createElement(no,{className:b("rt-BaseMenuItemIndicatorIcon","rt-ComboboxItemIndicatorIcon",x)})):null,o.createElement(bo,null,r))});_.displayName="Combobox.Item";export{J as Content,U as Empty,X as Group,K as Input,_ as Item,Y as Label,Q as List,H as Root,Z as Separator,q as Trigger,O as Value};
|
|
2
2
|
//# sourceMappingURL=combobox.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/combobox.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { useControllableState } from 'radix-ui/internal';\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { extractProps } from '../helpers/extract-props.js';\nimport { comboboxRootPropDefs, comboboxTriggerPropDefs, comboboxContentPropDefs } from './combobox.props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\nimport { ChevronDownIcon, ThickCheckIcon } from './icons.js';\nimport { Theme, useThemeContext } from './theme.js';\nimport { requireReactElement } from '../helpers/require-react-element.js';\nimport * as Popover from './popover.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Slottable } from './slot.js';\nimport { textFieldRootPropDefs } from './text-field.props.js';\n\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\n\ntype TextFieldVariant = (typeof textFieldRootPropDefs.variant.values)[number];\ntype ComboboxValue = string | null;\ntype CommandFilter = (value: string, search: string, keywords?: string[]) => number;\n\ntype ComboboxRootOwnProps = GetPropDefTypes<typeof comboboxRootPropDefs> & {\n value?: ComboboxValue;\n defaultValue?: ComboboxValue;\n onValueChange?: (value: ComboboxValue) => void;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n placeholder?: string;\n searchPlaceholder?: string;\n searchValue?: string;\n defaultSearchValue?: string;\n onSearchValueChange?: (value: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loop?: boolean;\n disabled?: boolean;\n};\n\ninterface ComboboxContextValue extends ComboboxRootOwnProps {\n open: boolean;\n setOpen: (open: boolean) => void;\n value: ComboboxValue;\n setValue: (value: ComboboxValue) => void;\n searchValue: string;\n setSearchValue: (value: string) => void;\n selectedLabel?: string;\n registerItemLabel: (value: string, label: string) => void;\n handleSelect: (value: string) => void;\n}\n\nconst ComboboxContext = React.createContext<ComboboxContextValue | null>(null);\nconst useComboboxContext = (caller: string) => {\n const ctx = React.useContext(ComboboxContext);\n if (!ctx) {\n throw new Error(`${caller} must be used within Combobox.Root`);\n }\n return ctx;\n};\n\nconst ComboboxContentContext = React.createContext<{ variant: 'solid' | 'soft'; size?: string; color?: string; material?: string } | null>(null);\nconst useComboboxContentContext = () => {\n const ctx = React.useContext(ComboboxContentContext);\n return ctx; // Optional - Input might not always be in Content\n};\n\ntype PopoverRootProps = React.ComponentPropsWithoutRef<typeof Popover.Root>;\ninterface ComboboxRootProps extends PopoverRootProps, ComboboxRootOwnProps {}\nconst ComboboxRoot: React.FC<ComboboxRootProps> = (props) => {\n const {\n children,\n size = comboboxRootPropDefs.size.default,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placeholder = 'Select an option',\n searchPlaceholder = 'Search options...',\n searchValue: searchValueProp,\n defaultSearchValue = '',\n onSearchValueChange,\n filter,\n shouldFilter = true,\n loop = true,\n disabled,\n ...rootProps\n } = props;\n\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const [value, setValue] = useControllableState<ComboboxValue>({\n prop: valueProp ?? null,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const [searchValue, setSearchValue] = useControllableState<string>({\n prop: searchValueProp,\n defaultProp: defaultSearchValue,\n onChange: onSearchValueChange,\n });\n\n const labelMapRef = React.useRef(new Map<string, string>());\n const registerItemLabel = React.useCallback((itemValue: string, label: string) => {\n labelMapRef.current.set(itemValue, label);\n }, []);\n\n const selectedLabel = value != null ? labelMapRef.current.get(value) : undefined;\n\n const handleSelect = React.useCallback(\n (nextValue: string) => {\n setValue(nextValue);\n setOpen(false);\n setSearchValue('');\n },\n [setOpen, setSearchValue, setValue],\n );\n\n const contextValue = React.useMemo<ComboboxContextValue>(\n () => ({\n size,\n placeholder,\n searchPlaceholder,\n filter,\n shouldFilter,\n loop,\n disabled,\n open,\n setOpen,\n value,\n setValue,\n searchValue,\n setSearchValue,\n selectedLabel,\n registerItemLabel,\n handleSelect,\n }),\n [size, placeholder, searchPlaceholder, filter, shouldFilter, loop, disabled, open, setOpen, value, setValue, searchValue, setSearchValue, selectedLabel, registerItemLabel, handleSelect],\n );\n\n return (\n <ComboboxContext.Provider value={contextValue}>\n <Popover.Root open={open} onOpenChange={setOpen} {...rootProps}>\n {children}\n </Popover.Root>\n </ComboboxContext.Provider>\n );\n};\nComboboxRoot.displayName = 'Combobox.Root';\n\ntype ComboboxTriggerElement = HTMLButtonElement;\ntype ComboboxTriggerOwnProps = GetPropDefTypes<typeof comboboxTriggerPropDefs>;\ntype NativeTriggerProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'color'>;\ninterface ComboboxTriggerProps extends NativeTriggerProps, MarginProps, ComboboxTriggerOwnProps {}\nconst ComboboxTrigger = React.forwardRef<ComboboxTriggerElement, ComboboxTriggerProps>((props, forwardedRef) => {\n const context = useComboboxContext('Combobox.Trigger');\n const { children, className, placeholder, disabled, readOnly, ...triggerProps } = extractProps(\n { size: context.size, ...props },\n { size: comboboxRootPropDefs.size },\n comboboxTriggerPropDefs,\n marginPropDefs,\n );\n\n const isDisabled = disabled ?? context.disabled;\n const ariaProps = React.useMemo(\n () => ({\n 'aria-expanded': context.open,\n 'aria-disabled': isDisabled || undefined,\n 'aria-haspopup': 'listbox' as const,\n }),\n [context.open, isDisabled],\n );\n\n const defaultContent = (\n <>\n <span className=\"rt-SelectTriggerInner\">\n <ComboboxValue placeholder={placeholder ?? context.placeholder} />\n </span>\n <ChevronDownIcon className=\"rt-SelectIcon\" />\n </>\n );\n\n const triggerChild = (\n <button\n data-disabled={isDisabled || undefined}\n data-read-only={readOnly || undefined}\n {...triggerProps}\n {...ariaProps}\n ref={forwardedRef}\n className={classNames('rt-reset', 'rt-SelectTrigger', 'rt-ComboboxTrigger', className)}\n >\n {children ? requireReactElement(children) : defaultContent}\n </button>\n );\n\n return <Popover.Trigger disabled={isDisabled}>{triggerChild}</Popover.Trigger>;\n});\nComboboxTrigger.displayName = 'Combobox.Trigger';\n\ntype ComboboxValueElement = HTMLSpanElement;\ninterface ComboboxValueProps extends React.ComponentPropsWithoutRef<'span'> {\n placeholder?: string;\n}\nconst ComboboxValue = React.forwardRef<ComboboxValueElement, ComboboxValueProps>(({ placeholder, children, className, ...valueProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Value');\n const displayValue = context.selectedLabel ?? context.value ?? undefined;\n const fallback = placeholder ?? context.placeholder;\n return (\n <span {...valueProps} ref={forwardedRef} className={classNames('rt-ComboboxValue', className)}>\n {displayValue ?? children ?? fallback}\n </span>\n );\n});\nComboboxValue.displayName = 'Combobox.Value';\n\ntype ComboboxContentElement = React.ElementRef<typeof Popover.Content>;\ntype ComboboxContentOwnProps = GetPropDefTypes<typeof comboboxContentPropDefs> & {\n container?: React.ComponentPropsWithoutRef<typeof Popover.Content>['container'];\n};\ninterface ComboboxContentProps extends Omit<ComponentPropsWithout<typeof Popover.Content, RemovedProps>, 'size'>, ComboboxContentOwnProps {}\nconst ComboboxContent = React.forwardRef<ComboboxContentElement, ComboboxContentProps>((props, forwardedRef) => {\n const context = useComboboxContext('Combobox.Content');\n const themeContext = useThemeContext();\n const effectiveMaterial = themeContext.panelBackground;\n\n const sizeProp = props.size ?? context.size ?? comboboxContentPropDefs.size.default;\n const variantProp = props.variant ?? comboboxContentPropDefs.variant.default;\n const highContrastProp = props.highContrast ?? comboboxContentPropDefs.highContrast.default;\n\n const { className, children, color, forceMount, container, ...contentProps } = extractProps(\n { ...props, size: sizeProp, variant: variantProp, highContrast: highContrastProp },\n comboboxContentPropDefs,\n );\n const resolvedColor = color || themeContext.accentColor;\n let sanitizedClassName = className;\n if (typeof sizeProp === 'string') {\n sanitizedClassName =\n className\n ?.split(/\\s+/)\n .filter(Boolean)\n .filter((token) => !/^rt-r-size-\\d$/.test(token))\n .join(' ') || undefined;\n }\n\n return (\n <Popover.Content\n size={sizeProp}\n data-accent-color={resolvedColor}\n data-material={effectiveMaterial}\n data-panel-background={effectiveMaterial}\n align=\"start\"\n sideOffset={4}\n collisionPadding={10}\n {...contentProps}\n forceMount={forceMount}\n container={container}\n ref={forwardedRef}\n className={classNames('rt-PopperContent', 'rt-BaseMenuContent', 'rt-ComboboxContent', sanitizedClassName)}\n >\n <Theme asChild>\n <ScrollArea type=\"auto\">\n <div className={classNames('rt-BaseMenuViewport', 'rt-ComboboxViewport')}>\n <ComboboxContentContext.Provider value={{ variant: variantProp, size: String(sizeProp), color: resolvedColor, material: effectiveMaterial }}>\n <CommandPrimitive\n loop={context.loop}\n value={context.searchValue}\n onValueChange={context.setSearchValue}\n shouldFilter={context.shouldFilter}\n filter={context.filter}\n className=\"rt-ComboboxCommand\"\n >\n {children}\n </CommandPrimitive>\n </ComboboxContentContext.Provider>\n </div>\n </ScrollArea>\n </Theme>\n </Popover.Content>\n );\n});\nComboboxContent.displayName = 'Combobox.Content';\n\ntype ComboboxInputElement = React.ElementRef<typeof CommandPrimitive.Input>;\ninterface ComboboxInputProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> {\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n variant?: TextFieldVariant;\n}\nconst ComboboxInput = React.forwardRef<ComboboxInputElement, ComboboxInputProps>(({ className, startAdornment, endAdornment, placeholder, variant: inputVariant, ...inputProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Input');\n const contentContext = useComboboxContentContext();\n const contentVariant = contentContext?.variant ?? 'solid';\n const color = contentContext?.color;\n const material = contentContext?.material;\n\n // Map combobox variant to textfield variant: solid -> surface, soft -> soft unless overridden\n const textFieldVariant = inputVariant ?? (contentVariant === 'solid' ? 'surface' : 'soft');\n\n return (\n <div\n className={classNames('rt-TextFieldRoot', 'rt-ComboboxInputRoot', `rt-r-size-${context.size}`, `rt-variant-${textFieldVariant}`)}\n data-accent-color={color}\n data-material={material}\n data-panel-background={material}\n >\n {startAdornment ? <div className=\"rt-TextFieldSlot\">{startAdornment}</div> : null}\n <CommandPrimitive.Input {...inputProps} ref={forwardedRef} placeholder={placeholder ?? context.searchPlaceholder} className={classNames('rt-reset', 'rt-TextFieldInput', className)} />\n {endAdornment ? (\n <div className=\"rt-TextFieldSlot\" data-side=\"right\">\n {endAdornment}\n </div>\n ) : null}\n </div>\n );\n});\nComboboxInput.displayName = 'Combobox.Input';\n\ntype ComboboxListElement = React.ElementRef<typeof CommandPrimitive.List>;\ninterface ComboboxListProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.List> {}\nconst ComboboxList = React.forwardRef<ComboboxListElement, ComboboxListProps>(({ className, ...listProps }, forwardedRef) => (\n <CommandPrimitive.List {...listProps} ref={forwardedRef} className={classNames('rt-ComboboxList', className)} />\n));\nComboboxList.displayName = 'Combobox.List';\n\ntype ComboboxEmptyElement = React.ElementRef<typeof CommandPrimitive.Empty>;\ninterface ComboboxEmptyProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> {}\nconst ComboboxEmpty = React.forwardRef<ComboboxEmptyElement, ComboboxEmptyProps>(({ className, ...emptyProps }, forwardedRef) => (\n <CommandPrimitive.Empty {...emptyProps} ref={forwardedRef} className={classNames('rt-ComboboxEmpty', className)} />\n));\nComboboxEmpty.displayName = 'Combobox.Empty';\n\ntype ComboboxGroupElement = React.ElementRef<typeof CommandPrimitive.Group>;\ninterface ComboboxGroupProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group> {}\nconst ComboboxGroup = React.forwardRef<ComboboxGroupElement, ComboboxGroupProps>(({ className, ...groupProps }, forwardedRef) => (\n <CommandPrimitive.Group {...groupProps} ref={forwardedRef} className={classNames('rt-BaseMenuGroup', 'rt-ComboboxGroup', className)} />\n));\nComboboxGroup.displayName = 'Combobox.Group';\n\ntype ComboboxLabelElement = React.ElementRef<'div'>;\ninterface ComboboxLabelProps extends React.ComponentPropsWithoutRef<'div'> {}\nconst ComboboxLabel = React.forwardRef<ComboboxLabelElement, ComboboxLabelProps>(({ className, ...labelProps }, forwardedRef) => (\n <div {...labelProps} ref={forwardedRef} className={classNames('rt-BaseMenuLabel', 'rt-ComboboxLabel', className)} />\n));\nComboboxLabel.displayName = 'Combobox.Label';\n\ntype ComboboxSeparatorElement = React.ElementRef<typeof CommandPrimitive.Separator>;\ninterface ComboboxSeparatorProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> {}\nconst ComboboxSeparator = React.forwardRef<ComboboxSeparatorElement, ComboboxSeparatorProps>(({ className, ...separatorProps }, forwardedRef) => (\n <CommandPrimitive.Separator {...separatorProps} ref={forwardedRef} className={classNames('rt-BaseMenuSeparator', 'rt-ComboboxSeparator', className)} />\n));\nComboboxSeparator.displayName = 'Combobox.Separator';\n\ntype ComboboxItemElement = React.ElementRef<typeof CommandPrimitive.Item>;\ninterface ComboboxItemProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item> {\n label?: string;\n}\nconst ComboboxItem = React.forwardRef<ComboboxItemElement, ComboboxItemProps>(({ className, children, label, value, disabled, onSelect, ...itemProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Item');\n const contentContext = useComboboxContentContext();\n const itemLabel = label ?? (typeof children === 'string' ? children : String(value));\n const isSelected = value != null && context.value === value;\n const sizeClass = contentContext?.size ? `rt-r-size-${contentContext.size}` : undefined;\n\n React.useEffect(() => {\n if (value) {\n context.registerItemLabel(value, itemLabel);\n }\n }, [context, value, itemLabel]);\n\n const handleSelect = React.useCallback(\n (selectedValue: string) => {\n context.handleSelect(selectedValue);\n onSelect?.(selectedValue);\n },\n [context, onSelect],\n );\n\n const isDisabled = disabled ?? context.disabled ?? false;\n\n // Internal ref to clean up data-disabled attribute\n const internalRef = React.useRef<ComboboxItemElement | null>(null);\n\n // Ref callback to handle both forwarded ref and internal ref\n const itemRef = React.useCallback(\n (node: ComboboxItemElement | null) => {\n internalRef.current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef) {\n (forwardedRef as React.MutableRefObject<ComboboxItemElement | null>).current = node;\n }\n },\n [forwardedRef],\n );\n\n // Remove data-disabled attribute if cmdk sets it incorrectly\n React.useEffect(() => {\n if (!isDisabled && internalRef.current) {\n const node = internalRef.current;\n // Check and remove immediately\n if (node.getAttribute('data-disabled') === 'false' || node.getAttribute('data-disabled') === '') {\n node.removeAttribute('data-disabled');\n }\n // Also watch for changes\n const observer = new MutationObserver(() => {\n if (node.getAttribute('data-disabled') === 'false' || node.getAttribute('data-disabled') === '') {\n node.removeAttribute('data-disabled');\n }\n });\n observer.observe(node, { attributes: true, attributeFilter: ['data-disabled'] });\n return () => observer.disconnect();\n }\n }, [isDisabled]);\n\n return (\n <CommandPrimitive.Item\n {...itemProps}\n value={value}\n {...(isDisabled ? { disabled: true } : {})}\n ref={itemRef}\n onSelect={handleSelect}\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-ComboboxItem', className)}\n >\n {isSelected ? (\n <span className={classNames('rt-BaseMenuItemIndicator', 'rt-ComboboxItemIndicator', sizeClass)}>\n <ThickCheckIcon className={classNames('rt-BaseMenuItemIndicatorIcon', 'rt-ComboboxItemIndicatorIcon', sizeClass)} />\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </CommandPrimitive.Item>\n );\n});\nComboboxItem.displayName = 'Combobox.Item';\n\nexport {\n ComboboxRoot as Root,\n ComboboxTrigger as Trigger,\n ComboboxValue as Value,\n ComboboxContent as Content,\n ComboboxInput as Input,\n ComboboxList as List,\n ComboboxEmpty as Empty,\n ComboboxGroup as Group,\n ComboboxLabel as Label,\n ComboboxSeparator as Separator,\n ComboboxItem as Item,\n};\nexport type {\n ComboboxRootProps as RootProps,\n ComboboxTriggerProps as TriggerProps,\n ComboboxContentProps as ContentProps,\n ComboboxInputProps as InputProps,\n ComboboxListProps as ListProps,\n ComboboxEmptyProps as EmptyProps,\n ComboboxGroupProps as GroupProps,\n ComboboxLabelProps as LabelProps,\n ComboboxSeparatorProps as SeparatorProps,\n ComboboxItemProps as ItemProps,\n};\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["React", "classNames", "useControllableState", "CommandPrimitive", "extractProps", "comboboxRootPropDefs", "comboboxTriggerPropDefs", "comboboxContentPropDefs", "marginPropDefs", "ChevronDownIcon", "ThickCheckIcon", "Theme", "useThemeContext", "requireReactElement", "Popover", "ScrollArea", "Slottable", "ComboboxContext", "useComboboxContext", "caller", "ctx", "ComboboxContentContext", "useComboboxContentContext", "ComboboxRoot", "props", "children", "size", "valueProp", "defaultValue", "onValueChange", "openProp", "defaultOpen", "onOpenChange", "placeholder", "searchPlaceholder", "searchValueProp", "defaultSearchValue", "onSearchValueChange", "filter", "shouldFilter", "loop", "disabled", "rootProps", "open", "setOpen", "value", "setValue", "searchValue", "setSearchValue", "labelMapRef", "registerItemLabel", "itemValue", "label", "selectedLabel", "handleSelect", "nextValue", "contextValue", "ComboboxTrigger", "forwardedRef", "context", "className", "readOnly", "triggerProps", "isDisabled", "ariaProps", "defaultContent", "ComboboxValue", "triggerChild", "valueProps", "displayValue", "fallback", "ComboboxContent", "themeContext", "effectiveMaterial", "sizeProp", "variantProp", "highContrastProp", "
|
|
4
|
+
"sourcesContent": ["'use client';\n\n/**\n * Combobox is a compound component built on top of Popover and cmdk's Command list.\n * It mirrors the Select API while adding search-first behaviors including filtering,\n * async-friendly state management, and design token support for trigger, content,\n * and input variants.\n */\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { useControllableState } from 'radix-ui/internal';\nimport { Command as CommandPrimitive } from 'cmdk';\n\nimport { extractProps } from '../helpers/extract-props.js';\nimport { comboboxRootPropDefs, comboboxTriggerPropDefs, comboboxContentPropDefs } from './combobox.props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\nimport { ChevronDownIcon, ThickCheckIcon } from './icons.js';\nimport { Theme, useThemeContext } from './theme.js';\nimport { requireReactElement } from '../helpers/require-react-element.js';\nimport * as Popover from './popover.js';\nimport { ScrollArea } from './scroll-area.js';\nimport { Slottable } from './slot.js';\nimport { textFieldRootPropDefs } from './text-field.props.js';\n\nimport type { MarginProps } from '../props/margin.props.js';\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\n\ntype TextFieldVariant = (typeof textFieldRootPropDefs.variant.values)[number];\ntype ComboboxValue = string | null;\ntype CommandFilter = (value: string, search: string, keywords?: string[]) => number;\n\n/**\n * Additional props supported by Combobox.Root beyond the Radix Popover surface.\n */\ntype ComboboxRootOwnProps = GetPropDefTypes<typeof comboboxRootPropDefs> & {\n value?: ComboboxValue;\n defaultValue?: ComboboxValue;\n onValueChange?: (value: ComboboxValue) => void;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n placeholder?: string;\n searchPlaceholder?: string;\n searchValue?: string;\n defaultSearchValue?: string;\n onSearchValueChange?: (value: string) => void;\n filter?: CommandFilter;\n shouldFilter?: boolean;\n loop?: boolean;\n disabled?: boolean;\n};\n\n/**\n * Internal context shared by all sub-components to avoid prop drilling.\n */\ninterface ComboboxContextValue extends ComboboxRootOwnProps {\n open: boolean;\n setOpen: (open: boolean) => void;\n value: ComboboxValue;\n setValue: (value: ComboboxValue) => void;\n searchValue: string;\n setSearchValue: (value: string) => void;\n selectedLabel?: string;\n registerItemLabel: (value: string, label: string) => void;\n handleSelect: (value: string) => void;\n}\n\nconst ComboboxContext = React.createContext<ComboboxContextValue | null>(null);\n\n/**\n * Utility hook that ensures consumers are wrapped in Combobox.Root.\n */\nconst useComboboxContext = (caller: string) => {\n const ctx = React.useContext(ComboboxContext);\n if (!ctx) {\n throw new Error(`${caller} must be used within Combobox.Root`);\n }\n return ctx;\n};\n\n/**\n * Context for values that are only available inside Content (e.g., variant, color)\n * so that Input/Item can style themselves consistently.\n */\nconst ComboboxContentContext = React.createContext<{ variant: 'solid' | 'soft'; size?: string; color?: string; material?: string; highContrast?: boolean } | null>(null);\nconst useComboboxContentContext = () => {\n const ctx = React.useContext(ComboboxContentContext);\n return ctx; // Optional - Input might not always be in Content\n};\n\ntype PopoverRootProps = React.ComponentPropsWithoutRef<typeof Popover.Root>;\ninterface ComboboxRootProps extends PopoverRootProps, ComboboxRootOwnProps {}\n/**\n * Root component that wires up Popover behavior, controllable state,\n * and shared context for trigger/content/input sub-components.\n */\nconst ComboboxRoot: React.FC<ComboboxRootProps> = (props) => {\n const {\n children,\n size = comboboxRootPropDefs.size.default,\n highContrast = comboboxRootPropDefs.highContrast.default,\n value: valueProp,\n defaultValue = null,\n onValueChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n placeholder = 'Select an option',\n searchPlaceholder = 'Search options...',\n searchValue: searchValueProp,\n defaultSearchValue = '',\n onSearchValueChange,\n filter,\n shouldFilter = true,\n loop = true,\n disabled,\n ...rootProps\n } = props;\n\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const [value, setValue] = useControllableState<ComboboxValue>({\n prop: valueProp,\n defaultProp: defaultValue,\n onChange: onValueChange,\n });\n\n const [searchValue, setSearchValue] = useControllableState<string>({\n prop: searchValueProp,\n defaultProp: defaultSearchValue,\n onChange: onSearchValueChange,\n });\n\n const labelMapRef = React.useRef(new Map<string, string>());\n const registerItemLabel = React.useCallback((itemValue: string, label: string) => {\n labelMapRef.current.set(itemValue, label);\n }, []);\n\n const selectedLabel = value != null ? labelMapRef.current.get(value) : undefined;\n\n const handleSelect = React.useCallback(\n (nextValue: string) => {\n setValue(nextValue);\n setOpen(false);\n setSearchValue('');\n },\n [setOpen, setSearchValue, setValue],\n );\n\n const contextValue = React.useMemo<ComboboxContextValue>(\n () => ({\n size,\n highContrast,\n placeholder,\n searchPlaceholder,\n filter,\n shouldFilter,\n loop,\n disabled,\n open,\n setOpen,\n value,\n setValue,\n searchValue,\n setSearchValue,\n selectedLabel,\n registerItemLabel,\n handleSelect,\n }),\n [\n size,\n highContrast,\n placeholder,\n searchPlaceholder,\n filter,\n shouldFilter,\n loop,\n disabled,\n open,\n setOpen,\n value,\n setValue,\n searchValue,\n setSearchValue,\n selectedLabel,\n registerItemLabel,\n handleSelect,\n ],\n );\n\n return (\n <ComboboxContext.Provider value={contextValue}>\n <Popover.Root open={open} onOpenChange={setOpen} {...rootProps}>\n {children}\n </Popover.Root>\n </ComboboxContext.Provider>\n );\n};\nComboboxRoot.displayName = 'Combobox.Root';\n\ntype ComboboxTriggerElement = HTMLButtonElement;\ntype ComboboxTriggerOwnProps = GetPropDefTypes<typeof comboboxTriggerPropDefs>;\ntype NativeTriggerProps = Omit<React.ComponentPropsWithoutRef<'button'>, 'color'>;\ninterface ComboboxTriggerProps extends NativeTriggerProps, MarginProps, ComboboxTriggerOwnProps {}\n/**\n * Trigger behaves like a styled button that opens the Popover,\n * syncing size/highContrast from Root while exposing select-like states.\n */\nconst ComboboxTrigger = React.forwardRef<ComboboxTriggerElement, ComboboxTriggerProps>((props, forwardedRef) => {\n const context = useComboboxContext('Combobox.Trigger');\n const { children, className, placeholder, disabled, readOnly, error, loading, color, radius, ...triggerProps } = extractProps(\n { size: context.size, highContrast: context.highContrast, ...props },\n { size: comboboxRootPropDefs.size, highContrast: comboboxRootPropDefs.highContrast },\n comboboxTriggerPropDefs,\n marginPropDefs,\n );\n\n // Extract material and panelBackground separately since they need to be passed as data attributes\n const { material, panelBackground } = props;\n\n const isDisabled = disabled ?? context.disabled;\n const ariaProps = React.useMemo(\n () => ({\n 'aria-expanded': context.open,\n 'aria-disabled': isDisabled || undefined,\n 'aria-haspopup': 'listbox' as const,\n }),\n [context.open, isDisabled],\n );\n\n const defaultContent = (\n <>\n <span className=\"rt-SelectTriggerInner\">\n <ComboboxValue placeholder={placeholder ?? context.placeholder} />\n </span>\n {loading ? (\n <div className=\"rt-SelectIcon rt-SelectLoadingIcon\" aria-hidden=\"true\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <circle cx=\"8\" cy=\"8\" r=\"6.5\" stroke=\"currentColor\" strokeWidth=\"1\" strokeLinecap=\"round\" strokeDasharray=\"6 34\" strokeDashoffset=\"0\" className=\"rt-SelectLoadingSpinner\" />\n </svg>\n </div>\n ) : (\n <ChevronDownIcon className=\"rt-SelectIcon\" />\n )}\n </>\n );\n\n const { type: buttonType, ...restTriggerProps } = triggerProps;\n const resolvedButtonType = buttonType ?? 'button';\n\n const triggerChild = (\n <button\n data-accent-color={color}\n data-radius={radius}\n data-panel-background={panelBackground}\n data-material={material}\n data-error={error}\n data-loading={loading}\n data-disabled={isDisabled || undefined}\n data-read-only={readOnly || undefined}\n {...restTriggerProps}\n {...ariaProps}\n type={resolvedButtonType}\n disabled={isDisabled}\n ref={forwardedRef}\n className={classNames('rt-reset', 'rt-SelectTrigger', 'rt-ComboboxTrigger', className)}\n >\n {children ? requireReactElement(children) : defaultContent}\n </button>\n );\n\n return <Popover.Trigger disabled={isDisabled}>{triggerChild}</Popover.Trigger>;\n});\nComboboxTrigger.displayName = 'Combobox.Trigger';\n\ntype ComboboxValueElement = HTMLSpanElement;\ninterface ComboboxValueProps extends React.ComponentPropsWithoutRef<'span'> {\n placeholder?: string;\n}\n/**\n * Value mirrors Select.Value by showing the selected item's label\n * or falling back to placeholder text supplied by the consumer or context.\n */\nconst ComboboxValue = React.forwardRef<ComboboxValueElement, ComboboxValueProps>(({ placeholder, children, className, ...valueProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Value');\n const displayValue = context.selectedLabel ?? context.value ?? undefined;\n const fallback = placeholder ?? context.placeholder;\n return (\n <span {...valueProps} ref={forwardedRef} className={classNames('rt-ComboboxValue', className)}>\n {displayValue ?? children ?? fallback}\n </span>\n );\n});\nComboboxValue.displayName = 'Combobox.Value';\n\ntype ComboboxContentElement = React.ElementRef<typeof Popover.Content>;\ntype ComboboxContentOwnProps = GetPropDefTypes<typeof comboboxContentPropDefs> & {\n container?: React.ComponentPropsWithoutRef<typeof Popover.Content>['container'];\n};\ninterface ComboboxContentProps extends Omit<ComponentPropsWithout<typeof Popover.Content, RemovedProps>, 'size'>, ComboboxContentOwnProps {}\n/**\n * Content renders the dropdown surface, syncing tokens from the current Theme\n * and instantiating cmdk's Command list for roving focus + filtering.\n */\nconst ComboboxContent = React.forwardRef<ComboboxContentElement, ComboboxContentProps>((props, forwardedRef) => {\n const context = useComboboxContext('Combobox.Content');\n const themeContext = useThemeContext();\n const effectiveMaterial = themeContext.panelBackground;\n\n const sizeProp = props.size ?? context.size ?? comboboxContentPropDefs.size.default;\n const variantProp = props.variant ?? comboboxContentPropDefs.variant.default;\n const highContrastProp = props.highContrast ?? context.highContrast ?? comboboxContentPropDefs.highContrast.default;\n\n const { className, children, color, forceMount, container, ...contentProps } = extractProps(\n { ...props, size: sizeProp, variant: variantProp, highContrast: highContrastProp },\n comboboxContentPropDefs,\n );\n const resolvedColor = color || themeContext.accentColor;\n let sanitizedClassName = className;\n if (typeof sizeProp === 'string') {\n sanitizedClassName =\n className\n ?.split(/\\s+/)\n .filter(Boolean)\n .filter((token) => !/^rt-r-size-\\d$/.test(token))\n .join(' ') || undefined;\n }\n\n return (\n <Popover.Content\n size={sizeProp}\n data-accent-color={resolvedColor}\n data-material={effectiveMaterial}\n data-panel-background={effectiveMaterial}\n align=\"start\"\n sideOffset={4}\n collisionPadding={10}\n {...contentProps}\n forceMount={forceMount}\n container={container}\n ref={forwardedRef}\n className={classNames('rt-PopperContent', 'rt-BaseMenuContent', 'rt-ComboboxContent', sanitizedClassName)}\n >\n <Theme asChild>\n <ComboboxContentContext.Provider value={{ variant: variantProp, size: String(sizeProp), color: resolvedColor, material: effectiveMaterial, highContrast: highContrastProp }}>\n <CommandPrimitive\n loop={context.loop}\n value={context.searchValue}\n onValueChange={context.setSearchValue}\n shouldFilter={context.shouldFilter}\n filter={context.filter}\n className=\"rt-ComboboxCommand\"\n >\n {children}\n </CommandPrimitive>\n </ComboboxContentContext.Provider>\n </Theme>\n </Popover.Content>\n );\n});\nComboboxContent.displayName = 'Combobox.Content';\n\ntype ComboboxInputElement = React.ElementRef<typeof CommandPrimitive.Input>;\ninterface ComboboxInputProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> {\n startAdornment?: React.ReactNode;\n endAdornment?: React.ReactNode;\n variant?: TextFieldVariant;\n}\n/**\n * Input composes TextField tokens with cmdk's Command.Input to provide\n * automatic focus management and optional adornments.\n */\nconst ComboboxInput = React.forwardRef<ComboboxInputElement, ComboboxInputProps>(({ className, startAdornment, endAdornment, placeholder, variant: inputVariant, ...inputProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Input');\n const contentContext = useComboboxContentContext();\n const contentVariant = contentContext?.variant ?? 'solid';\n const color = contentContext?.color;\n const material = contentContext?.material;\n\n // Map combobox variant to textfield variant: solid -> surface, soft -> soft unless overridden\n const textFieldVariant = inputVariant ?? (contentVariant === 'solid' ? 'surface' : 'soft');\n\n const inputField = (\n <div\n className={classNames('rt-TextFieldRoot', 'rt-ComboboxInputRoot', `rt-r-size-${context.size}`, `rt-variant-${textFieldVariant}`)}\n data-accent-color={color}\n data-material={material}\n data-panel-background={material}\n >\n {startAdornment ? <div className=\"rt-TextFieldSlot\">{startAdornment}</div> : null}\n <CommandPrimitive.Input {...inputProps} ref={forwardedRef} placeholder={placeholder ?? context.searchPlaceholder} className={classNames('rt-reset', 'rt-TextFieldInput', className)} />\n {endAdornment ? (\n <div className=\"rt-TextFieldSlot\" data-side=\"right\">\n {endAdornment}\n </div>\n ) : null}\n </div>\n );\n\n if (contentContext) {\n return <div className=\"rt-ComboboxSearch\">{inputField}</div>;\n }\n\n return inputField;\n});\nComboboxInput.displayName = 'Combobox.Input';\n\ntype ComboboxListElement = React.ElementRef<typeof CommandPrimitive.List>;\ninterface ComboboxListProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.List> {}\n/**\n * List wraps cmdk's Command.List to inherit base menu styles and provides ScrollArea for the items.\n */\nconst ComboboxList = React.forwardRef<ComboboxListElement, ComboboxListProps>(({ className, ...listProps }, forwardedRef) => (\n <ScrollArea type=\"auto\" className=\"rt-ComboboxScrollArea\" scrollbars=\"vertical\" size=\"1\">\n <div className={classNames('rt-BaseMenuViewport', 'rt-ComboboxViewport')}>\n <CommandPrimitive.List {...listProps} ref={forwardedRef} className={classNames('rt-ComboboxList', className)} />\n </div>\n </ScrollArea>\n));\nComboboxList.displayName = 'Combobox.List';\n\ntype ComboboxEmptyElement = React.ElementRef<typeof CommandPrimitive.Empty>;\ninterface ComboboxEmptyProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> {}\n/**\n * Empty renders when no options match the search query.\n */\nconst ComboboxEmpty = React.forwardRef<ComboboxEmptyElement, ComboboxEmptyProps>(({ className, ...emptyProps }, forwardedRef) => (\n <CommandPrimitive.Empty {...emptyProps} ref={forwardedRef} className={classNames('rt-ComboboxEmpty', className)} />\n));\nComboboxEmpty.displayName = 'Combobox.Empty';\n\ntype ComboboxGroupElement = React.ElementRef<typeof CommandPrimitive.Group>;\ninterface ComboboxGroupProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group> {}\n/**\n * Group and Label mirror menu semantics for subheadings inside the list.\n */\nconst ComboboxGroup = React.forwardRef<ComboboxGroupElement, ComboboxGroupProps>(({ className, ...groupProps }, forwardedRef) => (\n <CommandPrimitive.Group {...groupProps} ref={forwardedRef} className={classNames('rt-BaseMenuGroup', 'rt-ComboboxGroup', className)} />\n));\nComboboxGroup.displayName = 'Combobox.Group';\n\ntype ComboboxLabelElement = React.ElementRef<'div'>;\ninterface ComboboxLabelProps extends React.ComponentPropsWithoutRef<'div'> {}\nconst ComboboxLabel = React.forwardRef<ComboboxLabelElement, ComboboxLabelProps>(({ className, ...labelProps }, forwardedRef) => (\n <div {...labelProps} ref={forwardedRef} className={classNames('rt-BaseMenuLabel', 'rt-ComboboxLabel', className)} />\n));\nComboboxLabel.displayName = 'Combobox.Label';\n\ntype ComboboxSeparatorElement = React.ElementRef<typeof CommandPrimitive.Separator>;\ninterface ComboboxSeparatorProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> {}\n/**\n * Separator visually divides logical sections of the option list.\n */\nconst ComboboxSeparator = React.forwardRef<ComboboxSeparatorElement, ComboboxSeparatorProps>(({ className, ...separatorProps }, forwardedRef) => (\n <CommandPrimitive.Separator {...separatorProps} ref={forwardedRef} className={classNames('rt-BaseMenuSeparator', 'rt-ComboboxSeparator', className)} />\n));\nComboboxSeparator.displayName = 'Combobox.Separator';\n\ntype ComboboxItemElement = React.ElementRef<typeof CommandPrimitive.Item>;\ninterface ComboboxItemProps extends React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item> {\n label?: string;\n}\n/**\n * Item wires cmdk's selection handling with Kookie UI tokens and\n * ensures labels are registered for displaying the current value.\n */\nconst ComboboxItem = React.forwardRef<ComboboxItemElement, ComboboxItemProps>(({ className, children, label, value, disabled, onSelect, ...itemProps }, forwardedRef) => {\n const context = useComboboxContext('Combobox.Item');\n const contentContext = useComboboxContentContext();\n const itemLabel = label ?? (typeof children === 'string' ? children : String(value));\n const isSelected = value != null && context.value === value;\n const sizeClass = contentContext?.size ? `rt-r-size-${contentContext.size}` : undefined;\n\n React.useEffect(() => {\n if (value) {\n context.registerItemLabel(value, itemLabel);\n }\n }, [context, value, itemLabel]);\n\n const handleSelect = React.useCallback(\n (selectedValue: string) => {\n context.handleSelect(selectedValue);\n onSelect?.(selectedValue);\n },\n [context, onSelect],\n );\n\n const isDisabled = disabled ?? context.disabled ?? false;\n\n // Internal ref to clean up data-disabled attribute\n const internalRef = React.useRef<ComboboxItemElement | null>(null);\n\n // Ref callback to handle both forwarded ref and internal ref\n const itemRef = React.useCallback(\n (node: ComboboxItemElement | null) => {\n internalRef.current = node;\n if (typeof forwardedRef === 'function') {\n forwardedRef(node);\n } else if (forwardedRef) {\n (forwardedRef as React.MutableRefObject<ComboboxItemElement | null>).current = node;\n }\n },\n [forwardedRef],\n );\n\n // Remove data-disabled attribute if cmdk sets it incorrectly\n React.useEffect(() => {\n if (!isDisabled && internalRef.current) {\n const node = internalRef.current;\n // Check and remove immediately\n if (node.getAttribute('data-disabled') === 'false' || node.getAttribute('data-disabled') === '') {\n node.removeAttribute('data-disabled');\n }\n // Also watch for changes\n const observer = new MutationObserver(() => {\n if (node.getAttribute('data-disabled') === 'false' || node.getAttribute('data-disabled') === '') {\n node.removeAttribute('data-disabled');\n }\n });\n observer.observe(node, { attributes: true, attributeFilter: ['data-disabled'] });\n return () => observer.disconnect();\n }\n }, [isDisabled]);\n\n return (\n <CommandPrimitive.Item\n {...itemProps}\n value={value}\n {...(isDisabled ? { disabled: true } : {})}\n ref={itemRef}\n onSelect={handleSelect}\n className={classNames('rt-reset', 'rt-BaseMenuItem', 'rt-ComboboxItem', className)}\n >\n {isSelected ? (\n <span className={classNames('rt-BaseMenuItemIndicator', 'rt-ComboboxItemIndicator', sizeClass)}>\n <ThickCheckIcon className={classNames('rt-BaseMenuItemIndicatorIcon', 'rt-ComboboxItemIndicatorIcon', sizeClass)} />\n </span>\n ) : null}\n <Slottable>{children}</Slottable>\n </CommandPrimitive.Item>\n );\n});\nComboboxItem.displayName = 'Combobox.Item';\n\nexport {\n ComboboxRoot as Root,\n ComboboxTrigger as Trigger,\n ComboboxValue as Value,\n ComboboxContent as Content,\n ComboboxInput as Input,\n ComboboxList as List,\n ComboboxEmpty as Empty,\n ComboboxGroup as Group,\n ComboboxLabel as Label,\n ComboboxSeparator as Separator,\n ComboboxItem as Item,\n};\nexport type {\n ComboboxRootProps as RootProps,\n ComboboxTriggerProps as TriggerProps,\n ComboboxContentProps as ContentProps,\n ComboboxInputProps as InputProps,\n ComboboxListProps as ListProps,\n ComboboxEmptyProps as EmptyProps,\n ComboboxGroupProps as GroupProps,\n ComboboxLabelProps as LabelProps,\n ComboboxSeparatorProps as SeparatorProps,\n ComboboxItemProps as ItemProps,\n};\n"],
|
|
5
|
+
"mappings": "aASA,UAAYA,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,wBAAAC,MAA4B,oBACrC,OAAS,WAAWC,MAAwB,OAE5C,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,wBAAAC,EAAsB,2BAAAC,GAAyB,2BAAAC,MAA+B,sBACvF,OAAS,kBAAAC,OAAsB,2BAC/B,OAAS,mBAAAC,GAAiB,kBAAAC,OAAsB,aAChD,OAAS,SAAAC,GAAO,mBAAAC,OAAuB,aACvC,OAAS,uBAAAC,OAA2B,sCACpC,UAAYC,MAAa,eACzB,OAAS,cAAAC,OAAkB,mBAC3B,OAAS,aAAAC,OAAiB,YAC1B,MAAsC,wBA8CtC,MAAMC,EAAkBjB,EAAM,cAA2C,IAAI,EAKvEkB,EAAsBC,GAAmB,CAC7C,MAAMC,EAAMpB,EAAM,WAAWiB,CAAe,EAC5C,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,GAAGD,CAAM,oCAAoC,EAE/D,OAAOC,CACT,EAMMC,EAAyBrB,EAAM,cAA8H,IAAI,EACjKsB,EAA4B,IACpBtB,EAAM,WAAWqB,CAAsB,EAU/CE,EAA6CC,GAAU,CAC3D,KAAM,CACJ,SAAAC,EACA,KAAAC,EAAOrB,EAAqB,KAAK,QACjC,aAAAsB,EAAetB,EAAqB,aAAa,QACjD,MAAOuB,EACP,aAAAC,EAAe,KACf,cAAAC,EACA,KAAMC,EACN,YAAAC,EAAc,GACd,aAAAC,EACA,YAAAC,EAAc,mBACd,kBAAAC,EAAoB,oBACpB,YAAaC,EACb,mBAAAC,EAAqB,GACrB,oBAAAC,EACA,OAAAC,EACA,aAAAC,EAAe,GACf,KAAAC,EAAO,GACP,SAAAC,EACA,GAAGC,CACL,EAAInB,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AO7D,GAAiB,WAC1BA,EAAa6D,CAAI,EACR7D,IACRA,EAAoE,QAAU6D,EAEnF,EACA,CAAC7D,CAAY,CACf,EAGA,OAAA3D,EAAM,UAAU,IAAM,CACpB,GAAI,CAACsE,GAAcgD,EAAY,QAAS,CACtC,MAAME,EAAOF,EAAY,SAErBE,EAAK,aAAa,eAAe,IAAM,SAAWA,EAAK,aAAa,eAAe,IAAM,KAC3FA,EAAK,gBAAgB,eAAe,EAGtC,MAAMC,EAAW,IAAI,iBAAiB,IAAM,EACtCD,EAAK,aAAa,eAAe,IAAM,SAAWA,EAAK,aAAa,eAAe,IAAM,KAC3FA,EAAK,gBAAgB,eAAe,CAExC,CAAC,EACD,OAAAC,EAAS,QAAQD,EAAM,CAAE,WAAY,GAAM,gBAAiB,CAAC,eAAe,CAAE,CAAC,EACxE,IAAMC,EAAS,WAAW,CACnC,CACF,EAAG,CAACnD,CAAU,CAAC,EAGbtE,EAAA,cAACG,EAAiB,KAAjB,CACE,GAAG8G,EACJ,MAAOnE,EACN,GAAIwB,EAAa,CAAE,SAAU,EAAK,EAAI,CAAC,EACxC,IAAKiD,EACL,SAAUhE,EACV,UAAWtD,EAAW,WAAY,kBAAmB,kBAAmB4D,CAAS,GAEhFsD,EACCnH,EAAA,cAAC,QAAK,UAAWC,EAAW,2BAA4B,2BAA4BmH,CAAS,GAC3FpH,EAAA,cAACU,GAAA,CAAe,UAAWT,EAAW,+BAAgC,+BAAgCmH,CAAS,EAAG,CACpH,EACE,KACJpH,EAAA,cAACgB,GAAA,KAAWS,CAAS,CACvB,CAEJ,CAAC,EACDsF,EAAa,YAAc",
|
|
6
|
+
"names": ["React", "classNames", "useControllableState", "CommandPrimitive", "extractProps", "comboboxRootPropDefs", "comboboxTriggerPropDefs", "comboboxContentPropDefs", "marginPropDefs", "ChevronDownIcon", "ThickCheckIcon", "Theme", "useThemeContext", "requireReactElement", "Popover", "ScrollArea", "Slottable", "ComboboxContext", "useComboboxContext", "caller", "ctx", "ComboboxContentContext", "useComboboxContentContext", "ComboboxRoot", "props", "children", "size", "highContrast", "valueProp", "defaultValue", "onValueChange", "openProp", "defaultOpen", "onOpenChange", "placeholder", "searchPlaceholder", "searchValueProp", "defaultSearchValue", "onSearchValueChange", "filter", "shouldFilter", "loop", "disabled", "rootProps", "open", "setOpen", "value", "setValue", "searchValue", "setSearchValue", "labelMapRef", "registerItemLabel", "itemValue", "label", "selectedLabel", "handleSelect", "nextValue", "contextValue", "ComboboxTrigger", "forwardedRef", "context", "className", "readOnly", "error", "loading", "color", "radius", "triggerProps", "material", "panelBackground", "isDisabled", "ariaProps", "defaultContent", "ComboboxValue", "buttonType", "restTriggerProps", "triggerChild", "valueProps", "displayValue", "fallback", "ComboboxContent", "themeContext", "effectiveMaterial", "sizeProp", "variantProp", "highContrastProp", "forceMount", "container", "contentProps", "resolvedColor", "sanitizedClassName", "token", "ComboboxInput", "startAdornment", "endAdornment", "inputVariant", "inputProps", "contentContext", "contentVariant", "textFieldVariant", "inputField", "ComboboxList", "listProps", "ComboboxEmpty", "emptyProps", "ComboboxGroup", "groupProps", "ComboboxLabel", "labelProps", "ComboboxSeparator", "separatorProps", "ComboboxItem", "onSelect", "itemProps", "itemLabel", "isSelected", "sizeClass", "selectedValue", "internalRef", "itemRef", "node", "observer"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared responsive sizing + high contrast support inherited by Combobox.Root.
|
|
3
|
+
*/
|
|
1
4
|
declare const comboboxRootPropDefs: {
|
|
5
|
+
highContrast: {
|
|
6
|
+
type: "boolean";
|
|
7
|
+
className: string;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
2
10
|
size: {
|
|
3
11
|
type: "enum";
|
|
4
12
|
className: string;
|
|
@@ -7,6 +15,9 @@ declare const comboboxRootPropDefs: {
|
|
|
7
15
|
responsive: true;
|
|
8
16
|
};
|
|
9
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Token-aware props specific to Combobox.Trigger.
|
|
20
|
+
*/
|
|
10
21
|
declare const comboboxTriggerPropDefs: {
|
|
11
22
|
width: {
|
|
12
23
|
type: "string";
|
|
@@ -27,23 +38,6 @@ declare const comboboxTriggerPropDefs: {
|
|
|
27
38
|
values: readonly ["gray", "gold", "bronze", "brown", "yellow", "amber", "orange", "tomato", "red", "ruby", "crimson", "pink", "plum", "purple", "violet", "iris", "indigo", "blue", "cyan", "teal", "jade", "green", "grass", "lime", "mint", "sky"];
|
|
28
39
|
default: ("gray" | "gold" | "bronze" | "brown" | "yellow" | "amber" | "orange" | "tomato" | "red" | "ruby" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "lime" | "mint" | "sky") | undefined;
|
|
29
40
|
};
|
|
30
|
-
error: {
|
|
31
|
-
type: "boolean";
|
|
32
|
-
};
|
|
33
|
-
loading: {
|
|
34
|
-
type: "boolean";
|
|
35
|
-
};
|
|
36
|
-
disabled: {
|
|
37
|
-
type: "boolean";
|
|
38
|
-
};
|
|
39
|
-
readOnly: {
|
|
40
|
-
type: "boolean";
|
|
41
|
-
};
|
|
42
|
-
highContrast: {
|
|
43
|
-
type: "boolean";
|
|
44
|
-
className: string;
|
|
45
|
-
default: undefined;
|
|
46
|
-
};
|
|
47
41
|
variant: {
|
|
48
42
|
type: "enum";
|
|
49
43
|
className: string;
|
|
@@ -59,7 +53,22 @@ declare const comboboxTriggerPropDefs: {
|
|
|
59
53
|
type: "enum";
|
|
60
54
|
values: ("solid" | "translucent")[];
|
|
61
55
|
};
|
|
56
|
+
error: {
|
|
57
|
+
type: "boolean";
|
|
58
|
+
};
|
|
59
|
+
loading: {
|
|
60
|
+
type: "boolean";
|
|
61
|
+
};
|
|
62
|
+
disabled: {
|
|
63
|
+
type: "boolean";
|
|
64
|
+
};
|
|
65
|
+
readOnly: {
|
|
66
|
+
type: "boolean";
|
|
67
|
+
};
|
|
62
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Styling props for the dropdown surface rendered by Combobox.Content.
|
|
71
|
+
*/
|
|
63
72
|
declare const comboboxContentPropDefs: {
|
|
64
73
|
highContrast: {
|
|
65
74
|
type: "boolean";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.props.d.ts","sourceRoot":"","sources":["../../../src/components/combobox.props.tsx"],"names":[],"mappings":"AASA,QAAA,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"combobox.props.d.ts","sourceRoot":"","sources":["../../../src/components/combobox.props.tsx"],"names":[],"mappings":"AASA;;GAEG;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;CAMzB,CAAC;AAIF;;GAEG;AACH,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B5B,CAAC;AAIF;;GAEG;AACH,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;CAQ5B,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{colorPropDef as e}from"../props/color.prop.js";import{highContrastPropDef as o}from"../props/high-contrast.prop.js";import{radiusPropDef as t}from"../props/radius.prop.js";import{widthPropDefs as s}from"../props/width.props.js";const r=["1","2","3"],a={size:{type:"enum",className:"rt-r-size",values:r,default:"2",responsive:!0}},n=["classic","surface","soft","outline","ghost"],i={variant:{type:"enum",className:"rt-variant",values:n,default:"surface"},panelBackground:{type:"enum",className:"rt-panel-background",values:["solid","translucent"]},material:{type:"enum",values:["solid","translucent"]}
|
|
1
|
+
import{colorPropDef as e}from"../props/color.prop.js";import{highContrastPropDef as o}from"../props/high-contrast.prop.js";import{radiusPropDef as t}from"../props/radius.prop.js";import{widthPropDefs as s}from"../props/width.props.js";const r=["1","2","3"],a={size:{type:"enum",className:"rt-r-size",values:r,default:"2",responsive:!0},...o},n=["classic","surface","soft","outline","ghost"],i={variant:{type:"enum",className:"rt-variant",values:n,default:"surface"},panelBackground:{type:"enum",className:"rt-panel-background",values:["solid","translucent"]},material:{type:"enum",values:["solid","translucent"]},error:{type:"boolean"},loading:{type:"boolean"},disabled:{type:"boolean"},readOnly:{type:"boolean"},...e,...t,width:s.width,placeholder:{type:"string"}},p=["solid","soft"],l={size:{type:"enum",className:"rt-r-size",values:r,default:"2",responsive:!0},variant:{type:"enum",className:"rt-variant",values:p,default:"solid"},...e,...o};export{l as comboboxContentPropDefs,a as comboboxRootPropDefs,i as comboboxTriggerPropDefs};
|
|
2
2
|
//# sourceMappingURL=combobox.props.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/combobox.props.tsx"],
|
|
4
|
-
"sourcesContent": ["import { colorPropDef } from '../props/color.prop.js';\nimport { highContrastPropDef } from '../props/high-contrast.prop.js';\nimport { radiusPropDef } from '../props/radius.prop.js';\nimport { widthPropDefs } from '../props/width.props.js';\n\nimport type { PropDef } from '../props/prop-def.js';\n\nconst sizes = ['1', '2', '3'] as const;\n\nconst comboboxRootPropDefs = {\n size: { type: 'enum', className: 'rt-r-size', values: sizes, default: '2', responsive: true },\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n};\n\nconst triggerVariants = ['classic', 'surface', 'soft', 'outline', 'ghost'] as const;\n\nconst comboboxTriggerPropDefs = {\n variant: { type: 'enum', className: 'rt-variant', values: triggerVariants, default: 'surface' },\n panelBackground: {\n type: 'enum',\n className: 'rt-panel-background',\n values: ['solid', 'translucent'],\n },\n material: { type: 'enum', values: ['solid', 'translucent'] },\n
|
|
5
|
-
"mappings": "AAAA,OAAS,gBAAAA,MAAoB,yBAC7B,OAAS,uBAAAC,MAA2B,iCACpC,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,iBAAAC,MAAqB,0BAI9B,MAAMC,EAAQ,CAAC,IAAK,IAAK,GAAG,
|
|
4
|
+
"sourcesContent": ["import { colorPropDef } from '../props/color.prop.js';\nimport { highContrastPropDef } from '../props/high-contrast.prop.js';\nimport { radiusPropDef } from '../props/radius.prop.js';\nimport { widthPropDefs } from '../props/width.props.js';\n\nimport type { PropDef } from '../props/prop-def.js';\n\nconst sizes = ['1', '2', '3'] as const;\n\n/**\n * Shared responsive sizing + high contrast support inherited by Combobox.Root.\n */\nconst comboboxRootPropDefs = {\n size: { type: 'enum', className: 'rt-r-size', values: sizes, default: '2', responsive: true },\n ...highContrastPropDef,\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n highContrast: PropDef<boolean>;\n};\n\nconst triggerVariants = ['classic', 'surface', 'soft', 'outline', 'ghost'] as const;\n\n/**\n * Token-aware props specific to Combobox.Trigger.\n */\nconst comboboxTriggerPropDefs = {\n variant: { type: 'enum', className: 'rt-variant', values: triggerVariants, default: 'surface' },\n panelBackground: {\n type: 'enum',\n className: 'rt-panel-background',\n values: ['solid', 'translucent'],\n },\n material: { type: 'enum', values: ['solid', 'translucent'] },\n error: { type: 'boolean' },\n loading: { type: 'boolean' },\n disabled: { type: 'boolean' },\n readOnly: { type: 'boolean' },\n ...colorPropDef,\n ...radiusPropDef,\n width: widthPropDefs.width,\n placeholder: { type: 'string' },\n} satisfies {\n variant: PropDef<(typeof triggerVariants)[number]>;\n panelBackground: PropDef<'solid' | 'translucent'>;\n material: PropDef<'solid' | 'translucent'>;\n error: PropDef<boolean>;\n loading: PropDef<boolean>;\n disabled: PropDef<boolean>;\n readOnly: PropDef<boolean>;\n width: PropDef<string>;\n placeholder: PropDef<string>;\n};\n\nconst contentVariants = ['solid', 'soft'] as const;\n\n/**\n * Styling props for the dropdown surface rendered by Combobox.Content.\n */\nconst comboboxContentPropDefs = {\n size: { type: 'enum', className: 'rt-r-size', values: sizes, default: '2', responsive: true },\n variant: { type: 'enum', className: 'rt-variant', values: contentVariants, default: 'solid' },\n ...colorPropDef,\n ...highContrastPropDef,\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n variant: PropDef<(typeof contentVariants)[number]>;\n};\n\nexport { comboboxRootPropDefs, comboboxTriggerPropDefs, comboboxContentPropDefs };\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,gBAAAA,MAAoB,yBAC7B,OAAS,uBAAAC,MAA2B,iCACpC,OAAS,iBAAAC,MAAqB,0BAC9B,OAAS,iBAAAC,MAAqB,0BAI9B,MAAMC,EAAQ,CAAC,IAAK,IAAK,GAAG,EAKtBC,EAAuB,CAC3B,KAAM,CAAE,KAAM,OAAQ,UAAW,YAAa,OAAQD,EAAO,QAAS,IAAK,WAAY,EAAK,EAC5F,GAAGH,CACL,EAKMK,EAAkB,CAAC,UAAW,UAAW,OAAQ,UAAW,OAAO,EAKnEC,EAA0B,CAC9B,QAAS,CAAE,KAAM,OAAQ,UAAW,aAAc,OAAQD,EAAiB,QAAS,SAAU,EAC9F,gBAAiB,CACf,KAAM,OACN,UAAW,sBACX,OAAQ,CAAC,QAAS,aAAa,CACjC,EACA,SAAU,CAAE,KAAM,OAAQ,OAAQ,CAAC,QAAS,aAAa,CAAE,EAC3D,MAAO,CAAE,KAAM,SAAU,EACzB,QAAS,CAAE,KAAM,SAAU,EAC3B,SAAU,CAAE,KAAM,SAAU,EAC5B,SAAU,CAAE,KAAM,SAAU,EAC5B,GAAGN,EACH,GAAGE,EACH,MAAOC,EAAc,MACrB,YAAa,CAAE,KAAM,QAAS,CAChC,EAYMK,EAAkB,CAAC,QAAS,MAAM,EAKlCC,EAA0B,CAC9B,KAAM,CAAE,KAAM,OAAQ,UAAW,YAAa,OAAQL,EAAO,QAAS,IAAK,WAAY,EAAK,EAC5F,QAAS,CAAE,KAAM,OAAQ,UAAW,aAAc,OAAQI,EAAiB,QAAS,OAAQ,EAC5F,GAAGR,EACH,GAAGC,CACL",
|
|
6
6
|
"names": ["colorPropDef", "highContrastPropDef", "radiusPropDef", "widthPropDefs", "sizes", "comboboxRootPropDefs", "triggerVariants", "comboboxTriggerPropDefs", "contentVariants", "comboboxContentPropDefs"]
|
|
7
7
|
}
|
package/package.json
CHANGED
package/schemas/base-button.json
CHANGED
|
@@ -279,6 +279,6 @@
|
|
|
279
279
|
"title": "Base-button Component Props",
|
|
280
280
|
"description": "Props schema for the base-button component in Kookie UI",
|
|
281
281
|
"version": "1.0.0",
|
|
282
|
-
"generatedAt": "2025-
|
|
282
|
+
"generatedAt": "2025-12-04T10:05:53.518Z",
|
|
283
283
|
"source": "Zod schema"
|
|
284
284
|
}
|
package/schemas/button.json
CHANGED
|
@@ -530,6 +530,6 @@
|
|
|
530
530
|
"title": "Button Component Props",
|
|
531
531
|
"description": "Props schema for the button component in Kookie UI",
|
|
532
532
|
"version": "1.0.0",
|
|
533
|
-
"generatedAt": "2025-
|
|
533
|
+
"generatedAt": "2025-12-04T10:05:53.523Z",
|
|
534
534
|
"source": "Zod schema"
|
|
535
535
|
}
|
package/schemas/icon-button.json
CHANGED
|
@@ -313,6 +313,6 @@
|
|
|
313
313
|
"title": "Icon-button Component Props",
|
|
314
314
|
"description": "Props schema for the icon-button component in Kookie UI",
|
|
315
315
|
"version": "1.0.0",
|
|
316
|
-
"generatedAt": "2025-
|
|
316
|
+
"generatedAt": "2025-12-04T10:05:53.525Z",
|
|
317
317
|
"source": "Zod schema"
|
|
318
318
|
}
|
package/schemas/index.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"title": "Kookie UI Button Components",
|
|
4
4
|
"description": "Complete JSON Schema collection for all button components in Kookie UI",
|
|
5
5
|
"version": "1.0.0",
|
|
6
|
-
"generatedAt": "2025-
|
|
6
|
+
"generatedAt": "2025-12-04T10:05:53.527Z",
|
|
7
7
|
"source": "Zod schemas",
|
|
8
8
|
"components": {
|
|
9
9
|
"base-button": {
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
"title": "Base-button Component Props",
|
|
288
288
|
"description": "Props schema for the base-button component in Kookie UI",
|
|
289
289
|
"version": "1.0.0",
|
|
290
|
-
"generatedAt": "2025-
|
|
290
|
+
"generatedAt": "2025-12-04T10:05:53.518Z",
|
|
291
291
|
"source": "Zod schema"
|
|
292
292
|
},
|
|
293
293
|
"button": {
|
|
@@ -822,7 +822,7 @@
|
|
|
822
822
|
"title": "Button Component Props",
|
|
823
823
|
"description": "Props schema for the button component in Kookie UI",
|
|
824
824
|
"version": "1.0.0",
|
|
825
|
-
"generatedAt": "2025-
|
|
825
|
+
"generatedAt": "2025-12-04T10:05:53.523Z",
|
|
826
826
|
"source": "Zod schema"
|
|
827
827
|
},
|
|
828
828
|
"icon-button": {
|
|
@@ -1140,7 +1140,7 @@
|
|
|
1140
1140
|
"title": "Icon-button Component Props",
|
|
1141
1141
|
"description": "Props schema for the icon-button component in Kookie UI",
|
|
1142
1142
|
"version": "1.0.0",
|
|
1143
|
-
"generatedAt": "2025-
|
|
1143
|
+
"generatedAt": "2025-12-04T10:05:53.525Z",
|
|
1144
1144
|
"source": "Zod schema"
|
|
1145
1145
|
},
|
|
1146
1146
|
"toggle-button": {
|
|
@@ -1683,7 +1683,7 @@
|
|
|
1683
1683
|
"title": "Toggle-button Component Props",
|
|
1684
1684
|
"description": "Props schema for the toggle-button component in Kookie UI",
|
|
1685
1685
|
"version": "1.0.0",
|
|
1686
|
-
"generatedAt": "2025-
|
|
1686
|
+
"generatedAt": "2025-12-04T10:05:53.526Z",
|
|
1687
1687
|
"source": "Zod schema"
|
|
1688
1688
|
},
|
|
1689
1689
|
"toggle-icon-button": {
|
|
@@ -2009,7 +2009,7 @@
|
|
|
2009
2009
|
"title": "Toggle-icon-button Component Props",
|
|
2010
2010
|
"description": "Props schema for the toggle-icon-button component in Kookie UI",
|
|
2011
2011
|
"version": "1.0.0",
|
|
2012
|
-
"generatedAt": "2025-
|
|
2012
|
+
"generatedAt": "2025-12-04T10:05:53.527Z",
|
|
2013
2013
|
"source": "Zod schema"
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
@@ -538,6 +538,6 @@
|
|
|
538
538
|
"title": "Toggle-button Component Props",
|
|
539
539
|
"description": "Props schema for the toggle-button component in Kookie UI",
|
|
540
540
|
"version": "1.0.0",
|
|
541
|
-
"generatedAt": "2025-
|
|
541
|
+
"generatedAt": "2025-12-04T10:05:53.526Z",
|
|
542
542
|
"source": "Zod schema"
|
|
543
543
|
}
|
|
@@ -321,6 +321,6 @@
|
|
|
321
321
|
"title": "Toggle-icon-button Component Props",
|
|
322
322
|
"description": "Props schema for the toggle-icon-button component in Kookie UI",
|
|
323
323
|
"version": "1.0.0",
|
|
324
|
-
"generatedAt": "2025-
|
|
324
|
+
"generatedAt": "2025-12-04T10:05:53.527Z",
|
|
325
325
|
"source": "Zod schema"
|
|
326
326
|
}
|
|
@@ -189,9 +189,9 @@
|
|
|
189
189
|
letter-spacing: var(--letter-spacing-2);
|
|
190
190
|
}
|
|
191
191
|
.rt-ChatbarRoot:where(.rt-r-size-3) .rt-ChatbarBox {
|
|
192
|
-
/*
|
|
193
|
-
border-radius: min(var(--radius-
|
|
194
|
-
padding: var(--space-
|
|
192
|
+
/* Custom Chatbar size 3, different to Card size 4 */
|
|
193
|
+
border-radius: min(var(--radius-7), calc(var(--radius-3) + var(--space-3)));
|
|
194
|
+
padding: var(--space-4);
|
|
195
195
|
}
|
|
196
196
|
.rt-ChatbarRoot:where(.rt-r-size-3) .rt-ChatbarInput {
|
|
197
197
|
--text-area-padding-y: calc(var(--space-5) - var(--text-area-border-width));
|