@flodesk/grain 11.22.6 → 11.23.1

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.
Files changed (152) hide show
  1. package/es/components/arrange/index.js +34 -47
  2. package/es/components/autocomplete.js +94 -149
  3. package/es/components/autocomplete2.js +131 -170
  4. package/es/components/badge.js +12 -17
  5. package/es/components/box.js +115 -126
  6. package/es/components/breakpoints-provider.js +6 -4
  7. package/es/components/button.js +27 -40
  8. package/es/components/checkbox.js +31 -28
  9. package/es/components/dropdown.js +52 -50
  10. package/es/components/flex/index.js +31 -46
  11. package/es/components/icon-button.js +17 -25
  12. package/es/components/icon-toggle.js +30 -34
  13. package/es/components/icon.js +10 -20
  14. package/es/components/link.js +18 -18
  15. package/es/components/modal.js +75 -69
  16. package/es/components/nav/index.js +36 -43
  17. package/es/components/pagination.js +45 -63
  18. package/es/components/popover.js +47 -48
  19. package/es/components/progress.js +12 -15
  20. package/es/components/provider.js +7 -6
  21. package/es/components/radio.js +25 -24
  22. package/es/components/select.js +92 -100
  23. package/es/components/slider.js +25 -29
  24. package/es/components/spinner.js +11 -26
  25. package/es/components/stack.js +10 -19
  26. package/es/components/switch.js +21 -21
  27. package/es/components/tab.js +18 -25
  28. package/es/components/text/index.js +38 -48
  29. package/es/components/text-button.js +28 -41
  30. package/es/components/text-input.js +53 -75
  31. package/es/components/text-toggle.js +20 -31
  32. package/es/components/textarea.js +38 -33
  33. package/es/components/toast.js +29 -28
  34. package/es/components/tooltip.js +43 -77
  35. package/es/foundational/field.js +39 -34
  36. package/es/foundational/menu.js +112 -98
  37. package/es/foundational/styles.js +23 -23
  38. package/es/hooks/useKeyPress.js +10 -31
  39. package/es/hooks/useMedia.js +8 -45
  40. package/es/hooks/useOnClickOutside.js +4 -7
  41. package/es/hooks/usePrev.js +3 -3
  42. package/es/hooks/useWidth.js +3 -29
  43. package/es/hooks/useWindowSize.js +4 -32
  44. package/es/icons/icon-align-center.js +28 -32
  45. package/es/icons/icon-align-left.js +35 -39
  46. package/es/icons/icon-align-right.js +35 -39
  47. package/es/icons/icon-archive.js +21 -25
  48. package/es/icons/icon-arrow-down.js +21 -25
  49. package/es/icons/icon-arrow-left.js +21 -25
  50. package/es/icons/icon-arrow-right.js +21 -25
  51. package/es/icons/icon-arrow-up.js +21 -25
  52. package/es/icons/icon-at.js +21 -25
  53. package/es/icons/icon-bold.js +28 -32
  54. package/es/icons/icon-bolt-filled.js +21 -25
  55. package/es/icons/icon-bolt.js +21 -25
  56. package/es/icons/icon-browser.js +21 -25
  57. package/es/icons/icon-brush.js +20 -24
  58. package/es/icons/icon-bullet-list.js +21 -25
  59. package/es/icons/icon-chart.js +29 -33
  60. package/es/icons/icon-check.js +21 -25
  61. package/es/icons/icon-chevron-down.js +21 -25
  62. package/es/icons/icon-chevron-horizontal.js +21 -25
  63. package/es/icons/icon-chevron-left.js +21 -25
  64. package/es/icons/icon-chevron-right.js +21 -25
  65. package/es/icons/icon-chevron-up.js +28 -32
  66. package/es/icons/icon-chevron-vertical.js +28 -32
  67. package/es/icons/icon-clip.js +37 -41
  68. package/es/icons/icon-clock.js +21 -25
  69. package/es/icons/icon-column-and-rows.js +25 -29
  70. package/es/icons/icon-column-one.js +21 -25
  71. package/es/icons/icon-column-two.js +21 -25
  72. package/es/icons/icon-columns-and-row.js +25 -29
  73. package/es/icons/icon-columns.js +21 -25
  74. package/es/icons/icon-content-align-bottom.js +21 -25
  75. package/es/icons/icon-content-align-center.js +21 -25
  76. package/es/icons/icon-content-align-top.js +21 -25
  77. package/es/icons/icon-crop.js +21 -25
  78. package/es/icons/icon-cross.js +23 -27
  79. package/es/icons/icon-download.js +28 -32
  80. package/es/icons/icon-drag.js +21 -25
  81. package/es/icons/icon-duplicate.js +21 -25
  82. package/es/icons/icon-ellipsis.js +21 -25
  83. package/es/icons/icon-file.js +28 -32
  84. package/es/icons/icon-folder-add.js +21 -25
  85. package/es/icons/icon-folder-move.js +21 -25
  86. package/es/icons/icon-folder-remove.js +21 -25
  87. package/es/icons/icon-folder.js +21 -25
  88. package/es/icons/icon-gear.js +35 -39
  89. package/es/icons/icon-globe.js +28 -32
  90. package/es/icons/icon-heart.js +21 -25
  91. package/es/icons/icon-hide.js +21 -25
  92. package/es/icons/icon-image.js +21 -25
  93. package/es/icons/icon-info.js +21 -25
  94. package/es/icons/icon-italic.js +28 -32
  95. package/es/icons/icon-layout-text-bottom.js +28 -32
  96. package/es/icons/icon-layout-text-left.js +21 -25
  97. package/es/icons/icon-layout-text-right.js +28 -32
  98. package/es/icons/icon-layout-text-top.js +21 -25
  99. package/es/icons/icon-link.js +21 -25
  100. package/es/icons/icon-location.js +21 -25
  101. package/es/icons/icon-mail.js +21 -25
  102. package/es/icons/icon-minus.js +19 -23
  103. package/es/icons/icon-monitor.js +21 -25
  104. package/es/icons/icon-number-list.js +29 -33
  105. package/es/icons/icon-pencil.js +28 -32
  106. package/es/icons/icon-phone.js +21 -25
  107. package/es/icons/icon-play.js +21 -25
  108. package/es/icons/icon-plus.js +21 -25
  109. package/es/icons/icon-question.js +21 -25
  110. package/es/icons/icon-redo.js +21 -25
  111. package/es/icons/icon-reset.js +22 -26
  112. package/es/icons/icon-row-and-columns.js +25 -29
  113. package/es/icons/icon-rows-and-column.js +25 -29
  114. package/es/icons/icon-rows.js +21 -25
  115. package/es/icons/icon-search.js +21 -25
  116. package/es/icons/icon-send.js +21 -25
  117. package/es/icons/icon-share.js +21 -25
  118. package/es/icons/icon-show.js +21 -25
  119. package/es/icons/icon-smile.js +28 -32
  120. package/es/icons/icon-square.js +21 -25
  121. package/es/icons/icon-strike.js +28 -32
  122. package/es/icons/icon-switch.js +21 -25
  123. package/es/icons/icon-tablet.js +21 -25
  124. package/es/icons/icon-text-align-center.js +21 -25
  125. package/es/icons/icon-text-align-left.js +21 -25
  126. package/es/icons/icon-text-align-right.js +21 -25
  127. package/es/icons/icon-text-justify.js +21 -25
  128. package/es/icons/icon-trash.js +28 -32
  129. package/es/icons/icon-type.js +28 -32
  130. package/es/icons/icon-underline.js +28 -32
  131. package/es/icons/icon-undo.js +28 -32
  132. package/es/icons/icon-upload.js +28 -32
  133. package/es/styles/base.js +1 -1
  134. package/es/styles/card.js +4 -8
  135. package/es/styles/colors/core.js +1 -1
  136. package/es/styles/colors/theme.js +1 -1
  137. package/es/styles/foundational-variables.js +5 -0
  138. package/es/styles/index.js +2 -2
  139. package/es/styles/shadows.js +1 -1
  140. package/es/styles/utilities.js +65 -90
  141. package/es/styles/variables.js +1 -1
  142. package/es/types.js +28 -29
  143. package/es/utilities/attributes.js +46 -49
  144. package/es/utilities/helpers.js +13 -36
  145. package/es/utilities/responsive.js +16 -43
  146. package/es/utilities/style-config.js +32 -76
  147. package/es/utilities/styles.js +17 -29
  148. package/es/variables/breakpoints.js +1 -1
  149. package/es/variables/colors.js +1 -1
  150. package/es/variables/vars.js +3 -13
  151. package/package.json +5 -5
  152. package/es/styles/component-variables.js +0 -2
