@epilot/spark-ui 0.30.0 → 0.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/autocomplete.cjs +9 -2
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +10 -3
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/combobox.cjs +2 -1
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.js +3 -2
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/field.cjs +25 -7
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +3 -1
- package/dist/components/field.d.ts +3 -1
- package/dist/components/field.js +25 -8
- package/dist/components/field.js.map +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/input-date.cjs +11 -1
- package/dist/components/input-date.cjs.map +1 -1
- package/dist/components/input-date.js +11 -1
- package/dist/components/input-date.js.map +1 -1
- package/dist/components/input-otp.cjs +1 -0
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +2 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/theme.cjs +2 -0
- package/dist/components/theme.cjs.map +1 -1
- package/dist/components/theme.js +2 -0
- package/dist/components/theme.js.map +1 -1
- package/dist/hooks/use-focus-modality.cjs +55 -0
- package/dist/hooks/use-focus-modality.cjs.map +1 -0
- package/dist/hooks/use-focus-modality.d.cts +8 -0
- package/dist/hooks/use-focus-modality.d.ts +8 -0
- package/dist/hooks/use-focus-modality.js +53 -0
- package/dist/hooks/use-focus-modality.js.map +1 -0
- package/dist/styles/theme.css +45 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.js","names":["ComboboxPrimitive","React"],"sources":["../../src/components/combobox.tsx"],"sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox'\nimport { Add, Check, Search } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { ChevronDownGlyph, ClearGlyph } from '../lib/control-glyphs'\nimport { boxChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { buttonVariants } from './button'\nimport { Checkbox } from './checkbox'\nimport { useFieldControl } from './field'\nimport { Pill } from './pill'\nimport { PortalTheme } from './theme'\n\nconst Combobox = ComboboxPrimitive.Root\nconst ComboboxValue = ComboboxPrimitive.Value\nconst ComboboxCollection = ComboboxPrimitive.Collection\nconst useComboboxFilter = ComboboxPrimitive.useFilter\nconst useComboboxFilteredItems = ComboboxPrimitive.useFilteredItems\n\ntype ComboboxSelectedGroup<Item> = {\n value: 'selected' | 'items'\n label: string\n items: Item[]\n /** Options left unpicked before the search filters them; ComboboxEmpty reads it. */\n optionCount: number\n}\n\n/** Splits `items` into a group with every pick, never filtered, and a group with the rest. */\nfunction useComboboxSelectedGroups<Item>(\n items: readonly Item[],\n value: readonly Item[],\n {\n selected,\n items: itemsLabel,\n isItemEqualToValue = Object.is,\n }: {\n selected: string\n items: string\n isItemEqualToValue?: (item: Item, value: Item) => boolean\n },\n) {\n const { contains } = useComboboxFilter()\n const isPicked = (item: Item) =>\n value.some((picked) => isItemEqualToValue(item, picked))\n const options = items.filter((item) => !isPicked(item))\n const groups: ComboboxSelectedGroup<Item>[] = [\n {\n value: 'selected',\n label: selected,\n items: [...value],\n optionCount: options.length,\n },\n {\n value: 'items',\n label: itemsLabel,\n items: options,\n optionCount: options.length,\n },\n ]\n const filter = (\n item: Item,\n query: string,\n itemToString?: (item: Item) => string,\n ) => isPicked(item) || contains(item, query, itemToString)\n return { items: groups, filter, isItemEqualToValue }\n}\n\nconst CLEAR_BUTTON =\n \"relative inline-flex size-6 min-h-[24px] min-w-[24px] shrink-0 items-center justify-center rounded-sm p-0 text-gray-light outline-hidden transition-colors hover:text-gray focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n\nconst ComboboxGroupStateContext = React.createContext({\n disabled: false,\n readOnly: false,\n})\n\n// the trigger is a native <button>, so ComboboxClear sits beside it, not inside it;\n// Base UI's InputGroup is the only part whose state carries readOnly, so its render stays ours\nfunction ComboboxTriggerGroup({\n className,\n ...props\n}: Omit<React.ComponentProps<typeof ComboboxPrimitive.InputGroup>, 'render'>) {\n return (\n <ComboboxPrimitive.InputGroup\n data-slot=\"combobox-trigger-group\"\n className={cn(\n 'relative flex w-full items-center has-[[data-slot=combobox-clear]:not([hidden])]:[&_[data-slot=combobox-trigger]]:pr-15',\n className,\n )}\n {...props}\n render={({ role: _group, ...groupProps }, state) => (\n <ComboboxGroupStateContext.Provider\n value={{ disabled: state.disabled, readOnly: state.readOnly }}\n >\n <div {...groupProps} />\n </ComboboxGroupStateContext.Provider>\n )}\n />\n )\n}\n\nfunction ComboboxTrigger({\n className,\n children,\n variant,\n id: idProp,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Trigger> & {\n // input-style override; falls back to Field / <Theme>, then soft (like Input)\n variant?: SparkInputStyle\n}) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant,\n })\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n return (\n <ComboboxPrimitive.Trigger\n data-slot=\"combobox-trigger\"\n id={id}\n className={cn(\n 'relative flex w-full min-w-0 items-center gap-1.5 rounded-md px-3 text-left text-base text-gray transition-colors select-none disabled:cursor-not-allowed disabled:text-gray-disabled motion-reduce:transition-none',\n !isGhost && 'h-11 min-h-[2.75rem]',\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n 'pr-8',\n // the inset Field shell draws the outline (field.tsx)\n inset && 'focus-visible:outline-hidden',\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <ChevronDownGlyph\n data-slot=\"combobox-chevron\"\n className={cn(\n 'pointer-events-none absolute shrink-0 text-gray-light transition-transform in-data-popup-open:rotate-180 motion-reduce:transition-none',\n isGhost ? 'right-1' : 'right-3',\n )}\n />\n </ComboboxPrimitive.Trigger>\n )\n}\n\ntype ComboboxChipsProps<Item> = Omit<\n React.ComponentProps<'div'>,\n 'children'\n> & {\n /** Renders one chip per selected value, in pick order. */\n children: (item: Item, index: number) => React.ReactNode\n /** Renders at most this many chips, then a \"+N\" pill for the rest. */\n max?: number\n overflowLabel?: (count: number) => string\n /** Shown while nothing is selected: text, or a `ComboboxAddChip`. */\n placeholder?: React.ReactNode\n}\n\n// one row that never wraps: chips past the row's width are clipped, `max` folds them into \"+N\"\nfunction ComboboxChips<Item>({\n className,\n children,\n max,\n overflowLabel = (count) => `${count} more selected`,\n placeholder,\n ...props\n}: ComboboxChipsProps<Item>) {\n return (\n <div\n data-slot=\"combobox-chips\"\n className={cn(\n 'flex min-w-0 flex-1 flex-nowrap items-center gap-1 overflow-hidden',\n className,\n )}\n {...props}\n >\n <ComboboxPrimitive.Value>\n {(value: Item[]) => {\n if (value.length === 0) {\n return typeof placeholder === 'string' ? (\n <span className=\"truncate text-gray-placeholder in-data-disabled:text-gray-disabled\">\n {placeholder}\n </span>\n ) : (\n placeholder\n )\n }\n const shown = max === undefined ? value : value.slice(0, max)\n const hidden = value.length - shown.length\n return (\n <>\n {shown.map(children)}\n {hidden > 0 && (\n <Pill\n data-slot=\"combobox-chips-overflow\"\n className=\"shrink-0 in-data-disabled:opacity-50\"\n >\n <span aria-hidden=\"true\">+{hidden}</span>\n <span className=\"sr-only\">{overflowLabel(hidden)}</span>\n </Pill>\n )}\n </>\n )\n }}\n </ComboboxPrimitive.Value>\n </div>\n )\n}\n\n// display-only: chips sit inside the trigger button, so nothing in them may be interactive\nfunction ComboboxChip({\n className,\n children,\n ...props\n}: Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick' | 'color'>) {\n return (\n <Pill\n data-slot=\"combobox-chip\"\n className={cn('min-w-0 shrink in-data-disabled:opacity-50', className)}\n {...props}\n >\n <span className=\"truncate\">{children}</span>\n </Pill>\n )\n}\n\nfunction ComboboxAddChip({\n className,\n children,\n ...props\n}: Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick' | 'color'>) {\n return (\n <Pill\n data-slot=\"combobox-add-chip\"\n className={cn(\n 'shrink-0 border border-dashed border-spark-a6 bg-transparent pl-1.5 text-spark-a11 in-data-disabled:opacity-50',\n className,\n )}\n {...props}\n >\n <Add aria-hidden className=\"[--spark-icon-size:14px]\" />\n {children}\n </Pill>\n )\n}\n\nfunction ComboboxClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Clear>) {\n const group = React.useContext(ComboboxGroupStateContext)\n return (\n <ComboboxPrimitive.Clear\n data-slot=\"combobox-clear\"\n render={(buttonProps, state) => (\n <button\n {...buttonProps}\n hidden={state.disabled || buttonProps.hidden}\n />\n )}\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // Base UI refocuses the search input, which is unmounted while the popup is closed\n event.currentTarget\n .closest('[data-slot=\"combobox-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"combobox-trigger\"]')\n ?.focus()\n }}\n {...props}\n hidden={group.disabled || group.readOnly || props.hidden}\n >\n {children ?? <ClearGlyph />}\n </ComboboxPrimitive.Clear>\n )\n}\n\ntype ComboboxContentProps = React.ComponentProps<\n typeof ComboboxPrimitive.Popup\n> &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n > &\n Pick<ComboboxPrimitive.Portal.Props, 'container'>\n\n// a toggled item changes group and so its index; Enter records it so the remounted\n// item can take the highlight back (Base UI only highlights on hover or arrow keys)\ntype ComboboxToggleTracker = {\n pending: { value: unknown } | null\n values: WeakMap<Element, unknown>\n}\nconst ComboboxToggleContext = React.createContext<ComboboxToggleTracker | null>(\n null,\n)\n\n// a tap leaves Base UI's highlight on a list index, which the next pick moves to another\n// option; without hover the highlight shows only once these keys have moved it\nconst HIGHLIGHT_KEYS = new Set(['ArrowDown', 'ArrowUp', 'Home', 'End'])\n\n// below `sm` the popup is a bottom sheet; `!` beats the positioner's inline position styles\nfunction ComboboxContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n container,\n onKeyDownCapture,\n onPointerDownCapture,\n ...props\n}: ComboboxContentProps) {\n const [tracker] = React.useState<ComboboxToggleTracker>(() => ({\n pending: null,\n values: new WeakMap(),\n }))\n return (\n <ComboboxToggleContext.Provider value={tracker}>\n <ComboboxPrimitive.Portal container={container}>\n <PortalTheme>\n <ComboboxPrimitive.Backdrop\n data-slot=\"combobox-backdrop\"\n className=\"fixed top-(--spark-viewport-top,0) right-0 left-0 z-50 h-(--spark-viewport-height,100%) bg-(--color-overlay) transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none sm:hidden\"\n />\n <ComboboxPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"z-50 max-sm:fixed! max-sm:inset-x-0! max-sm:top-auto! max-sm:bottom-(--spark-viewport-bottom-offset,0)! max-sm:transform-none!\"\n >\n <ComboboxPrimitive.Popup\n data-slot=\"combobox-content\"\n className={cn(\n 'relative isolate z-50 flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-col overflow-hidden rounded-lg border border-gray-a1 bg-gray-1 p-1 text-gray-a12 shadow-lg dark:bg-gray-3 [[data-high-contrast]_&]:border-gray-a11',\n 'transition-[opacity,scale,translate] duration-100 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',\n 'sm:data-[side=bottom]:data-starting-style:-translate-y-2 sm:data-[side=left]:data-starting-style:translate-x-2 sm:data-[side=right]:data-starting-style:-translate-x-2 sm:data-[side=top]:data-starting-style:translate-y-2',\n 'max-sm:max-h-[80dvh] max-sm:w-full max-sm:max-w-none max-sm:rounded-b-none max-sm:border-x-0 max-sm:border-b-0 max-sm:px-4 max-sm:pt-3 max-sm:pb-[calc(env(safe-area-inset-bottom)+var(--spacing)*4)] max-sm:data-ending-style:translate-y-full max-sm:data-ending-style:scale-100 max-sm:data-ending-style:opacity-100 max-sm:data-starting-style:translate-y-full max-sm:data-starting-style:scale-100 max-sm:data-starting-style:opacity-100',\n className,\n )}\n {...props}\n onKeyDownCapture={(event) => {\n onKeyDownCapture?.(event)\n if (HIGHLIGHT_KEYS.has(event.key))\n event.currentTarget.setAttribute('data-keyboard', '')\n }}\n onPointerDownCapture={(event) => {\n onPointerDownCapture?.(event)\n event.currentTarget.removeAttribute('data-keyboard')\n }}\n >\n {children}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </PortalTheme>\n </ComboboxPrimitive.Portal>\n </ComboboxToggleContext.Provider>\n )\n}\n\n// Base UI removes the last pick on Backspace in the empty input only inside Chips\nfunction ComboboxInput({\n className,\n onKeyDown,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Input>) {\n const tracker = React.useContext(ComboboxToggleContext)\n return (\n <ComboboxPrimitive.Chips\n data-slot=\"combobox-search\"\n // Chips adds role=\"toolbar\" for arrow keys between chips; this row holds none\n render={({ role: _toolbar, ...chipsProps }) => <div {...chipsProps} />}\n className=\"-mx-1 -mt-1 mb-1 flex shrink-0 items-center gap-1.5 border-b border-gray-a4 px-2.5 text-gray-light max-sm:mx-0 max-sm:mt-0 max-sm:mb-2 max-sm:rounded-md max-sm:border-b-0 max-sm:bg-gray-a3\"\n >\n <Search aria-hidden className=\"shrink-0 [--spark-icon-size:16px]\" />\n <ComboboxPrimitive.Input\n data-slot=\"combobox-input\"\n className={cn(\n 'h-10 w-full min-w-0 bg-transparent text-base text-gray outline-hidden placeholder:text-gray-placeholder',\n className,\n )}\n onKeyDown={(event) => {\n onKeyDown?.(event)\n if (!tracker || event.key !== 'Enter') return\n const highlighted = event.currentTarget\n .closest('[data-slot=\"combobox-content\"]')\n ?.querySelector('[data-slot=\"combobox-item\"][data-highlighted]')\n if (!highlighted) return\n tracker.pending = { value: tracker.values.get(highlighted) }\n setTimeout(() => {\n tracker.pending = null\n })\n }}\n {...props}\n />\n </ComboboxPrimitive.Chips>\n )\n}\n\n// the bottom sheet's \"Done\"; hidden from `sm` up, where the popup closes on outside press\nfunction ComboboxClose({\n className,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"combobox-close\"\n type=\"button\"\n className={cn(\n buttonVariants({ variant: 'primary' }),\n 'mt-3 w-full shrink-0 sm:hidden',\n className,\n )}\n onClick={(event) => {\n onClick?.(event)\n // Combobox has no Close part; Escape is the key Base UI closes on\n event.currentTarget.dispatchEvent(\n new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),\n )\n }}\n {...props}\n />\n )\n}\n\nfunction ComboboxList({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.List>) {\n return (\n <ComboboxPrimitive.List\n data-slot=\"combobox-list\"\n className={cn(\n 'min-h-0 flex-1 overflow-y-auto overscroll-contain outline-hidden data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\n// forwardRef keeps refs working for React 18 consumers (ref-as-prop is 19-only)\nconst ComboboxItem = React.forwardRef<\n HTMLDivElement,\n ComboboxPrimitive.Item.Props\n>(function ComboboxItem({ className, value, ...props }, refProp) {\n const tracker = React.useContext(ComboboxToggleContext)\n const ref = React.useRef<HTMLDivElement | null>(null)\n React.useEffect(() => {\n const node = ref.current\n if (!tracker || !node) return\n tracker.values.set(node, value)\n if (!tracker.pending || !Object.is(tracker.pending.value, value)) return\n tracker.pending = null\n // after Base UI has registered the remounted item's new index\n const timer = setTimeout(() =>\n node.dispatchEvent(new MouseEvent('mousemove', { bubbles: true })),\n )\n return () => clearTimeout(timer)\n }, [tracker, value])\n return (\n <ComboboxPrimitive.Item\n ref={(node: HTMLDivElement | null) => {\n ref.current = node\n if (typeof refProp === 'function') refProp(node)\n else if (refProp) refProp.current = node\n }}\n value={value}\n data-slot=\"combobox-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm text-gray outline-hidden transition-colors select-none touch-target-row data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none max-sm:gap-3 max-sm:text-base [@media(hover:none)]:[[data-slot=combobox-content]:not([data-keyboard])_&]:data-highlighted:bg-transparent',\n className,\n )}\n {...props}\n />\n )\n})\n\nconst setInert = (node: HTMLElement | null) => {\n node?.setAttribute('inert', '')\n}\n\n// kept mounted so the bottom sheet draws an empty checkbox for unpicked items\nfunction ComboboxItemIndicator({\n className,\n children,\n keepMounted = true,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.ItemIndicator>) {\n return (\n <ComboboxPrimitive.ItemIndicator\n data-slot=\"combobox-item-indicator\"\n keepMounted={keepMounted}\n className={cn('flex shrink-0 items-center justify-center', className)}\n {...props}\n render={\n props.render ??\n ((indicatorProps, { selected }) => (\n <span {...indicatorProps}>\n <span\n className={cn(\n 'flex size-3.5 items-center justify-center max-sm:hidden',\n !selected && 'invisible',\n )}\n >\n {children ?? (\n <Check aria-hidden className=\"[--spark-icon-size:11px]\" />\n )}\n </span>\n {/* the option owns the press and the selected state; this only draws\n it. inert is set on the node as React 18 has no `inert` prop */}\n <span className=\"flex sm:hidden\" ref={setInert}>\n <Checkbox\n checked={selected}\n className=\"my-0 any-pointer-coarse:my-0\"\n readOnly\n render={<span />}\n />\n </span>\n </span>\n ))\n }\n />\n )\n}\n\nconst isSelectedGroup = (\n group: unknown,\n): group is ComboboxSelectedGroup<unknown> =>\n typeof group === 'object' && group !== null && 'optionCount' in group\n\n// with useComboboxSelectedGroups the picks never filter out, so Base UI alone would never\n// see an empty list; \"no matches\" is the options group gone while it had options\nfunction ComboboxEmpty({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Empty>) {\n const filtered: readonly unknown[] = useComboboxFilteredItems()\n const groups = filtered.filter(isSelectedGroup)\n const noOptionMatches =\n groups.some((group) => group.optionCount > 0) &&\n !groups.some((group) => group.value === 'items')\n return (\n <ComboboxPrimitive.Empty\n data-slot=\"combobox-empty\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n render={({ children: _baseChildren, ...emptyProps }) => (\n <div {...emptyProps}>\n {filtered.length === 0 || noOptionMatches ? children : null}\n </div>\n )}\n />\n )\n}\n\nfunction ComboboxStatus({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Status>) {\n return (\n <ComboboxPrimitive.Status\n data-slot=\"combobox-status\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxGroup({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Group>) {\n return (\n <ComboboxPrimitive.Group\n data-slot=\"combobox-group\"\n className={cn(\n 'scroll-my-1 [&+&]:mt-1 [&+&]:border-t [&+&]:border-gray-a4 [&+&]:pt-1',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxGroupLabel({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.GroupLabel>) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot=\"combobox-group-label\"\n className={cn(\n 'px-1.5 py-1 text-xs font-medium text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"combobox-separator\"\n className={cn(\n 'pointer-events-none -mx-1 my-1 h-px bg-gray-a3 [[data-high-contrast]_&]:bg-gray-a6',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Combobox,\n ComboboxAddChip,\n ComboboxChip,\n ComboboxChips,\n ComboboxClear,\n ComboboxClose,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxGroupLabel,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxList,\n ComboboxSeparator,\n ComboboxStatus,\n ComboboxTrigger,\n ComboboxTriggerGroup,\n ComboboxValue,\n useComboboxFilter,\n useComboboxFilteredItems,\n useComboboxSelectedGroups,\n}\nexport type { ComboboxSelectedGroup }\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,WAAWA,WAAkB;AACnC,MAAM,gBAAgBA,WAAkB;AACxC,MAAM,qBAAqBA,WAAkB;AAC7C,MAAM,oBAAoBA,WAAkB;AAC5C,MAAM,2BAA2BA,WAAkB;;AAWnD,SAAS,0BACP,OACA,OACA,EACE,UACA,OAAO,YACP,qBAAqB,OAAO,MAM9B;CACA,MAAM,EAAE,aAAa,kBAAkB;CACvC,MAAM,YAAY,SAChB,MAAM,MAAM,WAAW,mBAAmB,MAAM,MAAM,CAAC;CACzD,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,SAAS,IAAI,CAAC;CACtD,MAAM,SAAwC,CAC5C;EACE,OAAO;EACP,OAAO;EACP,OAAO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AGX,CAAA;AAEL;AAEA,MAAM,mBACJ,UAEA,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB;AAIlE,SAAS,cAAc,EACrB,WACA,UACA,GAAG,SACoD;CACvD,MAAM,WAA+B,yBAAyB;CAC9D,MAAM,SAAS,SAAS,OAAO,eAAe;CAC9C,MAAM,kBACJ,OAAO,MAAM,UAAU,MAAM,cAAc,CAAC,KAC5C,CAAC,OAAO,MAAM,UAAU,MAAM,UAAU,OAAO;CACjD,OACE,oBAACA,WAAkB,OAAnB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;EACJ,SAAS,EAAE,UAAU,eAAe,GAAG,iBACrC,oBAAC,OAAD;GAAK,GAAI;aACN,SAAS,WAAW,KAAK,kBAAkB,WAAW;EACpD,CAAA;CAER,CAAA;AAEL;AAEA,SAAS,eAAe,EACtB,WACA,GAAG,SACqD;CACxD,OACE,oBAACA,WAAkB,QAAnB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,cAAc,EACrB,WACA,GAAG,SACoD;CACvD,OACE,oBAACA,WAAkB,OAAnB;EACE,aAAU;EACV,WAAW,GACT,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,mBAAmB,EAC1B,WACA,GAAG,SACyD;CAC5D,OACE,oBAACA,WAAkB,YAAnB;EACE,aAAU;EACV,WAAW,GACT,0FACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,eAAY;EACZ,aAAU;EACV,WAAW,GACT,sFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"combobox.js","names":["ComboboxPrimitive","React"],"sources":["../../src/components/combobox.tsx"],"sourcesContent":["'use client'\n\nimport { Combobox as ComboboxPrimitive } from '@base-ui/react/combobox'\nimport { Add, Check, Search } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { ChevronDownGlyph, ClearGlyph } from '../lib/control-glyphs'\nimport { boxChrome, floatingChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { buttonVariants } from './button'\nimport { Checkbox } from './checkbox'\nimport { useFieldControl } from './field'\nimport { Pill } from './pill'\nimport { PortalTheme } from './theme'\n\nconst Combobox = ComboboxPrimitive.Root\nconst ComboboxValue = ComboboxPrimitive.Value\nconst ComboboxCollection = ComboboxPrimitive.Collection\nconst useComboboxFilter = ComboboxPrimitive.useFilter\nconst useComboboxFilteredItems = ComboboxPrimitive.useFilteredItems\n\ntype ComboboxSelectedGroup<Item> = {\n value: 'selected' | 'items'\n label: string\n items: Item[]\n /** Options left unpicked before the search filters them; ComboboxEmpty reads it. */\n optionCount: number\n}\n\n/** Splits `items` into a group with every pick, never filtered, and a group with the rest. */\nfunction useComboboxSelectedGroups<Item>(\n items: readonly Item[],\n value: readonly Item[],\n {\n selected,\n items: itemsLabel,\n isItemEqualToValue = Object.is,\n }: {\n selected: string\n items: string\n isItemEqualToValue?: (item: Item, value: Item) => boolean\n },\n) {\n const { contains } = useComboboxFilter()\n const isPicked = (item: Item) =>\n value.some((picked) => isItemEqualToValue(item, picked))\n const options = items.filter((item) => !isPicked(item))\n const groups: ComboboxSelectedGroup<Item>[] = [\n {\n value: 'selected',\n label: selected,\n items: [...value],\n optionCount: options.length,\n },\n {\n value: 'items',\n label: itemsLabel,\n items: options,\n optionCount: options.length,\n },\n ]\n const filter = (\n item: Item,\n query: string,\n itemToString?: (item: Item) => string,\n ) => isPicked(item) || contains(item, query, itemToString)\n return { items: groups, filter, isItemEqualToValue }\n}\n\nconst CLEAR_BUTTON =\n \"relative inline-flex size-6 min-h-[24px] min-w-[24px] shrink-0 items-center justify-center rounded-sm p-0 text-gray-light outline-hidden transition-colors hover:text-gray focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n\nconst ComboboxGroupStateContext = React.createContext({\n disabled: false,\n readOnly: false,\n})\n\n// the trigger is a native <button>, so ComboboxClear sits beside it, not inside it;\n// Base UI's InputGroup is the only part whose state carries readOnly, so its render stays ours\nfunction ComboboxTriggerGroup({\n className,\n ...props\n}: Omit<React.ComponentProps<typeof ComboboxPrimitive.InputGroup>, 'render'>) {\n return (\n <ComboboxPrimitive.InputGroup\n data-slot=\"combobox-trigger-group\"\n className={cn(\n 'relative flex w-full items-center has-[[data-slot=combobox-clear]:not([hidden])]:[&_[data-slot=combobox-trigger]]:pr-15',\n className,\n )}\n {...props}\n render={({ role: _group, ...groupProps }, state) => (\n <ComboboxGroupStateContext.Provider\n value={{ disabled: state.disabled, readOnly: state.readOnly }}\n >\n <div {...groupProps} />\n </ComboboxGroupStateContext.Provider>\n )}\n />\n )\n}\n\nfunction ComboboxTrigger({\n className,\n children,\n variant,\n id: idProp,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Trigger> & {\n // input-style override; falls back to Field / <Theme>, then soft (like Input)\n variant?: SparkInputStyle\n}) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant,\n })\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n const floating = !variant && field?.labelPosition === 'floating'\n return (\n <ComboboxPrimitive.Trigger\n data-slot=\"combobox-trigger\"\n id={id}\n className={cn(\n 'relative flex w-full min-w-0 items-center gap-1.5 rounded-md px-3 text-left text-base text-gray transition-colors select-none disabled:cursor-not-allowed disabled:text-gray-disabled motion-reduce:transition-none',\n !isGhost && 'h-11 min-h-[2.75rem]',\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n floating &&\n cn(\n floatingChrome(inputStyle),\n inputStyle !== 'outlined' &&\n '[&_[data-slot=combobox-chevron]]:-translate-y-2',\n '[&[data-placeholder]:not(:focus-visible,[data-popup-open])>:not([data-slot=combobox-chevron])]:invisible',\n ),\n 'pr-8',\n // the inset Field shell draws the outline (field.tsx)\n inset && 'focus-visible:outline-hidden',\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <ChevronDownGlyph\n data-slot=\"combobox-chevron\"\n className={cn(\n 'pointer-events-none absolute shrink-0 text-gray-light transition-transform in-data-popup-open:rotate-180 motion-reduce:transition-none',\n isGhost ? 'right-1' : 'right-3',\n )}\n />\n </ComboboxPrimitive.Trigger>\n )\n}\n\ntype ComboboxChipsProps<Item> = Omit<\n React.ComponentProps<'div'>,\n 'children'\n> & {\n /** Renders one chip per selected value, in pick order. */\n children: (item: Item, index: number) => React.ReactNode\n /** Renders at most this many chips, then a \"+N\" pill for the rest. */\n max?: number\n overflowLabel?: (count: number) => string\n /** Shown while nothing is selected: text, or a `ComboboxAddChip`. */\n placeholder?: React.ReactNode\n}\n\n// one row that never wraps: chips past the row's width are clipped, `max` folds them into \"+N\"\nfunction ComboboxChips<Item>({\n className,\n children,\n max,\n overflowLabel = (count) => `${count} more selected`,\n placeholder,\n ...props\n}: ComboboxChipsProps<Item>) {\n return (\n <div\n data-slot=\"combobox-chips\"\n className={cn(\n 'flex min-w-0 flex-1 flex-nowrap items-center gap-1 overflow-hidden',\n className,\n )}\n {...props}\n >\n <ComboboxPrimitive.Value>\n {(value: Item[]) => {\n if (value.length === 0) {\n return typeof placeholder === 'string' ? (\n <span className=\"truncate text-gray-placeholder in-data-disabled:text-gray-disabled\">\n {placeholder}\n </span>\n ) : (\n placeholder\n )\n }\n const shown = max === undefined ? value : value.slice(0, max)\n const hidden = value.length - shown.length\n return (\n <>\n {shown.map(children)}\n {hidden > 0 && (\n <Pill\n data-slot=\"combobox-chips-overflow\"\n className=\"shrink-0 in-data-disabled:opacity-50\"\n >\n <span aria-hidden=\"true\">+{hidden}</span>\n <span className=\"sr-only\">{overflowLabel(hidden)}</span>\n </Pill>\n )}\n </>\n )\n }}\n </ComboboxPrimitive.Value>\n </div>\n )\n}\n\n// display-only: chips sit inside the trigger button, so nothing in them may be interactive\nfunction ComboboxChip({\n className,\n children,\n ...props\n}: Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick' | 'color'>) {\n return (\n <Pill\n data-slot=\"combobox-chip\"\n className={cn('min-w-0 shrink in-data-disabled:opacity-50', className)}\n {...props}\n >\n <span className=\"truncate\">{children}</span>\n </Pill>\n )\n}\n\nfunction ComboboxAddChip({\n className,\n children,\n ...props\n}: Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick' | 'color'>) {\n return (\n <Pill\n data-slot=\"combobox-add-chip\"\n className={cn(\n 'shrink-0 border border-dashed border-spark-a6 bg-transparent pl-1.5 text-spark-a11 in-data-disabled:opacity-50',\n className,\n )}\n {...props}\n >\n <Add aria-hidden className=\"[--spark-icon-size:14px]\" />\n {children}\n </Pill>\n )\n}\n\nfunction ComboboxClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Clear>) {\n const group = React.useContext(ComboboxGroupStateContext)\n return (\n <ComboboxPrimitive.Clear\n data-slot=\"combobox-clear\"\n render={(buttonProps, state) => (\n <button\n {...buttonProps}\n hidden={state.disabled || buttonProps.hidden}\n />\n )}\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // Base UI refocuses the search input, which is unmounted while the popup is closed\n event.currentTarget\n .closest('[data-slot=\"combobox-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"combobox-trigger\"]')\n ?.focus()\n }}\n {...props}\n hidden={group.disabled || group.readOnly || props.hidden}\n >\n {children ?? <ClearGlyph />}\n </ComboboxPrimitive.Clear>\n )\n}\n\ntype ComboboxContentProps = React.ComponentProps<\n typeof ComboboxPrimitive.Popup\n> &\n Pick<\n ComboboxPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n > &\n Pick<ComboboxPrimitive.Portal.Props, 'container'>\n\n// a toggled item changes group and so its index; Enter records it so the remounted\n// item can take the highlight back (Base UI only highlights on hover or arrow keys)\ntype ComboboxToggleTracker = {\n pending: { value: unknown } | null\n values: WeakMap<Element, unknown>\n}\nconst ComboboxToggleContext = React.createContext<ComboboxToggleTracker | null>(\n null,\n)\n\n// a tap leaves Base UI's highlight on a list index, which the next pick moves to another\n// option; without hover the highlight shows only once these keys have moved it\nconst HIGHLIGHT_KEYS = new Set(['ArrowDown', 'ArrowUp', 'Home', 'End'])\n\n// below `sm` the popup is a bottom sheet; `!` beats the positioner's inline position styles\nfunction ComboboxContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n container,\n onKeyDownCapture,\n onPointerDownCapture,\n ...props\n}: ComboboxContentProps) {\n const [tracker] = React.useState<ComboboxToggleTracker>(() => ({\n pending: null,\n values: new WeakMap(),\n }))\n return (\n <ComboboxToggleContext.Provider value={tracker}>\n <ComboboxPrimitive.Portal container={container}>\n <PortalTheme>\n <ComboboxPrimitive.Backdrop\n data-slot=\"combobox-backdrop\"\n className=\"fixed top-(--spark-viewport-top,0) right-0 left-0 z-50 h-(--spark-viewport-height,100%) bg-(--color-overlay) transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none sm:hidden\"\n />\n <ComboboxPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className=\"z-50 max-sm:fixed! max-sm:inset-x-0! max-sm:top-auto! max-sm:bottom-(--spark-viewport-bottom-offset,0)! max-sm:transform-none!\"\n >\n <ComboboxPrimitive.Popup\n data-slot=\"combobox-content\"\n className={cn(\n 'relative isolate z-50 flex max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) flex-col overflow-hidden rounded-lg border border-gray-a1 bg-gray-1 p-1 text-gray-a12 shadow-lg dark:bg-gray-3 [[data-high-contrast]_&]:border-gray-a11',\n 'transition-[opacity,scale,translate] duration-100 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',\n 'sm:data-[side=bottom]:data-starting-style:-translate-y-2 sm:data-[side=left]:data-starting-style:translate-x-2 sm:data-[side=right]:data-starting-style:-translate-x-2 sm:data-[side=top]:data-starting-style:translate-y-2',\n 'max-sm:max-h-[80dvh] max-sm:w-full max-sm:max-w-none max-sm:rounded-b-none max-sm:border-x-0 max-sm:border-b-0 max-sm:px-4 max-sm:pt-3 max-sm:pb-[calc(env(safe-area-inset-bottom)+var(--spacing)*4)] max-sm:data-ending-style:translate-y-full max-sm:data-ending-style:scale-100 max-sm:data-ending-style:opacity-100 max-sm:data-starting-style:translate-y-full max-sm:data-starting-style:scale-100 max-sm:data-starting-style:opacity-100',\n className,\n )}\n {...props}\n onKeyDownCapture={(event) => {\n onKeyDownCapture?.(event)\n if (HIGHLIGHT_KEYS.has(event.key))\n event.currentTarget.setAttribute('data-keyboard', '')\n }}\n onPointerDownCapture={(event) => {\n onPointerDownCapture?.(event)\n event.currentTarget.removeAttribute('data-keyboard')\n }}\n >\n {children}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </PortalTheme>\n </ComboboxPrimitive.Portal>\n </ComboboxToggleContext.Provider>\n )\n}\n\n// Base UI removes the last pick on Backspace in the empty input only inside Chips\nfunction ComboboxInput({\n className,\n onKeyDown,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Input>) {\n const tracker = React.useContext(ComboboxToggleContext)\n return (\n <ComboboxPrimitive.Chips\n data-slot=\"combobox-search\"\n // Chips adds role=\"toolbar\" for arrow keys between chips; this row holds none\n render={({ role: _toolbar, ...chipsProps }) => <div {...chipsProps} />}\n className=\"-mx-1 -mt-1 mb-1 flex shrink-0 items-center gap-1.5 border-b border-gray-a4 px-2.5 text-gray-light max-sm:mx-0 max-sm:mt-0 max-sm:mb-2 max-sm:rounded-md max-sm:border-b-0 max-sm:bg-gray-a3\"\n >\n <Search aria-hidden className=\"shrink-0 [--spark-icon-size:16px]\" />\n <ComboboxPrimitive.Input\n data-slot=\"combobox-input\"\n className={cn(\n 'h-10 w-full min-w-0 bg-transparent text-base text-gray outline-hidden placeholder:text-gray-placeholder',\n className,\n )}\n onKeyDown={(event) => {\n onKeyDown?.(event)\n if (!tracker || event.key !== 'Enter') return\n const highlighted = event.currentTarget\n .closest('[data-slot=\"combobox-content\"]')\n ?.querySelector('[data-slot=\"combobox-item\"][data-highlighted]')\n if (!highlighted) return\n tracker.pending = { value: tracker.values.get(highlighted) }\n setTimeout(() => {\n tracker.pending = null\n })\n }}\n {...props}\n />\n </ComboboxPrimitive.Chips>\n )\n}\n\n// the bottom sheet's \"Done\"; hidden from `sm` up, where the popup closes on outside press\nfunction ComboboxClose({\n className,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"combobox-close\"\n type=\"button\"\n className={cn(\n buttonVariants({ variant: 'primary' }),\n 'mt-3 w-full shrink-0 sm:hidden',\n className,\n )}\n onClick={(event) => {\n onClick?.(event)\n // Combobox has no Close part; Escape is the key Base UI closes on\n event.currentTarget.dispatchEvent(\n new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),\n )\n }}\n {...props}\n />\n )\n}\n\nfunction ComboboxList({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.List>) {\n return (\n <ComboboxPrimitive.List\n data-slot=\"combobox-list\"\n className={cn(\n 'min-h-0 flex-1 overflow-y-auto overscroll-contain outline-hidden data-empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\n// forwardRef keeps refs working for React 18 consumers (ref-as-prop is 19-only)\nconst ComboboxItem = React.forwardRef<\n HTMLDivElement,\n ComboboxPrimitive.Item.Props\n>(function ComboboxItem({ className, value, ...props }, refProp) {\n const tracker = React.useContext(ComboboxToggleContext)\n const ref = React.useRef<HTMLDivElement | null>(null)\n React.useEffect(() => {\n const node = ref.current\n if (!tracker || !node) return\n tracker.values.set(node, value)\n if (!tracker.pending || !Object.is(tracker.pending.value, value)) return\n tracker.pending = null\n // after Base UI has registered the remounted item's new index\n const timer = setTimeout(() =>\n node.dispatchEvent(new MouseEvent('mousemove', { bubbles: true })),\n )\n return () => clearTimeout(timer)\n }, [tracker, value])\n return (\n <ComboboxPrimitive.Item\n ref={(node: HTMLDivElement | null) => {\n ref.current = node\n if (typeof refProp === 'function') refProp(node)\n else if (refProp) refProp.current = node\n }}\n value={value}\n data-slot=\"combobox-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm text-gray outline-hidden transition-colors select-none touch-target-row data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none max-sm:gap-3 max-sm:text-base [@media(hover:none)]:[[data-slot=combobox-content]:not([data-keyboard])_&]:data-highlighted:bg-transparent',\n className,\n )}\n {...props}\n />\n )\n})\n\nconst setInert = (node: HTMLElement | null) => {\n node?.setAttribute('inert', '')\n}\n\n// kept mounted so the bottom sheet draws an empty checkbox for unpicked items\nfunction ComboboxItemIndicator({\n className,\n children,\n keepMounted = true,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.ItemIndicator>) {\n return (\n <ComboboxPrimitive.ItemIndicator\n data-slot=\"combobox-item-indicator\"\n keepMounted={keepMounted}\n className={cn('flex shrink-0 items-center justify-center', className)}\n {...props}\n render={\n props.render ??\n ((indicatorProps, { selected }) => (\n <span {...indicatorProps}>\n <span\n className={cn(\n 'flex size-3.5 items-center justify-center max-sm:hidden',\n !selected && 'invisible',\n )}\n >\n {children ?? (\n <Check aria-hidden className=\"[--spark-icon-size:11px]\" />\n )}\n </span>\n {/* the option owns the press and the selected state; this only draws\n it. inert is set on the node as React 18 has no `inert` prop */}\n <span className=\"flex sm:hidden\" ref={setInert}>\n <Checkbox\n checked={selected}\n className=\"my-0 any-pointer-coarse:my-0\"\n readOnly\n render={<span />}\n />\n </span>\n </span>\n ))\n }\n />\n )\n}\n\nconst isSelectedGroup = (\n group: unknown,\n): group is ComboboxSelectedGroup<unknown> =>\n typeof group === 'object' && group !== null && 'optionCount' in group\n\n// with useComboboxSelectedGroups the picks never filter out, so Base UI alone would never\n// see an empty list; \"no matches\" is the options group gone while it had options\nfunction ComboboxEmpty({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Empty>) {\n const filtered: readonly unknown[] = useComboboxFilteredItems()\n const groups = filtered.filter(isSelectedGroup)\n const noOptionMatches =\n groups.some((group) => group.optionCount > 0) &&\n !groups.some((group) => group.value === 'items')\n return (\n <ComboboxPrimitive.Empty\n data-slot=\"combobox-empty\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n render={({ children: _baseChildren, ...emptyProps }) => (\n <div {...emptyProps}>\n {filtered.length === 0 || noOptionMatches ? children : null}\n </div>\n )}\n />\n )\n}\n\nfunction ComboboxStatus({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Status>) {\n return (\n <ComboboxPrimitive.Status\n data-slot=\"combobox-status\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxGroup({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.Group>) {\n return (\n <ComboboxPrimitive.Group\n data-slot=\"combobox-group\"\n className={cn(\n 'scroll-my-1 [&+&]:mt-1 [&+&]:border-t [&+&]:border-gray-a4 [&+&]:pt-1',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxGroupLabel({\n className,\n ...props\n}: React.ComponentProps<typeof ComboboxPrimitive.GroupLabel>) {\n return (\n <ComboboxPrimitive.GroupLabel\n data-slot=\"combobox-group-label\"\n className={cn(\n 'px-1.5 py-1 text-xs font-medium text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ComboboxSeparator({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"combobox-separator\"\n className={cn(\n 'pointer-events-none -mx-1 my-1 h-px bg-gray-a3 [[data-high-contrast]_&]:bg-gray-a6',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Combobox,\n ComboboxAddChip,\n ComboboxChip,\n ComboboxChips,\n ComboboxClear,\n ComboboxClose,\n ComboboxCollection,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxGroup,\n ComboboxGroupLabel,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxList,\n ComboboxSeparator,\n ComboboxStatus,\n ComboboxTrigger,\n ComboboxTriggerGroup,\n ComboboxValue,\n useComboboxFilter,\n useComboboxFilteredItems,\n useComboboxSelectedGroups,\n}\nexport type { ComboboxSelectedGroup }\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,WAAWA,WAAkB;AACnC,MAAM,gBAAgBA,WAAkB;AACxC,MAAM,qBAAqBA,WAAkB;AAC7C,MAAM,oBAAoBA,WAAkB;AAC5C,MAAM,2BAA2BA,WAAkB;;AAWnD,SAAS,0BACP,OACA,OACA,EACE,UACA,OAAO,YACP,qBAAqB,OAAO,MAM9B;CACA,MAAM,EAAE,aAAa,kBAAkB;CACvC,MAAM,YAAY,SAChB,MAAM,MAAM,WAAW,mBAAmB,MAAM,MAAM,CAAC;CACzD,MAAM,UAAU,MAAM,QAAQ,SAAS,CAAC,SAAS,IAAI,CAAC;CACtD,MAAM,SAAwC,CAC5C;EACE,OAAO;EACP,OAAO;EACP,OAAO,CAAC,GAAG,KAAK;EAChB,aAAa,QAAQ;CACvB,GACA;EACE,O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D,CAAO,CAAA;IAChB,CAAA;GACG,CAAA,CACF;;CAGX,CAAA;AAEL;AAEA,MAAM,mBACJ,UAEA,OAAO,UAAU,YAAY,UAAU,QAAQ,iBAAiB;AAIlE,SAAS,cAAc,EACrB,WACA,UACA,GAAG,SACoD;CACvD,MAAM,WAA+B,yBAAyB;CAC9D,MAAM,SAAS,SAAS,OAAO,eAAe;CAC9C,MAAM,kBACJ,OAAO,MAAM,UAAU,MAAM,cAAc,CAAC,KAC5C,CAAC,OAAO,MAAM,UAAU,MAAM,UAAU,OAAO;CACjD,OACE,oBAACA,WAAkB,OAAnB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;EACJ,SAAS,EAAE,UAAU,eAAe,GAAG,iBACrC,oBAAC,OAAD;GAAK,GAAI;aACN,SAAS,WAAW,KAAK,kBAAkB,WAAW;EACpD,CAAA;CAER,CAAA;AAEL;AAEA,SAAS,eAAe,EACtB,WACA,GAAG,SACqD;CACxD,OACE,oBAACA,WAAkB,QAAnB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,cAAc,EACrB,WACA,GAAG,SACoD;CACvD,OACE,oBAACA,WAAkB,OAAnB;EACE,aAAU;EACV,WAAW,GACT,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,mBAAmB,EAC1B,WACA,GAAG,SACyD;CAC5D,OACE,oBAACA,WAAkB,YAAnB;EACE,aAAU;EACV,WAAW,GACT,0FACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,eAAY;EACZ,aAAU;EACV,WAAW,GACT,sFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -7,7 +7,7 @@ import { SparkIcon } from "@epilot/spark-icons";
|
|
|
7
7
|
//#region src/components/empty-state.d.ts
|
|
8
8
|
declare const emptyStateVariants: (props?: ({
|
|
9
9
|
variant?: "ghost" | "dashed" | null | undefined;
|
|
10
|
-
size?: "
|
|
10
|
+
size?: "default" | "sm" | null | undefined;
|
|
11
11
|
layout?: "inline" | "stacked" | null | undefined;
|
|
12
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
13
|
type EmptyStateVariants = VariantProps<typeof emptyStateVariants>;
|
|
@@ -7,7 +7,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
7
7
|
//#region src/components/empty-state.d.ts
|
|
8
8
|
declare const emptyStateVariants: (props?: ({
|
|
9
9
|
variant?: "ghost" | "dashed" | null | undefined;
|
|
10
|
-
size?: "
|
|
10
|
+
size?: "default" | "sm" | null | undefined;
|
|
11
11
|
layout?: "inline" | "stacked" | null | undefined;
|
|
12
12
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
13
13
|
type EmptyStateVariants = VariantProps<typeof emptyStateVariants>;
|
|
@@ -17,6 +17,15 @@ const FieldContext = react.createContext(null);
|
|
|
17
17
|
function useFieldContext() {
|
|
18
18
|
return react.useContext(FieldContext);
|
|
19
19
|
}
|
|
20
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
21
|
+
function useKeepLabelOutset() {
|
|
22
|
+
const setHasOutsetControl = useFieldContext()?.setHasOutsetControl;
|
|
23
|
+
useIsomorphicLayoutEffect(() => {
|
|
24
|
+
if (!setHasOutsetControl) return;
|
|
25
|
+
setHasOutsetControl(true);
|
|
26
|
+
return () => setHasOutsetControl(false);
|
|
27
|
+
}, [setHasOutsetControl]);
|
|
28
|
+
}
|
|
20
29
|
function useFieldControl(options) {
|
|
21
30
|
const field = useFieldContext();
|
|
22
31
|
const theme = require_components_theme.useTheme();
|
|
@@ -214,10 +223,13 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
214
223
|
const [errorCount, setErrorCount] = react.useState(0);
|
|
215
224
|
const setHasDescription = react.useCallback((has) => setDescriptionCount((n) => n + (has ? 1 : -1)), []);
|
|
216
225
|
const setHasError = react.useCallback((has) => setErrorCount((n) => n + (has ? 1 : -1)), []);
|
|
226
|
+
const [outsetControlCount, setOutsetControlCount] = react.useState(0);
|
|
227
|
+
const setHasOutsetControl = react.useCallback((has) => setOutsetControlCount((n) => n + (has ? 1 : -1)), []);
|
|
217
228
|
const hasDescription = descriptionCount > 0;
|
|
218
229
|
const hasError = errorCount > 0;
|
|
219
230
|
const theme = require_components_theme.useTheme();
|
|
220
|
-
const
|
|
231
|
+
const requestedLabelPosition = labelPositionProp ?? theme.labelPosition ?? "inset";
|
|
232
|
+
const labelPosition = requestedLabelPosition === "floating" && outsetControlCount > 0 ? "outset" : requestedLabelPosition;
|
|
221
233
|
const inputStyle = inputStyleProp ?? theme.inputStyle ?? "soft";
|
|
222
234
|
const inputColor = inputColorProp ?? theme.inputColor ?? "brand";
|
|
223
235
|
const fieldId = `field-${id}`;
|
|
@@ -234,7 +246,8 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
234
246
|
readOnly,
|
|
235
247
|
labelPosition,
|
|
236
248
|
inputStyle,
|
|
237
|
-
inputColor
|
|
249
|
+
inputColor,
|
|
250
|
+
setHasOutsetControl
|
|
238
251
|
}), [
|
|
239
252
|
fieldId,
|
|
240
253
|
labelId,
|
|
@@ -245,11 +258,12 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
245
258
|
readOnly,
|
|
246
259
|
labelPosition,
|
|
247
260
|
inputStyle,
|
|
248
|
-
inputColor
|
|
261
|
+
inputColor,
|
|
262
|
+
setHasOutsetControl
|
|
249
263
|
]);
|
|
250
264
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldContext.Provider, {
|
|
251
265
|
value,
|
|
252
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.
|
|
266
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
253
267
|
role: "group",
|
|
254
268
|
"data-slot": "field",
|
|
255
269
|
"data-label-position": labelPosition,
|
|
@@ -263,7 +277,10 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
263
277
|
inputColor
|
|
264
278
|
}), className),
|
|
265
279
|
...props,
|
|
266
|
-
children
|
|
280
|
+
children: [children, labelPosition === "floating" && inputStyle === "outlined" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldNotch, {
|
|
281
|
+
className: "hidden group-has-[:is(input:not([type=checkbox],[type=radio],[type=hidden]),textarea,[data-slot=select-trigger])]/field:block group-has-[>[data-slot=field-label]]/field:hidden!",
|
|
282
|
+
inputColor
|
|
283
|
+
})]
|
|
267
284
|
})
|
|
268
285
|
});
|
|
269
286
|
}
|
|
@@ -281,11 +298,11 @@ const notchColorClassName = {
|
|
|
281
298
|
brand: "border-input",
|
|
282
299
|
gray: "border-input-gray"
|
|
283
300
|
};
|
|
284
|
-
function FieldNotch({ inputColor, children }) {
|
|
301
|
+
function FieldNotch({ className, inputColor, children }) {
|
|
285
302
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("fieldset", {
|
|
286
303
|
"aria-hidden": "true",
|
|
287
304
|
"data-slot": "field-notch",
|
|
288
|
-
className: (0, cn.cn)(notchClassName, notchColorClassName[inputColor]),
|
|
305
|
+
className: (0, cn.cn)(notchClassName, notchColorClassName[inputColor], className),
|
|
289
306
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", {
|
|
290
307
|
className: "invisible h-3 max-w-[0.01px] p-0 text-xs leading-3 whitespace-nowrap transition-[max-width] duration-50 ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:transition-none field-floated:max-w-full field-floated:delay-50 field-floated:duration-100",
|
|
291
308
|
children: children && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -457,5 +474,6 @@ exports.FieldValue = FieldValue;
|
|
|
457
474
|
exports.useFieldContext = useFieldContext;
|
|
458
475
|
exports.useFieldControl = useFieldControl;
|
|
459
476
|
exports.useFieldSetInvalid = useFieldSetInvalid;
|
|
477
|
+
exports.useKeepLabelOutset = useKeepLabelOutset;
|
|
460
478
|
|
|
461
479
|
//# sourceMappingURL=field.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.cjs","names":["React","useTheme","Skeleton","Separator","Callout"],"sources":["../../src/components/field.tsx"],"sourcesContent":["'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport type {\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { Callout } from './callout'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { useTheme } from './theme'\n\ntype FieldContextValue = {\n id: string\n labelId: string\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n readOnly: boolean\n labelPosition: SparkLabelPosition\n inputStyle: SparkInputStyle\n inputColor: SparkInputColor\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nexport function useFieldContext() {\n return React.useContext(FieldContext)\n}\n\n// Field→Theme→default resolution + id/aria-describedby wiring, shared by every\n// control that can sit inside a Field (Input, SelectTrigger, …) so they can't\n// drift on how a style/color/id resolves. `variant` is the control's own\n// per-instance override (already normalized — e.g. Input maps its 'none' to\n// undefined before calling this).\nexport function useFieldControl(options?: {\n id?: string\n ariaDescribedBy?: string\n variant?: SparkInputStyle\n}) {\n const field = useFieldContext()\n const theme = useTheme()\n const id = options?.id ?? field?.id\n const errorId = field?.hasError ? field.errorId : undefined\n const descriptionId = field?.hasDescription ? field.descriptionId : undefined\n // error before hint: the actionable message should be announced first\n const ariaDescribedBy =\n [errorId, descriptionId, options?.ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined\n const inputStyle =\n options?.variant ?? field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const ariaInvalid = field?.hasError || undefined\n return { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor }\n}\n\ntype FieldSetIndicator = 'required' | 'optional'\n\ntype FieldSetContextValue = {\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n /** Marks the set invalid without linking `errorId` (error has a custom id). */\n setHasUnlinkedError: (has: boolean) => void\n invalid: boolean\n indicator?: FieldSetIndicator\n indicatorLabel?: string\n}\n\nconst FieldSetContext = React.createContext<FieldSetContextValue | null>(null)\n\n/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */\nfunction useFieldSetInvalid() {\n return React.useContext(FieldSetContext)?.invalid || undefined\n}\n\nfunction useSlotCount() {\n const [count, setCount] = React.useState(0)\n const setHas = React.useCallback(\n (has: boolean) => setCount((n) => n + (has ? 1 : -1)),\n [],\n )\n return [count > 0, setHas] as const\n}\n\ninterface FieldSetProps extends React.ComponentProps<'fieldset'> {\n /** Marks the legend: `*` plus hidden text, or a visible \"(optional)\". */\n indicator?: FieldSetIndicator\n /** Text for the mark; defaults to `'required'` or `'optional'`. */\n indicatorLabel?: string\n}\n\nfunction FieldSet({\n className,\n indicator,\n indicatorLabel,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: FieldSetProps) {\n const id = useId()\n const [hasDescription, setHasDescription] = useSlotCount()\n const [hasError, setHasError] = useSlotCount()\n const [hasUnlinkedError, setHasUnlinkedError] = useSlotCount()\n const invalid = hasError || hasUnlinkedError\n const fieldSetId = `field-set-${id}`\n const descriptionId = `${fieldSetId}-description`\n const errorId = `${fieldSetId}-error`\n const value = React.useMemo<FieldSetContextValue>(\n () => ({\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n }),\n [\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n ],\n )\n const ariaDescribedBy =\n [hasError && errorId, hasDescription && descriptionId, ariaDescribedByProp]\n .filter(Boolean)\n .join(' ') || undefined\n\n return (\n <FieldSetContext.Provider value={value}>\n <fieldset\n data-slot=\"field-set\"\n data-invalid={invalid || undefined}\n aria-describedby={ariaDescribedBy}\n className={cn(\n 'group/field-set flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n </FieldSetContext.Provider>\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n children,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n const fieldSet = React.useContext(FieldSetContext)\n const indicator = fieldSet?.indicator\n const indicatorLabel = fieldSet?.indicatorLabel ?? indicator\n return (\n <legend\n data-invalid={fieldSet?.invalid || undefined}\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn(\n 'mb-1.5 font-medium text-gray data-[invalid=true]:text-error-active! data-[variant=label]:text-sm data-[variant=legend]:text-base',\n className,\n )}\n {...props}\n >\n {children}\n {indicator === 'required' && (\n <>\n {' '}\n <span aria-hidden=\"true\">*</span>\n <span className=\"sr-only\">{indicatorLabel}</span>\n </>\n )}\n {indicator === 'optional' && (\n <>\n {' '}\n <span className=\"font-normal text-gray-light\">\n ({indicatorLabel})\n </span>\n </>\n )}\n </legend>\n )\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group flex w-full flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n 'group/field relative flex w-full flex-col data-[invalid=true]:text-error-active',\n {\n variants: {\n labelPosition: {\n // inset puts label + input inside one shell, so the shell IS the input's box —\n // rounded-md tracks Input/Select/etc.'s own control radius, not the container one.\n // the shell draws the focus outline; the control inside keeps its underline cue\n inset:\n 'gap-y-1 rounded-md px-4 py-3 has-[:is(input,textarea,[data-slot=select-trigger]):focus-visible]:focus-outline has-[:user-invalid:focus-visible]:outline-(--color-error-active) has-[[aria-invalid=true]:focus-visible]:outline-(--color-error-active) data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger]):focus-visible]:outline-(--color-error-active)',\n outset: 'gap-y-2',\n floating:\n 'grid grid-cols-[minmax(0,1fr)] gap-y-1 [--spark-field-label-inset:0px] *:col-start-1 *:row-start-1 has-[[data-slot=input-group-addon][data-align=inline-start]]:[--spark-field-label-inset:1.75rem] [&>[data-slot=field-description]]:row-start-auto [&>[data-slot=field-error]]:row-start-auto',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'gray',\n class:\n 'bg-base-gray-soft has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-gray-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: 'border border-input bg-base-accent-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: 'border border-input-gray bg-base-gray-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border border-input',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border border-input-gray',\n },\n // ghost inset = bare label + underlined input; the input carries the line\n {\n labelPosition: 'inset',\n inputStyle: 'ghost',\n class: 'rounded-none px-0',\n },\n // shared inset states: filled shells swap bg, bordered shells swap border\n // invalid hover deepens the error tint instead of falling back to accent\n {\n labelPosition: 'inset',\n inputStyle: ['soft', 'surface'],\n class:\n 'data-[disabled=true]:bg-base-gray-soft data-[invalid=true]:bg-base-error-soft data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-red-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: ['surface', 'outlined'],\n class:\n 'data-[disabled=true]:border-input-disabled data-[invalid=true]:border-input-invalid',\n },\n ],\n },\n)\n\ninterface FieldProps extends React.ComponentProps<'div'> {\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n readOnly?: boolean\n 'data-invalid'?: boolean | 'true' | 'false'\n}\n\nfunction Field({\n className,\n children,\n labelPosition: labelPositionProp,\n inputStyle: inputStyleProp,\n inputColor: inputColorProp,\n readOnly = false,\n 'data-invalid': dataInvalid,\n ...props\n}: FieldProps) {\n const id = useId()\n const [descriptionCount, setDescriptionCount] = React.useState(0)\n const [errorCount, setErrorCount] = React.useState(0)\n // counts, not flags: one slot unmounting must not clear what siblings still need\n const setHasDescription = React.useCallback(\n (has: boolean) => setDescriptionCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const setHasError = React.useCallback(\n (has: boolean) => setErrorCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const hasDescription = descriptionCount > 0\n const hasError = errorCount > 0\n // knobs are structural (they move the label / pick the box carrier), so they\n // resolve here via the <Theme> context; props override per instance\n const theme = useTheme()\n const labelPosition = labelPositionProp ?? theme.labelPosition ?? 'inset'\n const inputStyle = inputStyleProp ?? theme.inputStyle ?? 'soft'\n const inputColor = inputColorProp ?? theme.inputColor ?? 'brand'\n const fieldId = `field-${id}`\n const labelId = `${fieldId}-label`\n const value = React.useMemo<FieldContextValue>(\n () => ({\n id: fieldId,\n labelId,\n descriptionId: `${fieldId}-description`,\n hasDescription,\n setHasDescription,\n errorId: `${fieldId}-error`,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n }),\n [\n fieldId,\n labelId,\n hasDescription,\n setHasDescription,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n ],\n )\n\n return (\n <FieldContext.Provider value={value}>\n <div\n role=\"group\"\n data-slot=\"field\"\n data-label-position={labelPosition}\n data-input-style={inputStyle}\n data-input-color={inputColor}\n data-invalid={dataInvalid ?? (hasError || undefined)}\n aria-labelledby={readOnly ? labelId : undefined}\n className={cn(\n fieldVariants({ labelPosition, inputStyle, inputColor }),\n className,\n )}\n {...props}\n >\n {children}\n </div>\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-1 leading-snug',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName =\n 'text-sm leading-5 font-normal text-gray transition-all group-data-[invalid=true]/field:text-error-active! motion-reduce:transition-none'\n\nconst floatingLabelClassName =\n 'pointer-events-none z-1 mx-3 max-w-[calc(100%-1.5rem)] origin-left translate-x-(--spark-field-label-inset) translate-y-3 self-start justify-self-start truncate text-base leading-6 font-normal text-gray-light transition-[translate,scale,color] duration-200 ease-[cubic-bezier(0,0,0.2,1)] group-focus-within/field:text-accent group-has-[[data-popup-open]]/field:text-accent group-has-[:disabled]/field:text-gray-disabled group-has-[[aria-invalid=true]]/field:text-error-active! group-data-[invalid=true]/field:text-error-active! group-data-[input-style=ghost]/field:mx-0 field-floated:max-w-[calc((100%-1.5rem)/0.75)] field-floated:translate-x-0 field-floated:scale-75 motion-reduce:transition-none'\n\nconst notchClassName =\n 'pointer-events-none -mt-1.5 min-w-0 self-stretch rounded-md border px-[7px] transition-[border-color] duration-200 group-focus-within/field:border-2 group-focus-within/field:border-(--color-focus-root) group-focus-within/field:px-[6px] group-has-[[data-popup-open]]/field:border-2 group-has-[[data-popup-open]]/field:border-(--color-focus-root) group-has-[[data-popup-open]]/field:px-[6px] group-has-[:disabled]/field:border-input-disabled group-has-[[aria-invalid=true]]/field:border-input-invalid! group-data-[invalid=true]/field:border-input-invalid! group-has-[[aria-invalid=true]:focus]/field:border-(--color-error-active)! motion-reduce:transition-none'\n\nconst notchColorClassName: Record<SparkInputColor, string> = {\n brand: 'border-input',\n gray: 'border-input-gray',\n}\n\nfunction FieldNotch({\n inputColor,\n children,\n}: {\n inputColor: SparkInputColor\n children?: React.ReactNode\n}) {\n return (\n <fieldset\n aria-hidden=\"true\"\n data-slot=\"field-notch\"\n className={cn(notchClassName, notchColorClassName[inputColor])}\n >\n <legend className=\"invisible h-3 max-w-[0.01px] p-0 text-xs leading-3 whitespace-nowrap transition-[max-width] duration-50 ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:transition-none field-floated:max-w-full field-floated:delay-50 field-floated:duration-100\">\n {children && <span className=\"inline-block px-1\">{children}</span>}\n </legend>\n </fieldset>\n )\n}\n\nfunction FieldLabel({\n className,\n htmlFor,\n srOnly,\n required,\n children: label,\n ...props\n}: React.ComponentProps<'label'> & {\n srOnly?: boolean\n /** Appends a visual `*`; the control's own `required` announces it. */\n required?: boolean\n}) {\n const field = useFieldContext()\n const floating = field?.labelPosition === 'floating'\n // FieldLegend's visual mark; a read-only value has nothing to fill in\n const children =\n required && !field?.readOnly ? (\n <>\n {label}{' '}\n <span aria-hidden=\"true\" data-slot=\"field-required\">\n *\n </span>\n </>\n ) : (\n label\n )\n const classNames = cn(\n // labels stay full-contrast even when disabled — the control itself\n // (dimmed text, gray shell) signals the state\n floating\n ? cn(\n floatingLabelClassName,\n field.inputStyle === 'outlined'\n ? 'field-floated:-translate-y-1/2'\n : 'field-floated:translate-y-0',\n )\n : fieldLabelClassName,\n // visually hidden but kept in the a11y tree (still names + focuses the control)\n srOnly && 'sr-only',\n className,\n )\n const notch = floating && field.inputStyle === 'outlined' && (\n <FieldNotch inputColor={field.inputColor}>\n {srOnly ? null : children}\n </FieldNotch>\n )\n\n if (field?.readOnly) {\n return (\n <>\n <div data-slot=\"field-label\" id={field.labelId} className={classNames}>\n {children}\n </div>\n {notch}\n </>\n )\n }\n\n return (\n <>\n <label\n data-slot=\"field-label\"\n className={classNames}\n htmlFor={htmlFor ?? field?.id}\n {...props}\n >\n {children}\n </label>\n {notch}\n </>\n )\n}\n\nfunction FieldValue({\n className,\n id,\n title,\n truncate,\n children,\n ...props\n}: React.ComponentProps<'div'> & { truncate?: boolean }) {\n return (\n <div\n data-slot=\"field-value\"\n id={id}\n // truncated string values keep the full text reachable on hover\n title={\n title ??\n (truncate && typeof children === 'string' ? children : undefined)\n }\n className={cn(\n // values are content, not controls — disabled dims but stays ≥4.5:1\n 'min-h-8 w-full text-base text-gray tabular-nums group-data-[disabled=true]/field:opacity-70',\n truncate\n ? 'block truncate leading-8'\n : 'inline-flex items-center wrap-anywhere whitespace-pre-wrap',\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nfunction FieldSkeleton({\n className,\n labelClassName,\n valueClassName,\n truncate,\n ...props\n}: React.ComponentProps<'div'> & {\n truncate?: boolean\n labelClassName?: string\n valueClassName?: string\n}) {\n return (\n <div\n data-slot=\"field-skeleton\"\n aria-hidden=\"true\"\n className={cn('flex w-full flex-col gap-y-1', className)}\n {...props}\n >\n <Skeleton\n data-slot=\"field-skeleton-label\"\n className={cn('h-5 w-24', labelClassName)}\n />\n <Skeleton\n data-slot=\"field-skeleton-value\"\n className={cn(\n 'h-8 min-h-8 w-full',\n truncate && 'max-w-full truncate',\n valueClassName,\n )}\n />\n </div>\n )\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-title\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium text-gray',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({\n className,\n id,\n render,\n ...props\n}: useRender.ComponentProps<'div'>) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasDescription = owner?.setHasDescription\n\n React.useEffect(() => {\n if (!setHasDescription) return\n setHasDescription(true)\n return () => setHasDescription(false)\n }, [setHasDescription])\n\n return useRender({\n defaultTagName: 'div',\n render,\n props: {\n 'data-slot': 'field-description',\n id: id ?? owner?.descriptionId,\n className: cn('text-sm leading-normal text-gray-light', className),\n ...props,\n },\n })\n}\n\nfunction FieldSeparator({\n children,\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"relative mx-auto block w-fit bg-(--spark-background) px-2 text-gray-light\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n id,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasError = owner?.setHasError\n const content = React.useMemo(() => {\n if (children) return children\n if (!errors?.length) return null\n const messages = [\n ...new Set(errors.map((error) => error?.message).filter(Boolean)),\n ]\n if (messages.length === 0) return null\n if (messages.length === 1) return messages[0]\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {messages.map((message) => (\n <li key={message}>{message}</li>\n ))}\n </ul>\n )\n }, [children, errors])\n\n const hasContent = Boolean(content)\n // a custom id means no element carries owner.errorId, so don't advertise it\n const hasCustomId = id != null\n const setSetUnlinked = !field ? fieldSet?.setHasUnlinkedError : undefined\n\n // must run before the empty-content early return to keep hook order stable\n React.useEffect(() => {\n if (!hasContent) return\n const set = hasCustomId ? setSetUnlinked : setHasError\n if (!set) return\n set(true)\n return () => set(false)\n }, [setHasError, setSetUnlinked, hasContent, hasCustomId])\n\n if (!content) return null\n\n if (!field && fieldSet) {\n // straight into Callout: CalloutDescription's <p> cannot hold the <ul> above\n return (\n <Callout\n variant=\"error\"\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? fieldSet.errorId}\n className={className}\n {...props}\n >\n {content}\n </Callout>\n )\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? field?.errorId}\n className={cn('text-sm font-normal text-error', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n useFieldSetInvalid,\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldSkeleton,\n FieldTitle,\n FieldValue,\n}\nexport type { FieldProps, FieldSetProps }\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,MAAM,eAAeA,MAAM,cAAwC,IAAI;AAEvE,SAAgB,kBAAkB;CAChC,OAAOA,MAAM,WAAW,YAAY;AACtC;AAOA,SAAgB,gBAAgB,SAI7B;CACD,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,QAAQC,yBAAAA,SAAS;CACvB,MAAM,KAAK,SAAS,MAAM,OAAO;CAIjC,MAAM,kBACJ;EAJc,OAAO,WAAW,MAAM,UAAU,KAAA;EAC5B,OAAO,iBAAiB,MAAM,gBAAgB,KAAA;EAGzC,SAAS;CAAe,EAC9C,OAAO,OAAO,EACd,KAAK,GAAG,KAAK,KAAA;CAClB,MAAM,aACJ,SAAS,WAAW,OAAO,cAAc,MAAM,cAAc;CAC/D,MAAM,aAAa,OAAO,cAAc,MAAM,cAAc;CAE5D,OAAO;EAAE;EAAO;EAAI;EAAiB,aADjB,OAAO,YAAY,KAAA;EACW;EAAY;CAAW;AAC3E;AAkBA,MAAM,kBAAkBD,MAAM,cAA2C,IAAI;;AAG7E,SAAS,qBAAqB;CAC5B,OAAOA,MAAM,WAAW,eAAe,GAAG,WAAW,KAAA;AACvD;AAEA,SAAS,eAAe;CACtB,MAAM,CAAC,OAAO,YAAYA,MAAM,SAAS,CA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,KAAK,UAAU,OAAO,OAAO,EAAE,OAAO,OAAO,CAAC,CAClE;EACA,IAAI,SAAS,WAAW,GAAG,OAAO;EAClC,IAAI,SAAS,WAAW,GAAG,OAAO,SAAS;EAC3C,OACE,iBAAA,GAAA,kBAAA,KAAC,MAAD;GAAI,WAAU;aACX,SAAS,KAAK,YACb,iBAAA,GAAA,kBAAA,KAAC,MAAD,EAAA,UAAmB,QAAY,GAAtB,OAAsB,CAChC;EACC,CAAA;CAER,GAAG,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,aAAa,QAAQ,OAAO;CAElC,MAAM,cAAc,MAAM;CAC1B,MAAM,iBAAiB,CAAC,QAAQ,UAAU,sBAAsB,KAAA;CAGhE,MAAM,gBAAgB;EACpB,IAAI,CAAC,YAAY;EACjB,MAAM,MAAM,cAAc,iBAAiB;EAC3C,IAAI,CAAC,KAAK;EACV,IAAI,IAAI;EACR,aAAa,IAAI,KAAK;CACxB,GAAG;EAAC;EAAa;EAAgB;EAAY;CAAW,CAAC;CAEzD,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI,CAAC,SAAS,UAEZ,OACE,iBAAA,GAAA,kBAAA,KAACI,2BAAAA,SAAD;EACE,SAAQ;EACR,MAAK;EACL,aAAU;EACV,IAAI,MAAM,SAAS;EACR;EACX,GAAI;YAEH;CACM,CAAA;CAIb,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,IAAI,MAAM,OAAO;EACjB,YAAA,GAAA,GAAA,IAAc,kCAAkC,SAAS;EACzD,GAAI;YAEH;CACE,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"field.cjs","names":["React","useTheme","Skeleton","Separator","Callout"],"sources":["../../src/components/field.tsx"],"sourcesContent":["'use client'\n\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { useId } from 'react'\nimport type {\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { Callout } from './callout'\nimport { Separator } from './separator'\nimport { Skeleton } from './skeleton'\nimport { useTheme } from './theme'\n\ntype FieldContextValue = {\n id: string\n labelId: string\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n readOnly: boolean\n labelPosition: SparkLabelPosition\n inputStyle: SparkInputStyle\n inputColor: SparkInputColor\n setHasOutsetControl: (has: boolean) => void\n}\n\nconst FieldContext = React.createContext<FieldContextValue | null>(null)\n\nexport function useFieldContext() {\n return React.useContext(FieldContext)\n}\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? React.useEffect : React.useLayoutEffect\n\nexport function useKeepLabelOutset() {\n const setHasOutsetControl = useFieldContext()?.setHasOutsetControl\n useIsomorphicLayoutEffect(() => {\n if (!setHasOutsetControl) return\n setHasOutsetControl(true)\n return () => setHasOutsetControl(false)\n }, [setHasOutsetControl])\n}\n\n// Field→Theme→default resolution + id/aria-describedby wiring, shared by every\n// control that can sit inside a Field (Input, SelectTrigger, …) so they can't\n// drift on how a style/color/id resolves. `variant` is the control's own\n// per-instance override (already normalized — e.g. Input maps its 'none' to\n// undefined before calling this).\nexport function useFieldControl(options?: {\n id?: string\n ariaDescribedBy?: string\n variant?: SparkInputStyle\n}) {\n const field = useFieldContext()\n const theme = useTheme()\n const id = options?.id ?? field?.id\n const errorId = field?.hasError ? field.errorId : undefined\n const descriptionId = field?.hasDescription ? field.descriptionId : undefined\n // error before hint: the actionable message should be announced first\n const ariaDescribedBy =\n [errorId, descriptionId, options?.ariaDescribedBy]\n .filter(Boolean)\n .join(' ') || undefined\n const inputStyle =\n options?.variant ?? field?.inputStyle ?? theme.inputStyle ?? 'soft'\n const inputColor = field?.inputColor ?? theme.inputColor ?? 'brand'\n const ariaInvalid = field?.hasError || undefined\n return { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor }\n}\n\ntype FieldSetIndicator = 'required' | 'optional'\n\ntype FieldSetContextValue = {\n descriptionId: string\n hasDescription: boolean\n setHasDescription: (has: boolean) => void\n errorId: string\n hasError: boolean\n setHasError: (has: boolean) => void\n /** Marks the set invalid without linking `errorId` (error has a custom id). */\n setHasUnlinkedError: (has: boolean) => void\n invalid: boolean\n indicator?: FieldSetIndicator\n indicatorLabel?: string\n}\n\nconst FieldSetContext = React.createContext<FieldSetContextValue | null>(null)\n\n/** True when the nearest enclosing FieldSet has an error; ignores outer sets. */\nfunction useFieldSetInvalid() {\n return React.useContext(FieldSetContext)?.invalid || undefined\n}\n\nfunction useSlotCount() {\n const [count, setCount] = React.useState(0)\n const setHas = React.useCallback(\n (has: boolean) => setCount((n) => n + (has ? 1 : -1)),\n [],\n )\n return [count > 0, setHas] as const\n}\n\ninterface FieldSetProps extends React.ComponentProps<'fieldset'> {\n /** Marks the legend: `*` plus hidden text, or a visible \"(optional)\". */\n indicator?: FieldSetIndicator\n /** Text for the mark; defaults to `'required'` or `'optional'`. */\n indicatorLabel?: string\n}\n\nfunction FieldSet({\n className,\n indicator,\n indicatorLabel,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: FieldSetProps) {\n const id = useId()\n const [hasDescription, setHasDescription] = useSlotCount()\n const [hasError, setHasError] = useSlotCount()\n const [hasUnlinkedError, setHasUnlinkedError] = useSlotCount()\n const invalid = hasError || hasUnlinkedError\n const fieldSetId = `field-set-${id}`\n const descriptionId = `${fieldSetId}-description`\n const errorId = `${fieldSetId}-error`\n const value = React.useMemo<FieldSetContextValue>(\n () => ({\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n }),\n [\n descriptionId,\n hasDescription,\n setHasDescription,\n errorId,\n hasError,\n setHasError,\n setHasUnlinkedError,\n invalid,\n indicator,\n indicatorLabel,\n ],\n )\n const ariaDescribedBy =\n [hasError && errorId, hasDescription && descriptionId, ariaDescribedByProp]\n .filter(Boolean)\n .join(' ') || undefined\n\n return (\n <FieldSetContext.Provider value={value}>\n <fieldset\n data-slot=\"field-set\"\n data-invalid={invalid || undefined}\n aria-describedby={ariaDescribedBy}\n className={cn(\n 'group/field-set flex flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n </FieldSetContext.Provider>\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n children,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n const fieldSet = React.useContext(FieldSetContext)\n const indicator = fieldSet?.indicator\n const indicatorLabel = fieldSet?.indicatorLabel ?? indicator\n return (\n <legend\n data-invalid={fieldSet?.invalid || undefined}\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn(\n 'mb-1.5 font-medium text-gray data-[invalid=true]:text-error-active! data-[variant=label]:text-sm data-[variant=legend]:text-base',\n className,\n )}\n {...props}\n >\n {children}\n {indicator === 'required' && (\n <>\n {' '}\n <span aria-hidden=\"true\">*</span>\n <span className=\"sr-only\">{indicatorLabel}</span>\n </>\n )}\n {indicator === 'optional' && (\n <>\n {' '}\n <span className=\"font-normal text-gray-light\">\n ({indicatorLabel})\n </span>\n </>\n )}\n </legend>\n )\n}\n\nfunction FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group flex w-full flex-col gap-[calc(var(--spark-layout-gap)*4)]',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n 'group/field relative flex w-full flex-col data-[invalid=true]:text-error-active',\n {\n variants: {\n labelPosition: {\n // inset puts label + input inside one shell, so the shell IS the input's box —\n // rounded-md tracks Input/Select/etc.'s own control radius, not the container one.\n // the shell draws the focus outline; the control inside keeps its underline cue\n inset:\n 'gap-y-1 rounded-md px-4 py-3 has-[:is(input,textarea,[data-slot=select-trigger]):focus-visible]:focus-outline has-[:user-invalid:focus-visible]:outline-(--color-error-active) has-[[aria-invalid=true]:focus-visible]:outline-(--color-error-active) data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger]):focus-visible]:outline-(--color-error-active)',\n outset: 'gap-y-2',\n floating:\n 'grid grid-cols-[minmax(0,1fr)] gap-y-1 [--spark-field-label-inset:0px] *:col-start-1 *:row-start-1 has-[[data-slot=input-group-addon][data-align=inline-start]]:[--spark-field-label-inset:1.75rem] [&>[data-slot=field-description]]:row-start-auto [&>[data-slot=field-error]]:row-start-auto',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n },\n compoundVariants: [\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'brand',\n class:\n 'bg-input-base has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-input-base-hover',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'soft',\n inputColor: 'gray',\n class:\n 'bg-base-gray-soft has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-gray-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: 'border border-input bg-base-accent-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: 'border border-input-gray bg-base-gray-surface',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: 'border border-input',\n },\n {\n labelPosition: 'inset',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: 'border border-input-gray',\n },\n // ghost inset = bare label + underlined input; the input carries the line\n {\n labelPosition: 'inset',\n inputStyle: 'ghost',\n class: 'rounded-none px-0',\n },\n // shared inset states: filled shells swap bg, bordered shells swap border\n // invalid hover deepens the error tint instead of falling back to accent\n {\n labelPosition: 'inset',\n inputStyle: ['soft', 'surface'],\n class:\n 'data-[disabled=true]:bg-base-gray-soft data-[invalid=true]:bg-base-error-soft data-[invalid=true]:has-[:is(input,textarea,[data-slot=select-trigger],[data-slot=combobox-trigger]):not(:disabled)]:hover:bg-red-a4',\n },\n {\n labelPosition: 'inset',\n inputStyle: ['surface', 'outlined'],\n class:\n 'data-[disabled=true]:border-input-disabled data-[invalid=true]:border-input-invalid',\n },\n ],\n },\n)\n\ninterface FieldProps extends React.ComponentProps<'div'> {\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n readOnly?: boolean\n 'data-invalid'?: boolean | 'true' | 'false'\n}\n\nfunction Field({\n className,\n children,\n labelPosition: labelPositionProp,\n inputStyle: inputStyleProp,\n inputColor: inputColorProp,\n readOnly = false,\n 'data-invalid': dataInvalid,\n ...props\n}: FieldProps) {\n const id = useId()\n const [descriptionCount, setDescriptionCount] = React.useState(0)\n const [errorCount, setErrorCount] = React.useState(0)\n // counts, not flags: one slot unmounting must not clear what siblings still need\n const setHasDescription = React.useCallback(\n (has: boolean) => setDescriptionCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const setHasError = React.useCallback(\n (has: boolean) => setErrorCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const [outsetControlCount, setOutsetControlCount] = React.useState(0)\n const setHasOutsetControl = React.useCallback(\n (has: boolean) => setOutsetControlCount((n) => n + (has ? 1 : -1)),\n [],\n )\n const hasDescription = descriptionCount > 0\n const hasError = errorCount > 0\n // knobs are structural (they move the label / pick the box carrier), so they\n // resolve here via the <Theme> context; props override per instance\n const theme = useTheme()\n const requestedLabelPosition =\n labelPositionProp ?? theme.labelPosition ?? 'inset'\n const labelPosition =\n requestedLabelPosition === 'floating' && outsetControlCount > 0\n ? 'outset'\n : requestedLabelPosition\n const inputStyle = inputStyleProp ?? theme.inputStyle ?? 'soft'\n const inputColor = inputColorProp ?? theme.inputColor ?? 'brand'\n const fieldId = `field-${id}`\n const labelId = `${fieldId}-label`\n const value = React.useMemo<FieldContextValue>(\n () => ({\n id: fieldId,\n labelId,\n descriptionId: `${fieldId}-description`,\n hasDescription,\n setHasDescription,\n errorId: `${fieldId}-error`,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n setHasOutsetControl,\n }),\n [\n fieldId,\n labelId,\n hasDescription,\n setHasDescription,\n hasError,\n setHasError,\n readOnly,\n labelPosition,\n inputStyle,\n inputColor,\n setHasOutsetControl,\n ],\n )\n\n return (\n <FieldContext.Provider value={value}>\n <div\n role=\"group\"\n data-slot=\"field\"\n data-label-position={labelPosition}\n data-input-style={inputStyle}\n data-input-color={inputColor}\n data-invalid={dataInvalid ?? (hasError || undefined)}\n aria-labelledby={readOnly ? labelId : undefined}\n className={cn(\n fieldVariants({ labelPosition, inputStyle, inputColor }),\n className,\n )}\n {...props}\n >\n {children}\n {labelPosition === 'floating' &&\n inputStyle === 'outlined' && (\n // the outline is FieldLabel's notch; a field without a label still needs one\n <FieldNotch\n className=\"hidden group-has-[:is(input:not([type=checkbox],[type=radio],[type=hidden]),textarea,[data-slot=select-trigger])]/field:block group-has-[>[data-slot=field-label]]/field:hidden!\"\n inputColor={inputColor}\n />\n )}\n </div>\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-1 leading-snug',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName =\n 'text-sm leading-5 font-normal text-gray transition-all group-data-[invalid=true]/field:text-error-active! motion-reduce:transition-none'\n\nconst floatingLabelClassName =\n 'pointer-events-none z-1 mx-3 max-w-[calc(100%-1.5rem)] origin-left translate-x-(--spark-field-label-inset) translate-y-3 self-start justify-self-start truncate text-base leading-6 font-normal text-gray-light transition-[translate,scale,color] duration-200 ease-[cubic-bezier(0,0,0.2,1)] group-focus-within/field:text-accent group-has-[[data-popup-open]]/field:text-accent group-has-[:disabled]/field:text-gray-disabled group-has-[[aria-invalid=true]]/field:text-error-active! group-data-[invalid=true]/field:text-error-active! group-data-[input-style=ghost]/field:mx-0 field-floated:max-w-[calc((100%-1.5rem)/0.75)] field-floated:translate-x-0 field-floated:scale-75 motion-reduce:transition-none'\n\nconst notchClassName =\n 'pointer-events-none -mt-1.5 min-w-0 self-stretch rounded-md border px-[7px] transition-[border-color] duration-200 group-focus-within/field:border-2 group-focus-within/field:border-(--color-focus-root) group-focus-within/field:px-[6px] group-has-[[data-popup-open]]/field:border-2 group-has-[[data-popup-open]]/field:border-(--color-focus-root) group-has-[[data-popup-open]]/field:px-[6px] group-has-[:disabled]/field:border-input-disabled group-has-[[aria-invalid=true]]/field:border-input-invalid! group-data-[invalid=true]/field:border-input-invalid! group-has-[[aria-invalid=true]:focus]/field:border-(--color-error-active)! motion-reduce:transition-none'\n\nconst notchColorClassName: Record<SparkInputColor, string> = {\n brand: 'border-input',\n gray: 'border-input-gray',\n}\n\nfunction FieldNotch({\n className,\n inputColor,\n children,\n}: {\n className?: string\n inputColor: SparkInputColor\n children?: React.ReactNode\n}) {\n return (\n <fieldset\n aria-hidden=\"true\"\n data-slot=\"field-notch\"\n className={cn(notchClassName, notchColorClassName[inputColor], className)}\n >\n <legend className=\"invisible h-3 max-w-[0.01px] p-0 text-xs leading-3 whitespace-nowrap transition-[max-width] duration-50 ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:transition-none field-floated:max-w-full field-floated:delay-50 field-floated:duration-100\">\n {children && <span className=\"inline-block px-1\">{children}</span>}\n </legend>\n </fieldset>\n )\n}\n\nfunction FieldLabel({\n className,\n htmlFor,\n srOnly,\n required,\n children: label,\n ...props\n}: React.ComponentProps<'label'> & {\n srOnly?: boolean\n /** Appends a visual `*`; the control's own `required` announces it. */\n required?: boolean\n}) {\n const field = useFieldContext()\n const floating = field?.labelPosition === 'floating'\n // FieldLegend's visual mark; a read-only value has nothing to fill in\n const children =\n required && !field?.readOnly ? (\n <>\n {label}{' '}\n <span aria-hidden=\"true\" data-slot=\"field-required\">\n *\n </span>\n </>\n ) : (\n label\n )\n const classNames = cn(\n // labels stay full-contrast even when disabled — the control itself\n // (dimmed text, gray shell) signals the state\n floating\n ? cn(\n floatingLabelClassName,\n field.inputStyle === 'outlined'\n ? 'field-floated:-translate-y-1/2'\n : 'field-floated:translate-y-0',\n )\n : fieldLabelClassName,\n // visually hidden but kept in the a11y tree (still names + focuses the control)\n srOnly && 'sr-only',\n className,\n )\n const notch = floating && field.inputStyle === 'outlined' && (\n <FieldNotch inputColor={field.inputColor}>\n {srOnly ? null : children}\n </FieldNotch>\n )\n\n if (field?.readOnly) {\n return (\n <>\n <div data-slot=\"field-label\" id={field.labelId} className={classNames}>\n {children}\n </div>\n {notch}\n </>\n )\n }\n\n return (\n <>\n <label\n data-slot=\"field-label\"\n className={classNames}\n htmlFor={htmlFor ?? field?.id}\n {...props}\n >\n {children}\n </label>\n {notch}\n </>\n )\n}\n\nfunction FieldValue({\n className,\n id,\n title,\n truncate,\n children,\n ...props\n}: React.ComponentProps<'div'> & { truncate?: boolean }) {\n return (\n <div\n data-slot=\"field-value\"\n id={id}\n // truncated string values keep the full text reachable on hover\n title={\n title ??\n (truncate && typeof children === 'string' ? children : undefined)\n }\n className={cn(\n // values are content, not controls — disabled dims but stays ≥4.5:1\n 'min-h-8 w-full text-base text-gray tabular-nums group-data-[disabled=true]/field:opacity-70',\n truncate\n ? 'block truncate leading-8'\n : 'inline-flex items-center wrap-anywhere whitespace-pre-wrap',\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n\nfunction FieldSkeleton({\n className,\n labelClassName,\n valueClassName,\n truncate,\n ...props\n}: React.ComponentProps<'div'> & {\n truncate?: boolean\n labelClassName?: string\n valueClassName?: string\n}) {\n return (\n <div\n data-slot=\"field-skeleton\"\n aria-hidden=\"true\"\n className={cn('flex w-full flex-col gap-y-1', className)}\n {...props}\n >\n <Skeleton\n data-slot=\"field-skeleton-label\"\n className={cn('h-5 w-24', labelClassName)}\n />\n <Skeleton\n data-slot=\"field-skeleton-value\"\n className={cn(\n 'h-8 min-h-8 w-full',\n truncate && 'max-w-full truncate',\n valueClassName,\n )}\n />\n </div>\n )\n}\n\nfunction FieldTitle({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-title\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm font-medium text-gray',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({\n className,\n id,\n render,\n ...props\n}: useRender.ComponentProps<'div'>) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasDescription = owner?.setHasDescription\n\n React.useEffect(() => {\n if (!setHasDescription) return\n setHasDescription(true)\n return () => setHasDescription(false)\n }, [setHasDescription])\n\n return useRender({\n defaultTagName: 'div',\n render,\n props: {\n 'data-slot': 'field-description',\n id: id ?? owner?.descriptionId,\n className: cn('text-sm leading-normal text-gray-light', className),\n ...props,\n },\n })\n}\n\nfunction FieldSeparator({\n children,\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('relative -my-2 h-5 text-sm', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"relative mx-auto block w-fit bg-(--spark-background) px-2 text-gray-light\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n id,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const field = useFieldContext()\n const fieldSet = React.useContext(FieldSetContext)\n const owner = field ?? fieldSet\n const setHasError = owner?.setHasError\n const content = React.useMemo(() => {\n if (children) return children\n if (!errors?.length) return null\n const messages = [\n ...new Set(errors.map((error) => error?.message).filter(Boolean)),\n ]\n if (messages.length === 0) return null\n if (messages.length === 1) return messages[0]\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {messages.map((message) => (\n <li key={message}>{message}</li>\n ))}\n </ul>\n )\n }, [children, errors])\n\n const hasContent = Boolean(content)\n // a custom id means no element carries owner.errorId, so don't advertise it\n const hasCustomId = id != null\n const setSetUnlinked = !field ? fieldSet?.setHasUnlinkedError : undefined\n\n // must run before the empty-content early return to keep hook order stable\n React.useEffect(() => {\n if (!hasContent) return\n const set = hasCustomId ? setSetUnlinked : setHasError\n if (!set) return\n set(true)\n return () => set(false)\n }, [setHasError, setSetUnlinked, hasContent, hasCustomId])\n\n if (!content) return null\n\n if (!field && fieldSet) {\n // straight into Callout: CalloutDescription's <p> cannot hold the <ul> above\n return (\n <Callout\n variant=\"error\"\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? fieldSet.errorId}\n className={className}\n {...props}\n >\n {content}\n </Callout>\n )\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n id={id ?? field?.errorId}\n className={cn('text-sm font-normal text-error', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n useFieldSetInvalid,\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldSkeleton,\n FieldTitle,\n FieldValue,\n}\nexport type { FieldProps, FieldSetProps }\n"],"mappings":";;;;;;;;;;;;;;;AAiCA,MAAM,eAAeA,MAAM,cAAwC,IAAI;AAEvE,SAAgB,kBAAkB;CAChC,OAAOA,MAAM,WAAW,YAAY;AACtC;AAEA,MAAM,4BACJ,OAAO,WAAW,cAAcA,MAAM,YAAYA,MAAM;AAE1D,SAAgB,qBAAqB;CACnC,MAAM,sBAAsB,gBAAgB,GAAG;CAC/C,gCAAgC;EAC9B,IAAI,CAAC,qBAAqB;EAC1B,oBAAoB,IAAI;EACxB,aAAa,oBAAoB,KAAK;CACxC,GAAG,CAAC,mBAAmB,CAAC;AAC1B;AAOA,SAAgB,gBAAgB,SAI7B;CACD,MAAM,QAAQ,gBAAgB;CAC9B,MAAM,QAAQC,yBAAAA,SAAS;CACvB,MAAM,KAA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AElC,MAAM,cAAc,MAAM;CAC1B,MAAM,iBAAiB,CAAC,QAAQ,UAAU,sBAAsB,KAAA;CAGhE,MAAM,gBAAgB;EACpB,IAAI,CAAC,YAAY;EACjB,MAAM,MAAM,cAAc,iBAAiB;EAC3C,IAAI,CAAC,KAAK;EACV,IAAI,IAAI;EACR,aAAa,IAAI,KAAK;CACxB,GAAG;EAAC;EAAa;EAAgB;EAAY;CAAW,CAAC;CAEzD,IAAI,CAAC,SAAS,OAAO;CAErB,IAAI,CAAC,SAAS,UAEZ,OACE,iBAAA,GAAA,kBAAA,KAACI,2BAAAA,SAAD;EACE,SAAQ;EACR,MAAK;EACL,aAAU;EACV,IAAI,MAAM,SAAS;EACR;EACX,GAAI;YAEH;CACM,CAAA;CAIb,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,MAAK;EACL,aAAU;EACV,IAAI,MAAM,OAAO;EACjB,YAAA,GAAA,GAAA,IAAc,kCAAkC,SAAS;EACzD,GAAI;YAEH;CACE,CAAA;AAET"}
|
|
@@ -18,8 +18,10 @@ type FieldContextValue = {
|
|
|
18
18
|
labelPosition: SparkLabelPosition;
|
|
19
19
|
inputStyle: SparkInputStyle;
|
|
20
20
|
inputColor: SparkInputColor;
|
|
21
|
+
setHasOutsetControl: (has: boolean) => void;
|
|
21
22
|
};
|
|
22
23
|
declare function useFieldContext(): FieldContextValue | null;
|
|
24
|
+
declare function useKeepLabelOutset(): void;
|
|
23
25
|
declare function useFieldControl(options?: {
|
|
24
26
|
id?: string;
|
|
25
27
|
ariaDescribedBy?: string;
|
|
@@ -140,5 +142,5 @@ declare function FieldError({
|
|
|
140
142
|
} | undefined>;
|
|
141
143
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
142
144
|
//#endregion
|
|
143
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid };
|
|
145
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid, useKeepLabelOutset };
|
|
144
146
|
//# sourceMappingURL=field.d.cts.map
|
|
@@ -18,8 +18,10 @@ type FieldContextValue = {
|
|
|
18
18
|
labelPosition: SparkLabelPosition;
|
|
19
19
|
inputStyle: SparkInputStyle;
|
|
20
20
|
inputColor: SparkInputColor;
|
|
21
|
+
setHasOutsetControl: (has: boolean) => void;
|
|
21
22
|
};
|
|
22
23
|
declare function useFieldContext(): FieldContextValue | null;
|
|
24
|
+
declare function useKeepLabelOutset(): void;
|
|
23
25
|
declare function useFieldControl(options?: {
|
|
24
26
|
id?: string;
|
|
25
27
|
ariaDescribedBy?: string;
|
|
@@ -140,5 +142,5 @@ declare function FieldError({
|
|
|
140
142
|
} | undefined>;
|
|
141
143
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
142
144
|
//#endregion
|
|
143
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid };
|
|
145
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, type FieldProps, FieldSeparator, FieldSet, type FieldSetProps, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid, useKeepLabelOutset };
|
|
144
146
|
//# sourceMappingURL=field.d.ts.map
|
package/dist/components/field.js
CHANGED
|
@@ -15,6 +15,15 @@ const FieldContext = React$1.createContext(null);
|
|
|
15
15
|
function useFieldContext() {
|
|
16
16
|
return React$1.useContext(FieldContext);
|
|
17
17
|
}
|
|
18
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? React$1.useEffect : React$1.useLayoutEffect;
|
|
19
|
+
function useKeepLabelOutset() {
|
|
20
|
+
const setHasOutsetControl = useFieldContext()?.setHasOutsetControl;
|
|
21
|
+
useIsomorphicLayoutEffect(() => {
|
|
22
|
+
if (!setHasOutsetControl) return;
|
|
23
|
+
setHasOutsetControl(true);
|
|
24
|
+
return () => setHasOutsetControl(false);
|
|
25
|
+
}, [setHasOutsetControl]);
|
|
26
|
+
}
|
|
18
27
|
function useFieldControl(options) {
|
|
19
28
|
const field = useFieldContext();
|
|
20
29
|
const theme = useTheme();
|
|
@@ -212,10 +221,13 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
212
221
|
const [errorCount, setErrorCount] = React$1.useState(0);
|
|
213
222
|
const setHasDescription = React$1.useCallback((has) => setDescriptionCount((n) => n + (has ? 1 : -1)), []);
|
|
214
223
|
const setHasError = React$1.useCallback((has) => setErrorCount((n) => n + (has ? 1 : -1)), []);
|
|
224
|
+
const [outsetControlCount, setOutsetControlCount] = React$1.useState(0);
|
|
225
|
+
const setHasOutsetControl = React$1.useCallback((has) => setOutsetControlCount((n) => n + (has ? 1 : -1)), []);
|
|
215
226
|
const hasDescription = descriptionCount > 0;
|
|
216
227
|
const hasError = errorCount > 0;
|
|
217
228
|
const theme = useTheme();
|
|
218
|
-
const
|
|
229
|
+
const requestedLabelPosition = labelPositionProp ?? theme.labelPosition ?? "inset";
|
|
230
|
+
const labelPosition = requestedLabelPosition === "floating" && outsetControlCount > 0 ? "outset" : requestedLabelPosition;
|
|
219
231
|
const inputStyle = inputStyleProp ?? theme.inputStyle ?? "soft";
|
|
220
232
|
const inputColor = inputColorProp ?? theme.inputColor ?? "brand";
|
|
221
233
|
const fieldId = `field-${id}`;
|
|
@@ -232,7 +244,8 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
232
244
|
readOnly,
|
|
233
245
|
labelPosition,
|
|
234
246
|
inputStyle,
|
|
235
|
-
inputColor
|
|
247
|
+
inputColor,
|
|
248
|
+
setHasOutsetControl
|
|
236
249
|
}), [
|
|
237
250
|
fieldId,
|
|
238
251
|
labelId,
|
|
@@ -243,11 +256,12 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
243
256
|
readOnly,
|
|
244
257
|
labelPosition,
|
|
245
258
|
inputStyle,
|
|
246
|
-
inputColor
|
|
259
|
+
inputColor,
|
|
260
|
+
setHasOutsetControl
|
|
247
261
|
]);
|
|
248
262
|
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
249
263
|
value,
|
|
250
|
-
children: /* @__PURE__ */
|
|
264
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
251
265
|
role: "group",
|
|
252
266
|
"data-slot": "field",
|
|
253
267
|
"data-label-position": labelPosition,
|
|
@@ -261,7 +275,10 @@ function Field({ className, children, labelPosition: labelPositionProp, inputSty
|
|
|
261
275
|
inputColor
|
|
262
276
|
}), className),
|
|
263
277
|
...props,
|
|
264
|
-
children
|
|
278
|
+
children: [children, labelPosition === "floating" && inputStyle === "outlined" && /* @__PURE__ */ jsx(FieldNotch, {
|
|
279
|
+
className: "hidden group-has-[:is(input:not([type=checkbox],[type=radio],[type=hidden]),textarea,[data-slot=select-trigger])]/field:block group-has-[>[data-slot=field-label]]/field:hidden!",
|
|
280
|
+
inputColor
|
|
281
|
+
})]
|
|
265
282
|
})
|
|
266
283
|
});
|
|
267
284
|
}
|
|
@@ -279,11 +296,11 @@ const notchColorClassName = {
|
|
|
279
296
|
brand: "border-input",
|
|
280
297
|
gray: "border-input-gray"
|
|
281
298
|
};
|
|
282
|
-
function FieldNotch({ inputColor, children }) {
|
|
299
|
+
function FieldNotch({ className, inputColor, children }) {
|
|
283
300
|
return /* @__PURE__ */ jsx("fieldset", {
|
|
284
301
|
"aria-hidden": "true",
|
|
285
302
|
"data-slot": "field-notch",
|
|
286
|
-
className: cn(notchClassName, notchColorClassName[inputColor]),
|
|
303
|
+
className: cn(notchClassName, notchColorClassName[inputColor], className),
|
|
287
304
|
children: /* @__PURE__ */ jsx("legend", {
|
|
288
305
|
className: "invisible h-3 max-w-[0.01px] p-0 text-xs leading-3 whitespace-nowrap transition-[max-width] duration-50 ease-[cubic-bezier(0,0,0.2,1)] motion-reduce:transition-none field-floated:max-w-full field-floated:delay-50 field-floated:duration-100",
|
|
289
306
|
children: children && /* @__PURE__ */ jsx("span", {
|
|
@@ -440,6 +457,6 @@ function FieldError({ className, children, errors, id, ...props }) {
|
|
|
440
457
|
});
|
|
441
458
|
}
|
|
442
459
|
//#endregion
|
|
443
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid };
|
|
460
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldSkeleton, FieldTitle, FieldValue, useFieldContext, useFieldControl, useFieldSetInvalid, useKeepLabelOutset };
|
|
444
461
|
|
|
445
462
|
//# sourceMappingURL=field.js.map
|