@mastra/playground-ui 68.0.0-alpha.3 → 68.0.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.
Files changed (163) hide show
  1. package/dist/{FilterBar-CQl04O6t.cjs → FilterBar-BSP2UTjc.cjs} +2 -2
  2. package/dist/{FilterBar-CQl04O6t.cjs.map → FilterBar-BSP2UTjc.cjs.map} +1 -1
  3. package/dist/{FilterBar-BgW2dqRQ.js → FilterBar-PSQ1OwqH.js} +2 -2
  4. package/dist/{FilterBar-BgW2dqRQ.js.map → FilterBar-PSQ1OwqH.js.map} +1 -1
  5. package/dist/{MetricsCard-CEB-f2sv.cjs → MetricsCard-BEwiS7Pe.cjs} +8 -8
  6. package/dist/MetricsCard-BEwiS7Pe.cjs.map +1 -0
  7. package/dist/{MetricsCard-M8awJ2B_.js → MetricsCard-ua6C6b8a.js} +10 -10
  8. package/dist/MetricsCard-ua6C6b8a.js.map +1 -0
  9. package/dist/{MetricsLineChart-BhHoduO0.js → MetricsLineChart-4SwxBbQx.js} +14 -3
  10. package/dist/MetricsLineChart-4SwxBbQx.js.map +1 -0
  11. package/dist/{MetricsLineChart-CjBm4IXu.cjs → MetricsLineChart-tZxsauau.cjs} +13 -2
  12. package/dist/MetricsLineChart-tZxsauau.cjs.map +1 -0
  13. package/dist/{MetricsStackedBarChart-BdMlKv6G.cjs → MetricsStackedBarChart-CDLE76IB.cjs} +2 -2
  14. package/dist/{MetricsStackedBarChart-BdMlKv6G.cjs.map → MetricsStackedBarChart-CDLE76IB.cjs.map} +1 -1
  15. package/dist/{MetricsStackedBarChart-BRuA6MTE.js → MetricsStackedBarChart-D2QyS4-z.js} +2 -2
  16. package/dist/{MetricsStackedBarChart-BRuA6MTE.js.map → MetricsStackedBarChart-D2QyS4-z.js.map} +1 -1
  17. package/dist/components/DateTimeRangePicker.cjs.js +1 -1
  18. package/dist/components/DateTimeRangePicker.es.js +1 -1
  19. package/dist/components/FilterBar.cjs.js +2 -2
  20. package/dist/components/FilterBar.es.js +2 -2
  21. package/dist/components/MetricsCard.cjs.js +1 -1
  22. package/dist/components/MetricsCard.es.js +1 -1
  23. package/dist/components/MetricsLineChart.cjs.js +1 -1
  24. package/dist/components/MetricsLineChart.es.js +1 -1
  25. package/dist/components/MetricsStackedBarChart.cjs.js +1 -1
  26. package/dist/components/MetricsStackedBarChart.es.js +1 -1
  27. package/dist/{date-time-range-picker-CTt7Od0P.cjs → date-time-range-picker-CWGjoR3j.cjs} +40 -13
  28. package/dist/date-time-range-picker-CWGjoR3j.cjs.map +1 -0
  29. package/dist/{date-time-range-picker-DKh1K9Iy.js → date-time-range-picker-CdSiXwB4.js} +40 -13
  30. package/dist/date-time-range-picker-CdSiXwB4.js.map +1 -0
  31. package/dist/domains/chat/messages/message-row.cjs.js +1 -1
  32. package/dist/domains/chat/messages/message-row.es.js +1 -1
  33. package/dist/domains/chat/tools/badges/agent-badge-wrapper.cjs.js +1 -1
  34. package/dist/domains/chat/tools/badges/agent-badge-wrapper.es.js +1 -1
  35. package/dist/domains/chat/tools/badges/agent-badge.cjs.js +1 -1
  36. package/dist/domains/chat/tools/badges/agent-badge.es.js +1 -1
  37. package/dist/domains/chat/tools/connect-prompt-tool.cjs.js +79 -4
  38. package/dist/domains/chat/tools/connect-prompt-tool.cjs.js.map +1 -1
  39. package/dist/domains/chat/tools/connect-prompt-tool.es.js +79 -4
  40. package/dist/domains/chat/tools/connect-prompt-tool.es.js.map +1 -1
  41. package/dist/domains/chat/tools/mcp-input-request-tool.cjs.js +10 -12
  42. package/dist/domains/chat/tools/mcp-input-request-tool.cjs.js.map +1 -1
  43. package/dist/domains/chat/tools/mcp-input-request-tool.es.js +10 -12
  44. package/dist/domains/chat/tools/mcp-input-request-tool.es.js.map +1 -1
  45. package/dist/domains/chat/tools/tool-card-kind.cjs.js +1 -1
  46. package/dist/domains/chat/tools/tool-card-kind.cjs.js.map +1 -1
  47. package/dist/domains/chat/tools/tool-card-kind.es.js +1 -1
  48. package/dist/domains/chat/tools/tool-card-kind.es.js.map +1 -1
  49. package/dist/domains/chat/tools/tool-card.cjs.js +1 -1
  50. package/dist/domains/chat/tools/tool-card.es.js +1 -1
  51. package/dist/domains/connect/types.cjs.js.map +1 -1
  52. package/dist/domains/connect/types.es.js.map +1 -1
  53. package/dist/domains/connect/use-user-connect.cjs.js +19 -2
  54. package/dist/domains/connect/use-user-connect.cjs.js.map +1 -1
  55. package/dist/domains/connect/use-user-connect.es.js +19 -2
  56. package/dist/domains/connect/use-user-connect.es.js.map +1 -1
  57. package/dist/domains/dashboards/components/dashboard-renderer.cjs.js +4 -3
  58. package/dist/domains/dashboards/components/dashboard-renderer.cjs.js.map +1 -1
  59. package/dist/domains/dashboards/components/dashboard-renderer.es.js +4 -3
  60. package/dist/domains/dashboards/components/dashboard-renderer.es.js.map +1 -1
  61. package/dist/domains/dashboards/components/widget-chrome.cjs.js +1 -1
  62. package/dist/domains/dashboards/components/widget-chrome.es.js +1 -1
  63. package/dist/domains/dashboards/components/widget-error.cjs.js +1 -1
  64. package/dist/domains/dashboards/components/widget-error.es.js +1 -1
  65. package/dist/domains/dashboards/hooks/use-widget-views.cjs.js +4 -3
  66. package/dist/domains/dashboards/hooks/use-widget-views.cjs.js.map +1 -1
  67. package/dist/domains/dashboards/hooks/use-widget-views.es.js +4 -3
  68. package/dist/domains/dashboards/hooks/use-widget-views.es.js.map +1 -1
  69. package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js +9 -6
  70. package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js.map +1 -1
  71. package/dist/domains/dashboards/kinds/scores/scores-widget.es.js +9 -6
  72. package/dist/domains/dashboards/kinds/scores/scores-widget.es.js.map +1 -1
  73. package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js +2 -2
  74. package/dist/domains/dashboards/kinds/table/table-tabs.es.js +2 -2
  75. package/dist/domains/dashboards/kinds/table/table-widget.cjs.js +1 -1
  76. package/dist/domains/dashboards/kinds/table/table-widget.es.js +1 -1
  77. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js +6 -5
  78. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js.map +1 -1
  79. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js +6 -5
  80. package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js.map +1 -1
  81. package/dist/domains/dashboards/lib/chrome.cjs.js +9 -2
  82. package/dist/domains/dashboards/lib/chrome.cjs.js.map +1 -1
  83. package/dist/domains/dashboards/lib/chrome.es.js +9 -2
  84. package/dist/domains/dashboards/lib/chrome.es.js.map +1 -1
  85. package/dist/domains/dashboards/widget-kind.cjs.js.map +1 -1
  86. package/dist/domains/dashboards/widget-kind.es.js.map +1 -1
  87. package/dist/domains/metrics/components/agent-runs-card.cjs.js +3 -3
  88. package/dist/domains/metrics/components/agent-runs-card.es.js +3 -3
  89. package/dist/domains/metrics/components/breakdown/breakdown-tab-body.cjs.js +1 -1
  90. package/dist/domains/metrics/components/breakdown/breakdown-tab-body.es.js +1 -1
  91. package/dist/domains/metrics/components/breakdown-card.cjs.js +1 -1
  92. package/dist/domains/metrics/components/breakdown-card.es.js +1 -1
  93. package/dist/domains/metrics/components/chart-area.cjs.js +1 -1
  94. package/dist/domains/metrics/components/chart-area.es.js +1 -1
  95. package/dist/domains/metrics/components/chart-card-error.cjs.js +1 -1
  96. package/dist/domains/metrics/components/chart-card-error.es.js +1 -1
  97. package/dist/domains/metrics/components/chart-card.cjs.js +1 -1
  98. package/dist/domains/metrics/components/chart-card.es.js +1 -1
  99. package/dist/domains/metrics/components/date-range-selector.cjs.js +1 -1
  100. package/dist/domains/metrics/components/date-range-selector.es.js +1 -1
  101. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js +3 -2
  102. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js.map +1 -1
  103. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js +3 -2
  104. package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js.map +1 -1
  105. package/dist/domains/metrics/components/failure-rate-card.cjs.js +3 -2
  106. package/dist/domains/metrics/components/failure-rate-card.cjs.js.map +1 -1
  107. package/dist/domains/metrics/components/failure-rate-card.es.js +3 -2
  108. package/dist/domains/metrics/components/failure-rate-card.es.js.map +1 -1
  109. package/dist/domains/metrics/components/latency-card.cjs.js +3 -2
  110. package/dist/domains/metrics/components/latency-card.cjs.js.map +1 -1
  111. package/dist/domains/metrics/components/latency-card.es.js +3 -2
  112. package/dist/domains/metrics/components/latency-card.es.js.map +1 -1
  113. package/dist/domains/metrics/components/metrics-time-range-chip.cjs.js +1 -1
  114. package/dist/domains/metrics/components/metrics-time-range-chip.es.js +1 -1
  115. package/dist/domains/metrics/components/scores-card.cjs.js +2 -1
  116. package/dist/domains/metrics/components/scores-card.cjs.js.map +1 -1
  117. package/dist/domains/metrics/components/scores-card.es.js +2 -1
  118. package/dist/domains/metrics/components/scores-card.es.js.map +1 -1
  119. package/dist/domains/metrics/components/token-usage-card.cjs.js +3 -3
  120. package/dist/domains/metrics/components/token-usage-card.es.js +3 -3
  121. package/dist/domains/metrics/components/trace-aggregate-card.cjs.js +1 -1
  122. package/dist/domains/metrics/components/trace-aggregate-card.es.js +1 -1
  123. package/dist/domains/observability/components/observability-histogram.cjs.js +1 -1
  124. package/dist/domains/observability/components/observability-histogram.es.js +1 -1
  125. package/dist/domains/spans/components/spans-filter-bar.cjs.js +2 -2
  126. package/dist/domains/spans/components/spans-filter-bar.es.js +2 -2
  127. package/dist/domains/spans/hooks/use-spans-filter-bar.cjs.js +1 -1
  128. package/dist/domains/spans/hooks/use-spans-filter-bar.es.js +1 -1
  129. package/dist/domains/threads/components/threads-filter-bar.cjs.js +2 -2
  130. package/dist/domains/threads/components/threads-filter-bar.es.js +2 -2
  131. package/dist/domains/threads/hooks/use-threads-filter-bar.cjs.js +1 -1
  132. package/dist/domains/threads/hooks/use-threads-filter-bar.es.js +1 -1
  133. package/dist/domains/traces/components/traces-explorer/traces-explorer-filter-bar.cjs.js +2 -2
  134. package/dist/domains/traces/components/traces-explorer/traces-explorer-filter-bar.es.js +2 -2
  135. package/dist/domains/traces/components/traces-explorer/use-traces-filter-bar.cjs.js +1 -1
  136. package/dist/domains/traces/components/traces-explorer/use-traces-filter-bar.es.js +1 -1
  137. package/dist/{filter-bar-time-range-mg9JeYue.js → filter-bar-time-range-qlV8p7hp.js} +2 -2
  138. package/dist/{filter-bar-time-range-mg9JeYue.js.map → filter-bar-time-range-qlV8p7hp.js.map} +1 -1
  139. package/dist/{filter-bar-time-range-BA-pXMlo.cjs → filter-bar-time-range-zdM024JD.cjs} +2 -2
  140. package/dist/{filter-bar-time-range-BA-pXMlo.cjs.map → filter-bar-time-range-zdM024JD.cjs.map} +1 -1
  141. package/dist/src/domains/chat/tools/connect-prompt-tool.d.ts +10 -1
  142. package/dist/src/domains/connect/types.d.ts +16 -0
  143. package/dist/src/domains/dashboards/components/dashboard-renderer.d.ts +4 -2
  144. package/dist/src/domains/dashboards/hooks/use-widget-views.d.ts +4 -3
  145. package/dist/src/domains/dashboards/index.d.ts +1 -1
  146. package/dist/src/domains/dashboards/kinds/scores/scores-widget.d.ts +1 -1
  147. package/dist/src/domains/dashboards/lib/chrome.d.ts +6 -4
  148. package/dist/src/domains/dashboards/widget-kind.d.ts +12 -0
  149. package/dist/src/ds/components/DateTimeRangePicker/date-time-range-picker.d.ts +12 -1
  150. package/dist/src/ds/components/MetricsCard/metrics-card-headline.d.ts +1 -1
  151. package/dist/src/ds/components/MetricsLineChart/metrics-line-chart.d.ts +8 -0
  152. package/dist/style.css +4 -0
  153. package/dist/{tool-card-rxhTDpk_.cjs → tool-card-BOLXeKIp.cjs} +4 -1
  154. package/dist/{tool-card-rxhTDpk_.cjs.map → tool-card-BOLXeKIp.cjs.map} +1 -1
  155. package/dist/{tool-card-toDgoZzJ.js → tool-card-HZ5bm7ue.js} +4 -1
  156. package/dist/{tool-card-toDgoZzJ.js.map → tool-card-HZ5bm7ue.js.map} +1 -1
  157. package/package.json +9 -9
  158. package/dist/MetricsCard-CEB-f2sv.cjs.map +0 -1
  159. package/dist/MetricsCard-M8awJ2B_.js.map +0 -1
  160. package/dist/MetricsLineChart-BhHoduO0.js.map +0 -1
  161. package/dist/MetricsLineChart-CjBm4IXu.cjs.map +0 -1
  162. package/dist/date-time-range-picker-CTt7Od0P.cjs.map +0 -1
  163. package/dist/date-time-range-picker-DKh1K9Iy.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBar-BgW2dqRQ.js","names":["_Fragment","_Fragment"],"sources":["../src/ds/components/FilterBar/filter-bar-input.tsx","../src/ds/components/FilterBar/use-settle-on-leave.ts","../src/ds/components/FilterBar/filter-bar-group-editor.tsx","../src/ds/components/FilterBar/filter-bar-advanced-chip.tsx","../src/ds/components/FilterBar/filter-bar-clear.tsx","../src/ds/components/FilterBar/filter-bar.tsx","../src/ds/components/FilterBar/default-operators.ts"],"sourcesContent":["import type { BaseUIEvent } from '@base-ui/react/types';\nimport { BracesIcon, ListFilterIcon } from 'lucide-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport { flushSync } from 'react-dom';\nimport { FILTER_BAR_CONTROL_SIZE, FilterBarFieldLabel, alwaysHighlightProps } from './filter-bar-chip';\nimport { useFilterBarContext } from './filter-bar-context';\nimport { FilterBarOptionLabel, FilterBarOptionList } from './filter-bar-option-list';\nimport { findGroup } from './filter-bar-tree';\nimport { matchesQueryFilter } from './match-query';\nimport type { FilterBarDraft, FilterBarField, FilterBarOperator, FilterBarOption, FilterBarValue } from './types';\nimport { parseFieldValue } from './types';\nimport { useValueStep } from './use-value-step';\nimport { Button } from '@/ds/components/Button/Button';\nimport { ComboboxPrimitive, comboboxStyles } from '@/ds/components/Combobox';\nimport { comboboxTriggerClass } from '@/ds/components/Combobox/combobox-styles';\nimport { Kbd } from '@/ds/components/Kbd/kbd';\nimport { Txt } from '@/ds/components/Txt';\nimport { FLOATING_POSITION_METHOD } from '@/ds/primitives/floating';\nimport { inputFocusBorderWithin, unstyledFormElementStyle } from '@/ds/primitives/form-element';\nimport { MENU_SIDE_OFFSET } from '@/ds/primitives/menu-item';\nimport { passwordManagerOptOutProps } from '@/ds/primitives/password-manager-autofill';\nimport { usePortalContainer } from '@/ds/primitives/portal-container';\nimport { useIsApplePlatform } from '@/hooks/use-keyboard-shortcut-label';\nimport { cn } from '@/lib/utils';\n\ntype Step = 'field' | 'operator' | 'value';\n\ntype Item = FilterBarField | FilterBarOperator | FilterBarOption;\n\nconst getItemLabel = (item: Item) => ('label' in item && item.label ? item.label : 'value' in item ? item.value : '');\n\nconst EMPTY_ITEMS: readonly Item[] = [];\n/** Pinned last entry of the field list that spawns an advanced filter (an `or` group) instead of a filter. */\nconst ADVANCED_FIELD_ID = '__filter-bar-advanced__';\nconst ADVANCED_FIELD: FilterBarField = {\n id: ADVANCED_FIELD_ID,\n label: 'Advanced filter…',\n icon: BracesIcon,\n operators: [],\n};\n\nexport type FilterBarInputProps = {\n placeholder?: string;\n className?: string;\n 'aria-label'?: string;\n /**\n * Group this instance commits into; omit for the bar's own input. Only the instance whose\n * `groupId` matches the provider's `inputTarget` renders, so a single input is ever mounted.\n */\n groupId?: string;\n /** Called when Escape is pressed on an empty query inside a group, after the input hands back to the bar. */\n onLeave?: () => void;\n};\n\n/**\n * Typeahead entry point: type to pick a field, then an operator, then a value.\n * Focus never leaves the input; the popup is driven with the arrow keys.\n */\nexport function FilterBarInput(props: FilterBarInputProps) {\n const ctx = useFilterBarContext();\n if (ctx.inputTarget !== props.groupId) return null;\n return <FilterBarInputImpl {...props} />;\n}\n\nfunction FilterBarInputImpl({\n placeholder = 'Filter',\n className,\n 'aria-label': ariaLabel = 'Add filter',\n groupId,\n onLeave,\n}: FilterBarInputProps) {\n const ctx = useFilterBarContext();\n const container = usePortalContainer();\n const inputRef = useRef<HTMLInputElement | null>(null);\n const anchorRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState<Item | null>(null);\n const [emptyForStepChange, setEmptyForStepChange] = useState(false);\n const modEnterLabel = useIsApplePlatform() ? '⌘↵' : 'Ctrl ↵';\n\n // The draft lives in the provider so the chip list can render it; the step follows from it.\n const { draft, setDraft: setDraftState, commitDraft } = ctx;\n const step: Step = !draft ? 'field' : !draft.operatorId ? 'operator' : 'value';\n const field = draft ? ctx.getField(draft.fieldId) : undefined;\n const fieldOperators = useMemo(() => (field ? ctx.getFieldOperators(field) : []), [ctx, field]);\n const operator = draft?.operatorId\n ? (fieldOperators.find(o => o.id === draft.operatorId) ?? ctx.getOperator(draft.operatorId))\n : undefined;\n // The advanced option lives in the bar only; inside a popover, nesting is the editor's `+ Group`.\n const offerAdvanced = ctx.groupsEnabled && groupId === undefined;\n const visibleFields = useMemo(() => {\n const fields = ctx.fields.filter(f => !f.hidden);\n return offerAdvanced ? [...fields, ADVANCED_FIELD] : fields;\n }, [ctx.fields, offerAdvanced]);\n const targetGroup = groupId ? findGroup(ctx.expression, groupId) : undefined;\n\n // A group's input mounts on demand (see `openGroupInput`) and takes focus itself.\n useEffect(() => {\n if (groupId) inputRef.current?.focus();\n }, [groupId]);\n\n // Base UI owns the highlight index and keeps it when the list content changes, so a row\n // reached with ArrowDown would carry over into the step that follows. An empty list committed\n // first drops that index, and `autoHighlight` re-anchors on the first row of the new step.\n const withHighlightReset = useCallback((change: () => void) => {\n flushSync(() => setEmptyForStepChange(true));\n change();\n setEmptyForStepChange(false);\n }, []);\n\n const setDraft = useCallback(\n (next: Omit<FilterBarDraft, 'id' | 'from'> | null) => withHighlightReset(() => setDraftState(next)),\n [withHighlightReset, setDraftState],\n );\n\n const reset = useCallback(() => {\n setDraftState(null);\n setQuery('');\n }, [setDraftState]);\n\n const close = useCallback(() => {\n setOpen(false);\n reset();\n }, [reset]);\n\n const commit = useCallback(\n (fieldId: string, operatorId: string, value: FilterBarValue) => {\n withHighlightReset(() => commitDraft({ fieldId, operatorId }, value));\n setQuery('');\n inputRef.current?.focus();\n },\n [withHighlightReset, commitDraft],\n );\n\n const selectOperator = useCallback(\n (fieldId: string, next: FilterBarOperator) => {\n if (next.arity === 'none') {\n commit(fieldId, next.id, '');\n return;\n }\n setDraft({ fieldId, operatorId: next.id });\n setQuery('');\n },\n [commit, setDraft],\n );\n\n const selectField = useCallback(\n (next: FilterBarField) => {\n if (next.id === ADVANCED_FIELD_ID) {\n // `or` is the useful default: an `and` group is indistinguishable from the root.\n const id = ctx.addGroup(undefined, 'or');\n ctx.setOpenGroup(id);\n ctx.openGroupInput(id);\n setQuery('');\n setOpen(false);\n return;\n }\n const [only, ...rest] = ctx.getFieldOperators(next);\n // Free-text entry with text already typed: that text is the value, so neither the\n // operator nor the value step has anything left to ask.\n if (next.search && only && query.trim() !== '') {\n commit(next.id, only.id, parseFieldValue(next.type, query));\n return;\n }\n // A single allowed operator is implied: skip straight to the value step.\n if (only && rest.length === 0) {\n selectOperator(next.id, only);\n return;\n }\n setDraft({ fieldId: next.id });\n setQuery('');\n },\n [ctx, commit, query, selectOperator, setDraft],\n );\n\n const valueStep = useValueStep({\n field,\n operator,\n query,\n enabled: open && step === 'value',\n setQuery,\n onCommit: value => {\n if (draft?.operatorId) commit(draft.fieldId, draft.operatorId, value);\n },\n });\n\n // Leaving a group's input hands the target back to the bar; empty groups are pruned when the\n // popover closes, never here.\n const leaveGroup = useCallback(() => {\n if (!groupId) return false;\n ctx.openGroupInput(undefined);\n onLeave?.();\n return true;\n }, [ctx, groupId, onLeave]);\n\n const stepBack = useCallback(() => {\n if (step === 'value' && draft) {\n // Back to the field step when the operator was implied (single operator).\n const skipOperator = field ? fieldOperators.length === 1 : false;\n setDraft(skipOperator ? null : { fieldId: draft.fieldId });\n } else if (step === 'operator') setDraft(null);\n else if (!leaveGroup()) setOpen(false);\n setQuery('');\n }, [step, draft, field, fieldOperators, setDraft, leaveGroup]);\n\n // Selection is routed per step and never kept by Base UI (`value` stays null).\n const handleSelect = (item: Item) => {\n if (step === 'field') selectField(item as FilterBarField);\n else if (step === 'operator' && draft) selectOperator(draft.fieldId, item as FilterBarOperator);\n else valueStep.handleSelect(item as FilterBarOption);\n };\n\n // App-level keys run before Base UI's own input handling.\n const handleKeyDown = (event: BaseUIEvent<KeyboardEvent<HTMLInputElement>>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n // Consumed here: an enclosing popover (advanced filter) must not close on it.\n event.stopPropagation();\n event.preventBaseUIHandler();\n stepBack();\n return;\n }\n if (!open && (event.key === 'ArrowDown' || event.key === 'Enter')) {\n event.preventDefault();\n event.preventBaseUIHandler();\n setOpen(true);\n return;\n }\n if (query === '') {\n if (event.key === 'Backspace') {\n event.preventDefault();\n event.preventBaseUIHandler();\n if (step !== 'field') stepBack();\n else if (targetGroup) {\n // Inside a group: eat its last chip, or drop the group once it is empty.\n const last = targetGroup.nodes.findLast(node => !ctx.leaving.has(node.id));\n if (last) ctx.removeItem(last.id);\n else leaveGroup();\n } else {\n // Chips still animating out are already gone from the value: skip them.\n const last = ctx.items.findLast(item => !ctx.leaving.has(item.id));\n if (last) ctx.removeItem(last.id);\n }\n return;\n }\n if (event.key === 'ArrowLeft' && step === 'field') {\n if (ctx.focusChip(ctx.items.length - 1, -1, 'remove')) event.preventDefault();\n return;\n }\n }\n if (!open) return;\n\n if (event.key === 'Tab' && highlighted && step !== 'value' && (step === 'operator' || query !== '')) {\n event.preventDefault();\n event.preventBaseUIHandler();\n handleSelect(highlighted);\n return;\n }\n if (step === 'value') {\n const highlightedOption = valueStep.hasSuggestions ? (highlighted as FilterBarOption | null) : null;\n const handled = valueStep.handleKeyDown(event, highlightedOption);\n // Base UI closes on Enter when nothing is highlighted (form submission); the draft must stay open.\n if (handled || (event.key === 'Enter' && highlightedOption === null)) event.preventBaseUIHandler();\n }\n };\n\n const optionsForStep: Record<Step, readonly Item[]> = {\n field: visibleFields,\n operator: fieldOperators,\n value: valueStep.options,\n };\n const items: readonly Item[] = emptyForStepChange ? EMPTY_ITEMS : optionsForStep[step];\n\n // A search field is the way out for text that names no field, so it survives the field\n // step's own filtering whatever was typed; every other item matches on its label.\n const filterItem = useCallback(\n (item: Item, text: string, itemToString?: (item: Item) => string) =>\n ('search' in item && item.search === true) || matchesQueryFilter(item, text, itemToString),\n [],\n );\n\n const inputPlaceholder =\n step === 'field'\n ? placeholder\n : step === 'operator'\n ? 'Operator'\n : valueStep.hasSuggestions && valueStep.allowFreeText\n ? 'Search or type a value'\n : field?.type === 'number'\n ? 'Number'\n : 'Value';\n\n return (\n <>\n <ComboboxPrimitive.Root<Item>\n items={items}\n itemToStringLabel={getItemLabel}\n // The value step is already filtered (locally or server-side) by useValueSuggestions.\n filter={step === 'value' ? null : filterItem}\n value={null}\n onValueChange={(item, details) => {\n // Never let Base UI keep the selection, fill the input or close: each step routes it.\n details.cancel();\n if (item) handleSelect(item);\n }}\n inputValue={query}\n onInputValueChange={(next, details) => {\n if (details.reason !== 'input-change') return;\n setQuery(next);\n if (!open) setOpen(true);\n }}\n onItemHighlighted={item => setHighlighted(item ?? null)}\n open={open}\n onOpenChange={(next, details) => {\n // Escape is handled by the input (it steps back rather than closing).\n if (!next && details.reason === 'escape-key') return;\n // The input is the anchor, not a trigger: clicking it must keep the draft open.\n if (\n !next &&\n details.reason === 'outside-press' &&\n details.event.target instanceof Node &&\n inputRef.current?.contains(details.event.target)\n ) {\n return;\n }\n if (next) setOpen(true);\n else close();\n }}\n {...alwaysHighlightProps}\n modal={false}\n >\n <div\n ref={anchorRef}\n data-slot=\"filter-bar-input-trigger\"\n className={cn(\n // Same trigger recipe as every other DS Combobox (fill, radius, `[&>svg]` icon sizing\n // and the Button icon offset); the bar itself has no chrome. Focus lives on the\n // nested input, so the recipe's `focus-visible` border becomes `focus-within`.\n comboboxTriggerClass({ variant: 'default', size: FILTER_BAR_CONTROL_SIZE }),\n 'w-auto cursor-text',\n 'focus-within:bg-fill-hover',\n inputFocusBorderWithin,\n step === 'field' ? 'min-w-40' : 'min-w-28',\n className,\n )}\n >\n <ListFilterIcon aria-hidden className=\"shrink-0\" />\n <ComboboxPrimitive.Input\n ref={el => {\n inputRef.current = el;\n ctx.registerInput(el);\n }}\n aria-label={ariaLabel}\n spellCheck={false}\n {...passwordManagerOptOutProps}\n data-slot=\"filter-bar-input\"\n data-step={step}\n data-target={targetGroup?.id}\n inputMode={step === 'value' && field?.type === 'number' ? 'decimal' : undefined}\n placeholder={inputPlaceholder}\n className={cn(\n unstyledFormElementStyle,\n 'min-w-0 flex-1 bg-transparent',\n 'placeholder:text-muted-foreground placeholder:transition-opacity placeholder:duration-normal focus:placeholder:opacity-70',\n )}\n onFocus={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n />\n </div>\n <ComboboxPrimitive.Portal container={container}>\n <ComboboxPrimitive.Positioner\n // Base UI anchors to the input, which starts after the filter icon; align with the pill instead.\n anchor={anchorRef}\n align=\"start\"\n sideOffset={MENU_SIDE_OFFSET}\n positionMethod={FLOATING_POSITION_METHOD}\n className={comboboxStyles.positioner}\n >\n <ComboboxPrimitive.Popup // Match the pill, with the DS Combobox's 11rem floor (replaces the menu's anchor-width minimum).\n className={cn(comboboxStyles.popup, 'w-(--anchor-width) min-w-44')}\n data-slot=\"filter-bar-editor\"\n >\n {step === 'field' && (\n <FilterBarOptionList<FilterBarField>\n aria-label=\"Fields\"\n getKey={f => f.id}\n renderOption={f => (\n <>\n <FilterBarFieldLabel field={f} />\n {f.search && query !== '' && (\n <span className=\"min-w-0 truncate text-muted-foreground\">\n {ctx.getFieldOperators(f)[0]?.label} \"{query}\"\n </span>\n )}\n </>\n )}\n emptyText=\"No matching field.\"\n />\n )}\n {step === 'operator' && (\n <FilterBarOptionList<FilterBarOperator>\n aria-label=\"Operators\"\n getKey={o => o.id}\n renderOption={o => o.label}\n emptyText=\"No matching operator.\"\n />\n )}\n {step === 'value' && valueStep.hasOptions && (\n <FilterBarOptionList<FilterBarOption>\n aria-label=\"Values\"\n aria-multiselectable={valueStep.isMany || undefined}\n getKey={o => o.value}\n renderOption={option => <FilterBarOptionLabel option={option} />}\n isSelected={o => valueStep.isMany && valueStep.selected.includes(o.value)}\n isLoading={valueStep.isLoading}\n error={valueStep.error}\n emptyText={\n valueStep.allowFreeText ? 'No suggestions — press Enter to use your text.' : 'No matching value.'\n }\n />\n )}\n {step === 'value' && !valueStep.hasSuggestions && (\n <div className=\"flex items-center justify-between gap-2 py-1 pr-1 pl-[.9em]\">\n <Txt variant=\"caption\" tone=\"muted\">\n Type a value\n </Txt>\n <Button\n size=\"sm\"\n variant=\"default\"\n disabled={!valueStep.canCommitQuery}\n onMouseDown={e => e.preventDefault()}\n onClick={() => valueStep.submitFreeText()}\n >\n Apply\n <Kbd size=\"xs\">↵</Kbd>\n </Button>\n </div>\n )}\n {step === 'value' && valueStep.isMany && (\n <div className=\"flex items-center justify-end gap-1 border-t border-border p-1\">\n <Button\n size=\"sm\"\n variant=\"default\"\n onMouseDown={e => e.preventDefault()}\n onClick={() => valueStep.commitDone()}\n >\n Done\n <Kbd size=\"xs\">{modEnterLabel}</Kbd>\n </Button>\n </div>\n )}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n </ComboboxPrimitive.Root>\n </>\n );\n}\n","import { useEffect } from 'react';\nimport { useFilterBarContext } from './filter-bar-context';\n\n/** Keeps a leaving node in the DOM until its exit animation has played, then releases it. */\nexport function useSettleOnLeave(id: string, leaving: boolean, rootRef: React.RefObject<HTMLElement | null>) {\n const { settleRemove } = useFilterBarContext();\n useEffect(() => {\n const root = rootRef.current;\n if (!leaving || !root) return;\n const animations = typeof root.getAnimations === 'function' ? root.getAnimations({ subtree: true }) : [];\n if (animations.length === 0) {\n settleRemove(id);\n return;\n }\n let cancelled = false;\n Promise.all(animations.map(animation => animation.finished))\n .then(() => {\n if (!cancelled) settleRemove(id);\n })\n .catch(() => {});\n return () => {\n cancelled = true;\n };\n }, [leaving, id, settleRemove, rootRef]);\n}\n","import { FolderIcon, FolderPlusIcon, PlusIcon, Trash2Icon } from 'lucide-react';\nimport { Fragment, useEffect, useRef } from 'react';\nimport type { ReactNode } from 'react';\nimport { FilterBarChip } from './filter-bar-chip';\nimport { useFilterBarContext } from './filter-bar-context';\nimport { FilterBarInput } from './filter-bar-input';\nimport { countLeaves } from './filter-bar-tree';\nimport type { FilterBarGroup, FilterBarLogic } from './types';\nimport { isFilterBarGroup } from './types';\nimport { useSettleOnLeave } from './use-settle-on-leave';\nimport { Button } from '@/ds/components/Button/Button';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nconst connectorClass =\n 'flex h-control-sm w-14 shrink-0 items-center justify-center rounded-md text-column tracking-wide text-muted-foreground uppercase';\n\nexport type FilterBarLogicToggleProps = {\n groupId: string;\n logic: FilterBarLogic;\n className?: string;\n};\n\n/** `and` / `or` connector in front of a row; every connector of a group shares its logic. */\nexport function FilterBarLogicToggle({ groupId, logic, className }: FilterBarLogicToggleProps) {\n const ctx = useFilterBarContext();\n const next: FilterBarLogic = logic === 'and' ? 'or' : 'and';\n return (\n <button\n type=\"button\"\n data-slot=\"filter-bar-logic\"\n data-logic={logic}\n aria-label={`Joined with ${logic}, switch to ${next}`}\n title={`Switch to ${next}`}\n className={cn(\n connectorClass,\n 'filter-bar-logic cursor-pointer border border-border bg-fill-subtle outline-none',\n 'hover:bg-fill-hover hover:text-foreground focus-visible:bg-fill-hover focus-visible:text-foreground',\n className,\n )}\n onClick={() => ctx.setLogic(groupId, next)}\n >\n {logic}\n </button>\n );\n}\n\n/** Segmented `and | or` control shown in a nested group's header. */\nfunction FilterBarLogicSwitch({ groupId, logic }: { groupId: string; logic: FilterBarLogic }) {\n const ctx = useFilterBarContext();\n return (\n <div\n role=\"radiogroup\"\n aria-label=\"Group logic\"\n className=\"flex h-control-sm items-center gap-0.5 rounded-md border border-border bg-fill-subtle p-0.5\"\n >\n {(['and', 'or'] as const).map(value => (\n <button\n key={value}\n type=\"button\"\n role=\"radio\"\n aria-checked={logic === value}\n aria-label={`Join with ${value}`}\n className={cn(\n 'h-full cursor-pointer rounded-sm px-1.5 text-column tracking-wide uppercase outline-none',\n 'focus-visible:bg-fill-hover',\n logic === value ? 'bg-fill-hover text-foreground' : 'text-muted-foreground hover:text-foreground',\n )}\n onClick={() => logic !== value && ctx.setLogic(groupId, value)}\n >\n {value}\n </button>\n ))}\n </div>\n );\n}\n\nexport type FilterBarGroupEditorProps = {\n group: FilterBarGroup;\n /** Nesting level of `group` (root-level group = 1). */\n depth: number;\n /** Drops this group; rendered as a trailing `Clear all` in the footer. */\n onRemove?: () => void;\n removeLabel?: string;\n className?: string;\n};\n\n/**\n * Recursive rule builder shown in an advanced-filter popover. Rows are laid out as\n * `connector | condition`: the first row reads `where`, the following ones carry the\n * group's `and` / `or` toggle. Nested groups render as bordered cards with their own\n * header (logic switch + remove) and footer. The shared typeahead input renders as the\n * last row of the group it is pointed at.\n */\nexport function FilterBarGroupEditor({\n group,\n depth,\n onRemove,\n removeLabel = 'Remove group',\n className,\n}: FilterBarGroupEditorProps) {\n const ctx = useFilterBarContext();\n const addFilterRef = useRef<HTMLButtonElement>(null);\n const focusAddFilter = useRef(false);\n const targeted = ctx.inputTarget === group.id;\n const canNest = depth < ctx.maxDepth;\n\n // `+ Condition` is hidden while the input is open; focus it once it remounts.\n useEffect(() => {\n if (targeted || !focusAddFilter.current) return;\n focusAddFilter.current = false;\n addFilterRef.current?.focus();\n }, [targeted]);\n\n const rows: ReactNode[] = [];\n const connector = (key: string) =>\n rows.length === 0 ? (\n <span key={`${key}:where`} className={connectorClass}>\n where\n </span>\n ) : (\n <FilterBarLogicToggle key={`${key}:logic`} groupId={group.id} logic={group.logic} />\n );\n for (const node of group.nodes) {\n rows.push(\n <Fragment key={node.id}>\n {connector(node.id)}\n {isFilterBarGroup(node) ? (\n <NestedGroupCard group={node} depth={depth + 1} />\n ) : (\n <FilterBarChip item={node} className=\"w-fit\" />\n )}\n </Fragment>,\n );\n }\n if (ctx.draft && ctx.draft.groupId === group.id) {\n const { id, fieldId, operatorId = '' } = ctx.draft;\n rows.push(\n <Fragment key={id}>\n {connector(id)}\n <FilterBarChip draft item={{ id, fieldId, operatorId, value: '' }} className=\"w-fit\" />\n </Fragment>,\n );\n }\n if (targeted) {\n rows.push(\n <Fragment key=\"input\">\n {connector('input')}\n <FilterBarInput\n groupId={group.id}\n placeholder=\"Add condition\"\n onLeave={() => {\n focusAddFilter.current = true;\n }}\n />\n </Fragment>,\n );\n }\n\n return (\n <div\n data-slot=\"filter-bar-group-editor\"\n data-depth={depth}\n role=\"group\"\n aria-label={`Conditions joined with ${group.logic}`}\n className={cn('flex min-w-0 flex-col', className)}\n >\n {rows.length > 0 && (\n <div className=\"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2 gap-y-1.5 p-2\">{rows}</div>\n )}\n <div\n data-slot=\"filter-bar-editor-actions\"\n className={cn('flex w-full items-center gap-1 p-1', rows.length > 0 && 'border-t border-border')}\n >\n {!targeted && (\n <Button\n ref={addFilterRef}\n variant=\"ghost\"\n size=\"sm\"\n icon={<PlusIcon />}\n onClick={() => ctx.openGroupInput(group.id)}\n >\n Condition\n </Button>\n )}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<FolderPlusIcon />}\n className=\"text-muted-foreground\"\n tooltip={canNest ? undefined : `Groups can nest ${ctx.maxDepth} levels deep`}\n disabled={!canNest}\n onClick={() => ctx.addGroup(group.id, group.logic === 'and' ? 'or' : 'and')}\n >\n Group\n </Button>\n {onRemove && (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<Trash2Icon />}\n className=\"ml-auto text-muted-foreground\"\n aria-label={removeLabel}\n onClick={onRemove}\n >\n Clear all\n </Button>\n )}\n </div>\n </div>\n );\n}\n\nfunction NestedGroupCard({ group, depth }: { group: FilterBarGroup; depth: number }) {\n const ctx = useFilterBarContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const leaving = ctx.leaving.has(group.id);\n useSettleOnLeave(group.id, leaving, rootRef);\n const count = countLeaves(group);\n\n return (\n <div\n ref={rootRef}\n data-slot=\"filter-bar-editor-nested\"\n data-leaving={leaving || undefined}\n aria-hidden={leaving || undefined}\n className={cn(\n 'filter-bar-editor-nested w-full overflow-hidden rounded-lg border border-border',\n leaving && 'pointer-events-none',\n )}\n >\n <div className=\"flex items-center gap-2 border-b border-border px-2 py-1\">\n <FolderIcon className=\"size-3.5 text-muted-foreground\" />\n <Txt as=\"span\" variant=\"label\" tone=\"ink\">\n Group\n </Txt>\n <Txt as=\"span\" variant=\"label\" tone=\"muted\">\n · {count} {count === 1 ? 'condition' : 'conditions'}\n </Txt>\n <div className=\"ml-auto flex items-center gap-1\">\n <FilterBarLogicSwitch groupId={group.id} logic={group.logic} />\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n tooltip=\"Remove group\"\n disabled={leaving}\n onClick={() => ctx.removeGroup(group.id)}\n >\n <Trash2Icon />\n </Button>\n </div>\n </div>\n <FilterBarGroupEditor group={group} depth={depth} />\n </div>\n );\n}\n","import { BracesIcon, XIcon } from 'lucide-react';\nimport { useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport { chipClass, editableSegmentClass, removeSegmentClass } from './filter-bar-chip';\nimport { FILTER_BAR_SCOPE_ATTR, useFilterBarContext } from './filter-bar-context';\nimport { FilterBarGroupEditor } from './filter-bar-group-editor';\nimport { countLeaves } from './filter-bar-tree';\nimport type { FilterBarGroup } from './types';\nimport { useSettleOnLeave } from './use-settle-on-leave';\nimport { Button } from '@/ds/components/Button/Button';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ds/components/Popover';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport type FilterBarAdvancedChipProps = {\n group: FilterBarGroup;\n className?: string;\n};\n\n/**\n * A root-level group rendered as one \"Advanced filter\" chip. Its popover hosts the\n * recursive rule builder; the chip's remove button drops the whole subtree.\n */\nexport function FilterBarAdvancedChip({ group, className }: FilterBarAdvancedChipProps) {\n const ctx = useFilterBarContext();\n const [initial] = useState(() => !ctx.mounted);\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const leaving = ctx.leaving.has(group.id);\n const open = ctx.openGroupId === group.id;\n const count = countLeaves(group);\n // Position in the flattened item list: navigation from the chip continues from its first leaf.\n const firstLeafIndex = ctx.items.findIndex(item => isUnder(group, item.id));\n const index = firstLeafIndex === -1 ? ctx.items.length : firstLeafIndex;\n useSettleOnLeave(group.id, leaving, rootRef);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (leaving) return;\n const segments = Array.from(rootRef.current?.querySelectorAll<HTMLElement>('[data-filter-bar-segment]') ?? []);\n const current = segments.findIndex(el => el === event.target);\n if (current === -1) return;\n switch (event.key) {\n case 'ArrowRight': {\n event.preventDefault();\n const next = segments[current + 1];\n if (next) next.focus();\n else if (!ctx.focusChip(index + count, 1, 'field')) ctx.focusInput();\n return;\n }\n case 'ArrowLeft': {\n event.preventDefault();\n const prev = segments[current - 1];\n if (prev) prev.focus();\n else ctx.focusChip(index - 1, -1, 'remove');\n return;\n }\n case 'Delete':\n case 'Backspace':\n event.preventDefault();\n remove();\n break;\n default:\n }\n };\n\n const remove = () => {\n ctx.removeGroup(group.id);\n ctx.focusAfterRemove(index);\n };\n\n return (\n <Popover open={open} onOpenChange={next => ctx.setOpenGroup(next ? group.id : null)}>\n <div\n ref={rootRef}\n role=\"group\"\n aria-label={`Advanced filter, ${count} ${count === 1 ? 'condition' : 'conditions'}`}\n aria-hidden={leaving || undefined}\n data-slot=\"filter-bar-advanced\"\n data-initial={initial || undefined}\n data-leaving={leaving || undefined}\n className={cn('filter-bar-advanced', chipClass, leaving && 'pointer-events-none', className)}\n onKeyDown={handleKeyDown}\n >\n <PopoverTrigger\n ref={el => {\n triggerRef.current = el;\n ctx.registerSegment(group.id, 'field', leaving ? null : el);\n }}\n render={<button type=\"button\" />}\n data-filter-bar-segment=\"field\"\n className={editableSegmentClass}\n title=\"Edit advanced filter\"\n >\n <BracesIcon aria-hidden />\n <span className=\"truncate\">Advanced filter</span>\n {count > 0 && (\n <Txt as=\"span\" variant=\"column\" tone=\"muted\" aria-hidden>\n {count}\n </Txt>\n )}\n </PopoverTrigger>\n {leaving ? (\n <span aria-hidden className={removeSegmentClass}>\n <XIcon />\n </span>\n ) : (\n <button\n type=\"button\"\n ref={el => ctx.registerSegment(group.id, 'remove', el)}\n data-filter-bar-segment=\"remove\"\n aria-label=\"Remove advanced filter\"\n title=\"Remove advanced filter\"\n className={removeSegmentClass}\n onClick={remove}\n >\n <XIcon />\n </button>\n )}\n </div>\n <PopoverContent\n align=\"start\"\n className=\"w-[min(92vw,44rem)] p-0\"\n {...{ [FILTER_BAR_SCOPE_ATTR]: 'advanced' }}\n finalFocus={triggerRef}\n >\n <div className=\"flex items-center gap-2 border-b border-border px-3 py-2\">\n <BracesIcon className=\"size-3.5 text-muted-foreground\" />\n <Txt as=\"span\" variant=\"label\" tone=\"ink\">\n Advanced filter\n </Txt>\n <Txt as=\"span\" variant=\"column\" tone=\"muted\" className=\"rounded-md bg-fill-subtle px-1.5\">\n {count}\n </Txt>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"ml-auto\"\n tooltip=\"Close\"\n onClick={() => ctx.setOpenGroup(null)}\n >\n <XIcon />\n </Button>\n </div>\n <FilterBarGroupEditor\n group={group}\n depth={1}\n removeLabel=\"Remove advanced filter\"\n onRemove={() => {\n ctx.setOpenGroup(null);\n remove();\n }}\n />\n </PopoverContent>\n </Popover>\n );\n}\n\nconst isUnder = (group: FilterBarGroup, itemId: string): boolean =>\n group.nodes.some(node => (node.id === itemId ? true : 'kind' in node && isUnder(node, itemId)));\n","import { useFilterBarContext } from './filter-bar-context';\nimport { ClearFiltersButton } from '@/ds/components/ClearFiltersButton/clear-filters-button';\n\n/** Removes every removable filter. Rendered by FilterBar at its trailing edge; hidden while nothing can be removed. */\nexport function FilterBarClear({ label }: { label: string }) {\n const ctx = useFilterBarContext();\n if (!ctx.hasRemovableItems) return null;\n return (\n <ClearFiltersButton\n label={label}\n onClick={event => {\n event.stopPropagation();\n ctx.clear();\n ctx.focusInput();\n }}\n />\n );\n}\n","import { Fragment } from 'react';\nimport type { ReactNode } from 'react';\nimport { FilterBarAdvancedChip } from './filter-bar-advanced-chip';\nimport { FilterBarChip } from './filter-bar-chip';\nimport { FilterBarClear } from './filter-bar-clear';\nimport { FILTER_BAR_SCOPE_ATTR, FilterBarProvider, useFilterBarContext } from './filter-bar-context';\nimport { FilterBarInput } from './filter-bar-input';\nimport { FilterBarTimeRange } from './filter-bar-time-range';\nimport { isFilterBarGroup } from './types';\nimport type { FilterBarExpression, FilterBarField, FilterBarItem, FilterBarOperator } from './types';\nimport { VisuallyHidden } from '@/ds/primitives/visually-hidden';\nimport { cn } from '@/lib/utils';\n\ntype FilterBarValueProps =\n | {\n /** Flat list of filters, implicitly joined with `and`. Advanced filters are never offered. */\n value: FilterBarItem[];\n onValueChange: (items: FilterBarItem[]) => void;\n }\n | {\n /**\n * Tree of filters and groups. Root nodes are joined with `and`; each root group renders\n * as one \"Advanced filter\" chip whose popover edits the nested `and` / `or` logic.\n */\n value: FilterBarExpression;\n onValueChange: (expression: FilterBarExpression) => void;\n };\n\nexport type FilterBarProps = FilterBarValueProps & {\n fields: FilterBarField[];\n operators: FilterBarOperator[];\n /**\n * Id given to a newly added item. Defaults to a random id. Consumers that rebuild `value` from\n * their own store (URL, query params…) should return the id they will rebuild it with, so the\n * draft chip and the committed chip are the same element.\n */\n createItemId?: (fieldId: string) => string;\n /** How deep advanced-filter groups may nest (root-level group = 1). Defaults to 3. */\n maxDepth?: number;\n 'aria-label'?: string;\n /**\n * Text shown in a value list when the field's `suggestions` resolver rejects, for example\n * to explain a server limit. Return `undefined` to keep the default \"Couldn't load values.\".\n */\n describeSuggestionsError?: (error: unknown) => string | undefined;\n /** Accessible label of the trailing \"remove every filter\" button. */\n clearLabel?: string;\n className?: string;\n children: ReactNode;\n};\n\nfunction FilterBarSurface({\n className,\n clearLabel,\n children,\n}: {\n className?: string;\n clearLabel: string;\n children: ReactNode;\n}) {\n const ctx = useFilterBarContext();\n return (\n <div\n role=\"group\"\n aria-label={ctx.ariaLabel}\n data-slot=\"filter-bar\"\n {...{ [FILTER_BAR_SCOPE_ATTR]: 'bar' }}\n className={cn(\n // No chrome of its own: chips and the typeahead input sit directly on the parent surface.\n // Layout: chips, input, then Clear right beside the input — all in one wrapping row so\n // Clear never drifts to the far edge of a wide container.\n 'flex w-full flex-wrap items-center gap-1.5',\n className,\n )}\n >\n {children}\n <span className=\"flex shrink-0 items-center empty:hidden\">\n <FilterBarClear label={clearLabel} />\n </span>\n <VisuallyHidden aria-live=\"polite\">{ctx.announcement}</VisuallyHidden>\n </div>\n );\n}\n\n/**\n * Braintrust-style filter bar: `field → operator → value` filters built from a\n * single typeahead input, rendered as inline editable chips. Domain-agnostic —\n * fields, operators and values are plain strings supplied by the consumer.\n *\n * Pass a `FilterBarExpression` as `value` to enable Linear-style advanced filters:\n * the input offers \"Advanced filter…\", which adds one chip whose popover hosts a\n * recursive rule builder (`and` / `or` connectors, nested groups). The bar itself\n * stays flat. A flat `FilterBarItem[]` stays flat.\n *\n * @example\n * <FilterBar value={items} onValueChange={setItems} fields={fields} operators={DEFAULT_FILTER_OPERATORS}>\n * <FilterBar.Chips />\n * <FilterBar.Input />\n * </FilterBar>\n */\nexport function FilterBar({\n fields,\n operators,\n value,\n onValueChange,\n createItemId,\n maxDepth,\n 'aria-label': ariaLabel = 'Filters',\n describeSuggestionsError,\n clearLabel = 'Clear filters',\n className,\n children,\n}: FilterBarProps) {\n return (\n <FilterBarProvider\n fields={fields}\n operators={operators}\n value={value}\n onValueChange={onValueChange}\n createItemId={createItemId}\n maxDepth={maxDepth}\n ariaLabel={ariaLabel}\n describeSuggestionsError={describeSuggestionsError}\n >\n <FilterBarSurface className={className} clearLabel={clearLabel}>\n {children}\n </FilterBarSurface>\n </FilterBarProvider>\n );\n}\n\n/**\n * Default layout: one editable chip per root item, one \"Advanced filter\" chip per root\n * group, in order, then the chip of the filter being built in the bar's input (which\n * becomes the last item's chip once committed).\n */\nexport function FilterBarChips({ renderChip = defaultRenderChip }: FilterBarChipsProps) {\n const ctx = useFilterBarContext();\n // One keyed array: the draft chip and the item it becomes share a key, so React\n // keeps the element across the commit instead of mounting a new chip.\n const chips: ReactNode[] = [];\n for (const node of ctx.expression.nodes) {\n const chip = isFilterBarGroup(node) ? <FilterBarAdvancedChip group={node} /> : renderChip(node);\n if (chip !== null) chips.push(<Fragment key={node.id}>{chip}</Fragment>);\n }\n if (ctx.draft && !ctx.draft.groupId) {\n // `FilterBarChip` needs a full item; the draft's missing parts are blank until picked.\n const { id, fieldId, operatorId = '' } = ctx.draft;\n chips.push(\n <Fragment key={id}>\n <FilterBarChip draft item={{ id, fieldId, operatorId, value: '' }} />\n </Fragment>,\n );\n }\n return <>{chips}</>;\n}\n\nexport type FilterBarChipsProps = {\n /**\n * Chip for an item; return `null` to render none (e.g. an item only held in the\n * value for scoping). Defaults to a plain editable `FilterBar.Chip`.\n */\n renderChip?: (item: FilterBarItem) => ReactNode;\n};\n\nconst defaultRenderChip = (item: FilterBarItem) => <FilterBarChip item={item} />;\n\nFilterBar.Chips = FilterBarChips;\nFilterBar.Chip = FilterBarChip;\nFilterBar.AdvancedChip = FilterBarAdvancedChip;\nFilterBar.Input = FilterBarInput;\nFilterBar.TimeRange = FilterBarTimeRange;\n","import type { FilterBarOperator } from './types';\n\n/** Opt-in starter set. Pure data: the component attaches no semantics to ids. */\nexport const DEFAULT_FILTER_OPERATORS: FilterBarOperator[] = [\n { id: 'is', label: 'is', widensTo: 'in' },\n { id: 'is-not', label: 'is not' },\n { id: 'contains', label: 'contains' },\n { id: 'not-contains', label: 'does not contain' },\n { id: 'starts-with', label: 'starts with' },\n { id: 'gt', label: '>' },\n { id: 'lt', label: '<' },\n { id: 'gte', label: '>=' },\n { id: 'lte', label: '<=' },\n { id: 'is-empty', label: 'is empty', arity: 'none' },\n { id: 'is-not-empty', label: 'is not empty', arity: 'none' },\n { id: 'in', label: 'in', arity: 'many' },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,gBAAgB,SAAgB,WAAW,QAAQ,KAAK,QAAQ,KAAK,QAAQ,WAAW,OAAO,KAAK,QAAQ;AAElH,IAAM,cAA+B,CAAC;;AAEtC,IAAM,oBAAoB;AAC1B,IAAM,iBAAiC;CACrC,IAAI;CACJ,OAAO;CACP,MAAM;CACN,WAAW,CAAC;AACd;;;;;AAmBA,SAAgB,eAAe,OAA4B;CAEzD,IADY,oBACR,CAAA,CAAI,gBAAgB,MAAM,SAAS,OAAO;CAC9C,OAAO,oBAAC,oBAAD,EAAoB,GAAI,MAAQ,CAAA;AACzC;AAEA,SAAS,mBAAmB,EAC1B,cAAc,UACd,WACA,cAAc,YAAY,cAC1B,SACA,WACsB;CACtB,MAAM,MAAM,oBAAoB;CAChC,MAAM,YAAY,mBAAmB;CACrC,MAAM,WAAW,OAAgC,IAAI;CACrD,MAAM,YAAY,OAAuB,IAAI;CAC7C,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CACtC,MAAM,CAAC,OAAO,YAAY,SAAS,EAAE;CACrC,MAAM,CAAC,aAAa,kBAAkB,SAAsB,IAAI;CAChE,MAAM,CAAC,oBAAoB,yBAAyB,SAAS,KAAK;CAClE,MAAM,gBAAgB,mBAAmB,IAAI,OAAO;CAGpD,MAAM,EAAE,OAAO,UAAU,eAAe,gBAAgB;CACxD,MAAM,OAAa,CAAC,QAAQ,UAAU,CAAC,MAAM,aAAa,aAAa;CACvE,MAAM,QAAQ,QAAQ,IAAI,SAAS,MAAM,OAAO,IAAI,KAAA;CACpD,MAAM,iBAAiB,cAAe,QAAQ,IAAI,kBAAkB,KAAK,IAAI,CAAC,GAAI,CAAC,KAAK,KAAK,CAAC;CAC9F,MAAM,WAA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AD;GAAe,OAAA;GAAM,MAAM;IAAE;IAAI;IAAS;IAAY,OAAO;GAAG;EAAI,CAAA,EAC5D,GAFK,EAEL,CACZ;CACF;CACA,OAAO,oBAAAC,YAAA,EAAA,UAAG,MAAQ,CAAA;AACpB;AAUA,IAAM,qBAAqB,SAAwB,oBAAC,eAAD,EAAqB,KAAO,CAAA;AAE/E,UAAU,QAAQ;AAClB,UAAU,OAAO;AACjB,UAAU,eAAe;AACzB,UAAU,QAAQ;AAClB,UAAU,YAAY;;;ACxKtB,IAAa,2BAAgD;CAC3D;EAAE,IAAI;EAAM,OAAO;EAAM,UAAU;CAAK;CACxC;EAAE,IAAI;EAAU,OAAO;CAAS;CAChC;EAAE,IAAI;EAAY,OAAO;CAAW;CACpC;EAAE,IAAI;EAAgB,OAAO;CAAmB;CAChD;EAAE,IAAI;EAAe,OAAO;CAAc;CAC1C;EAAE,IAAI;EAAM,OAAO;CAAI;CACvB;EAAE,IAAI;EAAM,OAAO;CAAI;CACvB;EAAE,IAAI;EAAO,OAAO;CAAK;CACzB;EAAE,IAAI;EAAO,OAAO;CAAK;CACzB;EAAE,IAAI;EAAY,OAAO;EAAY,OAAO;CAAO;CACnD;EAAE,IAAI;EAAgB,OAAO;EAAgB,OAAO;CAAO;CAC3D;EAAE,IAAI;EAAM,OAAO;EAAM,OAAO;CAAO;AACzC"}
