@flodesk/grain 10.17.4 → 10.19.0

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 (83) hide show
  1. package/es/components/arrange.js +74 -34
  2. package/es/components/autocomplete.js +132 -28
  3. package/es/components/autocomplete2.js +359 -0
  4. package/es/components/badge.js +7 -8
  5. package/es/components/box.js +85 -14
  6. package/es/components/box2.js +223 -0
  7. package/es/components/button.js +8 -26
  8. package/es/components/checkbox.js +12 -18
  9. package/es/components/dropdown.js +81 -28
  10. package/es/components/flex.js +72 -36
  11. package/es/components/index.js +5 -1
  12. package/es/components/link.js +27 -16
  13. package/es/components/modal.js +89 -68
  14. package/es/components/nav.js +9 -19
  15. package/es/components/pagination.js +4 -4
  16. package/es/components/popover.js +33 -12
  17. package/es/components/provider.js +14 -0
  18. package/es/components/select.js +12 -10
  19. package/es/components/slider.js +6 -17
  20. package/es/components/spinner.js +4 -14
  21. package/es/components/stack.js +5 -4
  22. package/es/components/switch.js +5 -17
  23. package/es/components/tab.js +1 -1
  24. package/es/components/text-button.js +13 -12
  25. package/es/components/text-input.js +64 -47
  26. package/es/components/text.js +84 -28
  27. package/es/components/text2/index.js +100 -0
  28. package/es/components/text2/styles.module.css +22 -0
  29. package/es/components/textarea.js +34 -20
  30. package/es/components/toast.js +16 -53
  31. package/es/components/tooltip.js +4 -4
  32. package/es/foundational/field.js +52 -28
  33. package/es/foundational/menu.js +138 -60
  34. package/es/foundational/styles.js +11 -11
  35. package/es/hooks/index.js +2 -1
  36. package/es/hooks/useOnClickOutside.js +7 -6
  37. package/es/hooks/usePrev.js +8 -0
  38. package/es/icons/icon-archive.js +21 -0
  39. package/es/icons/icon-at.js +21 -0
  40. package/es/icons/icon-bold.js +28 -0
  41. package/es/icons/icon-bullet-list.js +21 -0
  42. package/es/icons/icon-column-and-rows.js +21 -0
  43. package/es/icons/icon-columns-and-row.js +21 -0
  44. package/es/icons/icon-columns.js +21 -0
  45. package/es/icons/icon-folder-move.js +21 -0
  46. package/es/icons/icon-folder-remove.js +21 -0
  47. package/es/icons/icon-italic.js +28 -0
  48. package/es/icons/icon-number-list.js +21 -0
  49. package/es/icons/icon-row-and-columns.js +21 -0
  50. package/es/icons/icon-rows-and-column.js +21 -0
  51. package/es/icons/icon-rows.js +21 -0
  52. package/es/icons/icon-strike.js +28 -0
  53. package/es/icons/icon-text-justify.js +21 -0
  54. package/es/icons/icon-underline.js +28 -0
  55. package/es/icons/index.js +18 -1
  56. package/es/index.js +2 -1
  57. package/es/styles/base.js +2 -0
  58. package/es/styles/colors/core.js +2 -0
  59. package/es/styles/colors/experimental.js +2 -0
  60. package/es/styles/colors/index.js +4 -0
  61. package/es/styles/colors/theme.js +2 -0
  62. package/es/styles/index.js +6 -0
  63. package/es/styles/shadows.js +2 -0
  64. package/es/styles/utilities.js +108 -0
  65. package/es/styles/variables.js +2 -0
  66. package/es/types.js +18 -7
  67. package/es/utilities/attributes.js +66 -0
  68. package/es/utilities/helpers.js +13 -1
  69. package/es/utilities/index.js +3 -1
  70. package/es/utilities/responsive.js +3 -0
  71. package/es/utilities/style-config.js +442 -0
  72. package/es/utilities/styles.js +14 -2
  73. package/es/variables/breakpoints.js +9 -0
  74. package/es/variables/colors.js +2 -1
  75. package/es/variables/index.js +2 -1
  76. package/es/variables/vars.js +3 -0
  77. package/package.json +1 -1
  78. package/es/styles/base.css +0 -53
  79. package/es/styles/colors/core.css +0 -74
  80. package/es/styles/colors/experimental.css +0 -3
  81. package/es/styles/colors/theme.css +0 -92
  82. package/es/styles/shadows.css +0 -60
  83. package/es/styles/variables.css +0 -66
