@thecb/components 6.0.0-beta.12 → 6.0.0-beta.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.0.0-beta.12",
3
+ "version": "6.0.0-beta.15",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -21,6 +21,9 @@ const IconWrapper = styled.div`
21
21
  justify-content: center;
22
22
  transition: transform 0.3s ease;
23
23
  ${({ open }) => (open ? "transform: rotate(-180deg)" : "")}
24
+ position: absolute;
25
+ top: 20px;
26
+ right: 12px;
24
27
  `;
25
28
 
26
29
  const DropdownContentWrapper = styled.div`
@@ -39,6 +42,10 @@ const DropdownContentWrapper = styled.div`
39
42
  &:focus {
40
43
  outline: none;
41
44
  }
45
+
46
+ ul {
47
+ padding-left: 0;
48
+ }
42
49
  `;
43
50
 
44
51
  const DropdownItemWrapper = styled.li`
@@ -51,6 +58,7 @@ const DropdownItemWrapper = styled.li`
51
58
  padding: 1rem;
52
59
  box-sizing: border-box;
53
60
  width: 100%;
61
+ list-style: none;
54
62
  cursor: ${({ disabled }) => (disabled ? "default" : "pointer")};
55
63
 
56
64
  &:hover {
@@ -115,15 +123,11 @@ const Dropdown = ({
115
123
  value ? options.find(option => option.value === value)?.text : placeholder;
116
124
 
117
125
  const onKeyDown = e => {
118
- console.log("key down event is", e.target);
119
- console.log("key down event value is", e.target.value);
126
+ console.log("current input value", inputValue);
120
127
  const { key, keyCode } = e;
121
128
  const focus = document.activeElement;
122
129
  console.log("dropdown value is", value);
123
- console.log("focus is", focus);
124
- console.log("option refs are", optionRefs.current);
125
130
  const optionEl = optionRefs.current.find(ref => ref.current === focus);
126
- console.log("option el is", optionEl);
127
131
  switch (key) {
128
132
  case "ArrowDown":
129
133
  e.preventDefault();
@@ -179,13 +183,6 @@ const Dropdown = ({
179
183
  };
180
184
 
181
185
  useEffect(() => {
182
- console.log("option refs in isopen useffect", optionRefs);
183
- console.log(
184
- "option ref current in isopen useffect",
185
- optionRefs.current[0].current
186
- );
187
- console.log("selected refs in isopen useffect", selectedRef);
188
- console.log("value in isopen useffect", value);
189
186
  if (isOpen && selectedRef !== undefined && selectedRef.current !== null) {
190
187
  // WAI-ARIA requires the selected option to receive focus
191
188
  selectedRef.current.focus();
@@ -218,8 +215,6 @@ const Dropdown = ({
218
215
  !disabledValues.includes(filteredOptions[0].value) &&
219
216
  filteredOptions[0].text != placeholder
220
217
  ) {
221
- console.log("filtered options are", filteredOptions);
222
- console.log("option refs are", optionRefs);
223
218
  onSelect(filteredOptions[0].value);
224
219
  }
225
220
  if (optionRefs.current[0].current) {
@@ -230,8 +225,18 @@ const Dropdown = ({
230
225
  }, [filteredOptions]);
231
226
 
232
227
  return (
233
- <Fragment>
234
- <Stack direction="row" bottomItem={2} extraStyles={`position: relative;`}>
228
+ <Box
229
+ padding="0"
230
+ background={isOpen ? themeValues.hoverColor : WHITE}
231
+ extraStyles={`position: relative;`}
232
+ minWidth="100%"
233
+ onClick={() => {
234
+ onClick();
235
+ }}
236
+ onKeyDown={onKeyDown}
237
+ width="100%"
238
+ >
239
+ <Stack direction="row" bottomItem={2}>
235
240
  <Box
236
241
  as="input"
237
242
  aria-multiline="false"
@@ -253,6 +258,7 @@ const Dropdown = ({
253
258
  ? themeValues.selectedColor
254
259
  : GREY_CHATEAU
255
260
  }
261
+ borderWidthOverride="1px 0px 1px 1px"
256
262
  extraStyles={
257
263
  disabled &&
258
264
  `color: #6e727e;
@@ -261,11 +267,16 @@ const Dropdown = ({
261
267
  }
262
268
  hoverStyles={`background-color: ${themeValues.hoverColor};`}
263
269
  isOpen={isOpen}
270
+ minHeight="48px"
271
+ minWidth="100%"
264
272
  name={autocompleteValue}
265
- onKeyDown={onKeyDown}
266
- onClick={onClick}
267
- onFocus={onClick}
273
+ onFocus={() => {
274
+ if (!isOpen) {
275
+ onClick();
276
+ }
277
+ }}
268
278
  onChange={e => {
279
+ console.log("current input value", inputValue);
269
280
  console.log("input change event", e.target);
270
281
  console.log("input change event value", e.target.value);
271
282
  setInputValue(e.target.value);
@@ -276,7 +287,7 @@ const Dropdown = ({
276
287
  themeValues={themeValues}
277
288
  title={hasTitles ? getSelection() : null}
278
289
  type="text"
279
- tabIndex={-1}
290
+ tabIndex={0}
280
291
  value={inputValue}
281
292
  width="100%"
282
293
  dataQa={placeholder}
@@ -361,7 +372,7 @@ const Dropdown = ({
361
372
  <Fragment />
362
373
  )}
363
374
  </Fragment>
364
- </Fragment>
375
+ </Box>
365
376
  );
366
377
  };
367
378