1
+ {"version":3,"file":"FilterBar-PSQ1OwqH.js","names":["_Fragment","_Fragment"],"sources":["../src/ds/components/FilterBar/filter-bar-input.tsx","../src/ds/components/FilterBar/use-settle-on-leave.ts","../src/ds/components/FilterBar/filter-bar-group-editor.tsx","../src/ds/components/FilterBar/filter-bar-advanced-chip.tsx","../src/ds/components/FilterBar/filter-bar-clear.tsx","../src/ds/components/FilterBar/filter-bar.tsx","../src/ds/components/FilterBar/default-operators.ts"],"sourcesContent":["import type { BaseUIEvent } from '@base-ui/react/types';\nimport { BracesIcon, ListFilterIcon } from 'lucide-react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport { flushSync } from 'react-dom';\nimport { FILTER_BAR_CONTROL_SIZE, FilterBarFieldLabel, alwaysHighlightProps } from './filter-bar-chip';\nimport { useFilterBarContext } from './filter-bar-context';\nimport { FilterBarOptionLabel, FilterBarOptionList } from './filter-bar-option-list';\nimport { findGroup } from './filter-bar-tree';\nimport { matchesQueryFilter } from './match-query';\nimport type { FilterBarDraft, FilterBarField, FilterBarOperator, FilterBarOption, FilterBarValue } from './types';\nimport { parseFieldValue } from './types';\nimport { useValueStep } from './use-value-step';\nimport { Button } from '@/ds/components/Button/Button';\nimport { ComboboxPrimitive, comboboxStyles } from '@/ds/components/Combobox';\nimport { comboboxTriggerClass } from '@/ds/components/Combobox/combobox-styles';\nimport { Kbd } from '@/ds/components/Kbd/kbd';\nimport { Txt } from '@/ds/components/Txt';\nimport { FLOATING_POSITION_METHOD } from '@/ds/primitives/floating';\nimport { inputFocusBorderWithin, unstyledFormElementStyle } from '@/ds/primitives/form-element';\nimport { MENU_SIDE_OFFSET } from '@/ds/primitives/menu-item';\nimport { passwordManagerOptOutProps } from '@/ds/primitives/password-manager-autofill';\nimport { usePortalContainer } from '@/ds/primitives/portal-container';\nimport { useIsApplePlatform } from '@/hooks/use-keyboard-shortcut-label';\nimport { cn } from '@/lib/utils';\n\ntype Step = 'field' | 'operator' | 'value';\n\ntype Item = FilterBarField | FilterBarOperator | FilterBarOption;\n\nconst getItemLabel = (item: Item) => ('label' in item && item.label ? item.label : 'value' in item ? item.value : '');\n\nconst EMPTY_ITEMS: readonly Item[] = [];\n/** Pinned last entry of the field list that spawns an advanced filter (an `or` group) instead of a filter. */\nconst ADVANCED_FIELD_ID = '__filter-bar-advanced__';\nconst ADVANCED_FIELD: FilterBarField = {\n id: ADVANCED_FIELD_ID,\n label: 'Advanced filter…',\n icon: BracesIcon,\n operators: [],\n};\n\nexport type FilterBarInputProps = {\n placeholder?: string;\n className?: string;\n 'aria-label'?: string;\n /**\n * Group this instance commits into; omit for the bar's own input. Only the instance whose\n * `groupId` matches the provider's `inputTarget` renders, so a single input is ever mounted.\n */\n groupId?: string;\n /** Called when Escape is pressed on an empty query inside a group, after the input hands back to the bar. */\n onLeave?: () => void;\n};\n\n/**\n * Typeahead entry point: type to pick a field, then an operator, then a value.\n * Focus never leaves the input; the popup is driven with the arrow keys.\n */\nexport function FilterBarInput(props: FilterBarInputProps) {\n const ctx = useFilterBarContext();\n if (ctx.inputTarget !== props.groupId) return null;\n return <FilterBarInputImpl {...props} />;\n}\n\nfunction FilterBarInputImpl({\n placeholder = 'Filter',\n className,\n 'aria-label': ariaLabel = 'Add filter',\n groupId,\n onLeave,\n}: FilterBarInputProps) {\n const ctx = useFilterBarContext();\n const container = usePortalContainer();\n const inputRef = useRef<HTMLInputElement | null>(null);\n const anchorRef = useRef<HTMLDivElement>(null);\n const [open, setOpen] = useState(false);\n const [query, setQuery] = useState('');\n const [highlighted, setHighlighted] = useState<Item | null>(null);\n const [emptyForStepChange, setEmptyForStepChange] = useState(false);\n const modEnterLabel = useIsApplePlatform() ? '⌘↵' : 'Ctrl ↵';\n\n // The draft lives in the provider so the chip list can render it; the step follows from it.\n const { draft, setDraft: setDraftState, commitDraft } = ctx;\n const step: Step = !draft ? 'field' : !draft.operatorId ? 'operator' : 'value';\n const field = draft ? ctx.getField(draft.fieldId) : undefined;\n const fieldOperators = useMemo(() => (field ? ctx.getFieldOperators(field) : []), [ctx, field]);\n const operator = draft?.operatorId\n ? (fieldOperators.find(o => o.id === draft.operatorId) ?? ctx.getOperator(draft.operatorId))\n : undefined;\n // The advanced option lives in the bar only; inside a popover, nesting is the editor's `+ Group`.\n const offerAdvanced = ctx.groupsEnabled && groupId === undefined;\n const visibleFields = useMemo(() => {\n const fields = ctx.fields.filter(f => !f.hidden);\n return offerAdvanced ? [...fields, ADVANCED_FIELD] : fields;\n }, [ctx.fields, offerAdvanced]);\n const targetGroup = groupId ? findGroup(ctx.expression, groupId) : undefined;\n\n // A group's input mounts on demand (see `openGroupInput`) and takes focus itself.\n useEffect(() => {\n if (groupId) inputRef.current?.focus();\n }, [groupId]);\n\n // Base UI owns the highlight index and keeps it when the list content changes, so a row\n // reached with ArrowDown would carry over into the step that follows. An empty list committed\n // first drops that index, and `autoHighlight` re-anchors on the first row of the new step.\n const withHighlightReset = useCallback((change: () => void) => {\n flushSync(() => setEmptyForStepChange(true));\n change();\n setEmptyForStepChange(false);\n }, []);\n\n const setDraft = useCallback(\n (next: Omit<FilterBarDraft, 'id' | 'from'> | null) => withHighlightReset(() => setDraftState(next)),\n [withHighlightReset, setDraftState],\n );\n\n const reset = useCallback(() => {\n setDraftState(null);\n setQuery('');\n }, [setDraftState]);\n\n const close = useCallback(() => {\n setOpen(false);\n reset();\n }, [reset]);\n\n const commit = useCallback(\n (fieldId: string, operatorId: string, value: FilterBarValue) => {\n withHighlightReset(() => commitDraft({ fieldId, operatorId }, value));\n setQuery('');\n inputRef.current?.focus();\n },\n [withHighlightReset, commitDraft],\n );\n\n const selectOperator = useCallback(\n (fieldId: string, next: FilterBarOperator) => {\n if (next.arity === 'none') {\n commit(fieldId, next.id, '');\n return;\n }\n setDraft({ fieldId, operatorId: next.id });\n setQuery('');\n },\n [commit, setDraft],\n );\n\n const selectField = useCallback(\n (next: FilterBarField) => {\n if (next.id === ADVANCED_FIELD_ID) {\n // `or` is the useful default: an `and` group is indistinguishable from the root.\n const id = ctx.addGroup(undefined, 'or');\n ctx.setOpenGroup(id);\n ctx.openGroupInput(id);\n setQuery('');\n setOpen(false);\n return;\n }\n const [only, ...rest] = ctx.getFieldOperators(next);\n // Free-text entry with text already typed: that text is the value, so neither the\n // operator nor the value step has anything left to ask.\n if (next.search && only && query.trim() !== '') {\n commit(next.id, only.id, parseFieldValue(next.type, query));\n return;\n }\n // A single allowed operator is implied: skip straight to the value step.\n if (only && rest.length === 0) {\n selectOperator(next.id, only);\n return;\n }\n setDraft({ fieldId: next.id });\n setQuery('');\n },\n [ctx, commit, query, selectOperator, setDraft],\n );\n\n const valueStep = useValueStep({\n field,\n operator,\n query,\n enabled: open && step === 'value',\n setQuery,\n onCommit: value => {\n if (draft?.operatorId) commit(draft.fieldId, draft.operatorId, value);\n },\n });\n\n // Leaving a group's input hands the target back to the bar; empty groups are pruned when the\n // popover closes, never here.\n const leaveGroup = useCallback(() => {\n if (!groupId) return false;\n ctx.openGroupInput(undefined);\n onLeave?.();\n return true;\n }, [ctx, groupId, onLeave]);\n\n const stepBack = useCallback(() => {\n if (step === 'value' && draft) {\n // Back to the field step when the operator was implied (single operator).\n const skipOperator = field ? fieldOperators.length === 1 : false;\n setDraft(skipOperator ? null : { fieldId: draft.fieldId });\n } else if (step === 'operator') setDraft(null);\n else if (!leaveGroup()) setOpen(false);\n setQuery('');\n }, [step, draft, field, fieldOperators, setDraft, leaveGroup]);\n\n // Selection is routed per step and never kept by Base UI (`value` stays null).\n const handleSelect = (item: Item) => {\n if (step === 'field') selectField(item as FilterBarField);\n else if (step === 'operator' && draft) selectOperator(draft.fieldId, item as FilterBarOperator);\n else valueStep.handleSelect(item as FilterBarOption);\n };\n\n // App-level keys run before Base UI's own input handling.\n const handleKeyDown = (event: BaseUIEvent<KeyboardEvent<HTMLInputElement>>) => {\n if (event.key === 'Escape') {\n event.preventDefault();\n // Consumed here: an enclosing popover (advanced filter) must not close on it.\n event.stopPropagation();\n event.preventBaseUIHandler();\n stepBack();\n return;\n }\n if (!open && (event.key === 'ArrowDown' || event.key === 'Enter')) {\n event.preventDefault();\n event.preventBaseUIHandler();\n setOpen(true);\n return;\n }\n if (query === '') {\n if (event.key === 'Backspace') {\n event.preventDefault();\n event.preventBaseUIHandler();\n if (step !== 'field') stepBack();\n else if (targetGroup) {\n // Inside a group: eat its last chip, or drop the group once it is empty.\n const last = targetGroup.nodes.findLast(node => !ctx.leaving.has(node.id));\n if (last) ctx.removeItem(last.id);\n else leaveGroup();\n } else {\n // Chips still animating out are already gone from the value: skip them.\n const last = ctx.items.findLast(item => !ctx.leaving.has(item.id));\n if (last) ctx.removeItem(last.id);\n }\n return;\n }\n if (event.key === 'ArrowLeft' && step === 'field') {\n if (ctx.focusChip(ctx.items.length - 1, -1, 'remove')) event.preventDefault();\n return;\n }\n }\n if (!open) return;\n\n if (event.key === 'Tab' && highlighted && step !== 'value' && (step === 'operator' || query !== '')) {\n event.preventDefault();\n event.preventBaseUIHandler();\n handleSelect(highlighted);\n return;\n }\n if (step === 'value') {\n const highlightedOption = valueStep.hasSuggestions ? (highlighted as FilterBarOption | null) : null;\n const handled = valueStep.handleKeyDown(event, highlightedOption);\n // Base UI closes on Enter when nothing is highlighted (form submission); the draft must stay open.\n if (handled || (event.key === 'Enter' && highlightedOption === null)) event.preventBaseUIHandler();\n }\n };\n\n const optionsForStep: Record<Step, readonly Item[]> = {\n field: visibleFields,\n operator: fieldOperators,\n value: valueStep.options,\n };\n const items: readonly Item[] = emptyForStepChange ? EMPTY_ITEMS : optionsForStep[step];\n\n // A search field is the way out for text that names no field, so it survives the field\n // step's own filtering whatever was typed; every other item matches on its label.\n const filterItem = useCallback(\n (item: Item, text: string, itemToString?: (item: Item) => string) =>\n ('search' in item && item.search === true) || matchesQueryFilter(item, text, itemToString),\n [],\n );\n\n const inputPlaceholder =\n step === 'field'\n ? placeholder\n : step === 'operator'\n ? 'Operator'\n : valueStep.hasSuggestions && valueStep.allowFreeText\n ? 'Search or type a value'\n : field?.type === 'number'\n ? 'Number'\n : 'Value';\n\n return (\n <>\n <ComboboxPrimitive.Root<Item>\n items={items}\n itemToStringLabel={getItemLabel}\n // The value step is already filtered (locally or server-side) by useValueSuggestions.\n filter={step === 'value' ? null : filterItem}\n value={null}\n onValueChange={(item, details) => {\n // Never let Base UI keep the selection, fill the input or close: each step routes it.\n details.cancel();\n if (item) handleSelect(item);\n }}\n inputValue={query}\n onInputValueChange={(next, details) => {\n if (details.reason !== 'input-change') return;\n setQuery(next);\n if (!open) setOpen(true);\n }}\n onItemHighlighted={item => setHighlighted(item ?? null)}\n open={open}\n onOpenChange={(next, details) => {\n // Escape is handled by the input (it steps back rather than closing).\n if (!next && details.reason === 'escape-key') return;\n // The input is the anchor, not a trigger: clicking it must keep the draft open.\n if (\n !next &&\n details.reason === 'outside-press' &&\n details.event.target instanceof Node &&\n inputRef.current?.contains(details.event.target)\n ) {\n return;\n }\n if (next) setOpen(true);\n else close();\n }}\n {...alwaysHighlightProps}\n modal={false}\n >\n <div\n ref={anchorRef}\n data-slot=\"filter-bar-input-trigger\"\n className={cn(\n // Same trigger recipe as every other DS Combobox (fill, radius, `[&>svg]` icon sizing\n // and the Button icon offset); the bar itself has no chrome. Focus lives on the\n // nested input, so the recipe's `focus-visible` border becomes `focus-within`.\n comboboxTriggerClass({ variant: 'default', size: FILTER_BAR_CONTROL_SIZE }),\n 'w-auto cursor-text',\n 'focus-within:bg-fill-hover',\n inputFocusBorderWithin,\n step === 'field' ? 'min-w-40' : 'min-w-28',\n className,\n )}\n >\n <ListFilterIcon aria-hidden className=\"shrink-0\" />\n <ComboboxPrimitive.Input\n ref={el => {\n inputRef.current = el;\n ctx.registerInput(el);\n }}\n aria-label={ariaLabel}\n spellCheck={false}\n {...passwordManagerOptOutProps}\n data-slot=\"filter-bar-input\"\n data-step={step}\n data-target={targetGroup?.id}\n inputMode={step === 'value' && field?.type === 'number' ? 'decimal' : undefined}\n placeholder={inputPlaceholder}\n className={cn(\n unstyledFormElementStyle,\n 'min-w-0 flex-1 bg-transparent',\n 'placeholder:text-muted-foreground placeholder:transition-opacity placeholder:duration-normal focus:placeholder:opacity-70',\n )}\n onFocus={() => setOpen(true)}\n onKeyDown={handleKeyDown}\n />\n </div>\n <ComboboxPrimitive.Portal container={container}>\n <ComboboxPrimitive.Positioner\n // Base UI anchors to the input, which starts after the filter icon; align with the pill instead.\n anchor={anchorRef}\n align=\"start\"\n sideOffset={MENU_SIDE_OFFSET}\n positionMethod={FLOATING_POSITION_METHOD}\n className={comboboxStyles.positioner}\n >\n <ComboboxPrimitive.Popup // Match the pill, with the DS Combobox's 11rem floor (replaces the menu's anchor-width minimum).\n className={cn(comboboxStyles.popup, 'w-(--anchor-width) min-w-44')}\n data-slot=\"filter-bar-editor\"\n >\n {step === 'field' && (\n <FilterBarOptionList<FilterBarField>\n aria-label=\"Fields\"\n getKey={f => f.id}\n renderOption={f => (\n <>\n <FilterBarFieldLabel field={f} />\n {f.search && query !== '' && (\n <span className=\"min-w-0 truncate text-muted-foreground\">\n {ctx.getFieldOperators(f)[0]?.label} \"{query}\"\n </span>\n )}\n </>\n )}\n emptyText=\"No matching field.\"\n />\n )}\n {step === 'operator' && (\n <FilterBarOptionList<FilterBarOperator>\n aria-label=\"Operators\"\n getKey={o => o.id}\n renderOption={o => o.label}\n emptyText=\"No matching operator.\"\n />\n )}\n {step === 'value' && valueStep.hasOptions && (\n <FilterBarOptionList<FilterBarOption>\n aria-label=\"Values\"\n aria-multiselectable={valueStep.isMany || undefined}\n getKey={o => o.value}\n renderOption={option => <FilterBarOptionLabel option={option} />}\n isSelected={o => valueStep.isMany && valueStep.selected.includes(o.value)}\n isLoading={valueStep.isLoading}\n error={valueStep.error}\n emptyText={\n valueStep.allowFreeText ? 'No suggestions — press Enter to use your text.' : 'No matching value.'\n }\n />\n )}\n {step === 'value' && !valueStep.hasSuggestions && (\n <div className=\"flex items-center justify-between gap-2 py-1 pr-1 pl-[.9em]\">\n <Txt variant=\"caption\" tone=\"muted\">\n Type a value\n </Txt>\n <Button\n size=\"sm\"\n variant=\"default\"\n disabled={!valueStep.canCommitQuery}\n onMouseDown={e => e.preventDefault()}\n onClick={() => valueStep.submitFreeText()}\n >\n Apply\n <Kbd size=\"xs\">↵</Kbd>\n </Button>\n </div>\n )}\n {step === 'value' && valueStep.isMany && (\n <div className=\"flex items-center justify-end gap-1 border-t border-border p-1\">\n <Button\n size=\"sm\"\n variant=\"default\"\n onMouseDown={e => e.preventDefault()}\n onClick={() => valueStep.commitDone()}\n >\n Done\n <Kbd size=\"xs\">{modEnterLabel}</Kbd>\n </Button>\n </div>\n )}\n </ComboboxPrimitive.Popup>\n </ComboboxPrimitive.Positioner>\n </ComboboxPrimitive.Portal>\n </ComboboxPrimitive.Root>\n </>\n );\n}\n","import { useEffect } from 'react';\nimport { useFilterBarContext } from './filter-bar-context';\n\n/** Keeps a leaving node in the DOM until its exit animation has played, then releases it. */\nexport function useSettleOnLeave(id: string, leaving: boolean, rootRef: React.RefObject<HTMLElement | null>) {\n const { settleRemove } = useFilterBarContext();\n useEffect(() => {\n const root = rootRef.current;\n if (!leaving || !root) return;\n const animations = typeof root.getAnimations === 'function' ? root.getAnimations({ subtree: true }) : [];\n if (animations.length === 0) {\n settleRemove(id);\n return;\n }\n let cancelled = false;\n Promise.all(animations.map(animation => animation.finished))\n .then(() => {\n if (!cancelled) settleRemove(id);\n })\n .catch(() => {});\n return () => {\n cancelled = true;\n };\n }, [leaving, id, settleRemove, rootRef]);\n}\n","import { FolderIcon, FolderPlusIcon, PlusIcon, Trash2Icon } from 'lucide-react';\nimport { Fragment, useEffect, useRef } from 'react';\nimport type { ReactNode } from 'react';\nimport { FilterBarChip } from './filter-bar-chip';\nimport { useFilterBarContext } from './filter-bar-context';\nimport { FilterBarInput } from './filter-bar-input';\nimport { countLeaves } from './filter-bar-tree';\nimport type { FilterBarGroup, FilterBarLogic } from './types';\nimport { isFilterBarGroup } from './types';\nimport { useSettleOnLeave } from './use-settle-on-leave';\nimport { Button } from '@/ds/components/Button/Button';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nconst connectorClass =\n 'flex h-control-sm w-14 shrink-0 items-center justify-center rounded-md text-column tracking-wide text-muted-foreground uppercase';\n\nexport type FilterBarLogicToggleProps = {\n groupId: string;\n logic: FilterBarLogic;\n className?: string;\n};\n\n/** `and` / `or` connector in front of a row; every connector of a group shares its logic. */\nexport function FilterBarLogicToggle({ groupId, logic, className }: FilterBarLogicToggleProps) {\n const ctx = useFilterBarContext();\n const next: FilterBarLogic = logic === 'and' ? 'or' : 'and';\n return (\n <button\n type=\"button\"\n data-slot=\"filter-bar-logic\"\n data-logic={logic}\n aria-label={`Joined with ${logic}, switch to ${next}`}\n title={`Switch to ${next}`}\n className={cn(\n connectorClass,\n 'filter-bar-logic cursor-pointer border border-border bg-fill-subtle outline-none',\n 'hover:bg-fill-hover hover:text-foreground focus-visible:bg-fill-hover focus-visible:text-foreground',\n className,\n )}\n onClick={() => ctx.setLogic(groupId, next)}\n >\n {logic}\n </button>\n );\n}\n\n/** Segmented `and | or` control shown in a nested group's header. */\nfunction FilterBarLogicSwitch({ groupId, logic }: { groupId: string; logic: FilterBarLogic }) {\n const ctx = useFilterBarContext();\n return (\n <div\n role=\"radiogroup\"\n aria-label=\"Group logic\"\n className=\"flex h-control-sm items-center gap-0.5 rounded-md border border-border bg-fill-subtle p-0.5\"\n >\n {(['and', 'or'] as const).map(value => (\n <button\n key={value}\n type=\"button\"\n role=\"radio\"\n aria-checked={logic === value}\n aria-label={`Join with ${value}`}\n className={cn(\n 'h-full cursor-pointer rounded-sm px-1.5 text-column tracking-wide uppercase outline-none',\n 'focus-visible:bg-fill-hover',\n logic === value ? 'bg-fill-hover text-foreground' : 'text-muted-foreground hover:text-foreground',\n )}\n onClick={() => logic !== value && ctx.setLogic(groupId, value)}\n >\n {value}\n </button>\n ))}\n </div>\n );\n}\n\nexport type FilterBarGroupEditorProps = {\n group: FilterBarGroup;\n /** Nesting level of `group` (root-level group = 1). */\n depth: number;\n /** Drops this group; rendered as a trailing `Clear all` in the footer. */\n onRemove?: () => void;\n removeLabel?: string;\n className?: string;\n};\n\n/**\n * Recursive rule builder shown in an advanced-filter popover. Rows are laid out as\n * `connector | condition`: the first row reads `where`, the following ones carry the\n * group's `and` / `or` toggle. Nested groups render as bordered cards with their own\n * header (logic switch + remove) and footer. The shared typeahead input renders as the\n * last row of the group it is pointed at.\n */\nexport function FilterBarGroupEditor({\n group,\n depth,\n onRemove,\n removeLabel = 'Remove group',\n className,\n}: FilterBarGroupEditorProps) {\n const ctx = useFilterBarContext();\n const addFilterRef = useRef<HTMLButtonElement>(null);\n const focusAddFilter = useRef(false);\n const targeted = ctx.inputTarget === group.id;\n const canNest = depth < ctx.maxDepth;\n\n // `+ Condition` is hidden while the input is open; focus it once it remounts.\n useEffect(() => {\n if (targeted || !focusAddFilter.current) return;\n focusAddFilter.current = false;\n addFilterRef.current?.focus();\n }, [targeted]);\n\n const rows: ReactNode[] = [];\n const connector = (key: string) =>\n rows.length === 0 ? (\n <span key={`${key}:where`} className={connectorClass}>\n where\n </span>\n ) : (\n <FilterBarLogicToggle key={`${key}:logic`} groupId={group.id} logic={group.logic} />\n );\n for (const node of group.nodes) {\n rows.push(\n <Fragment key={node.id}>\n {connector(node.id)}\n {isFilterBarGroup(node) ? (\n <NestedGroupCard group={node} depth={depth + 1} />\n ) : (\n <FilterBarChip item={node} className=\"w-fit\" />\n )}\n </Fragment>,\n );\n }\n if (ctx.draft && ctx.draft.groupId === group.id) {\n const { id, fieldId, operatorId = '' } = ctx.draft;\n rows.push(\n <Fragment key={id}>\n {connector(id)}\n <FilterBarChip draft item={{ id, fieldId, operatorId, value: '' }} className=\"w-fit\" />\n </Fragment>,\n );\n }\n if (targeted) {\n rows.push(\n <Fragment key=\"input\">\n {connector('input')}\n <FilterBarInput\n groupId={group.id}\n placeholder=\"Add condition\"\n onLeave={() => {\n focusAddFilter.current = true;\n }}\n />\n </Fragment>,\n );\n }\n\n return (\n <div\n data-slot=\"filter-bar-group-editor\"\n data-depth={depth}\n role=\"group\"\n aria-label={`Conditions joined with ${group.logic}`}\n className={cn('flex min-w-0 flex-col', className)}\n >\n {rows.length > 0 && (\n <div className=\"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-x-2 gap-y-1.5 p-2\">{rows}</div>\n )}\n <div\n data-slot=\"filter-bar-editor-actions\"\n className={cn('flex w-full items-center gap-1 p-1', rows.length > 0 && 'border-t border-border')}\n >\n {!targeted && (\n <Button\n ref={addFilterRef}\n variant=\"ghost\"\n size=\"sm\"\n icon={<PlusIcon />}\n onClick={() => ctx.openGroupInput(group.id)}\n >\n Condition\n </Button>\n )}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<FolderPlusIcon />}\n className=\"text-muted-foreground\"\n tooltip={canNest ? undefined : `Groups can nest ${ctx.maxDepth} levels deep`}\n disabled={!canNest}\n onClick={() => ctx.addGroup(group.id, group.logic === 'and' ? 'or' : 'and')}\n >\n Group\n </Button>\n {onRemove && (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon={<Trash2Icon />}\n className=\"ml-auto text-muted-foreground\"\n aria-label={removeLabel}\n onClick={onRemove}\n >\n Clear all\n </Button>\n )}\n </div>\n </div>\n );\n}\n\nfunction NestedGroupCard({ group, depth }: { group: FilterBarGroup; depth: number }) {\n const ctx = useFilterBarContext();\n const rootRef = useRef<HTMLDivElement>(null);\n const leaving = ctx.leaving.has(group.id);\n useSettleOnLeave(group.id, leaving, rootRef);\n const count = countLeaves(group);\n\n return (\n <div\n ref={rootRef}\n data-slot=\"filter-bar-editor-nested\"\n data-leaving={leaving || undefined}\n aria-hidden={leaving || undefined}\n className={cn(\n 'filter-bar-editor-nested w-full overflow-hidden rounded-lg border border-border',\n leaving && 'pointer-events-none',\n )}\n >\n <div className=\"flex items-center gap-2 border-b border-border px-2 py-1\">\n <FolderIcon className=\"size-3.5 text-muted-foreground\" />\n <Txt as=\"span\" variant=\"label\" tone=\"ink\">\n Group\n </Txt>\n <Txt as=\"span\" variant=\"label\" tone=\"muted\">\n · {count} {count === 1 ? 'condition' : 'conditions'}\n </Txt>\n <div className=\"ml-auto flex items-center gap-1\">\n <FilterBarLogicSwitch groupId={group.id} logic={group.logic} />\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n tooltip=\"Remove group\"\n disabled={leaving}\n onClick={() => ctx.removeGroup(group.id)}\n >\n <Trash2Icon />\n </Button>\n </div>\n </div>\n <FilterBarGroupEditor group={group} depth={depth} />\n </div>\n );\n}\n","import { BracesIcon, XIcon } from 'lucide-react';\nimport { useRef, useState } from 'react';\nimport type { KeyboardEvent } from 'react';\nimport { chipClass, editableSegmentClass, removeSegmentClass } from './filter-bar-chip';\nimport { FILTER_BAR_SCOPE_ATTR, useFilterBarContext } from './filter-bar-context';\nimport { FilterBarGroupEditor } from './filter-bar-group-editor';\nimport { countLeaves } from './filter-bar-tree';\nimport type { FilterBarGroup } from './types';\nimport { useSettleOnLeave } from './use-settle-on-leave';\nimport { Button } from '@/ds/components/Button/Button';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ds/components/Popover';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport type FilterBarAdvancedChipProps = {\n group: FilterBarGroup;\n className?: string;\n};\n\n/**\n * A root-level group rendered as one \"Advanced filter\" chip. Its popover hosts the\n * recursive rule builder; the chip's remove button drops the whole subtree.\n */\nexport function FilterBarAdvancedChip({ group, className }: FilterBarAdvancedChipProps) {\n const ctx = useFilterBarContext();\n const [initial] = useState(() => !ctx.mounted);\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const leaving = ctx.leaving.has(group.id);\n const open = ctx.openGroupId === group.id;\n const count = countLeaves(group);\n // Position in the flattened item list: navigation from the chip continues from its first leaf.\n const firstLeafIndex = ctx.items.findIndex(item => isUnder(group, item.id));\n const index = firstLeafIndex === -1 ? ctx.items.length : firstLeafIndex;\n useSettleOnLeave(group.id, leaving, rootRef);\n\n const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n if (leaving) return;\n const segments = Array.from(rootRef.current?.querySelectorAll<HTMLElement>('[data-filter-bar-segment]') ?? []);\n const current = segments.findIndex(el => el === event.target);\n if (current === -1) return;\n switch (event.key) {\n case 'ArrowRight': {\n event.preventDefault();\n const next = segments[current + 1];\n if (next) next.focus();\n else if (!ctx.focusChip(index + count, 1, 'field')) ctx.focusInput();\n return;\n }\n case 'ArrowLeft': {\n event.preventDefault();\n const prev = segments[current - 1];\n if (prev) prev.focus();\n else ctx.focusChip(index - 1, -1, 'remove');\n return;\n }\n case 'Delete':\n case 'Backspace':\n event.preventDefault();\n remove();\n break;\n default:\n }\n };\n\n const remove = () => {\n ctx.removeGroup(group.id);\n ctx.focusAfterRemove(index);\n };\n\n return (\n <Popover open={open} onOpenChange={next => ctx.setOpenGroup(next ? group.id : null)}>\n <div\n ref={rootRef}\n role=\"group\"\n aria-label={`Advanced filter, ${count} ${count === 1 ? 'condition' : 'conditions'}`}\n aria-hidden={leaving || undefined}\n data-slot=\"filter-bar-advanced\"\n data-initial={initial || undefined}\n data-leaving={leaving || undefined}\n className={cn('filter-bar-advanced', chipClass, leaving && 'pointer-events-none', className)}\n onKeyDown={handleKeyDown}\n >\n <PopoverTrigger\n ref={el => {\n triggerRef.current = el;\n ctx.registerSegment(group.id, 'field', leaving ? null : el);\n }}\n render={<button type=\"button\" />}\n data-filter-bar-segment=\"field\"\n className={editableSegmentClass}\n title=\"Edit advanced filter\"\n >\n <BracesIcon aria-hidden />\n <span className=\"truncate\">Advanced filter</span>\n {count > 0 && (\n <Txt as=\"span\" variant=\"column\" tone=\"muted\" aria-hidden>\n {count}\n </Txt>\n )}\n </PopoverTrigger>\n {leaving ? (\n <span aria-hidden className={removeSegmentClass}>\n <XIcon />\n </span>\n ) : (\n <button\n type=\"button\"\n ref={el => ctx.registerSegment(group.id, 'remove', el)}\n data-filter-bar-segment=\"remove\"\n aria-label=\"Remove advanced filter\"\n title=\"Remove advanced filter\"\n className={removeSegmentClass}\n onClick={remove}\n >\n <XIcon />\n </button>\n )}\n </div>\n <PopoverContent\n align=\"start\"\n className=\"w-[min(92vw,44rem)] p-0\"\n {...{ [FILTER_BAR_SCOPE_ATTR]: 'advanced' }}\n finalFocus={triggerRef}\n >\n <div className=\"flex items-center gap-2 border-b border-border px-3 py-2\">\n <BracesIcon className=\"size-3.5 text-muted-foreground\" />\n <Txt as=\"span\" variant=\"label\" tone=\"ink\">\n Advanced filter\n </Txt>\n <Txt as=\"span\" variant=\"column\" tone=\"muted\" className=\"rounded-md bg-fill-subtle px-1.5\">\n {count}\n </Txt>\n <Button\n variant=\"ghost\"\n size=\"icon-sm\"\n className=\"ml-auto\"\n tooltip=\"Close\"\n onClick={() => ctx.setOpenGroup(null)}\n >\n <XIcon />\n </Button>\n </div>\n <FilterBarGroupEditor\n group={group}\n depth={1}\n removeLabel=\"Remove advanced filter\"\n onRemove={() => {\n ctx.setOpenGroup(null);\n remove();\n }}\n />\n </PopoverContent>\n </Popover>\n );\n}\n\nconst isUnder = (group: FilterBarGroup, itemId: string): boolean =>\n group.nodes.some(node => (node.id === itemId ? true : 'kind' in node && isUnder(node, itemId)));\n","import { useFilterBarContext } from './filter-bar-context';\nimport { ClearFiltersButton } from '@/ds/components/ClearFiltersButton/clear-filters-button';\n\n/** Removes every removable filter. Rendered by FilterBar at its trailing edge; hidden while nothing can be removed. */\nexport function FilterBarClear({ label }: { label: string }) {\n const ctx = useFilterBarContext();\n if (!ctx.hasRemovableItems) return null;\n return (\n <ClearFiltersButton\n label={label}\n onClick={event => {\n event.stopPropagation();\n ctx.clear();\n ctx.focusInput();\n }}\n />\n );\n}\n","import { Fragment } from 'react';\nimport type { ReactNode } from 'react';\nimport { FilterBarAdvancedChip } from './filter-bar-advanced-chip';\nimport { FilterBarChip } from './filter-bar-chip';\nimport { FilterBarClear } from './filter-bar-clear';\nimport { FILTER_BAR_SCOPE_ATTR, FilterBarProvider, useFilterBarContext } from './filter-bar-context';\nimport { FilterBarInput } from './filter-bar-input';\nimport { FilterBarTimeRange } from './filter-bar-time-range';\nimport { isFilterBarGroup } from './types';\nimport type { FilterBarExpression, FilterBarField, FilterBarItem, FilterBarOperator } from './types';\nimport { VisuallyHidden } from '@/ds/primitives/visually-hidden';\nimport { cn } from '@/lib/utils';\n\ntype FilterBarValueProps =\n | {\n /** Flat list of filters, implicitly joined with `and`. Advanced filters are never offered. */\n value: FilterBarItem[];\n onValueChange: (items: FilterBarItem[]) => void;\n }\n | {\n /**\n * Tree of filters and groups. Root nodes are joined with `and`; each root group renders\n * as one \"Advanced filter\" chip whose popover edits the nested `and` / `or` logic.\n */\n value: FilterBarExpression;\n onValueChange: (expression: FilterBarExpression) => void;\n };\n\nexport type FilterBarProps = FilterBarValueProps & {\n fields: FilterBarField[];\n operators: FilterBarOperator[];\n /**\n * Id given to a newly added item. Defaults to a random id. Consumers that rebuild `value` from\n * their own store (URL, query params…) should return the id they will rebuild it with, so the\n * draft chip and the committed chip are the same element.\n */\n createItemId?: (fieldId: string) => string;\n /** How deep advanced-filter groups may nest (root-level group = 1). Defaults to 3. */\n maxDepth?: number;\n 'aria-label'?: string;\n /**\n * Text shown in a value list when the field's `suggestions` resolver rejects, for example\n * to explain a server limit. Return `undefined` to keep the default \"Couldn't load values.\".\n */\n describeSuggestionsError?: (error: unknown) => string | undefined;\n /** Accessible label of the trailing \"remove every filter\" button. */\n clearLabel?: string;\n className?: string;\n children: ReactNode;\n};\n\nfunction FilterBarSurface({\n className,\n clearLabel,\n children,\n}: {\n className?: string;\n clearLabel: string;\n children: ReactNode;\n}) {\n const ctx = useFilterBarContext();\n return (\n <div\n role=\"group\"\n aria-label={ctx.ariaLabel}\n data-slot=\"filter-bar\"\n {...{ [FILTER_BAR_SCOPE_ATTR]: 'bar' }}\n className={cn(\n // No chrome of its own: chips and the typeahead input sit directly on the parent surface.\n // Layout: chips, input, then Clear right beside the input — all in one wrapping row so\n // Clear never drifts to the far edge of a wide container.\n 'flex w-full flex-wrap items-center gap-1.5',\n className,\n )}\n >\n {children}\n <span className=\"flex shrink-0 items-center empty:hidden\">\n <FilterBarClear label={clearLabel} />\n </span>\n <VisuallyHidden aria-live=\"polite\">{ctx.announcement}</VisuallyHidden>\n </div>\n );\n}\n\n/**\n * Braintrust-style filter bar: `field → operator → value` filters built from a\n * single typeahead input, rendered as inline editable chips. Domain-agnostic —\n * fields, operators and values are plain strings supplied by the consumer.\n *\n * Pass a `FilterBarExpression` as `value` to enable Linear-style advanced filters:\n * the input offers \"Advanced filter…\", which adds one chip whose popover hosts a\n * recursive rule builder (`and` / `or` connectors, nested groups). The bar itself\n * stays flat. A flat `FilterBarItem[]` stays flat.\n *\n * @example\n * <FilterBar value={items} onValueChange={setItems} fields={fields} operators={DEFAULT_FILTER_OPERATORS}>\n * <FilterBar.Chips />\n * <FilterBar.Input />\n * </FilterBar>\n */\nexport function FilterBar({\n fields,\n operators,\n value,\n onValueChange,\n createItemId,\n maxDepth,\n 'aria-label': ariaLabel = 'Filters',\n describeSuggestionsError,\n clearLabel = 'Clear filters',\n className,\n children,\n}: FilterBarProps) {\n return (\n <FilterBarProvider\n fields={fields}\n operators={operators}\n value={value}\n onValueChange={onValueChange}\n createItemId={createItemId}\n maxDepth={maxDepth}\n ariaLabel={ariaLabel}\n describeSuggestionsError={describeSuggestionsError}\n >\n <FilterBarSurface className={className} clearLabel={clearLabel}>\n {children}\n </FilterBarSurface>\n </FilterBarProvider>\n );\n}\n\n/**\n * Default layout: one editable chip per root item, one \"Advanced filter\" chip per root\n * group, in order, then the chip of the filter being built in the bar's input (which\n * becomes the last item's chip once committed).\n */\nexport function FilterBarChips({ renderChip = defaultRenderChip }: FilterBarChipsProps) {\n const ctx = useFilterBarContext();\n // One keyed array: the draft chip and the item it becomes share a key, so React\n // keeps the element across the commit instead of mounting a new chip.\n const chips: ReactNode[] = [];\n for (const node of ctx.expression.nodes) {\n const chip = isFilterBarGroup(node) ? <FilterBarAdvancedChip group={node} /> : renderChip(node);\n if (chip !== null) chips.push(<Fragment key={node.id}>{chip}</Fragment>);\n }\n if (ctx.draft && !ctx.draft.groupId) {\n // `FilterBarChip` needs a full item; the draft's missing parts are blank until picked.\n const { id, fieldId, operatorId = '' } = ctx.draft;\n chips.push(\n <Fragment key={id}>\n <FilterBarChip draft item={{ id, fieldId, operatorId, value: '' }} />\n </Fragment>,\n );\n }\n return <>{chips}</>;\n}\n\nexport type FilterBarChipsProps = {\n /**\n * Chip for an item; return `null` to render none (e.g. an item only held in the\n * value for scoping). Defaults to a plain editable `FilterBar.Chip`.\n */\n renderChip?: (item: FilterBarItem) => ReactNode;\n};\n\nconst defaultRenderChip = (item: FilterBarItem) => <FilterBarChip item={item} />;\n\nFilterBar.Chips = FilterBarChips;\nFilterBar.Chip = FilterBarChip;\nFilterBar.AdvancedChip = FilterBarAdvancedChip;\nFilterBar.Input = FilterBarInput;\nFilterBar.TimeRange = FilterBarTimeRange;\n","import type { FilterBarOperator } from './types';\n\n/** Opt-in starter set. Pure data: the component attaches no semantics to ids. */\nexport const DEFAULT_FILTER_OPERATORS: FilterBarOperator[] = [\n { id: 'is', label: 'is', widensTo: 'in' },\n { id: 'is-not', label: 'is not' },\n { id: 'contains', label: 'contains' },\n { id: 'not-contains', label: 'does not contain' },\n { id: 'starts-with', label: 'starts with' },\n { id: 'gt', label: '>' },\n { id: 'lt', label: '<' },\n { id: 'gte', label: '>=' },\n { id: 'lte', label: '<=' },\n { id: 'is-empty', label: 'is empty', arity: 'none' },\n { id: 'is-not-empty', label: 'is not empty', arity: 'none' },\n { id: 'in', label: 'in', arity: 'many' },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,gBAAgB,SAAgB,WAAW,QAAQ,KAAK,QAAQ,KAAK,QAAQ,WAAW,OAAO,KAAK,QAAQ;AAElH,IAAM,cAA+B,CAAC;;AAEtC,IAAM,oBAAoB;AAC1B,IAAM,iBAAiC;CACrC,IAAI;CACJ,OAAO;CACP,MAAM;CACN,WAAW,CAAC;AACd;;;;;AAmBA,SAAgB,eAAe,OAA4B;CAEzD,IADY,oBACR,CAAA,CAAI,gBAAgB,MAAM,SAAS,OAAO;CAC9C,OAAO,oBAAC,oBAAD,EAAoB,GAAI,MAAQ,CAAA;AACzC;AAEA,SAAS,mBAAmB,EAC1B,cAAc,UACd,WACA,cAAc,YAAY,cAC1B,SACA,WACsB;CACtB,MAAM,MAAM,oBAAoB;CAChC,MAAM,YAAY,mBAAmB;CACrC,MAAM,WAAW,OAAgC,IAAI;CACrD,MAAM,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O;EAAY,OAAO;CAAO;CACnD;EAAE,IAAI;EAAgB,OAAO;EAAgB,OAAO;CAAO;CAC3D;EAAE,IAAI;EAAM,OAAO;EAAM,OAAO;CAAO;AACzC"}
@@ -44,7 +44,7 @@ function MetricsCardError({ message = "Failed to load data", className }) {
44
44
  /**
45
45
  * The header of a card with one large chart (an explorer, a detail page): the label over a large
46
46
  * value, the change against the previous period beside it. Cards in a grid use the compact title
47
- * and `MetricsCard.Total` instead. A skeleton while loading, in the value's own line box.
47
+ * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.
48
48
  */
49
49
  function MetricsCardHeadline({ label, value, change, isLoading = false, className }) {
50
50
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -55,13 +55,13 @@ function MetricsCardHeadline({ label, value, change, isLoading = false, classNam
55
55
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
56
56
  className: "flex items-baseline gap-2",
57
57
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
58
- className: "text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]",
59
- children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Skeleton.SkeletonText, {
60
- line: "text-title",
61
- className: "w-24"
62
- }) : value
58
+ className: require_utils.cn("text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]", isLoading && "relative min-w-24"),
59
+ children: isLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
60
+ className: "invisible",
61
+ children: "0"
62
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Skeleton.Skeleton, { className: "absolute inset-0" })] }) : value
63
63
  }), !isLoading && change && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
