@longline/aqua-ui 1.0.280 → 1.0.281

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.
@@ -22,7 +22,7 @@ var List = React.forwardRef(function (props, ref) {
22
22
  return React.createElement(ListStyled, { className: props.className, tabIndex: -1, "$count": React.Children.count(props.children), "$maxItems": props.maxItems, "$contract": props.contract, "$tall": props.tall },
23
23
  props.onSearch &&
24
24
  React.createElement(SearchBox, { onClick: function (e) { return e.stopPropagation(); } },
25
- React.createElement(Input, { noTabIndex: true, icon: SVG.Icons.Search, placeholder: props.placeholder, clearable: true, value: props.search, transparent: true, fluid: true, type: "text", onChange: props.onSearch })),
25
+ React.createElement(Input, { icon: SVG.Icons.Search, placeholder: props.placeholder, clearable: true, value: props.search, transparent: true, fluid: true, type: "text", onChange: props.onSearch })),
26
26
  React.createElement(Inner, { ref: ref, tabIndex: -1 },
27
27
  React.createElement(OverlayScrollbarsComponent, { defer: true, className: "scroller", options: { scrollbars: { theme: 'os-theme-dark', autoHide: 'leave' } }, style: {
28
28
  position: "absolute",
@@ -17,7 +17,7 @@ import * as React from 'react';
17
17
  import styled, { css } from 'styled-components';
18
18
  import { List } from '../../containers/List';
19
19
  var BodyBase = React.forwardRef(function (props, ref) {
20
- return (React.createElement("div", __assign({ style: props.styles.popper }, props.attributes.popper, { className: "".concat(props.className), tabIndex: -1, ref: ref, onMouseDown: function (e) { return e.stopPropagation(); } }),
20
+ return (React.createElement("div", __assign({ style: props.styles.popper }, props.attributes.popper, { className: "".concat(props.className, " dropdown-panel"), tabIndex: -1, ref: ref, onMouseDown: function (e) { return e.stopPropagation(); } }),
21
21
  React.createElement(List, { tall: props.tall, maxItems: props.maxItems, contract: true, onSearch: props.onSearch }, props.children)));
22
22
  });
23
23
  var Body = styled(BodyBase)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n z-index: 9999 !important;\n outline: none;\n box-sizing: border-box;\n visibility: ", ";\n font: ", ";\n\n // Width:\n ", "\n \n transition: opacity ", "ms ease-in-out,\n max-height 0ms linear ", "ms;\n max-height: 0;\n opacity: 0;\n ", "\n"], ["\n z-index: 9999 !important;\n outline: none;\n box-sizing: border-box;\n visibility: ", ";\n font: ", ";\n\n // Width:\n ", "\n \n transition: opacity ", "ms ease-in-out,\n max-height 0ms linear ", "ms;\n max-height: 0;\n opacity: 0;\n ", "\n"])), function (p) { return p.open ? 'visible' : 'hidden'; }, function (p) { return p.theme.font.bodyMedium; }, function (p) { return p.minBodyWidth && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n min-width: ", "px;\n "], ["\n min-width: ", "px;\n "])), p.minBodyWidth); }, function (p) { return p.theme.animation.duration * 0; }, function (p) { return p.theme.animation.duration * 0; }, function (p) { return p.open && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n transition: opacity ", "ms ease-in,\n max-height 0ms linear;\n max-height: 1000px;\n opacity: 1;\n "], ["\n transition: opacity ", "ms ease-in,\n max-height 0ms linear;\n max-height: 1000px;\n opacity: 1;\n "])), function (p) { return p.theme.animation.duration; }); });
@@ -117,7 +117,7 @@ interface IDropdownProps {
117
117
  * A `Dropdown` is a replacement for `<select>` (select). It opens upwards or
118
118
  * downwards depending on its position in the viewport. Its selection and
119
119
  * dropdown items are formatted using a formatting function. A Dropdown can
120
- * also take an `onSearch` callback, which tells provides its subscriber with
120
+ * also take an `onSearch` callback, which provides its subscriber with
121
121
  * a search query in order to provide the `Dropdown` with new items.
122
122
  *
123
123
  * ```jsx
@@ -137,6 +137,8 @@ var DropdownBase = function (props) {
137
137
  // Close the dropdown.
138
138
  var doClose = function () {
139
139
  setOpen(false);
140
+ // Focus was on popper; restore focus to Dropdown.
141
+ wrapperRef.current.focus();
140
142
  // When the dropdown is closed, an onClose event may be fired.
141
143
  // It is fired 300ms after dropdown closure to give the close
142
144
  // animation a chance to run, before any changes are made
@@ -228,8 +230,6 @@ var DropdownBase = function (props) {
228
230
  // A key was pressed while the selector had focus.
229
231
  //
230
232
  var handleKeyDown = function (e) {
231
- if (!wrapperRef.current.contains(document.activeElement))
232
- return;
233
233
  if (props.disabled || props.ghost)
234
234
  return;
235
235
  var key = e.key;
@@ -245,12 +245,6 @@ var DropdownBase = function (props) {
245
245
  return;
246
246
  doClose();
247
247
  }
248
- if (key == ' ') {
249
- e.stopPropagation();
250
- if (open)
251
- return;
252
- doOpen();
253
- }
254
248
  if (key == 'ArrowUp') {
255
249
  e.stopPropagation();
256
250
  e.preventDefault();
@@ -261,6 +255,20 @@ var DropdownBase = function (props) {
261
255
  e.preventDefault();
262
256
  selectNextItem();
263
257
  }
258
+ // The keys after this check won't have any effect if onSearch has
259
+ // focus.
260
+ if (!wrapperRef.current.contains(document.activeElement))
261
+ return;
262
+ if (key == ' ') {
263
+ e.stopPropagation();
264
+ if (open)
265
+ return;
266
+ doOpen();
267
+ }
268
+ if (key == 'Delete' && props.clearable === true) {
269
+ e.stopPropagation();
270
+ handleClear();
271
+ }
264
272
  // Is a letter or a digit pressed?
265
273
  if (key.length == 1 && key.match(/[a-z0-9]/i)) {
266
274
  e.stopPropagation();
@@ -399,7 +407,6 @@ var DropdownBase = function (props) {
399
407
  var handleClickDropdown = function () {
400
408
  wrapperRef.current.children[0].click();
401
409
  };
402
- var children = getBodyChildren();
403
410
  var _d = usePopper(wrapperRef.current, bodyRef.current, {
404
411
  placement: props.direction == 'down' ? 'bottom' : 'top',
405
412
  modifiers: [
@@ -414,14 +421,14 @@ var DropdownBase = function (props) {
414
421
  }), styles = _d.styles, attributes = _d.attributes, update = _d.update;
415
422
  return (React.createElement("div", { className: props.className, tabIndex: props.disabled ? -1 : 0, ref: wrapperRef, onKeyDown: handleKeyDown, onClick: handleClickDropdown },
416
423
  React.createElement(Selection, { open: open, error: props.error, disabled: props.disabled, transparent: props.transparent, ghost: props.ghost, multiple: props.multiple, onClick: handleSelectorClicked, onClear: (props.clearable && !showPlaceholder) ? handleClear : null, placeholder: showPlaceholder }, label),
417
- createPortal(React.createElement(Body, { ref: bodyRef, open: open, transparent: props.transparent, maxItems: props.maxItems, onSearch: props.onSearch ? handleSearch : null, search: search, tall: props.tall, minBodyWidth: props.minBodyWidth, styles: styles, attributes: attributes }, children), document.body)));
424
+ createPortal(React.createElement(Body, { ref: bodyRef, open: open, transparent: props.transparent, maxItems: props.maxItems, onSearch: props.onSearch ? handleSearch : null, search: search, tall: props.tall, minBodyWidth: props.minBodyWidth, styles: styles, attributes: attributes }, getBodyChildren()), document.body)));
418
425
  };
419
- var DropdownStyled = styled(DropdownBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies full horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"], ["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies full horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"
426
+ var DropdownStyled = styled(DropdownBase)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies all available horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"], ["\n position: relative;\n // Dropdown has a minimum width. \n width: 250px;\n // A fluid Dropdown occupies all available horizontal width. \n ", " \n outline: none;\n user-select: none;\n font: ", ";\n color: ", ";\n"
420
427
  /**
421
428
  * A `Dropdown` is a replacement for `<select>` (select). It opens upwards or
422
429
  * downwards depending on its position in the viewport. Its selection and
423
430
  * dropdown items are formatted using a formatting function. A Dropdown can
424
- * also take an `onSearch` callback, which tells provides its subscriber with
431
+ * also take an `onSearch` callback, which provides its subscriber with
425
432
  * a search query in order to provide the `Dropdown` with new items.
426
433
  *
427
434
  * ```jsx
@@ -439,7 +446,7 @@ var DropdownStyled = styled(DropdownBase)(templateObject_2 || (templateObject_2
439
446
  * A `Dropdown` is a replacement for `<select>` (select). It opens upwards or
440
447
  * downwards depending on its position in the viewport. Its selection and
441
448
  * dropdown items are formatted using a formatting function. A Dropdown can
442
- * also take an `onSearch` callback, which tells provides its subscriber with
449
+ * also take an `onSearch` callback, which provides its subscriber with
443
450
  * a search query in order to provide the `Dropdown` with new items.
444
451
  *
445
452
  * ```jsx
@@ -454,7 +461,7 @@ var DropdownStyled = styled(DropdownBase)(templateObject_2 || (templateObject_2
454
461
  */
455
462
  var Dropdown = function (_a) {
456
463
  var _b = _a.direction, direction = _b === void 0 ? 'down' : _b, _c = _a.fluid, fluid = _c === void 0 ? false : _c, _d = _a.clearable, clearable = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.transparent, transparent = _f === void 0 ? false : _f, _g = _a.error, error = _g === void 0 ? false : _g, _h = _a.multiple, multiple = _h === void 0 ? false : _h, _j = _a.resetOnOpen, resetOnOpen = _j === void 0 ? false : _j, _k = _a.gap, gap = _k === void 0 ? 16 : _k, _l = _a.maxItems, maxItems = _l === void 0 ? 6 : _l, _m = _a.tall, tall = _m === void 0 ? false : _m, _o = _a.label, label = _o === void 0 ? function (item) { return item; } : _o, _p = _a.match, match = _p === void 0 ? 'json' : _p, props = __rest(_a, ["direction", "fluid", "clearable", "disabled", "transparent", "error", "multiple", "resetOnOpen", "gap", "maxItems", "tall", "label", "match"]);
457
- return React.createElement(DropdownStyled, __assign({ direction: direction, fluid: fluid, clearable: clearable, disabled: disabled, transparent: transparent, error: error, multiple: multiple, resetOnOpen: resetOnOpen, gap: gap, maxItems: maxItems, tall: tall, label: label, match: match }, props));
464
+ return (React.createElement(DropdownStyled, __assign({ direction: direction, fluid: fluid, clearable: clearable, disabled: disabled, transparent: transparent, error: error, multiple: multiple, resetOnOpen: resetOnOpen, gap: gap, maxItems: maxItems, tall: tall, label: label, match: match }, props)));
458
465
  };
459
466
  Dropdown.displayName = 'Dropdown';
460
467
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.280",
3
+ "version": "1.0.281",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",