@epilot/spark-ui 0.29.0 → 0.30.0
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/calendar-lists-CTby2kR5.d.cts +27 -0
- package/dist/calendar-lists-DoloqsCN.d.ts +27 -0
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/attachment.cjs +1 -1
- package/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/attachment.js +1 -1
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +1 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/badge.cjs +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/banner.cjs +1 -1
- package/dist/components/banner.js +1 -1
- package/dist/components/box.js +1 -1
- package/dist/components/breadcrumbs.cjs +1 -1
- package/dist/components/breadcrumbs.js +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/button-group.cjs +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.cjs +23 -4
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.d.cts +11 -2
- package/dist/components/calendar.d.ts +11 -2
- package/dist/components/calendar.js +23 -4
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.js +1 -1
- package/dist/components/card.cjs +1 -1
- package/dist/components/card.js +2 -2
- package/dist/components/combobox.cjs +45 -15
- package/dist/components/combobox.cjs.map +1 -1
- package/dist/components/combobox.d.cts +2 -0
- package/dist/components/combobox.d.ts +2 -0
- package/dist/components/combobox.js +46 -16
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/drawer.cjs +1 -1
- package/dist/components/drawer.js +1 -1
- package/dist/components/empty-state.cjs +1 -1
- package/dist/components/empty-state.js +1 -1
- package/dist/components/entity-card.cjs +1 -1
- package/dist/components/entity-card.js +1 -1
- package/dist/components/field.cjs +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/hero-metric.cjs +1 -1
- package/dist/components/hero-metric.js +1 -1
- package/dist/components/info-block.cjs +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/info-block.js +1 -1
- package/dist/components/input-date-time.cjs +212 -0
- package/dist/components/input-date-time.cjs.map +1 -0
- package/dist/components/input-date-time.d.cts +38 -0
- package/dist/components/input-date-time.d.ts +38 -0
- package/dist/components/input-date-time.js +205 -0
- package/dist/components/input-date-time.js.map +1 -0
- package/dist/components/input-group.cjs +2 -2
- package/dist/components/input-group.js +2 -2
- package/dist/components/input-otp.cjs +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/list.cjs +1 -1
- package/dist/components/list.js +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/page-header.cjs +1 -1
- package/dist/components/page-header.js +1 -1
- package/dist/components/popover.cjs +1 -1
- package/dist/components/popover.js +1 -1
- package/dist/components/select.cjs +2 -1
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.js +2 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +1 -1
- package/dist/components/separator.js +1 -1
- package/dist/components/skeleton.cjs +1 -1
- package/dist/components/skeleton.js +1 -1
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/theme.cjs +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toggle.cjs +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/lib/accent-theme.cjs +75 -17
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.d.cts +14 -1
- package/dist/lib/accent-theme.d.ts +14 -1
- package/dist/lib/accent-theme.js +74 -18
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/calendar-lists.cjs +222 -0
- package/dist/lib/calendar-lists.cjs.map +1 -0
- package/dist/lib/calendar-lists.d.cts +4 -0
- package/dist/lib/calendar-lists.d.ts +4 -0
- package/dist/lib/calendar-lists.js +217 -0
- package/dist/lib/calendar-lists.js.map +1 -0
- package/dist/lib/control-glyphs.cjs +37 -0
- package/dist/lib/control-glyphs.cjs.map +1 -0
- package/dist/lib/control-glyphs.d.cts +11 -0
- package/dist/lib/control-glyphs.d.ts +11 -0
- package/dist/lib/control-glyphs.js +35 -0
- package/dist/lib/control-glyphs.js.map +1 -0
- package/dist/lib/date-time-mask.cjs +155 -0
- package/dist/lib/date-time-mask.cjs.map +1 -0
- package/dist/lib/date-time-mask.d.cts +56 -0
- package/dist/lib/date-time-mask.d.ts +56 -0
- package/dist/lib/date-time-mask.js +147 -0
- package/dist/lib/date-time-mask.js.map +1 -0
- package/dist/lib/input-date-parts.cjs +154 -0
- package/dist/lib/input-date-parts.cjs.map +1 -0
- package/dist/lib/input-date-parts.d.cts +53 -0
- package/dist/lib/input-date-parts.d.ts +53 -0
- package/dist/lib/input-date-parts.js +147 -0
- package/dist/lib/input-date-parts.js.map +1 -0
- package/dist/styles/spark-default.css +366 -24
- 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 {\n Add,\n Check,\n Close,\n KeyboardArrowDown,\n Search,\n} from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { boxChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { buttonVariants } from './button'\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 <KeyboardArrowDown\n aria-hidden\n data-slot=\"combobox-chevron\"\n className={cn(\n 'pointer-events-none absolute shrink-0 text-gray-light transition-transform [--spark-icon-size:14px] 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 ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\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// 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 ...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 >\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',\n className,\n )}\n {...props}\n />\n )\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(\n 'flex size-3.5 shrink-0 items-center justify-center [[data-slot=combobox-item]:not([data-selected])_&_svg]:invisible',\n 'max-sm:size-5 max-sm:rounded-sm max-sm:border-2 max-sm:border-(--color-accent-ui) max-sm:bg-base-accent-soft max-sm:[[data-selected]_&]:border-(--color-primary) max-sm:[[data-selected]_&]:bg-(--color-primary) max-sm:[[data-selected]_&]:text-(--spark-on-solid)',\n className,\n )}\n {...props}\n >\n {children ?? <Check aria-hidden className=\"[--spark-icon-size:11px]\" />}\n </ComboboxPrimitive.ItemIndicator>\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":";;;;;;;;;;;;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AAS,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 } 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,CAAC,GAAG,KAAK;EAChB,aAAa,QAAQ;CACvB,GACA;EACE,OAAO;EACP,OAAO;EACP,OAAO;EACP,aAAa,QAAQ;CACvB,CACF;CACA,MAAM,UACJ,MACA,OACA,iBACG,SAAS,IAAI,KAAK,SAAS,MAAM,OAAO,YAAY;CACzD,OAAO;EAAE,OAAO;EAAQ;EAAQ;CAAmB;AACrD;AAEA,MAAM,eACJ;AAEF,MAAM,4BAA4BC,QAAM,cAAc;CACpD,UAAU;CACV,UAAU;AACZ,CAAC;AAID,SAAS,qBAAqB,EAC5B,WACA,GAAG,SACyE;CAC5E,OACE,oBAACD,WAAkB,YAAnB;EACE,aAAU;EACV,WAAW,GACT,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AC,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"}
|
|
@@ -4,8 +4,8 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
const require_components_theme = require("./theme.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
react = require_chunk.__toESM(react);
|
|
7
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
7
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
let vaul = require("vaul");
|
|
10
10
|
let cn = require("cn");
|
|
11
11
|
//#region src/components/drawer.tsx
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { PortalTheme } from "./theme.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { Drawer as Drawer$1 } from "vaul";
|
|
8
8
|
//#region src/components/drawer.tsx
|
|
9
9
|
function Drawer({ shouldScaleBackground = true, ...props }) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_components_icon = require("./icon.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
5
|
let class_variance_authority = require("class-variance-authority");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
7
|
let cn = require("cn");
|
|
8
8
|
//#region src/components/empty-state.tsx
|
|
9
9
|
const emptyStateVariants = (0, class_variance_authority.cva)("flex", {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import { Icon } from "./icon.js";
|
|
4
4
|
import { createContext, useContext } from "react";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { cva } from "class-variance-authority";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/empty-state.tsx
|
|
8
8
|
const emptyStateVariants = cva("flex", {
|
|
9
9
|
variants: {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
6
|
let class_variance_authority = require("class-variance-authority");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/entity-card.tsx
|
|
10
10
|
const EntityCard = ({ className, ...rest }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/entity-card.tsx
|
|
7
7
|
const EntityCard = ({ className, ...rest }) => /* @__PURE__ */ jsx("div", {
|
|
8
8
|
className: cn("flex flex-col overflow-hidden rounded-lg border border-gray bg-(--spark-background)", className),
|
|
@@ -8,9 +8,9 @@ const require_components_separator = require("./separator.cjs");
|
|
|
8
8
|
const require_components_skeleton = require("./skeleton.cjs");
|
|
9
9
|
let react = require("react");
|
|
10
10
|
react = require_chunk.__toESM(react);
|
|
11
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
11
|
let class_variance_authority = require("class-variance-authority");
|
|
13
12
|
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
13
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
14
14
|
let cn = require("cn");
|
|
15
15
|
//#region src/components/field.tsx
|
|
16
16
|
const FieldContext = react.createContext(null);
|
package/dist/components/field.js
CHANGED
|
@@ -7,9 +7,9 @@ import { Separator } from "./separator.js";
|
|
|
7
7
|
import { Skeleton } from "./skeleton.js";
|
|
8
8
|
import * as React$1 from "react";
|
|
9
9
|
import { useId } from "react";
|
|
10
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
10
|
import { cva } from "class-variance-authority";
|
|
12
11
|
import { useRender } from "@base-ui/react/use-render";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region src/components/field.tsx
|
|
14
14
|
const FieldContext = React$1.createContext(null);
|
|
15
15
|
function useFieldContext() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
3
|
let class_variance_authority = require("class-variance-authority");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let cn = require("cn");
|
|
6
6
|
//#region src/components/hero-metric.tsx
|
|
7
7
|
const HeroMetric = ({ className, ...rest }) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
3
|
import { cva } from "class-variance-authority";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/components/hero-metric.tsx
|
|
6
6
|
const HeroMetric = ({ className, ...rest }) => {
|
|
7
7
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
6
|
let class_variance_authority = require("class-variance-authority");
|
|
7
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let cn = require("cn");
|
|
9
9
|
//#region src/components/info-block.tsx
|
|
10
10
|
const infoBlockVariants = (0, class_variance_authority.cva)("flex items-center gap-3", {
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/info-block.d.ts
|
|
7
7
|
declare const InfoBlock: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "bare" | "default" | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
declare const InfoBlockIcon: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
declare const InfoBlockContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
@@ -5,7 +5,7 @@ import { VariantProps } from "class-variance-authority";
|
|
|
5
5
|
|
|
6
6
|
//#region src/components/info-block.d.ts
|
|
7
7
|
declare const InfoBlock: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "bare" | "default" | null | undefined;
|
|
9
9
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string> & React$1.RefAttributes<HTMLDivElement>>;
|
|
10
10
|
declare const InfoBlockIcon: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
11
11
|
declare const InfoBlockContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/info-block.tsx
|
|
7
7
|
const infoBlockVariants = cva("flex items-center gap-3", {
|
|
8
8
|
variants: { variant: {
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
5
|
+
const require_components_button = require("./button.cjs");
|
|
6
|
+
const require_lib_date_time_mask = require("../lib/date-time-mask.cjs");
|
|
7
|
+
const require_lib_input_date_parts = require("../lib/input-date-parts.cjs");
|
|
8
|
+
const require_components_input_group = require("./input-group.cjs");
|
|
9
|
+
const require_components_calendar = require("./calendar.cjs");
|
|
10
|
+
const require_components_popover = require("./popover.cjs");
|
|
11
|
+
let react = require("react");
|
|
12
|
+
react = require_chunk.__toESM(react);
|
|
13
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
let ictus_time = require("ictus/time");
|
|
16
|
+
let cn = require("cn");
|
|
17
|
+
//#region src/components/input-date-time.tsx
|
|
18
|
+
function useControllableState({ defaultProp, onChange, prop }) {
|
|
19
|
+
const [uncontrolled, setUncontrolled] = react.useState(defaultProp);
|
|
20
|
+
const isControlled = prop !== void 0;
|
|
21
|
+
return [isControlled ? prop : uncontrolled, react.useCallback((next) => {
|
|
22
|
+
if (!isControlled) setUncontrolled(next);
|
|
23
|
+
onChange?.(next);
|
|
24
|
+
}, [isControlled, onChange])];
|
|
25
|
+
}
|
|
26
|
+
const today = () => /* @__PURE__ */ new Date();
|
|
27
|
+
const placeholderOf = (separator, withTime) => `DD${separator}MM${separator}YYYY${withTime ? ", HH:MM" : ""}`;
|
|
28
|
+
/** The field text, the popup and the month shown, and how a pick becomes text. */
|
|
29
|
+
function useInputDateTimeState({ calendarMonth, defaultOpen = false, defaultValue = "", getDefaultDate, onDateChange, onOpenChange, onValueChange, open: openProp, separator, value, withTime }) {
|
|
30
|
+
const [text, setText] = useControllableState({
|
|
31
|
+
defaultProp: defaultValue,
|
|
32
|
+
onChange: onValueChange,
|
|
33
|
+
prop: value
|
|
34
|
+
});
|
|
35
|
+
const [open, setOpenState] = useControllableState({
|
|
36
|
+
defaultProp: defaultOpen,
|
|
37
|
+
onChange: onOpenChange,
|
|
38
|
+
prop: openProp
|
|
39
|
+
});
|
|
40
|
+
const selected = require_lib_date_time_mask.parseDatePart(text);
|
|
41
|
+
const parsed = require_lib_date_time_mask.parseDateTime(text, withTime);
|
|
42
|
+
const selectedTime = withTime && parsed ? (0, ictus_time.formatTime)(parsed) : void 0;
|
|
43
|
+
const [month, setMonth] = react.useState(() => selected ?? calendarMonth);
|
|
44
|
+
const setOpen = react.useCallback((next) => {
|
|
45
|
+
if (next && calendarMonth === void 0) setMonth(require_lib_date_time_mask.parseDatePart(text) ?? getDefaultDate());
|
|
46
|
+
setOpenState(next);
|
|
47
|
+
}, [
|
|
48
|
+
calendarMonth,
|
|
49
|
+
getDefaultDate,
|
|
50
|
+
setOpenState,
|
|
51
|
+
text
|
|
52
|
+
]);
|
|
53
|
+
const commit = react.useCallback((next) => {
|
|
54
|
+
if (next === text) return;
|
|
55
|
+
setText(next);
|
|
56
|
+
onDateChange?.(require_lib_date_time_mask.parseDateTime(next, withTime));
|
|
57
|
+
}, [
|
|
58
|
+
onDateChange,
|
|
59
|
+
setText,
|
|
60
|
+
text,
|
|
61
|
+
withTime
|
|
62
|
+
]);
|
|
63
|
+
const commitDate = (day, time = "00:00") => {
|
|
64
|
+
const next = new Date(day);
|
|
65
|
+
const [hours = 0, minutes = 0] = time.split(":").map(Number);
|
|
66
|
+
next.setHours(hours, minutes, 0, 0);
|
|
67
|
+
commit(require_lib_date_time_mask.formatDateTime(next, separator, withTime));
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
commit,
|
|
71
|
+
commitDate,
|
|
72
|
+
month,
|
|
73
|
+
open,
|
|
74
|
+
selected,
|
|
75
|
+
selectedTime,
|
|
76
|
+
setMonth,
|
|
77
|
+
setOpen,
|
|
78
|
+
text
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const InputDateTime = react.forwardRef(function InputDateTime({ calendarLabel, calendarProps, className, container, defaultOpen, defaultTime = "08:00", defaultValue, disabled, getDefaultDate = today, id, onDateChange, onKeyDown, onOpenChange, onPaste, onValueChange, open: openProp, pickerOnly = false, placeholder, rejectedKeyMessage, separator = ".", timeLabel, timeStep = 30, value: valueProp, withTime = false, ...props }, ref) {
|
|
82
|
+
const inputRef = react.useRef(null);
|
|
83
|
+
const [status, announce] = require_lib_input_date_parts.useAnnouncement();
|
|
84
|
+
const { commit, commitDate, month, open, selected, selectedTime, setMonth, setOpen, text } = useInputDateTimeState({
|
|
85
|
+
calendarMonth: calendarProps?.month,
|
|
86
|
+
defaultOpen,
|
|
87
|
+
defaultValue,
|
|
88
|
+
getDefaultDate,
|
|
89
|
+
onDateChange,
|
|
90
|
+
onOpenChange,
|
|
91
|
+
onValueChange,
|
|
92
|
+
open: openProp,
|
|
93
|
+
separator,
|
|
94
|
+
value: valueProp,
|
|
95
|
+
withTime
|
|
96
|
+
});
|
|
97
|
+
const setInputRef = react.useCallback((node) => {
|
|
98
|
+
inputRef.current = node;
|
|
99
|
+
if (typeof ref === "function") ref(node);
|
|
100
|
+
else if (ref) ref.current = node;
|
|
101
|
+
}, [ref]);
|
|
102
|
+
const times = react.useMemo(() => withTime ? require_lib_input_date_parts.timesOf(timeStep, selectedTime) : [], [
|
|
103
|
+
selectedTime,
|
|
104
|
+
timeStep,
|
|
105
|
+
withTime
|
|
106
|
+
]);
|
|
107
|
+
const handlers = require_lib_input_date_parts.useMaskHandlers({
|
|
108
|
+
commit,
|
|
109
|
+
inputRef,
|
|
110
|
+
onKeyDown,
|
|
111
|
+
onOpen: () => setOpen(true),
|
|
112
|
+
onPaste,
|
|
113
|
+
onRejectedKey: () => {
|
|
114
|
+
if (rejectedKeyMessage) announce(rejectedKeyMessage);
|
|
115
|
+
},
|
|
116
|
+
pickerOnly,
|
|
117
|
+
separator,
|
|
118
|
+
withTime
|
|
119
|
+
});
|
|
120
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_popover.Popover, {
|
|
121
|
+
onOpenChange: setOpen,
|
|
122
|
+
open,
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverAnchor, {
|
|
125
|
+
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "min-w-0" }),
|
|
126
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_input_group.InputGroup, {
|
|
127
|
+
className,
|
|
128
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupInput, {
|
|
129
|
+
autoComplete: "off",
|
|
130
|
+
...props,
|
|
131
|
+
className: (0, cn.cn)(pickerOnly && "cursor-pointer"),
|
|
132
|
+
disabled,
|
|
133
|
+
id,
|
|
134
|
+
inputMode: pickerOnly ? void 0 : "numeric",
|
|
135
|
+
onChange: () => {},
|
|
136
|
+
onClick: (event) => {
|
|
137
|
+
props.onClick?.(event);
|
|
138
|
+
if (pickerOnly && !disabled && !event.defaultPrevented) setOpen(true);
|
|
139
|
+
},
|
|
140
|
+
...handlers,
|
|
141
|
+
placeholder: placeholder ?? placeholderOf(separator, withTime),
|
|
142
|
+
readOnly: pickerOnly,
|
|
143
|
+
ref: setInputRef,
|
|
144
|
+
spellCheck: false,
|
|
145
|
+
value: text
|
|
146
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_input_group.InputGroupAddon, {
|
|
147
|
+
align: "inline-end",
|
|
148
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverTrigger, { render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
|
|
149
|
+
"aria-label": calendarLabel,
|
|
150
|
+
color: "neutral",
|
|
151
|
+
disabled,
|
|
152
|
+
size: "icon-small",
|
|
153
|
+
styleVariant: "ghost",
|
|
154
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_epilot_spark_icons.CalendarMonth, {})
|
|
155
|
+
}) })
|
|
156
|
+
})]
|
|
157
|
+
})
|
|
158
|
+
}),
|
|
159
|
+
status,
|
|
160
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_popover.PopoverContent, {
|
|
161
|
+
align: "start",
|
|
162
|
+
"aria-label": calendarLabel,
|
|
163
|
+
className: "w-auto p-0",
|
|
164
|
+
collisionAvoidance: {
|
|
165
|
+
side: "flip",
|
|
166
|
+
fallbackAxisSide: "none"
|
|
167
|
+
},
|
|
168
|
+
container,
|
|
169
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
170
|
+
className: "flex max-sm:flex-col has-[[data-slot=calendar-list]]:[&>[data-slot=input-date-times]]:hidden",
|
|
171
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_calendar.Calendar, {
|
|
172
|
+
autoFocus: true,
|
|
173
|
+
...calendarProps,
|
|
174
|
+
mode: "single",
|
|
175
|
+
month: calendarProps?.month ?? month,
|
|
176
|
+
onMonthChange: (next) => {
|
|
177
|
+
calendarProps?.onMonthChange?.(next);
|
|
178
|
+
if (calendarProps?.month === void 0) setMonth(next);
|
|
179
|
+
},
|
|
180
|
+
onSelect: (next) => {
|
|
181
|
+
if (!withTime) {
|
|
182
|
+
commit(next ? require_lib_date_time_mask.formatDateTime(next, separator) : "");
|
|
183
|
+
setOpen(false);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (next) commitDate(next, selectedTime ?? defaultTime);
|
|
187
|
+
},
|
|
188
|
+
selected
|
|
189
|
+
}), withTime && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_lib_input_date_parts.TimeList, {
|
|
190
|
+
defaultTime,
|
|
191
|
+
label: timeLabel,
|
|
192
|
+
onPick: (time) => {
|
|
193
|
+
commitDate(selected ?? getDefaultDate(), time);
|
|
194
|
+
setOpen(false);
|
|
195
|
+
inputRef.current?.focus();
|
|
196
|
+
},
|
|
197
|
+
open,
|
|
198
|
+
selectedTime,
|
|
199
|
+
times
|
|
200
|
+
})]
|
|
201
|
+
})
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
//#endregion
|
|
207
|
+
exports.InputDateTime = InputDateTime;
|
|
208
|
+
exports.dateTimeStatus = require_lib_date_time_mask.dateTimeStatus;
|
|
209
|
+
exports.formatDateTime = require_lib_date_time_mask.formatDateTime;
|
|
210
|
+
exports.parseDateTime = require_lib_date_time_mask.parseDateTime;
|
|
211
|
+
|
|
212
|
+
//# sourceMappingURL=input-date-time.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-date-time.cjs","names":["React","parseDatePart","parseDateTime","formatDateTime","useAnnouncement","timesOf","useMaskHandlers","Popover","PopoverAnchor","InputGroup","InputGroupInput","InputGroupAddon","PopoverTrigger","Button","CalendarMonth","PopoverContent","Calendar","TimeList"],"sources":["../../src/components/input-date-time.tsx"],"sourcesContent":["'use client'\n\nimport { CalendarMonth } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport {\n formatDateTime,\n formatTime,\n parseDatePart,\n parseDateTime,\n} from '../lib/date-time-mask'\nimport {\n TimeList,\n timesOf,\n useAnnouncement,\n useMaskHandlers,\n} from '../lib/input-date-parts'\nimport { cn } from '../utils/cn'\nimport { Button } from './button'\nimport { Calendar, type CalendarProps } from './calendar'\nimport { InputGroup, InputGroupAddon, InputGroupInput } from './input-group'\nimport {\n Popover,\n PopoverAnchor,\n PopoverContent,\n PopoverTrigger,\n} from './popover'\n\nfunction useControllableState<T>({\n defaultProp,\n onChange,\n prop,\n}: {\n defaultProp: T\n onChange?: (value: T) => void\n prop?: T\n}) {\n const [uncontrolled, setUncontrolled] = React.useState(defaultProp)\n const isControlled = prop !== undefined\n const value = isControlled ? prop : uncontrolled\n\n const setValue = React.useCallback(\n (next: T) => {\n if (!isControlled) setUncontrolled(next)\n onChange?.(next)\n },\n [isControlled, onChange],\n )\n\n return [value, setValue] as const\n}\n\nconst today = () => new Date()\n\nconst placeholderOf = (separator: string, withTime: boolean) =>\n `DD${separator}MM${separator}YYYY${withTime ? ', HH:MM' : ''}`\n\n/** The field text, the popup and the month shown, and how a pick becomes text. */\nfunction useInputDateTimeState({\n calendarMonth,\n defaultOpen = false,\n defaultValue = '',\n getDefaultDate,\n onDateChange,\n onOpenChange,\n onValueChange,\n open: openProp,\n separator,\n value,\n withTime,\n}: {\n calendarMonth?: Date\n defaultOpen?: boolean\n defaultValue?: string\n getDefaultDate: () => Date\n onDateChange?: (date: Date | undefined) => void\n onOpenChange?: (open: boolean) => void\n onValueChange?: (value: string) => void\n open?: boolean\n separator: string\n value?: string\n withTime: boolean\n}) {\n const [text, setText] = useControllableState({\n defaultProp: defaultValue,\n onChange: onValueChange,\n prop: value,\n })\n const [open, setOpenState] = useControllableState({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: openProp,\n })\n // the day stays picked while its time is still being typed\n const selected = parseDatePart(text)\n const parsed = parseDateTime(text, withTime)\n const selectedTime = withTime && parsed ? formatTime(parsed) : undefined\n const [month, setMonth] = React.useState<Date | undefined>(\n () => selected ?? calendarMonth,\n )\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (next && calendarMonth === undefined) {\n setMonth(parseDatePart(text) ?? getDefaultDate())\n }\n setOpenState(next)\n },\n [calendarMonth, getDefaultDate, setOpenState, text],\n )\n const commit = React.useCallback(\n (next: string) => {\n if (next === text) return\n setText(next)\n onDateChange?.(parseDateTime(next, withTime))\n },\n [onDateChange, setText, text, withTime],\n )\n const commitDate = (day: Date, time = '00:00') => {\n const next = new Date(day)\n const [hours = 0, minutes = 0] = time.split(':').map(Number)\n next.setHours(hours, minutes, 0, 0)\n commit(formatDateTime(next, separator, withTime))\n }\n return {\n commit,\n commitDate,\n month,\n open,\n selected,\n selectedTime,\n setMonth,\n setOpen,\n text,\n }\n}\n\n/**\n * A date, or a date and a time (`withTime`), in one field with a calendar popup.\n * Input Date's journey-grade sibling: the chosen day takes focus on open, Backspace\n * after a separator deletes the digit before it, pastes go through the mask, and\n * ignored keys can be read out.\n */\nexport type InputDateTimeProps = Omit<\n React.ComponentProps<'input'>,\n 'children' | 'defaultValue' | 'onChange' | 'readOnly' | 'type' | 'value'\n> & {\n calendarLabel: string\n calendarProps?: Omit<CalendarProps, 'mode' | 'onSelect' | 'selected'>\n /** Element the calendar popup mounts into, e.g. the drawer it sits in. */\n container?: React.ComponentProps<typeof PopoverContent>['container']\n defaultOpen?: boolean\n /** `HH:MM` a day picked from the calendar gets while no time is set. */\n defaultTime?: string\n defaultValue?: string\n /** The day a time picked before any date applies to; today by default. */\n getDefaultDate?: () => Date\n /** The date, with its time when `withTime`; undefined until complete. */\n onDateChange?: (date: Date | undefined) => void\n onOpenChange?: (open: boolean) => void\n onValueChange?: (value: string) => void\n open?: boolean\n pickerOnly?: boolean\n /** Read out politely when a key the field ignores is typed, e.g. \"Only numbers are allowed\". */\n rejectedKeyMessage?: string\n separator?: string\n /** Names the time list. */\n timeLabel?: string\n /** Minutes between the times offered; 30 by default, 5 at least. */\n timeStep?: number\n value?: string\n /** Adds `, HH:MM` to the field and a time list beside the calendar. */\n withTime?: boolean\n}\n\nconst InputDateTime = React.forwardRef<HTMLInputElement, InputDateTimeProps>(\n function InputDateTime(\n {\n calendarLabel,\n calendarProps,\n className,\n container,\n defaultOpen,\n defaultTime = '08:00',\n defaultValue,\n disabled,\n getDefaultDate = today,\n id,\n onDateChange,\n onKeyDown,\n onOpenChange,\n onPaste,\n onValueChange,\n open: openProp,\n pickerOnly = false,\n placeholder,\n rejectedKeyMessage,\n separator = '.',\n timeLabel,\n timeStep = 30,\n value: valueProp,\n withTime = false,\n ...props\n },\n ref,\n ) {\n const inputRef = React.useRef<HTMLInputElement>(null)\n const [status, announce] = useAnnouncement()\n const {\n commit,\n commitDate,\n month,\n open,\n selected,\n selectedTime,\n setMonth,\n setOpen,\n text,\n } = useInputDateTimeState({\n calendarMonth: calendarProps?.month,\n defaultOpen,\n defaultValue,\n getDefaultDate,\n onDateChange,\n onOpenChange,\n onValueChange,\n open: openProp,\n separator,\n value: valueProp,\n withTime,\n })\n\n const setInputRef = React.useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) ref.current = node\n },\n [ref],\n )\n\n const times = React.useMemo(\n () => (withTime ? timesOf(timeStep, selectedTime) : []),\n [selectedTime, timeStep, withTime],\n )\n\n const handlers = useMaskHandlers({\n commit,\n inputRef,\n onKeyDown,\n onOpen: () => setOpen(true),\n onPaste,\n onRejectedKey: () => {\n if (rejectedKeyMessage) announce(rejectedKeyMessage)\n },\n pickerOnly,\n separator,\n withTime,\n })\n\n return (\n <Popover onOpenChange={setOpen} open={open}>\n {/* a plain element anchors the popup: InputGroup drops its ref on React 18 */}\n <PopoverAnchor render={<div className=\"min-w-0\" />}>\n <InputGroup className={className}>\n <InputGroupInput\n autoComplete=\"off\"\n {...props}\n className={cn(pickerOnly && 'cursor-pointer')}\n disabled={disabled}\n id={id}\n inputMode={pickerOnly ? undefined : 'numeric'}\n onChange={() => {}}\n onClick={(event) => {\n props.onClick?.(event)\n // picker-only: the value opens the calendar instead of taking a caret\n if (pickerOnly && !disabled && !event.defaultPrevented)\n setOpen(true)\n }}\n {...handlers}\n placeholder={placeholder ?? placeholderOf(separator, withTime)}\n readOnly={pickerOnly}\n ref={setInputRef}\n spellCheck={false}\n value={text}\n />\n <InputGroupAddon align=\"inline-end\">\n <PopoverTrigger\n render={\n <Button\n aria-label={calendarLabel}\n color=\"neutral\"\n disabled={disabled}\n size=\"icon-small\"\n styleVariant=\"ghost\"\n >\n <CalendarMonth />\n </Button>\n }\n />\n </InputGroupAddon>\n </InputGroup>\n </PopoverAnchor>\n {status}\n <PopoverContent\n align=\"start\"\n aria-label={calendarLabel}\n className=\"w-auto p-0\"\n collisionAvoidance={{ side: 'flip', fallbackAxisSide: 'none' }}\n container={container}\n >\n {/* a month or year list replaces the days, and the times step aside for it */}\n <div className=\"flex max-sm:flex-col has-[[data-slot=calendar-list]]:[&>[data-slot=input-date-times]]:hidden\">\n <Calendar\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- DayPicker prop: the picked day takes focus when the popup opens\n autoFocus\n {...calendarProps}\n mode=\"single\"\n month={calendarProps?.month ?? month}\n onMonthChange={(next) => {\n calendarProps?.onMonthChange?.(next)\n if (calendarProps?.month === undefined) setMonth(next)\n }}\n onSelect={(next) => {\n if (!withTime) {\n commit(next ? formatDateTime(next, separator) : '')\n setOpen(false)\n return\n }\n // a time is picked next, so the popup stays open\n if (next) commitDate(next, selectedTime ?? defaultTime)\n }}\n selected={selected}\n />\n {withTime && (\n <TimeList\n defaultTime={defaultTime}\n label={timeLabel}\n onPick={(time) => {\n commitDate(selected ?? getDefaultDate(), time)\n setOpen(false)\n inputRef.current?.focus()\n }}\n open={open}\n selectedTime={selectedTime}\n times={times}\n />\n )}\n </div>\n </PopoverContent>\n </Popover>\n )\n },\n)\n\nexport { InputDateTime }\nexport {\n dateTimeStatus,\n formatDateTime,\n parseDateTime,\n type DateTimeStatus,\n} from '../lib/date-time-mask'\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,SAAS,qBAAwB,EAC/B,aACA,UACA,QAKC;CACD,MAAM,CAAC,cAAc,mBAAmBA,MAAM,SAAS,WAAW;CAClE,MAAM,eAAe,SAAS,KAAA;CAW9B,OAAO,CAVO,eAAe,OAAO,cAEnBA,MAAM,aACpB,SAAY;EACX,IAAI,CAAC,cAAc,gBAAgB,IAAI;EACvC,WAAW,IAAI;CACjB,GACA,CAAC,cAAc,QAAQ,CAGH,CAAC;AACzB;AAEA,MAAM,8BAAc,IAAI,KAAK;AAE7B,MAAM,iBAAiB,WAAmB,aACxC,KAAK,UAAU,IAAI,UAAU,MAAM,WAAW,YAAY;;AAG5D,SAAS,sBAAsB,EAC7B,eACA,cAAc,OACd,eAAe,IACf,gBACA,cACA,cACA,eACA,MAAM,UACN,WACA,OACA,YAaC;CACD,MAAM,CAAC,MAAM,WAAW,qBAAqB;EAC3C,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CACD,MAAM,CAAC,MAAM,gBAAgB,qBAAqB;EAChD,aAAa;EACb,UAAU;EACV,MAAM;CACR,CAAC;CAED,MAAM,WAAWC,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import { PopoverContent } from "./popover.cjs";
|
|
5
|
+
import { DateTimeStatus, dateTimeStatus, formatDateTime, parseDateTime } from "../lib/date-time-mask.cjs";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/components/input-date-time.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* A date, or a date and a time (`withTime`), in one field with a calendar popup.
|
|
11
|
+
* Input Date's journey-grade sibling: the chosen day takes focus on open, Backspace
|
|
12
|
+
* after a separator deletes the digit before it, pastes go through the mask, and
|
|
13
|
+
* ignored keys can be read out.
|
|
14
|
+
*/
|
|
15
|
+
type InputDateTimeProps = Omit<React$1.ComponentProps<'input'>, 'children' | 'defaultValue' | 'onChange' | 'readOnly' | 'type' | 'value'> & {
|
|
16
|
+
calendarLabel: string;
|
|
17
|
+
calendarProps?: Omit<CalendarProps, 'mode' | 'onSelect' | 'selected'>; /** Element the calendar popup mounts into, e.g. the drawer it sits in. */
|
|
18
|
+
container?: React$1.ComponentProps<typeof PopoverContent>['container'];
|
|
19
|
+
defaultOpen?: boolean; /** `HH:MM` a day picked from the calendar gets while no time is set. */
|
|
20
|
+
defaultTime?: string;
|
|
21
|
+
defaultValue?: string; /** The day a time picked before any date applies to; today by default. */
|
|
22
|
+
getDefaultDate?: () => Date; /** The date, with its time when `withTime`; undefined until complete. */
|
|
23
|
+
onDateChange?: (date: Date | undefined) => void;
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
onValueChange?: (value: string) => void;
|
|
26
|
+
open?: boolean;
|
|
27
|
+
pickerOnly?: boolean; /** Read out politely when a key the field ignores is typed, e.g. "Only numbers are allowed". */
|
|
28
|
+
rejectedKeyMessage?: string;
|
|
29
|
+
separator?: string; /** Names the time list. */
|
|
30
|
+
timeLabel?: string; /** Minutes between the times offered; 30 by default, 5 at least. */
|
|
31
|
+
timeStep?: number;
|
|
32
|
+
value?: string; /** Adds `, HH:MM` to the field and a time list beside the calendar. */
|
|
33
|
+
withTime?: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare const InputDateTime: React$1.ForwardRefExoticComponent<Omit<InputDateTimeProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { type DateTimeStatus, InputDateTime, InputDateTimeProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
38
|
+
//# sourceMappingURL=input-date-time.d.cts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { CalendarProps } from "./calendar.js";
|
|
4
|
+
import { PopoverContent } from "./popover.js";
|
|
5
|
+
import { DateTimeStatus, dateTimeStatus, formatDateTime, parseDateTime } from "../lib/date-time-mask.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/components/input-date-time.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* A date, or a date and a time (`withTime`), in one field with a calendar popup.
|
|
11
|
+
* Input Date's journey-grade sibling: the chosen day takes focus on open, Backspace
|
|
12
|
+
* after a separator deletes the digit before it, pastes go through the mask, and
|
|
13
|
+
* ignored keys can be read out.
|
|
14
|
+
*/
|
|
15
|
+
type InputDateTimeProps = Omit<React$1.ComponentProps<'input'>, 'children' | 'defaultValue' | 'onChange' | 'readOnly' | 'type' | 'value'> & {
|
|
16
|
+
calendarLabel: string;
|
|
17
|
+
calendarProps?: Omit<CalendarProps, 'mode' | 'onSelect' | 'selected'>; /** Element the calendar popup mounts into, e.g. the drawer it sits in. */
|
|
18
|
+
container?: React$1.ComponentProps<typeof PopoverContent>['container'];
|
|
19
|
+
defaultOpen?: boolean; /** `HH:MM` a day picked from the calendar gets while no time is set. */
|
|
20
|
+
defaultTime?: string;
|
|
21
|
+
defaultValue?: string; /** The day a time picked before any date applies to; today by default. */
|
|
22
|
+
getDefaultDate?: () => Date; /** The date, with its time when `withTime`; undefined until complete. */
|
|
23
|
+
onDateChange?: (date: Date | undefined) => void;
|
|
24
|
+
onOpenChange?: (open: boolean) => void;
|
|
25
|
+
onValueChange?: (value: string) => void;
|
|
26
|
+
open?: boolean;
|
|
27
|
+
pickerOnly?: boolean; /** Read out politely when a key the field ignores is typed, e.g. "Only numbers are allowed". */
|
|
28
|
+
rejectedKeyMessage?: string;
|
|
29
|
+
separator?: string; /** Names the time list. */
|
|
30
|
+
timeLabel?: string; /** Minutes between the times offered; 30 by default, 5 at least. */
|
|
31
|
+
timeStep?: number;
|
|
32
|
+
value?: string; /** Adds `, HH:MM` to the field and a time list beside the calendar. */
|
|
33
|
+
withTime?: boolean;
|
|
34
|
+
};
|
|
35
|
+
declare const InputDateTime: React$1.ForwardRefExoticComponent<Omit<InputDateTimeProps, "ref"> & React$1.RefAttributes<HTMLInputElement>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { type DateTimeStatus, InputDateTime, InputDateTimeProps, dateTimeStatus, formatDateTime, parseDateTime };
|
|
38
|
+
//# sourceMappingURL=input-date-time.d.ts.map
|