eidos-ui 4.1.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/chip/index.cjs +2 -2
  2. package/dist/chip/index.js +1 -1
  3. package/dist/{chunk-SOS4K7VC.js → chunk-45XFUEYG.js} +2 -2
  4. package/dist/{chunk-AWPJH3UB.js → chunk-4MURW4H3.js} +2 -2
  5. package/dist/{chunk-2WDL2ZVP.js → chunk-5TRO6CYR.js} +10 -4
  6. package/dist/chunk-5TRO6CYR.js.map +1 -0
  7. package/dist/{chunk-SJPCBRKR.cjs → chunk-5YTPZN6X.cjs} +3 -3
  8. package/dist/{chunk-SJPCBRKR.cjs.map → chunk-5YTPZN6X.cjs.map} +1 -1
  9. package/dist/{chunk-7VMF6LIC.cjs → chunk-6Z42NMP4.cjs} +9 -9
  10. package/dist/{chunk-7VMF6LIC.cjs.map → chunk-6Z42NMP4.cjs.map} +1 -1
  11. package/dist/{chunk-VGMRIXW4.cjs → chunk-7OWJQHHM.cjs} +25 -25
  12. package/dist/{chunk-VGMRIXW4.cjs.map → chunk-7OWJQHHM.cjs.map} +1 -1
  13. package/dist/{chunk-FSX7DDLO.js → chunk-BMRZHFDP.js} +97 -52
  14. package/dist/chunk-BMRZHFDP.js.map +1 -0
  15. package/dist/{chunk-43DJ3GGR.js → chunk-CEVMMYJ5.js} +2 -2
  16. package/dist/{chunk-DCUIT7SI.js → chunk-CIDHX2EW.js} +2 -2
  17. package/dist/{chunk-MKQVDEHI.cjs → chunk-CPRNLW4M.cjs} +13 -16
  18. package/dist/chunk-CPRNLW4M.cjs.map +1 -0
  19. package/dist/{chunk-6JYXGRJ3.cjs → chunk-EAUTJAKV.cjs} +3 -3
  20. package/dist/{chunk-6JYXGRJ3.cjs.map → chunk-EAUTJAKV.cjs.map} +1 -1
  21. package/dist/{chunk-OERK3T7E.js → chunk-ECP5J27K.js} +13 -16
  22. package/dist/chunk-ECP5J27K.js.map +1 -0
  23. package/dist/{chunk-5HRVHEHE.cjs → chunk-EJS22Y4B.cjs} +3 -3
  24. package/dist/{chunk-5HRVHEHE.cjs.map → chunk-EJS22Y4B.cjs.map} +1 -1
  25. package/dist/{chunk-HKLLKNRQ.cjs → chunk-EM4WYYFN.cjs} +3 -3
  26. package/dist/{chunk-HKLLKNRQ.cjs.map → chunk-EM4WYYFN.cjs.map} +1 -1
  27. package/dist/{chunk-Z3OEYDNI.js → chunk-EUQQG5WH.js} +2 -2
  28. package/dist/{chunk-FAGQGGT3.js → chunk-GVLQQGI3.js} +2 -2
  29. package/dist/{chunk-K6VEUJLY.cjs → chunk-I36GOOCM.cjs} +18 -18
  30. package/dist/{chunk-K6VEUJLY.cjs.map → chunk-I36GOOCM.cjs.map} +1 -1
  31. package/dist/{chunk-LXRNFQEI.js → chunk-JJJXVJUW.js} +3 -3
  32. package/dist/{chunk-FFYPSLQV.js → chunk-KUP3CP24.js} +8 -8
  33. package/dist/{chunk-UTOTOWPS.js → chunk-LPSRS5GI.js} +3 -3
  34. package/dist/{chunk-3QBMSZSE.cjs → chunk-NLTNIQG7.cjs} +3 -3
  35. package/dist/{chunk-3QBMSZSE.cjs.map → chunk-NLTNIQG7.cjs.map} +1 -1
  36. package/dist/{chunk-MUMTPMWD.cjs → chunk-NNNMXVHI.cjs} +3 -3
  37. package/dist/{chunk-MUMTPMWD.cjs.map → chunk-NNNMXVHI.cjs.map} +1 -1
  38. package/dist/{chunk-57BVERWD.js → chunk-NODLZFCN.js} +3 -3
  39. package/dist/{chunk-DHOBGYRD.js → chunk-NQ2IY4A2.js} +3 -3
  40. package/dist/{chunk-YHSCUPP6.cjs → chunk-QKCYXFET.cjs} +102 -57
  41. package/dist/chunk-QKCYXFET.cjs.map +1 -0
  42. package/dist/{chunk-SONL2RCW.js → chunk-QVUMYDRE.js} +5 -5
  43. package/dist/{chunk-SJKD3WCV.cjs → chunk-S3IZPWYP.cjs} +5 -5
  44. package/dist/{chunk-SJKD3WCV.cjs.map → chunk-S3IZPWYP.cjs.map} +1 -1
  45. package/dist/{chunk-GRKC4PIX.cjs → chunk-SHGRJX7B.cjs} +3 -3
  46. package/dist/{chunk-GRKC4PIX.cjs.map → chunk-SHGRJX7B.cjs.map} +1 -1
  47. package/dist/{chunk-BPVOQLCA.cjs → chunk-TFCOF5FC.cjs} +2 -2
  48. package/dist/chunk-TFCOF5FC.cjs.map +1 -0
  49. package/dist/{chunk-IJW6YCJB.cjs → chunk-TTFZKWPH.cjs} +5 -5
  50. package/dist/{chunk-IJW6YCJB.cjs.map → chunk-TTFZKWPH.cjs.map} +1 -1
  51. package/dist/{chunk-JO4NDJRA.cjs → chunk-U4B6C7OP.cjs} +6 -6
  52. package/dist/{chunk-JO4NDJRA.cjs.map → chunk-U4B6C7OP.cjs.map} +1 -1
  53. package/dist/{chunk-ADB7QRX5.cjs → chunk-U4MV7P4A.cjs} +5 -5
  54. package/dist/{chunk-ADB7QRX5.cjs.map → chunk-U4MV7P4A.cjs.map} +1 -1
  55. package/dist/{chunk-IBT535UH.js → chunk-UAAQVIZQ.js} +2 -2
  56. package/dist/chunk-UAAQVIZQ.js.map +1 -0
  57. package/dist/{chunk-VPN7AR7T.cjs → chunk-USGEUG2O.cjs} +4 -4
  58. package/dist/{chunk-VPN7AR7T.cjs.map → chunk-USGEUG2O.cjs.map} +1 -1
  59. package/dist/{chunk-TOLNPD7S.js → chunk-VA23PQTA.js} +2 -2
  60. package/dist/{chunk-BKUZF7CW.cjs → chunk-VY7DTPO3.cjs} +21 -15
  61. package/dist/chunk-VY7DTPO3.cjs.map +1 -0
  62. package/dist/{chunk-D2PXPX56.js → chunk-YAZSZFLB.js} +4 -4
  63. package/dist/{chunk-YYA5SWXD.js → chunk-ZBK4KYKJ.js} +2 -2
  64. package/dist/color-picker/index.cjs +3 -3
  65. package/dist/color-picker/index.js +2 -2
  66. package/dist/combobox/index.cjs +3 -3
  67. package/dist/combobox/index.js +2 -2
  68. package/dist/context-menu/index.cjs +4 -4
  69. package/dist/context-menu/index.js +3 -3
  70. package/dist/conversation/index.cjs +5 -5
  71. package/dist/conversation/index.js +4 -4
  72. package/dist/data-grid/index.cjs +10 -10
  73. package/dist/data-grid/index.js +9 -9
  74. package/dist/date-picker/index.cjs +4 -4
  75. package/dist/date-picker/index.d.cts +15 -1
  76. package/dist/date-picker/index.d.ts +15 -1
  77. package/dist/date-picker/index.js +3 -3
  78. package/dist/dropdown/index.cjs +2 -2
  79. package/dist/dropdown/index.d.cts +10 -0
  80. package/dist/dropdown/index.d.ts +10 -0
  81. package/dist/dropdown/index.js +1 -1
  82. package/dist/index.cjs +20 -20
  83. package/dist/index.css +1 -1
  84. package/dist/index.js +19 -19
  85. package/dist/menu/index.cjs +3 -3
  86. package/dist/menu/index.js +2 -2
  87. package/dist/page-layout/index.cjs +5 -5
  88. package/dist/page-layout/index.js +4 -4
  89. package/dist/pagination/index.cjs +4 -4
  90. package/dist/pagination/index.js +3 -3
  91. package/dist/select/index.cjs +3 -3
  92. package/dist/select/index.js +2 -2
  93. package/dist/split-button/index.cjs +4 -4
  94. package/dist/split-button/index.js +3 -3
  95. package/dist/split-chip/index.cjs +3 -3
  96. package/dist/split-chip/index.js +2 -2
  97. package/dist/table/index.cjs +9 -9
  98. package/dist/table/index.js +8 -8
  99. package/dist/tag-input/index.cjs +4 -4
  100. package/dist/tag-input/index.js +3 -3
  101. package/dist/theme-editor/index.cjs +5 -5
  102. package/dist/theme-editor/index.js +4 -4
  103. package/dist/toolbar/index.cjs +4 -4
  104. package/dist/toolbar/index.js +3 -3
  105. package/package.json +1 -1
  106. package/dist/chunk-2WDL2ZVP.js.map +0 -1
  107. package/dist/chunk-BKUZF7CW.cjs.map +0 -1
  108. package/dist/chunk-BPVOQLCA.cjs.map +0 -1
  109. package/dist/chunk-FSX7DDLO.js.map +0 -1
  110. package/dist/chunk-IBT535UH.js.map +0 -1
  111. package/dist/chunk-MKQVDEHI.cjs.map +0 -1
  112. package/dist/chunk-OERK3T7E.js.map +0 -1
  113. package/dist/chunk-YHSCUPP6.cjs.map +0 -1
  114. /package/dist/{chunk-SOS4K7VC.js.map → chunk-45XFUEYG.js.map} +0 -0
  115. /package/dist/{chunk-AWPJH3UB.js.map → chunk-4MURW4H3.js.map} +0 -0
  116. /package/dist/{chunk-43DJ3GGR.js.map → chunk-CEVMMYJ5.js.map} +0 -0
  117. /package/dist/{chunk-DCUIT7SI.js.map → chunk-CIDHX2EW.js.map} +0 -0
  118. /package/dist/{chunk-Z3OEYDNI.js.map → chunk-EUQQG5WH.js.map} +0 -0
  119. /package/dist/{chunk-FAGQGGT3.js.map → chunk-GVLQQGI3.js.map} +0 -0
  120. /package/dist/{chunk-LXRNFQEI.js.map → chunk-JJJXVJUW.js.map} +0 -0
  121. /package/dist/{chunk-FFYPSLQV.js.map → chunk-KUP3CP24.js.map} +0 -0
  122. /package/dist/{chunk-UTOTOWPS.js.map → chunk-LPSRS5GI.js.map} +0 -0
  123. /package/dist/{chunk-57BVERWD.js.map → chunk-NODLZFCN.js.map} +0 -0
  124. /package/dist/{chunk-DHOBGYRD.js.map → chunk-NQ2IY4A2.js.map} +0 -0
  125. /package/dist/{chunk-SONL2RCW.js.map → chunk-QVUMYDRE.js.map} +0 -0
  126. /package/dist/{chunk-TOLNPD7S.js.map → chunk-VA23PQTA.js.map} +0 -0
  127. /package/dist/{chunk-D2PXPX56.js.map → chunk-YAZSZFLB.js.map} +0 -0
  128. /package/dist/{chunk-YYA5SWXD.js.map → chunk-ZBK4KYKJ.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/chunk-IJW6YCJB.cjs","../src/components/TagInput/TagInput.component.tsx"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAgF;AAChF,2CAA4B;AA0PpB,+CAAA;AApPD,IAAM,SAAA,EAAoC,CAAC;AAAA,EAChD,KAAA;AAAA,EAC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AAA;AAEC,EAAA;AAEZ,EAAA;AAAA;AAAA;AAAA;AAIO,oBAAA;AAEA,MAAA;AAKE,sBAAA;AAED,QAAA;AAAC,UAAA;AAAA,UAAA;AAES,YAAA;AACF,YAAA;AACN,YAAA;AACiC,YAAA;AAEhC,YAAA;AAAA,UAAA;AANmB,UAAA;AAQvB,QAAA;AAED,wBAAA;AAAC,UAAA;AAAA,UAAA;AACM,YAAA;AACD,YAAA;AACM,YAAA;AACL,YAAA;AACE,YAAA;AACsB,YAAA;AAC7B,YAAA;AACW,YAAA;AACD,YAAA;AACD,YAAA;AACkB,YAAA;AACK,YAAA;AACP,YAAA;AAII,YAAA;AACN,YAAA;AACR,YAAA;AACI,YAAA;AAGJ,YAAA;AAEb,YAAA;AAEI,UAAA;AAER,QAAA;AAGE,QAAA;AAAC,UAAA;AAAA,UAAA;AACO,YAAA;AACQ,YAAA;AAIJ,YAAA;AAER,YAAA;AAAC,cAAA;AAAA,cAAA;AACW,gBAAA;AACA,gBAAA;AACL,gBAAA;AACgB,gBAAA;AACC,gBAAA;AAErB,gBAAA;AAII,kBAAA;AAAA,kBAAA;AAEW,oBAAA;AACC,oBAAA;AACT,sBAAA;AACU,sBAAA;AAGJ,oBAAA;AACH,oBAAA;AACU,oBAAA;AACA,oBAAA;AACK,oBAAA;AAEnB,oBAAA;AAAA,kBAAA;AAbI,kBAAA;AAeR,gBAAA;AAAA,cAAA;AAEL,YAAA;AAEU,YAAA;AACH,YAAA;AACY,YAAA;AACN,YAAA;AAAA,UAAA;AACjB,QAAA;AAEJ,MAAA;AAGE,MAAA;AAMC,MAAA;AACc,wBAAA;AACZ,QAAA;AACH,MAAA;AAEJ,IAAA;AAAA,EAAA;AAEJ;AAEuB;AD9EoB;AACA;AACA;AACA","file":"/home/runner/work/eidos-ui/eidos-ui/dist/chunk-IJW6YCJB.cjs","sourcesContent":[null,"import React, { useState, useId, useRef, useCallback, useMemo, useEffect } from 'react';\nimport { CircleAlert } from 'lucide-react';\nimport { Chip } from '../Chip/Chip.component';\nimport { Dropdown } from '../Dropdown/Dropdown.component';\nimport type { TagInputProps } from './TagInput.types';\nimport './TagInput.scss';\n\nexport const TagInput: React.FC<TagInputProps> = ({\n value,\n defaultValue = [],\n onChange,\n placeholder = 'Add tag…',\n size = 'md',\n disabled = false,\n label,\n error,\n hint,\n allowDuplicates = false,\n maxTags,\n separators = ['Enter', ',', 'Tab'],\n validate,\n className = '',\n fullWidth = false,\n suggestions,\n onSearch,\n suggestionsEmptyText = 'No matches',\n}) => {\n const generatedId = useId();\n const inputId = `tag-input-${generatedId}`;\n const inputRef = useRef<HTMLInputElement>(null);\n\n /** Entire component wrapper - used for click-outside detection on the suggestions dropdown */\n const containerRef = useRef<HTMLDivElement>(null);\n\n /** The field wrapper - passed to Dropdown as externalTriggerRef for width/anchoring */\n const fieldRef = useRef<HTMLDivElement>(null);\n\n /** The 0-height span that IS the Dropdown trigger element - programmatically clicked to open */\n\n const hasSuggestions = suggestions !== undefined;\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n // Read synchronously by the document `mousedown` listener and the key\n // handlers, where a value captured at render would be stale. Kept in step by\n // an effect rather than assigned at every call site, which is how the two\n // used to drift apart.\n const isSuggestionsOpenRef = useRef(isSuggestionsOpen);\n useEffect(() => {\n isSuggestionsOpenRef.current = isSuggestionsOpen;\n }, [isSuggestionsOpen]);\n const [focusedSuggestionIndex, setFocusedSuggestionIndex] = useState(-1);\n\n const isControlled = value !== undefined;\n\n const [internalTags, setInternalTags] = useState<string[]>(defaultValue);\n const [inputValue, setInputValue] = useState('');\n const [isFocused, setIsFocused] = useState(false);\n const [validationError, setValidationError] = useState<string | null>(null);\n\n const tags = isControlled ? (value as string[]) : internalTags;\n\n const updateTags = useCallback(\n (newTags: string[]) => {\n if (!isControlled) {\n setInternalTags(newTags);\n }\n onChange?.(newTags);\n },\n [isControlled, onChange],\n );\n\n const addTag = useCallback(\n (rawTag: string) => {\n const tag = rawTag.trim();\n\n if (!tag) return;\n\n if (!allowDuplicates && tags.includes(tag)) return;\n\n if (maxTags !== undefined && tags.length >= maxTags) return;\n\n if (validate) {\n const result = validate(tag);\n if (result === false) return;\n if (typeof result === 'string') {\n setValidationError(result);\n return;\n }\n // result === true → valid, fall through\n }\n\n setValidationError(null);\n updateTags([...tags, tag]);\n setInputValue('');\n },\n [tags, allowDuplicates, maxTags, validate, updateTags],\n );\n\n const removeTag = useCallback(\n (index: number) => {\n updateTags(tags.filter((_, i) => i !== index));\n },\n [tags, updateTags],\n );\n\n // ─── Suggestions dropdown (autocomplete) ───────────────────────────────────\n\n const filteredSuggestions = useMemo<string[]>(() => {\n if (!suggestions) return [];\n const query = inputValue.trim().toLowerCase();\n return suggestions.filter((suggestion) => {\n if (!allowDuplicates && tags.includes(suggestion)) return false;\n if (!query) return true;\n return suggestion.toLowerCase().includes(query);\n });\n }, [suggestions, inputValue, tags, allowDuplicates]);\n\n useEffect(() => {\n setFocusedSuggestionIndex(-1);\n }, [filteredSuggestions]);\n\n const openSuggestions = useCallback(() => {\n if (isSuggestionsOpenRef.current || disabled || !hasSuggestions) return;\n // This used to synthesise a click on a hidden zero-height `span` so that it\n // would bubble to the dropdown's trigger wrapper - the only way in, while\n // the overlay owned its open state privately.\n isSuggestionsOpenRef.current = true;\n setIsSuggestionsOpen(true);\n }, [disabled, hasSuggestions]);\n\n const closeSuggestions = useCallback(() => {\n isSuggestionsOpenRef.current = false;\n setIsSuggestionsOpen(false);\n setFocusedSuggestionIndex(-1);\n }, []);\n\n const selectSuggestion = useCallback(\n (suggestion: string) => {\n addTag(suggestion);\n closeSuggestions();\n inputRef.current?.focus();\n },\n [addTag, closeSuggestions],\n );\n\n // Click-outside detection for the suggestions dropdown.\n useEffect(() => {\n if (!hasSuggestions) return;\n\n const handleMouseDown = (e: MouseEvent) => {\n if (!isSuggestionsOpenRef.current) return;\n if (e.defaultPrevented) return; // click inside the portal-rendered listbox\n if (containerRef.current?.contains(e.target as Node)) return;\n closeSuggestions();\n };\n\n document.addEventListener('mousedown', handleMouseDown);\n return () => document.removeEventListener('mousedown', handleMouseDown);\n }, [hasSuggestions, closeSuggestions]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (hasSuggestions && isSuggestionsOpenRef.current && filteredSuggestions.length > 0) {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setFocusedSuggestionIndex((prev) => (prev + 1 < filteredSuggestions.length ? prev + 1 : 0));\n return;\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n setFocusedSuggestionIndex((prev) => (prev > 0 ? prev - 1 : filteredSuggestions.length - 1));\n return;\n }\n if (e.key === 'Enter' && focusedSuggestionIndex >= 0) {\n e.preventDefault();\n selectSuggestion(filteredSuggestions[focusedSuggestionIndex]);\n return;\n }\n if (e.key === 'Escape') {\n e.preventDefault();\n closeSuggestions();\n return;\n }\n }\n\n if (separators.includes(e.key)) {\n e.preventDefault();\n addTag(inputValue);\n return;\n }\n\n if (e.key === 'Backspace' && inputValue === '' && tags.length > 0) {\n e.preventDefault();\n removeTag(tags.length - 1);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const query = e.target.value;\n setInputValue(query);\n if (validationError) {\n setValidationError(null);\n }\n onSearch?.(query);\n if (hasSuggestions && !isSuggestionsOpenRef.current) openSuggestions();\n };\n\n const handleInputFocus = () => {\n setIsFocused(true);\n if (hasSuggestions) openSuggestions();\n };\n\n const handleFieldClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // Don't steal focus from interactive child elements\n if ((e.target as HTMLElement).closest('button, input')) return;\n if (!disabled) {\n inputRef.current?.focus();\n }\n };\n\n const displayError = validationError ?? error;\n const hasError = !!displayError;\n const errorId = `${inputId}-error`;\n const hintId = `${inputId}-hint`;\n\n const containerClasses = [\n 'eidos-tag-input',\n hasError && 'eidos-tag-input--error',\n disabled && 'eidos-tag-input--disabled',\n fullWidth && 'eidos-tag-input--full-width',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const fieldClasses = [\n 'eidos-tag-input-field',\n `eidos-tag-input-field--${size}`,\n isFocused && 'eidos-tag-input-field--focused',\n hasError && 'eidos-tag-input-field--error',\n disabled && 'eidos-tag-input-field--disabled',\n ]\n .filter(Boolean)\n .join(' ');\n\n const uid = generatedId;\n\n return (\n // No ARIA on this wrapper - it has no role, so `aria-expanded` and\n // `aria-haspopup` were invalid here. Same fix as `Combobox`: they belong\n // on the input, which is the combobox.\n <div className={containerClasses} ref={containerRef}>\n {label && (\n <label htmlFor={inputId} className=\"eidos-tag-input-label\">\n {label}\n </label>\n )}\n\n <div className={fieldClasses} onClick={handleFieldClick} ref={fieldRef}>\n {tags.map((tag, index) => (\n <Chip\n key={`${tag}-${index}`}\n variant=\"filled\"\n color=\"primary\"\n size={size}\n onRemove={disabled ? undefined : () => removeTag(index)}\n >\n {tag}\n </Chip>\n ))}\n\n <input\n ref={inputRef}\n id={inputId}\n className=\"eidos-tag-input-input\"\n type=\"text\"\n value={inputValue}\n placeholder={tags.length === 0 ? placeholder : undefined}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onChange={handleInputChange}\n onFocus={handleInputFocus}\n onBlur={() => setIsFocused(false)}\n aria-label={label ? undefined : 'Tag input'}\n aria-invalid={hasError ? true : undefined}\n // The ternary is deliberate, not a bug: the hint is unmounted when\n // an error shows (see the render below), so describing the field\n // with it would point at an element that is not there.\n aria-describedby={hasError ? errorId : hint ? hintId : undefined}\n role={hasSuggestions ? 'combobox' : undefined}\n aria-expanded={hasSuggestions ? isSuggestionsOpen : undefined}\n aria-autocomplete={hasSuggestions ? 'list' : undefined}\n // Only while the list is actually rendered - `aria-controls` must\n // name an element that exists.\n aria-controls={hasSuggestions && isSuggestionsOpen ? `${uid}-tag-suggestions` : undefined}\n aria-activedescendant={\n hasSuggestions && focusedSuggestionIndex >= 0\n ? `${uid}-tag-suggestion-${focusedSuggestionIndex}`\n : undefined\n }\n />\n\n {hasSuggestions && (\n <Dropdown\n open={isSuggestionsOpen}\n onOpenChange={setIsSuggestionsOpen}\n // Positioning is anchored to the field via `triggerRef` below; this\n // span is only here because a trigger is required. It used to carry\n // a ref purely so `openSuggestions` could click it.\n trigger={<span className=\"eidos-tag-input-dropdown-anchor\" aria-hidden=\"true\" />}\n content={\n <div\n id={`${uid}-tag-suggestions`}\n className=\"eidos-tag-input-suggestions\"\n role=\"listbox\"\n aria-label={label ?? 'Suggestions'}\n onMouseDown={(e) => e.preventDefault()}\n >\n {filteredSuggestions.length === 0 ? (\n <div className=\"eidos-tag-input-suggestions-empty\">{suggestionsEmptyText}</div>\n ) : (\n filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion}\n id={`${uid}-tag-suggestion-${index}`}\n className={[\n 'eidos-tag-input-suggestion',\n index === focusedSuggestionIndex && 'eidos-tag-input-suggestion--focused',\n ]\n .filter(Boolean)\n .join(' ')}\n role=\"option\"\n aria-selected={index === focusedSuggestionIndex}\n onClick={() => selectSuggestion(suggestion)}\n onMouseEnter={() => setFocusedSuggestionIndex(index)}\n >\n {suggestion}\n </div>\n ))\n )}\n </div>\n }\n triggerRef={fieldRef as React.RefObject<HTMLElement | null>}\n autoWidth\n closeOnClickOutside={false}\n closeOnEscape={false}\n />\n )}\n </div>\n\n {hint && !hasError && (\n <p className=\"eidos-tag-input-hint\" id={hintId}>\n {hint}\n </p>\n )}\n\n {hasError && (\n <p className=\"eidos-tag-input-error-message\" id={errorId} role=\"alert\">\n <CircleAlert />\n {displayError}\n </p>\n )}\n </div>\n );\n};\n\nTagInput.displayName = 'TagInput';\n"]}
