@evinvest/uikit 0.27.0 → 0.29.1

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/select.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { SELECT_CONTENT_BOUNDS, SELECT_ITEM, selectTriggerSizeClasses, type SelectTriggerSize } from \"../generated/select\";\nimport { useControllableState } from \"../primitives/use-controllable-state\";\nimport { useFloating } from \"../primitives/use-floating\";\nimport { DismissableLayerScope, useDismissableLayer } from \"../primitives/dismissable-layer\";\nimport { usePresence } from \"../primitives/presence\";\nimport { mergeRefs } from \"../primitives/merge-refs\";\nimport { Portal } from \"../primitives/portal\";\nimport { walkElements } from \"../primitives/walk-elements\";\nimport { useFieldControlId } from \"./field-context\";\nimport { SelectChevron } from \"./select-chevron\";\nimport { landOnChosen, tabFromTrigger, useListboxKeys } from \"./select-listbox\";\n\nexport type { SelectTriggerSize };\n\ninterface SelectContextValue {\n value: string;\n setValue: (next: string) => void;\n open: boolean;\n setOpen: (next: boolean) => void;\n /**\n * Closes the list. `restoreFocus`: hand focus back to the trigger — after a\n * key or a choice, never after a click elsewhere, where it would land on the\n * trigger for a moment and fire its blur (a field's validation) on the way out.\n */\n close: (restoreFocus: boolean) => void;\n /** Set by `close(true)`, read once the list is gone. */\n restoreFocusRef: React.RefObject<boolean>;\n anchorRef: React.RefObject<HTMLElement | null>;\n /** The listbox's id, for the trigger's `aria-controls`. */\n contentId: string;\n /** What `SelectValue` shows for a value: the matching `SelectItem`'s children. */\n labelOf: (value: string) => string;\n registerLabel: (value: string, label: string) => void;\n}\n\nconst SelectContext = React.createContext<SelectContextValue | null>(null);\n\nfunction useSelect(): SelectContextValue {\n const ctx = React.useContext(SelectContext);\n if (!ctx) throw new Error(\"Select parts must be used within <Select>\");\n return ctx;\n}\n\nexport interface SelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: React.ReactNode;\n}\n\nexport function Select({\n value,\n defaultValue = \"\",\n onValueChange,\n open,\n defaultOpen = false,\n onOpenChange,\n children,\n}: SelectProps) {\n const [currentValue, setValue] = useControllableState<string>({\n ...(value !== undefined ? { value } : {}),\n defaultValue,\n ...(onValueChange ? { onChange: onValueChange } : {}),\n });\n const [isOpen, setOpen] = useControllableState<boolean>({\n ...(open !== undefined ? { value: open } : {}),\n defaultValue: defaultOpen,\n ...(onOpenChange ? { onChange: onOpenChange } : {}),\n });\n const anchorRef = React.useRef<HTMLElement | null>(null);\n const contentId = React.useId();\n const restoreFocusRef = React.useRef(false);\n const close = React.useCallback(\n (restoreFocus: boolean) => {\n restoreFocusRef.current = restoreFocus;\n setOpen(false);\n },\n [setOpen],\n );\n // The items live in a closed popover, so they are not mounted when the\n // trigger first renders — on the server least of all. Their labels are read\n // off the element tree instead; items hidden behind a component of the\n // caller's register once they have mounted (i.e. after the first open), and\n // a label learnt that way re-renders the trigger once.\n const declared = React.useMemo(() => collectItemLabels(children), [children]);\n const mounted = React.useRef(new Map<string, string>());\n const [, bump] = React.useReducer((n: number) => n + 1, 0);\n const labelOf = (v: string) => declared.get(v) ?? mounted.current.get(v) ?? v;\n const registerLabel = React.useCallback(\n (v: string, label: string) => {\n if (mounted.current.get(v) === label) return;\n mounted.current.set(v, label);\n if (!declared.has(v)) bump();\n },\n [declared],\n );\n return (\n <SelectContext.Provider\n value={{\n value: currentValue,\n setValue,\n open: isOpen,\n setOpen,\n close,\n restoreFocusRef,\n anchorRef,\n contentId,\n labelOf,\n registerLabel,\n }}\n >\n {children}\n </SelectContext.Provider>\n );\n}\n\nfunction collectItemLabels(node: React.ReactNode): Map<string, string> {\n const labels = new Map<string, string>();\n walkElements(node, (element) => {\n if (element.type !== SelectItem) return true;\n const { value, textValue, children } = element.props as Partial<SelectItemProps>;\n if (typeof value === \"string\") labels.set(value, itemLabel(value, textValue, children));\n return false;\n });\n return labels;\n}\n\n/**\n * What the trigger shows for an item: its `textValue`, else the text of its\n * children. Text, not the children themselves — an item's markup rendered a\n * second time in the trigger would duplicate any id inside it.\n */\nfunction itemLabel(value: string, textValue: string | undefined, children: unknown): string {\n return textValue ?? (textOf(children).trim() || value);\n}\n\nfunction textOf(node: unknown): string {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(textOf).join(\"\");\n if (React.isValidElement<{ children?: unknown }>(node)) return textOf(node.props.children);\n return \"\";\n}\n\nexport interface SelectTriggerProps extends React.ComponentProps<\"button\"> {\n size?: SelectTriggerSize;\n}\n\nexport function SelectTrigger({\n className,\n size = \"md\",\n onClick,\n onKeyDown,\n children,\n id,\n ...props\n}: SelectTriggerProps) {\n const { open, setOpen, close, anchorRef, contentId } = useSelect();\n return (\n <button\n type=\"button\"\n role=\"combobox\"\n id={useFieldControlId(id)}\n data-slot=\"select-trigger\"\n data-size={size}\n data-state={open ? \"open\" : \"closed\"}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n ref={anchorRef as React.Ref<HTMLButtonElement>}\n onClick={(e) => {\n onClick?.(e);\n if (open) close(true);\n else setOpen(true);\n }}\n onKeyDown={(e) => {\n onKeyDown?.(e);\n // A native select opens on the arrows too; Enter and Space already click the button.\n if (!e.defaultPrevented && !open && (e.key === \"ArrowDown\" || e.key === \"ArrowUp\")) {\n e.preventDefault();\n setOpen(true);\n }\n }}\n className={cn(\n // The placeholder mark is on `SelectValue`'s span, not on this button.\n \"border-input [&_[data-placeholder]]:text-ink-soft [&_svg:not([class*='text-'])]:text-ink-soft focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-accent-error/20 aria-invalid:border-accent-error flex w-fit items-center justify-between gap-2 rounded-[var(--control-radius)] border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n selectTriggerSizeClasses[size],\n className,\n )}\n {...(props as Record<string, unknown>)}\n >\n {children}\n <SelectChevron className=\"size-4 opacity-50\" />\n </button>\n );\n}\n\nexport interface SelectValueProps extends React.ComponentProps<\"span\"> {\n placeholder?: string;\n}\n\n/**\n * The chosen option's label — the `textValue` of the `SelectItem` whose `value`\n * matches, else the text of its children — or `placeholder` while nothing is\n * chosen. `children`, when given,\n * replace the label outright.\n */\nexport function SelectValue({ className, placeholder, children, ...props }: SelectValueProps) {\n const { value, labelOf } = useSelect();\n const isEmpty = value === \"\";\n return (\n <span\n data-slot=\"select-value\"\n {...(isEmpty ? { \"data-placeholder\": \"true\" } : {})}\n className={className}\n {...(props as Record<string, unknown>)}\n >\n {isEmpty ? placeholder : (children ?? labelOf(value))}\n </span>\n );\n}\n\nexport interface SelectContentProps extends React.ComponentProps<\"div\"> {\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n align?: \"start\" | \"center\" | \"end\";\n sideOffset?: number;\n}\n\nexport function SelectContent({\n className,\n side: sideProp = \"bottom\",\n align = \"start\",\n sideOffset = 4,\n children,\n ...props\n}: SelectContentProps) {\n const { open, setOpen, close, restoreFocusRef, anchorRef, contentId } = useSelect();\n const { isPresent, ref: presRef } = usePresence(open);\n const listRef = React.useRef<HTMLDivElement | null>(null);\n const [name, setName] = React.useState<{ \"aria-labelledby\"?: string; \"aria-label\"?: string }>({});\n // Before placement measures the list: the trigger's width as\n // `--select-trigger-width` (the floor of `SELECT_CONTENT_BOUNDS`), written to\n // the element like the floating offset, and the list's name — the trigger's\n // label, as the combobox is named.\n React.useLayoutEffect(() => {\n const anchor = anchorRef.current;\n if (!open || !(anchor instanceof HTMLElement)) return;\n listRef.current?.style.setProperty(\"--select-trigger-width\", `${anchor.offsetWidth}px`);\n setName(listName(anchor));\n }, [open, anchorRef]);\n const { floatingRef, style, side } = useFloating({\n anchorRef,\n open,\n side: sideProp,\n align,\n offset: sideOffset,\n });\n const dismissRef = useDismissableLayer({\n enabled: open,\n onDismiss: (event) => close(event.type === \"keydown\"),\n exclude: [anchorRef],\n });\n const onListKey = useListboxKeys(listRef);\n React.useEffect(() => {\n if (open) landOnChosen(listRef.current);\n }, [open]);\n React.useEffect(() => {\n if (open || !restoreFocusRef.current) return;\n restoreFocusRef.current = false;\n anchorRef.current?.focus();\n }, [open, anchorRef, restoreFocusRef]);\n if (!isPresent) return null;\n return (\n <Portal>\n <div\n role=\"listbox\"\n id={contentId}\n {...name}\n data-slot=\"select-content\"\n data-state={open ? \"open\" : \"closed\"}\n data-side={side}\n ref={mergeRefs(floatingRef, dismissRef, presRef, listRef)}\n style={style}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (onListKey(e)) return;\n if (e.key === \"Escape\") {\n // The list's Escape is the list's: a consumer's `onKeyDown` around\n // it hears the key through React's tree, portal or not.\n e.stopPropagation();\n close(true);\n } else if (e.key === \"Tab\") {\n tabFromTrigger(e, anchorRef.current);\n setOpen(false);\n }\n }}\n className={cn(\n \"bg-popover text-ink data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border shadow-md\",\n SELECT_CONTENT_BOUNDS,\n className,\n )}\n {...(props as Record<string, unknown>)}\n >\n <div className=\"p-1\"><DismissableLayerScope layer={dismissRef}>{children}</DismissableLayerScope></div>\n </div>\n </Portal>\n );\n}\n\n/** The trigger's own name for the list: its `aria-labelledby`, else its `<label>`. */\nfunction listName(trigger: HTMLElement): { \"aria-labelledby\"?: string; \"aria-label\"?: string } {\n const by = trigger.getAttribute(\"aria-labelledby\");\n if (by) return { \"aria-labelledby\": by };\n const label = (trigger as HTMLButtonElement).labels?.[0];\n if (label?.id) return { \"aria-labelledby\": label.id };\n const text = label?.textContent?.trim() || trigger.getAttribute(\"aria-label\");\n return text ? { \"aria-label\": text } : {};\n}\n\nexport interface SelectItemProps extends React.ComponentProps<\"div\"> {\n value: string;\n /** What the trigger shows once this item is chosen; defaults to the text of `children`. */\n textValue?: string;\n}\n\nexport function SelectItem({ className, value, textValue, children, ...props }: SelectItemProps) {\n const { value: selectedValue, setValue, close, registerLabel } = useSelect();\n const selected = selectedValue === value;\n const label = itemLabel(value, textValue, children);\n React.useEffect(() => registerLabel(value, label), [registerLabel, value, label]);\n const choose = () => {\n setValue(value);\n close(true);\n };\n return (\n <div\n role=\"option\"\n data-slot=\"select-item\"\n aria-selected={selected}\n tabIndex={-1}\n onClick={choose}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n choose();\n }\n }}\n className={cn(SELECT_ITEM, className)}\n {...(props as Record<string, unknown>)}\n >\n {selected ? (\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"size-4\"\n aria-hidden=\"true\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n </span>\n ) : null}\n <span>{children}</span>\n </div>\n );\n}\n\nexport function SelectGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return <div role=\"group\" data-slot=\"select-group\" className={className} {...props} />;\n}\n\nexport function SelectLabel({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"select-label\"\n className={cn(\"text-ink-soft px-2 py-1.5 text-xs\", className)}\n {...props}\n />\n );\n}\n\nexport function SelectSeparator({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"select-separator\"\n className={cn(\"bg-border pointer-events-none -mx-1 my-1 h-px\", className)}\n {...props}\n />\n );\n}\n"],"mappings":";AAwGI,cA6DA,YA7DA;AAtGJ,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,uBAAuB,aAAa,gCAAwD;AACrG,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;AAC9B,SAAS,cAAc,gBAAgB,sBAAsB;AAyB7D,MAAM,gBAAgB,MAAM,cAAyC,IAAI;AAEzE,SAAS,YAAgC;AACvC,QAAM,MAAM,MAAM,WAAW,aAAa;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,2CAA2C;AACrE,SAAO;AACT;AAYO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AACF,GAAgB;AACd,QAAM,CAAC,cAAc,QAAQ,IAAI,qBAA6B;AAAA,IAC5D,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,CAAC;AAAA,IACvC;AAAA,IACA,GAAI,gBAAgB,EAAE,UAAU,cAAc,IAAI,CAAC;AAAA,EACrD,CAAC;AACD,QAAM,CAAC,QAAQ,OAAO,IAAI,qBAA8B;AAAA,IACtD,GAAI,SAAS,SAAY,EAAE,OAAO,KAAK,IAAI,CAAC;AAAA,IAC5C,cAAc;AAAA,IACd,GAAI,eAAe,EAAE,UAAU,aAAa,IAAI,CAAC;AAAA,EACnD,CAAC;AACD,QAAM,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C;AAChF,SAAO,oBAAC,SAAI,MAAK,SAAQ,aAAU,gBAAe,WAAuB,GAAG,OAAO;AACrF;AAEO,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAgC;AAChF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,qCAAqC,SAAS;AAAA,MAC3D,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,SAAS,gBAAgB,EAAE,WAAW,GAAG,MAAM,GAAgC;AACpF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,iDAAiD,SAAS;AAAA,MACvE,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/select.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { SELECT_CONTENT_BOUNDS, SELECT_ITEM, selectTriggerSizeClasses, type SelectTriggerSize } from \"../generated/select\";\nimport { useControllableState } from \"../primitives/use-controllable-state\";\nimport { useFloating } from \"../primitives/use-floating\";\nimport { DismissableLayerScope, useDismissableLayer } from \"../primitives/dismissable-layer\";\nimport { usePresence } from \"../primitives/presence\";\nimport { mergeRefs } from \"../primitives/merge-refs\";\nimport { Portal } from \"../primitives/portal\";\nimport { walkElements } from \"../primitives/walk-elements\";\nimport { markLabelable } from \"../primitives/labelable\";\nimport { useFieldControlId } from \"./field-context\";\nimport { SelectChevron } from \"./select-chevron\";\nimport { landOnChosen, tabFromTrigger, useListboxKeys } from \"./select-listbox\";\n\nexport type { SelectTriggerSize };\n\ninterface SelectContextValue {\n value: string;\n setValue: (next: string) => void;\n open: boolean;\n setOpen: (next: boolean) => void;\n /**\n * Closes the list. `restoreFocus`: hand focus back to the trigger — after a\n * key or a choice, never after a click elsewhere, where it would land on the\n * trigger for a moment and fire its blur (a field's validation) on the way out.\n */\n close: (restoreFocus: boolean) => void;\n /** Set by `close(true)`, read once the list is gone. */\n restoreFocusRef: React.RefObject<boolean>;\n anchorRef: React.RefObject<HTMLElement | null>;\n /** The listbox's id, for the trigger's `aria-controls`. */\n contentId: string;\n /** What `SelectValue` shows for a value: the matching `SelectItem`'s children. */\n labelOf: (value: string) => string;\n registerLabel: (value: string, label: string) => void;\n}\n\nconst SelectContext = React.createContext<SelectContextValue | null>(null);\n\nfunction useSelect(): SelectContextValue {\n const ctx = React.useContext(SelectContext);\n if (!ctx) throw new Error(\"Select parts must be used within <Select>\");\n return ctx;\n}\n\nexport interface SelectProps {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: React.ReactNode;\n}\n\nexport function Select({\n value,\n defaultValue = \"\",\n onValueChange,\n open,\n defaultOpen = false,\n onOpenChange,\n children,\n}: SelectProps) {\n const [currentValue, setValue] = useControllableState<string>({\n ...(value !== undefined ? { value } : {}),\n defaultValue,\n ...(onValueChange ? { onChange: onValueChange } : {}),\n });\n const [isOpen, setOpen] = useControllableState<boolean>({\n ...(open !== undefined ? { value: open } : {}),\n defaultValue: defaultOpen,\n ...(onOpenChange ? { onChange: onOpenChange } : {}),\n });\n const anchorRef = React.useRef<HTMLElement | null>(null);\n const contentId = React.useId();\n const restoreFocusRef = React.useRef(false);\n const close = React.useCallback(\n (restoreFocus: boolean) => {\n restoreFocusRef.current = restoreFocus;\n setOpen(false);\n },\n [setOpen],\n );\n // The items live in a closed popover, so they are not mounted when the\n // trigger first renders — on the server least of all. Their labels are read\n // off the element tree instead; items hidden behind a component of the\n // caller's register once they have mounted (i.e. after the first open), and\n // a label learnt that way re-renders the trigger once.\n const declared = React.useMemo(() => collectItemLabels(children), [children]);\n const mounted = React.useRef(new Map<string, string>());\n const [, bump] = React.useReducer((n: number) => n + 1, 0);\n const labelOf = (v: string) => declared.get(v) ?? mounted.current.get(v) ?? v;\n const registerLabel = React.useCallback(\n (v: string, label: string) => {\n if (mounted.current.get(v) === label) return;\n mounted.current.set(v, label);\n if (!declared.has(v)) bump();\n },\n [declared],\n );\n return (\n <SelectContext.Provider\n value={{\n value: currentValue,\n setValue,\n open: isOpen,\n setOpen,\n close,\n restoreFocusRef,\n anchorRef,\n contentId,\n labelOf,\n registerLabel,\n }}\n >\n {children}\n </SelectContext.Provider>\n );\n}\n\nfunction collectItemLabels(node: React.ReactNode): Map<string, string> {\n const labels = new Map<string, string>();\n walkElements(node, (element) => {\n if (element.type !== SelectItem) return true;\n const { value, textValue, children } = element.props as Partial<SelectItemProps>;\n if (typeof value === \"string\") labels.set(value, itemLabel(value, textValue, children));\n return false;\n });\n return labels;\n}\n\n/**\n * What the trigger shows for an item: its `textValue`, else the text of its\n * children. Text, not the children themselves — an item's markup rendered a\n * second time in the trigger would duplicate any id inside it.\n */\nfunction itemLabel(value: string, textValue: string | undefined, children: unknown): string {\n return textValue ?? (textOf(children).trim() || value);\n}\n\nfunction textOf(node: unknown): string {\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(textOf).join(\"\");\n if (React.isValidElement<{ children?: unknown }>(node)) return textOf(node.props.children);\n return \"\";\n}\n\nexport interface SelectTriggerProps extends React.ComponentProps<\"button\"> {\n size?: SelectTriggerSize;\n}\n\nexport function SelectTrigger({\n className,\n size = \"md\",\n onClick,\n onKeyDown,\n children,\n id,\n ...props\n}: SelectTriggerProps) {\n const { open, setOpen, close, anchorRef, contentId } = useSelect();\n return (\n <button\n type=\"button\"\n role=\"combobox\"\n id={useFieldControlId(id)}\n data-slot=\"select-trigger\"\n data-size={size}\n data-state={open ? \"open\" : \"closed\"}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n ref={anchorRef as React.Ref<HTMLButtonElement>}\n onClick={(e) => {\n onClick?.(e);\n if (open) close(true);\n else setOpen(true);\n }}\n onKeyDown={(e) => {\n onKeyDown?.(e);\n // A native select opens on the arrows too; Enter and Space already click the button.\n if (!e.defaultPrevented && !open && (e.key === \"ArrowDown\" || e.key === \"ArrowUp\")) {\n e.preventDefault();\n setOpen(true);\n }\n }}\n className={cn(\n // The placeholder mark is on `SelectValue`'s span, not on this button.\n \"border-input [&_[data-placeholder]]:text-ink-soft [&_svg:not([class*='text-'])]:text-ink-soft focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-accent-error/20 aria-invalid:border-accent-error flex w-fit items-center justify-between gap-2 rounded-[var(--control-radius)] border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n selectTriggerSizeClasses[size],\n className,\n )}\n {...(props as Record<string, unknown>)}\n >\n {children}\n <SelectChevron className=\"size-4 opacity-50\" />\n </button>\n );\n}\n\nmarkLabelable(SelectTrigger);\n\nexport interface SelectValueProps extends React.ComponentProps<\"span\"> {\n placeholder?: string;\n}\n\n/**\n * The chosen option's label — the `textValue` of the `SelectItem` whose `value`\n * matches, else the text of its children — or `placeholder` while nothing is\n * chosen. `children`, when given,\n * replace the label outright.\n */\nexport function SelectValue({ className, placeholder, children, ...props }: SelectValueProps) {\n const { value, labelOf } = useSelect();\n const isEmpty = value === \"\";\n return (\n <span\n data-slot=\"select-value\"\n {...(isEmpty ? { \"data-placeholder\": \"true\" } : {})}\n className={className}\n {...(props as Record<string, unknown>)}\n >\n {isEmpty ? placeholder : (children ?? labelOf(value))}\n </span>\n );\n}\n\nexport interface SelectContentProps extends React.ComponentProps<\"div\"> {\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n align?: \"start\" | \"center\" | \"end\";\n sideOffset?: number;\n}\n\nexport function SelectContent({\n className,\n side: sideProp = \"bottom\",\n align = \"start\",\n sideOffset = 4,\n children,\n ...props\n}: SelectContentProps) {\n const { open, setOpen, close, restoreFocusRef, anchorRef, contentId } = useSelect();\n const { isPresent, ref: presRef } = usePresence(open);\n const listRef = React.useRef<HTMLDivElement | null>(null);\n const [name, setName] = React.useState<{ \"aria-labelledby\"?: string; \"aria-label\"?: string }>({});\n // Before placement measures the list: the trigger's width as\n // `--select-trigger-width` (the floor of `SELECT_CONTENT_BOUNDS`), written to\n // the element like the floating offset, and the list's name — the trigger's\n // label, as the combobox is named.\n React.useLayoutEffect(() => {\n const anchor = anchorRef.current;\n if (!open || !(anchor instanceof HTMLElement)) return;\n listRef.current?.style.setProperty(\"--select-trigger-width\", `${anchor.offsetWidth}px`);\n setName(listName(anchor));\n }, [open, anchorRef]);\n const { floatingRef, style, side } = useFloating({\n anchorRef,\n open,\n side: sideProp,\n align,\n offset: sideOffset,\n });\n const dismissRef = useDismissableLayer({\n enabled: open,\n onDismiss: (event) => close(event.type === \"keydown\"),\n exclude: [anchorRef],\n });\n const onListKey = useListboxKeys(listRef);\n React.useEffect(() => {\n if (open) landOnChosen(listRef.current);\n }, [open]);\n React.useEffect(() => {\n if (open || !restoreFocusRef.current) return;\n restoreFocusRef.current = false;\n anchorRef.current?.focus();\n }, [open, anchorRef, restoreFocusRef]);\n if (!isPresent) return null;\n return (\n <Portal>\n <div\n role=\"listbox\"\n id={contentId}\n {...name}\n data-slot=\"select-content\"\n data-state={open ? \"open\" : \"closed\"}\n data-side={side}\n ref={mergeRefs(floatingRef, dismissRef, presRef, listRef)}\n style={style}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (onListKey(e)) return;\n if (e.key === \"Escape\") {\n // The list's Escape is the list's: a consumer's `onKeyDown` around\n // it hears the key through React's tree, portal or not.\n e.stopPropagation();\n close(true);\n } else if (e.key === \"Tab\") {\n tabFromTrigger(e, anchorRef.current);\n setOpen(false);\n }\n }}\n className={cn(\n \"bg-popover text-ink data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-border shadow-md\",\n SELECT_CONTENT_BOUNDS,\n className,\n )}\n {...(props as Record<string, unknown>)}\n >\n <div className=\"p-1\"><DismissableLayerScope layer={dismissRef}>{children}</DismissableLayerScope></div>\n </div>\n </Portal>\n );\n}\n\n/** The trigger's own name for the list: its `aria-labelledby`, else its `<label>`. */\nfunction listName(trigger: HTMLElement): { \"aria-labelledby\"?: string; \"aria-label\"?: string } {\n const by = trigger.getAttribute(\"aria-labelledby\");\n if (by) return { \"aria-labelledby\": by };\n const label = (trigger as HTMLButtonElement).labels?.[0];\n if (label?.id) return { \"aria-labelledby\": label.id };\n const text = label?.textContent?.trim() || trigger.getAttribute(\"aria-label\");\n return text ? { \"aria-label\": text } : {};\n}\n\nexport interface SelectItemProps extends React.ComponentProps<\"div\"> {\n value: string;\n /** What the trigger shows once this item is chosen; defaults to the text of `children`. */\n textValue?: string;\n}\n\nexport function SelectItem({ className, value, textValue, children, ...props }: SelectItemProps) {\n const { value: selectedValue, setValue, close, registerLabel } = useSelect();\n const selected = selectedValue === value;\n const label = itemLabel(value, textValue, children);\n React.useEffect(() => registerLabel(value, label), [registerLabel, value, label]);\n const choose = () => {\n setValue(value);\n close(true);\n };\n return (\n <div\n role=\"option\"\n data-slot=\"select-item\"\n aria-selected={selected}\n tabIndex={-1}\n onClick={choose}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n choose();\n }\n }}\n className={cn(SELECT_ITEM, className)}\n {...(props as Record<string, unknown>)}\n >\n {selected ? (\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"size-4\"\n aria-hidden=\"true\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n </span>\n ) : null}\n <span>{children}</span>\n </div>\n );\n}\n\nexport function SelectGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return <div role=\"group\" data-slot=\"select-group\" className={className} {...props} />;\n}\n\nexport function SelectLabel({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"select-label\"\n className={cn(\"text-ink-soft px-2 py-1.5 text-xs\", className)}\n {...props}\n />\n );\n}\n\nexport function SelectSeparator({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"select-separator\"\n className={cn(\"bg-border pointer-events-none -mx-1 my-1 h-px\", className)}\n {...props}\n />\n );\n}\n"],"mappings":";AAyGI,cA6DA,YA7DA;AAvGJ,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,uBAAuB,aAAa,gCAAwD;AACrG,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;AAC9B,SAAS,cAAc,gBAAgB,sBAAsB;AAyB7D,MAAM,gBAAgB,MAAM,cAAyC,IAAI;AAEzE,SAAS,YAAgC;AACvC,QAAM,MAAM,MAAM,WAAW,aAAa;AAC1C,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,2CAA2C;AACrE,SAAO;AACT;AAYO,SAAS,OAAO;AAAA,EACrB;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AACF,GAAgB;A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AAC,UAAK,WAAU,8DACd;AAAA,UAAC;AAAA;AAAA,YACC,OAAM;AAAA,YACN,OAAM;AAAA,YACN,QAAO;AAAA,YACP,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,QAAO;AAAA,YACP,aAAY;AAAA,YACZ,eAAc;AAAA,YACd,gBAAe;AAAA,YACf,WAAU;AAAA,YACV,eAAY;AAAA,YAEZ,8BAAC,UAAK,GAAE,mBAAkB;AAAA;AAAA,QAC5B,GACF,IACE;AAAA,QACJ,oBAAC,UAAM,UAAS;AAAA;AAAA;AAAA,EAClB;AAEJ;AAEO,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAgC;AAChF,SAAO,oBAAC,SAAI,MAAK,SAAQ,aAAU,gBAAe,WAAuB,GAAG,OAAO;AACrF;AAEO,SAAS,YAAY,EAAE,WAAW,GAAG,MAAM,GAAgC;AAChF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,qCAAqC,SAAS;AAAA,MAC3D,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,SAAS,gBAAgB,EAAE,WAAW,GAAG,MAAM,GAAgC;AACpF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,WAAW,GAAG,iDAAiD,SAAS;AAAA,MACvE,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import { cn } from "../lib/cn.js";
5
5
  import { SWITCH_BASE, SWITCH_THUMB } from "../generated/switch.js";
