@thecb/components 6.0.0-beta.16 → 6.0.0-beta.19
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 +32 -11
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +32 -11
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/dropdown/Dropdown.js +28 -12
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ const IconWrapper = styled.div`
|
|
|
21
21
|
flex-direction: column;
|
|
22
22
|
justify-content: center;
|
|
23
23
|
transition: transform 0.3s ease;
|
|
24
|
-
${({ open }) => (open ? "transform: rotate(-180deg)" : "")}
|
|
24
|
+
${({ open }) => (open ? "transform: rotate(-180deg)" : "")};
|
|
25
25
|
top: 20px;
|
|
26
26
|
right: 12px;
|
|
27
27
|
`;
|
|
@@ -123,7 +123,7 @@ const Dropdown = ({
|
|
|
123
123
|
value ? options.find(option => option.value === value)?.text : placeholder;
|
|
124
124
|
|
|
125
125
|
const onKeyDown = e => {
|
|
126
|
-
console.log("current input value", inputValue);
|
|
126
|
+
console.log("current input value top of keyDown", inputValue);
|
|
127
127
|
const { key, keyCode } = e;
|
|
128
128
|
const focus = document.activeElement;
|
|
129
129
|
console.log("dropdown value is", value);
|
|
@@ -185,10 +185,23 @@ const Dropdown = ({
|
|
|
185
185
|
}
|
|
186
186
|
if ((keyCode > 64 && keyCode < 91) || keyCode == 32 || keyCode == 189) {
|
|
187
187
|
e.preventDefault();
|
|
188
|
+
console.log("current input value inside keydown if", inputValue);
|
|
188
189
|
setInputValue(inputValue + key);
|
|
189
190
|
}
|
|
190
191
|
};
|
|
191
192
|
|
|
193
|
+
const handleItemSelection = (evt, choice, i) => {
|
|
194
|
+
if (disabledValues.includes(choice.value)) {
|
|
195
|
+
evt.preventDefault();
|
|
196
|
+
} else {
|
|
197
|
+
setSelectedRef(optionRefs.current[i]);
|
|
198
|
+
onSelect(choice.value);
|
|
199
|
+
if (isOpen) {
|
|
200
|
+
onClick();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
192
205
|
useEffect(() => {
|
|
193
206
|
if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
|
|
194
207
|
// WAI-ARIA requires the selected option to receive focus
|
|
@@ -278,15 +291,20 @@ const Dropdown = ({
|
|
|
278
291
|
minWidth="100%"
|
|
279
292
|
name={autocompleteValue}
|
|
280
293
|
onFocus={() => {
|
|
294
|
+
/*
|
|
281
295
|
if (!isOpen) {
|
|
282
296
|
onClick();
|
|
283
297
|
}
|
|
298
|
+
*/
|
|
284
299
|
}}
|
|
285
300
|
onChange={e => {
|
|
286
|
-
console.log("current input value", inputValue);
|
|
301
|
+
console.log("current input value onChange", inputValue);
|
|
287
302
|
console.log("input change event", e.target);
|
|
288
303
|
console.log("input change event value", e.target.value);
|
|
289
|
-
|
|
304
|
+
// support autofill and copy/paste
|
|
305
|
+
if (e.tarvet.value !== inputValue) {
|
|
306
|
+
setInputValue(e.target.value);
|
|
307
|
+
}
|
|
290
308
|
}}
|
|
291
309
|
padding="12px"
|
|
292
310
|
placeholder={getSelection()}
|
|
@@ -331,14 +349,12 @@ const Dropdown = ({
|
|
|
331
349
|
key={choice.value}
|
|
332
350
|
ref={optionRefs.current[i]}
|
|
333
351
|
tabIndex={-1}
|
|
334
|
-
onClick={
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
}
|
|
352
|
+
onClick={e => handleItemSelection(e, choice, i)}
|
|
353
|
+
onKeyDown={e => {
|
|
354
|
+
if (e.keyCode === 13) {
|
|
355
|
+
handleItemSelection(e, choice, i);
|
|
356
|
+
}
|
|
357
|
+
}}
|
|
342
358
|
selected={choice.value === value}
|
|
343
359
|
aria-selected={choice.value === value}
|
|
344
360
|
disabled={disabledValues.includes(choice.value)}
|