@happeouikit/form-elements 2.3.21 → 2.3.22

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/Dropdown.js CHANGED
@@ -1,11 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["label"];
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  import React, { Fragment, forwardRef, useRef, useImperativeHandle } from "react";
10
7
  import styled, { css } from "styled-components";
11
8
  import Select, { components } from "react-select";
@@ -15,11 +12,9 @@ import { BodyUI, sansFamily } from "@happeouikit/typography";
15
12
  import { screen } from "@happeouikit/theme";
16
13
  import { jsx as _jsx } from "react/jsx-runtime";
17
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
-
19
15
  var Dropdown = function Dropdown(_ref, ref) {
20
16
  var label = _ref.label,
21
- props = _objectWithoutProperties(_ref, _excluded);
22
-
17
+ props = _objectWithoutProperties(_ref, _excluded);
23
18
  var dropdownRef = useRef();
24
19
  useImperativeHandle(ref, function () {
25
20
  return {
@@ -45,7 +40,6 @@ var Dropdown = function Dropdown(_ref, ref) {
45
40
  }, props))]
46
41
  });
47
42
  };
48
-
49
43
  var DropdownIndicator = function DropdownIndicator(props) {
50
44
  return components.DropdownIndicator && /*#__PURE__*/_jsx(components.DropdownIndicator, _objectSpread(_objectSpread({}, props), {}, {
51
45
  children: /*#__PURE__*/_jsx(IconArrowDropDown, {
@@ -55,7 +49,6 @@ var DropdownIndicator = function DropdownIndicator(props) {
55
49
  })
56
50
  }));
57
51
  };
58
-
59
52
  export var dropdownStyles = css(["min-width:200px;width:auto;font-family:", ";letter-spacing:-0.3px;font-size:14px;font-weight:normal;:hover{cursor:pointer;}.dropdown{&__indicator-separator{display:none;}&__indicator{padding:7px 8px;}&__control{border:1px solid ", ";box-shadow:none;:hover{border-color:", ";}:active{outline:none;border-color:", ";}:focus{outline:none;border-color:", ";}&--is-focused,&--is-focused:active{outline:none !important;border:1px solid ", " !important;box-shadow:none;}}&__input{input{box-shadow:none !important;}}&__menu{.dropdown__option--is-focused:not(.dropdown__option--is-selected){background:", ";}}&__placeholder{font-family:", ";color:", ";letter-spacing:-0.3px;font-size:14px;font-weight:normal;}}@media ", "{", ";}"], sansFamily, gray06, gray04, active, active, active, toBgLight(active), sansFamily, gray05, screen.onlyXs, function (_ref2) {
60
53
  var hideOnMobile = _ref2.hideOnMobile;
61
54
  return hideOnMobile && " display: none;";
package/dist/Input.js CHANGED
@@ -1,23 +1,20 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  var _excluded = ["label", "icon", "iconProps", "state", "errorMessage"],
4
- _excluded2 = ["label"];
5
-
4
+ _excluded2 = ["label"];
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
7
  import React from "react";
11
8
  import styled from "styled-components";
12
9
  import { placeholder } from "polished";
13
10
  import { gray01, gray04, gray08, gray05, gray06, active, black, success, alert } from "@happeouikit/colors";
14
11
  import { TinyText, sansFamily, BodyUI } from "@happeouikit/typography";
15
12
  import { uuidv4 } from "./utils";
13
+
16
14
  /**
17
15
  * Map input states to colors
18
16
  * @type {{default: string, success: string, error: string}}
19
17
  */
20
-
21
18
  import { jsx as _jsx } from "react/jsx-runtime";
22
19
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
20
  var inputStates = {
@@ -25,42 +22,13 @@ var inputStates = {
25
22
  error: alert,
26
23
  "default": gray06
27
24
  };
28
- export var Input = function Input(_ref) {
29
- var label = _ref.label,
30
- icon = _ref.icon,
31
- iconProps = _ref.iconProps,
32
- state = _ref.state,
33
- errorMessage = _ref.errorMessage,
34
- rest = _objectWithoutProperties(_ref, _excluded);
35
25
 
36
- var id = React.useMemo(uuidv4, []);
37
- var accessibility = label ? {
38
- "aria-labelledby": id
39
- } : {};
40
- return /*#__PURE__*/_jsxs(Container, {
41
- children: [!!label && /*#__PURE__*/_jsx(InputLabel, {
42
- id: id,
43
- children: /*#__PURE__*/_jsx(BodyUI, {
44
- color: gray01,
45
- children: label
46
- })
47
- }), icon && new IconWrapper(icon, iconProps)(), /*#__PURE__*/_jsx(StyledInput, _objectSpread(_objectSpread({
48
- title: label || "Styled input",
49
- hasIcon: (icon || "").toString(),
50
- state: state || "default"
51
- }, accessibility), rest)), state === "error" && errorMessage && /*#__PURE__*/_jsx(ErrorMessage, {
52
- color: alert,
53
- children: errorMessage
54
- })]
55
- });
56
- };
57
26
  /**
58
27
  * HOC for customizing Icon components for input
59
28
  * @param IconComponent
60
29
  * @param iconProps
61
30
  * @returns {function(): *}
62
31
  */
63
-
64
32
  var IconWrapper = function IconWrapper(IconComponent, iconProps) {
65
33
  var iconDefaults = {
66
34
  width: "20px",
@@ -73,9 +41,7 @@ var IconWrapper = function IconWrapper(IconComponent, iconProps) {
73
41
  left: "10px",
74
42
  fontSize: "18px"
75
43
  };
76
-
77
44
  var props = _objectSpread(_objectSpread({}, iconDefaults), iconProps);
78
-
79
45
  return function () {
80
46
  return /*#__PURE__*/_jsx(InputIconWrapper, {
81
47
  children: /*#__PURE__*/_jsx(IconComponent, _objectSpread(_objectSpread({}, props), {}, {
@@ -84,7 +50,34 @@ var IconWrapper = function IconWrapper(IconComponent, iconProps) {
84
50
  });
85
51
  };
86
52
  };
87
-
53
+ export var Input = function Input(_ref) {
54
+ var label = _ref.label,
55
+ icon = _ref.icon,
56
+ iconProps = _ref.iconProps,
57
+ state = _ref.state,
58
+ errorMessage = _ref.errorMessage,
59
+ rest = _objectWithoutProperties(_ref, _excluded);
60
+ var id = React.useMemo(uuidv4, []);
61
+ var accessibility = label ? {
62
+ "aria-labelledby": id
63
+ } : {};
64
+ return /*#__PURE__*/_jsxs(Container, {
65
+ children: [!!label && /*#__PURE__*/_jsx(InputLabel, {
66
+ id: id,
67
+ children: /*#__PURE__*/_jsx(BodyUI, {
68
+ color: gray01,
69
+ children: label
70
+ })
71
+ }), icon && IconWrapper(icon, iconProps)(), /*#__PURE__*/_jsx(StyledInput, _objectSpread(_objectSpread({
72
+ title: label || "Styled input",
73
+ hasIcon: (icon || "").toString(),
74
+ state: state || "default"
75
+ }, accessibility), rest)), state === "error" && errorMessage && /*#__PURE__*/_jsx(ErrorMessage, {
76
+ color: alert,
77
+ children: errorMessage
78
+ })]
79
+ });
80
+ };
88
81
  var ErrorMessage = styled(TinyText).withConfig({
89
82
  displayName: "Input__ErrorMessage",
90
83
  componentId: "sc-1izazxd-0"
@@ -116,35 +109,34 @@ export var StyledInput = styled.input.attrs(function (_ref2) {
116
109
  return hasIcon ? "10px 12px 10px 38px" : "10px 12px";
117
110
  }, black, function (_ref4) {
118
111
  var _ref4$state = _ref4.state,
119
- state = _ref4$state === void 0 ? "default" : _ref4$state;
112
+ state = _ref4$state === void 0 ? "default" : _ref4$state;
120
113
  return state === "default" ? gray04 : inputStates[state];
121
114
  }, function (_ref5) {
122
115
  var _ref5$state = _ref5.state,
123
- state = _ref5$state === void 0 ? "default" : _ref5$state;
116
+ state = _ref5$state === void 0 ? "default" : _ref5$state;
124
117
  return state === "default" ? active : inputStates[state];
125
118
  }, function (_ref6) {
126
119
  var _ref6$state = _ref6.state,
127
- state = _ref6$state === void 0 ? "default" : _ref6$state;
120
+ state = _ref6$state === void 0 ? "default" : _ref6$state;
128
121
  return state === "default" ? active : inputStates[state];
129
122
  }, gray08, gray05, placeholder({
130
123
  color: gray05
131
124
  }), function (_ref7) {
132
125
  var _ref7$state = _ref7.state,
133
- state = _ref7$state === void 0 ? "default" : _ref7$state;
126
+ state = _ref7$state === void 0 ? "default" : _ref7$state;
134
127
  return inputStates[state];
135
128
  });
136
129
  var InputIconWrapper = styled.span.withConfig({
137
130
  displayName: "Input__InputIconWrapper",
138
131
  componentId: "sc-1izazxd-4"
139
132
  })(["position:relative;"]);
133
+
140
134
  /**
141
135
  * Number Input
142
136
  */
143
-
144
137
  export var InputNumber = function InputNumber(_ref8) {
145
138
  var label = _ref8.label,
146
- props = _objectWithoutProperties(_ref8, _excluded2);
147
-
139
+ props = _objectWithoutProperties(_ref8, _excluded2);
148
140
  return /*#__PURE__*/_jsxs(InputNumberContainer, {
149
141
  children: [/*#__PURE__*/_jsx(StyledInputNumber, _objectSpread(_objectSpread({}, props), {}, {
150
142
  type: "number"
package/dist/Link.js CHANGED
@@ -1,9 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
4
  import React from "react";
8
5
  import PropTypes from "prop-types";
9
6
  import styled from "styled-components";
@@ -1,11 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["label"];
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  import React from "react";
10
7
  import styled from "styled-components";
11
8
  import PropTypes from "prop-types";
@@ -13,11 +10,9 @@ import { white, active, gray06, gray01, gray08 } from "@happeouikit/colors";
13
10
  import { TextZeta } from "@happeouikit/typography";
14
11
  import { jsx as _jsx } from "react/jsx-runtime";
15
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
-
17
13
  var RadioButton = function RadioButton(_ref) {
18
14
  var label = _ref.label,
19
- props = _objectWithoutProperties(_ref, _excluded);
20
-
15
+ props = _objectWithoutProperties(_ref, _excluded);
21
16
  return /*#__PURE__*/_jsxs(RadioButtonWrapper, {
22
17
  children: [/*#__PURE__*/_jsx("input", _objectSpread({
23
18
  type: "radio"
@@ -28,7 +23,6 @@ var RadioButton = function RadioButton(_ref) {
28
23
  })]
29
24
  });
30
25
  };
31
-
32
26
  RadioButton.propTypes = {
33
27
  label: PropTypes.node
34
28
  };
package/dist/Switch.js CHANGED
@@ -1,11 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["label", "tabIndex"];
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  import React, { useRef } from "react";
10
7
  import styled from "styled-components";
11
8
  import PropTypes from "prop-types";
@@ -13,30 +10,25 @@ import { active, gray08, gray01 } from "@happeouikit/colors";
13
10
  import { BodyUI } from "@happeouikit/typography";
14
11
  import { jsx as _jsx } from "react/jsx-runtime";
15
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
-
17
13
  var Switch = function Switch(_ref) {
18
14
  var label = _ref.label,
19
- tabIndex = _ref.tabIndex,
20
- props = _objectWithoutProperties(_ref, _excluded);
21
-
15
+ tabIndex = _ref.tabIndex,
16
+ props = _objectWithoutProperties(_ref, _excluded);
22
17
  var checkboxRef = useRef();
23
-
24
18
  var onClick = function onClick(event) {
25
- event.preventDefault(); // Since this component can be used as controlled or uncontrolled
19
+ event.preventDefault();
20
+ // Since this component can be used as controlled or uncontrolled
26
21
  // it should have the ability to change aria-label based on its state
27
22
  // eslint-disable-next-line no-param-reassign
28
-
29
23
  event.currentTarget.ariaChecked = !checkboxRef.current.checked;
30
24
  checkboxRef.current.checked = !checkboxRef.current.checked;
31
25
  props.onChange(event);
32
26
  };
33
-
34
27
  var onKeyDown = function onKeyDown(event) {
35
28
  if (typeof props.onChange === "function" && event.key.match(/enter|spacebar|\W{1}/i)) {
36
29
  onClick(event);
37
30
  }
38
31
  };
39
-
40
32
  return /*#__PURE__*/_jsxs(ToggleSwitchWrapper, {
41
33
  children: [/*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
42
34
  ref: checkboxRef,
@@ -55,7 +47,6 @@ var Switch = function Switch(_ref) {
55
47
  })]
56
48
  });
57
49
  };
58
-
59
50
  Switch.propTypes = {
60
51
  label: PropTypes.node,
61
52
  tabIndex: PropTypes.number
package/dist/Tag.js CHANGED
@@ -2,11 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
4
  var _excluded = ["text", "closeCallback", "isUppercase"];
5
-
6
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
-
8
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
-
10
7
  import React, { useState } from "react";
11
8
  import styled from "styled-components";
12
9
  import PropTypes from "prop-types";
@@ -15,23 +12,19 @@ import { IconClose } from "@happeouikit/icons";
15
12
  import { BodyUI } from "@happeouikit/typography";
16
13
  import { jsx as _jsx } from "react/jsx-runtime";
17
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
18
-
19
15
  var Tag = function Tag(_ref) {
20
16
  var text = _ref.text,
21
- closeCallback = _ref.closeCallback,
22
- isUppercase = _ref.isUppercase,
23
- props = _objectWithoutProperties(_ref, _excluded);
24
-
17
+ closeCallback = _ref.closeCallback,
18
+ isUppercase = _ref.isUppercase,
19
+ props = _objectWithoutProperties(_ref, _excluded);
25
20
  var _useState = useState(true),
26
- _useState2 = _slicedToArray(_useState, 2),
27
- show = _useState2[0],
28
- setShow = _useState2[1];
29
-
21
+ _useState2 = _slicedToArray(_useState, 2),
22
+ show = _useState2[0],
23
+ setShow = _useState2[1];
30
24
  var onClick = function onClick() {
31
25
  setShow(false);
32
26
  closeCallback && closeCallback();
33
27
  };
34
-
35
28
  return show && /*#__PURE__*/_jsxs(TagWrapper, _objectSpread(_objectSpread({}, props), {}, {
36
29
  children: [/*#__PURE__*/_jsx(Text, {
37
30
  bold: true,
@@ -46,7 +39,6 @@ var Tag = function Tag(_ref) {
46
39
  })]
47
40
  }));
48
41
  };
49
-
50
42
  Tag.propTypes = {
51
43
  text: PropTypes.node.isRequired,
52
44
  closeCallback: PropTypes.func,
package/dist/Textarea.js CHANGED
@@ -1,11 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["cols", "rows", "label"];
4
-
5
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
6
  /* eslint-disable react/require-default-props */
10
7
  import React, { useEffect, useRef, useState } from "react";
11
8
  import styled from "styled-components";
@@ -16,13 +13,11 @@ import { uuidv4 } from "./utils";
16
13
  import { jsx as _jsx } from "react/jsx-runtime";
17
14
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
-
20
16
  var Textarea = function Textarea(_ref) {
21
17
  var cols = _ref.cols,
22
- rows = _ref.rows,
23
- label = _ref.label,
24
- props = _objectWithoutProperties(_ref, _excluded);
25
-
18
+ rows = _ref.rows,
19
+ label = _ref.label,
20
+ props = _objectWithoutProperties(_ref, _excluded);
26
21
  var id = useState(uuidv4)[0];
27
22
  var accessibility = label ? {
28
23
  "aria-labelledby": id
@@ -30,27 +25,25 @@ var Textarea = function Textarea(_ref) {
30
25
  var textareaRef = useRef(null);
31
26
  useEffect(function () {
32
27
  var textarea = textareaRef.current;
33
-
34
28
  if (textarea) {
35
29
  textarea.style.height = "".concat(Math.min(textarea.scrollHeight, props.maxHeight), "px");
36
30
  }
37
31
  }, [props.maxHeight]);
38
-
39
32
  var onChange = function onChange(event) {
40
33
  // Handle auto height
41
34
  if (props.autoHeight) {
42
- var target = event.target; // First set height to inherit to allow textarea to contract
35
+ var target = event.target;
43
36
 
37
+ // First set height to inherit to allow textarea to contract
44
38
  target.style.height = "inherit";
45
39
  target.style.height = "".concat(target.scrollHeight, "px");
46
- } // call props.onChange if exists
47
-
40
+ }
48
41
 
42
+ // call props.onChange if exists
49
43
  if (typeof props.onChange === "function") {
50
44
  props.onChange(event);
51
45
  }
52
46
  };
53
-
54
47
  return /*#__PURE__*/_jsxs(_Fragment, {
55
48
  children: [!!label && /*#__PURE__*/_jsx(Label, {
56
49
  id: id,
@@ -70,7 +63,6 @@ var Textarea = function Textarea(_ref) {
70
63
  }))]
71
64
  });
72
65
  };
73
-
74
66
  Textarea.propTypes = {
75
67
  rows: PropTypes.number,
76
68
  cols: PropTypes.number,
@@ -12,50 +12,44 @@ import TypeaheadNoResults from "./TypeaheadNoResults";
12
12
  import TypeaheadLoading from "./TypeaheadLoading";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
-
16
15
  var Typeahead = function Typeahead(_ref) {
17
16
  var onQuery = _ref.onQuery,
18
- loading = _ref.loading,
19
- results = _ref.results,
20
- onSelect = _ref.onSelect,
21
- onClear = _ref.onClear,
22
- keepResult = _ref.keepResult,
23
- placeholder = _ref.placeholder,
24
- errorMessage = _ref.errorMessage,
25
- queryError = _ref.queryError,
26
- dropdownMaxHeight = _ref.dropdownMaxHeight;
27
-
17
+ loading = _ref.loading,
18
+ results = _ref.results,
19
+ onSelect = _ref.onSelect,
20
+ onClear = _ref.onClear,
21
+ keepResult = _ref.keepResult,
22
+ placeholder = _ref.placeholder,
23
+ errorMessage = _ref.errorMessage,
24
+ queryError = _ref.queryError,
25
+ dropdownMaxHeight = _ref.dropdownMaxHeight;
28
26
  // Need to store query as object to support change detection when debouncing from query to the same query
29
27
  var _useState = useState({
30
- q: ""
31
- }),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- query = _useState2[0],
34
- setQuery = _useState2[1];
35
-
28
+ q: ""
29
+ }),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ query = _useState2[0],
32
+ setQuery = _useState2[1];
36
33
  var debouncedQuery = hooks.useDebounce(query, 300);
37
-
38
34
  var _useState3 = useState(null),
39
- _useState4 = _slicedToArray(_useState3, 2),
40
- focusedResultIndex = _useState4[0],
41
- setFocusedResultIndex = _useState4[1];
42
-
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ focusedResultIndex = _useState4[0],
37
+ setFocusedResultIndex = _useState4[1];
43
38
  var _useState5 = useState(true),
44
- _useState6 = _slicedToArray(_useState5, 2),
45
- allowDropdown = _useState6[0],
46
- setAllowDropdown = _useState6[1];
47
-
39
+ _useState6 = _slicedToArray(_useState5, 2),
40
+ allowDropdown = _useState6[0],
41
+ setAllowDropdown = _useState6[1];
48
42
  var _useState7 = useState(null),
49
- _useState8 = _slicedToArray(_useState7, 2),
50
- selectedResult = _useState8[0],
51
- setSelectedResult = _useState8[1];
52
-
43
+ _useState8 = _slicedToArray(_useState7, 2),
44
+ selectedResult = _useState8[0],
45
+ setSelectedResult = _useState8[1];
53
46
  var selfRef = useRef(null);
54
47
  var selectedRef = useRef(null);
55
48
  var userIsTyping = query !== debouncedQuery;
56
- var showDropDown = query.q.length > 1 && !selectedResult && allowDropdown; // The parent may want to keep the result visible until some further user interaction
57
- // Then keepResult may be toggled OFF to clear the input for next query and set back ON at onQuery
49
+ var showDropDown = query.q.length > 1 && !selectedResult && allowDropdown;
58
50
 
51
+ // The parent may want to keep the result visible until some further user interaction
52
+ // Then keepResult may be toggled OFF to clear the input for next query and set back ON at onQuery
59
53
  useEffect(function () {
60
54
  if (!keepResult) setQuery({
61
55
  q: ""
@@ -72,20 +66,16 @@ var Typeahead = function Typeahead(_ref) {
72
66
  if (results.length === 0) {
73
67
  setFocusedResultIndex(null);
74
68
  }
75
-
76
69
  if (results.length > 0) {
77
70
  setFocusedResultIndex(0);
78
71
  }
79
72
  }, [results]);
80
-
81
73
  var focusNextResult = function focusNextResult() {
82
74
  return focusedResultIndex < results.length - 1 ? focusedResultIndex + 1 : focusedResultIndex;
83
75
  };
84
-
85
76
  var focusPrevResult = function focusPrevResult() {
86
77
  return focusedResultIndex > 0 ? focusedResultIndex - 1 : focusedResultIndex;
87
78
  };
88
-
89
79
  var selectResult = function selectResult(result) {
90
80
  if (keepResult && result.text) {
91
81
  setQuery({
@@ -96,12 +86,10 @@ var Typeahead = function Typeahead(_ref) {
96
86
  q: ""
97
87
  });
98
88
  }
99
-
100
89
  setSelectedResult(result);
101
90
  onSelect(result.data);
102
91
  setFocusedResultIndex(null);
103
92
  };
104
-
105
93
  var valueChangeHandler = function valueChangeHandler(event) {
106
94
  var value = event.target.value;
107
95
  setQuery({
@@ -109,24 +97,22 @@ var Typeahead = function Typeahead(_ref) {
109
97
  });
110
98
  setAllowDropdown(true);
111
99
  setSelectedResult(null);
112
- setFocusedResultIndex(null); // notify parent that selection was erased
100
+ setFocusedResultIndex(null);
113
101
 
102
+ // notify parent that selection was erased
114
103
  if (keepResult && selectedResult) {
115
104
  onClear();
116
105
  }
117
106
  };
118
-
119
107
  useEffect(function () {
120
108
  if (!selectedRef.current) return;
121
109
  selectedRef.current.scrollIntoView({
122
110
  block: "nearest"
123
111
  });
124
112
  }, [focusedResultIndex]);
125
-
126
113
  var keyDownHandler = function keyDownHandler(event) {
127
114
  if (!showDropDown) return;
128
115
  if (queryError || userIsTyping || loading) return;
129
-
130
116
  if (event.key === "ArrowUp") {
131
117
  setFocusedResultIndex(focusPrevResult());
132
118
  event.preventDefault();
@@ -140,11 +126,9 @@ var Typeahead = function Typeahead(_ref) {
140
126
  }
141
127
  }
142
128
  };
143
-
144
129
  var resultClickHandler = function resultClickHandler(result) {
145
130
  selectResult(result);
146
131
  };
147
-
148
132
  useEffect(function () {
149
133
  var handleWindowClick = function handleWindowClick(event) {
150
134
  if (selfRef.current && !selfRef.current.contains(event.target)) {
@@ -153,24 +137,20 @@ var Typeahead = function Typeahead(_ref) {
153
137
  setAllowDropdown(true);
154
138
  }
155
139
  };
156
-
157
140
  document.addEventListener("pointerdown", handleWindowClick);
158
141
  return function cleanup() {
159
142
  document.removeEventListener("pointerdown", handleWindowClick);
160
143
  };
161
144
  }, [selfRef]);
162
-
163
145
  var renderDropdownContent = function renderDropdownContent() {
164
146
  if (queryError) {
165
147
  return /*#__PURE__*/_jsx(TypeaheadError, {});
166
148
  }
167
-
168
149
  if (userIsTyping || loading) {
169
150
  return /*#__PURE__*/_jsx(TypeaheadLoading, {
170
151
  query: query.q
171
152
  });
172
153
  }
173
-
174
154
  if (results.length > 0) {
175
155
  return /*#__PURE__*/_jsx(TypeaheadList, {
176
156
  results: results,
@@ -179,12 +159,10 @@ var Typeahead = function Typeahead(_ref) {
179
159
  ref: selectedRef
180
160
  });
181
161
  }
182
-
183
162
  return /*#__PURE__*/_jsx(TypeaheadNoResults, {
184
163
  query: query.q
185
164
  });
186
165
  };
187
-
188
166
  return /*#__PURE__*/_jsxs(Wrapper, {
189
167
  ref: selfRef,
190
168
  children: [/*#__PURE__*/_jsx(Input, {
@@ -203,7 +181,6 @@ var Typeahead = function Typeahead(_ref) {
203
181
  })]
204
182
  });
205
183
  };
206
-
207
184
  var Wrapper = styled.div.withConfig({
208
185
  displayName: "Typeahead__Wrapper",
209
186
  componentId: "sc-16j2d25-0"
@@ -216,7 +193,6 @@ Typeahead.propTypes = {
216
193
  // If keepResult, this is showed when selecting a result
217
194
  component: PropTypes.element.isRequired,
218
195
  data: PropTypes.shape.isRequired // Data will be passed with onSelect
219
-
220
196
  })).isRequired,
221
197
  onSelect: PropTypes.func.isRequired,
222
198
  onClear: PropTypes.func,
@@ -2,10 +2,9 @@ import styled from "styled-components";
2
2
  import { shadow400 } from "@happeouikit/theme";
3
3
  import { white } from "@happeouikit/colors";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
-
6
5
  var TypeaheadDropdown = function TypeaheadDropdown(_ref) {
7
6
  var maxHeight = _ref.maxHeight,
8
- children = _ref.children;
7
+ children = _ref.children;
9
8
  return /*#__PURE__*/_jsx(Dropdown, {
10
9
  children: /*#__PURE__*/_jsx(DropdownContent, {
11
10
  maxHeight: maxHeight,
@@ -13,7 +12,6 @@ var TypeaheadDropdown = function TypeaheadDropdown(_ref) {
13
12
  })
14
13
  });
15
14
  };
16
-
17
15
  var Dropdown = styled.div.withConfig({
18
16
  displayName: "TypeaheadDropdown__Dropdown",
19
17
  componentId: "sc-c2clla-0"
@@ -3,7 +3,6 @@ import { useIntl } from "react-intl";
3
3
  import messages from "./messages";
4
4
  import TypeaheadMessage from "./TypeaheadMessage";
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
6
-
7
6
  var TypeaheadError = function TypeaheadError() {
8
7
  var intl = useIntl();
9
8
  return /*#__PURE__*/_jsx(TypeaheadMessage, {
@@ -12,5 +11,4 @@ var TypeaheadError = function TypeaheadError() {
12
11
  details: intl.formatMessage(messages.typeaheadServerErrorDetails)
13
12
  });
14
13
  };
15
-
16
14
  export default TypeaheadError;
@@ -9,8 +9,8 @@ var FocusStyle = {
9
9
  };
10
10
  var TypeaheadList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
11
  var results = _ref.results,
12
- focusedResultIndex = _ref.focusedResultIndex,
13
- onResultClick = _ref.onResultClick;
12
+ focusedResultIndex = _ref.focusedResultIndex,
13
+ onResultClick = _ref.onResultClick;
14
14
  return /*#__PURE__*/_jsx(Container, {
15
15
  children: results.map(function (result, index) {
16
16
  return /*#__PURE__*/_jsx(Fragment, {