6
6
  import { useControllableState } from "../primitives/use-controllable-state.js";
7
+ import { markLabelable } from "../primitives/labelable.js";
7
8
  import { useFieldControlId } from "./field-context.js";
8
9
  function Switch({
9
10
  className,
@@ -48,6 +49,7 @@ function Switch({
48
49
  }
49
50
  );
50
51
  }
52
+ markLabelable(Switch);
51
53
  export {
52
54
  Switch
53
55
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/switch.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { SWITCH_BASE, SWITCH_THUMB } from \"../generated/switch\";\nimport { useControllableState } from \"../primitives/use-controllable-state\";\nimport { useFieldControlId } from \"./field-context\";\n\nexport interface SwitchProps\n extends Omit<React.ComponentProps<\"button\">, \"onChange\"> {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function Switch({\n className,\n checked,\n defaultChecked = false,\n onCheckedChange,\n onClick,\n disabled,\n id,\n ...props\n}: SwitchProps) {\n const [on, setOn] = useControllableState<boolean>({\n ...(checked !== undefined ? { value: checked } : {}),\n defaultValue: defaultChecked,\n ...(onCheckedChange ? { onChange: onCheckedChange } : {}),\n });\n const state = on ? \"checked\" : \"unchecked\";\n return (\n <button\n type=\"button\"\n role=\"switch\"\n data-slot=\"switch\"\n data-state={state}\n aria-checked={on}\n disabled={disabled}\n id={useFieldControlId(id)}\n className={cn(SWITCH_BASE, className)}\n onClick={(e) => {\n onClick?.(e);\n setOn(!on);\n }}\n {...props}\n >\n <span\n data-slot=\"switch-thumb\"\n data-state={state}\n className={SWITCH_THUMB}\n />\n </button>\n );\n}\n"],"mappings":";AA+CM;AA7CN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAS3B,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAgB;AACd,QAAM,CAAC,IAAI,KAAK,IAAI,qBAA8B;AAAA,IAChD,GAAI,YAAY,SAAY,EAAE,OAAO,QAAQ,IAAI,CAAC;AAAA,IAClD,cAAc;AAAA,IACd,GAAI,kBAAkB,EAAE,UAAU,gBAAgB,IAAI,CAAC;AAAA,EACzD,CAAC;AACD,QAAM,QAAQ,KAAK,YAAY;AAC/B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAK;AAAA,MACL,aAAU;AAAA,MACV,cAAY;AAAA,MACZ,gBAAc;AAAA,MACd;AAAA,MACA,IAAI,kBAAkB,EAAE;AAAA,MACxB,WAAW,GAAG,aAAa,SAAS;AAAA,MACpC,SAAS,CAAC,MAAM;AACd,kBAAU,CAAC;AACX,cAAM,CAAC,EAAE;AAAA,MACX;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,cAAY;AAAA,UACZ,WAAW;AAAA;AAAA,MACb;AAAA;AAAA,EACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/switch.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { SWITCH_BASE, SWITCH_THUMB } from \"../generated/switch\";\nimport { useControllableState } from \"../primitives/use-controllable-state\";\nimport { markLabelable } from \"../primitives/labelable\";\nimport { useFieldControlId } from \"./field-context\";\n\nexport interface SwitchProps\n extends Omit<React.ComponentProps<\"button\">, \"onChange\"> {\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: (checked: boolean) => void;\n}\n\nexport function Switch({\n className,\n checked,\n defaultChecked = false,\n onCheckedChange,\n onClick,\n disabled,\n id,\n ...props\n}: SwitchProps) {\n const [on, setOn] = useControllableState<boolean>({\n ...(checked !== undefined ? { value: checked } : {}),\n defaultValue: defaultChecked,\n ...(onCheckedChange ? { onChange: onCheckedChange } : {}),\n });\n const state = on ? \"checked\" : \"unchecked\";\n return (\n <button\n type=\"button\"\n role=\"switch\"\n data-slot=\"switch\"\n data-state={state}\n aria-checked={on}\n disabled={disabled}\n id={useFieldControlId(id)}\n className={cn(SWITCH_BASE, className)}\n onClick={(e) => {\n onClick?.(e);\n setOn(!on);\n }}\n {...props}\n >\n <span\n data-slot=\"switch-thumb\"\n data-state={state}\n className={SWITCH_THUMB}\n />\n </button>\n );\n}\n\nmarkLabelable(Switch);\n"],"mappings":";AAgDM;AA9CN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa,oBAAoB;AAC1C,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAS3B,SAAS,OAAO;AAAA,EACrB;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAgB;AACd,QAAM,CAAC,IAAI,KAAK,IAAI,qBAA8B;AAAA,IAChD,GAAI,YAAY,SAAY,EAAE,OAAO,QAAQ,IAAI,CAAC;AAAA,IAClD,cAAc;AAAA,IACd,GAAI,kBAAkB,EAAE,UAAU,gBAAgB,IAAI,CAAC;AAAA,EACzD,CAAC;AACD,QAAM,QAAQ,KAAK,YAAY;AAC/B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,MAAK;AAAA,MACL,aAAU;AAAA,MACV,cAAY;AAAA,MACZ,gBAAc;AAAA,MACd;AAAA,MACA,IAAI,kBAAkB,EAAE;AAAA,MACxB,WAAW,GAAG,aAAa,SAAS;AAAA,MACpC,SAAS,CAAC,MAAM;AACd,kBAAU,CAAC;AACX,cAAM,CAAC,EAAE;AAAA,MACX;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,cAAY;AAAA,UACZ,WAAW;AAAA;AAAA,MACb;AAAA;AAAA,EACF;AAEJ;AAEA,cAAc,MAAM;","names":[]}
@@ -3,6 +3,7 @@ import { jsx } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { cn } from "../lib/cn.js";
5
5
  import { TEXTAREA_BASE, textareaSizeClasses } from "../generated/textarea.js";