@@ -1,8 +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.object.assign.js";
5
- var _excluded = ["children", "gap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "rows", "autoFlow", "width", "height"];
1
+ import _styled from "@emotion/styled/base";
2
+ var _excluded = ["children", "gap", "columnGap", "rowGap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "rows", "autoFlow"];
6
3
 
7
4
  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); }
8
5
 
@@ -10,42 +7,85 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
7
 
11
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
9
 
13
- import { getResponsiveDimension, getResponsiveOneOf, getResponsiveSpace } from '../utilities';
10
+ import "core-js/modules/es.array.includes.js";
11
+ import "core-js/modules/es.string.includes.js";
12
+ import "core-js/modules/es.object.keys.js";
13
+ import "core-js/modules/es.array.concat.js";
14
+ import "core-js/modules/es.array.index-of.js";
15
+ import "core-js/modules/es.symbol.js";
16
+ import "core-js/modules/es.object.assign.js";
17
+ import { getResponsiveOneOf, getResponsiveSpace } from '../utilities';
14
18
  import React, { forwardRef } from 'react';
15
- import { css } from '@emotion/react';
16
19
  import { types } from '../types';
20
+ import { Box } from './box';
17
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
18
- export var Arrange = /*#__PURE__*/forwardRef(function (_ref, ref) {
19
- var children = _ref.children,
20
- gap = _ref.gap,
21
- _ref$alignItems = _ref.alignItems,
22
- alignItems = _ref$alignItems === void 0 ? 'center' : _ref$alignItems,
23
- justifyItems = _ref.justifyItems,
24
- _ref$justifyContent = _ref.justifyContent,
25
- justifyContent = _ref$justifyContent === void 0 ? 'start' : _ref$justifyContent,
26
- alignContent = _ref.alignContent,
27
- columns = _ref.columns,
28
- rows = _ref.rows,
29
- _ref$autoFlow = _ref.autoFlow,
30
- autoFlow = _ref$autoFlow === void 0 ? 'column' : _ref$autoFlow,
31
- width = _ref.width,
32
- height = _ref.height,
33
- props = _objectWithoutProperties(_ref, _excluded);
34
-
35
- return ___EmotionJSX("div", _extends({
36
- ref: ref,
37
- css: /*#__PURE__*/css("display:grid;", !columns && getResponsiveOneOf('grid-auto-flow', autoFlow), ";", getResponsiveSpace('gap', gap), ";", getResponsiveOneOf('grid-template-columns', columns), ";", getResponsiveOneOf('grid-template-rows', rows), ";", getResponsiveOneOf('justify-items', justifyItems), ";", getResponsiveOneOf('align-items', alignItems), ";", getResponsiveOneOf('justify-content', justifyContent), ";", getResponsiveOneOf('align-content', alignContent), ";", getResponsiveDimension('width', width), ";", getResponsiveDimension('height', height), ";" + (process.env.NODE_ENV === "production" ? "" : ";label:Arrange;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21wb25lbnRzL2FycmFuZ2UuanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXlCYyIsImZpbGUiOiIuLi8uLi9zcmMvY29tcG9uZW50cy9hcnJhbmdlLmpzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGdldFJlc3BvbnNpdmVEaW1lbnNpb24sIGdldFJlc3BvbnNpdmVPbmVPZiwgZ2V0UmVzcG9uc2l2ZVNwYWNlIH0gZnJvbSAnLi4vdXRpbGl0aWVzJztcbmltcG9ydCBSZWFjdCwgeyBmb3J3YXJkUmVmIH0gZnJvbSAncmVhY3QnO1xuaW1wb3J0IHsgY3NzIH0gZnJvbSAnQGVtb3Rpb24vcmVhY3QnO1xuaW1wb3J0IHsgdHlwZXMgfSBmcm9tICcuLi90eXBlcyc7XG5cbmV4cG9ydCBjb25zdCBBcnJhbmdlID0gZm9yd2FyZFJlZihcbiAgKFxuICAgIHtcbiAgICAgIGNoaWxkcmVuLFxuIC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VEaW1lbnNpb24oJ3dpZHRoJywgd2lkdGgpfTtcbiAgICAgICAgJHtnZXRSZXNwb25zaXZlRGltZW5zaW9uKCdoZWlnaHQnLCBoZWlnaHQpfTtcbiAgICAgIGB9XG4gICAgICB7Li4ucHJvcHN9XG4gICAgPlxuICAgICAge2NoaWxkcmVufVxuICAgIDwvZGl2PlxuICApLFxuKTtcblxuQXJyYW5nZS5wcm9wVHlwZXMgPSB7XG4gIGdhcDogdHlwZXMucmVzcG9uc2l2ZVNwYWNlLFxuICBjb2x1bW5zOiB0eXBlcy5yZXNwb25zaXZlQ29sdW1ucyxcbiAgcm93czogdHlwZXMucmVzcG9uc2l2ZVJvd3MsXG4gIGF1dG9GbG93OiB0eXBlcy5hdXRvRmxvdyxcbiAgYWxpZ25JdGVtczogdHlwZXMuZ3JpZEl0ZW1zQWxpZ25tZW50LFxuICBqdXN0aWZ5SXRlbXM6IHR5cGVzLmdyaWRJdGVtc0FsaWdubWVudCxcbiAganVzdGlmeUNvbnRlbnQ6IHR5cGVzLmdyaWRDb250ZW50UG9zaXRpb24sXG4gIGFsaWduQ29udGVudDogdHlwZXMuZ3JpZENvbnRlbnRQb3NpdGlvbixcbiAgd2lkdGg6IHR5cGVzLnJlc3BvbnNpdmVEaW1lbnNpb24sXG4gIGhlaWdodDogdHlwZXMucmVzcG9uc2l2ZURpbWVuc2lvbixcbn07XG4iXX0= */")
38
- }, props), children);
39
- });
40
- Arrange.propTypes = {
22
+ var gridProps = {
41
23
  gap: types.responsiveSpace,
24
+ columnGap: types.responsiveSpace,
25
+ rowGap: types.responsiveSpace,
42
26
  columns: types.responsiveColumns,
43
27
  rows: types.responsiveRows,
44
28
  autoFlow: types.autoFlow,
45
29
  alignItems: types.gridItemsAlignment,
46
30
  justifyItems: types.gridItemsAlignment,
47
31
  justifyContent: types.gridContentPosition,
48
- alignContent: types.gridContentPosition,
49
- width: types.responsiveDimension,
50
- height: types.responsiveDimension
51
- };
32
+ alignContent: types.gridContentPosition
33
+ };
34
+
35
+ var Root = /*#__PURE__*/_styled(Box, process.env.NODE_ENV === "production" ? {
36
+ shouldForwardProp: function shouldForwardProp(prop) {
37
+ return !Object.keys(gridProps).includes(prop);
38
+ },
39
+ target: "e12ddjtg0"
40
+ } : {
41
+ shouldForwardProp: function shouldForwardProp(prop) {
42
+ return !Object.keys(gridProps).includes(prop);
43
+ },
44
+ target: "e12ddjtg0",
45
+ label: "Root"
46
+ })("display:grid;", function (_ref) {
47
+ var columns = _ref.columns,
48
+ autoFlow = _ref.autoFlow,
49
+ gap = _ref.gap,
50
+ columnGap = _ref.columnGap,
51
+ rowGap = _ref.rowGap,
52
+ rows = _ref.rows,
53
+ justifyItems = _ref.justifyItems,
54
+ alignItems = _ref.alignItems,
55
+ justifyContent = _ref.justifyContent,
56
+ alignContent = _ref.alignContent;
57
+ return "\n ".concat(!columns && getResponsiveOneOf('grid-auto-flow', autoFlow), ";\n ").concat(getResponsiveSpace('gap', gap), ";\n ").concat(getResponsiveSpace('column-gap', columnGap), ";\n ").concat(getResponsiveSpace('row-gap', rowGap), ";\n ").concat(getResponsiveOneOf('grid-template-columns', columns), ";\n ").concat(getResponsiveOneOf('grid-template-rows', rows), ";\n ").concat(getResponsiveOneOf('justify-items', justifyItems), ";\n ").concat(getResponsiveOneOf('align-items', alignItems), ";\n ").concat(getResponsiveOneOf('justify-content', justifyContent), ";\n ").concat(getResponsiveOneOf('align-content', alignContent), ";\n ");
58
+ }, ";" + (process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb21wb25lbnRzL2FycmFuZ2UuanN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXFCRSIsImZpbGUiOiIuLi8uLi9zcmMvY29tcG9uZW50cy9hcnJhbmdlLmpzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGdldFJlc3BvbnNpdmVPbmVP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ZnlJdGVtcyxcbiAgICAgIGp1c3RpZnlDb250ZW50ID0gJ3N0YXJ0JyxcbiAgICAgIGFsaWduQ29udGVudCxcbiAgICAgIGNvbHVtbnMsXG4gICAgICByb3dzLFxuICAgICAgYXV0b0Zsb3cgPSAnY29sdW1uJyxcbiAgICAgIC4uLnByb3BzXG4gICAgfSxcbiAgICByZWYsXG4gICkgPT4gKFxuICAgIDxSb290XG4gICAgICByZWY9e3JlZn1cbiAgICAgIGdhcD17Z2FwfVxuICAgICAgY29sdW1uR2FwPXtjb2x1bW5HYXB9XG4gICAgICByb3dHYXA9e3Jvd0dhcH1cbiAgICAgIGFsaWduSXRlbXM9e2FsaWduSXRlbXN9XG4gICAgICBqdXN0aWZ5SXRlbXM9e2p1c3RpZnlJdGVtc31cbiAgICAgIGp1c3RpZnlDb250ZW50PXtqdXN0aWZ5Q29udGVudH1cbiAgICAgIGFsaWduQ29udGVudD17YWxpZ25Db250ZW50fVxuICAgICAgY29sdW1ucz17Y29sdW1uc31cbiAgICAgIHJvd3M9e3Jvd3N9XG4gICAgICBhdXRvRmxvdz17YXV0b0Zsb3d9XG4gICAgICB7Li4ucHJvcHN9XG4gICAgPlxuICAgICAge2NoaWxkcmVufVxuICAgIDwvUm9vdD5cbiAgKSxcbik7XG5cbkFycmFuZ2UucHJvcFR5cGVzID0gZ3JpZFByb3BzO1xuIl19 */"));
59
+
60
+ export var Arrange = /*#__PURE__*/forwardRef(function (_ref2, ref) {
61
+ var children = _ref2.children,
62
+ gap = _ref2.gap,
63
+ columnGap = _ref2.columnGap,
64
+ rowGap = _ref2.rowGap,
65
+ _ref2$alignItems = _ref2.alignItems,
66
+ alignItems = _ref2$alignItems === void 0 ? 'center' : _ref2$alignItems,
67
+ justifyItems = _ref2.justifyItems,
68
+ _ref2$justifyContent = _ref2.justifyContent,
69
+ justifyContent = _ref2$justifyContent === void 0 ? 'start' : _ref2$justifyContent,
70
+ alignContent = _ref2.alignContent,
71
+ columns = _ref2.columns,
72
+ rows = _ref2.rows,
73
+ _ref2$autoFlow = _ref2.autoFlow,
74
+ autoFlow = _ref2$autoFlow === void 0 ? 'column' : _ref2$autoFlow,
75
+ props = _objectWithoutProperties(_ref2, _excluded);
76
+
77
+ return ___EmotionJSX(Root, _extends({
78
+ ref: ref,
79
+ gap: gap,
80
+ columnGap: columnGap,
81
+ rowGap: rowGap,
82
+ alignItems: alignItems,
83
+ justifyItems: justifyItems,
84
+ justifyContent: justifyContent,
85
+ alignContent: alignContent,
86
+ columns: columns,
87
+ rows: rows,
88
+ autoFlow: autoFlow
89
+ }, props), children);
90
+ });
91
+ Arrange.propTypes = gridProps;
@@ -9,7 +9,7 @@ import "core-js/modules/web.dom-collections.iterator.js";
9
9
  import "core-js/modules/es.array.slice.js";
10
10
  import "core-js/modules/es.array.from.js";
11
11
  import "core-js/modules/es.regexp.exec.js";
12
- var _excluded = ["options", "value", "onChange", "menuPlacement", "menuWidth", "menuMaxHeight", "menuZIndex", "placeholder", "label", "hint", "menuItemsHaveEllipsis", "hasPortal"];
12
+ var _excluded = ["options", "value", "onChange", "isCreatable", "onCreate", "menuPlacement", "menuWidth", "menuMaxHeight", "menuZIndex", "placeholder", "label", "hint", "menuItemsHaveEllipsis", "hasPortal", "hasError", "errorMessage", "searchField"];
13
13
 
14
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
15
15
 
@@ -34,17 +34,20 @@ import "core-js/modules/es.array.filter.js";
34
34
  import "core-js/modules/es.object.to-string.js";
35
35
  import "core-js/modules/es.array.includes.js";
36
36
  import "core-js/modules/es.string.includes.js";
37
+ import "core-js/modules/es.array.concat.js";
37
38
  import "core-js/modules/es.array.find.js";
38
39
  import "core-js/modules/es.array.map.js";
39
40
  import PropTypes from 'prop-types';
40
- import React, { forwardRef, Fragment, useMemo, useState } from 'react';
41
+ import React, { forwardRef, Fragment, useMemo, useRef, useState } from 'react';
41
42
  import { Icon, Box, Text } from '.';
42
- import { IconChevronDown } from '../icons';
43
+ import { IconCheck, IconChevronDown, IconPlus } from '../icons';
43
44
  import { Combobox } from '@headlessui/react';
44
45
  import { defaultProps, types } from '../types';
45
- import { InputField, MenuCard, MenuItem, MenuGroupTitle, FieldLabel, FieldHint } from '../foundational';
46
- import { useMenuPosition } from '../foundational/menu';
46
+ import { InputField, MenuCard, MenuCardTransition, MenuGroupTitle, FieldLabel, FieldHint, componentVars } from '../foundational';
47
+ import { MenuItemDivider, useMenuPosition } from '../foundational/menu';
47
48
  import { FloatingPortal } from '@floating-ui/react-dom-interactions';
49
+ import { Global } from '@emotion/react';
50
+ import { getColor, getRadius } from '../utilities';
48
51
  import { jsx as ___EmotionJSX } from "@emotion/react";
49
52
  var Trigger = /*#__PURE__*/forwardRef(function (_ref, ref) {
50
53
  var props = Object.assign({}, _ref);
@@ -58,7 +61,7 @@ var Trigger = /*#__PURE__*/forwardRef(function (_ref, ref) {
58
61
  var EmptyState = function EmptyState() {
59
62
  return ___EmotionJSX(Box, {
60
63
  paddingY: "s",
61
- paddingX: "m"
64
+ paddingX: "12px"
62
65
  }, ___EmotionJSX(Text, {
63
66
  color: "content2"
64
67
  }, "No results"));
@@ -77,10 +80,10 @@ var ExpandIcon = function ExpandIcon() {
77
80
  }));
78
81
  };
79
82
 
80
- var getFilteredOptions = function getFilteredOptions(query, options) {
83
+ var getFilteredOptions = function getFilteredOptions(query, options, searchField) {
81
84
  if (query === '') return options;
82
85
  return options.filter(function (option) {
83
- return option.content.toLowerCase().includes(query.toLowerCase());
86
+ return option[searchField].toLowerCase().includes(query.toLowerCase());
84
87
  });
85
88
  };
86
89
 
@@ -90,10 +93,13 @@ var getShowGroupTitle = function getShowGroupTitle(index, option, filteredOption
90
93
  return firstOptionHasTitle || titleChanged;
91
94
  };
92
95
 
96
+ 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: ".concat(componentVars.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");
93
97
  export var Autocomplete = function Autocomplete(_ref2) {
94
98
  var options = _ref2.options,
95
99
  value = _ref2.value,
96
100
  onChange = _ref2.onChange,
101
+ isCreatable = _ref2.isCreatable,
102
+ onCreate = _ref2.onCreate,
97
103
  _ref2$menuPlacement = _ref2.menuPlacement,
98
104
  menuPlacement = _ref2$menuPlacement === void 0 ? defaultProps.menuPlacement : _ref2$menuPlacement,
99
105
  menuWidth = _ref2.menuWidth,
@@ -107,6 +113,10 @@ export var Autocomplete = function Autocomplete(_ref2) {
107
113
  menuItemsHaveEllipsis = _ref2$menuItemsHaveEl === void 0 ? true : _ref2$menuItemsHaveEl,
108
114
  _ref2$hasPortal = _ref2.hasPortal,
109
115
  hasPortal = _ref2$hasPortal === void 0 ? true : _ref2$hasPortal,
116
+ hasError = _ref2.hasError,
117
+ errorMessage = _ref2.errorMessage,
118
+ _ref2$searchField = _ref2.searchField,
119
+ searchField = _ref2$searchField === void 0 ? 'content' : _ref2$searchField,
110
120
  props = _objectWithoutProperties(_ref2, _excluded);
111
121
 
112
122
  var _useState = useState(''),
@@ -114,19 +124,44 @@ export var Autocomplete = function Autocomplete(_ref2) {
114
124
  query = _useState2[0],
115
125
  setQuery = _useState2[1];
116
126
 
117
- var handleChange = function handleChange(option) {
127
+ var handleCreatableChange = function handleCreatableChange(option) {
128
+ if (onCreate) {
129
+ var isCreatableOption = !options.find(function (item) {
130
+ return item.value === option.value;
131
+ });
132
+
133
+ if (isCreatableOption) {
134
+ onCreate(option);
135
+ return;
136
+ }
137
+ }
138
+
118
139
  onChange(option);
119
- setQuery('');
120
140
  };
121
141
 
122
- var filteredOptions = getFilteredOptions(query, options);
123
- var noResults = !Boolean(filteredOptions.length);
142
+ var handleChange = function handleChange(option) {
143
+ if (isCreatable) {
144
+ handleCreatableChange(option);
145
+ } else {
146
+ onChange(option);
147
+ }
148
+ };
149
+
150
+ var filteredOptions = getFilteredOptions(query, options, searchField);
151
+ var isShowCreateOption = isCreatable && query.length > 0;
152
+ var noResults = !Boolean(filteredOptions.length) && !isShowCreateOption;
124
153
  var fieldMarginTop = label || hint ? 'betweenFormControlAndLabel' : undefined;
125
154
  var selectedOption = useMemo(function () {
126
155
  return options.find(function (option) {
127
156
  return option.value === value;
128
157
  });
129
158
  }, [options, value]);
159
+ var newOption = useMemo(function () {
160
+ return {
161
+ value: query,
162
+ content: query
163
+ };
164
+ }, [query]);
130
165
 
131
166
  var _useMenuPosition = useMenuPosition({
132
167
  menuWidth: menuWidth,
@@ -137,12 +172,27 @@ export var Autocomplete = function Autocomplete(_ref2) {
137
172
  floatingStyles = _useMenuPosition.floatingStyles;
138
173
 
139
174
  var OptionsRoot = hasPortal ? FloatingPortal : Fragment;
140
- return ___EmotionJSX(Combobox, _extends({
175
+ var preContentRef = useRef(null);
176
+
177
+ var _useState3 = useState(0),
178
+ _useState4 = _slicedToArray(_useState3, 2),
179
+ preContentWidth = _useState4[0],
180
+ setPreContentWidth = _useState4[1];
181
+
182
+ React.useEffect(function () {
183
+ if (preContentRef.current) {
184
+ setPreContentWidth(preContentRef.current.offsetWidth);
185
+ }
186
+ }, [selectedOption, preContentRef]);
187
+ return ___EmotionJSX(React.Fragment, null, ___EmotionJSX(Global, {
188
+ styles: menuItemStyles
189
+ }), ___EmotionJSX(Combobox, _extends({
141
190
  as: "div",
142
191
  value: selectedOption || '',
143
192
  onChange: handleChange
144
193
  }, props), function (_ref3) {
145
194
  var open = _ref3.open;
195
+ var hasPreContent = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.preContent;
146
196
  return ___EmotionJSX(React.Fragment, null, label && ___EmotionJSX(Combobox.Label, {
147
197
  as: FieldLabel
148
198
  }, label), hint && ___EmotionJSX(FieldHint, null, hint), ___EmotionJSX(Box, {
@@ -151,7 +201,16 @@ export var Autocomplete = function Autocomplete(_ref2) {
151
201
  ref: reference
152
202
  }, ___EmotionJSX(Combobox.Button, {
153
203
  as: Trigger
154
- }, ___EmotionJSX(Combobox.Input, {
204
+ }, hasPreContent && !open && ___EmotionJSX(Box, {
205
+ ref: preContentRef,
206
+ width: "fit-content",
207
+ position: "absolute",
208
+ top: "0px",
209
+ bottom: "0px",
210
+ margin: "auto",
211
+ height: "fit-content",
212
+ left: "0"
213
+ }, selectedOption.preContent), ___EmotionJSX(Combobox.Input, {
155
214
  as: InputField,
156
215
  autoComplete: "off",
157
216
  onChange: function onChange(event) {
@@ -161,17 +220,23 @@ export var Autocomplete = function Autocomplete(_ref2) {
161
220
  displayValue: function displayValue(option) {
162
221
  return option && option.content;
163
222
  },
164
- paddingRight: "32px"
165
- }), ___EmotionJSX(ExpandIcon, null)), ___EmotionJSX(OptionsRoot, null, ___EmotionJSX(Combobox.Options, {
223
+ paddingRight: "32px",
224
+ paddingLeft: !open && hasPreContent ? "".concat(preContentWidth + 8, "px") : undefined,
225
+ hasError: hasError
226
+ }), ___EmotionJSX(ExpandIcon, null)), ___EmotionJSX(OptionsRoot, null, ___EmotionJSX(MenuCardTransition, {
227
+ afterLeave: function afterLeave() {
228
+ return setQuery('');
229
+ }
230
+ }, ___EmotionJSX(Combobox.Options, {
166
231
  static: true,
167
- isOpen: open,
168
232
  className: "grn-context",
169
233
  ref: floating,
170
234
  placement: menuPlacement,
171
235
  maxHeight: menuMaxHeight,
172
236
  as: MenuCard,
173
237
  zIndex: menuZIndex,
174
- style: floatingStyles
238
+ style: floatingStyles,
239
+ isDisabled: !open
175
240
  }, filteredOptions.map(function (option, index) {
176
241
  var showGroupTitle = getShowGroupTitle(index, option, filteredOptions);
177
242
  return ___EmotionJSX(Fragment, {
@@ -184,22 +249,59 @@ export var Autocomplete = function Autocomplete(_ref2) {
184
249
  disabled: option.isDisabled
185
250
  }, function (_ref4) {
186
251
  var active = _ref4.active;
187
- return ___EmotionJSX(MenuItem, {
188
- isSelected: option.value === value,
189
- isActive: !option.isDisabled && active,
190
- isDisabled: option.isDisabled,
191
- hasEllipsis: menuItemsHaveEllipsis
192
- }, option.content);
252
+ var isDisabled = option.isDisabled;
253
+ var isSelected = option.value === value;
254
+ var isActive = !option.isDisabled && active;
255
+ var hasEllipsis = menuItemsHaveEllipsis;
256
+ var hasPreContent = option.preContent;
257
+ return ___EmotionJSX("li", {
258
+ className: hasPreContent ? 'autocompleteMenuItem hasPreContent' : 'autocompleteMenuItem',
259
+ style: {
260
+ backgroundColor: isActive && getColor('fade1'),
261
+ color: isDisabled && getColor('disabledContent'),
262
+ cursor: !isDisabled && 'pointer'
263
+ }
264
+ }, hasPreContent && option.preContent, ___EmotionJSX("span", {
265
+ className: hasEllipsis ? 'autocompleteMenuItemText hasEllipsis' : 'autocompleteMenuItemText'
266
+ }, option.content), ___EmotionJSX(Icon, {
267
+ style: {
268
+ opacity: isSelected ? 1 : 0
269
+ },
270
+ icon: ___EmotionJSX(IconCheck, null),
271
+ color: isActive ? 'content' : 'icon'
272
+ }));
193
273
  }));
194
- }), noResults && ___EmotionJSX(EmptyState, null)))));
195
- });
274
+ }), isShowCreateOption && ___EmotionJSX(React.Fragment, null, filteredOptions.length > 0 && ___EmotionJSX(MenuItemDivider, null), ___EmotionJSX(Combobox.Option, {
275
+ value: newOption
276
+ }, function (_ref5) {
277
+ var active = _ref5.active;
278
+ var isActive = active;
279
+ return ___EmotionJSX("li", {
280
+ className: "autocompleteMenuItem",
281
+ style: {
282
+ backgroundColor: isActive && getColor('fade1'),
283
+ cursor: 'pointer'
284
+ }
285
+ }, ___EmotionJSX(Icon, {
286
+ icon: ___EmotionJSX(IconPlus, null),
287
+ color: isActive ? 'content' : 'icon'
288
+ }), ___EmotionJSX("span", {
289
+ className: "autocompleteMenuItemText hasEllipsis"
290
+ }, "Create ", "\"" + query + "\""));
291
+ })), noResults && ___EmotionJSX(EmptyState, null))))), errorMessage && ___EmotionJSX(Box, {
292
+ marginTop: "betweenFormControlAndLabel",
293
+ color: "danger"
294
+ }, errorMessage));
295
+ }));
196
296
  };
197
297
  Autocomplete.Label = FieldLabel;
198
298
  Autocomplete.Hint = FieldHint;
199
299
  Autocomplete.propTypes = {
200
300
  options: PropTypes.array,
201
- value: PropTypes.string.isRequired,
301
+ value: PropTypes.string,
202
302
  onChange: PropTypes.func.isRequired,
303
+ isCreatable: PropTypes.bool,
304
+ onCreate: PropTypes.func,
203
305
  menuPlacement: types.menuPlacement,
204
306
  menuWidth: types.dimension,
205
307
  menuMaxHeight: types.dimension,
@@ -207,5 +309,7 @@ Autocomplete.propTypes = {
207
309
  label: types.label,
208
310
  hint: types.hint,
209
311
  menuItemsHaveEllipsis: PropTypes.bool,
210
- hasPortal: PropTypes.bool
312
+ hasPortal: PropTypes.bool,
313
+ hasError: PropTypes.bool,
314
+ errorMessage: PropTypes.string
211
315
  };