@stackone/malachite 2.131.0 → 2.133.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +8 -8
- package/dist/assets/icons/hexagon_fill.svg.js +6 -0
- package/dist/assets/icons/hexagon_fill.svg.js.map +1 -0
- package/dist/assets/icons/shield_star_fill.svg.js +6 -0
- package/dist/assets/icons/shield_star_fill.svg.js.map +1 -0
- package/dist/components/Button.js.map +1 -1
- package/dist/components/CodeBlock.js +130 -130
- package/dist/components/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlockHighlighter.js +65 -65
- package/dist/components/CodeBlockHighlighter.js.map +1 -1
- package/dist/components/CodePreview.js +74 -63
- package/dist/components/CodePreview.js.map +1 -1
- package/dist/components/FormActions.js +13 -9
- package/dist/components/FormActions.js.map +1 -1
- package/dist/components/Hexagon.js +33 -26
- package/dist/components/Hexagon.js.map +1 -1
- package/dist/components/HexagonScale.js +20 -19
- package/dist/components/HexagonScale.js.map +1 -1
- package/dist/components/Input/Input.js +55 -54
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/KeyValueList.js +36 -32
- package/dist/components/KeyValueList.js.map +1 -1
- package/dist/components/QueryInput.js +91 -90
- package/dist/components/QueryInput.js.map +1 -1
- package/dist/components/Surface.js +1 -1
- package/dist/components/Surface.js.map +1 -1
- package/dist/components/Table/Table.js +691 -637
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/TextArea/TextArea.js +46 -46
- package/dist/components/TextArea/TextArea.js.map +1 -1
- package/dist/components/buttonStyles.js +2 -0
- package/dist/components/buttonStyles.js.map +1 -1
- package/dist/components/codeBlockStyles.js +11 -6
- package/dist/components/codeBlockStyles.js.map +1 -1
- package/dist/components/codePreviewJson.js +25 -0
- package/dist/components/codePreviewJson.js.map +1 -0
- package/dist/index.d.ts +42 -7
- package/dist/tailwind.css.js +1 -1
- package/dist/theme.js +11 -3
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInput.js","sources":["../../src/components/QueryInput.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useId,\n useInsertionEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport Spinner from './Spinner';\nimport { CONTROL_TEXT_SIZE, CONTROL_TEXT_SIZE_CLASS } from './controlTextSize';\nimport { pushEscapeLayer } from './escapeLayers';\nimport { ensureMultiSelectPanelStyles } from './optionRowStyles';\nimport { usePopupLayer } from './overlayLayers';\nimport { useOwnedByPopover } from './popoverTree';\nimport { type CaretMenuGeometry, computeCaretMenuGeometry } from './queryInputGeometry';\nimport { useFollowTrigger } from './useFollowTrigger';\n\nexport type QueryTokenKind =\n | 'key'\n | 'value'\n | 'operator'\n | 'negation'\n | 'punctuation'\n | 'error'\n | 'plain';\n\nexport interface QueryToken {\n /** Index into `value`. */\n start: number;\n /** Exclusive. */\n end: number;\n kind: QueryTokenKind;\n}\n\nexport interface QuerySuggestion {\n id: string;\n label: string;\n /** Secondary text, right-aligned in the row. */\n detail?: string;\n /** What replaces `activeRange` when accepted. Defaults to `label`. */\n insertText?: string;\n}\n\nexport type QueryInputSize = 'small' | 'medium' | 'large';\n\nexport interface QueryInputProps {\n value: string;\n onChange: (value: string) => void;\n /** Ranges to colour. Tokens that are out of range, reversed or overlapping are ignored. */\n tokens?: QueryToken[];\n /** Rows for the caret menu. Empty or undefined means the menu stays closed. */\n suggestions?: QuerySuggestion[];\n /** The span an accepted suggestion replaces. Defaults to a zero-width span at the caret. */\n activeRange?: { start: number; end: number };\n onAccept?: (suggestion: QuerySuggestion) => void;\n /** Every value change AND every caret move, so the consumer can recompute tokens/suggestions. */\n onQueryContextChange?: (context: { value: string; caret: number }) => void;\n /** Enter with nothing highlighted in the menu. */\n onSubmit?: (value: string) => void;\n placeholder?: string;\n size?: QueryInputSize;\n disabled?: boolean;\n /** Suggestions are being fetched: the menu shows a loading row instead of the empty message. */\n loading?: boolean;\n emptyMessage?: string;\n className?: string;\n style?: React.CSSProperties;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\n// Same 28/32/42 ladder as Search, minus the icon gap this component has no icon to space.\nconst SIZE_CLASSES: Record<QueryInputSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)] px-[10px] rounded-[var(--malachite-radius-10,10px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)] px-[10px] rounded-xl',\n large: 'h-[var(--malachite-control-height-large,42px)] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst TOKEN_COLORS: Record<QueryTokenKind, string> = {\n key: 'var(--malachite-codeblock-keyword, rgb(12, 88, 174))',\n value: 'var(--malachite-codeblock-string, rgb(2, 122, 66))',\n operator: 'var(--malachite-codeblock-type, rgb(12, 88, 174))',\n negation: 'var(--malachite-text-destructive, rgb(237, 53, 54))',\n punctuation: 'var(--malachite-codeblock-foreground, rgb(10, 10, 10))',\n error: 'var(--malachite-text-error, rgb(237, 53, 54))',\n plain: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n};\n\n// The one place the mirror and the input agree on typography: diverge here and the coloured\n// text drifts out from under the caret it's supposed to sit beneath.\nconst TEXT_STYLE: Record<QueryInputSize, React.CSSProperties> = {\n small: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.small,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n medium: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.medium,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n large: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.large,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n};\n\n/** Before layout the portal hasn't painted yet, so the first geometry pass needs a width. */\nconst MENU_FALLBACK_WIDTH_PX = 220;\n\nconst MENU_MAX_WIDTH_PX = 360;\n\nconst MENU_MESSAGE_STYLE: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n padding: '10px 12px',\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n whiteSpace: 'nowrap',\n};\n\n/** Keeps focus (and the caret) on the input so a row click never blurs it first. */\nconst handleMenuMouseDown = (event: React.MouseEvent) => {\n event.preventDefault();\n};\n\ninterface QuerySegment {\n start: number;\n end: number;\n kind: QueryTokenKind;\n}\n\n/** Drops tokens the consumer got wrong rather than letting them corrupt the render. */\nconst sanitizeTokens = (value: string, tokens: QueryToken[]): QueryToken[] => {\n const inRange = tokens.filter(\n (token) => token.start >= 0 && token.end <= value.length && token.start < token.end,\n );\n const sorted = [...inRange].sort((a, b) => a.start - b.start);\n const accepted: QueryToken[] = [];\n let cursor = 0;\n for (const token of sorted) {\n if (token.start < cursor) {\n continue;\n }\n accepted.push(token);\n cursor = token.end;\n }\n return accepted;\n};\n\n/** Fills the gaps between tokens with 'plain' segments so the mirror's text always equals `value`. */\nconst buildSegments = (value: string, tokens: QueryToken[]): QuerySegment[] => {\n const segments: QuerySegment[] = [];\n let cursor = 0;\n for (const token of sanitizeTokens(value, tokens)) {\n if (token.start > cursor) {\n segments.push({ start: cursor, end: token.start, kind: 'plain' });\n }\n segments.push(token);\n cursor = token.end;\n }\n if (cursor < value.length) {\n segments.push({ start: cursor, end: value.length, kind: 'plain' });\n }\n return segments;\n};\n\nconst QueryInput: React.FC<QueryInputProps> = ({\n value,\n onChange,\n tokens = [],\n suggestions,\n activeRange,\n onAccept,\n onQueryContextChange,\n onSubmit,\n placeholder,\n size = 'large',\n disabled = false,\n loading = false,\n emptyMessage,\n className = '',\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const instanceId = useId();\n const listboxId = `${instanceId}-listbox`;\n const getRowId = (index: number) => `${listboxId}-option-${index}`;\n\n const [focused, setFocused] = useState(false);\n const [caret, setCaret] = useState(() => value.length);\n const [rawHighlightedIndex, setHighlightedIndex] = useState(0);\n // Escape closes the menu whatever `suggestions` and `loading` say. Lifted by an edit or a\n // refocus, so navigating a dismissed query does not pop it back open.\n const [dismissed, setDismissed] = useState(false);\n const [menuPosition, setMenuPosition] = useState<CaretMenuGeometry | null>(null);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const mirrorRef = useRef<HTMLDivElement>(null);\n const measureRef = useRef<HTMLSpanElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const rowRefs = useRef<(HTMLButtonElement | null)[]>([]);\n // Caret restore after an accepted suggestion. Carries the string it was computed against:\n // nothing obliges a controlled consumer to apply the value handed to `onChange`, and a\n // caret from a rejected or rewritten suggestion must not land on a later unrelated edit.\n const pendingSelectionRef = useRef<{ value: string; caret: number } | null>(null);\n\n const suggestionsProvided = Array.isArray(suggestions);\n const suggestionList = suggestions ?? [];\n const hasSuggestions = suggestionList.length > 0;\n const isEmptyList = suggestionsProvided && !hasSuggestions;\n const wantsMenu = loading || hasSuggestions || (isEmptyList && !!emptyMessage);\n const isMenuOpen = focused && wantsMenu && !dismissed && !disabled;\n const popupIdentity = usePopupLayer('dropdown', isMenuOpen, menuRef);\n useOwnedByPopover(\n useCallback(() => menuRef.current, []),\n isMenuOpen,\n );\n // `loading` paints the spinner over any rows the consumer is still holding, so nothing is\n // on screen to arrow through, accept, or point `aria-activedescendant` at.\n const rowsVisible = isMenuOpen && hasSuggestions && !loading;\n\n // A consumer's `suggestions` array is commonly rebuilt inline, so its identity changes on\n // any parent re-render and cannot stand in for \"the candidates changed\". Clamping during\n // render keeps the row the user arrowed to, and keeps the highlight inside a shrunken list.\n const highlightedIndex = hasSuggestions\n ? Math.min(rawHighlightedIndex, suggestionList.length - 1)\n : -1;\n\n useLayoutEffect(() => {\n setCaret((current) => Math.min(current, value.length));\n }, [value]);\n\n const syncMirrorScroll = useCallback(() => {\n const input = inputRef.current;\n const mirror = mirrorRef.current;\n if (input && mirror) {\n mirror.style.transform = `translateX(${-input.scrollLeft}px)`;\n }\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-syncs on every value change, not on value itself\n useLayoutEffect(() => {\n syncMirrorScroll();\n }, [value, syncMirrorScroll]);\n\n const updateMenuPosition = useCallback(() => {\n const input = inputRef.current;\n if (!input) {\n return;\n }\n const caretOffsetPx = (measureRef.current?.offsetWidth ?? 0) - input.scrollLeft;\n setMenuPosition(\n computeCaretMenuGeometry({\n inputRect: input.getBoundingClientRect(),\n caretOffsetPx,\n menuWidth: menuRef.current?.offsetWidth ?? MENU_FALLBACK_WIDTH_PX,\n menuHeight: menuRef.current?.offsetHeight ?? 0,\n viewportWidth: window.innerWidth,\n viewportHeight: window.innerHeight,\n }),\n );\n }, []);\n\n // Depends on `caret` as well as `value`: the measuring span is sliced at the caret, so an\n // arrow-key move with no edit still changes where the menu belongs.\n // biome-ignore lint/correctness/useExhaustiveDependencies: repositions on every keystroke, not on value itself\n useLayoutEffect(() => {\n if (isMenuOpen) {\n updateMenuPosition();\n } else {\n setMenuPosition(null);\n }\n // `suggestions` and `loading` are here because they change the menu's own size: rows\n // arriving after a fetch resize it while the query and caret sit still, and a stale\n // measurement would leave `openUp` and the caret-aligned `left` computed for the old box.\n }, [isMenuOpen, value, caret, suggestions, loading, updateMenuPosition]);\n\n const dismissMenu = useCallback(() => setDismissed(true), []);\n useFollowTrigger(isMenuOpen, inputRef, updateMenuPosition, dismissMenu);\n\n useEffect(() => {\n if (!isMenuOpen) {\n return undefined;\n }\n const handleResize = () => updateMenuPosition();\n window.addEventListener('resize', handleResize);\n const popEscapeLayer = pushEscapeLayer(() => setDismissed(true));\n return () => {\n window.removeEventListener('resize', handleResize);\n popEscapeLayer();\n };\n }, [isMenuOpen, updateMenuPosition]);\n\n // Restore the caret placed by the last accepted suggestion once the new `value` has\n // actually rendered. Guarded on the ref so an externally-driven value change never gets\n // its selection clobbered.\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentionally re-reads latest closures via pendingSelectionRef's gate\n useLayoutEffect(() => {\n const pending = pendingSelectionRef.current;\n if (pending === null) {\n return;\n }\n pendingSelectionRef.current = null;\n const input = inputRef.current;\n // Dropped unless the consumer applied exactly the string this caret was measured\n // against. A rejected or rewritten suggestion leaves the caret where the user put it.\n if (!input || pending.value !== value) {\n return;\n }\n input.setSelectionRange(pending.caret, pending.caret);\n setCaret(pending.caret);\n onQueryContextChange?.({ value, caret: pending.caret });\n syncMirrorScroll();\n updateMenuPosition();\n }, [value]);\n\n // Scrolled by hand rather than with `scrollIntoView`, which would also scroll the page and\n // carry the field itself out of view. Same reason MultiSelect does it this way.\n useLayoutEffect(() => {\n if (!rowsVisible) {\n return;\n }\n const row = rowRefs.current[highlightedIndex];\n const container = menuRef.current;\n if (!row || !container) {\n return;\n }\n const rowBottom = row.offsetTop + row.offsetHeight;\n if (rowBottom > container.scrollTop + container.clientHeight) {\n container.scrollTop = rowBottom - container.clientHeight;\n } else if (row.offsetTop < container.scrollTop) {\n container.scrollTop = row.offsetTop;\n }\n }, [highlightedIndex, rowsVisible]);\n\n // useInsertionEffect, not layout: the rules have to land before the rows paint.\n useInsertionEffect(() => {\n if (isMenuOpen) {\n ensureMultiSelectPanelStyles();\n }\n }, [isMenuOpen]);\n\n const reportCaret = (nextValue: string, nextCaret: number) => {\n setCaret(nextCaret);\n onQueryContextChange?.({ value: nextValue, caret: nextCaret });\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const next = event.target.value;\n // Editing is the user asking again, so it lifts an earlier Escape. Moving the caret is\n // not, and neither is a new `suggestions` array: that identity changes on any parent\n // re-render, which would undo the dismissal with nothing having been asked.\n setDismissed(false);\n setHighlightedIndex(0);\n onChange(next);\n reportCaret(next, event.target.selectionStart ?? next.length);\n };\n\n const handleSelect = (event: React.SyntheticEvent<HTMLInputElement>) => {\n const target = event.currentTarget;\n reportCaret(target.value, target.selectionStart ?? target.value.length);\n };\n\n const acceptSuggestion = (suggestion: QuerySuggestion) => {\n const fallbackCaret = inputRef.current?.selectionStart ?? value.length;\n const range = activeRange ?? { start: fallbackCaret, end: fallbackCaret };\n // Clamped for the same reason `sanitizeTokens` drops a bad range, except this one\n // writes: `slice` reads a negative index from the end of the string, so an unchecked\n // `start` of -1 silently rewrites the tail instead of doing nothing.\n const start = Math.max(0, Math.min(range.start, value.length));\n const end = Math.max(start, Math.min(range.end, value.length));\n const insertText = suggestion.insertText ?? suggestion.label;\n const next = value.slice(0, start) + insertText + value.slice(end);\n pendingSelectionRef.current = { value: next, caret: start + insertText.length };\n onChange(next);\n onAccept?.(suggestion);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (rowsVisible && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n const count = suggestionList.length;\n // Steps from the clamped index, so a list that shrank moves from the row on screen\n // rather than from a raw index the user can no longer see.\n setHighlightedIndex(\n event.key === 'ArrowDown'\n ? (highlightedIndex + 1) % count\n : (highlightedIndex - 1 + count) % count,\n );\n return;\n }\n\n const highlighted =\n rowsVisible && highlightedIndex >= 0 ? suggestionList[highlightedIndex] : undefined;\n\n if (event.key === 'Enter') {\n if (highlighted) {\n event.preventDefault();\n acceptSuggestion(highlighted);\n return;\n }\n if (onSubmit) {\n // Otherwise a surrounding <form> submits too and the query is sent twice.\n // Without the prop the native submit is left alone, which is the useful default.\n event.preventDefault();\n onSubmit(value);\n }\n return;\n }\n\n if (event.key === 'Tab' && highlighted) {\n // Tab completes the term and stays put, the way an editor or a search bar does.\n // Letting focus move on would hand the next keystroke to another field.\n event.preventDefault();\n acceptSuggestion(highlighted);\n }\n };\n\n const segments = buildSegments(value, tokens);\n const textStyle = TEXT_STYLE[size];\n\n const menuContent = (() => {\n if (loading) {\n return (\n // `role=\"listbox\"` admits only option/group children.\n <div role=\"presentation\" style={MENU_MESSAGE_STYLE}>\n <Spinner size=\"xxxsmall\" />\n <span>Loading…</span>\n </div>\n );\n }\n if (hasSuggestions) {\n return suggestionList.map((suggestion, index) => {\n const highlighted = index === highlightedIndex;\n return (\n <button\n key={suggestion.id}\n ref={(element) => {\n rowRefs.current[index] = element;\n }}\n type=\"button\"\n id={getRowId(index)}\n role=\"option\"\n aria-selected={highlighted}\n // Focus stays on the input under the activedescendant model, so a row\n // must not become its own tab stop.\n tabIndex={-1}\n onClick={() => acceptSuggestion(suggestion)}\n onMouseEnter={() => setHighlightedIndex(index)}\n className=\"malachite-multiselect-option\"\n data-highlighted={highlighted}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 12,\n width: '100%',\n flexShrink: 0,\n border: 'none',\n textAlign: 'left',\n borderRadius: 8,\n padding: '8px 10px',\n font: 'inherit',\n cursor: 'pointer',\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n }}\n >\n <span\n style={{\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {suggestion.label}\n </span>\n {suggestion.detail && (\n <span\n style={{\n flexShrink: 0,\n fontSize: 'var(--malachite-font-size-xsmall, 11px)',\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n }}\n >\n {suggestion.detail}\n </span>\n )}\n </button>\n );\n });\n }\n if (emptyMessage) {\n // `role=\"listbox\"` admits only option/group children.\n return (\n <div role=\"presentation\" style={MENU_MESSAGE_STYLE}>\n {emptyMessage}\n </div>\n );\n }\n return null;\n })();\n\n const hoverBorderClass = disabled ? '' : 'hover:border-[var(--malachite-text-placeholder)]';\n\n return (\n <div\n className={`relative w-full ${SIZE_CLASSES[size]} bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)] ${hoverBorderClass} transition-colors flex items-center ${disabled ? 'opacity-60 cursor-not-allowed' : ''} ${className}`}\n style={{\n boxShadow: focused\n ? 'var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))'\n : '0px 1px 1px 0px rgba(0, 0, 0, 0.15)',\n borderColor: focused\n ? 'var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))'\n : undefined,\n ...style,\n }}\n >\n {/* Clips here, not on the mirror: the mirror is what translates, and a transform\n carries the element's own clip rect with it, so the window onto the text would\n slide out of the field by exactly `scrollLeft`. */}\n <div className=\"relative flex-1 h-full min-w-0 overflow-hidden\">\n {/* aria-hidden: purely decorative, the input carries the accessible value. */}\n <div\n ref={mirrorRef}\n aria-hidden=\"true\"\n className={`absolute inset-0 flex items-center pointer-events-none ${CONTROL_TEXT_SIZE_CLASS[size]}`}\n style={{ ...textStyle, whiteSpace: 'pre' }}\n >\n {segments.map((segment) => (\n <span\n key={segment.start}\n style={{\n color: TOKEN_COLORS[segment.kind],\n ...(segment.kind === 'error'\n ? { textDecoration: 'underline wavy' }\n : {}),\n }}\n >\n {value.slice(segment.start, segment.end)}\n </span>\n ))}\n <span\n ref={measureRef}\n style={{ position: 'absolute', top: 0, left: 0, visibility: 'hidden' }}\n >\n {value.slice(0, caret)}\n </span>\n </div>\n <input\n ref={inputRef}\n type=\"text\"\n role=\"combobox\"\n aria-expanded={isMenuOpen}\n aria-controls={isMenuOpen ? listboxId : undefined}\n aria-activedescendant={\n rowsVisible && highlightedIndex >= 0\n ? getRowId(highlightedIndex)\n : undefined\n }\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-labelledby={ariaLabelledBy}\n // A visible label outranks it, so the fallback only applies without one.\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? placeholder)}\n value={value}\n onChange={handleChange}\n onSelect={handleSelect}\n onScroll={() => {\n syncMirrorScroll();\n if (isMenuOpen) {\n updateMenuPosition();\n }\n }}\n onKeyDown={handleKeyDown}\n onFocus={() => {\n setFocused(true);\n setDismissed(false);\n }}\n onBlur={() => setFocused(false)}\n placeholder={placeholder}\n disabled={disabled}\n className={`absolute inset-0 w-full h-full bg-transparent border-none outline-none ${CONTROL_TEXT_SIZE_CLASS[size]} placeholder:text-[var(--malachite-text-placeholder)] placeholder:font-medium disabled:cursor-not-allowed`}\n style={{\n ...textStyle,\n color: 'transparent',\n caretColor: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n }}\n />\n </div>\n {isMenuOpen &&\n createPortal(\n <div\n ref={menuRef}\n id={listboxId}\n role=\"listbox\"\n // Rides the dropdown overlay band, but borrows the multiselect option\n // rows below: their highlight follows `data-highlighted`, which is the\n // keyboard cursor this menu has, rather than a bare `:hover`.\n {...popupIdentity}\n onMouseDown={handleMenuMouseDown}\n style={{\n position: 'fixed',\n top: menuPosition?.top ?? 0,\n left: menuPosition?.left ?? 0,\n minWidth: Math.min(\n MENU_FALLBACK_WIDTH_PX,\n menuPosition?.width ?? MENU_FALLBACK_WIDTH_PX,\n ),\n maxWidth: Math.min(\n MENU_MAX_WIDTH_PX,\n menuPosition?.width ?? MENU_MAX_WIDTH_PX,\n ),\n background: 'var(--malachite-card-background, rgb(255, 255, 255))',\n border: '1px solid var(--malachite-card-border, rgb(232, 232, 232))',\n borderRadius: 12,\n boxShadow: '0px 2px 5px 0px rgba(0, 0, 0, 0.1)',\n padding: 4,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n maxHeight: 320,\n overflowY: 'auto',\n fontSize: CONTROL_TEXT_SIZE[size],\n visibility: menuPosition ? 'visible' : 'hidden',\n opacity: menuPosition ? 1 : 0,\n }}\n >\n {menuContent}\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nexport default QueryInput;\nexport { QueryInput };\n"],"names":["SIZE_CLASSES","TOKEN_COLORS","TEXT_STYLE","CONTROL_TEXT_SIZE","MENU_FALLBACK_WIDTH_PX","MENU_MAX_WIDTH_PX","MENU_MESSAGE_STYLE","handleMenuMouseDown","event","sanitizeTokens","value","tokens","sorted","token","a","b","accepted","cursor","buildSegments","segments","QueryInput","onChange","suggestions","activeRange","onAccept","onQueryContextChange","onSubmit","placeholder","size","disabled","loading","emptyMessage","className","style","ariaLabel","ariaLabelledBy","listboxId","useId","getRowId","index","focused","setFocused","useState","caret","setCaret","rawHighlightedIndex","setHighlightedIndex","dismissed","setDismissed","menuPosition","setMenuPosition","inputRef","useRef","mirrorRef","measureRef","menuRef","rowRefs","pendingSelectionRef","suggestionsProvided","suggestionList","hasSuggestions","isMenuOpen","popupIdentity","usePopupLayer","useOwnedByPopover","useCallback","rowsVisible","highlightedIndex","useLayoutEffect","current","syncMirrorScroll","input","mirror","updateMenuPosition","caretOffsetPx","_a","computeCaretMenuGeometry","_b","_c","dismissMenu","useFollowTrigger","useEffect","handleResize","popEscapeLayer","pushEscapeLayer","pending","row","container","rowBottom","useInsertionEffect","ensureMultiSelectPanelStyles","reportCaret","nextValue","nextCaret","handleChange","next","handleSelect","target","acceptSuggestion","suggestion","fallbackCaret","range","start","end","insertText","handleKeyDown","count","highlighted","textStyle","menuContent","jsxs","jsx","Spinner","element","hoverBorderClass","CONTROL_TEXT_SIZE_CLASS","segment","createPortal"],"mappings":";;;;;;;;;;;AA0EA,MAAMA,KAA+C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAA+C;AAAA,EACjD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,UAAU;AAAA,EACV,UAAU;AAAA,EACV,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AACX,GAIMC,KAA0D;AAAA,EAC5D,OAAO;AAAA,IACH,YAAY;AAAA,IACZ,UAAUC,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,SAAS;AAAA,EAAA;AAAA,EAEb,QAAQ;AAAA,IACJ,YAAY;AAAA,IACZ,UAAUA,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,SAAS;AAAA,EAAA;AAAA,EAEb,OAAO;AAAA,IACH,YAAY;AAAA,IACZ,UAAUA,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAA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AAA;AAAA,YAChB;AAAA,UAAA;AAAA,QACJ,GACJ;AAAA,QACC/C,KACGwD;AAAA,UACI,gBAAAN;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,KAAKxD;AAAA,cACL,IAAInB;AAAA,cACJ,MAAK;AAAA,cAIJ,GAAG0B;AAAA,cACJ,aAAavD;AAAA,cACb,OAAO;AAAA,gBACH,UAAU;AAAA,gBACV,MAAK0C,KAAA,gBAAAA,EAAc,QAAO;AAAA,gBAC1B,OAAMA,KAAA,gBAAAA,EAAc,SAAQ;AAAA,gBAC5B,UAAU,KAAK;AAAA,kBACX7C;AAAA,mBACA6C,KAAA,gBAAAA,EAAc,UAAS7C;AAAA,gBAAA;AAAA,gBAE3B,UAAU,KAAK;AAAA,kBACXC;AAAA,mBACA4C,KAAA,gBAAAA,EAAc,UAAS5C;AAAA,gBAAA;AAAA,gBAE3B,YAAY;AAAA,gBACZ,QAAQ;AAAA,gBACR,cAAc;AAAA,gBACd,WAAW;AAAA,gBACX,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,KAAK;AAAA,gBACL,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,UAAUF,EAAkByB,CAAI;AAAA,gBAChC,YAAYqB,IAAe,YAAY;AAAA,gBACvC,SAASA,IAAe,IAAI;AAAA,cAAA;AAAA,cAG/B,UAAA4D;AAAA,YAAA;AAAA,UAAA;AAAA,UAEL,SAAS;AAAA,QAAA;AAAA,MACb;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
1
|
+
{"version":3,"file":"QueryInput.js","sources":["../../src/components/QueryInput.tsx"],"sourcesContent":["import React, {\n useCallback,\n useEffect,\n useId,\n useInsertionEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport Spinner from './Spinner';\nimport { CODE_TOKEN_COLOR } from './codeBlockStyles';\nimport { CONTROL_TEXT_SIZE, CONTROL_TEXT_SIZE_CLASS } from './controlTextSize';\nimport { pushEscapeLayer } from './escapeLayers';\nimport { ensureMultiSelectPanelStyles } from './optionRowStyles';\nimport { usePopupLayer } from './overlayLayers';\nimport { useOwnedByPopover } from './popoverTree';\nimport { type CaretMenuGeometry, computeCaretMenuGeometry } from './queryInputGeometry';\nimport { useFollowTrigger } from './useFollowTrigger';\n\nexport type QueryTokenKind =\n | 'key'\n | 'value'\n | 'operator'\n | 'negation'\n | 'punctuation'\n | 'error'\n | 'plain';\n\nexport interface QueryToken {\n /** Index into `value`. */\n start: number;\n /** Exclusive. */\n end: number;\n kind: QueryTokenKind;\n}\n\nexport interface QuerySuggestion {\n id: string;\n label: string;\n /** Secondary text, right-aligned in the row. */\n detail?: string;\n /** What replaces `activeRange` when accepted. Defaults to `label`. */\n insertText?: string;\n}\n\nexport type QueryInputSize = 'small' | 'medium' | 'large';\n\nexport interface QueryInputProps {\n value: string;\n onChange: (value: string) => void;\n /** Ranges to colour. Tokens that are out of range, reversed or overlapping are ignored. */\n tokens?: QueryToken[];\n /** Rows for the caret menu. Empty or undefined means the menu stays closed. */\n suggestions?: QuerySuggestion[];\n /** The span an accepted suggestion replaces. Defaults to a zero-width span at the caret. */\n activeRange?: { start: number; end: number };\n onAccept?: (suggestion: QuerySuggestion) => void;\n /** Every value change AND every caret move, so the consumer can recompute tokens/suggestions. */\n onQueryContextChange?: (context: { value: string; caret: number }) => void;\n /** Enter with nothing highlighted in the menu. */\n onSubmit?: (value: string) => void;\n placeholder?: string;\n size?: QueryInputSize;\n disabled?: boolean;\n /** Suggestions are being fetched: the menu shows a loading row instead of the empty message. */\n loading?: boolean;\n emptyMessage?: string;\n className?: string;\n style?: React.CSSProperties;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n}\n\n// Same 28/32/42 ladder as Search, minus the icon gap this component has no icon to space.\nconst SIZE_CLASSES: Record<QueryInputSize, string> = {\n small: 'h-[var(--malachite-control-height-small,28px)] px-[10px] rounded-[var(--malachite-radius-10,10px)]',\n medium: 'h-[var(--malachite-control-height-medium,32px)] px-[10px] rounded-xl',\n large: 'h-[var(--malachite-control-height-large,42px)] px-[12px] rounded-[var(--malachite-radius-xxl,14px)]',\n};\n\nconst TOKEN_COLORS: Record<QueryTokenKind, string> = {\n key: CODE_TOKEN_COLOR.keyword,\n value: CODE_TOKEN_COLOR.string,\n operator: 'var(--malachite-codeblock-type, rgb(12, 88, 174))',\n negation: 'var(--malachite-text-destructive, rgb(237, 53, 54))',\n punctuation: 'var(--malachite-codeblock-foreground, rgb(10, 10, 10))',\n error: 'var(--malachite-text-error, rgb(237, 53, 54))',\n plain: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n};\n\n// The one place the mirror and the input agree on typography: diverge here and the coloured\n// text drifts out from under the caret it's supposed to sit beneath.\nconst TEXT_STYLE: Record<QueryInputSize, React.CSSProperties> = {\n small: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.small,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n medium: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.medium,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n large: {\n fontFamily: 'inherit',\n fontSize: CONTROL_TEXT_SIZE.large,\n fontWeight: 500,\n letterSpacing: 'normal',\n lineHeight: 'normal',\n padding: 0,\n },\n};\n\n/** Before layout the portal hasn't painted yet, so the first geometry pass needs a width. */\nconst MENU_FALLBACK_WIDTH_PX = 220;\n\nconst MENU_MAX_WIDTH_PX = 360;\n\nconst MENU_MESSAGE_STYLE: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 8,\n padding: '10px 12px',\n color: 'var(--malachite-text-dimmed, rgb(161, 161, 161))',\n whiteSpace: 'nowrap',\n};\n\n/** Keeps focus (and the caret) on the input so a row click never blurs it first. */\nconst handleMenuMouseDown = (event: React.MouseEvent) => {\n event.preventDefault();\n};\n\ninterface QuerySegment {\n start: number;\n end: number;\n kind: QueryTokenKind;\n}\n\n/** Drops tokens the consumer got wrong rather than letting them corrupt the render. */\nconst sanitizeTokens = (value: string, tokens: QueryToken[]): QueryToken[] => {\n const inRange = tokens.filter(\n (token) => token.start >= 0 && token.end <= value.length && token.start < token.end,\n );\n const sorted = [...inRange].sort((a, b) => a.start - b.start);\n const accepted: QueryToken[] = [];\n let cursor = 0;\n for (const token of sorted) {\n if (token.start < cursor) {\n continue;\n }\n accepted.push(token);\n cursor = token.end;\n }\n return accepted;\n};\n\n/** Fills the gaps between tokens with 'plain' segments so the mirror's text always equals `value`. */\nconst buildSegments = (value: string, tokens: QueryToken[]): QuerySegment[] => {\n const segments: QuerySegment[] = [];\n let cursor = 0;\n for (const token of sanitizeTokens(value, tokens)) {\n if (token.start > cursor) {\n segments.push({ start: cursor, end: token.start, kind: 'plain' });\n }\n segments.push(token);\n cursor = token.end;\n }\n if (cursor < value.length) {\n segments.push({ start: cursor, end: value.length, kind: 'plain' });\n }\n return segments;\n};\n\nconst QueryInput: React.FC<QueryInputProps> = ({\n value,\n onChange,\n tokens = [],\n suggestions,\n activeRange,\n onAccept,\n onQueryContextChange,\n onSubmit,\n placeholder,\n size = 'large',\n disabled = false,\n loading = false,\n emptyMessage,\n className = '',\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n}) => {\n const instanceId = useId();\n const listboxId = `${instanceId}-listbox`;\n const getRowId = (index: number) => `${listboxId}-option-${index}`;\n\n const [focused, setFocused] = useState(false);\n const [caret, setCaret] = useState(() => value.length);\n const [rawHighlightedIndex, setHighlightedIndex] = useState(0);\n // Escape closes the menu whatever `suggestions` and `loading` say. Lifted by an edit or a\n // refocus, so navigating a dismissed query does not pop it back open.\n const [dismissed, setDismissed] = useState(false);\n const [menuPosition, setMenuPosition] = useState<CaretMenuGeometry | null>(null);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const mirrorRef = useRef<HTMLDivElement>(null);\n const measureRef = useRef<HTMLSpanElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n const rowRefs = useRef<(HTMLButtonElement | null)[]>([]);\n // Caret restore after an accepted suggestion. Carries the string it was computed against:\n // nothing obliges a controlled consumer to apply the value handed to `onChange`, and a\n // caret from a rejected or rewritten suggestion must not land on a later unrelated edit.\n const pendingSelectionRef = useRef<{ value: string; caret: number } | null>(null);\n\n const suggestionsProvided = Array.isArray(suggestions);\n const suggestionList = suggestions ?? [];\n const hasSuggestions = suggestionList.length > 0;\n const isEmptyList = suggestionsProvided && !hasSuggestions;\n const wantsMenu = loading || hasSuggestions || (isEmptyList && !!emptyMessage);\n const isMenuOpen = focused && wantsMenu && !dismissed && !disabled;\n const popupIdentity = usePopupLayer('dropdown', isMenuOpen, menuRef);\n useOwnedByPopover(\n useCallback(() => menuRef.current, []),\n isMenuOpen,\n );\n // `loading` paints the spinner over any rows the consumer is still holding, so nothing is\n // on screen to arrow through, accept, or point `aria-activedescendant` at.\n const rowsVisible = isMenuOpen && hasSuggestions && !loading;\n\n // A consumer's `suggestions` array is commonly rebuilt inline, so its identity changes on\n // any parent re-render and cannot stand in for \"the candidates changed\". Clamping during\n // render keeps the row the user arrowed to, and keeps the highlight inside a shrunken list.\n const highlightedIndex = hasSuggestions\n ? Math.min(rawHighlightedIndex, suggestionList.length - 1)\n : -1;\n\n useLayoutEffect(() => {\n setCaret((current) => Math.min(current, value.length));\n }, [value]);\n\n const syncMirrorScroll = useCallback(() => {\n const input = inputRef.current;\n const mirror = mirrorRef.current;\n if (input && mirror) {\n mirror.style.transform = `translateX(${-input.scrollLeft}px)`;\n }\n }, []);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-syncs on every value change, not on value itself\n useLayoutEffect(() => {\n syncMirrorScroll();\n }, [value, syncMirrorScroll]);\n\n const updateMenuPosition = useCallback(() => {\n const input = inputRef.current;\n if (!input) {\n return;\n }\n const caretOffsetPx = (measureRef.current?.offsetWidth ?? 0) - input.scrollLeft;\n setMenuPosition(\n computeCaretMenuGeometry({\n inputRect: input.getBoundingClientRect(),\n caretOffsetPx,\n menuWidth: menuRef.current?.offsetWidth ?? MENU_FALLBACK_WIDTH_PX,\n menuHeight: menuRef.current?.offsetHeight ?? 0,\n viewportWidth: window.innerWidth,\n viewportHeight: window.innerHeight,\n }),\n );\n }, []);\n\n // Depends on `caret` as well as `value`: the measuring span is sliced at the caret, so an\n // arrow-key move with no edit still changes where the menu belongs.\n // biome-ignore lint/correctness/useExhaustiveDependencies: repositions on every keystroke, not on value itself\n useLayoutEffect(() => {\n if (isMenuOpen) {\n updateMenuPosition();\n } else {\n setMenuPosition(null);\n }\n // `suggestions` and `loading` are here because they change the menu's own size: rows\n // arriving after a fetch resize it while the query and caret sit still, and a stale\n // measurement would leave `openUp` and the caret-aligned `left` computed for the old box.\n }, [isMenuOpen, value, caret, suggestions, loading, updateMenuPosition]);\n\n const dismissMenu = useCallback(() => setDismissed(true), []);\n useFollowTrigger(isMenuOpen, inputRef, updateMenuPosition, dismissMenu);\n\n useEffect(() => {\n if (!isMenuOpen) {\n return undefined;\n }\n const handleResize = () => updateMenuPosition();\n window.addEventListener('resize', handleResize);\n const popEscapeLayer = pushEscapeLayer(() => setDismissed(true));\n return () => {\n window.removeEventListener('resize', handleResize);\n popEscapeLayer();\n };\n }, [isMenuOpen, updateMenuPosition]);\n\n // Restore the caret placed by the last accepted suggestion once the new `value` has\n // actually rendered. Guarded on the ref so an externally-driven value change never gets\n // its selection clobbered.\n // biome-ignore lint/correctness/useExhaustiveDependencies: intentionally re-reads latest closures via pendingSelectionRef's gate\n useLayoutEffect(() => {\n const pending = pendingSelectionRef.current;\n if (pending === null) {\n return;\n }\n pendingSelectionRef.current = null;\n const input = inputRef.current;\n // Dropped unless the consumer applied exactly the string this caret was measured\n // against. A rejected or rewritten suggestion leaves the caret where the user put it.\n if (!input || pending.value !== value) {\n return;\n }\n input.setSelectionRange(pending.caret, pending.caret);\n setCaret(pending.caret);\n onQueryContextChange?.({ value, caret: pending.caret });\n syncMirrorScroll();\n updateMenuPosition();\n }, [value]);\n\n // Scrolled by hand rather than with `scrollIntoView`, which would also scroll the page and\n // carry the field itself out of view. Same reason MultiSelect does it this way.\n useLayoutEffect(() => {\n if (!rowsVisible) {\n return;\n }\n const row = rowRefs.current[highlightedIndex];\n const container = menuRef.current;\n if (!row || !container) {\n return;\n }\n const rowBottom = row.offsetTop + row.offsetHeight;\n if (rowBottom > container.scrollTop + container.clientHeight) {\n container.scrollTop = rowBottom - container.clientHeight;\n } else if (row.offsetTop < container.scrollTop) {\n container.scrollTop = row.offsetTop;\n }\n }, [highlightedIndex, rowsVisible]);\n\n // useInsertionEffect, not layout: the rules have to land before the rows paint.\n useInsertionEffect(() => {\n if (isMenuOpen) {\n ensureMultiSelectPanelStyles();\n }\n }, [isMenuOpen]);\n\n const reportCaret = (nextValue: string, nextCaret: number) => {\n setCaret(nextCaret);\n onQueryContextChange?.({ value: nextValue, caret: nextCaret });\n };\n\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const next = event.target.value;\n // Editing is the user asking again, so it lifts an earlier Escape. Moving the caret is\n // not, and neither is a new `suggestions` array: that identity changes on any parent\n // re-render, which would undo the dismissal with nothing having been asked.\n setDismissed(false);\n setHighlightedIndex(0);\n onChange(next);\n reportCaret(next, event.target.selectionStart ?? next.length);\n };\n\n const handleSelect = (event: React.SyntheticEvent<HTMLInputElement>) => {\n const target = event.currentTarget;\n reportCaret(target.value, target.selectionStart ?? target.value.length);\n };\n\n const acceptSuggestion = (suggestion: QuerySuggestion) => {\n const fallbackCaret = inputRef.current?.selectionStart ?? value.length;\n const range = activeRange ?? { start: fallbackCaret, end: fallbackCaret };\n // Clamped for the same reason `sanitizeTokens` drops a bad range, except this one\n // writes: `slice` reads a negative index from the end of the string, so an unchecked\n // `start` of -1 silently rewrites the tail instead of doing nothing.\n const start = Math.max(0, Math.min(range.start, value.length));\n const end = Math.max(start, Math.min(range.end, value.length));\n const insertText = suggestion.insertText ?? suggestion.label;\n const next = value.slice(0, start) + insertText + value.slice(end);\n pendingSelectionRef.current = { value: next, caret: start + insertText.length };\n onChange(next);\n onAccept?.(suggestion);\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (rowsVisible && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {\n event.preventDefault();\n const count = suggestionList.length;\n // Steps from the clamped index, so a list that shrank moves from the row on screen\n // rather than from a raw index the user can no longer see.\n setHighlightedIndex(\n event.key === 'ArrowDown'\n ? (highlightedIndex + 1) % count\n : (highlightedIndex - 1 + count) % count,\n );\n return;\n }\n\n const highlighted =\n rowsVisible && highlightedIndex >= 0 ? suggestionList[highlightedIndex] : undefined;\n\n if (event.key === 'Enter') {\n if (highlighted) {\n event.preventDefault();\n acceptSuggestion(highlighted);\n return;\n }\n if (onSubmit) {\n // Otherwise a surrounding <form> submits too and the query is sent twice.\n // Without the prop the native submit is left alone, which is the useful default.\n event.preventDefault();\n onSubmit(value);\n }\n return;\n }\n\n if (event.key === 'Tab' && highlighted) {\n // Tab completes the term and stays put, the way an editor or a search bar does.\n // Letting focus move on would hand the next keystroke to another field.\n event.preventDefault();\n acceptSuggestion(highlighted);\n }\n };\n\n const segments = buildSegments(value, tokens);\n const textStyle = TEXT_STYLE[size];\n\n const menuContent = (() => {\n if (loading) {\n return (\n // `role=\"listbox\"` admits only option/group children.\n <div role=\"presentation\" style={MENU_MESSAGE_STYLE}>\n <Spinner size=\"xxxsmall\" />\n <span>Loading…</span>\n </div>\n );\n }\n if (hasSuggestions) {\n return suggestionList.map((suggestion, index) => {\n const highlighted = index === highlightedIndex;\n return (\n <button\n key={suggestion.id}\n ref={(element) => {\n rowRefs.current[index] = element;\n }}\n type=\"button\"\n id={getRowId(index)}\n role=\"option\"\n aria-selected={highlighted}\n // Focus stays on the input under the activedescendant model, so a row\n // must not become its own tab stop.\n tabIndex={-1}\n onClick={() => acceptSuggestion(suggestion)}\n onMouseEnter={() => setHighlightedIndex(index)}\n className=\"malachite-multiselect-option\"\n data-highlighted={highlighted}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 12,\n width: '100%',\n flexShrink: 0,\n border: 'none',\n textAlign: 'left',\n borderRadius: 8,\n padding: '8px 10px',\n font: 'inherit',\n cursor: 'pointer',\n color: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n }}\n >\n <span\n style={{\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n }}\n >\n {suggestion.label}\n </span>\n {suggestion.detail && (\n <span\n style={{\n flexShrink: 0,\n fontSize: 'var(--malachite-font-size-xsmall, 11px)',\n color: 'var(--malachite-text-secondary, rgb(123, 123, 123))',\n }}\n >\n {suggestion.detail}\n </span>\n )}\n </button>\n );\n });\n }\n if (emptyMessage) {\n // `role=\"listbox\"` admits only option/group children.\n return (\n <div role=\"presentation\" style={MENU_MESSAGE_STYLE}>\n {emptyMessage}\n </div>\n );\n }\n return null;\n })();\n\n const hoverBorderClass = disabled ? '' : 'hover:border-[var(--malachite-text-placeholder)]';\n\n return (\n <div\n className={`relative w-full ${SIZE_CLASSES[size]} bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)] ${hoverBorderClass} transition-colors flex items-center ${disabled ? 'opacity-60 cursor-not-allowed' : ''} ${className}`}\n style={{\n boxShadow: focused\n ? 'var(--malachite-shadow-accent, 0px 1px 0px 0px rgba(0, 175, 102, 0.15))'\n : '0px 1px 1px 0px rgba(0, 0, 0, 0.15)',\n borderColor: focused\n ? 'var(--malachite-control-border-hover, rgba(0, 175, 102, 0.4))'\n : undefined,\n ...style,\n }}\n >\n {/* Clips here, not on the mirror: the mirror is what translates, and a transform\n carries the element's own clip rect with it, so the window onto the text would\n slide out of the field by exactly `scrollLeft`. */}\n <div className=\"relative flex-1 h-full min-w-0 overflow-hidden\">\n {/* aria-hidden: purely decorative, the input carries the accessible value. */}\n <div\n ref={mirrorRef}\n aria-hidden=\"true\"\n className={`absolute inset-0 flex items-center pointer-events-none ${CONTROL_TEXT_SIZE_CLASS[size]}`}\n style={{ ...textStyle, whiteSpace: 'pre' }}\n >\n {segments.map((segment) => (\n <span\n key={segment.start}\n style={{\n color: TOKEN_COLORS[segment.kind],\n ...(segment.kind === 'error'\n ? { textDecoration: 'underline wavy' }\n : {}),\n }}\n >\n {value.slice(segment.start, segment.end)}\n </span>\n ))}\n <span\n ref={measureRef}\n style={{ position: 'absolute', top: 0, left: 0, visibility: 'hidden' }}\n >\n {value.slice(0, caret)}\n </span>\n </div>\n <input\n ref={inputRef}\n type=\"text\"\n role=\"combobox\"\n aria-expanded={isMenuOpen}\n aria-controls={isMenuOpen ? listboxId : undefined}\n aria-activedescendant={\n rowsVisible && highlightedIndex >= 0\n ? getRowId(highlightedIndex)\n : undefined\n }\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n spellCheck={false}\n aria-labelledby={ariaLabelledBy}\n // A visible label outranks it, so the fallback only applies without one.\n aria-label={ariaLabelledBy ? undefined : (ariaLabel ?? placeholder)}\n value={value}\n onChange={handleChange}\n onSelect={handleSelect}\n onScroll={() => {\n syncMirrorScroll();\n if (isMenuOpen) {\n updateMenuPosition();\n }\n }}\n onKeyDown={handleKeyDown}\n onFocus={() => {\n setFocused(true);\n setDismissed(false);\n }}\n onBlur={() => setFocused(false)}\n placeholder={placeholder}\n disabled={disabled}\n className={`absolute inset-0 w-full h-full bg-transparent border-none outline-none ${CONTROL_TEXT_SIZE_CLASS[size]} placeholder:text-[var(--malachite-text-placeholder)] placeholder:font-medium disabled:cursor-not-allowed`}\n style={{\n ...textStyle,\n color: 'transparent',\n caretColor: 'var(--malachite-text-primary, rgb(10, 10, 10))',\n }}\n />\n </div>\n {isMenuOpen &&\n createPortal(\n <div\n ref={menuRef}\n id={listboxId}\n role=\"listbox\"\n // Rides the dropdown overlay band, but borrows the multiselect option\n // rows below: their highlight follows `data-highlighted`, which is the\n // keyboard cursor this menu has, rather than a bare `:hover`.\n {...popupIdentity}\n onMouseDown={handleMenuMouseDown}\n style={{\n position: 'fixed',\n top: menuPosition?.top ?? 0,\n left: menuPosition?.left ?? 0,\n minWidth: Math.min(\n MENU_FALLBACK_WIDTH_PX,\n menuPosition?.width ?? MENU_FALLBACK_WIDTH_PX,\n ),\n maxWidth: Math.min(\n MENU_MAX_WIDTH_PX,\n menuPosition?.width ?? MENU_MAX_WIDTH_PX,\n ),\n background: 'var(--malachite-card-background, rgb(255, 255, 255))',\n border: '1px solid var(--malachite-card-border, rgb(232, 232, 232))',\n borderRadius: 12,\n boxShadow: '0px 2px 5px 0px rgba(0, 0, 0, 0.1)',\n padding: 4,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n maxHeight: 320,\n overflowY: 'auto',\n fontSize: CONTROL_TEXT_SIZE[size],\n visibility: menuPosition ? 'visible' : 'hidden',\n opacity: menuPosition ? 1 : 0,\n }}\n >\n {menuContent}\n </div>,\n document.body,\n )}\n </div>\n );\n};\n\nexport default QueryInput;\nexport { QueryInput };\n"],"names":["SIZE_CLASSES","TOKEN_COLORS","CODE_TOKEN_COLOR","TEXT_STYLE","CONTROL_TEXT_SIZE","MENU_FALLBACK_WIDTH_PX","MENU_MAX_WIDTH_PX","MENU_MESSAGE_STYLE","handleMenuMouseDown","event","sanitizeTokens","value","tokens","sorted","token","a","b","accepted","cursor","buildSegments","segments","QueryInput","onChange","suggestions","activeRange","onAccept","onQueryContextChange","onSubmit","placeholder","size","disabled","loading","emptyMessage","className","style","ariaLabel","ariaLabelledBy","listboxId","useId","getRowId","index","focused","setFocused","useState","caret","setCaret","rawHighlightedIndex","setHighlightedIndex","dismissed","setDismissed","menuPosition","setMenuPosition","inputRef","useRef","mirrorRef","measureRef","menuRef","rowRefs","pendingSelectionRef","suggestionsProvided","suggestionList","hasSuggestions","isMenuOpen","popupIdentity","usePopupLayer","useOwnedByPopover","useCallback","rowsVisible","highlightedIndex","useLayoutEffect","current","syncMirrorScroll","input","mirror","updateMenuPosition","caretOffsetPx","_a","computeCaretMenuGeometry","_b","_c","dismissMenu","useFollowTrigger","useEffect","handleResize","popEscapeLayer","pushEscapeLayer","pending","row","container","rowBottom","useInsertionEffect","ensureMultiSelectPanelStyles","reportCaret","nextValue","nextCaret","handleChange","next","handleSelect","target","acceptSuggestion","suggestion","fallbackCaret","range","start","end","insertText","handleKeyDown","count","highlighted","textStyle","menuContent","jsxs","jsx","Spinner","element","hoverBorderClass","CONTROL_TEXT_SIZE_CLASS","segment","createPortal"],"mappings":";;;;;;;;;;;;AA2EA,MAAMA,KAA+C;AAAA,EACjD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACX,GAEMC,KAA+C;AAAA,EACjD,KAAKC,GAAiB;AAAA,EACtB,OAAOA,GAAiB;AAAA,EACxB,UAAU;AAAA,EACV,UAAU;AAAA,EACV,aAAa;AAAA,EACb,OAAO;AAAA,EACP,OAAO;AACX,GAIMC,KAA0D;AAAA,EAC5D,OAAO;AAAA,IACH,YAAY;AAAA,IACZ,UAAUC,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,SAAS;AAAA,EAAA;AAAA,EAEb,QAAQ;AAAA,IACJ,YAAY;AAAA,IACZ,UAAUA,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,SAAS;AAAA,EAAA;AAAA,EAEb,OAAO;AAAA,IACH,YAAY;AAAA,IACZ,UAAUA,EAAkB;AAAA,IAC5B,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,YAAY;AAAA,IACZ,SAAS;AAAA,EAAA;AAEjB,GAGMC,IAAyB,KAEzBC,KAAoB,KAEpBC,KAA0C;AAAA,EAC5C,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,KAAK;AAAA,EACL,SAAS;AAAA,EACT,OAAO;AAAA,EACP,YAAY;AAChB,GAGMC,KAAsB,CAACC,MAA4B;AACrD,EAAAA,EAAM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,KAAA,gBAAAA,EAAc,QAAO;AAAA,gBAC1B,OAAMA,KAAA,gBAAAA,EAAc,SAAQ;AAAA,gBAC5B,UAAU,KAAK;AAAA,kBACX7C;AAAA,mBACA6C,KAAA,gBAAAA,EAAc,UAAS7C;AAAA,gBAAA;AAAA,gBAE3B,UAAU,KAAK;AAAA,kBACXC;AAAA,mBACA4C,KAAA,gBAAAA,EAAc,UAAS5C;AAAA,gBAAA;AAAA,gBAE3B,YAAY;AAAA,gBACZ,QAAQ;AAAA,gBACR,cAAc;AAAA,gBACd,WAAW;AAAA,gBACX,SAAS;AAAA,gBACT,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,KAAK;AAAA,gBACL,WAAW;AAAA,gBACX,WAAW;AAAA,gBACX,UAAUF,EAAkByB,CAAI;AAAA,gBAChC,YAAYqB,IAAe,YAAY;AAAA,gBACvC,SAASA,IAAe,IAAI;AAAA,cAAA;AAAA,cAG/B,UAAA4D;AAAA,YAAA;AAAA,UAAA;AAAA,UAEL,SAAS;AAAA,QAAA;AAAA,MACb;AAAA,IAAA;AAAA,EAAA;AAGhB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Surface.js","sources":["../../src/components/Surface.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport { paintOnChild } from './asChild';\nimport { ROW_HOVER } from './chromeStyles';\nimport { FOCUS_RING_INSET, FOCUS_RING_INSET_OVERLAY_HIDDEN } from './focusRing';\nimport { resolveRel } from './linkRel';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\nimport {\n FOREGROUND_RESET,\n SELECTED_ROW_ACCENT,\n SELECTED_ROW_BACKGROUND,\n SELECTED_ROW_FOREGROUND,\n SELECTED_TEXT_CONTEXT,\n} from './selectedRow';\n\nexport type SurfaceTone = 'default' | 'highlight';\n\nexport interface SurfaceProps {\n children?: React.ReactNode;\n padding?: boolean;\n /**\n * Content overflow. Defaults to `hidden` so children are clipped to the rounded\n * corners. Use `clip` to keep the rounded clipping WITHOUT creating a scroll\n * container — so a `position: sticky` descendant still pins (unlike `hidden`,\n * which traps it). `visible` disables clipping entirely. A flat, default-tone `clip` card clips at its border.\n */\n overflow?: 'hidden' | 'visible' | 'clip';\n /**\n * `false` drops the elevation shadow, for a card that sits flat on its ground.\n * Default: `true`, or `false` with `tone=\"highlight\"`.\n */\n shadow?: boolean;\n /**\n * `highlight` paints the warm ground with no border and no shadow, for a static block that\n * stands out from the page, such as a hero or a guide's section header. Its ground is too\n * close to `Surface.Row`'s hover for clickable rows inside it.\n */\n tone?: SurfaceTone;\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\ninterface SurfaceRowChromeProps {\n children?: React.ReactNode;\n /** Renders a bottom divider — omit on the last row in a Surface. */\n divider?: boolean;\n /** Removes the hover affordance / disables the control (e.g. while loading/busy). */\n disabled?: boolean;\n /** Announces the row as selected — `aria-checked` under a `radio`/`checkbox` role,\n * `aria-current` otherwise — and paints `Table`'s selected treatment unless `selection`\n * says not to. `'mixed'` is for a `checkbox` row that is partly selected: it announces\n * `aria-checked=\"mixed\"` there, never paints and never marks the row current, and counts\n * as not selected under any other role. */\n selected?: boolean | 'mixed';\n /** How a `selected` row shows it. `highlight` paints the treatment; `tint` paints it\n * without the accent bar, for a menu whose choice is already marked inside the row;\n * `announce` leaves the visual to a control inside the row and only sets the ARIA state.\n * Defaults to `announce` under `role=\"checkbox\"` and `highlight` otherwise. */\n selection?: 'highlight' | 'tint' | 'announce';\n /**\n * Tints the whole row by what it reports. `muted` is a row whose subject is inactive —\n * not disabled: it stays interactive. `success`, `warning` and `error` are for a row that\n * carries an outcome, where the result belongs to the whole line rather than to one cell in it.\n */\n tone?: 'default' | 'muted' | 'success' | 'warning' | 'error';\n /** `compact` is an 8px by 16px inset the row owns. */\n inset?: 'none' | 'compact';\n /** `false` leaves the hover to something inside the row. */\n hover?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst INSET_CLASSES: Record<NonNullable<SurfaceRowChromeProps['inset']>, string> = {\n none: '',\n // The 16px is ROW_INSET_PX in accordionBodyInset.ts too; Accordion's bodyIndent gives it back.\n compact: 'px-[16px] py-[8px]',\n};\n\n/** Stays an interface under its original name: a consumer may `extends` it. */\nexport interface SurfaceRowProps extends SurfaceRowChromeProps {\n asChild?: false;\n /**\n * When provided, the whole row becomes clickable: it renders as a `<button>`\n * (or `<a>` when `href` is set), so the entire row is the click target with\n * native focus + Enter/Space — no manual tabIndex/key handlers. For a\n * selectable row, put a presentational `<Radio>`/`<Checkbox>` inside as the\n * visual indicator; do NOT nest an interactive control (invalid + double tab stop).\n */\n onClick?: (event: React.MouseEvent) => void;\n /** Renders the clickable row as an anchor instead of a button. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n /** Content pinned right, outside the row button, so it may hold its own control. */\n trailing?: React.ReactNode;\n /**\n * Shows `trailing` only while the row is hovered or holds focus, and while a menu\n * it opened is still open. Hidden by opacity, so it stays in the tab order; a touch screen,\n * which has no hover, always shows it.\n */\n revealTrailing?: boolean;\n /** The row's indicator, before the children. With this or `dimmed`, pass one child. */\n leading?: React.ReactNode;\n /** Fades the children, not `leading` or `trailing`. */\n dimmed?: boolean;\n /** ARIA role for a clickable row, e.g. `radio`/`checkbox` (wrap the list in a `radiogroup`). */\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** `-1` takes the row out of the Tab order, for a roving radio group. */\n tabIndex?: number;\n}\n\n/**\n * The outcome tones reuse the tag tokens rather than minting row ones, so a row saying \"this\n * passed\" and a tag saying it are the same green wherever the two sit together.\n */\nconst TONE_CLASSES: Record<NonNullable<SurfaceRowProps['tone']>, string> = {\n default: '',\n muted: 'bg-[var(--malachite-card-dimmed-background)]',\n success: 'bg-[var(--malachite-tag-success-background,rgba(0,175,102,0.1))]',\n warning: 'bg-[var(--malachite-tag-warning-background,rgba(150,88,10,0.1))]',\n error: 'bg-[var(--malachite-tag-error-background,rgba(196,62,62,0.1))]',\n};\n\n/**\n * The text an outcome tone carries with it, through the same context channel a selected row\n * uses, so `Typography` inside the row follows the tint instead of staying near-black on it.\n * `color` as well, for row content that is not Typography.\n *\n * Only the outcome tones. `muted` dims its subject rather than recolouring it, and its\n * foreground is the ordinary one.\n */\nconst TONE_FOREGROUNDS: Partial<Record<NonNullable<SurfaceRowProps['tone']>, string>> = {\n success: 'var(--malachite-tag-success-foreground, rgb(2, 122, 66))',\n warning: 'var(--malachite-tag-warning-foreground, rgb(150, 88, 10))',\n error: 'var(--malachite-tag-error-foreground, rgb(196, 62, 62))',\n};\n\nexport interface SurfaceRowAsChildProps extends SurfaceRowChromeProps {\n asChild: true;\n children: React.ReactElement;\n}\n\nexport type AnySurfaceRowProps = SurfaceRowProps | SurfaceRowAsChildProps;\n\n// Not `group-hover` or `group-has-[:focus-visible]`: WebKit never applies the first (its\n// `@media (hover: hover)` nested in the group selector) nor the second inside a shadow root,\n// so the control stayed hidden in Safari. An open menu takes focus out of the row into a\n// portal, and would otherwise lose its trigger.\nconst REVEALED_ON_INTERACTION =\n 'opacity-0 transition-opacity group-[:hover]/row:opacity-100 group-focus-within/row:opacity-100 has-[[aria-expanded=true]]:opacity-100 [@media(hover:none)]:opacity-100';\n\nconst selectsTextIn = (row: Element): boolean => {\n const root = row.getRootNode();\n const ownSelection = (root as Partial<Pick<Document, 'getSelection'>>).getSelection?.();\n const selection = ownSelection ?? row.ownerDocument.getSelection();\n if (!selection || selection.isCollapsed) {\n return false;\n }\n for (let index = 0; index < selection.rangeCount; index += 1) {\n if (selection.getRangeAt(index).intersectsNode(row)) {\n return true;\n }\n }\n return false;\n};\n\nconst forwardedClick = (event: MouseEvent): MouseEvent =>\n new (event.constructor as typeof MouseEvent)('click', event);\n\nconst TRIPLE_SHADOW =\n '0px 0px 4px 0px rgba(0,0,0,0.08), 0px 4px 4px 0px rgba(0,0,0,0.08), 0px 4px 10px 0px rgba(0,0,0,0.05)';\n\n/**\n * A single full-bleed row inside a <Surface>. Owns the row chrome — hover\n * highlight, colour transition and an optional bottom divider — so consumers\n * compose their own content inside without re-implementing design-system styling.\n * Pass `onClick`/`href` to make the entire row clickable (rendered as a real\n * button/anchor, so keyboard navigation works natively).\n */\nconst SurfaceRow: React.FC<AnySurfaceRowProps> = (props) => {\n const {\n children,\n divider = false,\n disabled = false,\n hover: hoverable = true,\n selected,\n selection,\n tone = 'default',\n inset = 'none',\n className = '',\n style,\n } = props;\n const asChild = props.asChild === true;\n const {\n onClick,\n href: rawHref,\n target,\n rel,\n trailing,\n revealTrailing,\n leading,\n dimmed,\n role,\n } = asChild ? ({} as SurfaceRowProps) : (props as SurfaceRowProps);\n // A rejected href (e.g. `javascript:`) leaves the row a button or a plain row, never an anchor.\n const href = safeHref(rawHref);\n const ariaLabel = asChild ? undefined : (props as SurfaceRowProps)['aria-label'];\n const ariaLabelledBy = asChild ? undefined : (props as SurfaceRowProps)['aria-labelledby'];\n const tabIndex = asChild ? undefined : (props as SurfaceRowProps).tabIndex;\n const interactive = Boolean(onClick || href);\n // `asChild` is interactive for the hover affordance only, not the focus/reset classes.\n const hover = disabled && (interactive || asChild) ? '' : hoverable ? ROW_HOVER : '';\n\n // A class, not an inline colour, which would outrank the hover utility. It replaces the\n // button reset's `bg-transparent` rather than joining it: same specificity, so the winner\n // would be whichever Tailwind emitted last.\n const tinted = tone !== 'default';\n const toneClass = TONE_CLASSES[tone];\n\n const hasTrailing = !asChild && isRenderableNode(trailing);\n const insetClass = INSET_CLASSES[inset];\n const controlPadding = insetClass ? '' : 'p-0';\n\n const chromeClasses = [\n 'w-full text-left border-0',\n toneClass,\n divider ? 'border-b border-solid border-[var(--malachite-card-border)]' : '',\n hover,\n ]\n .filter(Boolean)\n .join(' ');\n\n const controlReset = [\n 'appearance-none',\n tinted ? '' : 'bg-transparent',\n disabled ? '' : 'cursor-pointer',\n ];\n const rowClasses = (control: string[]) =>\n [chromeClasses, ...control, insetClass, className].filter(Boolean).join(' ');\n\n const paints = selection ? selection !== 'announce' : role !== 'checkbox';\n const accent = selection !== 'tint';\n\n const forwards = hasTrailing && Boolean(onClick) && !href && !disabled;\n const rowRef = useRef<HTMLDivElement>(null);\n const controlRef = useRef<HTMLButtonElement>(null);\n const pressLeftPadding = useRef(false);\n const startPress = (event: React.PointerEvent<HTMLDivElement>) => {\n pressLeftPadding.current = event.target !== event.currentTarget;\n };\n const trackPress = (event: React.PointerEvent<HTMLDivElement>) => {\n pressLeftPadding.current ||= event.target !== event.currentTarget;\n };\n useEffect(() => {\n const row = rowRef.current;\n if (!forwards || !row) {\n return undefined;\n }\n const forwardPaddingClick = (event: MouseEvent) => {\n const leftPadding = pressLeftPadding.current;\n pressLeftPadding.current = false;\n const control = controlRef.current;\n if (\n !control ||\n event.target !== row ||\n leftPadding ||\n (event.detail <= 1 && !event.shiftKey && selectsTextIn(row))\n ) {\n return;\n }\n event.stopPropagation();\n control.focus({ preventScroll: true });\n control.dispatchEvent(forwardedClick(event));\n };\n row.addEventListener('click', forwardPaddingClick);\n return () => row.removeEventListener('click', forwardPaddingClick);\n }, [forwards]);\n\n // A gradient layer so the tint composites over hover, and an inset shadow because\n // `ring-*` silently doesn't paint in a shadow root.\n const selectedStyle: React.CSSProperties =\n selected === true && paints\n ? {\n backgroundImage: `linear-gradient(${SELECTED_ROW_BACKGROUND}, ${SELECTED_ROW_BACKGROUND})`,\n color: SELECTED_ROW_FOREGROUND,\n ...(accent ? { boxShadow: `inset 2px 0 0 ${SELECTED_ROW_ACCENT}` } : {}),\n ...SELECTED_TEXT_CONTEXT,\n }\n : {};\n\n const toneForeground = TONE_FOREGROUNDS[tone];\n const toneStyle: React.CSSProperties = toneForeground\n ? ({\n color: toneForeground,\n '--malachite-ctx-text-primary': toneForeground,\n } as React.CSSProperties)\n : {};\n\n // `selected` last of the two: a row can be both, and selection is the state the reader is\n // acting on, so it wins the colour.\n const rowStyle = { ...toneStyle, ...selectedStyle, ...style };\n\n // Only a checkbox has a partly-checked state; a radio is chosen or not.\n const ariaChecked =\n role === 'checkbox' && selected === 'mixed'\n ? ('mixed' as const)\n : role === 'radio' || role === 'checkbox'\n ? selected === true\n : undefined;\n // `aria-current`, not `aria-pressed`: a selected row is one of many choices, not a toggle\n // (same call as `Dropdown`'s options). A role that carries its own state uses that instead.\n const ariaCurrent = ariaChecked === undefined && selected === true ? true : undefined;\n\n // Everything a control would have carried, for the branches that render none: the row\n // element is then the only thing assistive tech sees. `aria-disabled` because there is no\n // control to be natively disabled — and it is inert without a role, like the name.\n const rowFallbackAria = {\n role,\n 'aria-checked': ariaChecked,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-disabled': role && disabled ? true : undefined,\n };\n\n if (asChild) {\n return paintOnChild(children, rowClasses([]), rowStyle);\n }\n\n // The set goes here, not on the wrapper: `radio` and `checkbox` make their\n // descendants presentational, which would bury a control in the trailing slot.\n const controlAria = {\n role,\n tabIndex,\n 'aria-checked': ariaChecked,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n };\n\n const hasLeading = isRenderableNode(leading);\n const boxed = leading !== undefined || dimmed !== undefined;\n const content = boxed ? (\n <span className=\"flex w-full min-w-0 items-center gap-[12px]\">\n {hasLeading && <span className=\"shrink-0 flex items-center\">{leading}</span>}\n <span\n className={`grid flex-1 min-w-0 grid-cols-[minmax(0,1fr)] transition-opacity ${dimmed ? 'opacity-60' : ''}`}\n >\n {children}\n </span>\n </span>\n ) : (\n children\n );\n\n if (hasTrailing) {\n const focusRing = disabled ? null : (\n <span\n aria-hidden=\"true\"\n data-malachite-row-ring=\"\"\n className={FOCUS_RING_INSET_OVERLAY_HIDDEN}\n />\n );\n const rowControlClasses = [\n ...controlReset,\n 'outline-none border-0 p-0 flex-1 min-w-0 text-left',\n ]\n .filter(Boolean)\n .join(' ');\n const anchor = Boolean(href) && !disabled;\n const control = anchor ? (\n <a\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n onClick={onClick}\n className={`${rowControlClasses} no-underline text-inherit`}\n data-malachite-row-control=\"\"\n {...controlAria}\n >\n {content}\n {focusRing}\n </a>\n ) : onClick ? (\n <button\n ref={controlRef}\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n className={rowControlClasses}\n data-malachite-row-control=\"\"\n {...controlAria}\n >\n {content}\n {focusRing}\n </button>\n ) : (\n <div className=\"flex-1 min-w-0\" data-malachite-row-control=\"\" {...rowFallbackAria}>\n {content}\n </div>\n );\n\n return (\n <div\n className={[\n chromeClasses,\n 'relative flex items-center',\n forwards ? 'cursor-pointer' : '',\n insetClass,\n revealTrailing ? 'group/row' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={rowStyle}\n data-malachite-row=\"\"\n data-disabled={disabled ? '' : undefined}\n ref={rowRef}\n role={forwards ? 'presentation' : undefined}\n onPointerDownCapture={forwards ? startPress : undefined}\n onPointerUpCapture={forwards ? trackPress : undefined}\n >\n {control}\n <div\n className={`shrink-0 flex items-center ${forwards ? 'cursor-default' : ''} ${revealTrailing ? REVEALED_ON_INTERACTION : ''}`}\n data-malachite-row-slot=\"\"\n >\n {trailing}\n </div>\n </div>\n );\n }\n\n const classes = rowClasses(\n interactive ? [...controlReset, controlPadding, FOCUS_RING_INSET] : [],\n );\n\n if (href && !disabled) {\n return (\n <a\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n onClick={onClick}\n className={`${classes} block no-underline text-inherit`}\n style={rowStyle}\n {...controlAria}\n >\n {content}\n </a>\n );\n }\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n className={classes}\n style={rowStyle}\n {...controlAria}\n >\n {content}\n </button>\n );\n }\n\n return (\n <div className={classes} style={rowStyle} {...rowFallbackAria}>\n {content}\n </div>\n );\n};\n\nexport interface SurfaceExpandableRowProps {\n /** The row itself, laid out across the line. May hold its own controls. */\n header: React.ReactNode;\n /** The body, rendered beneath the row while it is open. */\n children?: React.ReactNode;\n expanded: boolean;\n /** Omit for a row that cannot open. The arrow's space is still reserved, so a list of\n * rows stays in one column whether or not each one has a body. */\n onToggle?: (expanded: boolean) => void;\n /**\n * Pins the row while its body scrolls, so a long body never leaves the reader without\n * the line it belongs to. Offset by whatever is already pinned above it.\n */\n sticky?: boolean;\n stickyTopOffset?: number;\n divider?: boolean;\n tone?: SurfaceRowProps['tone'];\n /** Names the disclosure control, which is otherwise only an arrow. */\n 'aria-label'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\n/**\n * Stops a click inside it from toggling the row, for the cells that hold controls.\n *\n * Explicit rather than sniffing the event's target for an interactive ancestor: a control\n * rendering into a shadow root retargets the event to its host, so the sniff would miss\n * exactly the components most likely to sit in a row.\n */\nconst ExpandableRowControls: React.FC<{\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n}> = ({ children, className = '', style }) => (\n <div className={className} style={style} onClick={(event) => event.stopPropagation()}>\n {children}\n </div>\n);\n\n/**\n * A row that opens to reveal a body, for a line that carries its own controls.\n *\n * Not `Accordion`: that puts its header inside the toggle button, so a header holding a\n * dropdown or a second button is invalid. Here the row surface takes the click and a cell\n * opts out with `ExpandableRow.Controls`, while the arrow stays a real button so the\n * keyboard reaches it.\n */\n/**\n * The space before the header: the arrow's own inset, its glyph and the gap after it.\n * Exported so a consumer aligning a column header above these rows offsets by the same\n * amount instead of guessing at it.\n */\nexport const EXPANDABLE_ROW_LEAD_PX = 39;\n\nconst SurfaceExpandableRow: React.FC<SurfaceExpandableRowProps> & {\n Controls: typeof ExpandableRowControls;\n} = Object.assign(\n ({\n header,\n children,\n expanded,\n onToggle,\n sticky = false,\n stickyTopOffset = 0,\n divider = false,\n tone = 'default',\n 'aria-label': ariaLabel,\n className = '',\n style,\n }: SurfaceExpandableRowProps) => {\n const bodyId = React.useId();\n const toggle = onToggle ? () => onToggle(!expanded) : undefined;\n\n return (\n // The hover is the header's, not the row's: the row holds the open body too, which is\n // not a target, and tinting it washes out everything in it.\n <SurfaceRow\n divider={divider}\n tone={tone}\n hover={false}\n className={className}\n style={style}\n >\n {/* `group` so the arrow takes its hover state from the whole header line. */}\n <div\n className={`group flex items-center w-full ${ROW_HOVER} ${\n toggle ? 'cursor-pointer' : ''\n } ${\n sticky && expanded\n ? 'sticky z-[1] bg-[var(--malachite-card-background)]'\n : ''\n }`}\n style={sticky && expanded ? { top: stickyTopOffset } : undefined}\n // Presentational: the arrow below is the keyboard control, and this only\n // widens the pointer target.\n onClick={toggle}\n role=\"presentation\"\n >\n {/* Reserved whether or not this row opens, so a list stays in one column.\n The inset and gap match Accordion's header. */}\n <span className=\"shrink-0 flex items-center pl-[16px] pr-[12px]\">\n {toggle && (\n <button\n type=\"button\"\n className={`appearance-none bg-transparent border-0 p-0 flex items-center cursor-pointer ${FOCUS_RING_INSET}`}\n aria-expanded={expanded}\n aria-controls={bodyId}\n aria-label={ariaLabel}\n onClick={(event) => {\n event.stopPropagation();\n toggle();\n }}\n >\n <DisclosureArrow expanded={expanded} />\n </button>\n )}\n </span>\n {header}\n </div>\n {expanded && <div id={bodyId}>{children}</div>}\n </SurfaceRow>\n );\n },\n { Controls: ExpandableRowControls },\n);\n\ninterface SurfaceComponent extends React.FC<SurfaceProps> {\n Row: React.FC<AnySurfaceRowProps>;\n ExpandableRow: typeof SurfaceExpandableRow;\n}\n\nconst SURFACE_TONE_CLASSES: Record<SurfaceTone, string> = {\n default:\n 'bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)]',\n highlight: 'bg-[var(--malachite-card-warm-background,rgb(244,242,240))]',\n};\n\nconst FLAT_CLIP_RING =\n \"relative after:pointer-events-none after:absolute after:-inset-px after:z-[9] after:rounded-[inherit] after:border after:border-solid after:[border-color:inherit] after:content-['']\";\n\nconst Surface = (({\n children,\n padding = false,\n overflow = 'hidden',\n tone = 'default',\n shadow = tone !== 'highlight',\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n style,\n}: SurfaceProps) => {\n // Literal class names (not interpolated) so Tailwind's JIT emits them.\n const clipsToBorder = overflow === 'clip' && !shadow && tone === 'default';\n const overflowClass = clipsToBorder\n ? 'overflow-visible'\n : overflow === 'clip'\n ? 'overflow-clip'\n : overflow === 'visible'\n ? 'overflow-visible'\n : 'overflow-hidden';\n return (\n <div\n className={`w-full rounded-[var(--malachite-radius-xxl,14px)] ${overflowClass} ${SURFACE_TONE_CLASSES[tone]} ${padding ? 'py-3 px-4' : ''} ${clipsToBorder ? FLAT_CLIP_RING : ''} ${className}`}\n style={{\n ...(shadow ? { boxShadow: TRIPLE_SHADOW } : {}),\n ...(clipsToBorder\n ? { clipPath: 'inset(0 round var(--malachite-radius-xxl, 14px))' }\n : {}),\n ...FOREGROUND_RESET,\n ...style,\n }}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </div>\n );\n}) as SurfaceComponent;\n\nSurface.Row = SurfaceRow;\nSurface.ExpandableRow = SurfaceExpandableRow;\n\nexport default Surface;\nexport { Surface, SurfaceRow, SurfaceExpandableRow };\n"],"names":["INSET_CLASSES","TONE_CLASSES","TONE_FOREGROUNDS","REVEALED_ON_INTERACTION","selectsTextIn","row","root","selection","_a","index","forwardedClick","event","TRIPLE_SHADOW","SurfaceRow","props","children","divider","disabled","hoverable","selected","tone","inset","className","style","asChild","onClick","rawHref","target","rel","trailing","revealTrailing","leading","dimmed","role","href","safeHref","ariaLabel","ariaLabelledBy","tabIndex","interactive","hover","ROW_HOVER","tinted","toneClass","hasTrailing","isRenderableNode","insetClass","controlPadding","chromeClasses","controlReset","rowClasses","control","paints","accent","forwards","rowRef","useRef","controlRef","pressLeftPadding","startPress","trackPress","useEffect","forwardPaddingClick","leftPadding","selectedStyle","SELECTED_ROW_BACKGROUND","SELECTED_ROW_FOREGROUND","SELECTED_ROW_ACCENT","SELECTED_TEXT_CONTEXT","toneForeground","rowStyle","ariaChecked","ariaCurrent","rowFallbackAria","paintOnChild","controlAria","hasLeading","content","jsxs","jsx","focusRing","FOCUS_RING_INSET_OVERLAY_HIDDEN","rowControlClasses","resolveRel","classes","FOCUS_RING_INSET","ExpandableRowControls","EXPANDABLE_ROW_LEAD_PX","SurfaceExpandableRow","header","expanded","onToggle","sticky","stickyTopOffset","bodyId","React","toggle","DisclosureArrow","SURFACE_TONE_CLASSES","FLAT_CLIP_RING","Surface","padding","overflow","shadow","clipsToBorder","FOREGROUND_RESET"],"mappings":";;;;;;;;;;AA6EA,MAAMA,KAA6E;AAAA,EAC/E,MAAM;AAAA;AAAA,EAEN,SAAS;AACb,GAyCMC,KAAqE;AAAA,EACvE,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAUMC,KAAkF;AAAA,EACpF,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAaMC,KACF,0KAEEC,KAAgB,CAACC,MAA0B;;AAC7C,QAAMC,IAAOD,EAAI,YAAA,GAEXE,MADgBC,IAAAF,EAAiD,iBAAjD,gBAAAE,EAAA,KAAAF,OACYD,EAAI,cAAc,aAAA;AACpD,MAAI,CAACE,KAAaA,EAAU;AACxB,WAAO;AAEX,WAASE,IAAQ,GAAGA,IAAQF,EAAU,YAAYE,KAAS;AACvD,QAAIF,EAAU,WAAWE,CAAK,EAAE,eAAeJ,CAAG;AAC9C,aAAO;AAGf,SAAO;AACX,GAEMK,KAAiB,CAACC,MACpB,IAAKA,EAAM,YAAkC,SAASA,CAAK,GAEzDC,KACF,yGASEC,KAA2C,CAACC,MAAU;AACxD,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,UAAAC,IAAW;AAAA,IACX,OAAOC,IAAY;AAAA,IACnB,UAAAC;AAAA,IACA,WAAAZ;AAAA,IACA,MAAAa,IAAO;AAAA,IACP,OAAAC,IAAQ;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,IAASnF,MAAS;AAAA,EAClB,MAAAa;AAAA,EACA,cAAcG;AAAA,EACd,mBAAmBC;AAAA,EACnB,WAAAf,IAAY;AAAA,EACZ,OAAAC;AACJ,MAAoB;AAEhB,QAAMiF,IAAgBF,MAAa,UAAU,CAACC,KAAUnF,MAAS;AAQjE,SACI,gBAAA2D;AAAA,IAAC;AAAA,IAAA;AAAA,MACG,WAAW,qDATGyB,IAChB,qBACAF,MAAa,SACX,kBACAA,MAAa,YACX,qBACA,iBAG2E,IAAIJ,GAAqB9E,CAAI,CAAC,IAAIiF,IAAU,cAAc,EAAE,IAAIG,IAAgBL,KAAiB,EAAE,IAAI7E,CAAS;AAAA,MAC7L,OAAO;AAAA,QACH,GAAIiF,IAAS,EAAE,WAAW3F,GAAA,IAAkB,CAAA;AAAA,QAC5C,GAAI4F,IACE,EAAE,UAAU,mDAAA,IACZ,CAAA;AAAA,QACN,GAAGC;AAAA,QACH,GAAGlF;AAAA,MAAA;AAAA,MAEP,MAAAU;AAAA,MACA,cAAYG;AAAA,MACZ,mBAAiBC;AAAA,MAEhB,UAAAtB;AAAA,IAAA;AAAA,EAAA;AAGb;AAEAqF,GAAQ,MAAMvF;AACduF,GAAQ,gBAAgBZ;"}
|
|
1
|
+
{"version":3,"file":"Surface.js","sources":["../../src/components/Surface.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport DisclosureArrow from './DisclosureArrow';\nimport { paintOnChild } from './asChild';\nimport { ROW_HOVER } from './chromeStyles';\nimport { FOCUS_RING_INSET, FOCUS_RING_INSET_OVERLAY_HIDDEN } from './focusRing';\nimport { resolveRel } from './linkRel';\nimport { isRenderableNode } from './renderableNode';\nimport { safeHref } from './safeHref';\nimport {\n FOREGROUND_RESET,\n SELECTED_ROW_ACCENT,\n SELECTED_ROW_BACKGROUND,\n SELECTED_ROW_FOREGROUND,\n SELECTED_TEXT_CONTEXT,\n} from './selectedRow';\n\nexport type SurfaceTone = 'default' | 'highlight';\n\nexport interface SurfaceProps {\n children?: React.ReactNode;\n padding?: boolean;\n /**\n * Content overflow. Defaults to `hidden` so children are clipped to the rounded\n * corners. Use `clip` to keep the rounded clipping WITHOUT creating a scroll\n * container — so a `position: sticky` descendant still pins (unlike `hidden`,\n * which traps it). `visible` disables clipping entirely. A flat, default-tone `clip` card clips at its border.\n */\n overflow?: 'hidden' | 'visible' | 'clip';\n /**\n * `false` drops the elevation shadow, for a card that sits flat on its ground.\n * Default: `true`, or `false` with `tone=\"highlight\"`.\n */\n shadow?: boolean;\n /**\n * `highlight` paints the warm ground with no border and no shadow, for a static block that\n * stands out from the page, such as a hero or a guide's section header. Its ground is too\n * close to `Surface.Row`'s hover for clickable rows inside it.\n */\n tone?: SurfaceTone;\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\ninterface SurfaceRowChromeProps {\n children?: React.ReactNode;\n /** Renders a bottom divider — omit on the last row in a Surface. */\n divider?: boolean;\n /** Removes the hover affordance / disables the control (e.g. while loading/busy). */\n disabled?: boolean;\n /** Announces the row as selected — `aria-checked` under a `radio`/`checkbox` role,\n * `aria-current` otherwise — and paints `Table`'s selected treatment unless `selection`\n * says not to. `'mixed'` is for a `checkbox` row that is partly selected: it announces\n * `aria-checked=\"mixed\"` there, never paints and never marks the row current, and counts\n * as not selected under any other role. */\n selected?: boolean | 'mixed';\n /** How a `selected` row shows it. `highlight` paints the treatment; `tint` paints it\n * without the accent bar, for a menu whose choice is already marked inside the row;\n * `announce` leaves the visual to a control inside the row and only sets the ARIA state.\n * Defaults to `announce` under `role=\"checkbox\"` and `highlight` otherwise. */\n selection?: 'highlight' | 'tint' | 'announce';\n /**\n * Tints the whole row by what it reports. `muted` is a row whose subject is inactive —\n * not disabled: it stays interactive. `success`, `warning` and `error` are for a row that\n * carries an outcome, where the result belongs to the whole line rather than to one cell in it.\n */\n tone?: 'default' | 'muted' | 'success' | 'warning' | 'error';\n /** `compact`, the default, is an 8px by 16px inset the row owns, so its content clears the\n * card's border without a padding wrapper. `none` leaves the edges to the content, for a row\n * that pads itself or runs edge to edge, such as a search field. */\n inset?: 'none' | 'compact';\n /** `false` leaves the hover to something inside the row. */\n hover?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst INSET_CLASSES: Record<NonNullable<SurfaceRowChromeProps['inset']>, string> = {\n none: '',\n // The 16px is ROW_INSET_PX in accordionBodyInset.ts too; Accordion's bodyIndent gives it back.\n compact: 'px-[16px] py-[8px]',\n};\n\n/** Stays an interface under its original name: a consumer may `extends` it. */\nexport interface SurfaceRowProps extends SurfaceRowChromeProps {\n asChild?: false;\n /**\n * When provided, the whole row becomes clickable: it renders as a `<button>`\n * (or `<a>` when `href` is set), so the entire row is the click target with\n * native focus + Enter/Space — no manual tabIndex/key handlers. For a\n * selectable row, put a presentational `<Radio>`/`<Checkbox>` inside as the\n * visual indicator; do NOT nest an interactive control (invalid + double tab stop).\n */\n onClick?: (event: React.MouseEvent) => void;\n /** Renders the clickable row as an anchor instead of a button. */\n href?: string;\n target?: React.HTMLAttributeAnchorTarget;\n rel?: string;\n /** Content pinned right, outside the row button, so it may hold its own control. */\n trailing?: React.ReactNode;\n /**\n * Shows `trailing` only while the row is hovered or holds focus, and while a menu\n * it opened is still open. Hidden by opacity, so it stays in the tab order; a touch screen,\n * which has no hover, always shows it.\n */\n revealTrailing?: boolean;\n /** The row's indicator, before the children. With this or `dimmed`, pass one child. */\n leading?: React.ReactNode;\n /** Fades the children, not `leading` or `trailing`. */\n dimmed?: boolean;\n /** ARIA role for a clickable row, e.g. `radio`/`checkbox` (wrap the list in a `radiogroup`). */\n role?: React.AriaRole;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /** `-1` takes the row out of the Tab order, for a roving radio group. */\n tabIndex?: number;\n}\n\n/**\n * The outcome tones reuse the tag tokens rather than minting row ones, so a row saying \"this\n * passed\" and a tag saying it are the same green wherever the two sit together.\n */\nconst TONE_CLASSES: Record<NonNullable<SurfaceRowProps['tone']>, string> = {\n default: '',\n muted: 'bg-[var(--malachite-card-dimmed-background)]',\n success: 'bg-[var(--malachite-tag-success-background,rgba(0,175,102,0.1))]',\n warning: 'bg-[var(--malachite-tag-warning-background,rgba(150,88,10,0.1))]',\n error: 'bg-[var(--malachite-tag-error-background,rgba(196,62,62,0.1))]',\n};\n\n/**\n * The text an outcome tone carries with it, through the same context channel a selected row\n * uses, so `Typography` inside the row follows the tint instead of staying near-black on it.\n * `color` as well, for row content that is not Typography.\n *\n * Only the outcome tones. `muted` dims its subject rather than recolouring it, and its\n * foreground is the ordinary one.\n */\nconst TONE_FOREGROUNDS: Partial<Record<NonNullable<SurfaceRowProps['tone']>, string>> = {\n success: 'var(--malachite-tag-success-foreground, rgb(2, 122, 66))',\n warning: 'var(--malachite-tag-warning-foreground, rgb(150, 88, 10))',\n error: 'var(--malachite-tag-error-foreground, rgb(196, 62, 62))',\n};\n\nexport interface SurfaceRowAsChildProps extends SurfaceRowChromeProps {\n asChild: true;\n children: React.ReactElement;\n}\n\nexport type AnySurfaceRowProps = SurfaceRowProps | SurfaceRowAsChildProps;\n\n// Not `group-hover` or `group-has-[:focus-visible]`: WebKit never applies the first (its\n// `@media (hover: hover)` nested in the group selector) nor the second inside a shadow root,\n// so the control stayed hidden in Safari. An open menu takes focus out of the row into a\n// portal, and would otherwise lose its trigger.\nconst REVEALED_ON_INTERACTION =\n 'opacity-0 transition-opacity group-[:hover]/row:opacity-100 group-focus-within/row:opacity-100 has-[[aria-expanded=true]]:opacity-100 [@media(hover:none)]:opacity-100';\n\nconst selectsTextIn = (row: Element): boolean => {\n const root = row.getRootNode();\n const ownSelection = (root as Partial<Pick<Document, 'getSelection'>>).getSelection?.();\n const selection = ownSelection ?? row.ownerDocument.getSelection();\n if (!selection || selection.isCollapsed) {\n return false;\n }\n for (let index = 0; index < selection.rangeCount; index += 1) {\n if (selection.getRangeAt(index).intersectsNode(row)) {\n return true;\n }\n }\n return false;\n};\n\nconst forwardedClick = (event: MouseEvent): MouseEvent =>\n new (event.constructor as typeof MouseEvent)('click', event);\n\nconst TRIPLE_SHADOW =\n '0px 0px 4px 0px rgba(0,0,0,0.08), 0px 4px 4px 0px rgba(0,0,0,0.08), 0px 4px 10px 0px rgba(0,0,0,0.05)';\n\n/**\n * A single full-bleed row inside a <Surface>. Owns the row chrome — hover\n * highlight, colour transition and an optional bottom divider — so consumers\n * compose their own content inside without re-implementing design-system styling.\n * Pass `onClick`/`href` to make the entire row clickable (rendered as a real\n * button/anchor, so keyboard navigation works natively).\n */\nconst SurfaceRow: React.FC<AnySurfaceRowProps> = (props) => {\n const {\n children,\n divider = false,\n disabled = false,\n hover: hoverable = true,\n selected,\n selection,\n tone = 'default',\n inset = 'compact',\n className = '',\n style,\n } = props;\n const asChild = props.asChild === true;\n const {\n onClick,\n href: rawHref,\n target,\n rel,\n trailing,\n revealTrailing,\n leading,\n dimmed,\n role,\n } = asChild ? ({} as SurfaceRowProps) : (props as SurfaceRowProps);\n // A rejected href (e.g. `javascript:`) leaves the row a button or a plain row, never an anchor.\n const href = safeHref(rawHref);\n const ariaLabel = asChild ? undefined : (props as SurfaceRowProps)['aria-label'];\n const ariaLabelledBy = asChild ? undefined : (props as SurfaceRowProps)['aria-labelledby'];\n const tabIndex = asChild ? undefined : (props as SurfaceRowProps).tabIndex;\n const interactive = Boolean(onClick || href);\n // `asChild` is interactive for the hover affordance only, not the focus/reset classes.\n const hover = disabled && (interactive || asChild) ? '' : hoverable ? ROW_HOVER : '';\n\n // A class, not an inline colour, which would outrank the hover utility. It replaces the\n // button reset's `bg-transparent` rather than joining it: same specificity, so the winner\n // would be whichever Tailwind emitted last.\n const tinted = tone !== 'default';\n const toneClass = TONE_CLASSES[tone];\n\n const hasTrailing = !asChild && isRenderableNode(trailing);\n const insetClass = INSET_CLASSES[inset];\n const controlPadding = insetClass ? '' : 'p-0';\n\n const chromeClasses = [\n 'w-full text-left border-0',\n toneClass,\n divider ? 'border-b border-solid border-[var(--malachite-card-border)]' : '',\n hover,\n ]\n .filter(Boolean)\n .join(' ');\n\n const controlReset = [\n 'appearance-none',\n tinted ? '' : 'bg-transparent',\n disabled ? '' : 'cursor-pointer',\n ];\n const rowClasses = (control: string[]) =>\n [chromeClasses, ...control, insetClass, className].filter(Boolean).join(' ');\n\n const paints = selection ? selection !== 'announce' : role !== 'checkbox';\n const accent = selection !== 'tint';\n\n const forwards = hasTrailing && Boolean(onClick) && !href && !disabled;\n const rowRef = useRef<HTMLDivElement>(null);\n const controlRef = useRef<HTMLButtonElement>(null);\n const pressLeftPadding = useRef(false);\n const startPress = (event: React.PointerEvent<HTMLDivElement>) => {\n pressLeftPadding.current = event.target !== event.currentTarget;\n };\n const trackPress = (event: React.PointerEvent<HTMLDivElement>) => {\n pressLeftPadding.current ||= event.target !== event.currentTarget;\n };\n useEffect(() => {\n const row = rowRef.current;\n if (!forwards || !row) {\n return undefined;\n }\n const forwardPaddingClick = (event: MouseEvent) => {\n const leftPadding = pressLeftPadding.current;\n pressLeftPadding.current = false;\n const control = controlRef.current;\n if (\n !control ||\n event.target !== row ||\n leftPadding ||\n (event.detail <= 1 && !event.shiftKey && selectsTextIn(row))\n ) {\n return;\n }\n event.stopPropagation();\n control.focus({ preventScroll: true });\n control.dispatchEvent(forwardedClick(event));\n };\n row.addEventListener('click', forwardPaddingClick);\n return () => row.removeEventListener('click', forwardPaddingClick);\n }, [forwards]);\n\n // A gradient layer so the tint composites over hover, and an inset shadow because\n // `ring-*` silently doesn't paint in a shadow root.\n const selectedStyle: React.CSSProperties =\n selected === true && paints\n ? {\n backgroundImage: `linear-gradient(${SELECTED_ROW_BACKGROUND}, ${SELECTED_ROW_BACKGROUND})`,\n color: SELECTED_ROW_FOREGROUND,\n ...(accent ? { boxShadow: `inset 2px 0 0 ${SELECTED_ROW_ACCENT}` } : {}),\n ...SELECTED_TEXT_CONTEXT,\n }\n : {};\n\n const toneForeground = TONE_FOREGROUNDS[tone];\n const toneStyle: React.CSSProperties = toneForeground\n ? ({\n color: toneForeground,\n '--malachite-ctx-text-primary': toneForeground,\n } as React.CSSProperties)\n : {};\n\n // `selected` last of the two: a row can be both, and selection is the state the reader is\n // acting on, so it wins the colour.\n const rowStyle = { ...toneStyle, ...selectedStyle, ...style };\n\n // Only a checkbox has a partly-checked state; a radio is chosen or not.\n const ariaChecked =\n role === 'checkbox' && selected === 'mixed'\n ? ('mixed' as const)\n : role === 'radio' || role === 'checkbox'\n ? selected === true\n : undefined;\n // `aria-current`, not `aria-pressed`: a selected row is one of many choices, not a toggle\n // (same call as `Dropdown`'s options). A role that carries its own state uses that instead.\n const ariaCurrent = ariaChecked === undefined && selected === true ? true : undefined;\n\n // Everything a control would have carried, for the branches that render none: the row\n // element is then the only thing assistive tech sees. `aria-disabled` because there is no\n // control to be natively disabled — and it is inert without a role, like the name.\n const rowFallbackAria = {\n role,\n 'aria-checked': ariaChecked,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-disabled': role && disabled ? true : undefined,\n };\n\n if (asChild) {\n return paintOnChild(children, rowClasses([]), rowStyle);\n }\n\n // The set goes here, not on the wrapper: `radio` and `checkbox` make their\n // descendants presentational, which would bury a control in the trailing slot.\n const controlAria = {\n role,\n tabIndex,\n 'aria-checked': ariaChecked,\n 'aria-current': ariaCurrent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n };\n\n const hasLeading = isRenderableNode(leading);\n const boxed = leading !== undefined || dimmed !== undefined;\n const content = boxed ? (\n <span className=\"flex w-full min-w-0 items-center gap-[12px]\">\n {hasLeading && <span className=\"shrink-0 flex items-center\">{leading}</span>}\n <span\n className={`grid flex-1 min-w-0 grid-cols-[minmax(0,1fr)] transition-opacity ${dimmed ? 'opacity-60' : ''}`}\n >\n {children}\n </span>\n </span>\n ) : (\n children\n );\n\n if (hasTrailing) {\n const focusRing = disabled ? null : (\n <span\n aria-hidden=\"true\"\n data-malachite-row-ring=\"\"\n className={FOCUS_RING_INSET_OVERLAY_HIDDEN}\n />\n );\n const rowControlClasses = [\n ...controlReset,\n 'outline-none border-0 p-0 flex-1 min-w-0 text-left',\n ]\n .filter(Boolean)\n .join(' ');\n const anchor = Boolean(href) && !disabled;\n const control = anchor ? (\n <a\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n onClick={onClick}\n className={`${rowControlClasses} no-underline text-inherit`}\n data-malachite-row-control=\"\"\n {...controlAria}\n >\n {content}\n {focusRing}\n </a>\n ) : onClick ? (\n <button\n ref={controlRef}\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n className={rowControlClasses}\n data-malachite-row-control=\"\"\n {...controlAria}\n >\n {content}\n {focusRing}\n </button>\n ) : (\n <div className=\"flex-1 min-w-0\" data-malachite-row-control=\"\" {...rowFallbackAria}>\n {content}\n </div>\n );\n\n return (\n <div\n className={[\n chromeClasses,\n 'relative flex items-center',\n forwards ? 'cursor-pointer' : '',\n insetClass,\n revealTrailing ? 'group/row' : '',\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n style={rowStyle}\n data-malachite-row=\"\"\n data-disabled={disabled ? '' : undefined}\n ref={rowRef}\n role={forwards ? 'presentation' : undefined}\n onPointerDownCapture={forwards ? startPress : undefined}\n onPointerUpCapture={forwards ? trackPress : undefined}\n >\n {control}\n <div\n className={`shrink-0 flex items-center ${forwards ? 'cursor-default' : ''} ${revealTrailing ? REVEALED_ON_INTERACTION : ''}`}\n data-malachite-row-slot=\"\"\n >\n {trailing}\n </div>\n </div>\n );\n }\n\n const classes = rowClasses(\n interactive ? [...controlReset, controlPadding, FOCUS_RING_INSET] : [],\n );\n\n if (href && !disabled) {\n return (\n <a\n href={href}\n target={target}\n rel={resolveRel(rel, target)}\n onClick={onClick}\n className={`${classes} block no-underline text-inherit`}\n style={rowStyle}\n {...controlAria}\n >\n {content}\n </a>\n );\n }\n\n if (onClick) {\n return (\n <button\n type=\"button\"\n onClick={onClick}\n disabled={disabled}\n className={classes}\n style={rowStyle}\n {...controlAria}\n >\n {content}\n </button>\n );\n }\n\n return (\n <div className={classes} style={rowStyle} {...rowFallbackAria}>\n {content}\n </div>\n );\n};\n\nexport interface SurfaceExpandableRowProps {\n /** The row itself, laid out across the line. May hold its own controls. */\n header: React.ReactNode;\n /** The body, rendered beneath the row while it is open. */\n children?: React.ReactNode;\n expanded: boolean;\n /** Omit for a row that cannot open. The arrow's space is still reserved, so a list of\n * rows stays in one column whether or not each one has a body. */\n onToggle?: (expanded: boolean) => void;\n /**\n * Pins the row while its body scrolls, so a long body never leaves the reader without\n * the line it belongs to. Offset by whatever is already pinned above it.\n */\n sticky?: boolean;\n stickyTopOffset?: number;\n divider?: boolean;\n tone?: SurfaceRowProps['tone'];\n /** Names the disclosure control, which is otherwise only an arrow. */\n 'aria-label'?: string;\n className?: string;\n style?: React.CSSProperties;\n}\n\n/**\n * Stops a click inside it from toggling the row, for the cells that hold controls.\n *\n * Explicit rather than sniffing the event's target for an interactive ancestor: a control\n * rendering into a shadow root retargets the event to its host, so the sniff would miss\n * exactly the components most likely to sit in a row.\n */\nconst ExpandableRowControls: React.FC<{\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n}> = ({ children, className = '', style }) => (\n <div className={className} style={style} onClick={(event) => event.stopPropagation()}>\n {children}\n </div>\n);\n\n/**\n * A row that opens to reveal a body, for a line that carries its own controls.\n *\n * Not `Accordion`: that puts its header inside the toggle button, so a header holding a\n * dropdown or a second button is invalid. Here the row surface takes the click and a cell\n * opts out with `ExpandableRow.Controls`, while the arrow stays a real button so the\n * keyboard reaches it.\n */\n/**\n * The space before the header: the arrow's own inset, its glyph and the gap after it.\n * Exported so a consumer aligning a column header above these rows offsets by the same\n * amount instead of guessing at it.\n */\nexport const EXPANDABLE_ROW_LEAD_PX = 39;\n\nconst SurfaceExpandableRow: React.FC<SurfaceExpandableRowProps> & {\n Controls: typeof ExpandableRowControls;\n} = Object.assign(\n ({\n header,\n children,\n expanded,\n onToggle,\n sticky = false,\n stickyTopOffset = 0,\n divider = false,\n tone = 'default',\n 'aria-label': ariaLabel,\n className = '',\n style,\n }: SurfaceExpandableRowProps) => {\n const bodyId = React.useId();\n const toggle = onToggle ? () => onToggle(!expanded) : undefined;\n\n return (\n // The hover is the header's, not the row's: the row holds the open body too, which is\n // not a target, and tinting it washes out everything in it.\n <SurfaceRow\n divider={divider}\n tone={tone}\n hover={false}\n className={className}\n style={style}\n >\n {/* `group` so the arrow takes its hover state from the whole header line. */}\n <div\n className={`group flex items-center w-full ${ROW_HOVER} ${\n toggle ? 'cursor-pointer' : ''\n } ${\n sticky && expanded\n ? 'sticky z-[1] bg-[var(--malachite-card-background)]'\n : ''\n }`}\n style={sticky && expanded ? { top: stickyTopOffset } : undefined}\n // Presentational: the arrow below is the keyboard control, and this only\n // widens the pointer target.\n onClick={toggle}\n role=\"presentation\"\n >\n {/* Reserved whether or not this row opens, so a list stays in one column.\n The inset and gap match Accordion's header. */}\n <span className=\"shrink-0 flex items-center pl-[16px] pr-[12px]\">\n {toggle && (\n <button\n type=\"button\"\n className={`appearance-none bg-transparent border-0 p-0 flex items-center cursor-pointer ${FOCUS_RING_INSET}`}\n aria-expanded={expanded}\n aria-controls={bodyId}\n aria-label={ariaLabel}\n onClick={(event) => {\n event.stopPropagation();\n toggle();\n }}\n >\n <DisclosureArrow expanded={expanded} />\n </button>\n )}\n </span>\n {header}\n </div>\n {expanded && <div id={bodyId}>{children}</div>}\n </SurfaceRow>\n );\n },\n { Controls: ExpandableRowControls },\n);\n\ninterface SurfaceComponent extends React.FC<SurfaceProps> {\n Row: React.FC<AnySurfaceRowProps>;\n ExpandableRow: typeof SurfaceExpandableRow;\n}\n\nconst SURFACE_TONE_CLASSES: Record<SurfaceTone, string> = {\n default:\n 'bg-[var(--malachite-card-background)] border border-solid border-[var(--malachite-card-border)]',\n highlight: 'bg-[var(--malachite-card-warm-background,rgb(244,242,240))]',\n};\n\nconst FLAT_CLIP_RING =\n \"relative after:pointer-events-none after:absolute after:-inset-px after:z-[9] after:rounded-[inherit] after:border after:border-solid after:[border-color:inherit] after:content-['']\";\n\nconst Surface = (({\n children,\n padding = false,\n overflow = 'hidden',\n tone = 'default',\n shadow = tone !== 'highlight',\n role,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className = '',\n style,\n}: SurfaceProps) => {\n // Literal class names (not interpolated) so Tailwind's JIT emits them.\n const clipsToBorder = overflow === 'clip' && !shadow && tone === 'default';\n const overflowClass = clipsToBorder\n ? 'overflow-visible'\n : overflow === 'clip'\n ? 'overflow-clip'\n : overflow === 'visible'\n ? 'overflow-visible'\n : 'overflow-hidden';\n return (\n <div\n className={`w-full rounded-[var(--malachite-radius-xxl,14px)] ${overflowClass} ${SURFACE_TONE_CLASSES[tone]} ${padding ? 'py-3 px-4' : ''} ${clipsToBorder ? FLAT_CLIP_RING : ''} ${className}`}\n style={{\n ...(shadow ? { boxShadow: TRIPLE_SHADOW } : {}),\n ...(clipsToBorder\n ? { clipPath: 'inset(0 round var(--malachite-radius-xxl, 14px))' }\n : {}),\n ...FOREGROUND_RESET,\n ...style,\n }}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </div>\n );\n}) as SurfaceComponent;\n\nSurface.Row = SurfaceRow;\nSurface.ExpandableRow = SurfaceExpandableRow;\n\nexport default Surface;\nexport { Surface, SurfaceRow, SurfaceExpandableRow };\n"],"names":["INSET_CLASSES","TONE_CLASSES","TONE_FOREGROUNDS","REVEALED_ON_INTERACTION","selectsTextIn","row","root","selection","_a","index","forwardedClick","event","TRIPLE_SHADOW","SurfaceRow","props","children","divider","disabled","hoverable","selected","tone","inset","className","style","asChild","onClick","rawHref","target","rel","trailing","revealTrailing","leading","dimmed","role","href","safeHref","ariaLabel","ariaLabelledBy","tabIndex","interactive","hover","ROW_HOVER","tinted","toneClass","hasTrailing","isRenderableNode","insetClass","controlPadding","chromeClasses","controlReset","rowClasses","control","paints","accent","forwards","rowRef","useRef","controlRef","pressLeftPadding","startPress","trackPress","useEffect","forwardPaddingClick","leftPadding","selectedStyle","SELECTED_ROW_BACKGROUND","SELECTED_ROW_FOREGROUND","SELECTED_ROW_ACCENT","SELECTED_TEXT_CONTEXT","toneForeground","rowStyle","ariaChecked","ariaCurrent","rowFallbackAria","paintOnChild","controlAria","hasLeading","content","jsxs","jsx","focusRing","FOCUS_RING_INSET_OVERLAY_HIDDEN","rowControlClasses","resolveRel","classes","FOCUS_RING_INSET","ExpandableRowControls","EXPANDABLE_ROW_LEAD_PX","SurfaceExpandableRow","header","expanded","onToggle","sticky","stickyTopOffset","bodyId","React","toggle","DisclosureArrow","SURFACE_TONE_CLASSES","FLAT_CLIP_RING","Surface","padding","overflow","shadow","clipsToBorder","FOREGROUND_RESET"],"mappings":";;;;;;;;;;AA+EA,MAAMA,KAA6E;AAAA,EAC/E,MAAM;AAAA;AAAA,EAEN,SAAS;AACb,GAyCMC,KAAqE;AAAA,EACvE,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAUMC,KAAkF;AAAA,EACpF,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACX,GAaMC,KACF,0KAEEC,KAAgB,CAACC,MAA0B;;AAC7C,QAAMC,IAAOD,EAAI,YAAA,GAEXE,MADgBC,IAAAF,EAAiD,iBAAjD,gBAAAE,EAAA,KAAAF,OACYD,EAAI,cAAc,aAAA;AACpD,MAAI,CAACE,KAAaA,EAAU;AACxB,WAAO;AAEX,WAASE,IAAQ,GAAGA,IAAQF,EAAU,YAAYE,KAAS;AACvD,QAAIF,EAAU,WAAWE,CAAK,EAAE,eAAeJ,CAAG;AAC9C,aAAO;AAGf,SAAO;AACX,GAEMK,KAAiB,CAACC,MACpB,IAAKA,EAAM,YAAkC,SAASA,CAAK,GAEzDC,KACF,yGASEC,KAA2C,CAACC,MAAU;AACxD,QAAM;AAAA,IACF,UAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,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