6
+ import { markLabelable } from "../primitives/labelable.js";
6
7
  import { useFieldControlId } from "./field-context.js";
7
8
  function Textarea({ className, id, size = "md", ...props }) {
8
9
  return /* @__PURE__ */ jsx(
@@ -16,6 +17,7 @@ function Textarea({ className, id, size = "md", ...props }) {
16
17
  }
17
18
  );
18
19
  }
20
+ markLabelable(Textarea);
19
21
  export {
20
22
  Textarea
21
23
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/textarea.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { TEXTAREA_BASE, textareaSizeClasses, type TextareaSize } from \"../generated/textarea\";\nimport { useFieldControlId } from \"./field-context\";\n\nexport type { TextareaSize };\n\nexport interface TextareaProps extends React.ComponentProps<\"textarea\"> {\n size?: TextareaSize;\n}\n\nexport function Textarea({ className, id, size = \"md\", ...props }: TextareaProps) {\n return (\n <textarea\n data-slot=\"textarea\"\n data-size={size}\n id={useFieldControlId(id)}\n className={cn(TEXTAREA_BASE, textareaSizeClasses[size], className)}\n {...props}\n />\n );\n}\n"],"mappings":";AAeI;AAbJ,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,eAAe,2BAA8C;AACtE,SAAS,yBAAyB;AAQ3B,SAAS,SAAS,EAAE,WAAW,IAAI,OAAO,MAAM,GAAG,MAAM,GAAkB;AAChF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,aAAW;AAAA,MACX,IAAI,kBAAkB,EAAE;AAAA,MACxB,WAAW,GAAG,eAAe,oBAAoB,IAAI,GAAG,SAAS;AAAA,MAChE,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/components/textarea.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { TEXTAREA_BASE, textareaSizeClasses, type TextareaSize } from \"../generated/textarea\";\nimport { markLabelable } from \"../primitives/labelable\";\nimport { useFieldControlId } from \"./field-context\";\n\nexport type { TextareaSize };\n\nexport interface TextareaProps extends React.ComponentProps<\"textarea\"> {\n size?: TextareaSize;\n}\n\nexport function Textarea({ className, id, size = \"md\", ...props }: TextareaProps) {\n return (\n <textarea\n data-slot=\"textarea\"\n data-size={size}\n id={useFieldControlId(id)}\n className={cn(TEXTAREA_BASE, textareaSizeClasses[size], className)}\n {...props}\n />\n );\n}\n\nmarkLabelable(Textarea);\n"],"mappings":";AAgBI;AAdJ,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,eAAe,2BAA8C;AACtE,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAQ3B,SAAS,SAAS,EAAE,WAAW,IAAI,OAAO,MAAM,GAAG,MAAM,GAAkB;AAChF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,aAAU;AAAA,MACV,aAAW;AAAA,MACX,IAAI,kBAAkB,EAAE;AAAA,MACxB,WAAW,GAAG,eAAe,oBAAoB,IAAI,GAAG,SAAS;AAAA,MAChE,GAAG;AAAA;AAAA,EACN;AAEJ;AAEA,cAAc,QAAQ;","names":[]}
@@ -4,9 +4,9 @@ const COMMAND_DIALOG_CONTENT = "fixed top-1/2 left-1/2 z-50 w-full max-w-lg -tra
4
4
  const COMMAND_DIALOG_COMMAND = "[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input]]:h-12";