64
- className: "text-body-sm text-muted-foreground tabular-nums",
64
+ className: "text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]",
65
65
  children: [change, " vs previous"]
66
66
  })]
67
67
  })]
@@ -213,4 +213,4 @@ Object.defineProperty(exports, "MetricsCard", {
213
213
  }
214
214
  });
215
215
 
216
- //# sourceMappingURL=MetricsCard-CEB-f2sv.cjs.map
216
+ //# sourceMappingURL=MetricsCard-BEwiS7Pe.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCard-BEwiS7Pe.cjs","names":["cn","cn","cn","Txt","cn","_Fragment","Skeleton","cn","Spinner","cn","Txt","Card","cn","cn","DropdownMenu","cn","ChevronDownIcon","cn","cn","cn","SkeletonText","MetricsKpiCard"],"sources":["../src/ds/components/MetricsCard/metrics-card-actions.tsx","../src/ds/components/MetricsCard/metrics-card-content.tsx","../src/ds/components/MetricsCard/metrics-card-error.tsx","../src/ds/components/MetricsCard/metrics-card-headline.tsx","../src/ds/components/MetricsCard/metrics-card-loading.tsx","../src/ds/components/MetricsCard/metrics-card-no-data.tsx","../src/ds/components/MetricsCard/metrics-card-root.tsx","../src/ds/components/MetricsCard/metrics-card-title.tsx","../src/ds/components/MetricsCard/metrics-card-title-menu.tsx","../src/ds/components/MetricsCard/metrics-card-toolbar.tsx","../src/ds/components/MetricsCard/metrics-card-top-bar.tsx","../src/ds/components/MetricsCard/metrics-card-total.tsx","../src/ds/components/MetricsCard/metrics-card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/** Container for icon buttons / small actions in the top bar of a MetricsCard,\n * placed between the title and `Total` (which always renders last). Small (28px) buttons sit\n * centered on the 20px title line without making the top bar taller. */\nexport function MetricsCardActions({\n children,\n reveal = 'always',\n className,\n}: {\n children: ReactNode;\n /**\n * `hover`: the actions appear while the card is hovered or one of them has focus, so a page\n * of cards doesn't read as a page of buttons.\n */\n reveal?: 'always' | 'hover';\n className?: string;\n}) {\n return (\n <div\n className={cn(\n '-my-1 flex shrink-0 items-center gap-1 self-start',\n reveal === 'hover' &&\n 'opacity-0 transition-opacity duration-150 group-hover/metrics-card:opacity-100 focus-within:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * Scrolls sideways only (wide tables). Vertical overflow is hidden: a chart filling a card with a\n * fractional height rounds 1px past it, which otherwise turns the content into a scroll box.\n * Tables inside a card drop the last row's border: the card edge already closes them.\n */\nexport function MetricsCardContent({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('overflow-x-auto overflow-y-hidden [&_tbody>tr:last-child]:border-b-0', className)}>\n {children}\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardError({\n message = 'Failed to load data',\n className,\n}: {\n message?: string;\n className?: string;\n}) {\n return (\n <div className={cn('flex flex-col items-center justify-center gap-3', className)}>\n <Txt variant=\"caption\" className=\"text-destructive-foreground\">\n {message}\n </Txt>\n </div>\n );\n}\n","import { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * The header of a card with one large chart (an explorer, a detail page): the label over a large\n * value, the change against the previous period beside it. Cards in a grid use the compact title\n * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.\n */\nexport function MetricsCardHeadline({\n label,\n value,\n change,\n isLoading = false,\n className,\n}: {\n label: string;\n value: string;\n /** E.g. \"+71.4%\"; shown as \"+71.4% vs previous\". */\n change?: string;\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <div className={cn('grid gap-1.5', className)}>\n <h3 className=\"text-body-sm text-muted-foreground\">{label}</h3>\n <span className=\"flex items-baseline gap-2\">\n <span\n className={cn(\n 'text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]',\n isLoading && 'relative min-w-24',\n )}\n >\n {isLoading ? (\n // Hidden text keeps the value's trimmed height, so the row (and the actions centred on\n // it) doesn't move when the value arrives; the bar covers it.\n <>\n <span className=\"invisible\">0</span>\n <Skeleton className=\"absolute inset-0\" />\n </>\n ) : (\n value\n )}\n </span>\n {!isLoading &&\n change && (\n // Trimmed like the value, so its line box doesn't make the row taller than while loading.\n <span className=\"text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]\">\n {change} vs previous\n </span>\n )}\n </span>\n </div>\n );\n}\n","import { Spinner } from '@/ds/components/Spinner/spinner';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardLoading({ className }: { className?: string }) {\n return (\n <div className={cn('flex items-center justify-center', className)}>\n <Spinner size=\"md\" variant=\"pulse\" className=\"text-placeholder\" />\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardNoData({ message = 'No data yet', className }: { message?: string; className?: string }) {\n return (\n <div className={cn('flex h-full items-center justify-center', className)}>\n <Txt tone=\"faint\">{message}</Txt>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Card } from '@/ds/components/Card';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardRoot({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <Card\n className={cn(\n 'group/metrics-card grid min-h-72 min-w-80 flex-1 grid-rows-[auto_1fr] gap-4 px-4 py-3 2xl:min-w-120 md:min-w-88 lg:min-w-sm xl:min-w-104',\n className,\n )}\n >\n {children}\n </Card>\n );\n}\n","import { cn } from '@/lib/utils';\n\nexport function MetricsCardTitle({\n children,\n className,\n as: Tag = 'h3',\n}: {\n children: string;\n className?: string;\n as?: 'h2' | 'h3' | 'h4';\n}) {\n return <Tag className={cn('text-body font-medium text-foreground', className)}>{children}</Tag>;\n}\n","import { ChevronDownIcon } from 'lucide-react';\nimport { DropdownMenu } from '@/ds/components/DropdownMenu';\nimport type { DropdownMenuRadioOption } from '@/ds/components/DropdownMenu';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardTitleMenuProps<V extends string> = {\n /** The card title for the picked view (e.g. \"Spend by model\"). */\n title: string;\n value: V;\n onValueChange: (value: V) => void;\n /** The views (e.g. \"By model\", \"By provider\"). */\n options: readonly DropdownMenuRadioOption<V>[];\n className?: string;\n};\n\n/**\n * A card title that switches the card's view, as on Vercel's usage cards: the title is the\n * trigger, with a chevron. The hover fill bleeds past the text so the title stays aligned.\n * Wrapped, so the top bar stretches the wrapper rather than the button, and the menu's open-state\n * nodes next to the trigger don't become the top bar's first child.\n */\nexport function MetricsCardTitleMenu<V extends string>({\n title,\n value,\n onValueChange,\n options,\n className,\n}: MetricsCardTitleMenuProps<V>) {\n return (\n <div className=\"flex min-w-0\">\n <DropdownMenu>\n <DropdownMenu.Trigger\n render={\n <button\n type=\"button\"\n className={cn(\n '-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-body font-medium text-foreground hover:bg-fill-subtle',\n className,\n )}\n />\n }\n >\n {title}\n <ChevronDownIcon className=\"size-3.5 text-muted-foreground\" />\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\">\n <DropdownMenu.RadioOptions options={options} value={value} onValueChange={onValueChange} closeOnSelect />\n </DropdownMenu.Content>\n </DropdownMenu>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * One row under the top bar for a card's controls: a legend, list column headers.\n * The first child sits on the left, the last on the right; either side may be omitted. When\n * both don't fit (a narrow card), the right side wraps to its own line, still on the right. At least 24px\n * tall, so toolbars line up across cards in the same row.\n */\nexport function MetricsCardToolbar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div\n className={cn(\n 'flex min-h-6 min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 [&>*:first-child]:min-w-0 [&>*:last-child:not(:first-child)]:ml-auto',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardTopBar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('flex items-start gap-4 [&>:first-child]:min-w-0 [&>:first-child]:flex-1', className)}>\n {children}\n </div>\n );\n}\n","import { SkeletonText } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/** One of several totals in a card that charts a few series, marked with its series' color. */\nexport type MetricsCardTotalPart = { label: string; value: string; color: string };\n\n/**\n * A card's total, right of the title in the same type (14px, medium). Always the top\n * bar's last item. A skeleton while loading, in the value's own line box. A card charting a\n * few series of different things (resources, threads) can give one total each, each after a\n * marker in its series' color, like the legend.\n */\nexport function MetricsCardTotal({\n value,\n isLoading = false,\n className,\n}: {\n value: string | readonly MetricsCardTotalPart[];\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <span className={cn('order-last shrink-0 text-body font-medium text-foreground tabular-nums', className)}>\n <TotalValue value={value} isLoading={isLoading} />\n </span>\n );\n}\n\nfunction TotalValue({ value, isLoading }: { value: string | readonly MetricsCardTotalPart[]; isLoading: boolean }) {\n if (isLoading) return <SkeletonText line=\"text-body\" className=\"h-4 w-14\" />;\n if (typeof value === 'string') return value;\n return (\n <span className=\"inline-flex items-center gap-3\">\n {value.map(part => (\n <span key={part.label} className=\"inline-flex items-center gap-1.5\">\n <span aria-hidden className=\"size-2 shrink-0 rounded-[2px]\" style={{ backgroundColor: part.color }} />\n {/* The marker is decorative; screen readers hear which total this is. */}\n <span className=\"sr-only\">{part.label} </span>\n {part.value}\n </span>\n ))}\n </span>\n );\n}\n","import { MetricsCardActions } from './metrics-card-actions';\nimport { MetricsCardContent } from './metrics-card-content';\nimport { MetricsCardError } from './metrics-card-error';\nimport { MetricsCardHeadline } from './metrics-card-headline';\nimport { MetricsCardLoading } from './metrics-card-loading';\nimport { MetricsCardNoData } from './metrics-card-no-data';\nimport { MetricsCardRoot } from './metrics-card-root';\nimport { MetricsCardTitle } from './metrics-card-title';\nimport { MetricsCardTitleMenu } from './metrics-card-title-menu';\nimport { MetricsCardToolbar } from './metrics-card-toolbar';\nimport { MetricsCardTopBar } from './metrics-card-top-bar';\nimport { MetricsCardTotal } from './metrics-card-total';\nimport { MetricsKpiCard } from '@/ds/components/MetricsKpiCard';\n\nexport const MetricsCard = Object.assign(MetricsCardRoot, {\n Root: MetricsCardRoot,\n Kpi: MetricsKpiCard,\n TopBar: MetricsCardTopBar,\n Toolbar: MetricsCardToolbar,\n Actions: MetricsCardActions,\n Title: MetricsCardTitle,\n TitleMenu: MetricsCardTitleMenu,\n Total: MetricsCardTotal,\n Headline: MetricsCardHeadline,\n Loading: MetricsCardLoading,\n Error: MetricsCardError,\n Content: MetricsCardContent,\n NoData: MetricsCardNoData,\n});\n"],"mappings":";;;;;;;;;;;;;AAMA,SAAgB,mBAAmB,EACjC,UACA,SAAS,UACT,aASC;CACD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,WAAWA,cAAAA,GACT,qDACA,WAAW,WACT,2GACF,SACF;EAEC;CACE,CAAA;AAET;;;;;;;ACvBA,SAAgB,mBAAmB,EAAE,UAAU,aAA0D;CACvG,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAWC,cAAAA,GAAG,wEAAwE,SAAS;EACjG;CACE,CAAA;AAET;;ACXA,SAAgB,iBAAiB,EAC/B,UAAU,uBACV,aAIC;CACD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,WAAWC,cAAAA,GAAG,mDAAmD,SAAS;EAC7E,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,YAAAA,KAAD;GAAK,SAAQ;GAAU,WAAU;GAC9B,UAAA;EACE,CAAA;CACF,CAAA;AAET;;;;;;;ACTA,SAAgB,oBAAoB,EAClC,OACA,OACA,QACA,YAAY,OACZ,aAQC;CACD,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAWC,cAAAA,GAAG,gBAAgB,SAAS;EAA5C,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;GAAI,WAAU;GAAsC,UAAA;EAAU,CAAA,GAC9D,iBAAA,GAAA,kBAAA,KAAA,CA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A,kBAAA,IAAA,CAAC,QAAD;EAAM,WAAWC,cAAAA,GAAG,0EAA0E,SAAS;EACrG,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD;GAAmB;GAAkB;EAAY,CAAA;CAC7C,CAAA;AAEV;AAEA,SAAS,WAAW,EAAE,OAAO,aAAsF;CACjH,IAAI,WAAW,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,cAAD;EAAc,MAAK;EAAY,WAAU;CAAY,CAAA;CAC3E,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,WAAU;EACb,UAAA,MAAM,KAAI,SACT,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;GAAuB,WAAU;GAAjC,UAAA;IACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,eAAA;KAAY,WAAU;KAAgC,OAAO,EAAE,iBAAiB,KAAK,MAAM;IAAI,CAAA;IAErG,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAA2B,KAAK,OAAM,GAAO;;IAC5C,KAAK;GACF;EALK,GAAA,KAAK,KAKV,CACP;CACG,CAAA;AAEV;;AC7BA,IAAa,cAAc,OAAO,OAAO,iBAAiB;CACxD,MAAM;CACN,KAAKC,uBAAAA;CACL,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;CACP,WAAW;CACX,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { t as cn } from "./utils-DQx8TpNT.js";
2
2
  import { t as Txt } from "./Txt-BM6TVV_c.js";
