@epilot/spark-ui 0.28.2 → 0.29.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/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/avatar.d.cts +1 -1
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/banner.d.cts +1 -1
- package/dist/components/box.d.cts +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button-group.d.cts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button.cjs +16 -16
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +4 -4
- package/dist/components/button.d.ts +4 -4
- package/dist/components/button.js +16 -16
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.d.cts +1 -1
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/card.d.cts +1 -1
- package/dist/components/card.d.ts +1 -1
- package/dist/components/checkbox-group.d.cts +1 -1
- package/dist/components/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/combobox.d.cts +1 -1
- package/dist/components/combobox.d.ts +1 -1
- package/dist/components/field.cjs +57 -16
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +8 -4
- package/dist/components/field.d.ts +8 -4
- package/dist/components/field.js +57 -16
- 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-group.cjs +71 -3
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +6 -1
- package/dist/components/input-group.d.ts +6 -1
- package/dist/components/input-group.js +72 -5
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.cjs +6 -3
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +7 -4
- package/dist/components/input.js.map +1 -1
- package/dist/components/list.d.cts +1 -1
- package/dist/components/list.d.ts +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/radio.d.cts +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +2 -1
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +3 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.cjs +15 -18
- package/dist/components/separator.cjs.map +1 -1
- package/dist/components/separator.d.cts +3 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +16 -19
- package/dist/components/separator.js.map +1 -1
- package/dist/components/skeleton.cjs +20 -5
- package/dist/components/skeleton.cjs.map +1 -1
- package/dist/components/skeleton.d.cts +9 -5
- package/dist/components/skeleton.d.ts +9 -5
- package/dist/components/skeleton.js +19 -6
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/spinner.cjs +8 -81
- package/dist/components/spinner.cjs.map +1 -1
- package/dist/components/spinner.js +8 -81
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/switch-group.d.cts +1 -1
- package/dist/components/switch-group.d.ts +1 -1
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/textarea.cjs +6 -3
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +6 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.d.cts +1 -1
- package/dist/components/theme.d.ts +1 -1
- package/dist/components/toggle-group.d.cts +1 -1
- package/dist/components/toggle-group.d.ts +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +1 -1
- package/dist/components/tooltip.cjs +29 -25
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.d.cts +4 -2
- package/dist/components/tooltip.d.ts +4 -2
- package/dist/components/tooltip.js +29 -25
- package/dist/components/tooltip.js.map +1 -1
- package/dist/lib/accent-theme.d.cts +1 -1
- package/dist/lib/accent-theme.d.ts +1 -1
- package/dist/lib/container-chrome.d.cts +1 -1
- package/dist/lib/container-chrome.d.ts +1 -1
- package/dist/lib/input-box-variants.cjs +11 -0
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +6 -2
- package/dist/lib/input-box-variants.d.ts +6 -2
- package/dist/lib/input-box-variants.js +8 -1
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/selection-list.d.cts +1 -1
- package/dist/lib/selection-list.d.ts +1 -1
- package/dist/lib/theme-types.cjs.map +1 -1
- package/dist/lib/theme-types.d.cts +1 -1
- package/dist/lib/theme-types.d.ts +1 -1
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/styles/spark-default.css +3 -1
- package/dist/styles/theme.css +18 -98
- package/dist/{theme-types-Dlge0s3s.d.ts → theme-types-CHl-L2F-.d.cts} +2 -2
- package/dist/{theme-types-Dlge0s3s.d.cts → theme-types-CHl-L2F-.d.ts} +2 -2
- package/package.json +3 -2
|
@@ -39,11 +39,12 @@ function SelectTrigger({ className, size = "default", variant, id: idProp, child
|
|
|
39
39
|
});
|
|
40
40
|
const inset = !variant && field?.labelPosition === "inset";
|
|
41
41
|
const isGhost = inputStyle === "ghost" || inset;
|
|
42
|
+
const floating = !variant && field?.labelPosition === "floating";
|
|
42
43
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_select.Select.Trigger, {
|
|
43
44
|
"data-slot": "select-trigger",
|
|
44
45
|
"data-size": size,
|
|
45
46
|
id,
|
|
46
|
-
className: (0, cn.cn)(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], require_lib_input_box_variants.boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", className),
|
|
47
|
+
className: (0, cn.cn)(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], require_lib_input_box_variants.boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && (0, cn.cn)(require_lib_input_box_variants.floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder"), className),
|
|
47
48
|
"aria-invalid": ariaInvalid,
|
|
48
49
|
...props,
|
|
49
50
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.cjs","names":["SelectPrimitive","useFieldControl","boxChrome","KeyboardArrowDown","Close","PortalTheme","Check"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } 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 { useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `min-h-[2.75rem]` is a literal, non-knob-scaled WCAG 2.5.5\n// floor; `sm` stays visually compact but restores the floor via an invisible\n// `before:` hit overlay rather than growing the box, with `my-1` to keep that\n// overlay out of an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11 min-h-[2.75rem]',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\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 // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\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 transition-colors hover:text-gray 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\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate z-50 max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-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 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-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\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,SAASA,sBAAAA,OAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;E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Control","boxChrome","floatingChrome","KeyboardArrowDown","Close","PortalTheme","Check"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { boxChrome, floatingChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `min-h-[2.75rem]` is a literal, non-knob-scaled WCAG 2.5.5\n// floor; `sm` stays visually compact but restores the floor via an invisible\n// `before:` hit overlay rather than growing the box, with `my-1` to keep that\n// overlay out of an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11 min-h-[2.75rem]',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\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 // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n const floating = !variant && field?.labelPosition === 'floating'\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n floating &&\n cn(\n floatingChrome(inputStyle),\n inputStyle !== 'outlined' &&\n '[&_[data-slot=select-chevron]]:-translate-y-2',\n 'data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder',\n ),\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\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 transition-colors hover:text-gray 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\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate z-50 max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-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 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-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\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,SAASA,sBAAAA,OAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IAAc,mBAAmB,SAAS;EAC1C,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EACnB,GAAG,SACkD;CACrD,OAAO,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;EAAuB,aAAU;EAAe,GAAI;CAAQ,CAAA;AACrE;AAEA,MAAM,eACJ;AAQF,MAAM,eAAe;CACnB,SAAS;CACT,IAAI;AACN;AAEA,SAAS,cAAc,EACrB,WACA,OAAO,WACP,SACA,IAAI,QACJ,UACA,oBAAoB,qBACpB,GAAG,SAKF;CACD,MAAM,EAAE,OAAO,IAAI,iBAAiB,aAAa,YAAY,eAC3DC,yBAAAA,gBAAgB;EACd,IAAI;EACJ,iBAAiB;EACjB;CACF,CAAC;CAIH,MAAM,QA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N,iBAAA,GAAA,kBAAA,KAACP,sBAAAA,OAAgB,UAAjB,EAA2B,SAAmC,CAAA,CAC1C;;AAE1B;AAKA,SAAS,gBAAgB,EAAE,WAAW,GAAG,SAAsC;CAC7E,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,eAAY;EACZ,aAAU;EACV,YAAA,GAAA,GAAA,IACE,sFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,qBAAqB,EAC5B,WACA,GAAG,SAC0D;CAC7D,OACE,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,eAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IACE,sIACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACI,oBAAAA,mBAAD,EAAmB,WAAU,sCAAuC,CAAA;CACvC,CAAA;AAEnC;AAEA,SAAS,uBAAuB,EAC9B,WACA,GAAG,SAC4D;CAC/D,OACE,iBAAA,GAAA,kBAAA,KAACJ,sBAAAA,OAAgB,iBAAjB;EACE,aAAU;EACV,YAAA,GAAA,GAAA,IACE,yIACA,SACF;EACA,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACI,oBAAAA,mBAAD,EAAmB,WAAU,2BAA4B,CAAA;CAC1B,CAAA;AAErC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import { cn } from "../utils/cn.js";
|
|
4
|
-
import { boxChrome } from "../lib/input-box-variants.js";
|
|
4
|
+
import { boxChrome, floatingChrome } from "../lib/input-box-variants.js";
|
|
5
5
|
import { PortalTheme } from "./theme.js";
|
|
6
6
|
import { useFieldControl } from "./field.js";
|
|
7
7
|
import "react";
|
|
@@ -36,11 +36,12 @@ function SelectTrigger({ className, size = "default", variant, id: idProp, child
|
|
|
36
36
|
});
|
|
37
37
|
const inset = !variant && field?.labelPosition === "inset";
|
|
38
38
|
const isGhost = inputStyle === "ghost" || inset;
|
|
39
|
+
const floating = !variant && field?.labelPosition === "floating";
|
|
39
40
|
return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
40
41
|
"data-slot": "select-trigger",
|
|
41
42
|
"data-size": size,
|
|
42
43
|
id,
|
|
43
|
-
className: cn(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", className),
|
|
44
|
+
className: cn(TRIGGER_BASE, field ? "w-full" : "w-fit", !isGhost && TRIGGER_SIZE[size], boxChrome[isGhost ? "ghost" : inputStyle][inputColor], inset && "focus-visible:outline-hidden", floating && cn(floatingChrome(inputStyle), inputStyle !== "outlined" && "[&_[data-slot=select-chevron]]:-translate-y-2", "data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder"), className),
|
|
44
45
|
"aria-invalid": ariaInvalid,
|
|
45
46
|
...props,
|
|
46
47
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":["SelectPrimitive"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } 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 { useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `min-h-[2.75rem]` is a literal, non-knob-scaled WCAG 2.5.5\n// floor; `sm` stays visually compact but restores the floor via an invisible\n// `before:` hit overlay rather than growing the box, with `my-1` to keep that\n// overlay out of an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11 min-h-[2.75rem]',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\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 // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\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 transition-colors hover:text-gray 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\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate z-50 max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-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 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-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\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,SAASA,SAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,oBAACA,SAAgB,OAAjB;EACE,aAAU;EACV,WAAW,GAAG,mBAAmB,SAAS;EAC1C,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EACnB,GAAG,SAC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,GACT,sIACA,SACF;EACA,GAAI;YAEJ,oBAAC,mBAAD,EAAmB,WAAU,sCAAuC,CAAA;CACvC,CAAA;AAEnC;AAEA,SAAS,uBAAuB,EAC9B,WACA,GAAG,SAC4D;CAC/D,OACE,oBAACA,SAAgB,iBAAjB;EACE,aAAU;EACV,WAAW,GACT,yIACA,SACF;EACA,GAAI;YAEJ,oBAAC,mBAAD,EAAmB,WAAU,2BAA4B,CAAA;CAC1B,CAAA;AAErC"}
|
|
1
|
+
{"version":3,"file":"select.js","names":["SelectPrimitive"],"sources":["../../src/components/select.tsx"],"sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { Check, Close, KeyboardArrowDown } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { boxChrome, floatingChrome } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\nimport { PortalTheme } from './theme'\n\n// bare re-export: Root renders no element and its props are generic over Value\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Group>) {\n return (\n <SelectPrimitive.Group\n data-slot=\"select-group\"\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Value>) {\n return <SelectPrimitive.Value data-slot=\"select-value\" {...props} />\n}\n\nconst TRIGGER_BASE =\n 'relative flex items-center justify-between gap-1.5 rounded-md px-3 text-base whitespace-nowrap text-gray transition-colors select-none data-placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:data-placeholder:text-gray-disabled *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4'\n\n// box-chrome sizing only — a ghost/inset trigger sizes via boxChrome.ghost's\n// GHOST_UNDERLINE (h-10), matching Input's underline row exactly (no competing\n// height utility). `min-h-[2.75rem]` is a literal, non-knob-scaled WCAG 2.5.5\n// floor; `sm` stays visually compact but restores the floor via an invisible\n// `before:` hit overlay rather than growing the box, with `my-1` to keep that\n// overlay out of an ancestor scroller's overflow.\nconst TRIGGER_SIZE = {\n default: 'h-11 min-h-[2.75rem]',\n sm: \"my-1 h-9 before:absolute before:inset-x-0 before:top-1/2 before:min-h-[2.75rem] before:-translate-y-1/2 before:content-['']\",\n} as const\n\nfunction SelectTrigger({\n className,\n size = 'default',\n variant,\n id: idProp,\n children,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {\n size?: 'sm' | 'default'\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 // inside an inset field the shell is the box, so the trigger goes bare\n // (underline row), matching Input's inset chrome; an explicit variant keeps\n // the box even inside an inset field (mirrors Input)\n const inset = !variant && field?.labelPosition === 'inset'\n const isGhost = inputStyle === 'ghost' || inset\n const floating = !variant && field?.labelPosition === 'floating'\n\n return (\n <SelectPrimitive.Trigger\n data-slot=\"select-trigger\"\n data-size={size}\n id={id}\n className={cn(\n TRIGGER_BASE,\n // fills the field shell like an Input; sizes to content when standalone\n field ? 'w-full' : 'w-fit',\n !isGhost && TRIGGER_SIZE[size],\n boxChrome[isGhost ? 'ghost' : inputStyle][inputColor],\n inset && 'focus-visible:outline-hidden',\n floating &&\n cn(\n floatingChrome(inputStyle),\n inputStyle !== 'outlined' &&\n '[&_[data-slot=select-chevron]]:-translate-y-2',\n 'data-placeholder:text-transparent data-placeholder:focus-visible:text-gray-placeholder data-popup-open:text-gray-placeholder',\n ),\n className,\n )}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n >\n {children}\n <SelectPrimitive.Icon\n className=\"pointer-events-none flex text-gray-light\"\n data-slot=\"select-chevron\"\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n )\n}\n\n// px floor: axe target-size flags it below 24px at small scalings because it overlays\n// the trigger; autocomplete.tsx ICON_BUTTON sits in flow and does not need one\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 transition-colors hover:text-gray 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\n// wraps SelectTrigger since Base UI ships no Select.Clear and the trigger is a\n// native <button> — the clear sits beside it, not nested inside it\nfunction SelectTriggerGroup({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"select-trigger-group\"\n className={cn(\n 'relative inline-flex w-fit items-center [&_[data-slot=select-chevron]]:absolute [&_[data-slot=select-chevron]]:right-3 has-[[data-slot=select-trigger][data-disabled]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-placeholder]]:[&_[data-slot=select-clear]]:hidden has-[[data-slot=select-trigger][data-readonly]]:[&_[data-slot=select-clear]]:hidden [&_[data-slot=select-trigger]]:pr-[calc(--spacing(8)+max(--spacing(6),24px))]',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectClear({\n className,\n children,\n onClick,\n ...props\n}: React.ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"select-clear\"\n type=\"button\"\n className={cn(CLEAR_BUTTON, 'absolute right-8', className)}\n onClick={(event) => {\n onClick?.(event)\n // clearing hides this button (data-placeholder returns), so keyboard\n // focus would otherwise drop to <body> — return it to the trigger\n event.currentTarget\n .closest('[data-slot=\"select-trigger-group\"]')\n ?.querySelector<HTMLElement>('[data-slot=\"select-trigger\"]')\n ?.focus()\n }}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </button>\n )\n}\n\ntype SelectContentProps = React.ComponentProps<typeof SelectPrimitive.Popup> &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n > &\n Pick<SelectPrimitive.Portal.Props, 'container'>\n\nfunction SelectContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n // drop the menu below the trigger (left-aligned) like a conventional form\n // dropdown; the native-<select>-style overlay (Base UI's inherited default)\n // shifts the popup to align item text with trigger text, exposing a sliver of\n // the trigger's fill at the edge. Opt back in per instance if you want it.\n alignItemWithTrigger = false,\n container,\n ...props\n}: SelectContentProps) {\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme>\n <SelectPrimitive.Positioner\n align={align}\n alignItemWithTrigger={alignItemWithTrigger}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <SelectPrimitive.Popup\n data-slot=\"select-content\"\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n // match the trigger's width (never narrower) so the drop-below menu\n // lines up under it; --anchor-width is the trigger width, floored at\n // 9rem for very narrow triggers\n 'relative isolate z-50 max-h-(--available-height) min-w-[max(9rem,var(--anchor-width))] origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-gray-a1 bg-gray-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 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n 'data-[align-trigger=true]:transition-none',\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalTheme>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot=\"select-label\"\n className={cn(\n 'px-1.5 py-1 text-xs text-gray-light [[data-high-contrast]_&]:text-gray-a12',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction SelectItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.Item>) {\n return (\n <SelectPrimitive.Item\n data-slot=\"select-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm py-1.5 pr-8 pl-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 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2',\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute right-2 flex size-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"[--spark-icon-size:11px]\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n )\n}\n\n// plain div, not Select.Separator: role=\"separator\" isn't a permitted child of a\n// listbox (aria-required-children), and the divider is decorative — the groups\n// carry the semantics. Hidden from assistive tech.\nfunction SelectSeparator({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"select-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\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot=\"select-scroll-up-button\"\n className={cn(\n 'top-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"rotate-180 [--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot=\"select-scroll-down-button\"\n className={cn(\n 'bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-gray-1 py-1 dark:bg-gray-3 [&_svg:not([class*=size-])]:size-4',\n className,\n )}\n {...props}\n >\n <KeyboardArrowDown className=\"[--spark-icon-size:14px]\" />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectClear,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n SelectTriggerGroup,\n SelectValue,\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,SAASA,SAAgB;AAE/B,SAAS,YAAY,EACnB,WACA,GAAG,SACkD;CACrD,OACE,oBAACA,SAAgB,OAAjB;EACE,aAAU;EACV,WAAW,GAAG,mBAAmB,SAAS;EAC1C,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,YAAY,EACnB,GAAG,SACkD;CACrD,OAAO,oBAACA,SAAgB,OAAjB;EAAuB,aAAU;EAAe,GAAI;CAAQ,CAAA;AACrE;AAEA,MAAM,eACJ;AAQF,MAAM,eAAe;CACnB,SAAS;CACT,IAAI;AACN;AAEA,SA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AmB,WAAU,sCAAuC,CAAA;CACvC,CAAA;AAEnC;AAEA,SAAS,uBAAuB,EAC9B,WACA,GAAG,SAC4D;CAC/D,OACE,oBAACA,SAAgB,iBAAjB;EACE,aAAU;EACV,WAAW,GACT,yIACA,SACF;EACA,GAAI;YAEJ,oBAAC,mBAAD,EAAmB,WAAU,2BAA4B,CAAA;CAC1B,CAAA;AAErC"}
|
|
@@ -4,6 +4,7 @@ const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
|
4
4
|
let react = require("react");
|
|
5
5
|
react = require_chunk.__toESM(react);
|
|
6
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
7
8
|
let cn = require("cn");
|
|
8
9
|
//#region src/components/separator.tsx
|
|
9
10
|
const dots = "bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted";
|
|
@@ -19,34 +20,30 @@ const plainLine = {
|
|
|
19
20
|
vertical: `h-full ${dottedVertical}`
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
const Separator = react.forwardRef(({ className, orientation = "horizontal", decorative, variant = "solid", children, ...props }, ref) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const Separator = react.forwardRef(({ className, orientation = "horizontal", decorative, variant = "solid", children, render, ...props }, ref) => {
|
|
24
|
+
const hasLabel = children != null && children !== false && children !== "";
|
|
25
|
+
const isDecorative = decorative ?? !hasLabel;
|
|
26
|
+
const labelLine = variant === "dotted" ? (0, cn.cn)("flex-1", dottedHorizontal) : "h-px flex-1 border-t border-gray";
|
|
27
|
+
return (0, _base_ui_react_use_render.useRender)({
|
|
28
|
+
defaultTagName: "div",
|
|
29
|
+
ref,
|
|
30
|
+
render: hasLabel ? void 0 : render,
|
|
31
|
+
props: {
|
|
32
|
+
className: hasLabel ? (0, cn.cn)("flex items-center gap-4", className) : (0, cn.cn)("shrink-0", plainLine[variant][orientation], className),
|
|
28
33
|
"data-orientation": orientation,
|
|
29
34
|
"data-variant": variant,
|
|
30
|
-
ref,
|
|
31
35
|
role: isDecorative ? "none" : "separator",
|
|
36
|
+
"aria-orientation": isDecorative || orientation === "horizontal" ? void 0 : orientation,
|
|
32
37
|
...props,
|
|
33
|
-
children: [
|
|
38
|
+
children: hasLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
34
39
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: labelLine }),
|
|
35
40
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
36
41
|
className: "shrink-0 text-sm text-gray-light",
|
|
37
42
|
children
|
|
38
43
|
}),
|
|
39
44
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: labelLine })
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
44
|
-
className: (0, cn.cn)("shrink-0", plainLine[variant][orientation], className),
|
|
45
|
-
"data-orientation": orientation,
|
|
46
|
-
"data-variant": variant,
|
|
47
|
-
ref,
|
|
48
|
-
role: isDecorative ? "none" : "separator",
|
|
49
|
-
...props
|
|
45
|
+
] }) : void 0
|
|
46
|
+
}
|
|
50
47
|
});
|
|
51
48
|
});
|
|
52
49
|
Separator.displayName = "Separator";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.cjs","names":["React"],"sources":["../../src/components/separator.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical'\n decorative?: boolean\n variant?: 'solid' | 'dotted'\n}\n\n// A gradient, not border-dotted: its 1px dots touch and read as a solid line.\n// Forced colors drops background images, so fall back to a dotted border there.\n// a8, not border-gray's a6: sparse dots read lighter than a solid line.\nconst dots =\n 'bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted'\nconst dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`\nconst dottedVertical = `w-[2px] bg-size-[2px_6px] forced-colors:border-l ${dots}`\n\nconst plainLine = {\n solid: {\n horizontal: 'border-gray h-px w-full border-t',\n vertical: 'border-gray h-full w-px border-l',\n },\n dotted: {\n horizontal: `w-full ${dottedHorizontal}`,\n vertical: `h-full ${dottedVertical}`,\n },\n}\n\nconst Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(\n (\n {\n className,\n orientation = 'horizontal',\n decorative,\n variant = 'solid',\n children,\n ...props\n },\n ref,\n ) => {\n // A labeled divider (e.g. \"OR\") conveys meaning, so default it to\n // role=\"separator\" unless the caller opts back into decorative.\n const isDecorative = decorative ?? !
|
|
1
|
+
{"version":3,"file":"separator.cjs","names":["React"],"sources":["../../src/components/separator.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical'\n decorative?: boolean\n variant?: 'solid' | 'dotted'\n /** Replaces the rendered `div`, e.g. `<hr />` for a semantic line. */\n render?: useRender.RenderProp\n}\n\n// A gradient, not border-dotted: its 1px dots touch and read as a solid line.\n// Forced colors drops background images, so fall back to a dotted border there.\n// a8, not border-gray's a6: sparse dots read lighter than a solid line.\nconst dots =\n 'bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted'\nconst dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`\nconst dottedVertical = `w-[2px] bg-size-[2px_6px] forced-colors:border-l ${dots}`\n\nconst plainLine = {\n solid: {\n horizontal: 'border-gray h-px w-full border-t',\n vertical: 'border-gray h-full w-px border-l',\n },\n dotted: {\n horizontal: `w-full ${dottedHorizontal}`,\n vertical: `h-full ${dottedVertical}`,\n },\n}\n\nconst Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(\n (\n {\n className,\n orientation = 'horizontal',\n decorative,\n variant = 'solid',\n children,\n render,\n ...props\n },\n ref,\n ) => {\n const hasLabel = children != null && children !== false && children !== ''\n // A labeled divider (e.g. \"OR\") conveys meaning, so default it to\n // role=\"separator\" unless the caller opts back into decorative.\n const isDecorative = decorative ?? !hasLabel\n const labelLine =\n variant === 'dotted'\n ? cn('flex-1', dottedHorizontal)\n : 'h-px flex-1 border-t border-gray'\n\n return useRender({\n defaultTagName: 'div',\n ref,\n // a labeled divider holds children, which a void element like <hr> can't\n render: hasLabel ? undefined : render,\n props: {\n className: hasLabel\n ? cn('flex items-center gap-4', className)\n : cn('shrink-0', plainLine[variant][orientation], className),\n 'data-orientation': orientation,\n 'data-variant': variant,\n role: isDecorative ? 'none' : 'separator',\n // role=\"separator\" defaults to horizontal, so a vertical one says so\n 'aria-orientation':\n isDecorative || orientation === 'horizontal'\n ? undefined\n : orientation,\n ...props,\n children: hasLabel ? (\n <>\n <div className={labelLine} />\n <span className=\"shrink-0 text-sm text-gray-light\">{children}</span>\n <div className={labelLine} />\n </>\n ) : undefined,\n },\n })\n },\n)\n\nSeparator.displayName = 'Separator'\n\nexport { Separator }\nexport type { SeparatorProps }\n"],"mappings":";;;;;;;;;AAeA,MAAM,OACJ;AACF,MAAM,mBAAmB,oDAAoD;AAC7E,MAAM,iBAAiB,oDAAoD;AAE3E,MAAM,YAAY;CAChB,OAAO;EACL,YAAY;EACZ,UAAU;CACZ;CACA,QAAQ;EACN,YAAY,UAAU;EACtB,UAAU,UAAU;CACtB;AACF;AAEA,MAAM,YAAYA,MAAM,YAEpB,EACE,WACA,cAAc,cACd,YACA,UAAU,SACV,UACA,QACA,GAAG,SAEL,QACG;CACH,MAAM,WAAW,YAAY,QAAQ,aAAa,SAAS,aAAa;CAGxE,MAAM,eAAe,cAAc,CAAC;CACpC,MAAM,YACJ,YAAY,YAAA,GAAA,GAAA,IACL,UAAU,gBAAgB,IAC7B;CAEN,QAAA,GAAA,0BAAA,WAAiB;EACf,gBAAgB;EAChB;EAEA,QAAQ,WAAW,KAAA,IAAY;EAC/B,OAAO;GACL,WAAW,YAAA,GAAA,GAAA,IACJ,2BAA2B,SAAS,KAAA,GAAA,GAAA,IACpC,YAAY,UAAU,SAAS,cAAc,SAAS;GAC7D,oBAAoB;GACpB,gBAAgB;GAChB,MAAM,eAAe,SAAS;GAE9B,oBACE,gBAAgB,gBAAgB,eAC5B,KAAA,IACA;GACN,GAAG;GACH,UAAU,WACR,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA;IACE,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAK,WAAW,UAAY,CAAA;IAC5B,iBAAA,GAAA,kBAAA,KAAC,QAAD;KAAM,WAAU;KAAoC;IAAe,CAAA;IACnE,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAK,WAAW,UAAY,CAAA;GAC5B,EAAA,CAAA,IACA,KAAA;EACN;CACF,CAAC;AACH,CACF;AAEA,UAAU,cAAc"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
5
|
|
|
5
6
|
//#region src/components/separator.d.ts
|
|
6
7
|
interface SeparatorProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
7
8
|
orientation?: 'horizontal' | 'vertical';
|
|
8
9
|
decorative?: boolean;
|
|
9
10
|
variant?: 'solid' | 'dotted';
|
|
11
|
+
/** Replaces the rendered `div`, e.g. `<hr />` for a semantic line. */
|
|
12
|
+
render?: useRender.RenderProp;
|
|
10
13
|
}
|
|
11
14
|
declare const Separator: React$1.ForwardRefExoticComponent<SeparatorProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
12
15
|
//#endregion
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React$1 from "react";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
5
|
|
|
5
6
|
//#region src/components/separator.d.ts
|
|
6
7
|
interface SeparatorProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
7
8
|
orientation?: 'horizontal' | 'vertical';
|
|
8
9
|
decorative?: boolean;
|
|
9
10
|
variant?: 'solid' | 'dotted';
|
|
11
|
+
/** Replaces the rendered `div`, e.g. `<hr />` for a semantic line. */
|
|
12
|
+
render?: useRender.RenderProp;
|
|
10
13
|
}
|
|
11
14
|
declare const Separator: React$1.ForwardRefExoticComponent<SeparatorProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
12
15
|
//#endregion
|
|
@@ -1,7 +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, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
6
|
//#region src/components/separator.tsx
|
|
6
7
|
const dots = "bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted";
|
|
7
8
|
const dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`;
|
|
@@ -16,34 +17,30 @@ const plainLine = {
|
|
|
16
17
|
vertical: `h-full ${dottedVertical}`
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
|
-
const Separator = React$1.forwardRef(({ className, orientation = "horizontal", decorative, variant = "solid", children, ...props }, ref) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const Separator = React$1.forwardRef(({ className, orientation = "horizontal", decorative, variant = "solid", children, render, ...props }, ref) => {
|
|
21
|
+
const hasLabel = children != null && children !== false && children !== "";
|
|
22
|
+
const isDecorative = decorative ?? !hasLabel;
|
|
23
|
+
const labelLine = variant === "dotted" ? cn("flex-1", dottedHorizontal) : "h-px flex-1 border-t border-gray";
|
|
24
|
+
return useRender({
|
|
25
|
+
defaultTagName: "div",
|
|
26
|
+
ref,
|
|
27
|
+
render: hasLabel ? void 0 : render,
|
|
28
|
+
props: {
|
|
29
|
+
className: hasLabel ? cn("flex items-center gap-4", className) : cn("shrink-0", plainLine[variant][orientation], className),
|
|
25
30
|
"data-orientation": orientation,
|
|
26
31
|
"data-variant": variant,
|
|
27
|
-
ref,
|
|
28
32
|
role: isDecorative ? "none" : "separator",
|
|
33
|
+
"aria-orientation": isDecorative || orientation === "horizontal" ? void 0 : orientation,
|
|
29
34
|
...props,
|
|
30
|
-
children: [
|
|
35
|
+
children: hasLabel ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
36
|
/* @__PURE__ */ jsx("div", { className: labelLine }),
|
|
32
37
|
/* @__PURE__ */ jsx("span", {
|
|
33
38
|
className: "shrink-0 text-sm text-gray-light",
|
|
34
39
|
children
|
|
35
40
|
}),
|
|
36
41
|
/* @__PURE__ */ jsx("div", { className: labelLine })
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return /* @__PURE__ */ jsx("div", {
|
|
41
|
-
className: cn("shrink-0", plainLine[variant][orientation], className),
|
|
42
|
-
"data-orientation": orientation,
|
|
43
|
-
"data-variant": variant,
|
|
44
|
-
ref,
|
|
45
|
-
role: isDecorative ? "none" : "separator",
|
|
46
|
-
...props
|
|
42
|
+
] }) : void 0
|
|
43
|
+
}
|
|
47
44
|
});
|
|
48
45
|
});
|
|
49
46
|
Separator.displayName = "Separator";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.js","names":["React"],"sources":["../../src/components/separator.tsx"],"sourcesContent":["import * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical'\n decorative?: boolean\n variant?: 'solid' | 'dotted'\n}\n\n// A gradient, not border-dotted: its 1px dots touch and read as a solid line.\n// Forced colors drops background images, so fall back to a dotted border there.\n// a8, not border-gray's a6: sparse dots read lighter than a solid line.\nconst dots =\n 'bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted'\nconst dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`\nconst dottedVertical = `w-[2px] bg-size-[2px_6px] forced-colors:border-l ${dots}`\n\nconst plainLine = {\n solid: {\n horizontal: 'border-gray h-px w-full border-t',\n vertical: 'border-gray h-full w-px border-l',\n },\n dotted: {\n horizontal: `w-full ${dottedHorizontal}`,\n vertical: `h-full ${dottedVertical}`,\n },\n}\n\nconst Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(\n (\n {\n className,\n orientation = 'horizontal',\n decorative,\n variant = 'solid',\n children,\n ...props\n },\n ref,\n ) => {\n // A labeled divider (e.g. \"OR\") conveys meaning, so default it to\n // role=\"separator\" unless the caller opts back into decorative.\n const isDecorative = decorative ?? !
|
|
1
|
+
{"version":3,"file":"separator.js","names":["React"],"sources":["../../src/components/separator.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical'\n decorative?: boolean\n variant?: 'solid' | 'dotted'\n /** Replaces the rendered `div`, e.g. `<hr />` for a semantic line. */\n render?: useRender.RenderProp\n}\n\n// A gradient, not border-dotted: its 1px dots touch and read as a solid line.\n// Forced colors drops background images, so fall back to a dotted border there.\n// a8, not border-gray's a6: sparse dots read lighter than a solid line.\nconst dots =\n 'bg-[radial-gradient(circle_closest-side,var(--neutral-a8)_98%,transparent)] bg-repeat-space forced-colors:bg-none forced-colors:border-dotted'\nconst dottedHorizontal = `h-[2px] bg-size-[6px_2px] forced-colors:border-t ${dots}`\nconst dottedVertical = `w-[2px] bg-size-[2px_6px] forced-colors:border-l ${dots}`\n\nconst plainLine = {\n solid: {\n horizontal: 'border-gray h-px w-full border-t',\n vertical: 'border-gray h-full w-px border-l',\n },\n dotted: {\n horizontal: `w-full ${dottedHorizontal}`,\n vertical: `h-full ${dottedVertical}`,\n },\n}\n\nconst Separator = React.forwardRef<HTMLDivElement, SeparatorProps>(\n (\n {\n className,\n orientation = 'horizontal',\n decorative,\n variant = 'solid',\n children,\n render,\n ...props\n },\n ref,\n ) => {\n const hasLabel = children != null && children !== false && children !== ''\n // A labeled divider (e.g. \"OR\") conveys meaning, so default it to\n // role=\"separator\" unless the caller opts back into decorative.\n const isDecorative = decorative ?? !hasLabel\n const labelLine =\n variant === 'dotted'\n ? cn('flex-1', dottedHorizontal)\n : 'h-px flex-1 border-t border-gray'\n\n return useRender({\n defaultTagName: 'div',\n ref,\n // a labeled divider holds children, which a void element like <hr> can't\n render: hasLabel ? undefined : render,\n props: {\n className: hasLabel\n ? cn('flex items-center gap-4', className)\n : cn('shrink-0', plainLine[variant][orientation], className),\n 'data-orientation': orientation,\n 'data-variant': variant,\n role: isDecorative ? 'none' : 'separator',\n // role=\"separator\" defaults to horizontal, so a vertical one says so\n 'aria-orientation':\n isDecorative || orientation === 'horizontal'\n ? undefined\n : orientation,\n ...props,\n children: hasLabel ? (\n <>\n <div className={labelLine} />\n <span className=\"shrink-0 text-sm text-gray-light\">{children}</span>\n <div className={labelLine} />\n </>\n ) : undefined,\n },\n })\n },\n)\n\nSeparator.displayName = 'Separator'\n\nexport { Separator }\nexport type { SeparatorProps }\n"],"mappings":";;;;;;AAeA,MAAM,OACJ;AACF,MAAM,mBAAmB,oDAAoD;AAC7E,MAAM,iBAAiB,oDAAoD;AAE3E,MAAM,YAAY;CAChB,OAAO;EACL,YAAY;EACZ,UAAU;CACZ;CACA,QAAQ;EACN,YAAY,UAAU;EACtB,UAAU,UAAU;CACtB;AACF;AAEA,MAAM,YAAYA,QAAM,YAEpB,EACE,WACA,cAAc,cACd,YACA,UAAU,SACV,UACA,QACA,GAAG,SAEL,QACG;CACH,MAAM,WAAW,YAAY,QAAQ,aAAa,SAAS,aAAa;CAGxE,MAAM,eAAe,cAAc,CAAC;CACpC,MAAM,YACJ,YAAY,WACR,GAAG,UAAU,gBAAgB,IAC7B;CAEN,OAAO,UAAU;EACf,gBAAgB;EAChB;EAEA,QAAQ,WAAW,KAAA,IAAY;EAC/B,OAAO;GACL,WAAW,WACP,GAAG,2BAA2B,SAAS,IACvC,GAAG,YAAY,UAAU,SAAS,cAAc,SAAS;GAC7D,oBAAoB;GACpB,gBAAgB;GAChB,MAAM,eAAe,SAAS;GAE9B,oBACE,gBAAgB,gBAAgB,eAC5B,KAAA,IACA;GACN,GAAG;GACH,UAAU,WACR,qBAAA,UAAA,EAAA,UAAA;IACE,oBAAC,OAAD,EAAK,WAAW,UAAY,CAAA;IAC5B,oBAAC,QAAD;KAAM,WAAU;KAAoC;IAAe,CAAA;IACnE,oBAAC,OAAD,EAAK,WAAW,UAAY,CAAA;GAC5B,EAAA,CAAA,IACA,KAAA;EACN;CACF,CAAC;AACH,CACF;AAEA,UAAU,cAAc"}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_chunk = require("../chunk-DY84GLCh.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_chunk.__toESM(react);
|
|
3
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
4
8
|
let cn = require("cn");
|
|
5
9
|
//#region src/components/skeleton.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
const Skeleton = react.forwardRef(({ className, render, loading = true, children, ...props }, ref) => {
|
|
11
|
+
const hasElement = loading || render != null;
|
|
12
|
+
const element = (0, _base_ui_react_use_render.useRender)({
|
|
13
|
+
defaultTagName: "div",
|
|
14
|
+
enabled: hasElement,
|
|
15
|
+
ref,
|
|
16
|
+
render,
|
|
17
|
+
props: {
|
|
18
|
+
"data-slot": loading ? "skeleton" : void 0,
|
|
19
|
+
className: loading ? (0, cn.cn)("animate-pulse rounded-md bg-(--spark-skeleton-bg,var(--neutral-a3)) motion-reduce:animate-none", className) : className,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}
|
|
10
23
|
});
|
|
11
|
-
}
|
|
24
|
+
return hasElement ? element : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children });
|
|
25
|
+
});
|
|
26
|
+
Skeleton.displayName = "Skeleton";
|
|
12
27
|
function CardSkeleton({ children, className = "", padding = "p-4", ...props }) {
|
|
13
28
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14
29
|
className: (0, cn.cn)("flex flex-col rounded-lg border border-gray", padding, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.cjs","names":[],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\
|
|
1
|
+
{"version":3,"file":"skeleton.cjs","names":["React"],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SkeletonProps extends HTMLAttributes<HTMLElement> {\n /** Replaces the rendered `div`; an element keeps its own children and takes the skeleton look. */\n render?: useRender.RenderProp\n /** When `false`, the `render` output (or the bare `children`) shows without the skeleton look. */\n loading?: boolean\n}\n\nexport const Skeleton = React.forwardRef<HTMLElement, SkeletonProps>(\n ({ className, render, loading = true, children, ...props }, ref) => {\n const hasElement = loading || render != null\n const element = useRender({\n defaultTagName: 'div',\n enabled: hasElement,\n ref,\n render,\n props: {\n 'data-slot': loading ? 'skeleton' : undefined,\n // props and the ref stay on the element either way; only the look follows loading\n className: loading\n ? cn(\n 'animate-pulse rounded-md bg-(--spark-skeleton-bg,var(--neutral-a3)) motion-reduce:animate-none',\n className,\n )\n : className,\n children,\n ...props,\n },\n })\n\n return hasElement ? element : <>{children}</>\n },\n)\n\nSkeleton.displayName = 'Skeleton'\n\ninterface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode\n padding?: 'p-3' | 'p-4'\n}\n\nexport function CardSkeleton({\n children,\n className = '',\n padding = 'p-4',\n ...props\n}: CardSkeletonProps) {\n return (\n <div\n className={cn(\n 'flex flex-col rounded-lg border border-gray',\n padding,\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;AAYA,MAAa,WAAWA,MAAM,YAC3B,EAAE,WAAW,QAAQ,UAAU,MAAM,UAAU,GAAG,SAAS,QAAQ;CAClE,MAAM,aAAa,WAAW,UAAU;CACxC,MAAM,WAAA,GAAA,0BAAA,WAAoB;EACxB,gBAAgB;EAChB,SAAS;EACT;EACA;EACA,OAAO;GACL,aAAa,UAAU,aAAa,KAAA;GAEpC,WAAW,WAAA,GAAA,GAAA,IAEL,kGACA,SACF,IACA;GACJ;GACA,GAAG;EACL;CACF,CAAC;CAED,OAAO,aAAa,UAAU,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAG,SAAW,CAAA;AAC9C,CACF;AAEA,SAAS,cAAc;AAOvB,SAAgB,aAAa,EAC3B,UACA,YAAY,IACZ,UAAU,OACV,GAAG,SACiB;CACpB,OACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,YAAA,GAAA,GAAA,IACE,+CACA,SACA,SACF;EACA,GAAI;EAEH;CACE,CAAA;AAET"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import * as React$1 from "react";
|
|
3
4
|
import { HTMLAttributes, ReactNode } from "react";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
6
|
|
|
5
7
|
//#region src/components/skeleton.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
interface SkeletonProps extends HTMLAttributes<HTMLElement> {
|
|
9
|
+
/** Replaces the rendered `div`; an element keeps its own children and takes the skeleton look. */
|
|
10
|
+
render?: useRender.RenderProp;
|
|
11
|
+
/** When `false`, the `render` output (or the bare `children`) shows without the skeleton look. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const Skeleton: React$1.ForwardRefExoticComponent<SkeletonProps & React$1.RefAttributes<HTMLElement>>;
|
|
11
15
|
interface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
16
|
children?: ReactNode;
|
|
13
17
|
padding?: 'p-3' | 'p-4';
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import * as React$1 from "react";
|
|
3
4
|
import { HTMLAttributes, ReactNode } from "react";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
6
|
|
|
5
7
|
//#region src/components/skeleton.d.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
interface SkeletonProps extends HTMLAttributes<HTMLElement> {
|
|
9
|
+
/** Replaces the rendered `div`; an element keeps its own children and takes the skeleton look. */
|
|
10
|
+
render?: useRender.RenderProp;
|
|
11
|
+
/** When `false`, the `render` output (or the bare `children`) shows without the skeleton look. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
}
|
|
14
|
+
declare const Skeleton: React$1.ForwardRefExoticComponent<SkeletonProps & React$1.RefAttributes<HTMLElement>>;
|
|
11
15
|
interface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
16
|
children?: ReactNode;
|
|
13
17
|
padding?: 'p-3' | 'p-4';
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
-
import
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
6
|
//#region src/components/skeleton.tsx
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const Skeleton = React$1.forwardRef(({ className, render, loading = true, children, ...props }, ref) => {
|
|
8
|
+
const hasElement = loading || render != null;
|
|
9
|
+
const element = useRender({
|
|
10
|
+
defaultTagName: "div",
|
|
11
|
+
enabled: hasElement,
|
|
12
|
+
ref,
|
|
13
|
+
render,
|
|
14
|
+
props: {
|
|
15
|
+
"data-slot": loading ? "skeleton" : void 0,
|
|
16
|
+
className: loading ? cn("animate-pulse rounded-md bg-(--spark-skeleton-bg,var(--neutral-a3)) motion-reduce:animate-none", className) : className,
|
|
17
|
+
children,
|
|
18
|
+
...props
|
|
19
|
+
}
|
|
9
20
|
});
|
|
10
|
-
}
|
|
21
|
+
return hasElement ? element : /* @__PURE__ */ jsx(Fragment, { children });
|
|
22
|
+
});
|
|
23
|
+
Skeleton.displayName = "Skeleton";
|
|
11
24
|
function CardSkeleton({ children, className = "", padding = "p-4", ...props }) {
|
|
12
25
|
return /* @__PURE__ */ jsx("div", {
|
|
13
26
|
className: cn("flex flex-col rounded-lg border border-gray", padding, className),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","names":[],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\
|
|
1
|
+
{"version":3,"file":"skeleton.js","names":["React"],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from '../utils/cn'\n\ninterface SkeletonProps extends HTMLAttributes<HTMLElement> {\n /** Replaces the rendered `div`; an element keeps its own children and takes the skeleton look. */\n render?: useRender.RenderProp\n /** When `false`, the `render` output (or the bare `children`) shows without the skeleton look. */\n loading?: boolean\n}\n\nexport const Skeleton = React.forwardRef<HTMLElement, SkeletonProps>(\n ({ className, render, loading = true, children, ...props }, ref) => {\n const hasElement = loading || render != null\n const element = useRender({\n defaultTagName: 'div',\n enabled: hasElement,\n ref,\n render,\n props: {\n 'data-slot': loading ? 'skeleton' : undefined,\n // props and the ref stay on the element either way; only the look follows loading\n className: loading\n ? cn(\n 'animate-pulse rounded-md bg-(--spark-skeleton-bg,var(--neutral-a3)) motion-reduce:animate-none',\n className,\n )\n : className,\n children,\n ...props,\n },\n })\n\n return hasElement ? element : <>{children}</>\n },\n)\n\nSkeleton.displayName = 'Skeleton'\n\ninterface CardSkeletonProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode\n padding?: 'p-3' | 'p-4'\n}\n\nexport function CardSkeleton({\n children,\n className = '',\n padding = 'p-4',\n ...props\n}: CardSkeletonProps) {\n return (\n <div\n className={cn(\n 'flex flex-col rounded-lg border border-gray',\n padding,\n className,\n )}\n {...props}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;AAYA,MAAa,WAAWA,QAAM,YAC3B,EAAE,WAAW,QAAQ,UAAU,MAAM,UAAU,GAAG,SAAS,QAAQ;CAClE,MAAM,aAAa,WAAW,UAAU;CACxC,MAAM,UAAU,UAAU;EACxB,gBAAgB;EAChB,SAAS;EACT;EACA;EACA,OAAO;GACL,aAAa,UAAU,aAAa,KAAA;GAEpC,WAAW,UACP,GACE,kGACA,SACF,IACA;GACJ;GACA,GAAG;EACL;CACF,CAAC;CAED,OAAO,aAAa,UAAU,oBAAA,UAAA,EAAG,SAAW,CAAA;AAC9C,CACF;AAEA,SAAS,cAAc;AAOvB,SAAgB,aAAa,EAC3B,UACA,YAAY,IACZ,UAAU,OACV,GAAG,SACiB;CACpB,OACE,oBAAC,OAAD;EACE,WAAW,GACT,+CACA,SACA,SACF;EACA,GAAI;EAEH;CACE,CAAA;AAET"}
|