@devalok/shilp-sutra 0.59.0 → 0.60.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/MIGRATION.md +72 -0
- package/dist/composed/avatar-group.js +3 -3
- package/dist/composed/avatar-group.js.map +1 -1
- package/dist/composed/bulk-action-bar.d.ts +9 -35
- package/dist/composed/bulk-action-bar.d.ts.map +1 -1
- package/dist/composed/bulk-action-bar.js +2 -139
- package/dist/composed/index.js +6 -5
- package/dist/composed/master-detail.d.ts.map +1 -1
- package/dist/composed/master-detail.js +1 -1
- package/dist/composed/master-detail.js.map +1 -1
- package/dist/composed/multi-select-popover.d.ts.map +1 -1
- package/dist/composed/multi-select-popover.js +1 -1
- package/dist/composed/multi-select-popover.js.map +1 -1
- package/dist/tokens/semantic.css +85 -3
- package/dist/ui/avatar.d.ts.map +1 -1
- package/dist/ui/avatar.js +3 -3
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/bulk-action-bar.d.ts +59 -0
- package/dist/ui/bulk-action-bar.d.ts.map +1 -0
- package/dist/ui/bulk-action-bar.js +145 -0
- package/dist/ui/bulk-action-bar.js.map +1 -0
- package/dist/ui/checkbox.d.ts.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/combobox.d.ts.map +1 -1
- package/dist/ui/combobox.js +10 -10
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/data-table-body.d.ts.map +1 -1
- package/dist/ui/data-table-body.js +2 -1
- package/dist/ui/data-table-body.js.map +1 -1
- package/dist/ui/data-table-bulk-actions.d.ts +26 -1
- package/dist/ui/data-table-bulk-actions.d.ts.map +1 -1
- package/dist/ui/data-table-bulk-actions.js +21 -46
- package/dist/ui/data-table-bulk-actions.js.map +1 -1
- package/dist/ui/data-table-context.d.ts +36 -2
- package/dist/ui/data-table-context.d.ts.map +1 -1
- package/dist/ui/data-table-context.js +25 -21
- package/dist/ui/data-table-context.js.map +1 -1
- package/dist/ui/data-table-header.d.ts.map +1 -1
- package/dist/ui/data-table-header.js +2 -1
- package/dist/ui/data-table-header.js.map +1 -1
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +58 -57
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/input.d.ts.map +1 -1
- package/dist/ui/input.js +6 -6
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/radio.d.ts.map +1 -1
- package/dist/ui/radio.js +4 -4
- package/dist/ui/radio.js.map +1 -1
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +6 -6
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/switch.d.ts.map +1 -1
- package/dist/ui/switch.js +2 -2
- package/dist/ui/switch.js.map +1 -1
- package/dist/ui/table.d.ts.map +1 -1
- package/dist/ui/table.js +1 -1
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/textarea.d.ts.map +1 -1
- package/dist/ui/textarea.js +6 -6
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toast.d.ts.map +1 -1
- package/dist/ui/toast.js +1 -1
- package/dist/ui/toast.js.map +1 -1
- package/docs/components/composed/bulk-action-bar.md +14 -7
- package/docs/components/ui/bulk-action-bar.md +72 -0
- package/llms.txt +2 -2
- package/make-kit/foundations/color.md +3 -1
- package/mcp-manifest.json +178 -150
- package/package.json +6 -1
- package/skill/SKILL.md +1 -1
- package/skill/references/components.md +2 -2
- package/dist/composed/bulk-action-bar.js.map +0 -1
package/dist/ui/combobox.js
CHANGED
|
@@ -15,21 +15,21 @@ import { motion as h } from "framer-motion";
|
|
|
15
15
|
import { cva as g } from "class-variance-authority";
|
|
16
16
|
//#region src/ui/combobox.tsx
|
|
17
17
|
var _ = {
|
|
18
|
-
error: "border-error-
|
|
18
|
+
error: "border-error-8",
|
|
19
19
|
warning: "border-warning-7",
|
|
20
|
-
success: "border-success-
|
|
20
|
+
success: "border-success-8"
|
|
21
21
|
}, v = g([
|
|
22
22
|
"flex w-full items-center justify-between whitespace-nowrap rounded-control",
|
|
23
|
-
"border border-surface-border-interactive bg-
|
|
23
|
+
"border border-surface-border-interactive bg-field hover:bg-field-hover",
|
|
24
24
|
"transition-colors duration-fast-01 ease-productive-standard",
|
|
25
25
|
"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2 focus-visible:border-accent-7",
|
|
26
26
|
"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-action-disabled"
|
|
27
27
|
], {
|
|
28
28
|
variants: { size: {
|
|
29
|
-
xs: "h-ds-xs-plus text-body-sm px-ds-
|
|
30
|
-
sm: "h-ds-sm text-body-sm px-ds-
|
|
29
|
+
xs: "h-ds-xs-plus text-body-sm px-ds-04",
|
|
30
|
+
sm: "h-ds-sm text-body-sm px-ds-04",
|
|
31
31
|
md: "h-ds-md text-body-md px-ds-04",
|
|
32
|
-
lg: "h-ds-lg text-body-md px-ds-
|
|
32
|
+
lg: "h-ds-lg text-body-md px-ds-04"
|
|
33
33
|
} },
|
|
34
34
|
defaultVariants: { size: "md" }
|
|
35
35
|
}), oe = {
|
|
@@ -41,9 +41,9 @@ var _ = {
|
|
|
41
41
|
md: "sm",
|
|
42
42
|
lg: "md"
|
|
43
43
|
}, ce = {
|
|
44
|
-
xs: "px-ds-02 py-
|
|
45
|
-
sm: "px-ds-02 py-
|
|
46
|
-
md: "px-ds-03 py-
|
|
44
|
+
xs: "px-ds-02 py-px text-body-xs",
|
|
45
|
+
sm: "px-ds-02 py-px text-body-xs",
|
|
46
|
+
md: "px-ds-03 py-px text-body-sm",
|
|
47
47
|
lg: "px-ds-03 py-[2px] text-body-sm"
|
|
48
48
|
}, le = {
|
|
49
49
|
xs: "text-body-xs",
|
|
@@ -132,7 +132,7 @@ var _ = {
|
|
|
132
132
|
if (C && G.length > 0) {
|
|
133
133
|
let e = G.slice(0, y), t = G.length - y;
|
|
134
134
|
return /* @__PURE__ */ u("span", {
|
|
135
|
-
className: "flex flex-1 flex-wrap items-center gap-ds-
|
|
135
|
+
className: "flex flex-1 flex-wrap items-center gap-ds-01 overflow-hidden",
|
|
136
136
|
children: [e.map((e) => {
|
|
137
137
|
let t = g.find((t) => t.value === e);
|
|
138
138
|
return t ? /* @__PURE__ */ u("span", {
|
package/dist/ui/combobox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.js","names":[],"sources":["../../src/ui/combobox.tsx"],"sourcesContent":["'use client'\n\nimport * as PopoverPrimitive from '@primitives/react-popover'\nimport { IconCheck, IconChevronDown, IconSearch, IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { MotionPreference } from '../motion/motion-preference'\nimport { useFormField } from './form'\nimport { Icon } from './icon'\nimport { IconProvider, type IconSize } from './icon-context'\nimport { type FieldState, resolveFieldState } from './lib/field-state'\nimport type { IconInput } from './lib/icon-input'\nimport { springs, tweens } from './lib/motion'\nimport { normalizeIcon } from './lib/normalize-icon'\nimport { cn } from './lib/utils'\n\n/** Border tint per validation state, applied to the trigger. */\nconst stateBorderClasses: Record<Exclude<FieldState, 'default'>, string> = {\n error: 'border-error-7',\n warning: 'border-warning-7',\n success: 'border-success-7',\n}\n\nexport const comboboxTriggerVariants = cva(\n [\n 'flex w-full items-center justify-between whitespace-nowrap rounded-control',\n 'border border-surface-border-interactive bg-surface-panel-hover',\n 'transition-colors duration-fast-01 ease-productive-standard',\n 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2 focus-visible:border-accent-7',\n // Trigger is a div[role=combobox] (so chip remove-buttons in multi-select\n // aren't nested in a <button>), so disabled styling keys off data-disabled,\n // not the :disabled pseudo-class.\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-action-disabled',\n ],\n {\n variants: {\n size: {\n xs: 'h-ds-xs-plus text-body-sm px-ds-02',\n sm: 'h-ds-sm text-body-sm px-ds-03',\n md: 'h-ds-md text-body-md px-ds-04',\n lg: 'h-ds-lg text-body-md px-ds-05',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\nexport type ComboboxSize = NonNullable<VariantProps<typeof comboboxTriggerVariants>['size']>\n\n/** Colour treatment for a selected pill. See `ComboboxProps.pillTone`. */\nexport type ComboboxPillTone = 'neutral' | 'accent'\n\n// accent-2 was the previous fixed value and is not offered: in LIGHT it is the\n// same lightness as the trigger behind it (1.006:1), so the pill vanished\n// entirely, and in dark it sits below the panel. Both options below clear their\n// ground in both themes.\nconst PILL_TONES: Record<ComboboxPillTone, string> = {\n neutral: 'bg-surface-panel-active text-surface-fg',\n accent: 'bg-accent-4 text-accent-11',\n}\n\n/** Maps combobox size to Icon component size for chevron / check icons */\nconst iconSizeMap: Record<NonNullable<ComboboxSize>, IconSize> = {\n xs: 'xs',\n sm: 'sm',\n md: 'sm',\n lg: 'md',\n}\n\n/** Maps combobox size to pill text + padding classes */\nconst pillSizeMap: Record<NonNullable<ComboboxSize>, string> = {\n xs: 'px-ds-02 py-0 text-body-xs',\n sm: 'px-ds-02 py-0 text-body-xs',\n md: 'px-ds-03 py-[1px] text-body-sm',\n lg: 'px-ds-03 py-[2px] text-body-sm',\n}\n\n/** Maps combobox size to overflow text classes */\nconst overflowTextMap: Record<NonNullable<ComboboxSize>, string> = {\n xs: 'text-body-xs',\n sm: 'text-body-xs',\n md: 'text-body-sm',\n lg: 'text-body-sm',\n}\n\n/**\n * Option shape for a Combobox dropdown item.\n * `value` must be unique across all options — it is the key used in selection state.\n */\nexport interface ComboboxOption {\n value: string\n label: string\n description?: string\n icon?: IconInput\n disabled?: boolean\n}\n\n/**\n * Props for Combobox — a searchable single or multi-select dropdown with built-in keyboard\n * navigation, pill overflow (\"+ N more\"), and an optional custom option renderer.\n *\n * **Single vs multi:** `multiple={false}` (default) — `value` is a `string` and `onValueChange`\n * receives a `string`. When `multiple={true}`, `value` is `string[]`, `onValueChange` receives\n * `string[]`, and selected items appear as dismissible pills in the trigger.\n *\n * The props form a **discriminated union** on `multiple` — TypeScript will narrow `value` and\n * `onValueChange` automatically, so no manual casts are needed.\n *\n * **Custom rendering:** Use `renderOption` to return custom JSX per option (e.g. avatars, badges).\n *\n * @example\n * // Single-select country picker:\n * <Combobox\n * options={[{ value: 'in', label: 'India' }, { value: 'us', label: 'United States' }]}\n * value={country}\n * onValueChange={(v) => setCountry(v)}\n * placeholder=\"Select country\"\n * />\n *\n * @example\n * // Multi-select tag picker with pill display:\n * <Combobox\n * multiple\n * options={tagOptions}\n * value={selectedTags}\n * onValueChange={(v) => setSelectedTags(v)}\n * placeholder=\"Select tags...\"\n * />\n *\n * @example\n * // Custom option renderer (user avatars in assignee picker):\n * <Combobox\n * options={users.map(u => ({ value: u.id, label: u.name }))}\n * value={assigneeId}\n * onValueChange={(v) => setAssigneeId(v)}\n * renderOption={(option, selected) => (\n * <span className=\"flex items-center gap-ds-03\">\n * <Avatar size=\"xs\"><AvatarFallback>{option.label[0]}</AvatarFallback></Avatar>\n * {option.label}\n * </span>\n * )}\n * />\n * // These are just a few ways — feel free to combine props creatively!\n */\ninterface ComboboxBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Available options shown in the dropdown. */\n options: ComboboxOption[]\n /** Placeholder shown in the trigger when no value is selected. */\n placeholder?: string\n /** Placeholder for the search input inside the dropdown. */\n searchPlaceholder?: string\n /** Message shown when the search yields no results. */\n emptyMessage?: string\n disabled?: boolean\n triggerClassName?: string\n /** Max visible items in the dropdown before scroll (default 6). */\n maxVisible?: number\n /** Custom renderer for each option row. Receives the option and whether it's currently selected. */\n renderOption?: (option: ComboboxOption, selected: boolean) => React.ReactNode\n /** Accessible label for the trigger button. Falls back to `placeholder` if not provided. */\n accessibleLabel?: string\n /** Size of the trigger. Controls height, text size, padding, and pill sizing. */\n size?: ComboboxSize\n /** Validation/feedback state. `'error'` also sets `aria-invalid`. Inherited from `FormField` when omitted. */\n state?: FieldState\n /**\n * How a selected pill is coloured.\n *\n * - `neutral` (default) — grey. A pill here is a removable token, not a\n * selection, so the brand colour stays reserved for things that ARE\n * selected. 1.12:1 light / 1.16:1 dark against the trigger.\n * - `accent` — brand-tinted, for pickers where the tokens should feel like\n * part of the brand. 1.30:1 light / 1.05:1 dark.\n *\n * @default 'neutral'\n */\n pillTone?: ComboboxPillTone\n}\n\ninterface ComboboxSingleProps extends ComboboxBaseProps {\n multiple?: false\n value?: string\n onValueChange: (value: string) => void\n}\n\ninterface ComboboxMultipleProps extends ComboboxBaseProps {\n multiple: true\n value?: string[]\n onValueChange: (value: string[]) => void\n}\n\nexport type ComboboxProps = ComboboxSingleProps | ComboboxMultipleProps\n\n/** Max pills shown in the trigger before \"+N more\" overflow */\nconst MAX_VISIBLE_PILLS = 2\n\n/** Approximate height of a single option item in px */\nconst ITEM_HEIGHT_PX = 36\n\nconst Combobox = React.forwardRef<HTMLDivElement, ComboboxProps>(\n (\n {\n options,\n value,\n onValueChange,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n emptyMessage = 'No results found',\n multiple = false,\n disabled = false,\n className,\n triggerClassName,\n maxVisible = 6,\n renderOption,\n accessibleLabel,\n id: externalId,\n size: sizeProp = 'md',\n state: stateProp,\n pillTone = 'neutral',\n ...rest\n },\n ref,\n ) => {\n const size = sizeProp ?? 'md'\n const [open, setOpen] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [highlightedIndex, setHighlightedIndex] = React.useState(-1)\n const searchInputRef = React.useRef<HTMLInputElement>(null)\n const listRef = React.useRef<HTMLUListElement>(null)\n const optionIdPrefix = React.useId()\n const listboxId = React.useId()\n\n const selectedValues = React.useMemo<string[]>(() => {\n if (value === undefined || value === null) return []\n if (Array.isArray(value)) return value\n return [value]\n }, [value])\n\n const filteredOptions = React.useMemo(\n () =>\n search\n ? options.filter((o) =>\n o.label.toLowerCase().includes(search.toLowerCase()),\n )\n : options,\n [options, search],\n )\n\n const isSelected = React.useCallback(\n (optionValue: string) => selectedValues.includes(optionValue),\n [selectedValues],\n )\n\n const handleSelect = React.useCallback(\n (optionValue: string) => {\n if (multiple) {\n const newValue = selectedValues.includes(optionValue)\n ? selectedValues.filter((v) => v !== optionValue)\n : [...selectedValues, optionValue]\n ;(onValueChange as (value: string[]) => void)(newValue)\n } else {\n ;(onValueChange as (value: string) => void)(optionValue)\n setOpen(false)\n }\n },\n [multiple, selectedValues, onValueChange],\n )\n\n const handleRemovePill = React.useCallback(\n (e: React.SyntheticEvent, optionValue: string) => {\n e.stopPropagation()\n e.preventDefault()\n const newValue = selectedValues.filter((v) => v !== optionValue)\n ;(onValueChange as (value: string[]) => void)(newValue)\n },\n [selectedValues, onValueChange],\n )\n\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean) => {\n if (disabled) return\n setOpen(nextOpen)\n if (!nextOpen) {\n setSearch('')\n setHighlightedIndex(-1)\n }\n },\n [disabled],\n )\n\n // Auto-focus search input when popover opens\n React.useEffect(() => {\n if (open) {\n // Use a small timeout to allow the popover to render\n const timer = setTimeout(() => {\n searchInputRef.current?.focus()\n }, 0)\n return () => clearTimeout(timer)\n }\n }, [open])\n\n const findNextEnabledIndex = React.useCallback(\n (currentIndex: number, direction: 1 | -1): number => {\n const len = filteredOptions.length\n if (len === 0) return -1\n\n let nextIndex = currentIndex + direction\n while (nextIndex >= 0 && nextIndex < len) {\n if (!filteredOptions[nextIndex].disabled) return nextIndex\n nextIndex += direction\n }\n return currentIndex\n },\n [filteredOptions],\n )\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault()\n const nextIdx = findNextEnabledIndex(highlightedIndex, 1)\n setHighlightedIndex(nextIdx)\n break\n }\n case 'ArrowUp': {\n e.preventDefault()\n const prevIdx = findNextEnabledIndex(highlightedIndex, -1)\n setHighlightedIndex(prevIdx)\n break\n }\n case 'Home': {\n e.preventDefault()\n const firstEnabled = filteredOptions.findIndex((o) => !o.disabled)\n setHighlightedIndex(firstEnabled)\n break\n }\n case 'End': {\n e.preventDefault()\n let lastEnabled = -1\n for (let i = filteredOptions.length - 1; i >= 0; i--) {\n if (!filteredOptions[i].disabled) {\n lastEnabled = i\n break\n }\n }\n setHighlightedIndex(lastEnabled)\n break\n }\n case 'Enter': {\n e.preventDefault()\n if (\n highlightedIndex >= 0 &&\n highlightedIndex < filteredOptions.length &&\n !filteredOptions[highlightedIndex].disabled\n ) {\n handleSelect(filteredOptions[highlightedIndex].value)\n }\n break\n }\n case 'Escape': {\n e.preventDefault()\n setOpen(false)\n setSearch('')\n setHighlightedIndex(-1)\n break\n }\n }\n },\n [highlightedIndex, filteredOptions, findNextEnabledIndex, handleSelect],\n )\n\n // Scroll highlighted option into view\n React.useEffect(() => {\n if (highlightedIndex >= 0 && listRef.current) {\n const optionEl = listRef.current.children[highlightedIndex] as HTMLElement\n if (optionEl) {\n optionEl.scrollIntoView?.({ block: 'nearest' })\n }\n }\n }, [highlightedIndex])\n\n const getSelectedLabel = React.useCallback(() => {\n if (selectedValues.length === 0) return null\n const option = options.find((o) => o.value === selectedValues[0])\n return option?.label ?? null\n }, [selectedValues, options])\n\n const resolvedIconSize = iconSizeMap[size]\n const resolvedPillClasses = pillSizeMap[size]\n const resolvedOverflowText = overflowTextMap[size]\n\n const renderTriggerContent = () => {\n if (multiple && selectedValues.length > 0) {\n const visiblePills = selectedValues.slice(0, MAX_VISIBLE_PILLS)\n const remaining = selectedValues.length - MAX_VISIBLE_PILLS\n\n return (\n <span className=\"flex flex-1 flex-wrap items-center gap-ds-02 overflow-hidden\">\n {visiblePills.map((val) => {\n const option = options.find((o) => o.value === val)\n if (!option) return null\n return (\n <span\n key={val}\n className={cn('inline-flex items-center gap-ds-01 rounded-control-inner', PILL_TONES[pillTone], resolvedPillClasses)}\n >\n {option.label}\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-pill outline-hidden hover:bg-surface-panel-hover transition-colors duration-fast-01 ease-productive-standard\"\n onClick={(e) => handleRemovePill(e, val)}\n aria-label={`Remove ${option.label}`}\n tabIndex={-1}\n >\n <Icon icon={IconX} size={resolvedIconSize} />\n </button>\n </span>\n )\n })}\n {remaining > 0 && (\n <span className={cn('text-surface-fg-muted', resolvedOverflowText)}>\n +{remaining} more\n </span>\n )}\n </span>\n )\n }\n\n if (!multiple && selectedValues.length === 1) {\n const label = getSelectedLabel()\n if (label) {\n return <span className=\"min-w-0 flex-1 truncate text-left\">{label}</span>\n }\n }\n\n return (\n <span className=\"min-w-0 flex-1 truncate text-left text-surface-fg-muted\">\n {placeholder}\n </span>\n )\n }\n\n const fieldCtx = useFormField()\n const state = resolveFieldState(stateProp, fieldCtx.state)\n const isError = state === 'error'\n const ariaDescribedBy = fieldCtx.helperTextId\n const ariaRequired = fieldCtx.required\n\n return (\n <MotionPreference>\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n <div className={cn('relative', className)} {...rest}>\n <PopoverPrimitive.Trigger asChild disabled={disabled}>\n {/* role=combobox on a <div>, NOT a <button> — a native button can't\n legally contain the chip remove-<button>s rendered in multi-select\n (invalid HTML + a11y break). This is the W3C select-only combobox\n pattern. Radix Trigger wires click/toggle; we add the keyboard-open\n (Enter/Space/ArrowDown) a real button would have given for free. */}\n <div\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled ? -1 : 0}\n data-disabled={disabled || undefined}\n id={externalId}\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-disabled={disabled || undefined}\n // The trigger is a div[role=combobox] — non-labellable, so `<Label htmlFor>`\n // can't target it. Inside a FormField, adopt the label's id via\n // aria-labelledby; explicit accessibleLabel wins; placeholder is the\n // standalone fallback.\n aria-labelledby={accessibleLabel ? undefined : fieldCtx.labelId}\n aria-label={accessibleLabel ?? (fieldCtx.labelId ? undefined : placeholder)}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-required={ariaRequired || undefined}\n onKeyDown={(e) => {\n if (disabled) return\n if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {\n e.preventDefault()\n handleOpenChange(true)\n }\n }}\n className={cn(\n comboboxTriggerVariants({ size }),\n 'cursor-pointer',\n open && 'border-accent-7',\n state && stateBorderClasses[state],\n triggerClassName,\n )}\n >\n {renderTriggerContent()}\n <Icon icon={IconChevronDown} size={resolvedIconSize} className={cn(\"ml-ds-02 shrink-0 opacity-50 transition-transform duration-fast-01 ease-productive-standard\", open && 'rotate-180')} />\n </div>\n </PopoverPrimitive.Trigger>\n\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n sideOffset={4}\n align=\"start\"\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n searchInputRef.current?.focus()\n }}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n 'z-popover w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-overlay bg-surface-overlay shadow-floating',\n )}\n >\n {/* Search input */}\n <div className=\"flex items-center gap-ds-02 border-b border-surface-border px-ds-04\">\n <Icon icon={IconSearch} size=\"sm\" className=\"shrink-0 text-surface-fg-subtle\" />\n <input\n ref={searchInputRef}\n type=\"text\"\n className=\"flex-1 bg-transparent py-ds-03 text-body-md outline-hidden placeholder:text-surface-fg-muted\"\n placeholder={searchPlaceholder}\n value={search}\n onChange={(e) => {\n setSearch(e.target.value)\n setHighlightedIndex(-1)\n }}\n onKeyDown={handleKeyDown}\n aria-autocomplete=\"list\"\n aria-controls={listboxId}\n aria-activedescendant={\n highlightedIndex >= 0\n ? `${optionIdPrefix}-option-${highlightedIndex}`\n : undefined\n }\n aria-label=\"Search options\"\n />\n </div>\n\n {/* Options list */}\n {filteredOptions.length === 0 ? (\n <div className=\"px-ds-04 py-ds-05 text-center text-body-md text-surface-fg-subtle\">\n {emptyMessage}\n </div>\n ) : (\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-multiselectable={multiple || undefined}\n className=\"overflow-auto p-ds-02\"\n style={{ maxHeight: `${maxVisible * ITEM_HEIGHT_PX}px` }}\n >\n {filteredOptions.map((option, index) => {\n const selected = isSelected(option.value)\n return (\n <li\n key={option.value}\n id={`${optionIdPrefix}-option-${index}`}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={option.disabled || undefined}\n className={cn(\n 'relative flex cursor-pointer select-none items-center gap-ds-03 rounded-control px-ds-04 py-ds-03 text-body-md outline-hidden',\n 'transition-colors duration-fast-01 ease-productive-standard',\n highlightedIndex === index &&\n 'bg-accent-4',\n selected && 'text-accent-11',\n option.disabled &&\n 'pointer-events-none opacity-action-disabled',\n )}\n onClick={() => {\n if (!option.disabled) {\n handleSelect(option.value)\n }\n }}\n onKeyDown={(e) => {\n if (!option.disabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault()\n handleSelect(option.value)\n }\n }}\n onMouseEnter={() => {\n if (!option.disabled) {\n setHighlightedIndex(index)\n }\n }}\n >\n {option.icon && (\n <span className=\"flex h-ico-sm w-ico-sm items-center justify-center shrink-0\">\n <IconProvider size={resolvedIconSize}>\n {normalizeIcon(option.icon)}\n </IconProvider>\n </span>\n )}\n <span className=\"flex flex-1 flex-col\">\n {renderOption ? (\n renderOption(option, selected)\n ) : (\n <>\n <span>{option.label}</span>\n {option.description && (\n <span className=\"text-body-sm text-surface-fg-muted\">\n {option.description}\n </span>\n )}\n </>\n )}\n </span>\n {selected && (\n <Icon icon={IconCheck} size=\"sm\" className=\"shrink-0\" />\n )}\n </li>\n )\n })}\n </ul>\n )}\n </motion.div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </div>\n </PopoverPrimitive.Root>\n </MotionPreference>\n )\n },\n)\nCombobox.displayName = 'Combobox'\n\nexport { Combobox }\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,IAAqE;CACzE,OAAO;CACP,SAAS;CACT,SAAS;AACX,GAEa,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,"file":"combobox.js","names":[],"sources":["../../src/ui/combobox.tsx"],"sourcesContent":["'use client'\n\nimport * as PopoverPrimitive from '@primitives/react-popover'\nimport { IconCheck, IconChevronDown, IconSearch, IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { MotionPreference } from '../motion/motion-preference'\nimport { useFormField } from './form'\nimport { Icon } from './icon'\nimport { IconProvider, type IconSize } from './icon-context'\nimport { type FieldState, resolveFieldState } from './lib/field-state'\nimport type { IconInput } from './lib/icon-input'\nimport { springs, tweens } from './lib/motion'\nimport { normalizeIcon } from './lib/normalize-icon'\nimport { cn } from './lib/utils'\n\n/** Border tint per validation state, applied to the trigger. */\nconst stateBorderClasses: Record<Exclude<FieldState, 'default'>, string> = {\n // Step 8 clears the 3:1 non-text bar; warning stays at 7 per the design note.\n error: 'border-error-8',\n warning: 'border-warning-7',\n success: 'border-success-8',\n}\n\nexport const comboboxTriggerVariants = cva(\n [\n 'flex w-full items-center justify-between whitespace-nowrap rounded-control',\n 'border border-surface-border-interactive bg-field hover:bg-field-hover',\n 'transition-colors duration-fast-01 ease-productive-standard',\n 'focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-2 focus-visible:border-accent-7',\n // Trigger is a div[role=combobox] (so chip remove-buttons in multi-select\n // aren't nested in a <button>), so disabled styling keys off data-disabled,\n // not the :disabled pseudo-class.\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-action-disabled',\n ],\n {\n variants: {\n // 12px inline padding on every size (design 2026-08-24).\n size: {\n xs: 'h-ds-xs-plus text-body-sm px-ds-04',\n sm: 'h-ds-sm text-body-sm px-ds-04',\n md: 'h-ds-md text-body-md px-ds-04',\n lg: 'h-ds-lg text-body-md px-ds-04',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\nexport type ComboboxSize = NonNullable<VariantProps<typeof comboboxTriggerVariants>['size']>\n\n/** Colour treatment for a selected pill. See `ComboboxProps.pillTone`. */\nexport type ComboboxPillTone = 'neutral' | 'accent'\n\n// accent-2 was the previous fixed value and is not offered: in LIGHT it is the\n// same lightness as the trigger behind it (1.006:1), so the pill vanished\n// entirely, and in dark it sits below the panel. Both options below clear their\n// ground in both themes.\nconst PILL_TONES: Record<ComboboxPillTone, string> = {\n neutral: 'bg-surface-panel-active text-surface-fg',\n accent: 'bg-accent-4 text-accent-11',\n}\n\n/** Maps combobox size to Icon component size for chevron / check icons */\nconst iconSizeMap: Record<NonNullable<ComboboxSize>, IconSize> = {\n xs: 'xs',\n sm: 'sm',\n md: 'sm',\n lg: 'md',\n}\n\n/** Maps combobox size to pill text + padding classes */\nconst pillSizeMap: Record<NonNullable<ComboboxSize>, string> = {\n // Every pill carries at least 1px block padding (design 2026-08-24) — xs/sm\n // were flush at py-0, which let the chip text sit on the chip's own edge.\n xs: 'px-ds-02 py-px text-body-xs',\n sm: 'px-ds-02 py-px text-body-xs',\n md: 'px-ds-03 py-px text-body-sm',\n lg: 'px-ds-03 py-[2px] text-body-sm',\n}\n\n/** Maps combobox size to overflow text classes */\nconst overflowTextMap: Record<NonNullable<ComboboxSize>, string> = {\n xs: 'text-body-xs',\n sm: 'text-body-xs',\n md: 'text-body-sm',\n lg: 'text-body-sm',\n}\n\n/**\n * Option shape for a Combobox dropdown item.\n * `value` must be unique across all options — it is the key used in selection state.\n */\nexport interface ComboboxOption {\n value: string\n label: string\n description?: string\n icon?: IconInput\n disabled?: boolean\n}\n\n/**\n * Props for Combobox — a searchable single or multi-select dropdown with built-in keyboard\n * navigation, pill overflow (\"+ N more\"), and an optional custom option renderer.\n *\n * **Single vs multi:** `multiple={false}` (default) — `value` is a `string` and `onValueChange`\n * receives a `string`. When `multiple={true}`, `value` is `string[]`, `onValueChange` receives\n * `string[]`, and selected items appear as dismissible pills in the trigger.\n *\n * The props form a **discriminated union** on `multiple` — TypeScript will narrow `value` and\n * `onValueChange` automatically, so no manual casts are needed.\n *\n * **Custom rendering:** Use `renderOption` to return custom JSX per option (e.g. avatars, badges).\n *\n * @example\n * // Single-select country picker:\n * <Combobox\n * options={[{ value: 'in', label: 'India' }, { value: 'us', label: 'United States' }]}\n * value={country}\n * onValueChange={(v) => setCountry(v)}\n * placeholder=\"Select country\"\n * />\n *\n * @example\n * // Multi-select tag picker with pill display:\n * <Combobox\n * multiple\n * options={tagOptions}\n * value={selectedTags}\n * onValueChange={(v) => setSelectedTags(v)}\n * placeholder=\"Select tags...\"\n * />\n *\n * @example\n * // Custom option renderer (user avatars in assignee picker):\n * <Combobox\n * options={users.map(u => ({ value: u.id, label: u.name }))}\n * value={assigneeId}\n * onValueChange={(v) => setAssigneeId(v)}\n * renderOption={(option, selected) => (\n * <span className=\"flex items-center gap-ds-03\">\n * <Avatar size=\"xs\"><AvatarFallback>{option.label[0]}</AvatarFallback></Avatar>\n * {option.label}\n * </span>\n * )}\n * />\n * // These are just a few ways — feel free to combine props creatively!\n */\ninterface ComboboxBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Available options shown in the dropdown. */\n options: ComboboxOption[]\n /** Placeholder shown in the trigger when no value is selected. */\n placeholder?: string\n /** Placeholder for the search input inside the dropdown. */\n searchPlaceholder?: string\n /** Message shown when the search yields no results. */\n emptyMessage?: string\n disabled?: boolean\n triggerClassName?: string\n /** Max visible items in the dropdown before scroll (default 6). */\n maxVisible?: number\n /** Custom renderer for each option row. Receives the option and whether it's currently selected. */\n renderOption?: (option: ComboboxOption, selected: boolean) => React.ReactNode\n /** Accessible label for the trigger button. Falls back to `placeholder` if not provided. */\n accessibleLabel?: string\n /** Size of the trigger. Controls height, text size, padding, and pill sizing. */\n size?: ComboboxSize\n /** Validation/feedback state. `'error'` also sets `aria-invalid`. Inherited from `FormField` when omitted. */\n state?: FieldState\n /**\n * How a selected pill is coloured.\n *\n * - `neutral` (default) — grey. A pill here is a removable token, not a\n * selection, so the brand colour stays reserved for things that ARE\n * selected. 1.12:1 light / 1.16:1 dark against the trigger.\n * - `accent` — brand-tinted, for pickers where the tokens should feel like\n * part of the brand. 1.30:1 light / 1.05:1 dark.\n *\n * @default 'neutral'\n */\n pillTone?: ComboboxPillTone\n}\n\ninterface ComboboxSingleProps extends ComboboxBaseProps {\n multiple?: false\n value?: string\n onValueChange: (value: string) => void\n}\n\ninterface ComboboxMultipleProps extends ComboboxBaseProps {\n multiple: true\n value?: string[]\n onValueChange: (value: string[]) => void\n}\n\nexport type ComboboxProps = ComboboxSingleProps | ComboboxMultipleProps\n\n/** Max pills shown in the trigger before \"+N more\" overflow */\nconst MAX_VISIBLE_PILLS = 2\n\n/** Approximate height of a single option item in px */\nconst ITEM_HEIGHT_PX = 36\n\nconst Combobox = React.forwardRef<HTMLDivElement, ComboboxProps>(\n (\n {\n options,\n value,\n onValueChange,\n placeholder = 'Select...',\n searchPlaceholder = 'Search...',\n emptyMessage = 'No results found',\n multiple = false,\n disabled = false,\n className,\n triggerClassName,\n maxVisible = 6,\n renderOption,\n accessibleLabel,\n id: externalId,\n size: sizeProp = 'md',\n state: stateProp,\n pillTone = 'neutral',\n ...rest\n },\n ref,\n ) => {\n const size = sizeProp ?? 'md'\n const [open, setOpen] = React.useState(false)\n const [search, setSearch] = React.useState('')\n const [highlightedIndex, setHighlightedIndex] = React.useState(-1)\n const searchInputRef = React.useRef<HTMLInputElement>(null)\n const listRef = React.useRef<HTMLUListElement>(null)\n const optionIdPrefix = React.useId()\n const listboxId = React.useId()\n\n const selectedValues = React.useMemo<string[]>(() => {\n if (value === undefined || value === null) return []\n if (Array.isArray(value)) return value\n return [value]\n }, [value])\n\n const filteredOptions = React.useMemo(\n () =>\n search\n ? options.filter((o) =>\n o.label.toLowerCase().includes(search.toLowerCase()),\n )\n : options,\n [options, search],\n )\n\n const isSelected = React.useCallback(\n (optionValue: string) => selectedValues.includes(optionValue),\n [selectedValues],\n )\n\n const handleSelect = React.useCallback(\n (optionValue: string) => {\n if (multiple) {\n const newValue = selectedValues.includes(optionValue)\n ? selectedValues.filter((v) => v !== optionValue)\n : [...selectedValues, optionValue]\n ;(onValueChange as (value: string[]) => void)(newValue)\n } else {\n ;(onValueChange as (value: string) => void)(optionValue)\n setOpen(false)\n }\n },\n [multiple, selectedValues, onValueChange],\n )\n\n const handleRemovePill = React.useCallback(\n (e: React.SyntheticEvent, optionValue: string) => {\n e.stopPropagation()\n e.preventDefault()\n const newValue = selectedValues.filter((v) => v !== optionValue)\n ;(onValueChange as (value: string[]) => void)(newValue)\n },\n [selectedValues, onValueChange],\n )\n\n const handleOpenChange = React.useCallback(\n (nextOpen: boolean) => {\n if (disabled) return\n setOpen(nextOpen)\n if (!nextOpen) {\n setSearch('')\n setHighlightedIndex(-1)\n }\n },\n [disabled],\n )\n\n // Auto-focus search input when popover opens\n React.useEffect(() => {\n if (open) {\n // Use a small timeout to allow the popover to render\n const timer = setTimeout(() => {\n searchInputRef.current?.focus()\n }, 0)\n return () => clearTimeout(timer)\n }\n }, [open])\n\n const findNextEnabledIndex = React.useCallback(\n (currentIndex: number, direction: 1 | -1): number => {\n const len = filteredOptions.length\n if (len === 0) return -1\n\n let nextIndex = currentIndex + direction\n while (nextIndex >= 0 && nextIndex < len) {\n if (!filteredOptions[nextIndex].disabled) return nextIndex\n nextIndex += direction\n }\n return currentIndex\n },\n [filteredOptions],\n )\n\n const handleKeyDown = React.useCallback(\n (e: React.KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown': {\n e.preventDefault()\n const nextIdx = findNextEnabledIndex(highlightedIndex, 1)\n setHighlightedIndex(nextIdx)\n break\n }\n case 'ArrowUp': {\n e.preventDefault()\n const prevIdx = findNextEnabledIndex(highlightedIndex, -1)\n setHighlightedIndex(prevIdx)\n break\n }\n case 'Home': {\n e.preventDefault()\n const firstEnabled = filteredOptions.findIndex((o) => !o.disabled)\n setHighlightedIndex(firstEnabled)\n break\n }\n case 'End': {\n e.preventDefault()\n let lastEnabled = -1\n for (let i = filteredOptions.length - 1; i >= 0; i--) {\n if (!filteredOptions[i].disabled) {\n lastEnabled = i\n break\n }\n }\n setHighlightedIndex(lastEnabled)\n break\n }\n case 'Enter': {\n e.preventDefault()\n if (\n highlightedIndex >= 0 &&\n highlightedIndex < filteredOptions.length &&\n !filteredOptions[highlightedIndex].disabled\n ) {\n handleSelect(filteredOptions[highlightedIndex].value)\n }\n break\n }\n case 'Escape': {\n e.preventDefault()\n setOpen(false)\n setSearch('')\n setHighlightedIndex(-1)\n break\n }\n }\n },\n [highlightedIndex, filteredOptions, findNextEnabledIndex, handleSelect],\n )\n\n // Scroll highlighted option into view\n React.useEffect(() => {\n if (highlightedIndex >= 0 && listRef.current) {\n const optionEl = listRef.current.children[highlightedIndex] as HTMLElement\n if (optionEl) {\n optionEl.scrollIntoView?.({ block: 'nearest' })\n }\n }\n }, [highlightedIndex])\n\n const getSelectedLabel = React.useCallback(() => {\n if (selectedValues.length === 0) return null\n const option = options.find((o) => o.value === selectedValues[0])\n return option?.label ?? null\n }, [selectedValues, options])\n\n const resolvedIconSize = iconSizeMap[size]\n const resolvedPillClasses = pillSizeMap[size]\n const resolvedOverflowText = overflowTextMap[size]\n\n const renderTriggerContent = () => {\n if (multiple && selectedValues.length > 0) {\n const visiblePills = selectedValues.slice(0, MAX_VISIBLE_PILLS)\n const remaining = selectedValues.length - MAX_VISIBLE_PILLS\n\n return (\n /* 2px between chips (design 2026-08-24) — was 4px. */\n <span className=\"flex flex-1 flex-wrap items-center gap-ds-01 overflow-hidden\">\n {visiblePills.map((val) => {\n const option = options.find((o) => o.value === val)\n if (!option) return null\n return (\n <span\n key={val}\n className={cn('inline-flex items-center gap-ds-01 rounded-control-inner', PILL_TONES[pillTone], resolvedPillClasses)}\n >\n {option.label}\n <button\n type=\"button\"\n className=\"inline-flex items-center justify-center rounded-pill outline-hidden hover:bg-surface-panel-hover transition-colors duration-fast-01 ease-productive-standard\"\n onClick={(e) => handleRemovePill(e, val)}\n aria-label={`Remove ${option.label}`}\n tabIndex={-1}\n >\n <Icon icon={IconX} size={resolvedIconSize} />\n </button>\n </span>\n )\n })}\n {remaining > 0 && (\n <span className={cn('text-surface-fg-muted', resolvedOverflowText)}>\n +{remaining} more\n </span>\n )}\n </span>\n )\n }\n\n if (!multiple && selectedValues.length === 1) {\n const label = getSelectedLabel()\n if (label) {\n return <span className=\"min-w-0 flex-1 truncate text-left\">{label}</span>\n }\n }\n\n return (\n <span className=\"min-w-0 flex-1 truncate text-left text-surface-fg-muted\">\n {placeholder}\n </span>\n )\n }\n\n const fieldCtx = useFormField()\n const state = resolveFieldState(stateProp, fieldCtx.state)\n const isError = state === 'error'\n const ariaDescribedBy = fieldCtx.helperTextId\n const ariaRequired = fieldCtx.required\n\n return (\n <MotionPreference>\n <PopoverPrimitive.Root open={open} onOpenChange={handleOpenChange}>\n <div className={cn('relative', className)} {...rest}>\n <PopoverPrimitive.Trigger asChild disabled={disabled}>\n {/* role=combobox on a <div>, NOT a <button> — a native button can't\n legally contain the chip remove-<button>s rendered in multi-select\n (invalid HTML + a11y break). This is the W3C select-only combobox\n pattern. Radix Trigger wires click/toggle; we add the keyboard-open\n (Enter/Space/ArrowDown) a real button would have given for free. */}\n <div\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled ? -1 : 0}\n data-disabled={disabled || undefined}\n id={externalId}\n aria-expanded={open}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-disabled={disabled || undefined}\n // The trigger is a div[role=combobox] — non-labellable, so `<Label htmlFor>`\n // can't target it. Inside a FormField, adopt the label's id via\n // aria-labelledby; explicit accessibleLabel wins; placeholder is the\n // standalone fallback.\n aria-labelledby={accessibleLabel ? undefined : fieldCtx.labelId}\n aria-label={accessibleLabel ?? (fieldCtx.labelId ? undefined : placeholder)}\n aria-invalid={isError || undefined}\n aria-describedby={ariaDescribedBy}\n aria-required={ariaRequired || undefined}\n onKeyDown={(e) => {\n if (disabled) return\n if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {\n e.preventDefault()\n handleOpenChange(true)\n }\n }}\n className={cn(\n comboboxTriggerVariants({ size }),\n 'cursor-pointer',\n open && 'border-accent-7',\n state && stateBorderClasses[state],\n triggerClassName,\n )}\n >\n {renderTriggerContent()}\n <Icon icon={IconChevronDown} size={resolvedIconSize} className={cn(\"ml-ds-02 shrink-0 opacity-50 transition-transform duration-fast-01 ease-productive-standard\", open && 'rotate-180')} />\n </div>\n </PopoverPrimitive.Trigger>\n\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n asChild\n sideOffset={4}\n align=\"start\"\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n searchInputRef.current?.focus()\n }}\n >\n <motion.div\n initial={{ opacity: 0, scale: 0.95 }}\n animate={{ opacity: 1, scale: 1 }}\n transition={{ ...springs.snappy, opacity: tweens.fade }}\n className={cn(\n 'z-popover w-[var(--radix-popover-trigger-width)] overflow-hidden rounded-overlay bg-surface-overlay shadow-floating',\n )}\n >\n {/* Search input */}\n <div className=\"flex items-center gap-ds-02 border-b border-surface-border px-ds-04\">\n <Icon icon={IconSearch} size=\"sm\" className=\"shrink-0 text-surface-fg-subtle\" />\n <input\n ref={searchInputRef}\n type=\"text\"\n className=\"flex-1 bg-transparent py-ds-03 text-body-md outline-hidden placeholder:text-surface-fg-muted\"\n placeholder={searchPlaceholder}\n value={search}\n onChange={(e) => {\n setSearch(e.target.value)\n setHighlightedIndex(-1)\n }}\n onKeyDown={handleKeyDown}\n aria-autocomplete=\"list\"\n aria-controls={listboxId}\n aria-activedescendant={\n highlightedIndex >= 0\n ? `${optionIdPrefix}-option-${highlightedIndex}`\n : undefined\n }\n aria-label=\"Search options\"\n />\n </div>\n\n {/* Options list */}\n {filteredOptions.length === 0 ? (\n <div className=\"px-ds-04 py-ds-05 text-center text-body-md text-surface-fg-subtle\">\n {emptyMessage}\n </div>\n ) : (\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-multiselectable={multiple || undefined}\n className=\"overflow-auto p-ds-02\"\n style={{ maxHeight: `${maxVisible * ITEM_HEIGHT_PX}px` }}\n >\n {filteredOptions.map((option, index) => {\n const selected = isSelected(option.value)\n return (\n <li\n key={option.value}\n id={`${optionIdPrefix}-option-${index}`}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={option.disabled || undefined}\n className={cn(\n 'relative flex cursor-pointer select-none items-center gap-ds-03 rounded-control px-ds-04 py-ds-03 text-body-md outline-hidden',\n 'transition-colors duration-fast-01 ease-productive-standard',\n highlightedIndex === index &&\n 'bg-accent-4',\n selected && 'text-accent-11',\n option.disabled &&\n 'pointer-events-none opacity-action-disabled',\n )}\n onClick={() => {\n if (!option.disabled) {\n handleSelect(option.value)\n }\n }}\n onKeyDown={(e) => {\n if (!option.disabled && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault()\n handleSelect(option.value)\n }\n }}\n onMouseEnter={() => {\n if (!option.disabled) {\n setHighlightedIndex(index)\n }\n }}\n >\n {option.icon && (\n <span className=\"flex h-ico-sm w-ico-sm items-center justify-center shrink-0\">\n <IconProvider size={resolvedIconSize}>\n {normalizeIcon(option.icon)}\n </IconProvider>\n </span>\n )}\n <span className=\"flex flex-1 flex-col\">\n {renderOption ? (\n renderOption(option, selected)\n ) : (\n <>\n <span>{option.label}</span>\n {option.description && (\n <span className=\"text-body-sm text-surface-fg-muted\">\n {option.description}\n </span>\n )}\n </>\n )}\n </span>\n {selected && (\n <Icon icon={IconCheck} size=\"sm\" className=\"shrink-0\" />\n )}\n </li>\n )\n })}\n </ul>\n )}\n </motion.div>\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </div>\n </PopoverPrimitive.Root>\n </MotionPreference>\n )\n },\n)\nCombobox.displayName = 'Combobox'\n\nexport { Combobox }\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,IAAqE;CAEzE,OAAO;CACP,SAAS;CACT,SAAS;AACX,GAEa,IAA0B,EACrC;CACE;CACA;CACA;CACA;CAIA;AACF,GACA;CACE,UAAU,EAER,MAAM;EACJ,IAA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"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAmD,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"data-table-body.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-body.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAmD,MAAM,OAAO,CAAA;AAoQvE,wBAAgB,aAAa,CAAC,KAAK,EAAE,EACnC,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC5B,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,KAAK,IAAI,CAAA;CAC5D,qBAoFA"}
|
|
@@ -39,10 +39,11 @@ function C({ row: e }) {
|
|
|
39
39
|
className: t(h && "cursor-pointer", _?.(e.original)),
|
|
40
40
|
onClick: h ? v : void 0,
|
|
41
41
|
children: y.map((o) => {
|
|
42
|
-
let l = i(o.column.id, s), d = f?.rowIndex === e.index && f?.columnId === o.column.id;
|
|
42
|
+
let l = i(o.column.id, s, o.column), d = f?.rowIndex === e.index && f?.columnId === o.column.id;
|
|
43
43
|
return /* @__PURE__ */ g(c, {
|
|
44
44
|
className: t(l.className, r(o.column.columnDef.meta)),
|
|
45
45
|
style: l.style,
|
|
46
|
+
"data-pinned": l["data-pinned"],
|
|
46
47
|
onDoubleClick: () => {
|
|
47
48
|
a(o.column.id, u, n) && p({
|
|
48
49
|
rowIndex: e.index,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-body.js","names":[],"sources":["../../src/ui/data-table-body.tsx"],"sourcesContent":["'use client'\n\nimport { flexRender,type Row } from '@tanstack/react-table'\nimport { type VirtualItem } from '@tanstack/react-virtual'\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n getColumnMetaClasses,\n getPinnedCellStyle,\n INTERACTIVE_SELECTOR,\n isColumnEditable,\n useDataTableContext,\n} from './data-table-context'\nimport { springs } from './lib/motion'\nimport { cn } from './lib/utils'\nimport { Skeleton } from './skeleton'\nimport { TableBody, TableCell, TableRow } from './table'\n\n// ── CellEditInput ───────────────────────────────────────────────\n\n/**\n * Inline edit input rendered inside a table cell.\n * Auto-focuses, saves on Enter/blur, cancels on Escape.\n */\nfunction CellEditInput({\n initialValue,\n onSave,\n onCancel,\n}: {\n initialValue: string\n onSave: (value: string) => void\n onCancel: () => void\n}) {\n const [value, setValue] = useState(initialValue)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n inputRef.current?.focus()\n inputRef.current?.select()\n }, [])\n\n const handleSave = useCallback(() => {\n onSave(value)\n }, [onSave, value])\n\n return (\n <input\n ref={inputRef}\n type=\"text\"\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onBlur={handleSave}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n handleSave()\n } else if (e.key === 'Escape') {\n e.preventDefault()\n onCancel()\n }\n }}\n className={cn(\n 'h-ds-xs-plus w-full rounded-control',\n 'border border-accent-7 bg-surface-panel-hover',\n 'px-ds-02 text-body-sm',\n 'text-surface-fg placeholder:text-surface-fg-subtle',\n 'outline-hidden focus:border-accent-7',\n )}\n aria-label=\"Edit cell value\"\n />\n )\n}\n\n// ── DataRow ─────────────────────────────────────────────────────\n\n/** Render a single data row (shared between virtual and non-virtual paths) */\nfunction DataTableRow<TData>({ row }: { row: Row<TData> }) {\n const {\n table,\n columnPinningState,\n editable,\n editingCell,\n setEditingCell,\n onCellEdit,\n onRowClick,\n rowClassName,\n } = useDataTableContext<TData>()\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLTableRowElement>) => {\n if (!onRowClick) return\n const target = e.target as HTMLElement\n if (target.closest(INTERACTIVE_SELECTOR)) return\n onRowClick(row.original)\n },\n [onRowClick, row.original],\n )\n\n const visibleCells = row.getVisibleCells()\n\n return (\n <TableRow\n data-state={row.getIsSelected() && 'selected'}\n className={cn(\n onRowClick && 'cursor-pointer',\n rowClassName?.(row.original),\n )}\n onClick={onRowClick ? handleRowClick : undefined}\n >\n {visibleCells.map((cell) => {\n const pinned = getPinnedCellStyle(cell.column.id, columnPinningState)\n const isEditing =\n editingCell?.rowIndex === row.index &&\n editingCell?.columnId === cell.column.id\n\n return (\n <TableCell\n key={cell.id}\n className={cn(\n pinned.className,\n getColumnMetaClasses(\n cell.column.columnDef.meta as Record<string, unknown>,\n ),\n )}\n style={pinned.style}\n onDoubleClick={() => {\n if (isColumnEditable(cell.column.id, editable, table)) {\n setEditingCell({\n rowIndex: row.index,\n columnId: cell.column.id,\n })\n }\n }}\n >\n {isEditing ? (\n <CellEditInput\n initialValue={String(cell.getValue() ?? '')}\n onSave={(value) => {\n onCellEdit?.(row.index, cell.column.id, value)\n setEditingCell(null)\n }}\n onCancel={() => setEditingCell(null)}\n />\n ) : (\n flexRender(cell.column.columnDef.cell, cell.getContext())\n )}\n </TableCell>\n )\n })}\n </TableRow>\n )\n}\n\n// ── ExpandedRow ─────────────────────────────────────────────────\n\n/** Render expanded content row below the data row */\nfunction DataTableExpandedRow<TData>({ row }: { row: Row<TData> }) {\n const { allColumns, expandable, renderExpanded, virtualRows } =\n useDataTableContext<TData>()\n // Self-guarded (StatFlash pattern) — reveal collapses to an instant swap\n // without relying on a consumer MotionProvider.\n const prefersReduced = useReducedMotion()\n\n if (!expandable || !renderExpanded) return null\n\n const expanded = row.getIsExpanded()\n\n // In virtual mode the reveal is instant: the row group's height is watched by\n // the virtualizer's ResizeObserver, and an animating height would fire a\n // resize on every frame of the spring.\n if (virtualRows) {\n if (!expanded) return null\n return (\n <TableRow>\n <TableCell colSpan={allColumns.length} className=\"bg-surface-sunken p-ds-05\">\n {renderExpanded(row.original)}\n </TableCell>\n </TableRow>\n )\n }\n\n return (\n <AnimatePresence initial={false}>\n {expanded && (\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n // A recess, not a raised layer — surface-panel would vanish on a\n // card. Padding moves to the inner div so the collapsed state has\n // zero height.\n className=\"bg-surface-sunken p-0\"\n >\n <motion.div\n className=\"overflow-hidden\"\n initial={prefersReduced ? false : { height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={prefersReduced ? undefined : { height: 0, opacity: 0 }}\n transition={\n prefersReduced ? { duration: 0 } : { ...springs.smooth }\n }\n >\n <div className=\"p-ds-05\">{renderExpanded(row.original)}</div>\n </motion.div>\n </TableCell>\n </TableRow>\n )}\n </AnimatePresence>\n )\n}\n\n// ── SkeletonRows ────────────────────────────────────────────────\n\nfunction DataTableSkeletonRows({\n rowCount,\n}: {\n rowCount: number\n}) {\n const { allColumns } = useDataTableContext()\n const visibleColumnCount = allColumns.length\n const skeletonWidths = ['w-3/4', 'w-1/2', 'w-2/3', 'w-full']\n\n return (\n <TableBody>\n {Array.from({ length: rowCount }, (_, rowIdx) => (\n <TableRow key={`skeleton-${rowIdx}`}>\n {Array.from({ length: visibleColumnCount }, (_, colIdx) => {\n const colId = allColumns[colIdx]?.id ?? allColumns[colIdx]?.header\n const isSelect = colId === '_select'\n return (\n <TableCell key={`skeleton-${rowIdx}-${colIdx}`}>\n {isSelect ? (\n <Skeleton\n variant=\"text\"\n className=\"h-4 w-4\"\n animation=\"pulse\"\n />\n ) : (\n <Skeleton\n variant=\"text\"\n className={cn(\n 'h-4',\n skeletonWidths[colIdx % skeletonWidths.length],\n )}\n animation=\"pulse\"\n />\n )}\n </TableCell>\n )\n })}\n </TableRow>\n ))}\n </TableBody>\n )\n}\n\n// ── DataTableBody (orchestrates all body rendering) ─────────────\n\nexport function DataTableBody<TData>({\n loading,\n skeletonRowCount,\n noResultsText,\n emptyState,\n virtualItems,\n totalVirtualSize,\n measureRow,\n}: {\n loading?: boolean\n skeletonRowCount: number\n noResultsText?: string\n emptyState?: React.ReactNode\n virtualItems?: VirtualItem[]\n totalVirtualSize?: number\n /** `virtualizer.measureElement` — attached to each virtual row group */\n measureRow?: (node: HTMLTableSectionElement | null) => void\n}) {\n const { table, allColumns, virtualRows } = useDataTableContext<TData>()\n const rows = table.getRowModel().rows\n\n // Loading state: show skeleton rows\n if (loading) {\n return <DataTableSkeletonRows rowCount={skeletonRowCount} />\n }\n\n if (!rows.length) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n className={cn(\n 'py-ds-07 text-center',\n !emptyState && 'text-surface-fg-subtle',\n )}\n >\n {emptyState || noResultsText || 'No results.'}\n </TableCell>\n </TableRow>\n </TableBody>\n )\n }\n\n if (virtualRows && virtualItems) {\n // Each windowed row gets its OWN <tbody> (valid HTML — a table may hold any\n // number of row groups) carrying `data-index` + the virtualizer's\n // `measureElement` ref. That group is what gets measured, so a row's height\n // INCLUDES its expanded detail row and `getTotalSize()` stays truthful.\n //\n // Rows stay in normal table flow; the window is positioned by spacer row\n // groups above and below instead of absolute offsets. Two consequences worth\n // knowing: an expanded panel can never paint on top of the next row (flow\n // layout forbids it), and column widths keep tracking <thead> because the\n // cells are still real table cells.\n const firstItem = virtualItems[0]\n const lastItem = virtualItems[virtualItems.length - 1]\n const padTop = firstItem ? firstItem.start : 0\n const padBottom = lastItem ? Math.max(0, (totalVirtualSize ?? 0) - lastItem.end) : 0\n const spacerCell = (height: number) => (\n <tbody aria-hidden=\"true\">\n <tr>\n <td colSpan={allColumns.length} style={{ height, padding: 0, border: 0 }} />\n </tr>\n </tbody>\n )\n\n return (\n <>\n {padTop > 0 && spacerCell(padTop)}\n {virtualItems.map((virtualRow) => {\n const row = rows[virtualRow.index]\n const isLastRow = virtualRow.index === rows.length - 1\n return (\n <tbody\n key={row.id}\n ref={measureRow}\n data-index={virtualRow.index}\n className={cn(isLastRow && '[&_tr:last-child]:border-0')}\n >\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </tbody>\n )\n })}\n {padBottom > 0 && spacerCell(padBottom)}\n </>\n )\n }\n\n // Standard (non-virtual) rendering\n return (\n <TableBody>\n {rows.map((row) => (\n <React.Fragment key={row.id}>\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </React.Fragment>\n ))}\n </TableBody>\n )\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,EAAc,EACrB,iBACA,WACA,eAKC;CACD,IAAM,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,IAAW,EAAyB,IAAI;CAE9C,QAAgB;EAEd,AADA,EAAS,SAAS,MAAM,GACxB,EAAS,SAAS,OAAO;CAC3B,GAAG,CAAC,CAAC;CAEL,IAAM,IAAa,QAAkB;EACnC,EAAO,CAAK;CACd,GAAG,CAAC,GAAQ,CAAK,CAAC;CAElB,OACE,kBAAC,SAAD;EACE,KAAK;EACL,MAAK;EACE;EACP,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;EACxC,QAAQ;EACR,YAAY,MAAM;GAChB,AAAI,EAAE,QAAQ,WACZ,EAAE,eAAe,GACjB,EAAW,KACF,EAAE,QAAQ,aACnB,EAAE,eAAe,GACjB,EAAS;EAEb;EACA,WAAW,EACT,uCACA,iDACA,yBACA,sDACA,sCACF;EACA,cAAW;CACZ,CAAA;AAEL;AAKA,SAAS,EAAoB,EAAE,UAA4B;CACzD,IAAM,EACJ,UACA,uBACA,aACA,gBACA,mBACA,eACA,eACA,oBACE,EAA2B,GAEzB,IAAiB,GACpB,MAA6C;EACvC,MACU,EAAE,OACN,QAAA,yDAA4B,KACvC,EAAW,EAAI,QAAQ;CACzB,G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AA,CACnB,EAAA,GAHK,EAAI,EAGT,CACjB,EACQ,CAAA;AAEf"}
|
|
1
|
+
{"version":3,"file":"data-table-body.js","names":[],"sources":["../../src/ui/data-table-body.tsx"],"sourcesContent":["'use client'\n\nimport { flexRender,type Row } from '@tanstack/react-table'\nimport { type VirtualItem } from '@tanstack/react-virtual'\nimport { AnimatePresence, motion, useReducedMotion } from 'framer-motion'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport {\n getColumnMetaClasses,\n getPinnedCellStyle,\n INTERACTIVE_SELECTOR,\n isColumnEditable,\n useDataTableContext,\n} from './data-table-context'\nimport { springs } from './lib/motion'\nimport { cn } from './lib/utils'\nimport { Skeleton } from './skeleton'\nimport { TableBody, TableCell, TableRow } from './table'\n\n// ── CellEditInput ───────────────────────────────────────────────\n\n/**\n * Inline edit input rendered inside a table cell.\n * Auto-focuses, saves on Enter/blur, cancels on Escape.\n */\nfunction CellEditInput({\n initialValue,\n onSave,\n onCancel,\n}: {\n initialValue: string\n onSave: (value: string) => void\n onCancel: () => void\n}) {\n const [value, setValue] = useState(initialValue)\n const inputRef = useRef<HTMLInputElement>(null)\n\n useEffect(() => {\n inputRef.current?.focus()\n inputRef.current?.select()\n }, [])\n\n const handleSave = useCallback(() => {\n onSave(value)\n }, [onSave, value])\n\n return (\n <input\n ref={inputRef}\n type=\"text\"\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onBlur={handleSave}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n handleSave()\n } else if (e.key === 'Escape') {\n e.preventDefault()\n onCancel()\n }\n }}\n className={cn(\n 'h-ds-xs-plus w-full rounded-control',\n 'border border-accent-7 bg-surface-panel-hover',\n 'px-ds-02 text-body-sm',\n 'text-surface-fg placeholder:text-surface-fg-subtle',\n 'outline-hidden focus:border-accent-7',\n )}\n aria-label=\"Edit cell value\"\n />\n )\n}\n\n// ── DataRow ─────────────────────────────────────────────────────\n\n/** Render a single data row (shared between virtual and non-virtual paths) */\nfunction DataTableRow<TData>({ row }: { row: Row<TData> }) {\n const {\n table,\n columnPinningState,\n editable,\n editingCell,\n setEditingCell,\n onCellEdit,\n onRowClick,\n rowClassName,\n } = useDataTableContext<TData>()\n\n const handleRowClick = useCallback(\n (e: React.MouseEvent<HTMLTableRowElement>) => {\n if (!onRowClick) return\n const target = e.target as HTMLElement\n if (target.closest(INTERACTIVE_SELECTOR)) return\n onRowClick(row.original)\n },\n [onRowClick, row.original],\n )\n\n const visibleCells = row.getVisibleCells()\n\n return (\n <TableRow\n data-state={row.getIsSelected() && 'selected'}\n className={cn(\n onRowClick && 'cursor-pointer',\n rowClassName?.(row.original),\n )}\n onClick={onRowClick ? handleRowClick : undefined}\n >\n {visibleCells.map((cell) => {\n // `cell.column` is what makes the offset cumulative — without it every\n // pinned column resolves to the same edge and they stack.\n const pinned = getPinnedCellStyle(\n cell.column.id,\n columnPinningState,\n cell.column,\n )\n const isEditing =\n editingCell?.rowIndex === row.index &&\n editingCell?.columnId === cell.column.id\n\n return (\n <TableCell\n key={cell.id}\n className={cn(\n pinned.className,\n getColumnMetaClasses(\n cell.column.columnDef.meta as Record<string, unknown>,\n ),\n )}\n style={pinned.style}\n data-pinned={pinned['data-pinned']}\n onDoubleClick={() => {\n if (isColumnEditable(cell.column.id, editable, table)) {\n setEditingCell({\n rowIndex: row.index,\n columnId: cell.column.id,\n })\n }\n }}\n >\n {isEditing ? (\n <CellEditInput\n initialValue={String(cell.getValue() ?? '')}\n onSave={(value) => {\n onCellEdit?.(row.index, cell.column.id, value)\n setEditingCell(null)\n }}\n onCancel={() => setEditingCell(null)}\n />\n ) : (\n flexRender(cell.column.columnDef.cell, cell.getContext())\n )}\n </TableCell>\n )\n })}\n </TableRow>\n )\n}\n\n// ── ExpandedRow ─────────────────────────────────────────────────\n\n/** Render expanded content row below the data row */\nfunction DataTableExpandedRow<TData>({ row }: { row: Row<TData> }) {\n const { allColumns, expandable, renderExpanded, virtualRows } =\n useDataTableContext<TData>()\n // Self-guarded (StatFlash pattern) — reveal collapses to an instant swap\n // without relying on a consumer MotionProvider.\n const prefersReduced = useReducedMotion()\n\n if (!expandable || !renderExpanded) return null\n\n const expanded = row.getIsExpanded()\n\n // In virtual mode the reveal is instant: the row group's height is watched by\n // the virtualizer's ResizeObserver, and an animating height would fire a\n // resize on every frame of the spring.\n if (virtualRows) {\n if (!expanded) return null\n return (\n <TableRow>\n <TableCell colSpan={allColumns.length} className=\"bg-surface-sunken p-ds-05\">\n {renderExpanded(row.original)}\n </TableCell>\n </TableRow>\n )\n }\n\n return (\n <AnimatePresence initial={false}>\n {expanded && (\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n // A recess, not a raised layer — surface-panel would vanish on a\n // card. Padding moves to the inner div so the collapsed state has\n // zero height.\n className=\"bg-surface-sunken p-0\"\n >\n <motion.div\n className=\"overflow-hidden\"\n initial={prefersReduced ? false : { height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={prefersReduced ? undefined : { height: 0, opacity: 0 }}\n transition={\n prefersReduced ? { duration: 0 } : { ...springs.smooth }\n }\n >\n <div className=\"p-ds-05\">{renderExpanded(row.original)}</div>\n </motion.div>\n </TableCell>\n </TableRow>\n )}\n </AnimatePresence>\n )\n}\n\n// ── SkeletonRows ────────────────────────────────────────────────\n\nfunction DataTableSkeletonRows({\n rowCount,\n}: {\n rowCount: number\n}) {\n const { allColumns } = useDataTableContext()\n const visibleColumnCount = allColumns.length\n const skeletonWidths = ['w-3/4', 'w-1/2', 'w-2/3', 'w-full']\n\n return (\n <TableBody>\n {Array.from({ length: rowCount }, (_, rowIdx) => (\n <TableRow key={`skeleton-${rowIdx}`}>\n {Array.from({ length: visibleColumnCount }, (_, colIdx) => {\n const colId = allColumns[colIdx]?.id ?? allColumns[colIdx]?.header\n const isSelect = colId === '_select'\n return (\n <TableCell key={`skeleton-${rowIdx}-${colIdx}`}>\n {isSelect ? (\n <Skeleton\n variant=\"text\"\n className=\"h-4 w-4\"\n animation=\"pulse\"\n />\n ) : (\n <Skeleton\n variant=\"text\"\n className={cn(\n 'h-4',\n skeletonWidths[colIdx % skeletonWidths.length],\n )}\n animation=\"pulse\"\n />\n )}\n </TableCell>\n )\n })}\n </TableRow>\n ))}\n </TableBody>\n )\n}\n\n// ── DataTableBody (orchestrates all body rendering) ─────────────\n\nexport function DataTableBody<TData>({\n loading,\n skeletonRowCount,\n noResultsText,\n emptyState,\n virtualItems,\n totalVirtualSize,\n measureRow,\n}: {\n loading?: boolean\n skeletonRowCount: number\n noResultsText?: string\n emptyState?: React.ReactNode\n virtualItems?: VirtualItem[]\n totalVirtualSize?: number\n /** `virtualizer.measureElement` — attached to each virtual row group */\n measureRow?: (node: HTMLTableSectionElement | null) => void\n}) {\n const { table, allColumns, virtualRows } = useDataTableContext<TData>()\n const rows = table.getRowModel().rows\n\n // Loading state: show skeleton rows\n if (loading) {\n return <DataTableSkeletonRows rowCount={skeletonRowCount} />\n }\n\n if (!rows.length) {\n return (\n <TableBody>\n <TableRow>\n <TableCell\n colSpan={allColumns.length}\n className={cn(\n 'py-ds-07 text-center',\n !emptyState && 'text-surface-fg-subtle',\n )}\n >\n {emptyState || noResultsText || 'No results.'}\n </TableCell>\n </TableRow>\n </TableBody>\n )\n }\n\n if (virtualRows && virtualItems) {\n // Each windowed row gets its OWN <tbody> (valid HTML — a table may hold any\n // number of row groups) carrying `data-index` + the virtualizer's\n // `measureElement` ref. That group is what gets measured, so a row's height\n // INCLUDES its expanded detail row and `getTotalSize()` stays truthful.\n //\n // Rows stay in normal table flow; the window is positioned by spacer row\n // groups above and below instead of absolute offsets. Two consequences worth\n // knowing: an expanded panel can never paint on top of the next row (flow\n // layout forbids it), and column widths keep tracking <thead> because the\n // cells are still real table cells.\n const firstItem = virtualItems[0]\n const lastItem = virtualItems[virtualItems.length - 1]\n const padTop = firstItem ? firstItem.start : 0\n const padBottom = lastItem ? Math.max(0, (totalVirtualSize ?? 0) - lastItem.end) : 0\n const spacerCell = (height: number) => (\n <tbody aria-hidden=\"true\">\n <tr>\n <td colSpan={allColumns.length} style={{ height, padding: 0, border: 0 }} />\n </tr>\n </tbody>\n )\n\n return (\n <>\n {padTop > 0 && spacerCell(padTop)}\n {virtualItems.map((virtualRow) => {\n const row = rows[virtualRow.index]\n const isLastRow = virtualRow.index === rows.length - 1\n return (\n <tbody\n key={row.id}\n ref={measureRow}\n data-index={virtualRow.index}\n className={cn(isLastRow && '[&_tr:last-child]:border-0')}\n >\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </tbody>\n )\n })}\n {padBottom > 0 && spacerCell(padBottom)}\n </>\n )\n }\n\n // Standard (non-virtual) rendering\n return (\n <TableBody>\n {rows.map((row) => (\n <React.Fragment key={row.id}>\n <DataTableRow row={row} />\n <DataTableExpandedRow row={row} />\n </React.Fragment>\n ))}\n </TableBody>\n )\n}\n"],"mappings":";;;;;;;;;;;AAyBA,SAAS,EAAc,EACrB,iBACA,WACA,eAKC;CACD,IAAM,CAAC,GAAO,KAAY,EAAS,CAAY,GACzC,IAAW,EAAyB,IAAI;CAE9C,QAAgB;EAEd,AADA,EAAS,SAAS,MAAM,GACxB,EAAS,SAAS,OAAO;CAC3B,GAAG,CAAC,CAAC;CAEL,IAAM,IAAa,QAAkB;EACnC,EAAO,CAAK;CACd,GAAG,CAAC,GAAQ,CAAK,CAAC;CAElB,OACE,kBAAC,SAAD;EACE,KAAK;EACL,MAAK;EACE;EACP,WAAW,MAAM,EAAS,EAAE,OAAO,KAAK;EACxC,QAAQ;EACR,YAAY,MAAM;GAChB,AAAI,EAAE,QAAQ,WACZ,EAAE,eAAe,GACjB,EAAW,KACF,EAAE,QAAQ,aACnB,EAAE,eAAe,GACjB,EAAS;EAEb;EACA,WAAW,EACT,uCACA,iDACA,yBACA,sDACA,sCACF;EACA,cAAW;CACZ,CAAA;AAEL;AAKA,SAAS,EAAoB,EAAE,UAA4B;CACzD,IAAM,EACJ,UACA,uBACA,aACA,gBACA,mBACA,eACA,eACA,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EAAA,UACG,EAAK,KAAK,MACT,kBAAC,EAAM,UAAP,EAAA,UAAA,CACE,kBAAC,GAAD,EAAmB,OAAM,CAAA,GACzB,kBAAC,GAAD,EAA2B,OAAM,CAAA,CACnB,EAAA,GAHK,EAAI,EAGT,CACjB,EACQ,CAAA;AAEf"}
|
|
@@ -11,9 +11,34 @@ export interface BulkAction<TData> {
|
|
|
11
11
|
icon?: IconInput;
|
|
12
12
|
color?: 'accent' | 'error';
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
/** Show an inline "Are you sure?" step before running. */
|
|
15
|
+
requiresConfirmation?: boolean;
|
|
16
|
+
/** Overrides the default "Are you sure?" prompt. */
|
|
17
|
+
confirmMessage?: string;
|
|
18
|
+
/** Spinner on this action while its work is in flight. */
|
|
19
|
+
loading?: boolean;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
|
-
*
|
|
22
|
+
* DataTable's bulk-action bar. An adapter over the shared `BulkActionBar`
|
|
23
|
+
* rather than a second implementation.
|
|
24
|
+
*
|
|
25
|
+
* It used to be a parallel, thinner copy — and the copy drifted in four ways
|
|
26
|
+
* inside one release cycle (raw `bottom-6` instead of the spacing token, a
|
|
27
|
+
* non-RTL `left-1/2`, `outline` against the repo's documented soft-over-outline
|
|
28
|
+
* preference, and a bare `<button>` where `Button` belonged). Worse, it
|
|
29
|
+
* declared `role="toolbar"` while implementing plain tab stops, so it told
|
|
30
|
+
* screen-reader users to expect arrow-key navigation and one tab stop, and
|
|
31
|
+
* delivered neither. That is the class of bug a single implementation cannot
|
|
32
|
+
* have, and it was sitting on the higher-traffic path.
|
|
33
|
+
*
|
|
34
|
+
* The adapter is deliberately thin. Everything DataTable-specific stays here:
|
|
35
|
+
*
|
|
36
|
+
* - `onClick(selectedRows)` keeps its row payload, closed over per render. The
|
|
37
|
+
* shared bar's actions take no argument, and changing DataTable's signature
|
|
38
|
+
* to match would have broken every consumer for no benefit.
|
|
39
|
+
* - Clearing still calls `table.resetRowSelection()` itself, so consumers do
|
|
40
|
+
* not have to wire it.
|
|
41
|
+
*
|
|
17
42
|
* Internal — not exported to consumers.
|
|
18
43
|
*/
|
|
19
44
|
export declare function DataTableBulkActions<TData>({ table, selectedRows, bulkActions, position, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-bulk-actions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-bulk-actions.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEjD,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE7D,yDAAyD;AACzD,MAAM,WAAW,UAAU,CAAC,KAAK;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,IAAI,CAAA;IACxC,uEAAuE;IACvE,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,EAC1C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAmB,GACpB,EAAE;IACD,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACnB,YAAY,EAAE,KAAK,EAAE,CAAA;IACrB,WAAW,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAA;IAChC,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CAC/B,qBAyBA"}
|
|
@@ -1,51 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import "react";
|
|
6
|
-
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
7
|
-
import { IconX as a } from "@tabler/icons-react";
|
|
2
|
+
import { BulkActionBar as e } from "./bulk-action-bar.js";
|
|
3
|
+
import t from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
8
5
|
//#region src/ui/data-table-bulk-actions.tsx
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"aria-hidden": "true"
|
|
27
|
-
}),
|
|
28
|
-
l.map((e) => /* @__PURE__ */ r(n, {
|
|
29
|
-
size: "sm",
|
|
30
|
-
variant: e.color === "error" ? "solid" : "outline",
|
|
31
|
-
color: e.color === "error" ? "error" : void 0,
|
|
32
|
-
disabled: e.disabled,
|
|
33
|
-
startIcon: e.icon,
|
|
34
|
-
onClick: () => e.onClick(c),
|
|
35
|
-
children: e.label
|
|
36
|
-
}, e.label)),
|
|
37
|
-
/* @__PURE__ */ r("button", {
|
|
38
|
-
type: "button",
|
|
39
|
-
onClick: () => s.resetRowSelection(),
|
|
40
|
-
"aria-label": "Clear selection",
|
|
41
|
-
className: e("flex items-center justify-center p-ds-01", "rounded-control-inner hover:bg-surface-panel-hover transition-colors", "text-surface-fg-muted hover:text-surface-fg"),
|
|
42
|
-
children: /* @__PURE__ */ r(t, {
|
|
43
|
-
icon: a,
|
|
44
|
-
size: "sm"
|
|
45
|
-
})
|
|
46
|
-
})
|
|
47
|
-
]
|
|
6
|
+
function r({ table: r, selectedRows: i, bulkActions: a, position: o = "bottom" }) {
|
|
7
|
+
let s = t.useMemo(() => a.map((e) => ({
|
|
8
|
+
label: e.label,
|
|
9
|
+
icon: e.icon,
|
|
10
|
+
color: e.color,
|
|
11
|
+
disabled: e.disabled,
|
|
12
|
+
loading: e.loading,
|
|
13
|
+
requiresConfirmation: e.requiresConfirmation,
|
|
14
|
+
confirmMessage: e.confirmMessage,
|
|
15
|
+
onClick: () => e.onClick(i)
|
|
16
|
+
})), [a, i]);
|
|
17
|
+
return /* @__PURE__ */ n(e, {
|
|
18
|
+
show: !0,
|
|
19
|
+
count: i.length,
|
|
20
|
+
actions: s,
|
|
21
|
+
placement: o,
|
|
22
|
+
onClearSelection: () => r.resetRowSelection()
|
|
48
23
|
});
|
|
49
24
|
}
|
|
50
25
|
//#endregion
|
|
51
|
-
export {
|
|
26
|
+
export { r as DataTableBulkActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-bulk-actions.js","names":[],"sources":["../../src/ui/data-table-bulk-actions.tsx"],"sourcesContent":["'use client'\n\nimport {
|
|
1
|
+
{"version":3,"file":"data-table-bulk-actions.js","names":[],"sources":["../../src/ui/data-table-bulk-actions.tsx"],"sourcesContent":["'use client'\n\nimport { type Table } from '@tanstack/react-table'\nimport React from 'react'\n\nimport { BulkActionBar,type BulkActionBarAction } from './bulk-action-bar'\nimport type { IconInput } from './lib/icon-input'\n\n/** Where the floating bulk-action bar renders. @default 'bottom' */\nexport type BulkActionsPosition = 'bottom' | 'top' | 'inline'\n\n/** Bulk action definition for the floating action bar */\nexport interface BulkAction<TData> {\n label: string\n onClick: (selectedRows: TData[]) => void\n /** Icon rendered before the label — useful for compact/mobile bars. */\n icon?: IconInput\n color?: 'accent' | 'error'\n disabled?: boolean\n /** Show an inline \"Are you sure?\" step before running. */\n requiresConfirmation?: boolean\n /** Overrides the default \"Are you sure?\" prompt. */\n confirmMessage?: string\n /** Spinner on this action while its work is in flight. */\n loading?: boolean\n}\n\n/**\n * DataTable's bulk-action bar. An adapter over the shared `BulkActionBar`\n * rather than a second implementation.\n *\n * It used to be a parallel, thinner copy — and the copy drifted in four ways\n * inside one release cycle (raw `bottom-6` instead of the spacing token, a\n * non-RTL `left-1/2`, `outline` against the repo's documented soft-over-outline\n * preference, and a bare `<button>` where `Button` belonged). Worse, it\n * declared `role=\"toolbar\"` while implementing plain tab stops, so it told\n * screen-reader users to expect arrow-key navigation and one tab stop, and\n * delivered neither. That is the class of bug a single implementation cannot\n * have, and it was sitting on the higher-traffic path.\n *\n * The adapter is deliberately thin. Everything DataTable-specific stays here:\n *\n * - `onClick(selectedRows)` keeps its row payload, closed over per render. The\n * shared bar's actions take no argument, and changing DataTable's signature\n * to match would have broken every consumer for no benefit.\n * - Clearing still calls `table.resetRowSelection()` itself, so consumers do\n * not have to wire it.\n *\n * Internal — not exported to consumers.\n */\nexport function DataTableBulkActions<TData>({\n table,\n selectedRows,\n bulkActions,\n position = 'bottom',\n}: {\n table: Table<TData>\n selectedRows: TData[]\n bulkActions: BulkAction<TData>[]\n position?: BulkActionsPosition\n}) {\n const actions = React.useMemo<BulkActionBarAction[]>(\n () =>\n bulkActions.map((a) => ({\n label: a.label,\n icon: a.icon,\n color: a.color,\n disabled: a.disabled,\n loading: a.loading,\n requiresConfirmation: a.requiresConfirmation,\n confirmMessage: a.confirmMessage,\n onClick: () => a.onClick(selectedRows),\n })),\n [bulkActions, selectedRows],\n )\n\n return (\n <BulkActionBar\n show\n count={selectedRows.length}\n actions={actions}\n placement={position}\n onClearSelection={() => table.resetRowSelection()}\n />\n )\n}\n"],"mappings":";;;;;AAkDA,SAAgB,EAA4B,EAC1C,UACA,iBACA,gBACA,cAAW,YAMV;CACD,IAAM,IAAU,EAAM,cAElB,EAAY,KAAK,OAAO;EACtB,OAAO,EAAE;EACT,MAAM,EAAE;EACR,OAAO,EAAE;EACT,UAAU,EAAE;EACZ,SAAS,EAAE;EACX,sBAAsB,EAAE;EACxB,gBAAgB,EAAE;EAClB,eAAe,EAAE,QAAQ,CAAY;CACvC,EAAE,GACJ,CAAC,GAAa,CAAY,CAC5B;CAEA,OACE,kBAAC,GAAD;EACE,MAAA;EACA,OAAO,EAAa;EACX;EACT,WAAW;EACX,wBAAwB,EAAM,kBAAkB;CACjD,CAAA;AAEL"}
|
|
@@ -51,10 +51,44 @@ export declare function DataTableProvider<TData>({ children, value, }: {
|
|
|
51
51
|
value: DataTableContextValue<TData>;
|
|
52
52
|
}): React.JSX.Element;
|
|
53
53
|
export declare function useDataTableContext<TData = unknown>(): DataTableContextValue<TData>;
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Compute sticky positioning styles for pinned columns.
|
|
56
|
+
*
|
|
57
|
+
* `column` is optional so existing callers keep working, but WITHOUT it every
|
|
58
|
+
* pinned column resolves to the same edge. Pass it.
|
|
59
|
+
*
|
|
60
|
+
* Three things were wrong here and all three had the same root: the function
|
|
61
|
+
* knew a column's *identity* but nothing about its *geometry*.
|
|
62
|
+
*
|
|
63
|
+
* - The offset was hardcoded to 0, so two left-pinned columns stacked on top of
|
|
64
|
+
* each other. `leftIndex` was computed and then thrown away. TanStack already
|
|
65
|
+
* knows the cumulative width — `getStart('left')` / `getAfter('right')` — so
|
|
66
|
+
* the fix is to ask it rather than to sum widths here.
|
|
67
|
+
* - The cell painted `bg-surface-panel` unconditionally, which is right for
|
|
68
|
+
* occluding scrolled content underneath and wrong for everything else: a
|
|
69
|
+
* selected row's pinned cell stayed panel-coloured and a striped row's showed
|
|
70
|
+
* a white notch. It now inherits the row's background and only falls back to
|
|
71
|
+
* the panel colour when the row has none of its own (`bg-inherit`), so the
|
|
72
|
+
* occlusion still works.
|
|
73
|
+
* - There was no edge, so a pinned column was invisible unscrolled and had
|
|
74
|
+
* content slide under it with no seam when scrolled. The last left-pinned and
|
|
75
|
+
* first right-pinned column now carry a hairline on the boundary.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getPinnedCellStyle(columnId: string, columnPinningState: ColumnPinningState, column?: {
|
|
78
|
+
getStart: (p?: 'left') => number;
|
|
79
|
+
getAfter: (p?: 'right') => number;
|
|
80
|
+
}): {
|
|
56
81
|
className: string;
|
|
57
82
|
style: React.CSSProperties;
|
|
83
|
+
'data-pinned': "left";
|
|
84
|
+
} | {
|
|
85
|
+
className: string;
|
|
86
|
+
style: React.CSSProperties;
|
|
87
|
+
'data-pinned': "right";
|
|
88
|
+
} | {
|
|
89
|
+
className: string;
|
|
90
|
+
style: React.CSSProperties;
|
|
91
|
+
'data-pinned': undefined;
|
|
58
92
|
};
|
|
59
93
|
/** Check if a column allows editing */
|
|
60
94
|
export declare function isColumnEditable<TData>(columnId: string, editable: boolean, table: Table<TData>): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table-context.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"data-table-context.d.ts","sourceRoot":"","sources":["../../src/ui/data-table-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAA;AAIvE,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAS3E;A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AA;CAClD;AAID,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,EACvC,QAAQ,EACR,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,EAAE,qBAAqB,CAAC,KAAK,CAAC,CAAA;CACpC,qBAMA;AAED,wBAAgB,mBAAmB,CAAC,KAAK,GAAG,OAAO,KAGnC,qBAAqB,CAAC,KAAK,CAAC,CAC3C;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,kBAAkB,EACtC,MAAM,CAAC,EAAE;IAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,CAAA;CAAE;;WA0BnB,KAAK,CAAC,aAAa;;;;WAWjB,KAAK,CAAC,aAAa;;;;WAMnE,KAAK,CAAC,aAAa;;EAGnC;AAED,uCAAuC;AACvC,wBAAgB,gBAAgB,CAAC,KAAK,EACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAClB,OAAO,CAYT"}
|
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import e from "
|
|
3
|
-
import
|
|
2
|
+
import { cn as e } from "./lib/utils.js";
|
|
3
|
+
import t from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
5
|
//#region src/ui/data-table-context.tsx
|
|
5
|
-
function
|
|
6
|
+
function r(e) {
|
|
6
7
|
if (!e) return "";
|
|
7
8
|
let t = [];
|
|
8
9
|
return e.align === "right" && t.push("text-right tabular-nums"), e.align === "center" && t.push("text-center"), e.hideBelow === "sm" && t.push("hidden sm:table-cell"), e.hideBelow === "md" && t.push("hidden md:table-cell"), e.hideBelow === "lg" && t.push("hidden lg:table-cell"), t.join(" ");
|
|
9
10
|
}
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
value:
|
|
11
|
+
var i = "button, a, input, select, textarea, [role=\"checkbox\"]", a = t.createContext(null);
|
|
12
|
+
function o({ children: e, value: t }) {
|
|
13
|
+
return /* @__PURE__ */ n(a.Provider, {
|
|
14
|
+
value: t,
|
|
14
15
|
children: e
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
if (!
|
|
20
|
-
return
|
|
18
|
+
function s() {
|
|
19
|
+
let e = t.useContext(a);
|
|
20
|
+
if (!e) throw Error("useDataTableContext must be used within DataTableProvider");
|
|
21
|
+
return e;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
let { left:
|
|
24
|
-
return
|
|
23
|
+
function c(t, n, r) {
|
|
24
|
+
let { left: i = [], right: a = [] } = n, o = i.indexOf(t), s = a.indexOf(t), c = e("sticky z-raised bg-surface-panel", "group-hover/row:bg-surface-panel-hover", "group-data-[state=selected]/row:bg-accent-4", "group-data-[state=selected]/row:group-hover/row:bg-accent-5");
|
|
25
|
+
return o === -1 ? s === -1 ? {
|
|
25
26
|
className: "",
|
|
26
|
-
style: {}
|
|
27
|
+
style: {},
|
|
28
|
+
"data-pinned": void 0
|
|
27
29
|
} : {
|
|
28
|
-
className: "
|
|
29
|
-
style: { right: 0 }
|
|
30
|
+
className: e(c, s === 0 && "border-l border-surface-border"),
|
|
31
|
+
style: { right: r ? r.getAfter("right") : 0 },
|
|
32
|
+
"data-pinned": "right"
|
|
30
33
|
} : {
|
|
31
|
-
className: "
|
|
32
|
-
style: { left: 0 }
|
|
34
|
+
className: e(c, o === i.length - 1 && "border-r border-surface-border"),
|
|
35
|
+
style: { left: r ? r.getStart("left") : 0 },
|
|
36
|
+
"data-pinned": "left"
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
function
|
|
39
|
+
function l(e, t, n) {
|
|
36
40
|
if (!t || e === "_select" || e === "_expand") return !1;
|
|
37
41
|
let r = n.getColumn(e);
|
|
38
42
|
return !(!r || r.columnDef.meta?.enableEditing === !1);
|
|
39
43
|
}
|
|
40
44
|
//#endregion
|
|
41
|
-
export {
|
|
45
|
+
export { o as DataTableProvider, i as INTERACTIVE_SELECTOR, r as getColumnMetaClasses, c as getPinnedCellStyle, l as isColumnEditable, s as useDataTableContext };
|