3
3
  import { t as DropdownMenu } from "./dropdown-menu-B4jY3J9e.js";
4
- import { SkeletonText } from "./components/Skeleton.es.js";
4
+ import { Skeleton, SkeletonText } from "./components/Skeleton.es.js";
5
5
  import { t as Spinner } from "./spinner-CnLgLj9R.js";
6
6
  import { t as MetricsKpiCard } from "./MetricsKpiCard-OHbAElTl.js";
7
7
  import { t as Card } from "./Card-LU1aWO7U.js";
8
- import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { ChevronDownIcon } from "lucide-react";
10
10
  // src/ds/components/MetricsCard/metrics-card-actions.tsx
11
11
  /** Container for icon buttons / small actions in the top bar of a MetricsCard,
@@ -44,7 +44,7 @@ function MetricsCardError({ message = "Failed to load data", className }) {
44
44
  /**
45
45
  * The header of a card with one large chart (an explorer, a detail page): the label over a large
46
46
  * value, the change against the previous period beside it. Cards in a grid use the compact title
47
- * and `MetricsCard.Total` instead. A skeleton while loading, in the value's own line box.
47
+ * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.
48
48
  */
49
49
  function MetricsCardHeadline({ label, value, change, isLoading = false, className }) {
50
50
  return /* @__PURE__ */ jsxs("div", {
@@ -55,13 +55,13 @@ function MetricsCardHeadline({ label, value, change, isLoading = false, classNam
55
55
  }), /* @__PURE__ */ jsxs("span", {
56
56
  className: "flex items-baseline gap-2",
57
57
  children: [/* @__PURE__ */ jsx("span", {
58
- className: "text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]",
59
- children: isLoading ? /* @__PURE__ */ jsx(SkeletonText, {
60
- line: "text-title",
61
- className: "w-24"
62
- }) : value
58
+ className: cn("text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]", isLoading && "relative min-w-24"),
59
+ children: isLoading ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
60
+ className: "invisible",
61
+ children: "0"
62
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0" })] }) : value
63
63
  }), !isLoading && change && /* @__PURE__ */ jsxs("span", {
64
- className: "text-body-sm text-muted-foreground tabular-nums",
64
+ className: "text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]",
65
65
  children: [change, " vs previous"]
66
66
  })]
67
67
  })]
@@ -208,4 +208,4 @@ var MetricsCard = Object.assign(MetricsCardRoot, {
208
208
  });
209
209
  export { MetricsCard as t };
210
210
 
211
- //# sourceMappingURL=MetricsCard-M8awJ2B_.js.map
211
+ //# sourceMappingURL=MetricsCard-ua6C6b8a.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsCard-ua6C6b8a.js","names":["_Fragment"],"sources":["../src/ds/components/MetricsCard/metrics-card-actions.tsx","../src/ds/components/MetricsCard/metrics-card-content.tsx","../src/ds/components/MetricsCard/metrics-card-error.tsx","../src/ds/components/MetricsCard/metrics-card-headline.tsx","../src/ds/components/MetricsCard/metrics-card-loading.tsx","../src/ds/components/MetricsCard/metrics-card-no-data.tsx","../src/ds/components/MetricsCard/metrics-card-root.tsx","../src/ds/components/MetricsCard/metrics-card-title.tsx","../src/ds/components/MetricsCard/metrics-card-title-menu.tsx","../src/ds/components/MetricsCard/metrics-card-toolbar.tsx","../src/ds/components/MetricsCard/metrics-card-top-bar.tsx","../src/ds/components/MetricsCard/metrics-card-total.tsx","../src/ds/components/MetricsCard/metrics-card.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/** Container for icon buttons / small actions in the top bar of a MetricsCard,\n * placed between the title and `Total` (which always renders last). Small (28px) buttons sit\n * centered on the 20px title line without making the top bar taller. */\nexport function MetricsCardActions({\n children,\n reveal = 'always',\n className,\n}: {\n children: ReactNode;\n /**\n * `hover`: the actions appear while the card is hovered or one of them has focus, so a page\n * of cards doesn't read as a page of buttons.\n */\n reveal?: 'always' | 'hover';\n className?: string;\n}) {\n return (\n <div\n className={cn(\n '-my-1 flex shrink-0 items-center gap-1 self-start',\n reveal === 'hover' &&\n 'opacity-0 transition-opacity duration-150 group-hover/metrics-card:opacity-100 focus-within:opacity-100',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * Scrolls sideways only (wide tables). Vertical overflow is hidden: a chart filling a card with a\n * fractional height rounds 1px past it, which otherwise turns the content into a scroll box.\n * Tables inside a card drop the last row's border: the card edge already closes them.\n */\nexport function MetricsCardContent({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('overflow-x-auto overflow-y-hidden [&_tbody>tr:last-child]:border-b-0', className)}>\n {children}\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardError({\n message = 'Failed to load data',\n className,\n}: {\n message?: string;\n className?: string;\n}) {\n return (\n <div className={cn('flex flex-col items-center justify-center gap-3', className)}>\n <Txt variant=\"caption\" className=\"text-destructive-foreground\">\n {message}\n </Txt>\n </div>\n );\n}\n","import { Skeleton } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/**\n * The header of a card with one large chart (an explorer, a detail page): the label over a large\n * value, the change against the previous period beside it. Cards in a grid use the compact title\n * and `MetricsCard.Total` instead. A skeleton while loading, at the value's own trimmed height.\n */\nexport function MetricsCardHeadline({\n label,\n value,\n change,\n isLoading = false,\n className,\n}: {\n label: string;\n value: string;\n /** E.g. \"+71.4%\"; shown as \"+71.4% vs previous\". */\n change?: string;\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <div className={cn('grid gap-1.5', className)}>\n <h3 className=\"text-body-sm text-muted-foreground\">{label}</h3>\n <span className=\"flex items-baseline gap-2\">\n <span\n className={cn(\n 'text-title text-foreground tabular-nums [text-box:trim-both_cap_alphabetic]',\n isLoading && 'relative min-w-24',\n )}\n >\n {isLoading ? (\n // Hidden text keeps the value's trimmed height, so the row (and the actions centred on\n // it) doesn't move when the value arrives; the bar covers it.\n <>\n <span className=\"invisible\">0</span>\n <Skeleton className=\"absolute inset-0\" />\n </>\n ) : (\n value\n )}\n </span>\n {!isLoading &&\n change && (\n // Trimmed like the value, so its line box doesn't make the row taller than while loading.\n <span className=\"text-body-sm text-muted-foreground tabular-nums [text-box:trim-both_cap_alphabetic]\">\n {change} vs previous\n </span>\n )}\n </span>\n </div>\n );\n}\n","import { Spinner } from '@/ds/components/Spinner/spinner';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardLoading({ className }: { className?: string }) {\n return (\n <div className={cn('flex items-center justify-center', className)}>\n <Spinner size=\"md\" variant=\"pulse\" className=\"text-placeholder\" />\n </div>\n );\n}\n","import { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardNoData({ message = 'No data yet', className }: { message?: string; className?: string }) {\n return (\n <div className={cn('flex h-full items-center justify-center', className)}>\n <Txt tone=\"faint\">{message}</Txt>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { Card } from '@/ds/components/Card';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardRoot({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <Card\n className={cn(\n 'group/metrics-card grid min-h-72 min-w-80 flex-1 grid-rows-[auto_1fr] gap-4 px-4 py-3 2xl:min-w-120 md:min-w-88 lg:min-w-sm xl:min-w-104',\n className,\n )}\n >\n {children}\n </Card>\n );\n}\n","import { cn } from '@/lib/utils';\n\nexport function MetricsCardTitle({\n children,\n className,\n as: Tag = 'h3',\n}: {\n children: string;\n className?: string;\n as?: 'h2' | 'h3' | 'h4';\n}) {\n return <Tag className={cn('text-body font-medium text-foreground', className)}>{children}</Tag>;\n}\n","import { ChevronDownIcon } from 'lucide-react';\nimport { DropdownMenu } from '@/ds/components/DropdownMenu';\nimport type { DropdownMenuRadioOption } from '@/ds/components/DropdownMenu';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsCardTitleMenuProps<V extends string> = {\n /** The card title for the picked view (e.g. \"Spend by model\"). */\n title: string;\n value: V;\n onValueChange: (value: V) => void;\n /** The views (e.g. \"By model\", \"By provider\"). */\n options: readonly DropdownMenuRadioOption<V>[];\n className?: string;\n};\n\n/**\n * A card title that switches the card's view, as on Vercel's usage cards: the title is the\n * trigger, with a chevron. The hover fill bleeds past the text so the title stays aligned.\n * Wrapped, so the top bar stretches the wrapper rather than the button, and the menu's open-state\n * nodes next to the trigger don't become the top bar's first child.\n */\nexport function MetricsCardTitleMenu<V extends string>({\n title,\n value,\n onValueChange,\n options,\n className,\n}: MetricsCardTitleMenuProps<V>) {\n return (\n <div className=\"flex min-w-0\">\n <DropdownMenu>\n <DropdownMenu.Trigger\n render={\n <button\n type=\"button\"\n className={cn(\n '-mx-1.5 -my-0.5 flex items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-left text-body font-medium text-foreground hover:bg-fill-subtle',\n className,\n )}\n />\n }\n >\n {title}\n <ChevronDownIcon className=\"size-3.5 text-muted-foreground\" />\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"start\">\n <DropdownMenu.RadioOptions options={options} value={value} onValueChange={onValueChange} closeOnSelect />\n </DropdownMenu.Content>\n </DropdownMenu>\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\n/**\n * One row under the top bar for a card's controls: a legend, list column headers.\n * The first child sits on the left, the last on the right; either side may be omitted. When\n * both don't fit (a narrow card), the right side wraps to its own line, still on the right. At least 24px\n * tall, so toolbars line up across cards in the same row.\n */\nexport function MetricsCardToolbar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div\n className={cn(\n 'flex min-h-6 min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 [&>*:first-child]:min-w-0 [&>*:last-child:not(:first-child)]:ml-auto',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n","import type { ReactNode } from 'react';\nimport { cn } from '@/lib/utils';\n\nexport function MetricsCardTopBar({ children, className }: { children: ReactNode; className?: string }) {\n return (\n <div className={cn('flex items-start gap-4 [&>:first-child]:min-w-0 [&>:first-child]:flex-1', className)}>\n {children}\n </div>\n );\n}\n","import { SkeletonText } from '@/ds/components/Skeleton';\nimport { cn } from '@/lib/utils';\n\n/** One of several totals in a card that charts a few series, marked with its series' color. */\nexport type MetricsCardTotalPart = { label: string; value: string; color: string };\n\n/**\n * A card's total, right of the title in the same type (14px, medium). Always the top\n * bar's last item. A skeleton while loading, in the value's own line box. A card charting a\n * few series of different things (resources, threads) can give one total each, each after a\n * marker in its series' color, like the legend.\n */\nexport function MetricsCardTotal({\n value,\n isLoading = false,\n className,\n}: {\n value: string | readonly MetricsCardTotalPart[];\n isLoading?: boolean;\n className?: string;\n}) {\n return (\n <span className={cn('order-last shrink-0 text-body font-medium text-foreground tabular-nums', className)}>\n <TotalValue value={value} isLoading={isLoading} />\n </span>\n );\n}\n\nfunction TotalValue({ value, isLoading }: { value: string | readonly MetricsCardTotalPart[]; isLoading: boolean }) {\n if (isLoading) return <SkeletonText line=\"text-body\" className=\"h-4 w-14\" />;\n if (typeof value === 'string') return value;\n return (\n <span className=\"inline-flex items-center gap-3\">\n {value.map(part => (\n <span key={part.label} className=\"inline-flex items-center gap-1.5\">\n <span aria-hidden className=\"size-2 shrink-0 rounded-[2px]\" style={{ backgroundColor: part.color }} />\n {/* The marker is decorative; screen readers hear which total this is. */}\n <span className=\"sr-only\">{part.label} </span>\n {part.value}\n </span>\n ))}\n </span>\n );\n}\n","import { MetricsCardActions } from './metrics-card-actions';\nimport { MetricsCardContent } from './metrics-card-content';\nimport { MetricsCardError } from './metrics-card-error';\nimport { MetricsCardHeadline } from './metrics-card-headline';\nimport { MetricsCardLoading } from './metrics-card-loading';\nimport { MetricsCardNoData } from './metrics-card-no-data';\nimport { MetricsCardRoot } from './metrics-card-root';\nimport { MetricsCardTitle } from './metrics-card-title';\nimport { MetricsCardTitleMenu } from './metrics-card-title-menu';\nimport { MetricsCardToolbar } from './metrics-card-toolbar';\nimport { MetricsCardTopBar } from './metrics-card-top-bar';\nimport { MetricsCardTotal } from './metrics-card-total';\nimport { MetricsKpiCard } from '@/ds/components/MetricsKpiCard';\n\nexport const MetricsCard = Object.assign(MetricsCardRoot, {\n Root: MetricsCardRoot,\n Kpi: MetricsKpiCard,\n TopBar: MetricsCardTopBar,\n Toolbar: MetricsCardToolbar,\n Actions: MetricsCardActions,\n Title: MetricsCardTitle,\n TitleMenu: MetricsCardTitleMenu,\n Total: MetricsCardTotal,\n Headline: MetricsCardHeadline,\n Loading: MetricsCardLoading,\n Error: MetricsCardError,\n Content: MetricsCardContent,\n NoData: MetricsCardNoData,\n});\n"],"mappings":";;;;;;;;;;;;;AAMA,SAAgB,mBAAmB,EACjC,UACA,SAAS,UACT,aASC;CACD,OACE,oBAAC,OAAD;EACE,WAAW,GACT,qDACA,WAAW,WACT,2GACF,SACF;EAEC;CACE,CAAA;AAET;;;;;;;ACvBA,SAAgB,mBAAmB,EAAE,UAAU,aAA0D;CACvG,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,wEAAwE,SAAS;EACjG;CACE,CAAA;AAET;;ACXA,SAAgB,iBAAiB,EAC/B,UAAU,uBACV,aAIC;CACD,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,mDAAmD,SAAS;EAC7E,UAAA,oBAAC,KAAD;GAAK,SAAQ;GAAU,WAAU;GAC9B,UAAA;EACE,CAAA;CACF,CAAA;AAET;;;;;;;ACTA,SAAgB,oBAAoB,EAClC,OACA,OACA,QACA,YAAY,OACZ,aAQC;CACD,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,SAAS;EAA5C,UAAA,CACE,oBAAC,MAAD;GAAI,WAAU;GAAsC,UAAA;EAAU,CAAA,GAC9D,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACE,oBAAC,QAAD;IACE,WAAW,GACT,+EACA,aAAa,mBACf;IAEC,UAAA,YAGC,qBAAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAY,UAAA;IAAO,CAAA,GACnC,oBAAC,UAAD,EAAU,WAAU,mBAAoB,CAAA,CACxC,EAAA,CAAA,IAEF;GAEE,CAAA,GACL,CAAC,aACA,UAEE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACG,QAAO,cACJ;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oJACA,SACF;EAEC;CACE,CAAA;AAET;;ACjBA,SAAgB,kBAAkB,EAAE,UAAU,aAA0D;CACtG,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,2EAA2E,SAAS;EACpG;CACE,CAAA;AAET;;;;;;;;ACGA,SAAgB,iBAAiB,EAC/B,OACA,YAAY,OACZ,aAKC;CACD,OACE,oBAAC,QAAD;EAAM,WAAW,GAAG,0EAA0E,SAAS;EACrG,UAAA,oBAAC,YAAD;GAAmB;GAAkB;EAAY,CAAA;CAC7C,CAAA;AAEV;AAEA,SAAS,WAAW,EAAE,OAAO,aAAsF;CACjH,IAAI,WAAW,OAAO,oBAAC,cAAD;EAAc,MAAK;EAAY,WAAU;CAAY,CAAA;CAC3E,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OACE,oBAAC,QAAD;EAAM,WAAU;EACb,UAAA,MAAM,KAAI,SACT,qBAAC,QAAD;GAAuB,WAAU;GAAjC,UAAA;IACE,oBAAC,QAAD;KAAM,eAAA;KAAY,WAAU;KAAgC,OAAO,EAAE,iBAAiB,KAAK,MAAM;IAAI,CAAA;IAErG,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CAA2B,KAAK,OAAM,GAAO;;IAC5C,KAAK;GACF;EALK,GAAA,KAAK,KAKV,CACP;CACG,CAAA;AAEV;;AC7BA,IAAa,cAAc,OAAO,OAAO,iBAAiB;CACxD,MAAM;CACN,KAAK;CACL,QAAQ;CACR,SAAS;CACT,SAAS;CACT,OAAO;CACP,WAAW;CACX,OAAO;CACP,UAAU;CACV,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;AACV,CAAC"}
@@ -9,7 +9,7 @@ import { ChartPlot } from "./primitives/chart-plot.es.js";
9
9
  import { ChartTooltipPosition } from "./primitives/chart-tooltip-position.es.js";
10
10
  import { useChartDefsId } from "./primitives/use-chart-defs-id.es.js";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
- import { Area, CartesianGrid, ComposedChart, Line, Tooltip } from "recharts";
12
+ import { Area, CartesianGrid, ComposedChart, Line, ReferenceLine, Tooltip } from "recharts";
13
13
  // src/ds/components/MetricsLineChart/metrics-line-chart-legend.tsx
14
14
  /** A marker and a label per series. Totals belong in the card's header, not here. */
15
15
  function MetricsLineChartLegend({ series, className }) {
@@ -141,7 +141,7 @@ function MetricsLineChart(props) {
141
141
  });
142
142
  }
143
143
  /** The plot itself, once the data is in. */
144
- function LinePlot({ data, series, height = 210, yDomain, onPointClick, onBucketClick, xKey = "time", timestampKey = "tsMs", xLabels = "auto", tooltipLabelKey, showDots = false, dots = "auto", lineStyle = "default", valueFormatter, axisFormatter, showYAxis = true }) {
144
+ function LinePlot({ data, series, height = 210, yDomain, onPointClick, onBucketClick, xKey = "time", timestampKey = "tsMs", xLabels = "auto", tooltipLabelKey, showDots = false, dots = "auto", lineStyle = "default", valueFormatter, axisFormatter, showYAxis = true, markers = [] }) {
145
145
  const id = useChartDefsId();
146
146
  const { size, onResize, ref } = useChartSize();
147
147
  const format = valueFormatter ?? compactNumber.format;
@@ -212,6 +212,17 @@ function LinePlot({ data, series, height = 210, yDomain, onPointClick, onBucketC
212
212
  max: dataMax(data, series.map((s) => s.dataKey)),
213
213
  integer: isWholeData(data, series.map((s) => s.dataKey))
214
214
  }),
215
+ markers.map((m) => /* @__PURE__ */ jsx(ReferenceLine, {
216
+ x: m.x,
217
+ stroke: "var(--border-strong)",
218
+ strokeDasharray: "3 3",
219
+ label: m.label ? {
220
+ value: m.label,
221
+ position: "insideTopLeft",
222
+ fill: "var(--muted-foreground)",
223
+ fontSize: 11
224
+ } : void 0
225
+ }, m.x)),
215
226
  /* @__PURE__ */ jsx(Tooltip, {
216
227
  ...CHART_TOOLTIP_PROPS,
217
228
  content: /* @__PURE__ */ jsx(ChartTooltipPosition, { children: /* @__PURE__ */ jsx(MetricsLineChartTooltip, {
@@ -248,4 +259,4 @@ function isRecord(value) {
248
259
  }
249
260
  export { MetricsLineChartTooltip as n, MetricsLineChartLegend as r, MetricsLineChart as t };
250
261
 
251
- //# sourceMappingURL=MetricsLineChart-BhHoduO0.js.map
262
+ //# sourceMappingURL=MetricsLineChart-4SwxBbQx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricsLineChart-4SwxBbQx.js","names":[],"sources":["../src/ds/components/MetricsLineChart/metrics-line-chart-legend.tsx","../src/ds/components/MetricsLineChart/metrics-line-chart-tooltip.tsx","../src/ds/components/MetricsLineChart/metrics-line-chart.tsx"],"sourcesContent":["import type { MetricsLineChartSeries } from './metrics-line-chart';\nimport { Txt } from '@/ds/components/Txt';\nimport { cn } from '@/lib/utils';\n\n/** A marker and a label per series. Totals belong in the card's header, not here. */\nexport function MetricsLineChartLegend({\n series,\n className,\n}: {\n series: Pick<MetricsLineChartSeries, 'dataKey' | 'label' | 'color' | 'dashed'>[];\n className?: string;\n}) {\n return (\n <div className={cn('flex flex-wrap items-center gap-x-4 gap-y-1', className)}>\n {series.map(s => (\n <div key={s.dataKey} className=\"inline-flex items-center gap-1.5\">\n {s.dashed ? (\n <span className=\"h-0 w-3 shrink-0 border-t-2 border-dashed\" style={{ borderColor: s.color }} />\n ) : (\n <div className=\"size-2 shrink-0 rounded-[2px]\" style={{ backgroundColor: s.color }} />\n )}\n <Txt as=\"span\" variant=\"body-sm\" tone=\"muted\" className=\"max-w-48 truncate\">\n {s.label}\n </Txt>\n </div>\n ))}\n </div>\n );\n}\n","import { ChartTooltip } from '@/ds/components/ChartTooltip';\nimport { Txt } from '@/ds/components/Txt';\n\nexport function MetricsLineChartTooltip({\n active,\n payload,\n label,\n suffix,\n formatValue = value => value.toLocaleString('en-US'),\n showTotal = false,\n labelKey,\n formatByKey,\n}: {\n active?: boolean;\n payload?: Array<{\n name: string;\n value: number;\n color: string;\n dataKey?: string | number;\n payload?: Record<string, unknown>;\n }>;\n label?: string;\n suffix?: string;\n formatValue?: (value: number) => string;\n /** Adds a \"Total\" row under a hairline: the sum of every row, e.g. a stacked column's height. */\n showTotal?: boolean;\n /** Read the heading from this field of the hovered row instead of the x-axis label. */\n labelKey?: string;\n /** Per-series formatters, by data key, for charts that mix units (counts and durations). */\n formatByKey?: Record<string, (value: number) => string>;\n}) {\n if (!active || !payload?.length) return null;\n // A missing reading (NaN, Infinity) shows as a dash and stays out of the total.\n const finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);\n const total = payload.reduce((sum, entry) => sum + (finite(entry.value) ? entry.value : 0), 0);\n // A bucket with no readings at all totals to a dash, not 0.\n const hasReading = payload.some(entry => finite(entry.value));\n const heading = labelKey ? String(payload[0]?.payload?.[labelKey] ?? label ?? '') : label;\n const format = (entry: { dataKey?: string | number }) => formatByKey?.[String(entry.dataKey)] ?? formatValue;\n // A number through its formatter; a missing or non-finite one as a dash; text as it is.\n const reading = (entry: (typeof payload)[number]) => {\n if (finite(entry.value)) return format(entry)(entry.value);\n if (typeof entry.value === 'number' || entry.value == null) return '—';\n return entry.value;\n };\n return (\n // A floor like shadcn's chart tooltip, so short readouts don't size it to their own label.\n <ChartTooltip className=\"min-w-32\">\n <Txt variant=\"column\" tone=\"ink\" className=\"mb-1\">\n {heading}\n </Txt>\n <div className=\"grid grid-cols-[auto_1fr_auto] items-center gap-x-2 gap-y-1\">\n {payload.map(entry => (\n <div key={entry.name} className=\"contents\">\n <span className=\"size-2 rounded-[2px]\" style={{ backgroundColor: entry.color }} />\n <Txt as=\"span\" variant=\"caption\" tone=\"muted\" className=\"max-w-40 truncate\">\n {entry.name}\n </Txt>\n <span className=\"text-right font-mono text-foreground tabular-nums\">\n {reading(entry)}\n {finite(entry.value) && suffix}\n </span>\n </div>\n ))}\n {showTotal && (\n <div className=\"col-span-3 grid grid-cols-subgrid items-center border-t border-border pt-1\">\n <Txt as=\"span\" variant=\"caption\" tone=\"muted\" className=\"col-span-2\">\n Total\n </Txt>\n <span className=\"text-right font-mono text-foreground tabular-nums\">\n {hasReading ? formatValue(total) : '—'}\n {hasReading && suffix}\n </span>\n </div>\n )}\n </div>\n </ChartTooltip>\n );\n}\n","import { Area, CartesianGrid, ComposedChart, Line, ReferenceLine, Tooltip } from 'recharts';\nimport { MetricsLineChartLegend } from './metrics-line-chart-legend';\nimport { MetricsLineChartTooltip } from './metrics-line-chart-tooltip';\nimport { ChartSkeleton } from '@/ds/components/ChartSkeleton';\nimport { CHART_CURSOR_PROPS, CHART_GRID_PROPS, CHART_TOOLTIP_PROPS, useChartSize } from '@/ds/primitives/chart-axes';\nimport type { ChartXLabels } from '@/ds/primitives/chart-axes';\nimport { Y_AXIS_WIDTH, compactNumber, dataMax, isWholeData, timeXAxis, valueYAxis } from '@/ds/primitives/chart-frame';\nimport type { ChartHeight } from '@/ds/primitives/chart-frame';\nimport { CHART_MARGIN } from '@/ds/primitives/chart-layout';\nimport { ChartPlot } from '@/ds/primitives/chart-plot';\nimport { ChartTooltipPosition } from '@/ds/primitives/chart-tooltip-position';\nimport { useChartDefsId } from '@/ds/primitives/use-chart-defs-id';\nimport { cn } from '@/lib/utils';\n\nexport type MetricsLineChartSeries = {\n dataKey: string;\n label: string;\n color: string;\n /** A secondary reading (e.g. an average next to counts): dashed, no fill under it. */\n dashed?: boolean;\n /** The series to read first (e.g. P95 among percentiles): a slightly heavier line. */\n emphasis?: boolean;\n};\n\n/** Line weight; an emphasised series adds half a pixel. */\nconst LINE_WIDTH = 1.75;\n/** Opacity at the top of the fill under a line (it fades to nothing at the base). */\nconst AREA_OPACITY = 0.12;\n\n/**\n * How the series draw.\n * - `default`: 1.75px lines over a fill.\n * - `thin`: 1.5px lines (emphasis included) over a fainter fill (40% of the default), for small\n * cards in a grid.\n */\nexport type MetricsLineChartLineStyle = 'default' | 'thin';\n\nconst LINE_STYLES: Record<MetricsLineChartLineStyle, { width: number; emphasis: number; areaOpacity: number }> = {\n default: { width: LINE_WIDTH, emphasis: LINE_WIDTH + 0.5, areaOpacity: AREA_OPACITY },\n thin: { width: 1.5, emphasis: 1.5, areaOpacity: AREA_OPACITY * 0.4 },\n};\n\n/**\n * Fills fade out sideways over their first and last 24px, so they don't end in a hard vertical\n * edge where the line starts and stops. A mask sized to each fill's own box.\n */\nconst THIN_FILL_FADE = '[&_.recharts-area-area]:mask-x-from-[calc(100%-24px)]';\n/** A lone point draws no line at all, so it gets a dot; lines already bridge gaps (`connectNulls`). */\nconst SPARSE_POINTS = 1;\n\n// Jumps straight to the hovered point, with the dots and the tooltip.\nfunction HoverLine({ points }: { points?: { x: number; y: number }[] }) {\n const [top, bottom] = points ?? [];\n if (!top || !bottom) return null;\n return (\n <line x1={top.x} x2={top.x} y1={top.y} y2={bottom.y} {...CHART_CURSOR_PROPS} className=\"pointer-events-none\" />\n );\n}\n\nexport type MetricsLineChartPointClickHandler = (point: Record<string, unknown>, seriesKey: string) => void;\n\nexport type MetricsLineChartProps = {\n data: Record<string, unknown>[];\n series: MetricsLineChartSeries[];\n /** Pixels, or `fill` to grow with the parent (a flex column, e.g. a card's content). */\n height?: ChartHeight;\n yDomain?: [number, number];\n /** Click on a series' active dot. */\n onPointClick?: MetricsLineChartPointClickHandler;\n /** Click anywhere on a bucket (e.g. to open its traces); the plot shows a pointer cursor. */\n onBucketClick?: (row: Record<string, unknown>, index: number) => void;\n /** Row field printed under the x-axis. */\n xKey?: string;\n /** Row field with the bucket's start time (ms), which places labels on round clock times. */\n timestampKey?: string;\n /** `auto` fits as many labels as the width allows; `edges` prints only the first and last. */\n xLabels?: ChartXLabels;\n /** Row field for the tooltip heading (e.g. a longer date); defaults to the x-axis label. */\n tooltipLabelKey?: string;\n /** Render a visible dot on every point. A series with a single point gets one anyway. */\n showDots?: boolean;\n /**\n * Point markers. `auto`: on a series' lone point (or every point with `showDots`). `hover`:\n * none at rest, only the hovered point's.\n */\n dots?: 'auto' | 'hover';\n /** Line weight and fill. `thin` suits small cards in a grid. */\n lineStyle?: MetricsLineChartLineStyle;\n /** Set to `false` to render `MetricsLineChartLegend` elsewhere, e.g. next to tabs. */\n showLegend?: boolean;\n /** Formats tooltip values (e.g. `ms`, `%`), and y-axis ticks unless `axisFormatter` is set. */\n valueFormatter?: (value: number) => string;\n /** Formats y-axis ticks, when they need a shorter form than the tooltip. */\n axisFormatter?: (value: number) => string;\n /**\n * Set to `false` to drop the y-axis labels and let the plot span the card. The gridlines stay\n * for relative scale; exact values come from the tooltip and the card's summary.\n */\n showYAxis?: boolean;\n /** Show a ghost of the chart while data loads, in the chart's own footprint. */\n isLoading?: boolean;\n /**\n * Vertical lines at buckets, e.g. where a billing period starts. `x` must be one of the data's\n * `xKey` values: the axis is categorical, so any other value draws nothing.\n */\n markers?: { x: string; label?: string }[];\n className?: string;\n};\n\nexport function MetricsLineChart(props: MetricsLineChartProps) {\n const { data, series, height = 210, showLegend = true, isLoading = false, className } = props;\n const root = cn(height === 'fill' && 'flex min-h-0 flex-1 flex-col', className);\n // The legend stays while loading: it comes from the series, not the data.\n return (\n <div className={root}>\n {showLegend && <MetricsLineChartLegend series={series} className=\"mb-4\" />}\n {isLoading ? <ChartSkeleton kind=\"line\" height={height} /> : <LinePlot {...props} />}\n </div>\n );\n}\n\n/** The plot itself, once the data is in. */\nfunction LinePlot({\n data,\n series,\n height = 210,\n yDomain,\n onPointClick,\n onBucketClick,\n xKey = 'time',\n timestampKey = 'tsMs',\n xLabels = 'auto',\n tooltipLabelKey,\n showDots = false,\n dots = 'auto',\n lineStyle = 'default',\n valueFormatter,\n axisFormatter,\n showYAxis = true,\n markers = [],\n}: MetricsLineChartProps) {\n const id = useChartDefsId();\n const { size, onResize, ref } = useChartSize();\n\n const format = valueFormatter ?? compactNumber.format;\n const isSparse = (key: string) => data.filter(row => typeof row[key] === 'number').length <= SPARSE_POINTS;\n const plotWidth = size.width - (showYAxis ? Y_AXIS_WIDTH : 0);\n const line = LINE_STYLES[lineStyle];\n const restDot = (s: MetricsLineChartSeries) =>\n dots === 'auto' && (showDots || isSparse(s.dataKey)) ? { r: 3, fill: s.color, strokeWidth: 0 } : false;\n const activeDot = (s: MetricsLineChartSeries) => ({\n r: 3.5,\n fill: s.color,\n stroke: 'var(--background)',\n strokeWidth: 2,\n ...(onPointClick && {\n style: { cursor: 'pointer' },\n onClick: (_: unknown, payload: unknown) => {\n // Recharts passes the dot's props; the hovered row is under `payload`.\n if (isRecord(payload) && isRecord(payload.payload)) onPointClick(payload.payload, s.dataKey);\n },\n }),\n });\n\n return (\n <ChartPlot\n height={height}\n plotRef={ref}\n onResize={onResize}\n clickable={!!onBucketClick}\n className={cn(lineStyle === 'thin' && THIN_FILL_FADE)}\n >\n <ComposedChart\n data={data}\n margin={CHART_MARGIN}\n onClick={state => {\n const i = state?.activeTooltipIndex;\n const row = i === undefined || i === null ? undefined : data[Number(i)];\n if (onBucketClick && row) onBucketClick(row, Number(i));\n }}\n >\n <defs>\n {series.map((s, i) => (\n <linearGradient key={s.dataKey} id={`${id}-area-${i}`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"0%\" stopColor={s.color} stopOpacity={line.areaOpacity} />\n <stop offset=\"95%\" stopColor={s.color} stopOpacity={0} />\n </linearGradient>\n ))}\n </defs>\n <CartesianGrid {...CHART_GRID_PROPS} />\n {timeXAxis({ data, xKey, timestampKey, xLabels, plotWidth })}\n {valueYAxis({\n show: showYAxis,\n size,\n formatter: axisFormatter ?? format,\n domain: yDomain,\n max: dataMax(\n data,\n series.map(s => s.dataKey),\n ),\n integer: isWholeData(\n data,\n series.map(s => s.dataKey),\n ),\n })}\n {markers.map(m => (\n <ReferenceLine\n key={m.x}\n x={m.x}\n stroke=\"var(--border-strong)\"\n strokeDasharray=\"3 3\"\n label={\n m.label\n ? { value: m.label, position: 'insideTopLeft', fill: 'var(--muted-foreground)', fontSize: 11 }\n : undefined\n }\n />\n ))}\n <Tooltip\n {...CHART_TOOLTIP_PROPS}\n content={\n <ChartTooltipPosition>\n <MetricsLineChartTooltip formatValue={format} labelKey={tooltipLabelKey} />\n </ChartTooltipPosition>\n }\n cursor={<HoverLine />}\n />\n {series.map((s, i) => {\n const common = {\n type: 'monotone' as const,\n dataKey: s.dataKey,\n name: s.label,\n stroke: s.color,\n strokeWidth: s.emphasis ? line.emphasis : line.width,\n strokeDasharray: s.dashed ? '4 3' : undefined,\n dot: restDot(s),\n activeDot: activeDot(s),\n isAnimationActive: false,\n connectNulls: true,\n };\n return s.dashed ? (\n <Line key={s.dataKey} {...common} />\n ) : (\n <Area key={s.dataKey} {...common} fill={`url(#${id}-area-${i})`} fillOpacity={1} />\n );\n })}\n </ComposedChart>\n </ChartPlot>\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,SAAgB,uBAAuB,EACrC,QACA,aAIC;CACD,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,+CAA+C,SAAS;EACxE,UAAA,OAAO,KAAI,MACV,qBAAC,OAAD;GAAqB,WAAU;GAA/B,UAAA,CACG,EAAE,SACD,oBAAC,QAAD;IAAM,WAAU;IAA4C,OAAO,EAAE,aAAa,EAAE,MAAM;GAAI,CAAA,IAE9F,oBAAC,OAAD;IAAK,WAAU;IAAgC,OAAO,EAAE,iBAAiB,EAAE,MAAM;GAAI,CAAA,GAEvF,oBAAC,KAAD;IAAK,IAAG;IAAO,SAAQ;IAAU,MAAK;IAAQ,WAAU;IACrD,UAAA,EAAE;GACA,CAAA,CACF;EATK,GAAA,EAAE,OASP,CACN;CACE,CAAA;AAET;;ACzBA,SAAgB,wBAAwB,EACtC,QACA,SACA,OACA,QACA,eAAc,UAAS,MAAM,eAAe,OAAO,GACnD,YAAY,OACZ,UACA,eAmBC;CACD,IAAI,CAAC,UAAU,CAAC,SAAS,QAAQ,OAAO;CAExC,MAAM,UAAU,UAAoC,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK;CACtG,MAAM,QAAQ,QAAQ,QAAQ,KAAK,UAAU,OAAO,OAAO,MAAM,KAAK,IAAI,MAAM,QAAQ,IAAI,CAAC;CAE7F,MAAM,aAAa,QAAQ,MAAK,UAAS,OAAO,MAA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