@thecb/components 6.0.0-beta.15 → 6.0.0-beta.16
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/dist/index.cjs.js +16 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +16 -8
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +65 -59
package/package.json
CHANGED
|
@@ -16,12 +16,12 @@ import { fallbackValues } from "./Dropdown.theme";
|
|
|
16
16
|
import { themeComponent } from "../../../util/themeUtils";
|
|
17
17
|
|
|
18
18
|
const IconWrapper = styled.div`
|
|
19
|
+
position: absolute;
|
|
19
20
|
display: flex;
|
|
20
21
|
flex-direction: column;
|
|
21
22
|
justify-content: center;
|
|
22
23
|
transition: transform 0.3s ease;
|
|
23
24
|
${({ open }) => (open ? "transform: rotate(-180deg)" : "")}
|
|
24
|
-
position: absolute;
|
|
25
25
|
top: 20px;
|
|
26
26
|
right: 12px;
|
|
27
27
|
`;
|
|
@@ -131,6 +131,9 @@ const Dropdown = ({
|
|
|
131
131
|
switch (key) {
|
|
132
132
|
case "ArrowDown":
|
|
133
133
|
e.preventDefault();
|
|
134
|
+
if (!isOpen) {
|
|
135
|
+
onClick();
|
|
136
|
+
}
|
|
134
137
|
if (optionEl) {
|
|
135
138
|
if (optionEl.current.nextElementSibling) {
|
|
136
139
|
optionEl.current.nextElementSibling.focus();
|
|
@@ -180,6 +183,10 @@ const Dropdown = ({
|
|
|
180
183
|
}
|
|
181
184
|
break;
|
|
182
185
|
}
|
|
186
|
+
if ((keyCode > 64 && keyCode < 91) || keyCode == 32 || keyCode == 189) {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
setInputValue(inputValue + key);
|
|
189
|
+
}
|
|
183
190
|
};
|
|
184
191
|
|
|
185
192
|
useEffect(() => {
|
|
@@ -231,71 +238,70 @@ const Dropdown = ({
|
|
|
231
238
|
extraStyles={`position: relative;`}
|
|
232
239
|
minWidth="100%"
|
|
233
240
|
onClick={() => {
|
|
234
|
-
|
|
241
|
+
if (!isOpen) {
|
|
242
|
+
onClick();
|
|
243
|
+
}
|
|
235
244
|
}}
|
|
236
245
|
onKeyDown={onKeyDown}
|
|
237
246
|
width="100%"
|
|
238
247
|
>
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
disabled &&
|
|
264
|
-
`color: #6e727e;
|
|
248
|
+
<Box
|
|
249
|
+
as="input"
|
|
250
|
+
aria-multiline="false"
|
|
251
|
+
aria-autocomplete="list"
|
|
252
|
+
aria-controls={`${ariaLabelledby}_listbox`}
|
|
253
|
+
aria-activedescendant="focused_option"
|
|
254
|
+
aria-owns={`${ariaLabelledby}_listbox`}
|
|
255
|
+
aria-haspopup="listbox"
|
|
256
|
+
aria-labelledby={ariaLabelledby}
|
|
257
|
+
aria-expanded={isOpen}
|
|
258
|
+
autocomplete={autocompleteValue}
|
|
259
|
+
background={isOpen ? themeValues.hoverColor : WHITE}
|
|
260
|
+
borderRadius="2px"
|
|
261
|
+
borderSize="1px"
|
|
262
|
+
borderColor={
|
|
263
|
+
isError
|
|
264
|
+
? ERROR_COLOR
|
|
265
|
+
: isOpen
|
|
266
|
+
? themeValues.selectedColor
|
|
267
|
+
: GREY_CHATEAU
|
|
268
|
+
}
|
|
269
|
+
extraStyles={
|
|
270
|
+
disabled &&
|
|
271
|
+
`color: #6e727e;
|
|
265
272
|
background-color: #f7f7f7;
|
|
266
273
|
pointer-events: none;`
|
|
274
|
+
}
|
|
275
|
+
hoverStyles={`background-color: ${themeValues.hoverColor};`}
|
|
276
|
+
isOpen={isOpen}
|
|
277
|
+
minHeight="48px"
|
|
278
|
+
minWidth="100%"
|
|
279
|
+
name={autocompleteValue}
|
|
280
|
+
onFocus={() => {
|
|
281
|
+
if (!isOpen) {
|
|
282
|
+
onClick();
|
|
267
283
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
type="text"
|
|
290
|
-
tabIndex={0}
|
|
291
|
-
value={inputValue}
|
|
292
|
-
width="100%"
|
|
293
|
-
dataQa={placeholder}
|
|
294
|
-
/>
|
|
295
|
-
<IconWrapper open={isOpen}>
|
|
296
|
-
<DropdownIcon />
|
|
297
|
-
</IconWrapper>
|
|
298
|
-
</Stack>
|
|
284
|
+
}}
|
|
285
|
+
onChange={e => {
|
|
286
|
+
console.log("current input value", inputValue);
|
|
287
|
+
console.log("input change event", e.target);
|
|
288
|
+
console.log("input change event value", e.target.value);
|
|
289
|
+
setInputValue(e.target.value);
|
|
290
|
+
}}
|
|
291
|
+
padding="12px"
|
|
292
|
+
placeholder={getSelection()}
|
|
293
|
+
role="combobox"
|
|
294
|
+
themeValues={themeValues}
|
|
295
|
+
title={hasTitles ? getSelection() : null}
|
|
296
|
+
type="text"
|
|
297
|
+
tabIndex={0}
|
|
298
|
+
value={inputValue}
|
|
299
|
+
width="100%"
|
|
300
|
+
dataQa={placeholder}
|
|
301
|
+
/>
|
|
302
|
+
<IconWrapper open={isOpen} onClick={onClick}>
|
|
303
|
+
<DropdownIcon />
|
|
304
|
+
</IconWrapper>
|
|
299
305
|
<Fragment>
|
|
300
306
|
{isOpen ? (
|
|
301
307
|
<DropdownContentWrapper
|