5
5
  const COMMAND_INPUT_WRAPPER = "flex h-9 items-center gap-2 border-b border-border px-3";
6
6
  const COMMAND_INPUT = "placeholder:text-ink-soft flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50";
7
- const COMMAND_LIST = "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto";
7
+ const COMMAND_LIST = "grid max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto";
8
8
  const COMMAND_EMPTY = "py-6 text-center text-sm";
9
- const COMMAND_GROUP = "text-ink [&_[data-slot=command-group-heading]]:text-ink-soft overflow-hidden p-1 [&_[data-slot=command-group-heading]]:px-2 [&_[data-slot=command-group-heading]]:py-1.5 [&_[data-slot=command-group-heading]]:text-xs [&_[data-slot=command-group-heading]]:font-medium";
9
+ const COMMAND_GROUP = "grid text-ink [&_[data-slot=command-group-heading]]:text-ink-soft overflow-hidden p-1 [&>[data-slot=command-group-heading]]:order-first [&_[data-slot=command-group-heading]]:px-2 [&_[data-slot=command-group-heading]]:py-1.5 [&_[data-slot=command-group-heading]]:text-xs [&_[data-slot=command-group-heading]]:font-medium";
10
10
  const COMMAND_ITEM = "data-[selected=true]:bg-hover data-[selected=true]:text-ink [&_svg:not([class*='text-'])]:text-ink-soft relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4";
11
11
  const COMMAND_SEPARATOR = "bg-border -mx-1 h-px";