1
+ {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/chunk-TTFZKWPH.cjs","../src/components/TagInput/TagInput.component.tsx"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACPA,8BAAgF;AAChF,2CAA4B;AA0PpB,+CAAA;AApPD,IAAM,SAAA,EAAoC,CAAC;AAAA,EAChD,KAAA;A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AAGH,EAAA;AAEC,EAAA;AAEZ,EAAA;AAAA;AAAA;AAAA;AAIO,oBAAA;AAEA,MAAA;AAKE,sBAAA;AAED,QAAA;AAAC,UAAA;AAAA,UAAA;AAES,YAAA;AACF,YAAA;AACN,YAAA;AACiC,YAAA;AAEhC,YAAA;AAAA,UAAA;AANmB,UAAA;AAQvB,QAAA;AAED,wBAAA;AAAC,UAAA;AAAA,UAAA;AACM,YAAA;AACD,YAAA;AACM,YAAA;AACL,YAAA;AACE,YAAA;AACsB,YAAA;AAC7B,YAAA;AACW,YAAA;AACD,YAAA;AACD,YAAA;AACkB,YAAA;AACK,YAAA;AACP,YAAA;AAII,YAAA;AACN,YAAA;AACR,YAAA;AACI,YAAA;AAGJ,YAAA;AAEb,YAAA;AAEI,UAAA;AAER,QAAA;AAGE,QAAA;AAAC,UAAA;AAAA,UAAA;AACO,YAAA;AACQ,YAAA;AAIJ,YAAA;AAER,YAAA;AAAC,cAAA;AAAA,cAAA;AACW,gBAAA;AACA,gBAAA;AACL,gBAAA;AACgB,gBAAA;AACC,gBAAA;AAErB,gBAAA;AAII,kBAAA;AAAA,kBAAA;AAEW,oBAAA;AACC,oBAAA;AACT,sBAAA;AACU,sBAAA;AAGJ,oBAAA;AACH,oBAAA;AACU,oBAAA;AACA,oBAAA;AACK,oBAAA;AAEnB,oBAAA;AAAA,kBAAA;AAbI,kBAAA;AAeR,gBAAA;AAAA,cAAA;AAEL,YAAA;AAEU,YAAA;AACH,YAAA;AACY,YAAA;AACN,YAAA;AAAA,UAAA;AACjB,QAAA;AAEJ,MAAA;AAGE,MAAA;AAMC,MAAA;AACc,wBAAA;AACZ,QAAA;AACH,MAAA;AAEJ,IAAA;AAAA,EAAA;AAEJ;AAEuB;AD9EoB;AACA;AACA;AACA","file":"/home/runner/work/eidos-ui/eidos-ui/dist/chunk-TTFZKWPH.cjs","sourcesContent":[null,"import React, { useState, useId, useRef, useCallback, useMemo, useEffect } from 'react';\nimport { CircleAlert } from 'lucide-react';\nimport { Chip } from '../Chip/Chip.component';\nimport { Dropdown } from '../Dropdown/Dropdown.component';\nimport type { TagInputProps } from './TagInput.types';\nimport './TagInput.scss';\n\nexport const TagInput: React.FC<TagInputProps> = ({\n value,\n defaultValue = [],\n onChange,\n placeholder = 'Add tag…',\n size = 'md',\n disabled = false,\n label,\n error,\n hint,\n allowDuplicates = false,\n maxTags,\n separators = ['Enter', ',', 'Tab'],\n validate,\n className = '',\n fullWidth = false,\n suggestions,\n onSearch,\n suggestionsEmptyText = 'No matches',\n}) => {\n const generatedId = useId();\n const inputId = `tag-input-${generatedId}`;\n const inputRef = useRef<HTMLInputElement>(null);\n\n /** Entire component wrapper - used for click-outside detection on the suggestions dropdown */\n const containerRef = useRef<HTMLDivElement>(null);\n\n /** The field wrapper - passed to Dropdown as externalTriggerRef for width/anchoring */\n const fieldRef = useRef<HTMLDivElement>(null);\n\n /** The 0-height span that IS the Dropdown trigger element - programmatically clicked to open */\n\n const hasSuggestions = suggestions !== undefined;\n const [isSuggestionsOpen, setIsSuggestionsOpen] = useState(false);\n // Read synchronously by the document `mousedown` listener and the key\n // handlers, where a value captured at render would be stale. Kept in step by\n // an effect rather than assigned at every call site, which is how the two\n // used to drift apart.\n const isSuggestionsOpenRef = useRef(isSuggestionsOpen);\n useEffect(() => {\n isSuggestionsOpenRef.current = isSuggestionsOpen;\n }, [isSuggestionsOpen]);\n const [focusedSuggestionIndex, setFocusedSuggestionIndex] = useState(-1);\n\n const isControlled = value !== undefined;\n\n const [internalTags, setInternalTags] = useState<string[]>(defaultValue);\n const [inputValue, setInputValue] = useState('');\n const [isFocused, setIsFocused] = useState(false);\n const [validationError, setValidationError] = useState<string | null>(null);\n\n const tags = isControlled ? (value as string[]) : internalTags;\n\n const updateTags = useCallback(\n (newTags: string[]) => {\n if (!isControlled) {\n setInternalTags(newTags);\n }\n onChange?.(newTags);\n },\n [isControlled, onChange],\n );\n\n const addTag = useCallback(\n (rawTag: string) => {\n const tag = rawTag.trim();\n\n if (!tag) return;\n\n if (!allowDuplicates && tags.includes(tag)) return;\n\n if (maxTags !== undefined && tags.length >= maxTags) return;\n\n if (validate) {\n const result = validate(tag);\n if (result === false) return;\n if (typeof result === 'string') {\n setValidationError(result);\n return;\n }\n // result === true → valid, fall through\n }\n\n setValidationError(null);\n updateTags([...tags, tag]);\n setInputValue('');\n },\n [tags, allowDuplicates, maxTags, validate, updateTags],\n );\n\n const removeTag = useCallback(\n (index: number) => {\n updateTags(tags.filter((_, i) => i !== index));\n },\n [tags, updateTags],\n );\n\n // ─── Suggestions dropdown (autocomplete) ───────────────────────────────────\n\n const filteredSuggestions = useMemo<string[]>(() => {\n if (!suggestions) return [];\n const query = inputValue.trim().toLowerCase();\n return suggestions.filter((suggestion) => {\n if (!allowDuplicates && tags.includes(suggestion)) return false;\n if (!query) return true;\n return suggestion.toLowerCase().includes(query);\n });\n }, [suggestions, inputValue, tags, allowDuplicates]);\n\n useEffect(() => {\n setFocusedSuggestionIndex(-1);\n }, [filteredSuggestions]);\n\n const openSuggestions = useCallback(() => {\n if (isSuggestionsOpenRef.current || disabled || !hasSuggestions) return;\n // This used to synthesise a click on a hidden zero-height `span` so that it\n // would bubble to the dropdown's trigger wrapper - the only way in, while\n // the overlay owned its open state privately.\n isSuggestionsOpenRef.current = true;\n setIsSuggestionsOpen(true);\n }, [disabled, hasSuggestions]);\n\n const closeSuggestions = useCallback(() => {\n isSuggestionsOpenRef.current = false;\n setIsSuggestionsOpen(false);\n setFocusedSuggestionIndex(-1);\n }, []);\n\n const selectSuggestion = useCallback(\n (suggestion: string) => {\n addTag(suggestion);\n closeSuggestions();\n inputRef.current?.focus();\n },\n [addTag, closeSuggestions],\n );\n\n // Click-outside detection for the suggestions dropdown.\n useEffect(() => {\n if (!hasSuggestions) return;\n\n const handleMouseDown = (e: MouseEvent) => {\n if (!isSuggestionsOpenRef.current) return;\n if (e.defaultPrevented) return; // click inside the portal-rendered listbox\n if (containerRef.current?.contains(e.target as Node)) return;\n closeSuggestions();\n };\n\n document.addEventListener('mousedown', handleMouseDown);\n return () => document.removeEventListener('mousedown', handleMouseDown);\n }, [hasSuggestions, closeSuggestions]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (hasSuggestions && isSuggestionsOpenRef.current && filteredSuggestions.length > 0) {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setFocusedSuggestionIndex((prev) => (prev + 1 < filteredSuggestions.length ? prev + 1 : 0));\n return;\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n setFocusedSuggestionIndex((prev) => (prev > 0 ? prev - 1 : filteredSuggestions.length - 1));\n return;\n }\n if (e.key === 'Enter' && focusedSuggestionIndex >= 0) {\n e.preventDefault();\n selectSuggestion(filteredSuggestions[focusedSuggestionIndex]);\n return;\n }\n if (e.key === 'Escape') {\n e.preventDefault();\n closeSuggestions();\n return;\n }\n }\n\n if (separators.includes(e.key)) {\n e.preventDefault();\n addTag(inputValue);\n return;\n }\n\n if (e.key === 'Backspace' && inputValue === '' && tags.length > 0) {\n e.preventDefault();\n removeTag(tags.length - 1);\n }\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const query = e.target.value;\n setInputValue(query);\n if (validationError) {\n setValidationError(null);\n }\n onSearch?.(query);\n if (hasSuggestions && !isSuggestionsOpenRef.current) openSuggestions();\n };\n\n const handleInputFocus = () => {\n setIsFocused(true);\n if (hasSuggestions) openSuggestions();\n };\n\n const handleFieldClick = (e: React.MouseEvent<HTMLDivElement>) => {\n // Don't steal focus from interactive child elements\n if ((e.target as HTMLElement).closest('button, input')) return;\n if (!disabled) {\n inputRef.current?.focus();\n }\n };\n\n const displayError = validationError ?? error;\n const hasError = !!displayError;\n const errorId = `${inputId}-error`;\n const hintId = `${inputId}-hint`;\n\n const containerClasses = [\n 'eidos-tag-input',\n hasError && 'eidos-tag-input--error',\n disabled && 'eidos-tag-input--disabled',\n fullWidth && 'eidos-tag-input--full-width',\n className,\n ]\n .filter(Boolean)\n .join(' ');\n\n const fieldClasses = [\n 'eidos-tag-input-field',\n `eidos-tag-input-field--${size}`,\n isFocused && 'eidos-tag-input-field--focused',\n hasError && 'eidos-tag-input-field--error',\n disabled && 'eidos-tag-input-field--disabled',\n ]\n .filter(Boolean)\n .join(' ');\n\n const uid = generatedId;\n\n return (\n // No ARIA on this wrapper - it has no role, so `aria-expanded` and\n // `aria-haspopup` were invalid here. Same fix as `Combobox`: they belong\n // on the input, which is the combobox.\n <div className={containerClasses} ref={containerRef}>\n {label && (\n <label htmlFor={inputId} className=\"eidos-tag-input-label\">\n {label}\n </label>\n )}\n\n <div className={fieldClasses} onClick={handleFieldClick} ref={fieldRef}>\n {tags.map((tag, index) => (\n <Chip\n key={`${tag}-${index}`}\n variant=\"filled\"\n color=\"primary\"\n size={size}\n onRemove={disabled ? undefined : () => removeTag(index)}\n >\n {tag}\n </Chip>\n ))}\n\n <input\n ref={inputRef}\n id={inputId}\n className=\"eidos-tag-input-input\"\n type=\"text\"\n value={inputValue}\n placeholder={tags.length === 0 ? placeholder : undefined}\n disabled={disabled}\n onKeyDown={handleKeyDown}\n onChange={handleInputChange}\n onFocus={handleInputFocus}\n onBlur={() => setIsFocused(false)}\n aria-label={label ? undefined : 'Tag input'}\n aria-invalid={hasError ? true : undefined}\n // The ternary is deliberate, not a bug: the hint is unmounted when\n // an error shows (see the render below), so describing the field\n // with it would point at an element that is not there.\n aria-describedby={hasError ? errorId : hint ? hintId : undefined}\n role={hasSuggestions ? 'combobox' : undefined}\n aria-expanded={hasSuggestions ? isSuggestionsOpen : undefined}\n aria-autocomplete={hasSuggestions ? 'list' : undefined}\n // Only while the list is actually rendered - `aria-controls` must\n // name an element that exists.\n aria-controls={hasSuggestions && isSuggestionsOpen ? `${uid}-tag-suggestions` : undefined}\n aria-activedescendant={\n hasSuggestions && focusedSuggestionIndex >= 0\n ? `${uid}-tag-suggestion-${focusedSuggestionIndex}`\n : undefined\n }\n />\n\n {hasSuggestions && (\n <Dropdown\n open={isSuggestionsOpen}\n onOpenChange={setIsSuggestionsOpen}\n // Positioning is anchored to the field via `triggerRef` below; this\n // span is only here because a trigger is required. It used to carry\n // a ref purely so `openSuggestions` could click it.\n trigger={<span className=\"eidos-tag-input-dropdown-anchor\" aria-hidden=\"true\" />}\n content={\n <div\n id={`${uid}-tag-suggestions`}\n className=\"eidos-tag-input-suggestions\"\n role=\"listbox\"\n aria-label={label ?? 'Suggestions'}\n onMouseDown={(e) => e.preventDefault()}\n >\n {filteredSuggestions.length === 0 ? (\n <div className=\"eidos-tag-input-suggestions-empty\">{suggestionsEmptyText}</div>\n ) : (\n filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion}\n id={`${uid}-tag-suggestion-${index}`}\n className={[\n 'eidos-tag-input-suggestion',\n index === focusedSuggestionIndex && 'eidos-tag-input-suggestion--focused',\n ]\n .filter(Boolean)\n .join(' ')}\n role=\"option\"\n aria-selected={index === focusedSuggestionIndex}\n onClick={() => selectSuggestion(suggestion)}\n onMouseEnter={() => setFocusedSuggestionIndex(index)}\n >\n {suggestion}\n </div>\n ))\n )}\n </div>\n }\n triggerRef={fieldRef as React.RefObject<HTMLElement | null>}\n autoWidth\n closeOnClickOutside={false}\n closeOnEscape={false}\n />\n )}\n </div>\n\n {hint && !hasError && (\n <p className=\"eidos-tag-input-hint\" id={hintId}>\n {hint}\n </p>\n )}\n\n {hasError && (\n <p className=\"eidos-tag-input-error-message\" id={errorId} role=\"alert\">\n <CircleAlert />\n {displayError}\n </p>\n )}\n </div>\n );\n};\n\nTagInput.displayName = 'TagInput';\n"]}
@@ -26,13 +26,13 @@ var _chunkOZZHOEN5cjs = require('./chunk-OZZHOEN5.cjs');
26
26
  var _chunkE7BFBU6Kcjs = require('./chunk-E7BFBU6K.cjs');
