@cdc/core 4.25.10 → 4.26.1
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/_stories/Gallery.Charts.stories.tsx +307 -0
- package/_stories/Gallery.DataBite.stories.tsx +72 -0
- package/_stories/Gallery.Maps.stories.tsx +230 -0
- package/_stories/Gallery.WaffleChart.stories.tsx +187 -0
- package/_stories/PageART.stories.tsx +192 -0
- package/_stories/PageBRFSS.stories.tsx +289 -0
- package/_stories/PageCancerRegistries.stories.tsx +199 -0
- package/_stories/PageEasternEquineEncephalitis.stories.tsx +202 -0
- package/_stories/PageExcessiveAlcoholUse.stories.tsx +196 -0
- package/_stories/PageMaternalMortality.stories.tsx +192 -0
- package/_stories/PageOralHealth.stories.tsx +196 -0
- package/_stories/PageRespiratory.stories.tsx +332 -0
- package/_stories/PageSmokingTobacco.stories.tsx +195 -0
- package/_stories/PageStateDiabetesProfiles.stories.tsx +196 -0
- package/_stories/PageWastewater.stories.tsx +463 -0
- package/_stories/StoryRenderingTests.stories.tsx +164 -0
- package/assets/icon-magnifying-glass.svg +5 -0
- package/assets/icon-warming-stripes.svg +13 -0
- package/components/AdvancedEditor/AdvancedEditor.tsx +7 -1
- package/components/AdvancedEditor/EmbedEditor.tsx +281 -0
- package/components/ComboBox/ComboBox.tsx +345 -0
- package/components/ComboBox/combobox.styles.css +185 -0
- package/components/ComboBox/index.ts +1 -0
- package/components/CustomColorsEditor/CustomColorsEditor.css +299 -0
- package/components/CustomColorsEditor/CustomColorsEditor.tsx +209 -0
- package/components/CustomColorsEditor/index.ts +1 -0
- package/components/DataTable/DataTable.tsx +132 -58
- package/components/DataTable/DataTableStandAlone.tsx +8 -3
- package/components/DataTable/components/DataTableEditorPanel.tsx +12 -2
- package/components/DataTable/data-table.css +217 -210
- package/components/DataTable/helpers/mapCellMatrix.tsx +28 -9
- package/components/DataTable/helpers/standardizeState.js +2 -2
- package/components/DataTable/helpers/tests/standardizeState.test.js +54 -0
- package/components/EditorPanel/ColumnsEditor.tsx +37 -19
- package/components/EditorPanel/DataTableEditor.tsx +54 -28
- package/components/EditorPanel/EditorPanel.styles.css +439 -0
- package/components/EditorPanel/EditorPanel.tsx +144 -0
- package/components/EditorPanel/EditorPanelDispatch.tsx +75 -0
- package/components/EditorPanel/FieldSetWrapper.tsx +66 -23
- package/components/EditorPanel/FootnotesEditor.tsx +44 -37
- package/components/EditorPanel/Inputs.tsx +44 -8
- package/components/EditorPanel/VizFilterEditor/NestedDropdownEditor.tsx +35 -62
- package/components/EditorPanel/VizFilterEditor/VizFilterEditor.tsx +246 -175
- package/components/EditorPanel/components/MarkupVariablesEditor.tsx +61 -22
- package/components/EditorPanel/sections/VisualSection.tsx +169 -0
- package/components/Filters/Filters.tsx +57 -10
- package/components/Filters/components/Dropdown.tsx +6 -1
- package/components/Filters/helpers/getNestedOptions.ts +2 -1
- package/components/Filters/helpers/handleSorting.ts +1 -1
- package/components/Footnotes/Footnotes.tsx +35 -25
- package/components/Footnotes/FootnotesStandAlone.tsx +42 -6
- package/components/HeaderThemeSelector/HeaderThemeSelector.css +43 -0
- package/components/HeaderThemeSelector/HeaderThemeSelector.stories.tsx +74 -0
- package/components/HeaderThemeSelector/HeaderThemeSelector.tsx +61 -0
- package/components/HeaderThemeSelector/index.ts +2 -0
- package/components/Layout/components/Sidebar/components/sidebar.styles.scss +82 -0
- package/components/Layout/components/Visualization/index.tsx +16 -1
- package/components/Layout/components/Visualization/visualizations.scss +7 -0
- package/components/Layout/styles/editor.scss +2 -1
- package/components/Legend/Legend.Gradient.tsx +1 -1
- package/components/Loader/Loader.tsx +1 -1
- package/components/MediaControls.tsx +63 -34
- package/components/PaletteConversionModal.tsx +7 -4
- package/components/PaletteSelector/PaletteSelector.css +49 -6
- package/components/Table/components/Cell.tsx +23 -2
- package/components/Table/components/Row.tsx +5 -3
- package/components/_stories/Filters.stories.tsx +20 -1
- package/components/_stories/Footnotes.CSV.stories.tsx +247 -0
- package/components/_stories/Footnotes.stories.tsx +768 -3
- package/components/_stories/Inputs.stories.tsx +2 -2
- package/components/_stories/styles.scss +0 -1
- package/components/ui/Accordion.jsx +1 -1
- package/components/ui/Icon.tsx +3 -1
- package/components/ui/Title/index.tsx +30 -2
- package/components/ui/Title/title.styles.css +42 -0
- package/components/ui/accordion.styles.css +57 -0
- package/data/chartColorPalettes.ts +1 -1
- package/dist/cove-main.css +75 -6
- package/dist/cove-main.css.map +1 -1
- package/generateViteConfig.js +8 -1
- package/helpers/addValuesToFilters.ts +11 -1
- package/helpers/constants.ts +37 -0
- package/helpers/cove/number.ts +33 -12
- package/helpers/coveUpdateWorker.ts +20 -11
- package/helpers/embedCodeGenerator.ts +109 -0
- package/helpers/fetchRemoteData.ts +3 -15
- package/helpers/getUniqueValues.ts +19 -0
- package/helpers/hashObj.ts +25 -0
- package/helpers/isRightAlignedTableValue.js +5 -0
- package/helpers/markupProcessor.ts +27 -12
- package/helpers/mergeCustomOrderValues.ts +37 -0
- package/helpers/metrics/helpers.ts +1 -0
- package/helpers/parseCsvWithQuotes.ts +65 -0
- package/helpers/pivotData.ts +2 -2
- package/helpers/prepareScreenshot.ts +268 -0
- package/helpers/queryStringUtils.ts +29 -0
- package/helpers/testing.ts +17 -4
- package/helpers/tests/prepareScreenshot.test.ts +414 -0
- package/helpers/tests/queryStringUtils.test.ts +381 -0
- package/helpers/tests/testStandaloneBuild.ts +23 -5
- package/helpers/useDataVizClasses.ts +0 -1
- package/helpers/ver/4.25.11.ts +13 -0
- package/helpers/ver/4.26.1.ts +80 -0
- package/helpers/viewports.ts +2 -0
- package/hooks/useDataColumns.ts +63 -0
- package/hooks/useFilterManagement.ts +94 -0
- package/hooks/useLegendSeparators.ts +26 -0
- package/hooks/useListManagement.ts +192 -0
- package/package.json +6 -4
- package/styles/_button-section.scss +0 -3
- package/styles/_common-components.css +73 -0
- package/styles/_global.scss +25 -5
- package/styles/base.scss +0 -50
- package/styles/cove-main.scss +3 -1
- package/styles/filters.scss +10 -3
- package/styles/v2/base/index.scss +0 -1
- package/styles/v2/components/editor.scss +14 -6
- package/styles/v2/utils/_breakpoints.scss +1 -1
- package/styles/v2/utils/index.scss +0 -1
- package/styles/waiting.scss +1 -1
- package/types/Axis.ts +1 -0
- package/types/ForecastingSeriesKey.ts +1 -0
- package/types/MarkupInclude.ts +5 -3
- package/types/MarkupVariable.ts +1 -1
- package/types/Series.ts +3 -0
- package/types/Table.ts +1 -0
- package/types/Visualization.ts +1 -0
- package/types/VizFilter.ts +2 -0
- package/LICENSE +0 -201
- package/styles/_mixins.scss +0 -13
- package/styles/_typography.scss +0 -0
- package/styles/v2/base/_typography.scss +0 -0
- package/styles/v2/components/guidance-block.scss +0 -74
- package/styles/v2/utils/_functions.scss +0 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState, useId } from 'react'
|
|
2
|
+
import './combobox.styles.css'
|
|
3
|
+
import { UpdateFieldFunc } from '../../types/UpdateFieldFunc'
|
|
4
|
+
import MagnifyingGlassIcon from '../../assets/icon-magnifying-glass.svg'
|
|
5
|
+
|
|
6
|
+
interface Option {
|
|
7
|
+
value: string | number
|
|
8
|
+
label: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ComboBoxProps {
|
|
12
|
+
section?: string
|
|
13
|
+
subsection?: string
|
|
14
|
+
fieldName: string | number
|
|
15
|
+
options: Option[]
|
|
16
|
+
updateField: UpdateFieldFunc<string>
|
|
17
|
+
label?: string
|
|
18
|
+
selected?: string | number
|
|
19
|
+
placeholder?: string
|
|
20
|
+
loading?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ComboBox: React.FC<ComboBoxProps> = ({
|
|
24
|
+
section = null,
|
|
25
|
+
subsection = null,
|
|
26
|
+
fieldName,
|
|
27
|
+
options,
|
|
28
|
+
updateField,
|
|
29
|
+
label,
|
|
30
|
+
selected = '',
|
|
31
|
+
placeholder = '- Select -',
|
|
32
|
+
loading = false
|
|
33
|
+
}) => {
|
|
34
|
+
const [query, setQuery] = useState('')
|
|
35
|
+
const [focused, setFocused] = useState(false)
|
|
36
|
+
const [activeIndex, setActiveIndex] = useState(-1)
|
|
37
|
+
|
|
38
|
+
const isDisabled = loading || !options?.length
|
|
39
|
+
|
|
40
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
41
|
+
const listboxRef = useRef<HTMLUListElement>(null)
|
|
42
|
+
const comboboxId = useId()
|
|
43
|
+
|
|
44
|
+
// Get selected option
|
|
45
|
+
const selectedOption = options.find(opt => opt.value === selected)
|
|
46
|
+
|
|
47
|
+
// Token-based filtering: all tokens must match (AND logic)
|
|
48
|
+
const filteredOptions = query
|
|
49
|
+
? options.filter(opt => {
|
|
50
|
+
const tokens = query
|
|
51
|
+
.toLowerCase()
|
|
52
|
+
.split(/\s+/)
|
|
53
|
+
.filter(t => t.length > 0)
|
|
54
|
+
const label = opt.label.toLowerCase()
|
|
55
|
+
return tokens.every(token => label.includes(token))
|
|
56
|
+
})
|
|
57
|
+
: options
|
|
58
|
+
|
|
59
|
+
// Highlight matched tokens in option labels
|
|
60
|
+
const highlightMatches = (label: string, query: string): React.ReactNode => {
|
|
61
|
+
if (!query) return label
|
|
62
|
+
|
|
63
|
+
const tokens = query
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.split(/\s+/)
|
|
66
|
+
.filter(t => t.length > 0)
|
|
67
|
+
if (tokens.length === 0) return label
|
|
68
|
+
|
|
69
|
+
// Find all match positions for all tokens
|
|
70
|
+
const matches: { start: number; end: number }[] = []
|
|
71
|
+
tokens.forEach(token => {
|
|
72
|
+
let pos = 0
|
|
73
|
+
const lowerLabel = label.toLowerCase()
|
|
74
|
+
while ((pos = lowerLabel.indexOf(token, pos)) !== -1) {
|
|
75
|
+
matches.push({ start: pos, end: pos + token.length })
|
|
76
|
+
pos += token.length
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
// Sort and merge overlapping matches
|
|
81
|
+
matches.sort((a, b) => a.start - b.start)
|
|
82
|
+
const merged: { start: number; end: number }[] = []
|
|
83
|
+
matches.forEach(match => {
|
|
84
|
+
if (merged.length === 0 || match.start > merged[merged.length - 1].end) {
|
|
85
|
+
merged.push(match)
|
|
86
|
+
} else {
|
|
87
|
+
merged[merged.length - 1].end = Math.max(merged[merged.length - 1].end, match.end)
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
// Build the highlighted result
|
|
92
|
+
const parts: React.ReactNode[] = []
|
|
93
|
+
let lastIndex = 0
|
|
94
|
+
merged.forEach((match, i) => {
|
|
95
|
+
if (match.start > lastIndex) {
|
|
96
|
+
parts.push(label.substring(lastIndex, match.start))
|
|
97
|
+
}
|
|
98
|
+
parts.push(
|
|
99
|
+
<span className='cove-combobox-option-highlight' key={i}>
|
|
100
|
+
{label.substring(match.start, match.end)}
|
|
101
|
+
</span>
|
|
102
|
+
)
|
|
103
|
+
lastIndex = match.end
|
|
104
|
+
})
|
|
105
|
+
if (lastIndex < label.length) {
|
|
106
|
+
parts.push(label.substring(lastIndex))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return <>{parts}</>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const noResults = focused && query.length > 0 && !filteredOptions.length
|
|
113
|
+
const isListOpen = focused && !isDisabled
|
|
114
|
+
|
|
115
|
+
const listboxId = `${comboboxId}-listbox`
|
|
116
|
+
const labelId = label ? `${comboboxId}-label` : undefined
|
|
117
|
+
|
|
118
|
+
// Handle option selection
|
|
119
|
+
const handleSelect = (option: Option) => {
|
|
120
|
+
updateField(section, subsection, fieldName, String(option.value))
|
|
121
|
+
setQuery('')
|
|
122
|
+
setFocused(false)
|
|
123
|
+
setActiveIndex(-1)
|
|
124
|
+
inputRef.current?.blur()
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Handle input change (typing)
|
|
128
|
+
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
129
|
+
const value = e.target.value
|
|
130
|
+
setQuery(value)
|
|
131
|
+
setActiveIndex(-1)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Handle keyboard navigation
|
|
135
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
136
|
+
if (isDisabled) return
|
|
137
|
+
|
|
138
|
+
switch (e.key) {
|
|
139
|
+
case 'ArrowDown':
|
|
140
|
+
e.preventDefault()
|
|
141
|
+
if (!focused) {
|
|
142
|
+
setFocused(true)
|
|
143
|
+
setActiveIndex(0)
|
|
144
|
+
} else {
|
|
145
|
+
setActiveIndex(prev => (prev < filteredOptions.length - 1 ? prev + 1 : 0))
|
|
146
|
+
}
|
|
147
|
+
break
|
|
148
|
+
|
|
149
|
+
case 'ArrowUp':
|
|
150
|
+
e.preventDefault()
|
|
151
|
+
if (focused) {
|
|
152
|
+
setActiveIndex(prev => (prev > 0 ? prev - 1 : filteredOptions.length - 1))
|
|
153
|
+
}
|
|
154
|
+
break
|
|
155
|
+
|
|
156
|
+
case 'Home':
|
|
157
|
+
if (focused && filteredOptions.length > 0) {
|
|
158
|
+
e.preventDefault()
|
|
159
|
+
setActiveIndex(0)
|
|
160
|
+
}
|
|
161
|
+
break
|
|
162
|
+
|
|
163
|
+
case 'End':
|
|
164
|
+
if (focused && filteredOptions.length > 0) {
|
|
165
|
+
e.preventDefault()
|
|
166
|
+
setActiveIndex(filteredOptions.length - 1)
|
|
167
|
+
}
|
|
168
|
+
break
|
|
169
|
+
|
|
170
|
+
case 'Enter':
|
|
171
|
+
e.preventDefault()
|
|
172
|
+
if (focused && activeIndex >= 0 && filteredOptions[activeIndex]) {
|
|
173
|
+
handleSelect(filteredOptions[activeIndex])
|
|
174
|
+
} else if (!focused) {
|
|
175
|
+
setFocused(true)
|
|
176
|
+
}
|
|
177
|
+
break
|
|
178
|
+
|
|
179
|
+
case 'Escape':
|
|
180
|
+
e.preventDefault()
|
|
181
|
+
setQuery('')
|
|
182
|
+
setFocused(false)
|
|
183
|
+
setActiveIndex(-1)
|
|
184
|
+
inputRef.current?.blur()
|
|
185
|
+
break
|
|
186
|
+
|
|
187
|
+
case 'Tab':
|
|
188
|
+
setQuery('')
|
|
189
|
+
setFocused(false)
|
|
190
|
+
setActiveIndex(-1)
|
|
191
|
+
break
|
|
192
|
+
|
|
193
|
+
default:
|
|
194
|
+
// Any other key opens the dropdown
|
|
195
|
+
if (!focused && e.key.length === 1) {
|
|
196
|
+
setFocused(true)
|
|
197
|
+
}
|
|
198
|
+
break
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Handle input focus
|
|
203
|
+
const handleFocus = () => {
|
|
204
|
+
if (isDisabled) return
|
|
205
|
+
inputRef.current?.select()
|
|
206
|
+
setFocused(true)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Handle input blur
|
|
210
|
+
const handleBlur = (e: React.FocusEvent) => {
|
|
211
|
+
const relatedTarget = e.relatedTarget as Node
|
|
212
|
+
const clickedInListbox = listboxRef.current && listboxRef.current.contains(relatedTarget)
|
|
213
|
+
|
|
214
|
+
if (!clickedInListbox) {
|
|
215
|
+
setQuery('')
|
|
216
|
+
setFocused(false)
|
|
217
|
+
setActiveIndex(-1)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Handle button toggle
|
|
222
|
+
const handleButtonClick = (e: React.MouseEvent) => {
|
|
223
|
+
if (isDisabled) return
|
|
224
|
+
|
|
225
|
+
e.preventDefault()
|
|
226
|
+
if (focused) {
|
|
227
|
+
inputRef.current?.blur()
|
|
228
|
+
setFocused(false)
|
|
229
|
+
} else {
|
|
230
|
+
inputRef.current?.focus()
|
|
231
|
+
setFocused(true)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Handle click outside
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
238
|
+
const target = event.target as Node
|
|
239
|
+
if (
|
|
240
|
+
inputRef.current &&
|
|
241
|
+
!inputRef.current.contains(target) &&
|
|
242
|
+
listboxRef.current &&
|
|
243
|
+
!listboxRef.current.contains(target)
|
|
244
|
+
) {
|
|
245
|
+
setQuery('')
|
|
246
|
+
setFocused(false)
|
|
247
|
+
setActiveIndex(-1)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
document.addEventListener('mousedown', handleClickOutside)
|
|
252
|
+
return () => document.removeEventListener('mousedown', handleClickOutside)
|
|
253
|
+
}, [])
|
|
254
|
+
|
|
255
|
+
const activeDescendantId = activeIndex >= 0 ? `${comboboxId}-option-${activeIndex}` : undefined
|
|
256
|
+
const displayValue = isDisabled ? '' : focused ? query : selectedOption?.label || ''
|
|
257
|
+
const displayPlaceholder = isDisabled ? (loading ? 'Loading...' : '- Select -') : selectedOption?.label || placeholder
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<div className='cove-combobox'>
|
|
261
|
+
{/* SR-only instructions */}
|
|
262
|
+
<span className='sr-only'>Use ↑ or ↓ to navigate options, Enter to select, Escape to close</span>
|
|
263
|
+
|
|
264
|
+
<div className='cove-combobox-wrapper'>
|
|
265
|
+
<input
|
|
266
|
+
ref={inputRef}
|
|
267
|
+
id={`${comboboxId}-input`}
|
|
268
|
+
type='text'
|
|
269
|
+
role='combobox'
|
|
270
|
+
aria-autocomplete='list'
|
|
271
|
+
aria-expanded={isListOpen}
|
|
272
|
+
aria-controls={isListOpen ? listboxId : undefined}
|
|
273
|
+
aria-activedescendant={activeDescendantId}
|
|
274
|
+
aria-labelledby={labelId}
|
|
275
|
+
aria-label={label ? undefined : 'Filter selection'}
|
|
276
|
+
aria-disabled={isDisabled}
|
|
277
|
+
autoComplete='off'
|
|
278
|
+
className='cove-combobox-input'
|
|
279
|
+
value={displayValue}
|
|
280
|
+
onChange={handleInputChange}
|
|
281
|
+
onFocus={handleFocus}
|
|
282
|
+
onBlur={handleBlur}
|
|
283
|
+
onKeyDown={handleKeyDown}
|
|
284
|
+
placeholder={displayPlaceholder}
|
|
285
|
+
disabled={isDisabled}
|
|
286
|
+
/>
|
|
287
|
+
|
|
288
|
+
<button
|
|
289
|
+
type='button'
|
|
290
|
+
tabIndex={-1}
|
|
291
|
+
aria-label={isListOpen ? 'Close dropdown' : 'Open dropdown'}
|
|
292
|
+
aria-controls={listboxId}
|
|
293
|
+
aria-expanded={isListOpen}
|
|
294
|
+
className='cove-combobox-button'
|
|
295
|
+
onMouseDown={handleButtonClick}
|
|
296
|
+
disabled={isDisabled}
|
|
297
|
+
>
|
|
298
|
+
<MagnifyingGlassIcon aria-hidden='true' />
|
|
299
|
+
</button>
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
{isListOpen && (
|
|
303
|
+
<ul
|
|
304
|
+
ref={listboxRef}
|
|
305
|
+
id={listboxId}
|
|
306
|
+
role='listbox'
|
|
307
|
+
aria-labelledby={labelId}
|
|
308
|
+
aria-label={label ? undefined : 'Filter options'}
|
|
309
|
+
className='cove-combobox-listbox'
|
|
310
|
+
tabIndex={-1}
|
|
311
|
+
>
|
|
312
|
+
{noResults ? (
|
|
313
|
+
<li className='cove-combobox-option no-results' aria-disabled='true'>
|
|
314
|
+
There are no items matching this search.
|
|
315
|
+
</li>
|
|
316
|
+
) : (
|
|
317
|
+
filteredOptions.map((option, index) => {
|
|
318
|
+
const isSelected = option.value === selected
|
|
319
|
+
const isActive = index === activeIndex
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<li
|
|
323
|
+
key={option.value}
|
|
324
|
+
id={`${comboboxId}-option-${index}`}
|
|
325
|
+
role='option'
|
|
326
|
+
aria-selected={isSelected}
|
|
327
|
+
className={`cove-combobox-option${isSelected ? ' selected' : ''}${isActive ? ' active' : ''}`}
|
|
328
|
+
onMouseDown={e => {
|
|
329
|
+
e.preventDefault()
|
|
330
|
+
handleSelect(option)
|
|
331
|
+
}}
|
|
332
|
+
onMouseEnter={() => setActiveIndex(index)}
|
|
333
|
+
>
|
|
334
|
+
{highlightMatches(option.label, query)}
|
|
335
|
+
</li>
|
|
336
|
+
)
|
|
337
|
+
})
|
|
338
|
+
)}
|
|
339
|
+
</ul>
|
|
340
|
+
)}
|
|
341
|
+
</div>
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export default ComboBox
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
.cdc-open-viz-module {
|
|
2
|
+
.cove-combobox {
|
|
3
|
+
position: relative;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.cove-combobox-wrapper {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
input.cove-combobox-input[role='combobox'] {
|
|
15
|
+
width: 100%;
|
|
16
|
+
display: block;
|
|
17
|
+
padding: 0.5rem 3rem 0.5rem 0.5rem;
|
|
18
|
+
font-family: var(--app-font-secondary);
|
|
19
|
+
font-weight: 300;
|
|
20
|
+
font-size: 0.833rem;
|
|
21
|
+
line-height: normal;
|
|
22
|
+
color: var(--cool-gray-90);
|
|
23
|
+
background-color: white;
|
|
24
|
+
background-clip: padding-box;
|
|
25
|
+
border: 1px solid var(--cool-gray-10) !important;
|
|
26
|
+
border-radius: 0.333rem;
|
|
27
|
+
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
28
|
+
appearance: none;
|
|
29
|
+
-webkit-appearance: none;
|
|
30
|
+
-moz-appearance: none;
|
|
31
|
+
cursor: text;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
input.cove-combobox-input[role='combobox']:focus {
|
|
35
|
+
color: var(--cool-gray-90);
|
|
36
|
+
background-color: white;
|
|
37
|
+
border: 1px solid var(--cool-gray-10) !important;
|
|
38
|
+
box-shadow: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
input.cove-combobox-input[role='combobox']:focus-visible {
|
|
42
|
+
outline: dashed 2px rgb(0, 122, 153) !important;
|
|
43
|
+
outline-offset: 3px !important;
|
|
44
|
+
border-radius: 6px !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
input.cove-combobox-input[role='combobox']:disabled {
|
|
48
|
+
background-color: var(--lightestGray);
|
|
49
|
+
color: var(--cool-gray-90);
|
|
50
|
+
opacity: 1;
|
|
51
|
+
cursor: default;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
input.cove-combobox-input[role='combobox']:disabled::placeholder {
|
|
55
|
+
color: var(--cool-gray-90);
|
|
56
|
+
opacity: 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input.cove-combobox-input[role='combobox']::placeholder {
|
|
60
|
+
color: #6c757d;
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cove-combobox-button {
|
|
65
|
+
position: absolute;
|
|
66
|
+
right: 0.5rem;
|
|
67
|
+
top: 50%;
|
|
68
|
+
transform: translateY(-50%);
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
width: 1em;
|
|
73
|
+
height: 1em;
|
|
74
|
+
background: transparent;
|
|
75
|
+
border: none;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
padding: 0;
|
|
78
|
+
z-index: 2;
|
|
79
|
+
pointer-events: none;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.cove-combobox-button:disabled {
|
|
83
|
+
cursor: default;
|
|
84
|
+
opacity: 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.cove-combobox-button:disabled svg {
|
|
88
|
+
color: var(--cool-gray-90);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.cove-combobox-button svg {
|
|
92
|
+
color: currentColor;
|
|
93
|
+
font-size: 0.8em;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.cove-combobox-listbox {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: calc(100% + 0.125rem);
|
|
99
|
+
left: 0;
|
|
100
|
+
right: auto;
|
|
101
|
+
width: 150%;
|
|
102
|
+
z-index: 1000;
|
|
103
|
+
max-height: 20rem;
|
|
104
|
+
margin: 0;
|
|
105
|
+
padding: 0;
|
|
106
|
+
overflow-y: auto;
|
|
107
|
+
list-style: none;
|
|
108
|
+
background-color: white;
|
|
109
|
+
border: 1px solid var(--cool-gray-10);
|
|
110
|
+
border-radius: 0.333rem;
|
|
111
|
+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.cove-combobox-listbox:has(.no-results) {
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.cove-combobox-option {
|
|
119
|
+
padding: 0.5rem 0.5rem;
|
|
120
|
+
font-family: var(--app-font-secondary);
|
|
121
|
+
font-weight: 300;
|
|
122
|
+
font-size: 0.778rem;
|
|
123
|
+
color: var(--cool-gray-90);
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
user-select: none;
|
|
126
|
+
transition: background-color 0.15s ease-in-out;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.cove-combobox-option .cove-combobox-option-highlight {
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.cove-combobox-option:hover:not(.no-results) {
|
|
134
|
+
background-color: var(--cool-gray-10);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.cove-combobox-option.active:not(.no-results) {
|
|
138
|
+
background-color: var(--cool-gray-10);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.cove-combobox-option.no-results {
|
|
142
|
+
cursor: default;
|
|
143
|
+
font-style: italic;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.cove-combobox-option.no-results:hover {
|
|
147
|
+
background-color: transparent;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.sr-only {
|
|
151
|
+
position: absolute;
|
|
152
|
+
width: 1px;
|
|
153
|
+
height: 1px;
|
|
154
|
+
padding: 0;
|
|
155
|
+
margin: -1px;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
clip: rect(0, 0, 0, 0);
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
border: 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@media (prefers-reduced-motion: reduce) {
|
|
163
|
+
.cove-combobox-input,
|
|
164
|
+
.cove-combobox-option {
|
|
165
|
+
transition: none;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.cove-combobox-listbox::-webkit-scrollbar {
|
|
170
|
+
width: 8px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.cove-combobox-listbox::-webkit-scrollbar-track {
|
|
174
|
+
background: #f1f1f1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.cove-combobox-listbox::-webkit-scrollbar-thumb {
|
|
178
|
+
background: #888;
|
|
179
|
+
border-radius: 4px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.cove-combobox-listbox::-webkit-scrollbar-thumb:hover {
|
|
183
|
+
background: #555;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ComboBox'
|