12
12
  const COMMAND_SHORTCUT = "text-ink-soft ml-auto text-xs tracking-widest";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generated/command.ts"],"sourcesContent":["// AUTO-GENERATED by `nix run .#gen` — do not edit.\n\nexport const COMMAND_ROOT = \"bg-popover text-ink flex h-full w-full flex-col overflow-hidden rounded-md\";\n\nexport const COMMAND_DIALOG_OVERLAY = \"fixed inset-0 z-50 bg-black/50\";\n\nexport const COMMAND_DIALOG_CONTENT = \"fixed top-1/2 left-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-lg border border-border p-0 shadow-lg\";\n\nexport const COMMAND_DIALOG_COMMAND = \"[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input]]:h-12\";\n\nexport const COMMAND_INPUT_WRAPPER = \"flex h-9 items-center gap-2 border-b border-border px-3\";\n\nexport const COMMAND_INPUT = \"placeholder:text-ink-soft flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50\";\n\nexport const COMMAND_LIST = \"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto\";\n\nexport const COMMAND_EMPTY = \"py-6 text-center text-sm\";\n\nexport const COMMAND_GROUP = \"text-ink [&_[data-slot=command-group-heading]]:text-ink-soft overflow-hidden p-1 [&_[data-slot=command-group-heading]]:px-2 [&_[data-slot=command-group-heading]]:py-1.5 [&_[data-slot=command-group-heading]]:text-xs [&_[data-slot=command-group-heading]]:font-medium\";\n\nexport const COMMAND_ITEM = \"data-[selected=true]:bg-hover data-[selected=true]:text-ink [&_svg:not([class*='text-'])]:text-ink-soft relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\";\n\nexport const COMMAND_SEPARATOR = \"bg-border -mx-1 h-px\";\n\nexport const COMMAND_SHORTCUT = \"text-ink-soft ml-auto text-xs tracking-widest\";\n"],"mappings":"AAEO,MAAM,eAAe;AAErB,MAAM,yBAAyB;AAE/B,MAAM,yBAAyB;AAE/B,MAAM,yBAAyB;AAE/B,MAAM,wBAAwB;AAE9B,MAAM,gBAAgB;AAEtB,MAAM,eAAe;AAErB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB;AAEtB,MAAM,eAAe;AAErB,MAAM,oBAAoB;AAE1B,MAAM,mBAAmB;","names":[]}