27
27
 
28
28
 
29
- var _chunkBKUZF7CWcjs = require('./chunk-BKUZF7CW.cjs');
29
+ var _chunkVY7DTPO3cjs = require('./chunk-VY7DTPO3.cjs');
30
30
 
31
31
 
32
32
  var _chunkV5RS3JZNcjs = require('./chunk-V5RS3JZN.cjs');
33
33
 
34
34
 
35
- var _chunkSJPCBRKRcjs = require('./chunk-SJPCBRKR.cjs');
35
+ var _chunk5YTPZN6Xcjs = require('./chunk-5YTPZN6X.cjs');
36
36
 
37
37
 
38
38
  var _chunkYWXS4IPHcjs = require('./chunk-YWXS4IPH.cjs');
@@ -176,7 +176,7 @@ var FontRow = ({
176
176
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row eidos-theme-editor-row--wide", children: [
177
177
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label", children: label }),
178
178
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-theme-editor-row__control", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
179
- _chunkBKUZF7CWcjs.Select,
179
+ _chunkVY7DTPO3cjs.Select,
180
180
  {
181
181
  options: selectOptions,
182
182
  value,
@@ -392,7 +392,7 @@ var ThemeEditor = ({
392
392
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "eidos-theme-editor-row", children: [
393
393
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "eidos-theme-editor-row__label", children: COLOR_LABELS[key] }),
394
394
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
395
- _chunkSJPCBRKRcjs.ColorPicker,
395
+ _chunk5YTPZN6Xcjs.ColorPicker,
396
396
  {
397
397
  value: base,
398
398
  onChange: (hex) => setColor(key, hex),
@@ -401,7 +401,7 @@ var ThemeEditor = ({
401
401
  }
402
402
  ),
403
403
  separateDark && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
404
- _chunkSJPCBRKRcjs.ColorPicker,
404
+ _chunk5YTPZN6Xcjs.ColorPicker,
405
405
  {
406
406
  value: darkBase,
407
407
  onChange: (hex) => setDarkColor(key, hex),
@@ -528,4 +528,4 @@ ThemeEditor.displayName = "ThemeEditor";
528
528
 
529
529
 
530
530
  exports.ThemeEditor = ThemeEditor;
531
- //# sourceMappingURL=chunk-JO4NDJRA.cjs.map
531
+ //# sourceMappingURL=chunk-U4B6C7OP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/chunk-JO4NDJRA.cjs","../src/components/ThemeEditor/ThemeEditor.component.tsx"],"names":["ratio","grade"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;AC9CA,8BAAqF;AACrF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,2CACK;AA0RD,+CAAA;AA/ON,IAAM,aAAA,EAAoD;AAAA,EACxD,KAAA,EAAO,gCAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,IAAM,eAAA,EAA0D;AAAA,EAC9D,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,QAAQ,CAAA;AAAA,EACjC,EAAE,KAAA,EAAO,MAAA,EAAQ,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/B,EAAE,KAAA,EAAO,QAAA,EAAU,KAAA,EAAO,SAAS;AACrC,CAAA;AAGA,IAAM,eAAA,EAAiB,GAAA;AAEvB,IAAM,aAAA,EAA8C;AAAA,EAClD,OAAA,EAAS,SAAA;AAAA,EACT,SAAA,EAAW,WAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,SAAA;AAAA,EACT,IAAA,EAAM,M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ACO,YAAA;AAC0B,YAAA;AACK,YAAA;AAC/B,YAAA;AACO,YAAA;AACuD,YAAA;AAElE,cAAA;AACA,8BAAA;AAAkC,YAAA;AACpC,UAAA;AAAA,QAAA;AACF,wBAAA;AAEA,UAAA;AAAC,UAAA;AAAA,YAAA;AACO,YAAA;AAC0B,YAAA;AACa,YAAA;AACzC,YAAA;AACS,YAAA;AACuD,YAAA;AAElE,cAAA;AACA,8BAAA;AAAiC,YAAA;AACnC,UAAA;AAAA,QAAA;AACF,wBAAA;AAGE,0BAAA;AAAqD,0BAAA;AAEnD,YAAA;AAAC,YAAA;AAAA,cAAA;AACiC,cAAA;AAC3B,cAAA;AACA,cAAA;AACC,cAAA;AACG,cAAA;AACC,cAAA;AACL,cAAA;AACgE,YAAA;AAAA,UAAA;AAEzE,QAAA;AACF,MAAA;AACF,IAAA;AACF,IAAA;AAKG,MAAA;AAGC,MAAA;AAGA,QAAA;AAAC,QAAA;AAAA,UAAA;AACS,UAAA;AACkB,UAAA;AACjB,UAAA;AACD,UAAA;AAEa,QAAA;AAAA,MAAA;AACvB,IAAA;AAEJ,EAAA;AAIR;AAEA;AD1MA;AACA;AACA;AACA","file":"/home/runner/work/eidos-ui/eidos-ui/dist/chunk-JO4NDJRA.cjs","sourcesContent":[null,"import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport {\n Check,\n CircleCheck,\n CircleX,\n Clipboard,\n RotateCcw,\n TriangleAlert,\n Upload,\n} from 'lucide-react';\nimport { Alert } from '../Alert';\nimport { Button, IconButton } from '../Button';\nimport { Card } from '../Card';\nimport { ColorPicker } from '../ColorPicker';\nimport { SegmentedControl } from '../SegmentedControl';\nimport { Select } from '../Select';\nimport { Slider } from '../Slider';\nimport { Switch } from '../Switch';\nimport { Tooltip } from '../Tooltip';\nimport { useTheme } from '../ThemeProvider';\nimport type {\n ColorScheme,\n ResolvedColorScheme,\n ThemeColorKey,\n ThemeFontOption,\n} from '../ThemeProvider';\nimport {\n THEME_COLOR_KEYS,\n FONT_SCALE_MAX,\n FONT_SCALE_MIN,\n defaultTheme,\n} from '../ThemeProvider/ThemeProvider.tokens';\nimport {\n CONTRAST_DARK,\n CONTRAST_LIGHT,\n DARK_SURFACE,\n contrastRatio,\n pickContrast,\n} from '../ThemeProvider/ThemeProvider.color';\nimport {\n FONT_ACCEPT,\n isFontStackAvailable,\n registerFontFile,\n subscribeToFontLoads,\n toFontStack,\n} from '../ThemeProvider/ThemeProvider.fonts';\nimport type { ThemeEditorProps } from './ThemeEditor.types';\n\n/**\n * The page surface each scheme's diagnostics are measured against - the\n * `--surface` token's value in that scheme.\n */\nconst PAGE_SURFACE: Record<ResolvedColorScheme, string> = {\n light: CONTRAST_LIGHT,\n dark: DARK_SURFACE,\n};\n\nconst SCHEME_OPTIONS: { value: ColorScheme; label: string }[] = [\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n { value: 'system', label: 'System' },\n];\n\n/** Below this, a fill is effectively invisible against the page behind it. */\nconst EDGE_MIN_RATIO = 1.5;\n\nconst COLOR_LABELS: Record<ThemeColorKey, string> = {\n primary: 'Primary',\n secondary: 'Secondary',\n success: 'Success',\n danger: 'Danger',\n warning: 'Warning',\n info: 'Info',\n hyperlink: 'Hyperlink',\n};\n\n/** `hyperlink` is only ever text on a surface, so it is graded differently. */\nconst isFill = (key: ThemeColorKey): boolean => key !== 'hyperlink';\n\n/**\n * Built-in stacks, deliberately limited to fonts that can be relied on.\n *\n * A dropdown implies its entries are available, but a font stack is only a list\n * of *names* - nothing here can install a font. So the list is restricted to\n * generic families (guaranteed by CSS), `system-ui` (whatever the OS provides),\n * and the handful of genuinely web-safe faces. Fonts like Inter, which are not\n * installed anywhere by default, were removed: offering one is offering a\n * choice that silently does nothing on most machines.\n *\n * The preset is included because it is the shipped default and therefore has to\n * be representable - and note that `eidos-ui` does not ship the Plus Jakarta\n * Sans file either, so it renders only where the consumer provides it. That is\n * exactly why unavailable options are labelled as such.\n *\n * Anything beyond this belongs to the consuming app, via `fontOptions`.\n */\nconst FONT_STACKS: ThemeFontOption[] = [\n // Taken from the preset rather than retyped, so the shipped default always\n // matches an option exactly. A hand-copied shorter stack did not match, and\n // the row fell back to showing a synthetic \"custom\" entry instead of the\n // name of the font actually in use.\n { label: 'Plus Jakarta Sans (theme default)', value: defaultTheme.typography.fontFamily! },\n { label: 'System UI', value: \"system-ui, -apple-system, 'Segoe UI', sans-serif\" },\n { label: 'Helvetica / Arial', value: 'Helvetica, Arial, sans-serif' },\n { label: 'Georgia', value: \"Georgia, 'Times New Roman', serif\" },\n { label: 'Sans-serif (generic)', value: 'sans-serif' },\n { label: 'Serif (generic)', value: 'serif' },\n];\n\nconst MONO_STACKS: ThemeFontOption[] = [\n { label: 'JetBrains Mono (theme default)', value: defaultTheme.typography.monoFamily! },\n { label: 'Menlo / Consolas', value: 'Menlo, Consolas, monospace' },\n { label: 'Courier New', value: \"'Courier New', Courier, monospace\" },\n { label: 'Monospace (generic)', value: 'monospace' },\n];\n\ntype Grade = 'aa' | 'aa-large' | 'fail';\n\nconst gradeFor = (ratio: number): Grade => (ratio >= 4.5 ? 'aa' : ratio >= 3 ? 'aa-large' : 'fail');\n\n/** Spelled out for the middle grade, which is the one that misleads. */\nconst GRADE_CAVEAT: Partial<Record<Grade, string>> = {\n 'aa-large':\n ' WCAG AA needs 4.5:1 for normal text and allows 3:1 only at 24px or larger - button and label text here is around 12px, so this does not pass.',\n fail: ' Below 3:1, which fails WCAG AA at every text size.',\n};\n\n/**\n * Severity is carried by an icon and the label text, not by colour.\n *\n * These badges cannot use `Pill`, or any themed `--x-color`: the theme being\n * edited also styles this editor, so a washed-out `success` colour would render\n * the \"passes AA\" badge illegible at precisely the moment it is reporting that\n * a colour is illegible. The badge styling comes from the gray ramp, which is\n * deliberately not themeable.\n *\n * Not relying on colour alone also satisfies WCAG 1.4.1 (Use of Colour).\n */\nconst GRADE_BADGE: Record<\n Grade,\n { label: string; icon: React.ComponentType<{ className?: string }> }\n> = {\n aa: { label: 'AA', icon: CircleCheck },\n // Named for what it means in practice, not just for the threshold it clears.\n // WCAG's relaxed 3:1 tier applies only to text at 24px (or 18.7px bold) and\n // above, and nothing in this library is that large - `--font-size-sm` is\n // ~12.25px at the default root size. A bare \"AA large only\" reads as a pass\n // when for every component here it is a fail.\n 'aa-large': { label: 'Too low for body text', icon: TriangleAlert },\n fail: { label: 'Fails AA', icon: CircleX },\n};\n\ninterface Diagnostic {\n grade: Grade;\n ratio: number;\n /** What the ratio describes, for the tooltip. */\n detail: string;\n /** Set when the fill is too close to the page surface to be seen. */\n edgeWarning?: string;\n}\n\nconst diagnose = (\n key: ThemeColorKey,\n base: string,\n explicitContrast: string | undefined,\n scheme: ResolvedColorScheme,\n): Diagnostic => {\n const page = PAGE_SURFACE[scheme];\n if (!isFill(key)) {\n // Link text sits on the page, so the page is what it must contrast with.\n const ratio = contrastRatio(base, page);\n const grade = gradeFor(ratio);\n return {\n grade,\n ratio,\n detail: `Link text on the page background: ${ratio.toFixed(2)}:1 against the ${scheme} page.${GRADE_CAVEAT[grade] ?? ''}`,\n };\n }\n\n const foreground = explicitContrast ?? pickContrast(base);\n const ratio = contrastRatio(base, foreground);\n const name = foreground.toLowerCase() === CONTRAST_DARK ? 'dark' : 'white';\n const edge = contrastRatio(base, page);\n\n const grade = gradeFor(ratio);\n\n return {\n grade,\n ratio,\n detail: `${name === 'white' ? 'White' : 'Near-black'} text on this fill is ${ratio.toFixed(2)}:1.${\n explicitContrast ? ' Foreground pinned via the theme.' : ''\n }${GRADE_CAVEAT[grade] ?? ''}`,\n edgeWarning:\n edge < EDGE_MIN_RATIO\n ? `Only ${edge.toFixed(2)}:1 against the page background - this fill is barely distinguishable from the page it sits on.`\n : undefined,\n };\n};\n\ninterface FontRowProps {\n label: string;\n /** Stack currently applied, used to pick the matching option. */\n value: string;\n options: ThemeFontOption[];\n mono: boolean;\n allowUpload: boolean;\n onChange: (stack: string) => void;\n onUploaded: (option: ThemeFontOption, file: File, family: string) => void;\n}\n\n/** Pulls the first family out of a stack, unquoted. */\nconst firstFamily = (stack: string): string =>\n stack\n .split(',')[0]\n ?.trim()\n .replace(/^['\"]|['\"]$/g, '') || 'Custom';\n\n/**\n * One font row: a `Select` over the known stacks, an optional upload, and an\n * availability warning.\n *\n * Uses `Select` rather than `Combobox` deliberately. `Combobox` filters its\n * options against the text in the field, and the field holds a full font stack\n * (`'Plus Jakarta Sans', -apple-system, …`) which matches no option label - so\n * the list read \"No results found\" until the text was cleared by hand. A font\n * is a choice from a known set, not a search.\n */\nconst FontRow: React.FC<FontRowProps> = ({\n label,\n value,\n options,\n mono,\n allowUpload,\n onChange,\n onUploaded,\n}) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Web fonts load asynchronously, so the first render always sees them as\n // unavailable. Without re-checking once they arrive, the row would sit on a\n // stale \"not installed\" warning for a font that is rendering perfectly.\n // The reducer exists only to schedule that re-render; its value is unused.\n const [, onFontsLoaded] = useReducer((count: number) => count + 1, 0);\n useEffect(() => subscribeToFontLoads(onFontsLoaded), [onFontsLoaded]);\n\n const baseOptions = useMemo(() => {\n // A stack the theme carries but that isn't in the list (loaded by the host\n // app, or set programmatically) still needs to be selectable, labelled with\n // its own first family so the row names the font actually in use.\n const known = options.some((o) => o.value === value);\n return known ? options : [...options, { label: `${firstFamily(value)} (custom)`, value }];\n }, [options, value]);\n\n // Probed on every render rather than memoised: availability changes over time\n // as fonts load, so a cached answer is a wrong answer. Four canvas\n // measurements are far cheaper than getting this wrong.\n //\n // Availability is annotated per option rather than filtered or disabled. A\n // theme is shared across machines, so a font present here may be absent for\n // the next user - and vice versa, which would mean hiding a font someone\n // legitimately wants. Annotating keeps every choice selectable while making\n // the list stop implying that a name is a guarantee.\n const selectOptions = baseOptions.map((option) => ({\n id: option.value,\n label: isFontStackAvailable(option.value) ? option.label : `${option.label} - not installed`,\n value: option.value,\n }));\n\n const handleFile = useCallback(\n async (file: File | undefined) => {\n if (!file) return;\n setError(null);\n try {\n const family = await registerFontFile(file);\n const stack = toFontStack(family, mono);\n onUploaded({ label: `${family} (this session)`, value: stack }, file, family);\n onChange(stack);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause.message : 'That file could not be loaded as a font.',\n );\n }\n },\n [mono, onChange, onUploaded],\n );\n\n const unavailable = !isFontStackAvailable(value);\n\n return (\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">{label}</span>\n\n <div className=\"eidos-theme-editor-row__control\">\n <Select\n options={selectOptions}\n value={value}\n onChange={(next) => onChange(Array.isArray(next) ? next[0] : next)}\n fullWidth\n // The row's visible label is a `<span>`, not a `<label htmlFor>`,\n // so nothing associates it with the control. Naming the input\n // directly keeps the two in step without restructuring the row.\n inputProps={{ 'aria-label': label }}\n />\n </div>\n\n {/* Occasional - lives before the action so it can never displace it. */}\n <div className=\"eidos-theme-editor-row__diagnostics\">\n {unavailable && (\n <Tooltip\n message={`${firstFamily(value)} isn't available here, so the browser is rendering the next family in the stack instead. Upload the file, or have your app serve it, to use it.`}\n >\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--aa-large\">\n <TriangleAlert className=\"eidos-theme-editor-badge__icon\" />\n Not installed\n </span>\n </Tooltip>\n )}\n {error && (\n <Tooltip message={error}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Upload failed\n </span>\n </Tooltip>\n )}\n </div>\n\n {allowUpload && (\n <div className=\"eidos-theme-editor-row__actions\">\n <Button\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n preIcon={Upload}\n onClick={() => inputRef.current?.click()}\n tooltip=\"Load a font file to use it right away. Not saved - see onFontUpload to persist it.\"\n >\n Upload\n </Button>\n {/* Plain input rather than FileUpload: this is a single inline\n action in a dense row, not a drop zone. */}\n <input\n ref={inputRef}\n type=\"file\"\n accept={FONT_ACCEPT}\n // Same proxy pattern as `MessageComposer` - see the note there.\n className=\"eidos-theme-editor-file\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onChange={(event) => {\n void handleFile(event.target.files?.[0]);\n // Allow re-picking the same file after a failure.\n event.target.value = '';\n }}\n />\n </div>\n )}\n </div>\n );\n};\n\n/**\n * Live editor for the active `ThemeProvider` theme.\n *\n * Renders no preview of its own: the provider writes tokens to\n * `document.documentElement`, so the surrounding page is the preview.\n *\n * Contrast readouts are diagnostics only - a colour that fails is still\n * applied. Automatically \"correcting\" a chosen colour would mean silently\n * rendering something other than what was picked.\n */\nexport const ThemeEditor: React.FC<ThemeEditorProps> = ({\n colors = THEME_COLOR_KEYS as ThemeColorKey[],\n fontOptions = FONT_STACKS,\n monoFontOptions = MONO_STACKS,\n allowFontUpload = true,\n onFontUpload,\n hideTypography = false,\n hideReset = false,\n hideCssExport = false,\n className,\n}) => {\n const {\n theme,\n resolvedTheme,\n setTheme,\n updateTheme,\n resetTheme,\n isDefault,\n toCss,\n colorScheme,\n resolvedColorScheme,\n setColorScheme,\n } = useTheme();\n const [copied, setCopied] = useState(false);\n\n // Separate dark colours are opt-in: most palettes want the derived dark\n // tones, which are accessible by construction. Starts on when the theme\n // already carries dark overrides, so none are hidden from view.\n const hasDarkOverrides = Object.keys(theme.dark?.colors ?? {}).length > 0;\n const [separateDark, setSeparateDark] = useState(hasDarkOverrides);\n\n // Fonts registered through the upload control this session. Kept local\n // because font *data* cannot live in a ThemeConfig - see the .mdx.\n const [uploaded, setUploaded] = useState<ThemeFontOption[]>([]);\n const [monoUploaded, setMonoUploaded] = useState<ThemeFontOption[]>([]);\n\n const setColor = useCallback(\n (key: ThemeColorKey, hex: string) => {\n const current = theme.colors?.[key];\n // Only the base is written here. A `contrast` pinned in the theme is\n // preserved rather than dropped, since the editor never sets one.\n const pinned = typeof current === 'object' ? current.contrast : undefined;\n updateTheme({ colors: { [key]: pinned ? { base: hex, contrast: pinned } : hex } });\n },\n [theme.colors, updateTheme],\n );\n\n const resetColor = useCallback(\n (key: ThemeColorKey) => {\n // Must go through setTheme, not updateTheme: updateTheme merges, so a key\n // left out of the patch keeps its existing value instead of being removed.\n // Removal is what restores the preset, since resolveTheme fills gaps.\n const nextColors = { ...theme.colors };\n delete nextColors[key];\n setTheme({ ...theme, colors: nextColors });\n },\n [theme, setTheme],\n );\n\n const setDarkColor = useCallback(\n (key: ThemeColorKey, hex: string) => updateTheme({ dark: { colors: { [key]: hex } } }),\n [updateTheme],\n );\n\n const resetDarkColor = useCallback(\n (key: ThemeColorKey) => {\n // As `resetColor`: removing the override is what restores the derived tone.\n const nextDark = { ...theme.dark?.colors };\n delete nextDark[key];\n setTheme({ ...theme, dark: { colors: nextDark } });\n },\n [theme, setTheme],\n );\n\n const toggleSeparateDark = useCallback(\n (on: boolean) => {\n setSeparateDark(on);\n // Turning it off discards the overrides rather than hiding them: a\n // hidden override would keep changing the dark scheme with no control\n // left on screen to explain or undo it.\n if (!on && hasDarkOverrides) setTheme({ ...theme, dark: { colors: {} } });\n },\n [hasDarkOverrides, setTheme, theme],\n );\n\n // Diagnostics follow the scheme being previewed: a colour is graded against\n // the page it is actually on right now, with the foreground it actually has.\n const diagnostics = useMemo(\n () =>\n colors.map((key) => {\n const palette =\n resolvedColorScheme === 'dark' ? resolvedTheme.dark.colors : resolvedTheme.colors;\n const { base, contrast } = palette[key];\n const diagnostic = diagnose(key, base, contrast, resolvedColorScheme);\n const lightBase = resolvedTheme.colors[key].base;\n return {\n key,\n base: lightBase,\n darkBase: resolvedTheme.dark.colors[key].base,\n ...diagnostic,\n // In dark the picker still shows the colour as picked, but what is\n // graded - and rendered - is its dark tone. Name it, or the badge\n // appears to describe a colour that is not on screen.\n detail:\n resolvedColorScheme === 'dark' && base !== lightBase\n ? `In dark this renders as ${base}. ${diagnostic.detail}`\n : diagnostic.detail,\n };\n }),\n [colors, resolvedTheme, resolvedColorScheme],\n );\n\n const failing = diagnostics.filter((d) => d.grade === 'fail');\n const invisible = diagnostics.filter((d) => d.edgeWarning);\n\n const copyCss = useCallback(() => {\n const css = toCss();\n const done = () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n };\n if (navigator.clipboard?.writeText) {\n navigator.clipboard.writeText(css).then(done, done);\n return;\n }\n done();\n }, [toCss]);\n\n return (\n <div className={['eidos-theme-editor', className].filter(Boolean).join(' ')}>\n {(failing.length > 0 || invisible.length > 0) && (\n <Alert variant=\"warning\" title=\"Contrast issues\">\n {failing.length > 0 && (\n <p>\n Cannot reach WCAG AA (4.5:1) with either foreground:{' '}\n {failing.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n {invisible.length > 0 && (\n <p>\n Too close to the page background to read as a filled surface:{' '}\n {invisible.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n </Alert>\n )}\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\" id=\"eidos-theme-editor-scheme\">\n Colour scheme\n </span>\n <span className=\"eidos-theme-editor-section__hint\">\n Your colours apply to both schemes. In dark each one is lightened until it reads on the\n dark page, with dark text on it - turn on separate dark colours to pick them yourself.\n </span>\n </div>\n <div className=\"eidos-theme-editor-rows\">\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scheme</span>\n <div className=\"eidos-theme-editor-row__control\">\n <SegmentedControl\n options={SCHEME_OPTIONS}\n value={colorScheme}\n onChange={(value) => setColorScheme(value as ColorScheme)}\n aria-labelledby=\"eidos-theme-editor-scheme\"\n size=\"sm\"\n />\n </div>\n </div>\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\" />\n <div className=\"eidos-theme-editor-row__control\">\n <Switch\n label=\"Separate dark colours\"\n checked={separateDark}\n onChange={(event) => toggleSeparateDark(event.target.checked)}\n size=\"sm\"\n />\n </div>\n </div>\n </div>\n </Card>\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Colours</span>\n <span className=\"eidos-theme-editor-section__hint\">\n Shades, tints and foregrounds are derived from each base colour. Contrast is measured\n against the {resolvedColorScheme} page.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n {diagnostics.map(({ key, base, darkBase, grade, ratio, detail, edgeWarning }) => {\n const badge = GRADE_BADGE[grade];\n const overridden = theme.colors?.[key] !== undefined;\n const darkOverridden = theme.dark?.colors?.[key] !== undefined;\n return (\n <div className=\"eidos-theme-editor-row\" key={key}>\n <span className=\"eidos-theme-editor-row__label\">{COLOR_LABELS[key]}</span>\n\n {/* `md` rather than `sm`: the size drives the panel's\n saturation/brightness canvas, and 120px is cramped for\n picking a lightness precisely. */}\n <ColorPicker\n value={base}\n onChange={(hex) => setColor(key, hex)}\n size=\"md\"\n // The row draws its own visible label, so the picker must\n // not draw a second one - but without a name of its own\n // every picker here announced as \"Open colour picker\" and\n // they were indistinguishable.\n ariaLabel={COLOR_LABELS[key]}\n />\n\n {separateDark && (\n <ColorPicker\n value={darkBase}\n onChange={(hex) => setDarkColor(key, hex)}\n size=\"md\"\n ariaLabel={`${COLOR_LABELS[key]} (dark)`}\n />\n )}\n\n <div className=\"eidos-theme-editor-row__diagnostics\">\n <Tooltip message={detail}>\n <span className={`eidos-theme-editor-badge eidos-theme-editor-badge--${grade}`}>\n <badge.icon className=\"eidos-theme-editor-badge__icon\" />\n {`${ratio.toFixed(2)}:1 ${badge.label}`}\n </span>\n </Tooltip>\n {edgeWarning && (\n <Tooltip message={edgeWarning}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Invisible on page\n </span>\n </Tooltip>\n )}\n </div>\n\n <div className=\"eidos-theme-editor-row__actions\">\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!overridden}\n onClick={() => resetColor(key)}\n tooltip={overridden ? `Reset ${COLOR_LABELS[key]} to the preset` : 'Unchanged'}\n aria-label={`Reset ${COLOR_LABELS[key]}`}\n />\n {separateDark && (\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!darkOverridden}\n onClick={() => resetDarkColor(key)}\n tooltip={\n darkOverridden\n ? `Use the derived dark ${COLOR_LABELS[key]} again`\n : 'Derived from the light colour'\n }\n aria-label={`Reset dark ${COLOR_LABELS[key]}`}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n </Card>\n\n {!hideTypography && (\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Typography</span>\n <span className=\"eidos-theme-editor-section__hint\">\n A stack only names a font - upload the file to use one the browser doesn&apos;t\n already have. Spacing is declared in <code>em</code>, so the scale moves padding with\n the text.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n <FontRow\n label=\"Body font\"\n value={resolvedTheme.typography.fontFamily}\n options={[...fontOptions, ...uploaded]}\n mono={false}\n allowUpload={allowFontUpload}\n onChange={(fontFamily) => updateTheme({ typography: { fontFamily } })}\n onUploaded={(option, file, family) => {\n setUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, false);\n }}\n />\n\n <FontRow\n label=\"Mono font\"\n value={resolvedTheme.typography.monoFamily}\n options={[...monoFontOptions, ...monoUploaded]}\n mono\n allowUpload={allowFontUpload}\n onChange={(monoFamily) => updateTheme({ typography: { monoFamily } })}\n onUploaded={(option, file, family) => {\n setMonoUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, true);\n }}\n />\n\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scale</span>\n <div className=\"eidos-theme-editor-row__control\">\n <Slider\n value={resolvedTheme.typography.fontScale}\n min={FONT_SCALE_MIN}\n max={FONT_SCALE_MAX}\n step={0.025}\n showValue\n showMinMax\n unit=\"×\"\n onChange={(value) => updateTheme({ typography: { fontScale: value } })}\n />\n </div>\n </div>\n </div>\n </Card>\n )}\n\n {(!hideReset || !hideCssExport) && (\n <div className=\"eidos-theme-editor-actions\">\n {!hideReset && (\n <Button variant=\"outlined\" color=\"secondary\" disabled={isDefault} onClick={resetTheme}>\n Reset all\n </Button>\n )}\n {!hideCssExport && (\n <Button\n variant=\"outlined\"\n preIcon={copied ? Check : Clipboard}\n onClick={copyCss}\n tooltip=\"Copy the resolved tokens - light and dark - as CSS you can paste into your own stylesheet\"\n >\n {copied ? 'Copied' : 'Copy as CSS'}\n </Button>\n )}\n </div>\n )}\n </div>\n );\n};\n\nThemeEditor.displayName = 'ThemeEditor';\n"]}
1
+ {"version":3,"sources":["/home/runner/work/eidos-ui/eidos-ui/dist/chunk-U4B6C7OP.cjs","../src/components/ThemeEditor/ThemeEditor.component.tsx"],"names":["ratio","grade"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;AC9CA,8BAAqF;AACrF;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,2CACK;AA0RD,+CAAA;AA/ON,IAAM,aAAA,EAAoD;AAAA,EACxD,KAAA,EAAO,gCAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,IAAM,eAAA,EAA0D;AAAA,EAC9D,EAAE,KAAA,EAAO,OAAA,EAAS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AA,YAAA;AACxC,YAAA;AAEE,cAAA;AAAC,cAAA;AAAA,gBAAA;AACO,gBAAA;AACE,gBAAA;AACF,gBAAA;AACD,gBAAA;AACM,gBAAA;AACsB,gBAAA;AAI3B,gBAAA;AAEqC,cAAA;AAAA,YAAA;AAC7C,UAAA;AAEJ,QAAA;AACF,MAAA;AAGN,IAAA;AACF,IAAA;AAII,sBAAA;AACE,wBAAA;AAA8D,wBAAA;AACX,UAAA;AAAA,0BAAA;AAEJ,UAAA;AAAO,QAAA;AAEtD,MAAA;AACF,sBAAA;AAGE,wBAAA;AAAA,UAAA;AAAC,UAAA;AAAA,YAAA;AACO,YAAA;AAC0B,YAAA;AACK,YAAA;AAC/B,YAAA;AACO,YAAA;AACuD,YAAA;AAElE,cAAA;AACA,8BAAA;AAAkC,YAAA;AACpC,UAAA;AAAA,QAAA;AACF,wBAAA;AAEA,UAAA;AAAC,UAAA;AAAA,YAAA;AACO,YAAA;AAC0B,YAAA;AACa,YAAA;AACzC,YAAA;AACS,YAAA;AACuD,YAAA;AAElE,cAAA;AACA,8BAAA;AAAiC,YAAA;AACnC,UAAA;AAAA,QAAA;AACF,wBAAA;AAGE,0BAAA;AAAqD,0BAAA;AAEnD,YAAA;AAAC,YAAA;AAAA,cAAA;AACiC,cAAA;AAC3B,cAAA;AACA,cAAA;AACC,cAAA;AACG,cAAA;AACC,cAAA;AACL,cAAA;AACgE,YAAA;AAAA,UAAA;AAEzE,QAAA;AACF,MAAA;AACF,IAAA;AACF,IAAA;AAKG,MAAA;AAGC,MAAA;AAGA,QAAA;AAAC,QAAA;AAAA,UAAA;AACS,UAAA;AACkB,UAAA;AACjB,UAAA;AACD,UAAA;AAEa,QAAA;AAAA,MAAA;AACvB,IAAA;AAEJ,EAAA;AAIR;AAEA;AD1MA;AACA;AACA;AACA","file":"/home/runner/work/eidos-ui/eidos-ui/dist/chunk-U4B6C7OP.cjs","sourcesContent":[null,"import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport {\n Check,\n CircleCheck,\n CircleX,\n Clipboard,\n RotateCcw,\n TriangleAlert,\n Upload,\n} from 'lucide-react';\nimport { Alert } from '../Alert';\nimport { Button, IconButton } from '../Button';\nimport { Card } from '../Card';\nimport { ColorPicker } from '../ColorPicker';\nimport { SegmentedControl } from '../SegmentedControl';\nimport { Select } from '../Select';\nimport { Slider } from '../Slider';\nimport { Switch } from '../Switch';\nimport { Tooltip } from '../Tooltip';\nimport { useTheme } from '../ThemeProvider';\nimport type {\n ColorScheme,\n ResolvedColorScheme,\n ThemeColorKey,\n ThemeFontOption,\n} from '../ThemeProvider';\nimport {\n THEME_COLOR_KEYS,\n FONT_SCALE_MAX,\n FONT_SCALE_MIN,\n defaultTheme,\n} from '../ThemeProvider/ThemeProvider.tokens';\nimport {\n CONTRAST_DARK,\n CONTRAST_LIGHT,\n DARK_SURFACE,\n contrastRatio,\n pickContrast,\n} from '../ThemeProvider/ThemeProvider.color';\nimport {\n FONT_ACCEPT,\n isFontStackAvailable,\n registerFontFile,\n subscribeToFontLoads,\n toFontStack,\n} from '../ThemeProvider/ThemeProvider.fonts';\nimport type { ThemeEditorProps } from './ThemeEditor.types';\n\n/**\n * The page surface each scheme's diagnostics are measured against - the\n * `--surface` token's value in that scheme.\n */\nconst PAGE_SURFACE: Record<ResolvedColorScheme, string> = {\n light: CONTRAST_LIGHT,\n dark: DARK_SURFACE,\n};\n\nconst SCHEME_OPTIONS: { value: ColorScheme; label: string }[] = [\n { value: 'light', label: 'Light' },\n { value: 'dark', label: 'Dark' },\n { value: 'system', label: 'System' },\n];\n\n/** Below this, a fill is effectively invisible against the page behind it. */\nconst EDGE_MIN_RATIO = 1.5;\n\nconst COLOR_LABELS: Record<ThemeColorKey, string> = {\n primary: 'Primary',\n secondary: 'Secondary',\n success: 'Success',\n danger: 'Danger',\n warning: 'Warning',\n info: 'Info',\n hyperlink: 'Hyperlink',\n};\n\n/** `hyperlink` is only ever text on a surface, so it is graded differently. */\nconst isFill = (key: ThemeColorKey): boolean => key !== 'hyperlink';\n\n/**\n * Built-in stacks, deliberately limited to fonts that can be relied on.\n *\n * A dropdown implies its entries are available, but a font stack is only a list\n * of *names* - nothing here can install a font. So the list is restricted to\n * generic families (guaranteed by CSS), `system-ui` (whatever the OS provides),\n * and the handful of genuinely web-safe faces. Fonts like Inter, which are not\n * installed anywhere by default, were removed: offering one is offering a\n * choice that silently does nothing on most machines.\n *\n * The preset is included because it is the shipped default and therefore has to\n * be representable - and note that `eidos-ui` does not ship the Plus Jakarta\n * Sans file either, so it renders only where the consumer provides it. That is\n * exactly why unavailable options are labelled as such.\n *\n * Anything beyond this belongs to the consuming app, via `fontOptions`.\n */\nconst FONT_STACKS: ThemeFontOption[] = [\n // Taken from the preset rather than retyped, so the shipped default always\n // matches an option exactly. A hand-copied shorter stack did not match, and\n // the row fell back to showing a synthetic \"custom\" entry instead of the\n // name of the font actually in use.\n { label: 'Plus Jakarta Sans (theme default)', value: defaultTheme.typography.fontFamily! },\n { label: 'System UI', value: \"system-ui, -apple-system, 'Segoe UI', sans-serif\" },\n { label: 'Helvetica / Arial', value: 'Helvetica, Arial, sans-serif' },\n { label: 'Georgia', value: \"Georgia, 'Times New Roman', serif\" },\n { label: 'Sans-serif (generic)', value: 'sans-serif' },\n { label: 'Serif (generic)', value: 'serif' },\n];\n\nconst MONO_STACKS: ThemeFontOption[] = [\n { label: 'JetBrains Mono (theme default)', value: defaultTheme.typography.monoFamily! },\n { label: 'Menlo / Consolas', value: 'Menlo, Consolas, monospace' },\n { label: 'Courier New', value: \"'Courier New', Courier, monospace\" },\n { label: 'Monospace (generic)', value: 'monospace' },\n];\n\ntype Grade = 'aa' | 'aa-large' | 'fail';\n\nconst gradeFor = (ratio: number): Grade => (ratio >= 4.5 ? 'aa' : ratio >= 3 ? 'aa-large' : 'fail');\n\n/** Spelled out for the middle grade, which is the one that misleads. */\nconst GRADE_CAVEAT: Partial<Record<Grade, string>> = {\n 'aa-large':\n ' WCAG AA needs 4.5:1 for normal text and allows 3:1 only at 24px or larger - button and label text here is around 12px, so this does not pass.',\n fail: ' Below 3:1, which fails WCAG AA at every text size.',\n};\n\n/**\n * Severity is carried by an icon and the label text, not by colour.\n *\n * These badges cannot use `Pill`, or any themed `--x-color`: the theme being\n * edited also styles this editor, so a washed-out `success` colour would render\n * the \"passes AA\" badge illegible at precisely the moment it is reporting that\n * a colour is illegible. The badge styling comes from the gray ramp, which is\n * deliberately not themeable.\n *\n * Not relying on colour alone also satisfies WCAG 1.4.1 (Use of Colour).\n */\nconst GRADE_BADGE: Record<\n Grade,\n { label: string; icon: React.ComponentType<{ className?: string }> }\n> = {\n aa: { label: 'AA', icon: CircleCheck },\n // Named for what it means in practice, not just for the threshold it clears.\n // WCAG's relaxed 3:1 tier applies only to text at 24px (or 18.7px bold) and\n // above, and nothing in this library is that large - `--font-size-sm` is\n // ~12.25px at the default root size. A bare \"AA large only\" reads as a pass\n // when for every component here it is a fail.\n 'aa-large': { label: 'Too low for body text', icon: TriangleAlert },\n fail: { label: 'Fails AA', icon: CircleX },\n};\n\ninterface Diagnostic {\n grade: Grade;\n ratio: number;\n /** What the ratio describes, for the tooltip. */\n detail: string;\n /** Set when the fill is too close to the page surface to be seen. */\n edgeWarning?: string;\n}\n\nconst diagnose = (\n key: ThemeColorKey,\n base: string,\n explicitContrast: string | undefined,\n scheme: ResolvedColorScheme,\n): Diagnostic => {\n const page = PAGE_SURFACE[scheme];\n if (!isFill(key)) {\n // Link text sits on the page, so the page is what it must contrast with.\n const ratio = contrastRatio(base, page);\n const grade = gradeFor(ratio);\n return {\n grade,\n ratio,\n detail: `Link text on the page background: ${ratio.toFixed(2)}:1 against the ${scheme} page.${GRADE_CAVEAT[grade] ?? ''}`,\n };\n }\n\n const foreground = explicitContrast ?? pickContrast(base);\n const ratio = contrastRatio(base, foreground);\n const name = foreground.toLowerCase() === CONTRAST_DARK ? 'dark' : 'white';\n const edge = contrastRatio(base, page);\n\n const grade = gradeFor(ratio);\n\n return {\n grade,\n ratio,\n detail: `${name === 'white' ? 'White' : 'Near-black'} text on this fill is ${ratio.toFixed(2)}:1.${\n explicitContrast ? ' Foreground pinned via the theme.' : ''\n }${GRADE_CAVEAT[grade] ?? ''}`,\n edgeWarning:\n edge < EDGE_MIN_RATIO\n ? `Only ${edge.toFixed(2)}:1 against the page background - this fill is barely distinguishable from the page it sits on.`\n : undefined,\n };\n};\n\ninterface FontRowProps {\n label: string;\n /** Stack currently applied, used to pick the matching option. */\n value: string;\n options: ThemeFontOption[];\n mono: boolean;\n allowUpload: boolean;\n onChange: (stack: string) => void;\n onUploaded: (option: ThemeFontOption, file: File, family: string) => void;\n}\n\n/** Pulls the first family out of a stack, unquoted. */\nconst firstFamily = (stack: string): string =>\n stack\n .split(',')[0]\n ?.trim()\n .replace(/^['\"]|['\"]$/g, '') || 'Custom';\n\n/**\n * One font row: a `Select` over the known stacks, an optional upload, and an\n * availability warning.\n *\n * Uses `Select` rather than `Combobox` deliberately. `Combobox` filters its\n * options against the text in the field, and the field holds a full font stack\n * (`'Plus Jakarta Sans', -apple-system, …`) which matches no option label - so\n * the list read \"No results found\" until the text was cleared by hand. A font\n * is a choice from a known set, not a search.\n */\nconst FontRow: React.FC<FontRowProps> = ({\n label,\n value,\n options,\n mono,\n allowUpload,\n onChange,\n onUploaded,\n}) => {\n const inputRef = useRef<HTMLInputElement>(null);\n const [error, setError] = useState<string | null>(null);\n\n // Web fonts load asynchronously, so the first render always sees them as\n // unavailable. Without re-checking once they arrive, the row would sit on a\n // stale \"not installed\" warning for a font that is rendering perfectly.\n // The reducer exists only to schedule that re-render; its value is unused.\n const [, onFontsLoaded] = useReducer((count: number) => count + 1, 0);\n useEffect(() => subscribeToFontLoads(onFontsLoaded), [onFontsLoaded]);\n\n const baseOptions = useMemo(() => {\n // A stack the theme carries but that isn't in the list (loaded by the host\n // app, or set programmatically) still needs to be selectable, labelled with\n // its own first family so the row names the font actually in use.\n const known = options.some((o) => o.value === value);\n return known ? options : [...options, { label: `${firstFamily(value)} (custom)`, value }];\n }, [options, value]);\n\n // Probed on every render rather than memoised: availability changes over time\n // as fonts load, so a cached answer is a wrong answer. Four canvas\n // measurements are far cheaper than getting this wrong.\n //\n // Availability is annotated per option rather than filtered or disabled. A\n // theme is shared across machines, so a font present here may be absent for\n // the next user - and vice versa, which would mean hiding a font someone\n // legitimately wants. Annotating keeps every choice selectable while making\n // the list stop implying that a name is a guarantee.\n const selectOptions = baseOptions.map((option) => ({\n id: option.value,\n label: isFontStackAvailable(option.value) ? option.label : `${option.label} - not installed`,\n value: option.value,\n }));\n\n const handleFile = useCallback(\n async (file: File | undefined) => {\n if (!file) return;\n setError(null);\n try {\n const family = await registerFontFile(file);\n const stack = toFontStack(family, mono);\n onUploaded({ label: `${family} (this session)`, value: stack }, file, family);\n onChange(stack);\n } catch (cause) {\n setError(\n cause instanceof Error ? cause.message : 'That file could not be loaded as a font.',\n );\n }\n },\n [mono, onChange, onUploaded],\n );\n\n const unavailable = !isFontStackAvailable(value);\n\n return (\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">{label}</span>\n\n <div className=\"eidos-theme-editor-row__control\">\n <Select\n options={selectOptions}\n value={value}\n onChange={(next) => onChange(Array.isArray(next) ? next[0] : next)}\n fullWidth\n // The row's visible label is a `<span>`, not a `<label htmlFor>`,\n // so nothing associates it with the control. Naming the input\n // directly keeps the two in step without restructuring the row.\n inputProps={{ 'aria-label': label }}\n />\n </div>\n\n {/* Occasional - lives before the action so it can never displace it. */}\n <div className=\"eidos-theme-editor-row__diagnostics\">\n {unavailable && (\n <Tooltip\n message={`${firstFamily(value)} isn't available here, so the browser is rendering the next family in the stack instead. Upload the file, or have your app serve it, to use it.`}\n >\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--aa-large\">\n <TriangleAlert className=\"eidos-theme-editor-badge__icon\" />\n Not installed\n </span>\n </Tooltip>\n )}\n {error && (\n <Tooltip message={error}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Upload failed\n </span>\n </Tooltip>\n )}\n </div>\n\n {allowUpload && (\n <div className=\"eidos-theme-editor-row__actions\">\n <Button\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n preIcon={Upload}\n onClick={() => inputRef.current?.click()}\n tooltip=\"Load a font file to use it right away. Not saved - see onFontUpload to persist it.\"\n >\n Upload\n </Button>\n {/* Plain input rather than FileUpload: this is a single inline\n action in a dense row, not a drop zone. */}\n <input\n ref={inputRef}\n type=\"file\"\n accept={FONT_ACCEPT}\n // Same proxy pattern as `MessageComposer` - see the note there.\n className=\"eidos-theme-editor-file\"\n tabIndex={-1}\n aria-hidden=\"true\"\n onChange={(event) => {\n void handleFile(event.target.files?.[0]);\n // Allow re-picking the same file after a failure.\n event.target.value = '';\n }}\n />\n </div>\n )}\n </div>\n );\n};\n\n/**\n * Live editor for the active `ThemeProvider` theme.\n *\n * Renders no preview of its own: the provider writes tokens to\n * `document.documentElement`, so the surrounding page is the preview.\n *\n * Contrast readouts are diagnostics only - a colour that fails is still\n * applied. Automatically \"correcting\" a chosen colour would mean silently\n * rendering something other than what was picked.\n */\nexport const ThemeEditor: React.FC<ThemeEditorProps> = ({\n colors = THEME_COLOR_KEYS as ThemeColorKey[],\n fontOptions = FONT_STACKS,\n monoFontOptions = MONO_STACKS,\n allowFontUpload = true,\n onFontUpload,\n hideTypography = false,\n hideReset = false,\n hideCssExport = false,\n className,\n}) => {\n const {\n theme,\n resolvedTheme,\n setTheme,\n updateTheme,\n resetTheme,\n isDefault,\n toCss,\n colorScheme,\n resolvedColorScheme,\n setColorScheme,\n } = useTheme();\n const [copied, setCopied] = useState(false);\n\n // Separate dark colours are opt-in: most palettes want the derived dark\n // tones, which are accessible by construction. Starts on when the theme\n // already carries dark overrides, so none are hidden from view.\n const hasDarkOverrides = Object.keys(theme.dark?.colors ?? {}).length > 0;\n const [separateDark, setSeparateDark] = useState(hasDarkOverrides);\n\n // Fonts registered through the upload control this session. Kept local\n // because font *data* cannot live in a ThemeConfig - see the .mdx.\n const [uploaded, setUploaded] = useState<ThemeFontOption[]>([]);\n const [monoUploaded, setMonoUploaded] = useState<ThemeFontOption[]>([]);\n\n const setColor = useCallback(\n (key: ThemeColorKey, hex: string) => {\n const current = theme.colors?.[key];\n // Only the base is written here. A `contrast` pinned in the theme is\n // preserved rather than dropped, since the editor never sets one.\n const pinned = typeof current === 'object' ? current.contrast : undefined;\n updateTheme({ colors: { [key]: pinned ? { base: hex, contrast: pinned } : hex } });\n },\n [theme.colors, updateTheme],\n );\n\n const resetColor = useCallback(\n (key: ThemeColorKey) => {\n // Must go through setTheme, not updateTheme: updateTheme merges, so a key\n // left out of the patch keeps its existing value instead of being removed.\n // Removal is what restores the preset, since resolveTheme fills gaps.\n const nextColors = { ...theme.colors };\n delete nextColors[key];\n setTheme({ ...theme, colors: nextColors });\n },\n [theme, setTheme],\n );\n\n const setDarkColor = useCallback(\n (key: ThemeColorKey, hex: string) => updateTheme({ dark: { colors: { [key]: hex } } }),\n [updateTheme],\n );\n\n const resetDarkColor = useCallback(\n (key: ThemeColorKey) => {\n // As `resetColor`: removing the override is what restores the derived tone.\n const nextDark = { ...theme.dark?.colors };\n delete nextDark[key];\n setTheme({ ...theme, dark: { colors: nextDark } });\n },\n [theme, setTheme],\n );\n\n const toggleSeparateDark = useCallback(\n (on: boolean) => {\n setSeparateDark(on);\n // Turning it off discards the overrides rather than hiding them: a\n // hidden override would keep changing the dark scheme with no control\n // left on screen to explain or undo it.\n if (!on && hasDarkOverrides) setTheme({ ...theme, dark: { colors: {} } });\n },\n [hasDarkOverrides, setTheme, theme],\n );\n\n // Diagnostics follow the scheme being previewed: a colour is graded against\n // the page it is actually on right now, with the foreground it actually has.\n const diagnostics = useMemo(\n () =>\n colors.map((key) => {\n const palette =\n resolvedColorScheme === 'dark' ? resolvedTheme.dark.colors : resolvedTheme.colors;\n const { base, contrast } = palette[key];\n const diagnostic = diagnose(key, base, contrast, resolvedColorScheme);\n const lightBase = resolvedTheme.colors[key].base;\n return {\n key,\n base: lightBase,\n darkBase: resolvedTheme.dark.colors[key].base,\n ...diagnostic,\n // In dark the picker still shows the colour as picked, but what is\n // graded - and rendered - is its dark tone. Name it, or the badge\n // appears to describe a colour that is not on screen.\n detail:\n resolvedColorScheme === 'dark' && base !== lightBase\n ? `In dark this renders as ${base}. ${diagnostic.detail}`\n : diagnostic.detail,\n };\n }),\n [colors, resolvedTheme, resolvedColorScheme],\n );\n\n const failing = diagnostics.filter((d) => d.grade === 'fail');\n const invisible = diagnostics.filter((d) => d.edgeWarning);\n\n const copyCss = useCallback(() => {\n const css = toCss();\n const done = () => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1600);\n };\n if (navigator.clipboard?.writeText) {\n navigator.clipboard.writeText(css).then(done, done);\n return;\n }\n done();\n }, [toCss]);\n\n return (\n <div className={['eidos-theme-editor', className].filter(Boolean).join(' ')}>\n {(failing.length > 0 || invisible.length > 0) && (\n <Alert variant=\"warning\" title=\"Contrast issues\">\n {failing.length > 0 && (\n <p>\n Cannot reach WCAG AA (4.5:1) with either foreground:{' '}\n {failing.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n {invisible.length > 0 && (\n <p>\n Too close to the page background to read as a filled surface:{' '}\n {invisible.map((d) => COLOR_LABELS[d.key]).join(', ')}.\n </p>\n )}\n </Alert>\n )}\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\" id=\"eidos-theme-editor-scheme\">\n Colour scheme\n </span>\n <span className=\"eidos-theme-editor-section__hint\">\n Your colours apply to both schemes. In dark each one is lightened until it reads on the\n dark page, with dark text on it - turn on separate dark colours to pick them yourself.\n </span>\n </div>\n <div className=\"eidos-theme-editor-rows\">\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scheme</span>\n <div className=\"eidos-theme-editor-row__control\">\n <SegmentedControl\n options={SCHEME_OPTIONS}\n value={colorScheme}\n onChange={(value) => setColorScheme(value as ColorScheme)}\n aria-labelledby=\"eidos-theme-editor-scheme\"\n size=\"sm\"\n />\n </div>\n </div>\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\" />\n <div className=\"eidos-theme-editor-row__control\">\n <Switch\n label=\"Separate dark colours\"\n checked={separateDark}\n onChange={(event) => toggleSeparateDark(event.target.checked)}\n size=\"sm\"\n />\n </div>\n </div>\n </div>\n </Card>\n\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Colours</span>\n <span className=\"eidos-theme-editor-section__hint\">\n Shades, tints and foregrounds are derived from each base colour. Contrast is measured\n against the {resolvedColorScheme} page.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n {diagnostics.map(({ key, base, darkBase, grade, ratio, detail, edgeWarning }) => {\n const badge = GRADE_BADGE[grade];\n const overridden = theme.colors?.[key] !== undefined;\n const darkOverridden = theme.dark?.colors?.[key] !== undefined;\n return (\n <div className=\"eidos-theme-editor-row\" key={key}>\n <span className=\"eidos-theme-editor-row__label\">{COLOR_LABELS[key]}</span>\n\n {/* `md` rather than `sm`: the size drives the panel's\n saturation/brightness canvas, and 120px is cramped for\n picking a lightness precisely. */}\n <ColorPicker\n value={base}\n onChange={(hex) => setColor(key, hex)}\n size=\"md\"\n // The row draws its own visible label, so the picker must\n // not draw a second one - but without a name of its own\n // every picker here announced as \"Open colour picker\" and\n // they were indistinguishable.\n ariaLabel={COLOR_LABELS[key]}\n />\n\n {separateDark && (\n <ColorPicker\n value={darkBase}\n onChange={(hex) => setDarkColor(key, hex)}\n size=\"md\"\n ariaLabel={`${COLOR_LABELS[key]} (dark)`}\n />\n )}\n\n <div className=\"eidos-theme-editor-row__diagnostics\">\n <Tooltip message={detail}>\n <span className={`eidos-theme-editor-badge eidos-theme-editor-badge--${grade}`}>\n <badge.icon className=\"eidos-theme-editor-badge__icon\" />\n {`${ratio.toFixed(2)}:1 ${badge.label}`}\n </span>\n </Tooltip>\n {edgeWarning && (\n <Tooltip message={edgeWarning}>\n <span className=\"eidos-theme-editor-badge eidos-theme-editor-badge--fail\">\n <CircleX className=\"eidos-theme-editor-badge__icon\" />\n Invisible on page\n </span>\n </Tooltip>\n )}\n </div>\n\n <div className=\"eidos-theme-editor-row__actions\">\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!overridden}\n onClick={() => resetColor(key)}\n tooltip={overridden ? `Reset ${COLOR_LABELS[key]} to the preset` : 'Unchanged'}\n aria-label={`Reset ${COLOR_LABELS[key]}`}\n />\n {separateDark && (\n <IconButton\n icon={RotateCcw}\n variant=\"text\"\n color=\"secondary\"\n size=\"sm\"\n disabled={!darkOverridden}\n onClick={() => resetDarkColor(key)}\n tooltip={\n darkOverridden\n ? `Use the derived dark ${COLOR_LABELS[key]} again`\n : 'Derived from the light colour'\n }\n aria-label={`Reset dark ${COLOR_LABELS[key]}`}\n />\n )}\n </div>\n </div>\n );\n })}\n </div>\n </Card>\n\n {!hideTypography && (\n <Card variant=\"outlined\" padding=\"lg\" className=\"eidos-theme-editor-section\">\n <div className=\"eidos-theme-editor-section__header\">\n <span className=\"eidos-theme-editor-section__title\">Typography</span>\n <span className=\"eidos-theme-editor-section__hint\">\n A stack only names a font - upload the file to use one the browser doesn&apos;t\n already have. Spacing is declared in <code>em</code>, so the scale moves padding with\n the text.\n </span>\n </div>\n\n <div className=\"eidos-theme-editor-rows\">\n <FontRow\n label=\"Body font\"\n value={resolvedTheme.typography.fontFamily}\n options={[...fontOptions, ...uploaded]}\n mono={false}\n allowUpload={allowFontUpload}\n onChange={(fontFamily) => updateTheme({ typography: { fontFamily } })}\n onUploaded={(option, file, family) => {\n setUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, false);\n }}\n />\n\n <FontRow\n label=\"Mono font\"\n value={resolvedTheme.typography.monoFamily}\n options={[...monoFontOptions, ...monoUploaded]}\n mono\n allowUpload={allowFontUpload}\n onChange={(monoFamily) => updateTheme({ typography: { monoFamily } })}\n onUploaded={(option, file, family) => {\n setMonoUploaded((prev) => [...prev, option]);\n onFontUpload?.(file, family, true);\n }}\n />\n\n <div className=\"eidos-theme-editor-row eidos-theme-editor-row--wide\">\n <span className=\"eidos-theme-editor-row__label\">Scale</span>\n <div className=\"eidos-theme-editor-row__control\">\n <Slider\n value={resolvedTheme.typography.fontScale}\n min={FONT_SCALE_MIN}\n max={FONT_SCALE_MAX}\n step={0.025}\n showValue\n showMinMax\n unit=\"×\"\n onChange={(value) => updateTheme({ typography: { fontScale: value } })}\n />\n </div>\n </div>\n </div>\n </Card>\n )}\n\n {(!hideReset || !hideCssExport) && (\n <div className=\"eidos-theme-editor-actions\">\n {!hideReset && (\n <Button variant=\"outlined\" color=\"secondary\" disabled={isDefault} onClick={resetTheme}>\n Reset all\n </Button>\n )}\n {!hideCssExport && (\n <Button\n variant=\"outlined\"\n preIcon={copied ? Check : Clipboard}\n onClick={copyCss}\n tooltip=\"Copy the resolved tokens - light and dark - as CSS you can paste into your own stylesheet\"\n >\n {copied ? 'Copied' : 'Copy as CSS'}\n </Button>\n )}\n </div>\n )}\n </div>\n );\n};\n\nThemeEditor.displayName = 'ThemeEditor';\n"]}
@@ -12,10 +12,10 @@ var _chunkTROYIUDHcjs = require('./chunk-TROYIUDH.cjs');
12
12
  var _chunkKV3V2CPHcjs = require('./chunk-KV3V2CPH.cjs');
13
13
 
14
14
 
15
- var _chunkBPVOQLCAcjs = require('./chunk-BPVOQLCA.cjs');
15
+ var _chunkTFCOF5FCcjs = require('./chunk-TFCOF5FC.cjs');
16
16
 
17
17
 
18
- var _chunkVPN7AR7Tcjs = require('./chunk-VPN7AR7T.cjs');
18
+ var _chunkUSGEUG2Ocjs = require('./chunk-USGEUG2O.cjs');
19
19
 
20
20
 
21
21
  var _chunkQ3GNKF74cjs = require('./chunk-Q3GNKF74.cjs');
@@ -374,7 +374,7 @@ var MessageComposer = ({
374
374
  }
375
375
  ),
376
376
  attachments.length > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "eidos-composer-attachments", children: attachments.map((file, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
377
- _chunkBPVOQLCAcjs.Chip,
377
+ _chunkTFCOF5FCcjs.Chip,
378
378
  {
379
379
  size: "sm",
380
380
  variant: "outlined",
@@ -564,7 +564,7 @@ var MessageItem = ({
564
564
  onReply && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-message-reply", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkNSA7ASZ7cjs.Button, { variant: "text", color: "secondary", size: "sm", onClick: onReply, children: "Reply" }) })
565
565
  ] }),
566
566
  hasActions && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "eidos-message-actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
567
- _chunkVPN7AR7Tcjs.Menu,
567
+ _chunkUSGEUG2Ocjs.Menu,
568
568
  {
569
569
  items: _nullishCoalesce(actions, () => ( [])),
570
570
  trigger: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -907,4 +907,4 @@ CommentThread.displayName = "CommentThread";
907
907
 
908
908
 
909
909
  exports.MessageComposer = MessageComposer; exports.Chat = Chat; exports.CommentThread = CommentThread;
910
- //# sourceMappingURL=chunk-ADB7QRX5.cjs.map
910
+ //# sourceMappingURL=chunk-U4MV7P4A.cjs.map