@@ -1,22 +1,10 @@
1
- import "core-js/modules/es.object.keys.js";
2
- import "core-js/modules/es.array.index-of.js";
3
- import "core-js/modules/es.symbol.js";
4
- import "core-js/modules/es.object.define-property.js";
5
- import "core-js/modules/es.array.filter.js";
6
- import "core-js/modules/es.object.to-string.js";
7
- import "core-js/modules/es.object.get-own-property-descriptor.js";
8
- import "core-js/modules/web.dom-collections.for-each.js";
9
- import "core-js/modules/es.object.get-own-property-descriptors.js";
10
- import "core-js/modules/es.object.define-properties.js";
11
- import "core-js/modules/es.object.assign.js";
12
- var _excluded = ["children", "gap", "columnGap", "rowGap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "rows", "autoFlow", "className", "style"];
1
+ const _excluded = ["children", "gap", "columnGap", "rowGap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "rows", "autoFlow", "className", "style"];
13
2
 
14
3
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
4
 
16
5
  import "core-js/modules/es.regexp.exec.js";
17
6
  import "core-js/modules/es.string.replace.js";
18
7
  import "core-js/modules/es.string.trim.js";
19
- import "core-js/modules/es.array.concat.js";
20
8
 
21
9
  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; }
22
10
 
@@ -35,50 +23,49 @@ import { Box } from '../box';
35
23
  import styles from './styles.module.css';
36
24
  import { BreakpointsContext } from '../breakpoints-provider';
37
25
  import { jsx as ___EmotionJSX } from "@emotion/react";
38
- export var Arrange = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
- var children = _ref.children,
40
- gap = _ref.gap,
41
- columnGap = _ref.columnGap,
42
- rowGap = _ref.rowGap,
43
- _ref$alignItems = _ref.alignItems,
44
- alignItems = _ref$alignItems === void 0 ? 'center' : _ref$alignItems,
45
- justifyItems = _ref.justifyItems,
46
- _ref$justifyContent = _ref.justifyContent,
47
- justifyContent = _ref$justifyContent === void 0 ? 'start' : _ref$justifyContent,
48
- alignContent = _ref.alignContent,
49
- columns = _ref.columns,
50
- rows = _ref.rows,
51
- _ref$autoFlow = _ref.autoFlow,
52
- autoFlow = _ref$autoFlow === void 0 ? 'column' : _ref$autoFlow,
53
- className = _ref.className,
54
- style = _ref.style,
26
+ export const Arrange = /*#__PURE__*/forwardRef((_ref, ref) => {
27
+ let {
28
+ children,
29
+ gap,
30
+ columnGap,
31
+ rowGap,
32
+ alignItems = 'center',
33
+ justifyItems,
34
+ justifyContent = 'start',
35
+ alignContent,
36
+ columns,
37
+ rows,
38
+ autoFlow = 'column',
39
+ className,
40
+ style
41
+ } = _ref,
55
42
  props = _objectWithoutProperties(_ref, _excluded);
56
43
 
57
- var propClassName = className ? className : '';
58
- var propStyle = style ? style : {};
59
- var breakpoints = useContext(BreakpointsContext);
60
- var sharedProps = {
61
- gap: gap,
62
- columnGap: columnGap,
63
- rowGap: rowGap,
64
- alignItems: alignItems,
65
- justifyItems: justifyItems,
66
- justifyContent: justifyContent,
67
- alignContent: alignContent,
44
+ const propClassName = className ? className : '';
45
+ const propStyle = style ? style : {};
46
+ const breakpoints = useContext(BreakpointsContext);
47
+ const sharedProps = {
48
+ gap,
49
+ columnGap,
50
+ rowGap,
51
+ alignItems,
52
+ justifyItems,
53
+ justifyContent,
54
+ alignContent,
68
55
  autoFlow: !columns ? autoFlow : undefined
69
56
  };
70
- var attributes = generateAttributes({
57
+ const attributes = generateAttributes({
71
58
  styleProps: _objectSpread({
72
- columns: columns,
73
- rows: rows
59
+ columns,
60
+ rows
74
61
  }, sharedProps),
75
62
  classNameProps: _objectSpread({}, sharedProps),
76
- breakpoints: breakpoints
63
+ breakpoints
77
64
  });
78
65
 
79
- var styleAttributes = _objectSpread(_objectSpread({}, attributes.styles), propStyle);
66
+ const styleAttributes = _objectSpread(_objectSpread({}, attributes.styles), propStyle);
80
67
 
81
- var classAttributes = "".concat(attributes.classNames, " ").concat(propClassName, " ").concat(styles.arrange).trim().replace(/\s+/g, ' ');
68
+ const classAttributes = "".concat(attributes.classNames, " ").concat(propClassName, " ").concat(styles.arrange).trim().replace(/\s+/g, ' ');
82
69
  return ___EmotionJSX(Box, _extends({
83
70
  ref: ref,
84
71
  className: classAttributes,
@@ -1,27 +1,5 @@
1
- import "core-js/modules/es.object.keys.js";
2
- import "core-js/modules/es.array.index-of.js";
3
- import "core-js/modules/es.symbol.js";
4
- import "core-js/modules/es.symbol.description.js";
5
- import "core-js/modules/es.symbol.iterator.js";
6
- import "core-js/modules/es.array.iterator.js";
7
- import "core-js/modules/es.string.iterator.js";
1
+ const _excluded = ["options", "value", "onChange", "isCreatable", "onCreate", "menuPlacement", "menuWidth", "menuMaxHeight", "menuZIndex", "placeholder", "label", "hint", "menuItemsHaveEllipsis", "hasPortal", "hasError", "errorMessage", "searchField"];
8
2
  import "core-js/modules/web.dom-collections.iterator.js";
9
- import "core-js/modules/es.array.slice.js";
10
- import "core-js/modules/es.array.from.js";
11
- import "core-js/modules/es.regexp.exec.js";
12
- var _excluded = ["options", "value", "onChange", "isCreatable", "onCreate", "menuPlacement", "menuWidth", "menuMaxHeight", "menuZIndex", "placeholder", "label", "hint", "menuItemsHaveEllipsis", "hasPortal", "hasError", "errorMessage", "searchField"];
13
-
14
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
-
16
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
17
-
18
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
19
-
20
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
21
-
22
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
23
-
24
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
3
 
26
4
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
5
 
@@ -29,13 +7,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
29
7
 
30
8
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
31
9
 
32
- import "core-js/modules/es.object.assign.js";
33
- import "core-js/modules/es.array.filter.js";
34
- import "core-js/modules/es.object.to-string.js";
35
- import "core-js/modules/es.array.includes.js";
36
- import "core-js/modules/es.string.includes.js";
37
- import "core-js/modules/es.array.find.js";
38
- import "core-js/modules/es.array.map.js";
39
10
  import PropTypes from 'prop-types';
40
11
  import React, { forwardRef, Fragment, useMemo, useRef, useState } from 'react';
41
12
  import { Icon, Box, Text } from '.';
@@ -48,8 +19,8 @@ import { FloatingPortal } from '@floating-ui/react-dom-interactions';
48
19
  import { Global } from '@emotion/react';
49
20
  import { getColor, getRadius } from '../utilities';
50
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
51
- var Trigger = /*#__PURE__*/forwardRef(function (_ref, ref) {
52
- var props = Object.assign({}, _ref);
22
+ const Trigger = /*#__PURE__*/forwardRef((_ref, ref) => {
23
+ let props = Object.assign({}, _ref);
53
24
  return ___EmotionJSX(Box, _extends({
54
25
  ref: ref
55
26
  }, props, {
@@ -57,77 +28,63 @@ var Trigger = /*#__PURE__*/forwardRef(function (_ref, ref) {
57
28
  }));
58
29
  });
59
30
 
60
- var EmptyState = function EmptyState() {
61
- return ___EmotionJSX(Box, {
62
- paddingY: "s",
63
- paddingX: "12px"
64
- }, ___EmotionJSX(Text, {
65
- color: "content2"
66
- }, "No results"));
67
- };
31
+ const EmptyState = () => ___EmotionJSX(Box, {
32
+ paddingY: "s",
33
+ paddingX: "12px"
34
+ }, ___EmotionJSX(Text, {
35
+ color: "content2"
36
+ }, "No results"));
68
37
 
69
- var ExpandIcon = function ExpandIcon() {
70
- return ___EmotionJSX(Box, {
71
- right: "fieldPaddingX",
72
- position: "absolute",
73
- top: "0px",
74
- bottom: "0px",
75
- margin: "auto",
76
- height: "fit-content"
77
- }, ___EmotionJSX(Icon, {
78
- icon: ___EmotionJSX(IconChevronDown, null)
79
- }));
80
- };
38
+ const ExpandIcon = () => ___EmotionJSX(Box, {
39
+ right: "fieldPaddingX",
40
+ position: "absolute",
41
+ top: "0px",
42
+ bottom: "0px",
43
+ margin: "auto",
44
+ height: "fit-content"
45
+ }, ___EmotionJSX(Icon, {
46
+ icon: ___EmotionJSX(IconChevronDown, null)
47
+ }));
81
48
 
82
- var getFilteredOptions = function getFilteredOptions(query, options, searchField) {
49
+ const getFilteredOptions = (query, options, searchField) => {
83
50
  if (query === '') return options;
84
- return options.filter(function (option) {
85
- return option[searchField].toLowerCase().includes(query.toLowerCase());
86
- });
51
+ return options.filter(option => option[searchField].toLowerCase().includes(query.toLowerCase()));
87
52
  };
88
53
 
89
- var getShowGroupTitle = function getShowGroupTitle(index, option, filteredOptions) {
90
- var firstOptionHasTitle = index === 0 && option.groupTitle;
91
- var titleChanged = index > 0 && option.groupTitle !== filteredOptions[index - 1].groupTitle;
54
+ const getShowGroupTitle = (index, option, filteredOptions) => {
55
+ const firstOptionHasTitle = index === 0 && option.groupTitle;
56
+ const titleChanged = index > 0 && option.groupTitle !== filteredOptions[index - 1].groupTitle;
92
57
  return firstOptionHasTitle || titleChanged;
93
58
  };
94
59
 
95
- var menuItemStyles = "\n .autocompleteMenuItem {\n display: flex;\n gap: 8px;\n align-items: center;\n list-style: none;\n padding: 4px 12px;\n min-height: var(--grn-textBoxHeight);\n border-radius: ".concat(getRadius('s'), ";\n appearance: none;\n\n &.hasPreContent {\n padding-left: 0;\n }\n }\n\n .autocompleteMenuItemText {\n flex-grow: 1;\n\n &.hasEllipsis {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n");
96
- export var Autocomplete = function Autocomplete(_ref2) {
97
- var options = _ref2.options,
98
- value = _ref2.value,
99
- onChange = _ref2.onChange,
100
- isCreatable = _ref2.isCreatable,
101
- onCreate = _ref2.onCreate,
102
- _ref2$menuPlacement = _ref2.menuPlacement,
103
- menuPlacement = _ref2$menuPlacement === void 0 ? defaultProps.menuPlacement : _ref2$menuPlacement,
104
- menuWidth = _ref2.menuWidth,
105
- _ref2$menuMaxHeight = _ref2.menuMaxHeight,
106
- menuMaxHeight = _ref2$menuMaxHeight === void 0 ? defaultProps.menuMaxHeight : _ref2$menuMaxHeight,
107
- menuZIndex = _ref2.menuZIndex,
108
- placeholder = _ref2.placeholder,
109
- label = _ref2.label,
110
- hint = _ref2.hint,
111
- _ref2$menuItemsHaveEl = _ref2.menuItemsHaveEllipsis,
112
- menuItemsHaveEllipsis = _ref2$menuItemsHaveEl === void 0 ? true : _ref2$menuItemsHaveEl,
113
- _ref2$hasPortal = _ref2.hasPortal,
114
- hasPortal = _ref2$hasPortal === void 0 ? true : _ref2$hasPortal,
115
- hasError = _ref2.hasError,
116
- errorMessage = _ref2.errorMessage,
117
- _ref2$searchField = _ref2.searchField,
118
- searchField = _ref2$searchField === void 0 ? 'content' : _ref2$searchField,
60
+ const menuItemStyles = "\n .autocompleteMenuItem {\n display: flex;\n gap: 8px;\n align-items: center;\n list-style: none;\n padding: 4px 12px;\n min-height: var(--grn-textbox-height-m);\n border-radius: ".concat(getRadius('s'), ";\n appearance: none;\n\n &.hasPreContent {\n padding-left: 0;\n }\n }\n\n .autocompleteMenuItemText {\n flex-grow: 1;\n\n &.hasEllipsis {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n");
61
+ export const Autocomplete = _ref2 => {
62
+ let {
63
+ options,
64
+ value,
65
+ onChange,
66
+ isCreatable,
67
+ onCreate,
68
+ menuPlacement = defaultProps.menuPlacement,
69
+ menuWidth,
70
+ menuMaxHeight = defaultProps.menuMaxHeight,
71
+ menuZIndex,
72
+ placeholder,
73
+ label,
74
+ hint,
75
+ menuItemsHaveEllipsis = true,
76
+ hasPortal = true,
77
+ hasError,
78
+ errorMessage,
79
+ searchField = 'content'
80
+ } = _ref2,
119
81
  props = _objectWithoutProperties(_ref2, _excluded);
120
82
 
121
- var _useState = useState(''),
122
- _useState2 = _slicedToArray(_useState, 2),
123
- query = _useState2[0],
124
- setQuery = _useState2[1];
83
+ const [query, setQuery] = useState('');
125
84
 
126
- var handleCreatableChange = function handleCreatableChange(option) {
85
+ const handleCreatableChange = option => {
127
86
  if (onCreate) {
128
- var isCreatableOption = !options.find(function (item) {
129
- return item.value === option.value;
130
- });
87
+ const isCreatableOption = !options.find(item => item.value === option.value);
131
88
 
132
89
  if (isCreatableOption) {
133
90
  onCreate(option);
@@ -138,7 +95,7 @@ export var Autocomplete = function Autocomplete(_ref2) {
138
95
  onChange(option);
139
96
  };
140
97
 
141
- var handleChange = function handleChange(option) {
98
+ const handleChange = option => {
142
99
  if (isCreatable) {
143
100
  handleCreatableChange(option);
144
101
  } else {
@@ -146,39 +103,27 @@ export var Autocomplete = function Autocomplete(_ref2) {
146
103
  }
147
104
  };
148
105
 
149
- var filteredOptions = getFilteredOptions(query, options, searchField);
150
- var isShowCreateOption = isCreatable && query.length > 0;
151
- var noResults = !Boolean(filteredOptions.length) && !isShowCreateOption;
152
- var fieldMarginTop = label || hint ? 'betweenFormControlAndLabel' : undefined;
153
- var selectedOption = useMemo(function () {
154
- return options.find(function (option) {
155
- return option.value === value;
156
- });
157
- }, [options, value]);
158
- var newOption = useMemo(function () {
159
- return {
160
- value: query,
161
- content: query
162
- };
163
- }, [query]);
164
-
165
- var _useMenuPosition = useMenuPosition({
166
- menuWidth: menuWidth,
167
- menuPlacement: menuPlacement
168
- }),
169
- reference = _useMenuPosition.reference,
170
- floating = _useMenuPosition.floating,
171
- floatingStyles = _useMenuPosition.floatingStyles;
172
-
173
- var OptionsRoot = hasPortal ? FloatingPortal : Fragment;
174
- var preContentRef = useRef(null);
175
-
176
- var _useState3 = useState(0),
177
- _useState4 = _slicedToArray(_useState3, 2),
178
- preContentWidth = _useState4[0],
179
- setPreContentWidth = _useState4[1];
180
-
181
- React.useEffect(function () {
106
+ const filteredOptions = getFilteredOptions(query, options, searchField);
107
+ const isShowCreateOption = isCreatable && query.length > 0;
108
+ const noResults = !Boolean(filteredOptions.length) && !isShowCreateOption;
109
+ const fieldMarginTop = label || hint ? 'betweenFormControlAndLabel' : undefined;
110
+ const selectedOption = useMemo(() => options.find(option => option.value === value), [options, value]);
111
+ const newOption = useMemo(() => ({
112
+ value: query,
113
+ content: query
114
+ }), [query]);
115
+ const {
116
+ reference,
117
+ floating,
118
+ floatingStyles
119
+ } = useMenuPosition({
120
+ menuWidth,
121
+ menuPlacement
122
+ });
123
+ const OptionsRoot = hasPortal ? FloatingPortal : Fragment;
124
+ const preContentRef = useRef(null);
125
+ const [preContentWidth, setPreContentWidth] = useState(0);
126
+ React.useEffect(() => {
182
127
  if (preContentRef.current) {
183
128
  setPreContentWidth(preContentRef.current.offsetWidth);
184
129
  }
@@ -189,9 +134,11 @@ export var Autocomplete = function Autocomplete(_ref2) {
189
134
  as: "div",
190
135
  value: selectedOption || '',
191
136
  onChange: handleChange
192
- }, props), function (_ref3) {
193
- var open = _ref3.open;
194
- var hasPreContent = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.preContent;
137
+ }, props), _ref3 => {
138
+ let {
139
+ open
140
+ } = _ref3;
141
+ const hasPreContent = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.preContent;
195
142
  return ___EmotionJSX(React.Fragment, null, label && ___EmotionJSX(Combobox.Label, {
196
143
  as: FieldLabel
197
144
  }, label), hint && ___EmotionJSX(FieldHint, null, hint), ___EmotionJSX(Box, {
@@ -212,20 +159,14 @@ export var Autocomplete = function Autocomplete(_ref2) {
212
159
  }, selectedOption.preContent), ___EmotionJSX(Combobox.Input, {
213
160
  as: InputField,
214
161
  autoComplete: "off",
215
- onChange: function onChange(event) {
216
- return setQuery(event.target.value);
217
- },
162
+ onChange: event => setQuery(event.target.value),
218
163
  placeholder: placeholder,
219
- displayValue: function displayValue(option) {
220
- return option && option.content;
221
- },
164
+ displayValue: option => option && option.content,
222
165
  paddingRight: "32px",
223
166
  paddingLeft: !open && hasPreContent ? "".concat(preContentWidth + 8, "px") : undefined,
224
167
  hasError: hasError
225
168
  }), ___EmotionJSX(ExpandIcon, null)), ___EmotionJSX(OptionsRoot, null, ___EmotionJSX(MenuCardTransition, {
226
- afterLeave: function afterLeave() {
227
- return setQuery('');
228
- }
169
+ afterLeave: () => setQuery('')
229
170
  }, ___EmotionJSX(Combobox.Options, {
230
171
  static: true,
231
172
  className: "grn-context",
@@ -236,8 +177,8 @@ export var Autocomplete = function Autocomplete(_ref2) {
236
177
  zIndex: menuZIndex,
237
178
  style: floatingStyles,
238
179
  isDisabled: !open
239
- }, filteredOptions.map(function (option, index) {
240
- var showGroupTitle = getShowGroupTitle(index, option, filteredOptions);
180
+ }, filteredOptions.map((option, index) => {
181
+ const showGroupTitle = getShowGroupTitle(index, option, filteredOptions);
241
182
  return ___EmotionJSX(Fragment, {
242
183
  key: index
243
184
  }, showGroupTitle && ___EmotionJSX(MenuGroupTitle, {
@@ -246,13 +187,15 @@ export var Autocomplete = function Autocomplete(_ref2) {
246
187
  value: option,
247
188
  as: Fragment,
248
189
  disabled: option.isDisabled
249
- }, function (_ref4) {
250
- var active = _ref4.active;
251
- var isDisabled = option.isDisabled;
252
- var isSelected = option.value === value;
253
- var isActive = !option.isDisabled && active;
254
- var hasEllipsis = menuItemsHaveEllipsis;
255
- var hasPreContent = option.preContent;
190
+ }, _ref4 => {
191
+ let {
192
+ active
193
+ } = _ref4;
194
+ const isDisabled = option.isDisabled;
195
+ const isSelected = option.value === value;
196
+ const isActive = !option.isDisabled && active;
197
+ const hasEllipsis = menuItemsHaveEllipsis;
198
+ const hasPreContent = option.preContent;
256
199
  return ___EmotionJSX("li", {
257
200
  className: hasPreContent ? 'autocompleteMenuItem hasPreContent' : 'autocompleteMenuItem',
258
201
  style: {
@@ -272,9 +215,11 @@ export var Autocomplete = function Autocomplete(_ref2) {
272
215
  }));
273
216
  }), isShowCreateOption && ___EmotionJSX(React.Fragment, null, filteredOptions.length > 0 && ___EmotionJSX(MenuItemDivider, null), ___EmotionJSX(Combobox.Option, {
274
217
  value: newOption
275
- }, function (_ref5) {
276
- var active = _ref5.active;
277
- var isActive = active;
218
+ }, _ref5 => {
219
+ let {
220
+ active
221
+ } = _ref5;
222
+ const isActive = active;
278
223
  return ___EmotionJSX("li", {
279
224
  className: "autocompleteMenuItem",
280
225
  style: {