1
+ {"version":3,"sources":["../../src/generated/command.ts"],"sourcesContent":["// AUTO-GENERATED by `nix run .#gen` — do not edit.\n\nexport const COMMAND_ROOT = \"bg-popover text-ink flex h-full w-full flex-col overflow-hidden rounded-md\";\n\nexport const COMMAND_DIALOG_OVERLAY = \"fixed inset-0 z-50 bg-black/50\";\n\nexport const COMMAND_DIALOG_CONTENT = \"fixed top-1/2 left-1/2 z-50 w-full max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-lg border border-border p-0 shadow-lg\";\n\nexport const COMMAND_DIALOG_COMMAND = \"[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input]]:h-12\";\n\nexport const COMMAND_INPUT_WRAPPER = \"flex h-9 items-center gap-2 border-b border-border px-3\";\n\nexport const COMMAND_INPUT = \"placeholder:text-ink-soft flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50\";\n\nexport const COMMAND_LIST = \"grid max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto\";\n\nexport const COMMAND_EMPTY = \"py-6 text-center text-sm\";\n\nexport const COMMAND_GROUP = \"grid text-ink [&_[data-slot=command-group-heading]]:text-ink-soft overflow-hidden p-1 [&>[data-slot=command-group-heading]]:order-first [&_[data-slot=command-group-heading]]:px-2 [&_[data-slot=command-group-heading]]:py-1.5 [&_[data-slot=command-group-heading]]:text-xs [&_[data-slot=command-group-heading]]:font-medium\";\n\nexport const COMMAND_ITEM = \"data-[selected=true]:bg-hover data-[selected=true]:text-ink [&_svg:not([class*='text-'])]:text-ink-soft relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\";\n\nexport const COMMAND_SEPARATOR = \"bg-border -mx-1 h-px\";\n\nexport const COMMAND_SHORTCUT = \"text-ink-soft ml-auto text-xs tracking-widest\";\n"],"mappings":"AAEO,MAAM,eAAe;AAErB,MAAM,yBAAyB;AAE/B,MAAM,yBAAyB;AAE/B,MAAM,yBAAyB;AAE/B,MAAM,wBAAwB;AAE9B,MAAM,gBAAgB;AAEtB,MAAM,eAAe;AAErB,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB;AAEtB,MAAM,eAAe;AAErB,MAAM,oBAAoB;AAE1B,MAAM,mBAAmB;","names":[]}
package/dist/index.d.ts CHANGED
@@ -413,6 +413,17 @@ declare function EmptyTitle({ className, ...props }: React.ComponentProps<"div">
413
413
  declare function EmptyDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
414
414
  declare function EmptyContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
415
415
 
416
+ /**
417
+ * What a section shows a caller it is not for: an `Empty` with a lock, a title, why,
418
+ * and an action slot. A guest gets the sign-in button there; a signed-in caller
419
+ * without the permission gets no action, or the host's own (request access).
420
+ */
421
+ interface AuthWallProps extends Omit<React.ComponentProps<"div">, "title"> {
422
+ title: React.ReactNode;
423
+ description: React.ReactNode;
424
+ }
425
+ declare function AuthWall({ title, description, children, ...props }: AuthWallProps): React.JSX.Element;
426
+
416
427
  declare function Label({ className, ...props }: React.ComponentProps<"label">): React.JSX.Element;
417
428
 
418
429
  declare const fieldOrientation: {
@@ -1619,42 +1630,6 @@ declare function CommandItem({ className, value, disabled, onSelect, id: idProp,
1619
1630
  declare function CommandSeparator({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
1620
1631
  declare function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
1621
1632
 
1622
- type ChartConfig = {
1623
- [k in string]: {
1624
- label?: React.ReactNode;
1625
- color?: string;
1626
- };
1627
- };
1628
- declare function ChartContainer({ id, className, children, config, ...props }: React.ComponentProps<"div"> & {
1629
- config: ChartConfig;
1630
- }): React.JSX.Element;
1631
- declare const ChartStyle: ({ id, config }: {
1632
- id: string;
1633
- config: ChartConfig;
1634
- }) => React.JSX.Element | null;
1635
- type ChartItem = {
1636
- label?: React.ReactNode;
1637
- value?: React.ReactNode;
1638
- color?: string;
1639
- };
1640
- declare const ChartTooltip: ({ children }: {
1641
- children?: React.ReactNode;
1642
- }) => React.JSX.Element;
1643
- declare function ChartTooltipContent({ className, items, label, hideLabel, hideIndicator, labelClassName, }: React.ComponentProps<"div"> & {
1644
- items?: ChartItem[];
1645
- label?: React.ReactNode;
1646
- hideLabel?: boolean;
1647
- hideIndicator?: boolean;
1648
- labelClassName?: string;
1649
- }): React.JSX.Element | null;
1650
- declare const ChartLegend: ({ children }: {
1651
- children?: React.ReactNode;
1652
- }) => React.JSX.Element;
1653
- declare function ChartLegendContent({ className, hideIcon, items, }: React.ComponentProps<"div"> & {
1654
- hideIcon?: boolean;
1655
- items?: ChartItem[];
1656
- }): React.JSX.Element | null;
1657
-
1658
1633
  interface CalendarProps {
1659
1634
  /** The currently selected day, if any. */
1660
1635
  selected?: Date;
@@ -1852,24 +1827,6 @@ declare function FormControl({ error, ...props }: React.ComponentProps<typeof Sl
1852
1827
  declare function FormDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
1853
1828
  declare function FormMessage({ className, children, ...props }: React.ComponentProps<"p">): React.JSX.Element | null;
1854
1829
 
1855
- type ResizableDirection = "horizontal" | "vertical";
1856
- interface ResizablePanelGroupProps extends React.ComponentProps<"div"> {
1857
- direction?: ResizableDirection;
1858
- keyboardStep?: number;
1859
- onLayout?: (sizes: number[]) => void;
1860
- }
1861
- declare function ResizablePanelGroup({ className, direction, keyboardStep, onLayout, children, ...props }: ResizablePanelGroupProps): React.JSX.Element;
1862
- interface ResizablePanelProps extends React.ComponentProps<"div"> {
1863
- index: number;
1864
- defaultSize?: number;
1865
- }
1866
- declare function ResizablePanel({ className, index, defaultSize, style, children, ...props }: ResizablePanelProps): React.JSX.Element;
1867
- interface ResizableHandleProps extends React.ComponentProps<"div"> {
1868
- index: number;
1869
- withHandle?: boolean;
1870
- }
1871
- declare function ResizableHandle({ className, index, withHandle, children, ...props }: ResizableHandleProps): React.JSX.Element;
1872
-
1873
1830
  declare const terminalAreaClasses: {
1874
1831
  readonly ticker: "lg:col-span-3 lg:row-start-1";
1875
1832
  readonly chart: "lg:col-start-1 lg:row-start-2";
@@ -2453,4 +2410,4 @@ interface SettledProps extends Omit<React.ComponentProps<"div">, "children"> {
2453
2410
  */
2454
2411
  declare function Settled({ loading, skeleton, children, ...props }: SettledProps): React.JSX.Element;
2455
2412
 
2456
- export { type Accent, Accordion, AccordionContent, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, AccountMenu, type AccountMenuLabels, type AccountMenuProps, Alert, AlertDescription, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, type AlertDialogOverlayProps, type AlertDialogProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, AlertTitle, type AlertVariant, type Align, AppShell, type AppShellProps, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, type BadgeVariant, type BookSide, BottomTabBar, type BottomTabBarLabels, type BottomTabBarProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, type ButtonGroupOrientation, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, type ButtonGroupTextProps, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselEdgeFade, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, type ChartConfig, ChartContainer, type ChartItem, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Check, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleProps, CollapsibleTrigger, Command, CommandDialog, type CommandDialogProps, CommandEmpty, CommandGroup, type CommandGroupProps, CommandInput, CommandItem, type CommandItemProps, CommandList, type CommandProps, CommandSeparator, CommandShortcut, Container, type ContainerProps, ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, ContextMenuGroup, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, DialogTitle, DialogTrigger, type DialogTriggerProps, type DismissEvent, DismissableLayerScope, Display, Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, DrawerDescription, type DrawerDirection, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, DropdownMenuPortal, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyMediaProps, type EmptyMediaVariant, EmptyTitle, Eyebrow, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldOrientation, FieldSeparator, FieldSet, FieldTitle, type FloatingResult, Footer, type FooterLink, type FooterLinkGroup, type FooterOffice, type FooterProps, Forbidden, Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, type HoverIntentHandlers, InfoTip, InfoTipContent, type InfoTipContentProps, type InfoTipProps, InfoTipTrigger, type InfoTipTriggerProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonAlign, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupButtonSize, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, type InputOTPProps, InputOTPSeparator, InputOTPSlot, type InputOTPSlotProps, type InputProps, type InputSize, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, type ItemMediaProps, type ItemMediaVariant, type ItemProps, ItemSeparator, type ItemSize, ItemTitle, type ItemVariant, Kbd, KbdGroup, LAYER_IGNORE_ATTR, Label, ListRow, ListRowLabel, type ListRowLabelProps, type ListRowProps, ListRowValue, ListRows, type ListRowsProps, type ListRowsVariant, Logo, type LogoProps, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, type MenubarMenuProps, MenubarRadioGroup, type MenubarRadioGroupProps, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, type MenubarSubProps, MenubarSubTrigger, MenubarTrigger, MobileAppBar, type MobileAppBarBack, type MobileAppBarLabels, type MobileAppBarProps, NativeSelect, NativeSelectGroup, NativeSelectOption, type NativeSelectProps, type NativeSelectSize, NavBadge, type NavBadgeProps, type NavBadgeVariant, NavDot, type NavDotProps, type NavDotTone, type NavGroup, type NavItem, type NavItemState, type NavMatch, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFound, OpenOrdersEmpty, OrderBook, OrderBookHead, type OrderBookHeadProps, OrderBookRow, type OrderBookRowProps, OrderBookSpread, OrderForm, OrderFormRow, type OrderFormRowProps, OrderFormSubmit, type OrderFormSubmitProps, type OrderSide, PageFrame, type PageFrameProps, type PageFrameWidth, PageHeading, type PageHeadingProps, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, type Polarity, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, type PortalProps, PortalProvider, type PortalProviderProps, Progress, type ProgressProps, Prose, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, type ResizableDirection, ResizableHandle, type ResizableHandleProps, ResizablePanel, ResizablePanelGroup, type ResizablePanelGroupProps, type ResizablePanelProps, ResourceError, type ResourceErrorLabels, type ResourceErrorProps, ScrollArea, ScrollBar, type ScrollBarOrientation, type ScrollBarProps, Section, SectionDescriptor, type SectionDescriptorProps, SectionHead, type SectionHeadProps, SectionLabel, type SectionLabelProps, type SectionLabelTone, SectionNav, type SectionNavGroup, type SectionNavItem, type SectionNavLabels, type SectionNavProps, type SectionProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, type SelectItemProps, SelectLabel, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, type SelectTriggerSize, SelectValue, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, ServerError, type ServerErrorProps, Settled, type SettledProps, Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, SheetTitle, SheetTrigger, type SheetTriggerProps, type ShellBreakpoint, ShellNav, type ShellNavLabels, type ShellNavProps, type Side, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, SidebarMenuItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, type SliderProps, Slot, type SlotProps, Spinner, Stat, type StatProps, type StatusLinkData, type StatusPageProps, StatusScreen, type StatusScreenProps, type Surface, Switch, type SwitchProps, SystemBanner, type SystemBannerLabels, type SystemBannerProps, type SystemBannerTone, Table, type TableAlign, TableBody, TableCaption, TableCard, TableCell, type TableCellProps, type TableDensity, TableFooter, TableHead, type TableHeadProps, TableHeader, type TableProps, TableRow, type TableVariant, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsProps, TabsTrigger, type TabsTriggerProps, Terminal, type TerminalArea, TerminalChart, TerminalPane, TerminalPaneBody, TerminalPaneHeader, type TerminalPaneProps, TerminalTicker, Textarea, type TextareaProps, type TextareaSize, TickerStat, type TickerStatProps, type Toast, type ToastFn, type ToastOptions, type ToastPosition, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, TopBar, type TopBarProps, TradesTapeRow, type TradesTapeRowProps, buttonVariants, cn, isNavItemActive, isPlainLeftClick, mergeRefs, navItemMatch, navigationMenuTriggerStyle, resolveActiveNavItem, statusCtaClass, toast, toggleVariants, useControllableState, useDismissableLayer, useFloating, useFocusScope, useHoverIntent, usePendingNavigation, usePresence, useRovingFocus, useSidebar };
2413
+ export { type Accent, Accordion, AccordionContent, AccordionItem, type AccordionItemProps, type AccordionProps, AccordionTrigger, AccountMenu, type AccountMenuLabels, type AccountMenuProps, Alert, AlertDescription, AlertDialog, AlertDialogAction, type AlertDialogActionProps, AlertDialogCancel, type AlertDialogCancelProps, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, type AlertDialogOverlayProps, type AlertDialogProps, AlertDialogTitle, AlertDialogTrigger, type AlertDialogTriggerProps, type AlertProps, AlertTitle, type AlertVariant, type Align, AppShell, type AppShellProps, AuthWall, type AuthWallProps, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, type BadgeVariant, type BookSide, BottomTabBar, type BottomTabBarLabels, type BottomTabBarProps, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, type BreadcrumbLinkProps, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, ButtonGroup, type ButtonGroupOrientation, type ButtonGroupProps, ButtonGroupSeparator, ButtonGroupText, type ButtonGroupTextProps, type ButtonProps, type ButtonSize, type ButtonVariant, type ButtonVariantsOptions, Calendar, type CalendarProps, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselEdgeFade, CarouselItem, CarouselNext, CarouselPrevious, type CarouselProps, Check, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleProps, CollapsibleTrigger, Command, CommandDialog, type CommandDialogProps, CommandEmpty, CommandGroup, type CommandGroupProps, CommandInput, CommandItem, type CommandItemProps, CommandList, type CommandProps, CommandSeparator, CommandShortcut, Container, type ContainerProps, ContextMenu, ContextMenuCheckboxItem, type ContextMenuCheckboxItemProps, ContextMenuContent, ContextMenuGroup, ContextMenuItem, type ContextMenuItemProps, ContextMenuLabel, type ContextMenuLabelProps, ContextMenuPortal, type ContextMenuProps, ContextMenuRadioGroup, type ContextMenuRadioGroupProps, ContextMenuRadioItem, type ContextMenuRadioItemProps, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, type ContextMenuSubProps, ContextMenuSubTrigger, type ContextMenuSubTriggerProps, ContextMenuTrigger, type ContextMenuTriggerProps, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Dialog, DialogClose, type DialogCloseProps, DialogContent, type DialogContentProps, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, type DialogOverlayProps, DialogPortal, type DialogPortalProps, type DialogProps, DialogTitle, DialogTrigger, type DialogTriggerProps, type DismissEvent, DismissableLayerScope, Display, Drawer, DrawerClose, type DrawerCloseProps, DrawerContent, DrawerDescription, type DrawerDirection, DrawerFooter, DrawerHeader, DrawerOverlay, type DrawerProps, DrawerTitle, DrawerTrigger, type DrawerTriggerProps, DropdownMenu, DropdownMenuCheckboxItem, type DropdownMenuCheckboxItemProps, DropdownMenuContent, type DropdownMenuContentProps, DropdownMenuGroup, DropdownMenuItem, type DropdownMenuItemProps, DropdownMenuLabel, type DropdownMenuLabelProps, DropdownMenuPortal, type DropdownMenuProps, DropdownMenuRadioGroup, type DropdownMenuRadioGroupProps, DropdownMenuRadioItem, type DropdownMenuRadioItemProps, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, type DropdownMenuSubProps, DropdownMenuSubTrigger, type DropdownMenuSubTriggerProps, DropdownMenuTrigger, type DropdownMenuTriggerProps, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, type EmptyMediaProps, type EmptyMediaVariant, EmptyTitle, Eyebrow, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldOrientation, FieldSeparator, FieldSet, FieldTitle, type FloatingResult, Footer, type FooterLink, type FooterLinkGroup, type FooterOffice, type FooterProps, Forbidden, Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, type HoverCardContentProps, type HoverCardProps, HoverCardTrigger, type HoverCardTriggerProps, type HoverIntentHandlers, InfoTip, InfoTipContent, type InfoTipContentProps, type InfoTipProps, InfoTipTrigger, type InfoTipTriggerProps, Input, InputGroup, InputGroupAddon, type InputGroupAddonAlign, type InputGroupAddonProps, InputGroupButton, type InputGroupButtonProps, type InputGroupButtonSize, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, type InputOTPProps, InputOTPSeparator, InputOTPSlot, type InputOTPSlotProps, type InputProps, type InputSize, Item, ItemActions, ItemContent, ItemDescription, ItemFooter, ItemGroup, ItemHeader, ItemMedia, type ItemMediaProps, type ItemMediaVariant, type ItemProps, ItemSeparator, type ItemSize, ItemTitle, type ItemVariant, Kbd, KbdGroup, LAYER_IGNORE_ATTR, Label, ListRow, ListRowLabel, type ListRowLabelProps, type ListRowProps, ListRowValue, ListRows, type ListRowsProps, type ListRowsVariant, Logo, type LogoProps, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, type MenubarMenuProps, MenubarRadioGroup, type MenubarRadioGroupProps, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, type MenubarSubProps, MenubarSubTrigger, MenubarTrigger, MobileAppBar, type MobileAppBarBack, type MobileAppBarLabels, type MobileAppBarProps, NativeSelect, NativeSelectGroup, NativeSelectOption, type NativeSelectProps, type NativeSelectSize, NavBadge, type NavBadgeProps, type NavBadgeVariant, NavDot, type NavDotProps, type NavDotTone, type NavGroup, type NavItem, type NavItemState, type NavMatch, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, type NavigationMenuItemProps, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, NotFound, OpenOrdersEmpty, OrderBook, OrderBookHead, type OrderBookHeadProps, OrderBookRow, type OrderBookRowProps, OrderBookSpread, OrderForm, OrderFormRow, type OrderFormRowProps, OrderFormSubmit, type OrderFormSubmitProps, type OrderSide, PageFrame, type PageFrameProps, type PageFrameWidth, PageHeading, type PageHeadingProps, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, type PaginationLinkProps, PaginationNext, PaginationPrevious, type Polarity, Popover, PopoverAnchor, type PopoverAnchorProps, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, type PortalProps, PortalProvider, type PortalProviderProps, Progress, type ProgressProps, Prose, RadioGroup, RadioGroupItem, type RadioGroupItemProps, type RadioGroupProps, ResourceError, type ResourceErrorLabels, type ResourceErrorProps, ScrollArea, ScrollBar, type ScrollBarOrientation, type ScrollBarProps, Section, SectionDescriptor, type SectionDescriptorProps, SectionHead, type SectionHeadProps, SectionLabel, type SectionLabelProps, type SectionLabelTone, SectionNav, type SectionNavGroup, type SectionNavItem, type SectionNavLabels, type SectionNavProps, type SectionProps, Select, SelectContent, type SelectContentProps, SelectGroup, SelectItem, type SelectItemProps, SelectLabel, type SelectProps, SelectSeparator, SelectTrigger, type SelectTriggerProps, type SelectTriggerSize, SelectValue, type SelectValueProps, Separator, type SeparatorOrientation, type SeparatorProps, ServerError, type ServerErrorProps, Settled, type SettledProps, Sheet, SheetClose, type SheetCloseProps, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, type SheetOverlayProps, type SheetProps, SheetTitle, SheetTrigger, type SheetTriggerProps, type ShellBreakpoint, ShellNav, type ShellNavLabels, type ShellNavProps, type Side, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, SidebarMenuItem, type SidebarProps, SidebarProvider, type SidebarProviderProps, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, type SliderProps, Slot, type SlotProps, Spinner, Stat, type StatProps, type StatusLinkData, type StatusPageProps, StatusScreen, type StatusScreenProps, type Surface, Switch, type SwitchProps, SystemBanner, type SystemBannerLabels, type SystemBannerProps, type SystemBannerTone, Table, type TableAlign, TableBody, TableCaption, TableCard, TableCell, type TableCellProps, type TableDensity, TableFooter, TableHead, type TableHeadProps, TableHeader, type TableProps, TableRow, type TableVariant, Tabs, TabsContent, type TabsContentProps, TabsList, type TabsProps, TabsTrigger, type TabsTriggerProps, Terminal, type TerminalArea, TerminalChart, TerminalPane, TerminalPaneBody, TerminalPaneHeader, type TerminalPaneProps, TerminalTicker, Textarea, type TextareaProps, type TextareaSize, TickerStat, type TickerStatProps, type Toast, type ToastFn, type ToastOptions, type ToastPosition, type ToastState, type ToastVariant, Toaster, type ToasterProps, Toggle, ToggleGroup, ToggleGroupItem, type ToggleGroupItemProps, type ToggleGroupProps, type ToggleProps, type ToggleSize, type ToggleVariant, type ToggleVariantsOptions, Tooltip, TooltipContent, type TooltipContentProps, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, TopBar, type TopBarProps, TradesTapeRow, type TradesTapeRowProps, buttonVariants, cn, isNavItemActive, isPlainLeftClick, mergeRefs, navItemMatch, navigationMenuTriggerStyle, resolveActiveNavItem, statusCtaClass, toast, toggleVariants, useControllableState, useDismissableLayer, useFloating, useFocusScope, useHoverIntent, usePendingNavigation, usePresence, useRovingFocus, useSidebar };
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export { Button, buttonVariants } from "./components/button.js";
17
17
  export { ButtonGroup, ButtonGroupText, ButtonGroupSeparator, } from "./components/button-group.js";
18
18
  export { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter, } from "./components/card.js";
19
19
  export { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent, } from "./components/empty.js";
20
+ export { AuthWall } from "./components/auth-wall.js";
20
21
  export { Field, FieldSet, FieldLegend, FieldGroup, FieldContent, FieldLabel, FieldTitle, FieldDescription, FieldSeparator, FieldError, } from "./components/field.js";
21
22
  export { SectionDescriptor } from "./components/section-descriptor.js";
22
23
  export { Footer } from "./components/footer.js";
@@ -65,12 +66,10 @@ export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, Dr
65
66
  export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, } from "./components/select.js";
66
67
  export { NativeSelect, NativeSelectGroup, NativeSelectOption, } from "./components/native-select.js";
67
68
  export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, } from "./components/command.js";
68
- export { ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, } from "./components/chart.js";
69
69
  export { Calendar, } from "./components/calendar.js";
70
70
  export { DateTimePicker, } from "./components/date-time-picker.js";
71
71
  export { Toaster, toast, } from "./components/sonner.js";
72
72
  export { Form, FormControl, FormDescription, FormItem, FormLabel, FormMessage, } from "./components/form.js";
73
- export { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "./components/resizable.js";
74
73
  export { OpenOrdersEmpty, OrderBook, OrderBookHead, OrderBookRow, OrderBookSpread, OrderForm, OrderFormRow, OrderFormSubmit, Terminal, TerminalChart, TerminalPane, TerminalPaneBody, TerminalPaneHeader, TerminalTicker, TickerStat, TradesTapeRow, } from "./components/terminal.js";
75
74
  export { AppShell } from "./components/app-shell.js";
76
75
  export { isNavItemActive, isPlainLeftClick, navItemMatch, resolveActiveNavItem, } from "./components/nav-model.js";
@@ -0,0 +1,24 @@
1
+ const LABELABLE = /* @__PURE__ */ Symbol.for("@evinvest/uikit/labelable@1");
2
+ const LAZY = /* @__PURE__ */ Symbol.for("react.lazy");
3
+ function markLabelable(component) {
4
+ Object.defineProperty(component, LABELABLE, { value: true });
5
+ }
6
+ function isLabelable(type) {
7
+ const resolved = unwrapLazy(type);
8
+ return (typeof resolved === "function" || typeof resolved === "object" && resolved !== null) && Reflect.get(resolved, LABELABLE) === true;
9
+ }
10
+ function unwrapLazy(type) {
11
+ if (typeof type !== "object" || type === null || Reflect.get(type, "$$typeof") !== LAZY) return type;
12
+ const init = Reflect.get(type, "_init");
13
+ if (typeof init !== "function") return void 0;
14
+ try {
15
+ return Reflect.apply(init, void 0, [Reflect.get(type, "_payload")]);
16
+ } catch {
17
+ return void 0;
18
+ }
19
+ }
20
+ export {
21
+ isLabelable,
22
+ markLabelable
23
+ };
24
+ //# sourceMappingURL=labelable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/primitives/labelable.ts"],"sourcesContent":["// How `FieldLabel` tells a kit control from any other component without\n// importing it: each control marks itself in its own module. Recognising them\n// by identity meant `field.tsx` imported every control, so a page with one\n// `Field` and an `Input` still shipped the whole `Select` (floating, portal,\n// focus scope, listbox — ~4 KB gz).\n//\n// `Symbol.for`, not `Symbol`: two copies of the kit in one app (a hoisting\n// accident) still read each other's marks.\nconst LABELABLE = Symbol.for(\"@evinvest/uikit/labelable@1\");\nconst LAZY = Symbol.for(\"react.lazy\");\n\n/** Marks a component that renders one labelable element and takes its `Field`'s id. */\nexport function markLabelable(component: object): void {\n Object.defineProperty(component, LABELABLE, { value: true });\n}\n\n/** Whether an element `type` is a component marked with `markLabelable`. */\nexport function isLabelable(type: unknown): boolean {\n const resolved = unwrapLazy(type);\n return (\n (typeof resolved === \"function\" || (typeof resolved === \"object\" && resolved !== null)) &&\n Reflect.get(resolved, LABELABLE) === true\n );\n}\n\n// An element a Server Component rendered reaches the client with a lazy type:\n// the Flight client wraps every client reference in a `React.lazy`-shaped\n// object, so the control's own function (and its mark) sits behind it. The\n// mark cannot travel through the reference instead — the server holds only the\n// module id, never the module. So resolve the lazy the way the reconciler\n// does, by calling its `_init` on its `_payload`: once the module has loaded\n// that returns the export synchronously. Until then it throws (a thenable while\n// pending, the error if loading failed); that is answered \"not a control\",\n// the pre-mark behaviour, and the reconciler meets the same throw itself when\n// it renders the element.\nfunction unwrapLazy(type: unknown): unknown {\n if (typeof type !== \"object\" || type === null || Reflect.get(type, \"$$typeof\") !== LAZY) return type;\n const init: unknown = Reflect.get(type, \"_init\");\n if (typeof init !== \"function\") return undefined;\n try {\n return Reflect.apply(init, undefined, [Reflect.get(type, \"_payload\")]);\n } catch {\n return undefined;\n }\n}\n"],"mappings":"AAQA,MAAM,YAAY,uBAAO,IAAI,6BAA6B;AAC1D,MAAM,OAAO,uBAAO,IAAI,YAAY;AAG7B,SAAS,cAAc,WAAyB;AACrD,SAAO,eAAe,WAAW,WAAW,EAAE,OAAO,KAAK,CAAC;AAC7D;AAGO,SAAS,YAAY,MAAwB;AAClD,QAAM,WAAW,WAAW,IAAI;AAChC,UACG,OAAO,aAAa,cAAe,OAAO,aAAa,YAAY,aAAa,SACjF,QAAQ,IAAI,UAAU,SAAS,MAAM;AAEzC;AAYA,SAAS,WAAW,MAAwB;AAC1C,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,QAAQ,IAAI,MAAM,UAAU,MAAM,KAAM,QAAO;AAChG,QAAM,OAAgB,QAAQ,IAAI,MAAM,OAAO;AAC/C,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,MAAI;AACF,WAAO,QAAQ,MAAM,MAAM,QAAW,CAAC,QAAQ,IAAI,MAAM,UAAU,CAAC,CAAC;AAAA,EACvE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evinvest/uikit",
3
- "version": "0.27.0",
3
+ "version": "0.29.1",
4
4
  "description": "Dep-light React UI kit: shadcn-semantics components with zero @radix-ui / cva, mirroring the ev_lib::uikit Rust feature. Ships the shared design tokens.",
5
5
  "license": "BlueOak-1.0.0",
6
6
  "publishConfig": {
@@ -1,151 +0,0 @@
1
- "use client";
2
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import * as React from "react";
4
- import { cn } from "../lib/cn.js";
5
- import { CHART_CONTAINER, CHART_LEGEND, CHART_TOOLTIP } from "../generated/chart.js";
6
- const ChartContext = React.createContext(null);
7
- function useChart() {
8
- const context = React.useContext(ChartContext);
9
- if (!context) {
10
- throw new Error("useChart must be used within a <ChartContainer />");
11
- }
12
- return context;
13
- }
14
- function ChartContainer({
15
- id,
16
- className,
17
- children,
18
- config,
19
- ...props
20
- }) {
21
- const uniqueId = React.useId();
22
- const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
23
- return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
24
- "div",
25
- {
26
- "data-slot": "chart",
27
- "data-chart": chartId,
28
- className: cn(CHART_CONTAINER, className),
29
- ...props,
30
- children: [
31
- /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
32
- children
33
- ]
34
- }
35
- ) });
36
- }
37
- const ChartStyle = ({ id, config }) => {
38
- const colorConfig = Object.entries(config).filter(([, c]) => c.color);
39
- if (!colorConfig.length) {
40
- return null;
41
- }
42
- return /* @__PURE__ */ jsx(
43
- "style",
44
- {
45
- dangerouslySetInnerHTML: {
46
- __html: `[data-chart=${id}] {
47
- ${colorConfig.map(([key, itemConfig]) => ` --color-${key}: ${itemConfig.color};`).join("\n")}
48
- }`
49
- }
50
- }
51
- );
52
- };
53
- const ChartTooltip = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
54
- function ChartTooltipContent({
55
- className,
56
- items = [],
57
- label,
58
- hideLabel = false,
59
- hideIndicator = false,
60
- labelClassName
61
- }) {
62
- useChart();
63
- if (!items.length) {
64
- return null;
65
- }
66
- return /* @__PURE__ */ jsxs(
67
- "div",
68
- {
69
- "data-slot": "chart-tooltip",
70
- className: cn(CHART_TOOLTIP, className),
71
- children: [
72
- !hideLabel && label ? /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: label }) : null,
73
- /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: items.map((item, index) => /* @__PURE__ */ jsxs(
74
- "div",
75
- {
76
- className: cn(
77
- "[&>svg]:text-ink-soft flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 items-center"
78
- ),
79
- children: [
80
- !hideIndicator && /* @__PURE__ */ jsx(
81
- "div",
82
- {
83
- className: "shrink-0 rounded-[2px] h-2.5 w-2.5",
84
- style: {
85
- backgroundColor: item.color,
86
- borderColor: item.color
87
- }
88
- }
89
- ),
90
- /* @__PURE__ */ jsxs("div", { className: "flex flex-1 justify-between leading-none items-center", children: [
91
- /* @__PURE__ */ jsx("span", { className: "text-ink-soft", children: item.label }),
92
- item.value !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-ink font-mono font-medium tabular-nums", children: item.value })
93
- ] })
94
- ]
95
- },
96
- index
97
- )) })
98
- ]
99
- }
100
- );
101
- }
102
- const ChartLegend = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
103
- function ChartLegendContent({
104
- className,
105
- hideIcon = false,
106
- items
107
- }) {
108
- const { config } = useChart();
109
- const rows = items ?? Object.entries(config).map(([key, c]) => ({
110
- label: c.label ?? key,
111
- ...c.color ? { color: c.color } : {}
112
- }));
113
- if (!rows.length) {
114
- return null;
115
- }
116
- return /* @__PURE__ */ jsx(
117
- "div",
118
- {
119
- "data-slot": "chart-legend",
120
- className: cn(CHART_LEGEND, className),
121
- children: rows.map((item, index) => /* @__PURE__ */ jsxs(
122
- "div",
123
- {
124
- className: cn(
125
- "[&>svg]:text-ink-soft flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
126
- ),
127
- children: [
128
- !hideIcon && /* @__PURE__ */ jsx(
129
- "div",
130
- {
131
- className: "h-2 w-2 shrink-0 rounded-[2px]",
132
- style: { backgroundColor: item.color }
133
- }
134
- ),
135
- item.label
136
- ]
137
- },
138
- index
139
- ))
140
- }
141
- );
142
- }
143
- export {
144
- ChartContainer,
145
- ChartLegend,
146
- ChartLegendContent,
147
- ChartStyle,
148
- ChartTooltip,
149
- ChartTooltipContent
150
- };
151
- //# sourceMappingURL=chart.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/components/chart.tsx"],"sourcesContent":["\"use client\";\n\n// Dep-light chart primitives: the shadcn/recharts wrapper minus recharts.\n//\n// Upstream shadcn `chart` is theming + presentational tooltip/legend wrappers\n// around recharts, which does the actual plotting. We keep the wrappers and\n// drop recharts: `ChartContainer` is a themed SVG host that emits per-key\n// `--color-<key>` custom properties from its `config`, and consumers draw their\n// own <svg>/series inside it. `ChartTooltipContent` and `ChartLegendContent`\n// are purely presentational and take explicit `items` instead of a recharts\n// payload. `ChartTooltip`/`ChartLegend` are passthrough wrappers. `dark:*`\n// selectors are dropped; the recharts-specific `[&_.recharts-*]` selectors are\n// dropped from the container base.\n\nimport * as React from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { CHART_CONTAINER, CHART_LEGEND, CHART_TOOLTIP } from \"../generated/chart\";\n\nexport type ChartConfig = {\n [k in string]: {\n label?: React.ReactNode;\n color?: string;\n };\n};\n\ntype ChartContextProps = {\n config: ChartConfig;\n};\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null);\n\nfunction useChart() {\n const context = React.useContext(ChartContext);\n\n if (!context) {\n throw new Error(\"useChart must be used within a <ChartContainer />\");\n }\n\n return context;\n}\n\nfunction ChartContainer({\n id,\n className,\n children,\n config,\n ...props\n}: React.ComponentProps<\"div\"> & {\n config: ChartConfig;\n}) {\n const uniqueId = React.useId();\n const chartId = `chart-${id || uniqueId.replace(/:/g, \"\")}`;\n\n return (\n <ChartContext.Provider value={{ config }}>\n <div\n data-slot=\"chart\"\n data-chart={chartId}\n className={cn(CHART_CONTAINER, className)}\n {...props}\n >\n <ChartStyle id={chartId} config={config} />\n {children}\n </div>\n </ChartContext.Provider>\n );\n}\n\nconst ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {\n const colorConfig = Object.entries(config).filter(([, c]) => c.color);\n\n if (!colorConfig.length) {\n return null;\n }\n\n return (\n <style\n dangerouslySetInnerHTML={{\n __html: `[data-chart=${id}] {\n${colorConfig\n .map(([key, itemConfig]) => ` --color-${key}: ${itemConfig.color};`)\n .join(\"\\n\")}\n}`,\n }}\n />\n );\n};\n\n// One rendered tooltip/legend row. Replaces the recharts payload.\nexport type ChartItem = {\n label?: React.ReactNode;\n value?: React.ReactNode;\n color?: string;\n};\n\nconst ChartTooltip = ({ children }: { children?: React.ReactNode }) => (\n <>{children}</>\n);\n\nfunction ChartTooltipContent({\n className,\n items = [],\n label,\n hideLabel = false,\n hideIndicator = false,\n labelClassName,\n}: React.ComponentProps<\"div\"> & {\n items?: ChartItem[];\n label?: React.ReactNode;\n hideLabel?: boolean;\n hideIndicator?: boolean;\n labelClassName?: string;\n}) {\n useChart();\n\n if (!items.length) {\n return null;\n }\n\n return (\n <div\n data-slot=\"chart-tooltip\"\n className={cn(CHART_TOOLTIP, className)}\n >\n {!hideLabel && label ? (\n <div className={cn(\"font-medium\", labelClassName)}>{label}</div>\n ) : null}\n <div className=\"grid gap-1.5\">\n {items.map((item, index) => (\n <div\n key={index}\n className={cn(\n \"[&>svg]:text-ink-soft flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 items-center\",\n )}\n >\n {!hideIndicator && (\n <div\n className=\"shrink-0 rounded-[2px] h-2.5 w-2.5\"\n style={\n {\n backgroundColor: item.color,\n borderColor: item.color,\n } as React.CSSProperties\n }\n />\n )}\n <div className=\"flex flex-1 justify-between leading-none items-center\">\n <span className=\"text-ink-soft\">{item.label}</span>\n {item.value !== undefined && (\n <span className=\"text-ink font-mono font-medium tabular-nums\">\n {item.value}\n </span>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n}\n\nconst ChartLegend = ({ children }: { children?: React.ReactNode }) => (\n <>{children}</>\n);\n\nfunction ChartLegendContent({\n className,\n hideIcon = false,\n items,\n}: React.ComponentProps<\"div\"> & {\n hideIcon?: boolean;\n items?: ChartItem[];\n}) {\n const { config } = useChart();\n\n const rows: ChartItem[] =\n items ??\n Object.entries(config).map(([key, c]) => ({\n label: c.label ?? key,\n ...(c.color ? { color: c.color } : {}),\n }));\n\n if (!rows.length) {\n return null;\n }\n\n return (\n <div\n data-slot=\"chart-legend\"\n className={cn(CHART_LEGEND, className)}\n >\n {rows.map((item, index) => (\n <div\n key={index}\n className={cn(\n \"[&>svg]:text-ink-soft flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3\",\n )}\n >\n {!hideIcon && (\n <div\n className=\"h-2 w-2 shrink-0 rounded-[2px]\"\n style={{ backgroundColor: item.color }}\n />\n )}\n {item.label}\n </div>\n ))}\n </div>\n );\n}\n\nexport {\n ChartContainer,\n ChartTooltip,\n ChartTooltipContent,\n ChartLegend,\n ChartLegendContent,\n ChartStyle,\n};\n"],"mappings":";AAuDM,SAyCJ,UAnCM,KANF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