@flodesk/grain 5.8.2 → 5.9.2

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.
@@ -1,44 +1,25 @@
1
- import "core-js/modules/es.array.slice.js";
2
- import "core-js/modules/es.object.freeze.js";
3
- import "core-js/modules/es.object.define-properties.js";
4
1
  import "core-js/modules/es.object.keys.js";
5
2
  import "core-js/modules/es.array.index-of.js";
6
3
  import "core-js/modules/es.symbol.js";
7
- var _excluded = ["children", "gap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "autoFlow", "width", "height"];
4
+ import "core-js/modules/es.array.slice.js";
5
+ import "core-js/modules/es.object.freeze.js";
6
+ import "core-js/modules/es.object.define-properties.js";
8
7
 
9
8
  var _templateObject;
10
9
 
10
+ var _excluded = ["children", "gap", "alignItems", "justifyItems", "justifyContent", "alignContent", "columns", "autoFlow", "width", "height"];
11
11
  import "core-js/modules/es.object.assign.js";
12
12
 
13
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
14
+
13
15
  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; }
14
16
 
15
17
  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; }
16
18
 
17
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
-
19
19
  import { getResponsiveDimension, getResponsiveGridColumns, getResponsiveSpace } from '../utilities';
20
20
  import React from 'react';
21
- import styled from '@emotion/styled';
21
+ import { css } from '@emotion/react';
22
22
  import { types } from '../types';
23
- var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n ", ";\n ", ";\n ", ";\n justify-items: ", ";\n align-items: ", ";\n justify-content: ", ";\n align-content: ", ";\n ", ";\n ", ";\n"])), function (p) {
24
- return !p.columns && "grid-auto-flow: ".concat(p.autoFlow);
25
- }, function (p) {
26
- return getResponsiveSpace('gap', p.gap);
27
- }, function (p) {
28
- return getResponsiveGridColumns(p.columns);
29
- }, function (p) {
30
- return p.justifyItems;
31
- }, function (p) {
32
- return p.alignItems;
33
- }, function (p) {
34
- return p.justifyContent;
35
- }, function (p) {
36
- return p.alignContent;
37
- }, function (p) {
38
- return getResponsiveDimension('width', p.width);
39
- }, function (p) {
40
- return getResponsiveDimension('height', p.height);
41
- });
42
23
  export var Arrange = function Arrange(_ref) {
43
24
  var children = _ref.children,
44
25
  gap = _ref.gap,
@@ -55,16 +36,8 @@ export var Arrange = function Arrange(_ref) {
55
36
  height = _ref.height,
56
37
  props = _objectWithoutProperties(_ref, _excluded);
57
38
 
58
- return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
59
- gap: gap,
60
- columns: columns,
61
- autoFlow: autoFlow,
62
- alignItems: alignItems,
63
- justifyItems: justifyItems,
64
- justifyContent: justifyContent,
65
- alignContent: alignContent,
66
- width: width,
67
- height: height
39
+ return /*#__PURE__*/React.createElement("div", Object.assign({
40
+ css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: grid;\n ", ";\n ", ";\n ", ";\n justify-items: ", ";\n align-items: ", ";\n justify-content: ", ";\n align-content: ", ";\n ", ";\n ", ";\n "])), !columns && "grid-auto-flow: ".concat(autoFlow), getResponsiveSpace('gap', gap), getResponsiveGridColumns(columns), justifyItems, alignItems, justifyContent, alignContent, getResponsiveDimension('width', width), getResponsiveDimension('height', height))
68
41
  }, props), children);
69
42
  };
70
43
  Arrange.propTypes = {
@@ -0,0 +1,147 @@
1
+ import "core-js/modules/es.array.slice.js";
2
+ import "core-js/modules/es.object.freeze.js";
3
+ import "core-js/modules/es.object.define-properties.js";
4
+ import "core-js/modules/es.symbol.js";
5
+ import "core-js/modules/es.symbol.description.js";
6
+ import "core-js/modules/es.symbol.iterator.js";
7
+ import "core-js/modules/es.array.iterator.js";
8
+ import "core-js/modules/es.string.iterator.js";
9
+ import "core-js/modules/web.dom-collections.iterator.js";
10
+ import "core-js/modules/es.array.from.js";
11
+ import "core-js/modules/es.regexp.exec.js";
12
+
13
+ var _templateObject;
14
+
15
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+
17
+ 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."); }
18
+
19
+ 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); }
20
+
21
+ 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; }
22
+
23
+ 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; }
24
+
25
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
+
27
+ import "core-js/modules/es.object.assign.js";
28
+ import "core-js/modules/es.array.filter.js";
29
+ import "core-js/modules/es.object.to-string.js";
30
+ import "core-js/modules/es.array.includes.js";
31
+ import "core-js/modules/es.string.includes.js";
32
+ import "core-js/modules/es.array.map.js";
33
+
34
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
35
+
36
+ import PropTypes from 'prop-types';
37
+ import React, { forwardRef, useState } from 'react';
38
+ import styled from '@emotion/styled';
39
+ import { Icon, Box, Text } from '.';
40
+ import { IconChevronDown } from '../icons';
41
+ import { Combobox } from '@headlessui/react';
42
+ import { types } from '../types';
43
+ import { fieldStyles, fieldXPadding, focusFieldStyles, Menu, MenuItem } from '../foundational';
44
+ var Input = styled(Combobox.Input)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n ", ";\n"])), fieldStyles({
45
+ paddingRight: '32px'
46
+ }), focusFieldStyles);
47
+
48
+ var Root = function Root(_ref) {
49
+ var props = Object.assign({}, _ref);
50
+ return /*#__PURE__*/React.createElement(Box, Object.assign({}, props, {
51
+ position: "relative"
52
+ }));
53
+ };
54
+
55
+ var Trigger = /*#__PURE__*/forwardRef(function (_ref2, ref) {
56
+ var props = Object.assign({}, _ref2);
57
+ return /*#__PURE__*/React.createElement(Box, Object.assign({
58
+ ref: ref
59
+ }, props, {
60
+ position: "relative"
61
+ }));
62
+ });
63
+
64
+ var EmptyState = function EmptyState() {
65
+ return /*#__PURE__*/React.createElement(Box, {
66
+ padding: "s"
67
+ }, /*#__PURE__*/React.createElement(Text, {
68
+ color: "content2"
69
+ }, "No results"));
70
+ };
71
+
72
+ export var Autocomplete = function Autocomplete(_ref3) {
73
+ var options = _ref3.options,
74
+ defaultOption = _ref3.defaultOption,
75
+ onChange = _ref3.onChange,
76
+ _ref3$menuAlign = _ref3.menuAlign,
77
+ menuAlign = _ref3$menuAlign === void 0 ? 'left' : _ref3$menuAlign,
78
+ _ref3$menuWidth = _ref3.menuWidth,
79
+ menuWidth = _ref3$menuWidth === void 0 ? '240px' : _ref3$menuWidth,
80
+ placeholder = _ref3.placeholder;
81
+
82
+ var _useState = useState(defaultOption ? defaultOption : ''),
83
+ _useState2 = _slicedToArray(_useState, 2),
84
+ selectedOption = _useState2[0],
85
+ setSelectedOption = _useState2[1];
86
+
87
+ var _useState3 = useState(''),
88
+ _useState4 = _slicedToArray(_useState3, 2),
89
+ query = _useState4[0],
90
+ setQuery = _useState4[1];
91
+
92
+ var handleChange = function handleChange(option) {
93
+ setSelectedOption(option);
94
+ onChange && onChange(option);
95
+ setQuery('');
96
+ };
97
+
98
+ var filteredOptions = query === '' ? options : options.filter(function (option) {
99
+ return option.toLowerCase().includes(query.toLowerCase());
100
+ });
101
+ return /*#__PURE__*/React.createElement(Combobox, {
102
+ as: Root,
103
+ value: selectedOption,
104
+ onChange: handleChange
105
+ }, /*#__PURE__*/React.createElement(Combobox.Button, {
106
+ as: Trigger
107
+ }, /*#__PURE__*/React.createElement(Input, {
108
+ autoComplete: "off",
109
+ onChange: function onChange(event) {
110
+ return setQuery(event.target.value);
111
+ },
112
+ placeholder: placeholder
113
+ }), /*#__PURE__*/React.createElement(Box, {
114
+ right: fieldXPadding,
115
+ position: "absolute",
116
+ top: "0px",
117
+ bottom: "0px",
118
+ margin: "auto",
119
+ height: "fit-content"
120
+ }, /*#__PURE__*/React.createElement(Icon, {
121
+ icon: /*#__PURE__*/React.createElement(IconChevronDown, null)
122
+ }))), /*#__PURE__*/React.createElement(Combobox.Options, {
123
+ menuAlign: menuAlign,
124
+ menuWidth: menuWidth,
125
+ as: Menu
126
+ }, filteredOptions.map(function (option, index) {
127
+ return /*#__PURE__*/React.createElement(Combobox.Option, {
128
+ key: index,
129
+ value: option,
130
+ as: React.Fragment
131
+ }, function (_ref4) {
132
+ var active = _ref4.active,
133
+ selected = _ref4.selected;
134
+ return /*#__PURE__*/React.createElement(MenuItem, {
135
+ isSelected: selected,
136
+ isActive: active
137
+ }, option);
138
+ });
139
+ }), !Boolean(filteredOptions.length) && /*#__PURE__*/React.createElement(EmptyState, null)));
140
+ };
141
+ Autocomplete.propTypes = {
142
+ options: PropTypes.array,
143
+ defaultOption: PropTypes.string,
144
+ onChange: PropTypes.func,
145
+ menuAlign: PropTypes.oneOf(['left', 'right']),
146
+ menuWidth: types.dimension
147
+ };
@@ -1,227 +1,72 @@
1
- import "core-js/modules/es.array.slice.js";
2
- import "core-js/modules/es.object.freeze.js";
3
- import "core-js/modules/es.object.define-properties.js";
4
1
  import "core-js/modules/es.object.keys.js";
5
2
  import "core-js/modules/es.array.index-of.js";
6
3
  import "core-js/modules/es.symbol.js";
7
- var _excluded = ["borderSide", "borderWidth", "borderColor", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "top", "bottom", "left", "right", "width", "minWidth", "maxWidth", "height", "minHeight", "maxHeight", "color", "backgroundColor", "position", "radius", "shadow", "overflow", "aspectRatio", "zIndex"],
8
- _excluded2 = ["children", "color", "backgroundColor", "borderColor", "borderWidth", "borderSide", "width", "minWidth", "maxWidth", "height", "minHeight", "maxHeight", "radius", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "paddingX", "paddingY", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "marginX", "marginY", "position", "top", "bottom", "left", "right", "shadow", "overflow", "aspectRatio", "zIndex"];
4
+ import "core-js/modules/es.array.slice.js";
5
+ import "core-js/modules/es.object.freeze.js";
6
+ import "core-js/modules/es.object.define-properties.js";
9
7
 
10
8
  var _templateObject;
11
9
 
10
+ var _excluded = ["children", "color", "backgroundColor", "borderColor", "borderWidth", "borderSide", "width", "minWidth", "maxWidth", "height", "minHeight", "maxHeight", "radius", "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight", "paddingX", "paddingY", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "marginX", "marginY", "position", "top", "bottom", "left", "right", "shadow", "overflow", "aspectRatio", "zIndex"];
12
11
  import "core-js/modules/es.object.assign.js";
13
12
 
13
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
14
+
14
15
  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; }
15
16
 
16
17
  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; }
17
18
 
18
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
19
-
20
19
  import { getBorder, getColor, getRadius, getResponsiveSpace, getShadow, getResponsiveDimension } from '../utilities';
21
- import React from 'react';
22
- import styled from '@emotion/styled';
20
+ import React, { forwardRef } from 'react';
21
+ import { css } from '@emotion/react';
23
22
  import { types } from '../types';
24
23
  import PropTypes from 'prop-types';
25
- var Wrapper = styled(function (_ref) {
26
- var borderSide = _ref.borderSide,
27
- borderWidth = _ref.borderWidth,
28
- borderColor = _ref.borderColor,
24
+ export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
25
+ var children = _ref.children,
26
+ color = _ref.color,
27
+ backgroundColor = _ref.backgroundColor,
28
+ _ref$borderColor = _ref.borderColor,
29
+ borderColor = _ref$borderColor === void 0 ? 'border' : _ref$borderColor,
30
+ _ref$borderWidth = _ref.borderWidth,
31
+ borderWidth = _ref$borderWidth === void 0 ? '1px' : _ref$borderWidth,
32
+ borderSide = _ref.borderSide,
33
+ width = _ref.width,
34
+ minWidth = _ref.minWidth,
35
+ maxWidth = _ref.maxWidth,
36
+ height = _ref.height,
37
+ minHeight = _ref.minHeight,
38
+ maxHeight = _ref.maxHeight,
39
+ radius = _ref.radius,
29
40
  padding = _ref.padding,
30
41
  paddingTop = _ref.paddingTop,
31
42
  paddingBottom = _ref.paddingBottom,
32
43
  paddingLeft = _ref.paddingLeft,
33
44
  paddingRight = _ref.paddingRight,
45
+ paddingX = _ref.paddingX,
46
+ paddingY = _ref.paddingY,
34
47
  margin = _ref.margin,
35
48
  marginTop = _ref.marginTop,
36
49
  marginBottom = _ref.marginBottom,
37
50
  marginLeft = _ref.marginLeft,
38
51
  marginRight = _ref.marginRight,
52
+ marginX = _ref.marginX,
53
+ marginY = _ref.marginY,
54
+ position = _ref.position,
39
55
  top = _ref.top,
40
56
  bottom = _ref.bottom,
41
57
  left = _ref.left,
42
58
  right = _ref.right,
43
- width = _ref.width,
44
- minWidth = _ref.minWidth,
45
- maxWidth = _ref.maxWidth,
46
- height = _ref.height,
47
- minHeight = _ref.minHeight,
48
- maxHeight = _ref.maxHeight,
49
- color = _ref.color,
50
- backgroundColor = _ref.backgroundColor,
51
- position = _ref.position,
52
- radius = _ref.radius,
53
59
  shadow = _ref.shadow,
54
60
  overflow = _ref.overflow,
55
61
  aspectRatio = _ref.aspectRatio,
56
62
  zIndex = _ref.zIndex,
57
- rest = _objectWithoutProperties(_ref, _excluded);
58
-
59
- return /*#__PURE__*/React.createElement("div", rest);
60
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n color: ", ";\n background-color: ", ";\n\n position: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: ", ";\n aspect-ratio: ", ";\n ", ";\n"])), function (_ref2) {
61
- var borderSide = _ref2.borderSide,
62
- borderWidth = _ref2.borderWidth,
63
- borderColor = _ref2.borderColor;
64
- return getBorder(borderSide, borderWidth, borderColor);
65
- }, function (_ref3) {
66
- var padding = _ref3.padding;
67
- return getResponsiveSpace('padding', padding);
68
- }, function (_ref4) {
69
- var paddingTop = _ref4.paddingTop;
70
- return getResponsiveSpace('padding-top', paddingTop);
71
- }, function (_ref5) {
72
- var paddingBottom = _ref5.paddingBottom;
73
- return getResponsiveSpace('padding-bottom', paddingBottom);
74
- }, function (_ref6) {
75
- var paddingLeft = _ref6.paddingLeft;
76
- return getResponsiveSpace('padding-left', paddingLeft);
77
- }, function (_ref7) {
78
- var paddingRight = _ref7.paddingRight;
79
- return getResponsiveSpace('padding-right', paddingRight);
80
- }, function (_ref8) {
81
- var margin = _ref8.margin;
82
- return getResponsiveSpace('margin', margin);
83
- }, function (_ref9) {
84
- var marginTop = _ref9.marginTop;
85
- return getResponsiveSpace('margin-top', marginTop);
86
- }, function (_ref10) {
87
- var marginBottom = _ref10.marginBottom;
88
- return getResponsiveSpace('margin-bottom', marginBottom);
89
- }, function (_ref11) {
90
- var marginLeft = _ref11.marginLeft;
91
- return getResponsiveSpace('margin-left', marginLeft);
92
- }, function (_ref12) {
93
- var marginRight = _ref12.marginRight;
94
- return getResponsiveSpace('margin-right', marginRight);
95
- }, function (_ref13) {
96
- var top = _ref13.top;
97
- return getResponsiveSpace('top', top);
98
- }, function (_ref14) {
99
- var bottom = _ref14.bottom;
100
- return getResponsiveSpace('bottom', bottom);
101
- }, function (_ref15) {
102
- var left = _ref15.left;
103
- return getResponsiveSpace('left', left);
104
- }, function (_ref16) {
105
- var right = _ref16.right;
106
- return getResponsiveSpace('right', right);
107
- }, function (_ref17) {
108
- var width = _ref17.width;
109
- return getResponsiveDimension('width', width);
110
- }, function (_ref18) {
111
- var minWidth = _ref18.minWidth;
112
- return getResponsiveDimension('min-width', minWidth);
113
- }, function (_ref19) {
114
- var maxWidth = _ref19.maxWidth;
115
- return getResponsiveDimension('max-width', maxWidth);
116
- }, function (_ref20) {
117
- var height = _ref20.height;
118
- return getResponsiveDimension('height', height);
119
- }, function (_ref21) {
120
- var minHeight = _ref21.minHeight;
121
- return getResponsiveDimension('min-height', minHeight);
122
- }, function (_ref22) {
123
- var maxHeight = _ref22.maxHeight;
124
- return getResponsiveDimension('max-height', maxHeight);
125
- }, function (_ref23) {
126
- var color = _ref23.color;
127
- return getColor(color);
128
- }, function (_ref24) {
129
- var backgroundColor = _ref24.backgroundColor;
130
- return getColor(backgroundColor);
131
- }, function (_ref25) {
132
- var position = _ref25.position;
133
- return position;
134
- }, function (_ref26) {
135
- var radius = _ref26.radius;
136
- return getRadius(radius);
137
- }, function (_ref27) {
138
- var shadow = _ref27.shadow;
139
- return getShadow(shadow);
140
- }, function (_ref28) {
141
- var overflow = _ref28.overflow;
142
- return overflow;
143
- }, function (_ref29) {
144
- var aspectRatio = _ref29.aspectRatio;
145
- return aspectRatio;
146
- }, function (_ref30) {
147
- var zIndex = _ref30.zIndex;
148
- return zIndex && "z-index: ".concat(zIndex);
149
- });
150
- export var Box = function Box(_ref31) {
151
- var children = _ref31.children,
152
- color = _ref31.color,
153
- backgroundColor = _ref31.backgroundColor,
154
- _ref31$borderColor = _ref31.borderColor,
155
- borderColor = _ref31$borderColor === void 0 ? 'border' : _ref31$borderColor,
156
- _ref31$borderWidth = _ref31.borderWidth,
157
- borderWidth = _ref31$borderWidth === void 0 ? '1px' : _ref31$borderWidth,
158
- borderSide = _ref31.borderSide,
159
- width = _ref31.width,
160
- minWidth = _ref31.minWidth,
161
- maxWidth = _ref31.maxWidth,
162
- height = _ref31.height,
163
- minHeight = _ref31.minHeight,
164
- maxHeight = _ref31.maxHeight,
165
- radius = _ref31.radius,
166
- padding = _ref31.padding,
167
- paddingTop = _ref31.paddingTop,
168
- paddingBottom = _ref31.paddingBottom,
169
- paddingLeft = _ref31.paddingLeft,
170
- paddingRight = _ref31.paddingRight,
171
- paddingX = _ref31.paddingX,
172
- paddingY = _ref31.paddingY,
173
- margin = _ref31.margin,
174
- marginTop = _ref31.marginTop,
175
- marginBottom = _ref31.marginBottom,
176
- marginLeft = _ref31.marginLeft,
177
- marginRight = _ref31.marginRight,
178
- marginX = _ref31.marginX,
179
- marginY = _ref31.marginY,
180
- position = _ref31.position,
181
- top = _ref31.top,
182
- bottom = _ref31.bottom,
183
- left = _ref31.left,
184
- right = _ref31.right,
185
- shadow = _ref31.shadow,
186
- overflow = _ref31.overflow,
187
- aspectRatio = _ref31.aspectRatio,
188
- zIndex = _ref31.zIndex,
189
- props = _objectWithoutProperties(_ref31, _excluded2);
63
+ props = _objectWithoutProperties(_ref, _excluded);
190
64
 
191
- return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
192
- backgroundColor: backgroundColor,
193
- color: color,
194
- borderSide: borderSide,
195
- borderWidth: borderWidth,
196
- borderColor: borderColor,
197
- width: width,
198
- minWidth: minWidth,
199
- maxWidth: maxWidth,
200
- height: height,
201
- minHeight: minHeight,
202
- maxHeight: maxHeight,
203
- radius: radius,
204
- padding: padding,
205
- paddingTop: paddingY || paddingTop,
206
- paddingBottom: paddingY || paddingBottom,
207
- paddingLeft: paddingX || paddingLeft,
208
- paddingRight: paddingX || paddingRight,
209
- margin: margin,
210
- marginTop: marginY || marginTop,
211
- marginBottom: marginY || marginBottom,
212
- marginLeft: marginX || marginLeft,
213
- marginRight: marginX || marginRight,
214
- position: position,
215
- top: top,
216
- bottom: bottom,
217
- left: left,
218
- right: right,
219
- shadow: shadow,
220
- overflow: overflow,
221
- aspectRatio: aspectRatio,
222
- zIndex: zIndex
65
+ return /*#__PURE__*/React.createElement("div", Object.assign({
66
+ ref: ref,
67
+ css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n\n color: ", ";\n background-color: ", ";\n position: ", ";\n border-radius: ", ";\n box-shadow: ", ";\n overflow: ", ";\n aspect-ratio: ", ";\n z-index: ", ";\n "])), getBorder(borderSide, borderWidth, borderColor), getResponsiveSpace('padding', padding), getResponsiveSpace('padding-top', paddingTop || paddingY), getResponsiveSpace('padding-bottom', paddingBottom || paddingY), getResponsiveSpace('padding-left', paddingLeft || paddingX), getResponsiveSpace('padding-right', paddingRight || paddingX), getResponsiveSpace('margin', margin), getResponsiveSpace('margin-top', marginTop || marginY), getResponsiveSpace('margin-bottom', marginBottom || marginY), getResponsiveSpace('margin-left', marginLeft || marginX), getResponsiveSpace('margin-right', marginRight || marginX), getResponsiveSpace('top', top), getResponsiveSpace('bottom', bottom), getResponsiveSpace('left', left), getResponsiveSpace('right', right), getResponsiveDimension('width', width), getResponsiveDimension('min-width', minWidth), getResponsiveDimension('max-width', maxWidth), getResponsiveDimension('height', height), getResponsiveDimension('min-height', minHeight), getResponsiveDimension('max-height', maxHeight), getColor(color), getColor(backgroundColor), position, getRadius(radius), getShadow(shadow), overflow, aspectRatio, zIndex)
223
68
  }, props), children);
224
- };
69
+ });
225
70
  Box.propTypes = {
226
71
  color: types.color,
227
72
  backgroundColor: types.color,
@@ -13,4 +13,5 @@ export { Select } from './select';
13
13
  export { Stack } from './stack';
14
14
  export { Slider } from './slider';
15
15
  export { Spinner } from './spinner';
16
- export { Switch } from './switch';
16
+ export { Switch } from './switch';
17
+ export { Autocomplete } from './autocomplete';
@@ -12,11 +12,9 @@ import "core-js/modules/es.string.iterator.js";
12
12
  import "core-js/modules/web.dom-collections.iterator.js";
13
13
  import "core-js/modules/es.array.from.js";
14
14
  import "core-js/modules/es.regexp.exec.js";
15
- var _excluded = ["menuWidth", "menuAlign"],
16
- _excluded2 = ["children"],
17
- _excluded3 = ["children", "isSelected", "isActive"];
15
+ var _excluded = ["children"];
18
16
 
19
- var _templateObject, _templateObject2, _templateObject3;
17
+ var _templateObject;
20
18
 
21
19
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
20
 
@@ -43,28 +41,16 @@ import PropTypes from 'prop-types';
43
41
  import React, { useState } from 'react';
44
42
  import styled from '@emotion/styled';
45
43
  import { Icon, Box, Text } from '.';
46
- import { IconCheck, IconChevronDown } from '../icons';
44
+ import { IconChevronDown } from '../icons';
47
45
  import { Listbox } from '@headlessui/react';
48
- import { getColor, getDimension, getRadius, getShadow } from '../utilities';
46
+ import { getColor, getRadius } from '../utilities';
49
47
  import { types } from '../types';
50
- var Options = styled(function (_ref) {
51
- var menuWidth = _ref.menuWidth,
52
- menuAlign = _ref.menuAlign,
53
- rest = _objectWithoutProperties(_ref, _excluded);
54
-
55
- return /*#__PURE__*/React.createElement(Listbox.Options, rest);
56
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px;\n margin: 0;\n position: absolute;\n background: white;\n box-shadow: ", ";\n border-radius: ", ";\n max-height: 468px;\n overflow: auto;\n width: ", ";\n ", "\n\n &:focus {\n outline: none;\n }\n"])), getShadow('m'), getRadius('s'), function (_ref2) {
57
- var menuWidth = _ref2.menuWidth;
58
- return getDimension(menuWidth);
59
- }, function (_ref3) {
60
- var menuAlign = _ref3.menuAlign;
61
- return "".concat(menuAlign, ": 0;");
62
- });
63
- var SelectButtonWrapper = styled(Listbox.Button)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n gap: 8px;\n appearance: none;\n border: none;\n background: ", ";\n padding: 0 var(--grn-fieldXPadding);\n min-height: var(--grn-textBoxHeight-m);\n border-radius: ", ";\n font: inherit;\n color: inherit;\n cursor: pointer;\n width: 100%;\n text-align: left;\n"])), getColor('fade1'), getRadius('s'));
64
-
65
- var SelectButton = function SelectButton(_ref4) {
66
- var children = _ref4.children,
67
- props = _objectWithoutProperties(_ref4, _excluded2);
48
+ import { fieldXPadding, Menu, MenuItem, textBoxHeight, transitions } from '../foundational';
49
+ var SelectButtonWrapper = styled(Listbox.Button)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n display: flex;\n align-items: center;\n gap: 8px;\n appearance: none;\n border: none;\n background: ", ";\n padding: 0 ", ";\n min-height: ", ";\n border-radius: ", ";\n font: inherit;\n color: inherit;\n cursor: pointer;\n width: 100%;\n text-align: left;\n\n &:hover {\n background: ", ";\n }\n"])), transitions, getColor('fade1'), fieldXPadding, textBoxHeight, getRadius('s'), getColor('fade2'));
50
+
51
+ var SelectButton = function SelectButton(_ref) {
52
+ var children = _ref.children,
53
+ props = _objectWithoutProperties(_ref, _excluded);
68
54
 
69
55
  return /*#__PURE__*/React.createElement(SelectButtonWrapper, props, /*#__PURE__*/React.createElement(Text, {
70
56
  hasEllipsis: true,
@@ -76,45 +62,23 @@ var SelectButton = function SelectButton(_ref4) {
76
62
  })));
77
63
  };
78
64
 
79
- var MenuItemWrapper = styled.li(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: grid;\n grid-auto-flow: column;\n gap: 8px;\n align-items: center;\n list-style: none;\n padding: 0 1rem;\n min-height: var(--grn-textBoxHeight-m);\n cursor: pointer;\n border-radius: ", ";\n"])), getRadius('s'));
80
- var MenuItem = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
81
- var children = _ref5.children,
82
- isSelected = _ref5.isSelected,
83
- isActive = _ref5.isActive,
84
- props = _objectWithoutProperties(_ref5, _excluded3);
85
-
86
- return /*#__PURE__*/React.createElement(MenuItemWrapper, Object.assign({
87
- ref: ref,
88
- isActive: isActive,
89
- style: {
90
- background: isActive ? getColor('overlay') : undefined
91
- }
92
- }, props), /*#__PURE__*/React.createElement(Text, {
93
- hasEllipsis: true
94
- }, children), isSelected && /*#__PURE__*/React.createElement(Box, {
95
- marginLeft: "auto"
96
- }, /*#__PURE__*/React.createElement(Icon, {
97
- icon: /*#__PURE__*/React.createElement(IconCheck, null)
98
- })));
99
- });
100
-
101
- var SelectRoot = function SelectRoot(_ref6) {
102
- var props = Object.assign({}, _ref6);
65
+ var SelectRoot = function SelectRoot(_ref2) {
66
+ var props = Object.assign({}, _ref2);
103
67
  return /*#__PURE__*/React.createElement(Box, Object.assign({}, props, {
104
68
  position: "relative"
105
69
  }));
106
70
  };
107
71
 
108
- export var Select = function Select(_ref7) {
109
- var options = _ref7.options,
110
- defaultOption = _ref7.defaultOption,
111
- onChange = _ref7.onChange,
112
- _ref7$menuAlign = _ref7.menuAlign,
113
- menuAlign = _ref7$menuAlign === void 0 ? 'left' : _ref7$menuAlign,
114
- _ref7$menuWidth = _ref7.menuWidth,
115
- menuWidth = _ref7$menuWidth === void 0 ? '240px' : _ref7$menuWidth;
72
+ export var Select = function Select(_ref3) {
73
+ var options = _ref3.options,
74
+ defaultOption = _ref3.defaultOption,
75
+ onChange = _ref3.onChange,
76
+ _ref3$menuAlign = _ref3.menuAlign,
77
+ menuAlign = _ref3$menuAlign === void 0 ? 'left' : _ref3$menuAlign,
78
+ _ref3$menuWidth = _ref3.menuWidth,
79
+ menuWidth = _ref3$menuWidth === void 0 ? '240px' : _ref3$menuWidth;
116
80
 
117
- var _useState = useState(defaultOption || {}),
81
+ var _useState = useState(defaultOption || ''),
118
82
  _useState2 = _slicedToArray(_useState, 2),
119
83
  selectedOption = _useState2[0],
120
84
  setSelectedOption = _useState2[1];
@@ -128,27 +92,28 @@ export var Select = function Select(_ref7) {
128
92
  as: SelectRoot,
129
93
  value: selectedOption,
130
94
  onChange: handleChange
131
- }, /*#__PURE__*/React.createElement(SelectButton, null, selectedOption.content), /*#__PURE__*/React.createElement(Options, {
95
+ }, /*#__PURE__*/React.createElement(SelectButton, null, selectedOption), /*#__PURE__*/React.createElement(Listbox.Options, {
132
96
  menuAlign: menuAlign,
133
- menuWidth: menuWidth
134
- }, options.map(function (option) {
97
+ menuWidth: menuWidth,
98
+ as: Menu
99
+ }, options.map(function (option, index) {
135
100
  return /*#__PURE__*/React.createElement(Listbox.Option, {
136
- key: option.id,
101
+ key: index,
137
102
  value: option,
138
103
  as: React.Fragment
139
- }, function (_ref8) {
140
- var active = _ref8.active,
141
- selected = _ref8.selected;
104
+ }, function (_ref4) {
105
+ var active = _ref4.active,
106
+ selected = _ref4.selected;
142
107
  return /*#__PURE__*/React.createElement(MenuItem, {
143
108
  isSelected: selected,
144
109
  isActive: active
145
- }, option.content);
110
+ }, option);
146
111
  });
147
112
  })));
148
113
  };
149
114
  Select.propTypes = {
150
115
  options: PropTypes.array,
151
- defaultOption: PropTypes.object,
116
+ defaultOption: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
152
117
  onChange: PropTypes.func,
153
118
  menuAlign: PropTypes.oneOf(['left', 'right']),
154
119
  menuWidth: types.dimension
@@ -36,25 +36,25 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
36
36
 
37
37
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
38
38
 
39
- import { getColor, getRadius } from '../utilities';
40
39
  import PropTypes from 'prop-types';
41
40
  import React from 'react';
42
41
  import styled from '@emotion/styled';
43
42
  import { css } from '@emotion/react';
44
43
  import { Box, Text } from '.';
45
44
  import { Icon } from './icon';
46
- import { transitions } from '../foundational';
45
+ import { fieldStyles, focusFieldStyles } from '../foundational';
47
46
  var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-fieldBorderColor: var(--grn-color-fade3);\n --grn-fieldBorderColor-hover: var(--grn-color-fade6);\n --grn-fieldBorderColor-focus: var(--grn-color-grey6);\n"])));
48
47
  var iconOffsetPx = 12;
49
48
  var iconTextGapPx = 8;
50
49
  var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n"])), variables);
51
50
  var Label = styled.label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: block;\n margin-bottom: 4px;\n"])));
52
- var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n font: inherit;\n color: inherit;\n background-color: transparent;\n transition-property: border-color;\n width: 100%;\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-fieldXPadding) 0 ", ";\n outline: none;\n border: 1px solid ", ";\n\n &::placeholder {\n color: ", ";\n }\n\n ", "\n"])), transitions, getRadius('s'), function (p) {
53
- return p.paddingLeft;
51
+ var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n\n ", ";\n"])), function (p) {
52
+ return fieldStyles({
53
+ paddingLeft: p.paddingLeft,
54
+ borderColor: p.hasError ? 'var(--grn-color-danger)' : 'var(--grn-fieldBorderColor)'
55
+ });
54
56
  }, function (p) {
55
- return p.hasError ? 'var(--grn-color-danger)' : 'var(--grn-fieldBorderColor)';
56
- }, getColor('grey5'), function (p) {
57
- return !p.hasError && "\n &:hover {\n border-color: var(--grn-fieldBorderColor-hover);\n }\n\n &:focus {\n transition: 0s;\n border-color: var(--grn-fieldBorderColor-focus);\n }\n ";
57
+ return !p.hasError && focusFieldStyles;
58
58
  });
59
59
  var IconSection = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n position: absolute;\n margin: auto;\n left: ", "px;\n top: 0;\n bottom: 0;\n height: fit-content;\n pointer-events: none;\n"])), iconOffsetPx);
60
60
  export var TextInput = function TextInput(_ref) {
@@ -1,41 +1,26 @@
1
- import "core-js/modules/es.array.slice.js";
2
- import "core-js/modules/es.object.freeze.js";
3
- import "core-js/modules/es.object.define-properties.js";
4
1
  import "core-js/modules/es.object.keys.js";
5
2
  import "core-js/modules/es.array.index-of.js";
6
3
  import "core-js/modules/es.symbol.js";
7
- var _excluded = ["children", "size", "weight", "color", "tag", "hasEllipsis", "ellipsisLines", "align"];
4
+ import "core-js/modules/es.array.slice.js";
5
+ import "core-js/modules/es.object.freeze.js";
6
+ import "core-js/modules/es.object.define-properties.js";
8
7
 
9
8
  var _templateObject;
10
9
 
10
+ var _excluded = ["children", "size", "weight", "color", "tag", "hasEllipsis", "ellipsisLines", "align"];
11
11
  import "core-js/modules/es.object.assign.js";
12
12
 
13
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
14
+
13
15
  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; }
14
16
 
15
17
  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; }
16
18
 
17
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
18
-
19
19
  import { getColor, getResponsiveTextSize, getWeight } from '../utilities';
20
20
  import PropTypes from 'prop-types';
21
21
  import React from 'react';
22
- import styled from '@emotion/styled';
22
+ import { css } from '@emotion/react';
23
23
  import { types } from '../types';
24
- var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n ", ";\n font-weight: ", ";\n color: ", ";\n text-align: ", ";\n\n ", ";\n ", ";\n ", ";\n"])), function (p) {
25
- return getResponsiveTextSize(p.size);
26
- }, function (p) {
27
- return getWeight(p.weight);
28
- }, function (p) {
29
- return getColor(p.color);
30
- }, function (p) {
31
- return p.align;
32
- }, function (p) {
33
- return p.hasEllipsis && "\n overflow: hidden;\n text-overflow: ellipsis;\n ";
34
- }, function (p) {
35
- return p.hasEllipsis && !p.ellipsisLines && "\n white-space: nowrap;\n ";
36
- }, function (p) {
37
- return p.hasEllipsis && p.ellipsisLines && "\n display: -webkit-box;\n -webkit-line-clamp: ".concat(p.ellipsisLines, ";\n -webkit-box-orient: vertical;\n ");
38
- });
39
24
  export var Text = function Text(_ref) {
40
25
  var children = _ref.children,
41
26
  _ref$size = _ref.size,
@@ -50,14 +35,9 @@ export var Text = function Text(_ref) {
50
35
  align = _ref.align,
51
36
  props = _objectWithoutProperties(_ref, _excluded);
52
37
 
53
- return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
54
- size: size,
55
- weight: weight,
56
- color: color,
57
- as: tag,
58
- hasEllipsis: hasEllipsis,
59
- ellipsisLines: ellipsisLines,
60
- align: align
38
+ var Tag = tag;
39
+ return /*#__PURE__*/React.createElement(Tag, Object.assign({
40
+ css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n ", ";\n font-weight: ", ";\n color: ", ";\n text-align: ", ";\n\n ", ";\n\n ", ";\n "])), getResponsiveTextSize(size), getWeight(weight), getColor(color), align, hasEllipsis && "\n overflow: hidden;\n text-overflow: ellipsis;\n ".concat(!ellipsisLines && "white-space: nowrap", ";\n "), hasEllipsis && ellipsisLines && "\n display: -webkit-box;\n -webkit-line-clamp: ".concat(ellipsisLines, ";\n -webkit-box-orient: vertical;\n "))
61
41
  }, props), children);
62
42
  };
63
43
  Text.propTypes = {
@@ -1,13 +1,66 @@
1
1
  import "core-js/modules/es.array.slice.js";
2
2
  import "core-js/modules/es.object.freeze.js";
3
3
  import "core-js/modules/es.object.define-properties.js";
4
+ import "core-js/modules/es.object.keys.js";
5
+ import "core-js/modules/es.array.index-of.js";
6
+ import "core-js/modules/es.symbol.js";
7
+ var _excluded = ["children", "isSelected", "isActive"];
4
8
 
5
- var _templateObject, _templateObject2;
9
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
10
+
11
+ import "core-js/modules/es.object.assign.js";
12
+
13
+ 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; }
14
+
15
+ 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; }
6
16
 
7
17
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
8
18
 
9
19
  import styled from '@emotion/styled';
10
20
  import { css } from '@emotion/react';
11
- import { getColor, getRadius, getTransition, getWeight } from '../utilities';
21
+ import { getColor, getDimension, getRadius, getShadow, getTransition, getWeight } from '../utilities';
22
+ import { Box, Icon, Text } from '../components';
23
+ import { IconCheck } from '../icons';
24
+ import { forwardRef } from 'react';
25
+ export var fieldXPadding = '12px';
26
+ export var textBoxHeight = '40px';
12
27
  export var transitions = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n transition: ", ";\n\n &:hover {\n transition: ", ";\n }\n\n &:active {\n transition: 0s;\n }\n"])), getTransition('slow'), getTransition('fast'));
13
- export var ClearButtonBox = styled.button(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n --grn-borderColor-active: var(--grn-color-fade5);\n\n appearance: none;\n border: 1px solid transparent;\n padding: 0;\n font-family: inherit;\n font-size: inherit;\n cursor: pointer;\n font-weight: ", ";\n border-radius: ", ";\n height: var(--grn-clearButtonHeight-m);\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: var(--grn-color-backgroundOverlay);\n }\n\n &:active {\n border-color: var(--grn-borderColor-active);\n outline-color: var(--grn-borderColor-active);\n background-color: transparent;\n }\n\n &:disabled {\n color: ", ";\n cursor: default;\n border-color: transparent;\n\n &:hover {\n background-color: transparent;\n }\n }\n"])), transitions, getWeight('medium'), getRadius('s'), getColor('contentDisabled'));
28
+ export var ClearButtonBox = styled.button(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n --grn-borderColor-active: var(--grn-color-fade5);\n\n appearance: none;\n border: 1px solid transparent;\n padding: 0;\n font-family: inherit;\n font-size: inherit;\n cursor: pointer;\n font-weight: ", ";\n border-radius: ", ";\n height: var(--grn-clearButtonHeight-m);\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n\n &:hover {\n background-color: var(--grn-color-backgroundOverlay);\n }\n\n &:active {\n border-color: var(--grn-borderColor-active);\n outline-color: var(--grn-borderColor-active);\n background-color: transparent;\n }\n\n &:disabled {\n color: ", ";\n cursor: default;\n border-color: transparent;\n\n &:hover {\n background-color: transparent;\n }\n }\n"])), transitions, getWeight('medium'), getRadius('s'), getColor('contentDisabled'));
29
+ export var fieldStyles = function fieldStyles(_ref) {
30
+ var _ref$paddingLeft = _ref.paddingLeft,
31
+ paddingLeft = _ref$paddingLeft === void 0 ? '12px' : _ref$paddingLeft,
32
+ _ref$paddingRight = _ref.paddingRight,
33
+ paddingRight = _ref$paddingRight === void 0 ? '12px' : _ref$paddingRight,
34
+ _ref$borderColor = _ref.borderColor,
35
+ borderColor = _ref$borderColor === void 0 ? 'var(--grn-color-fade3)' : _ref$borderColor;
36
+ return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n --grn-fieldBorderColor-hover: var(--grn-color-fade6);\n --grn-fieldBorderColor-focus: var(--grn-color-grey6);\n\n ", ";\n appearance: none;\n border: none;\n font: inherit;\n color: inherit;\n background-color: transparent;\n transition-property: border-color;\n width: 100%;\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 ", " 0 ", ";\n outline: none;\n border: 1px solid ", ";\n\n &::placeholder {\n color: ", ";\n }\n"])), transitions, getRadius('s'), paddingRight, paddingLeft, borderColor, getColor('grey5'));
37
+ };
38
+ export var focusFieldStyles = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n &:hover {\n border-color: var(--grn-fieldBorderColor-hover);\n }\n\n &:focus {\n transition: 0s;\n border-color: var(--grn-fieldBorderColor-focus);\n }\n"])));
39
+ export var Menu = styled.ul(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 8px;\n margin: 0;\n position: absolute;\n background: white;\n box-shadow: ", ";\n border-radius: ", ";\n max-height: 468px;\n overflow: auto;\n width: ", ";\n ", "\n\n &:focus {\n outline: none;\n }\n"])), getShadow('m'), getRadius('s'), function (_ref2) {
40
+ var menuWidth = _ref2.menuWidth;
41
+ return getDimension(menuWidth);
42
+ }, function (_ref3) {
43
+ var menuAlign = _ref3.menuAlign;
44
+ return "".concat(menuAlign, ": 0;");
45
+ });
46
+ var MenuItemWrapper = styled.li(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: grid;\n grid-auto-flow: column;\n gap: 8px;\n align-items: center;\n list-style: none;\n padding: 0 1rem;\n min-height: var(--grn-textBoxHeight-m);\n cursor: pointer;\n border-radius: ", ";\n"])), getRadius('s'));
47
+ export var MenuItem = /*#__PURE__*/forwardRef(function (_ref4, ref) {
48
+ var children = _ref4.children,
49
+ isSelected = _ref4.isSelected,
50
+ isActive = _ref4.isActive,
51
+ props = _objectWithoutProperties(_ref4, _excluded);
52
+
53
+ return /*#__PURE__*/React.createElement(MenuItemWrapper, Object.assign({
54
+ ref: ref,
55
+ isActive: isActive,
56
+ style: {
57
+ background: isActive ? getColor('overlay') : undefined
58
+ }
59
+ }, props), /*#__PURE__*/React.createElement(Text, {
60
+ hasEllipsis: true
61
+ }, children), isSelected && /*#__PURE__*/React.createElement(Box, {
62
+ marginLeft: "auto"
63
+ }, /*#__PURE__*/React.createElement(Icon, {
64
+ icon: /*#__PURE__*/React.createElement(IconCheck, null)
65
+ })));
66
+ });
package/es/hooks/index.js CHANGED
@@ -1 +1,3 @@
1
- export { useMedia } from './useMedia';
1
+ export { useMedia } from './useMedia';
2
+ export { useKeyPress } from './useKeyPress';
3
+ export { useOnClickOutside } from './useOnClickOutside';
@@ -0,0 +1,56 @@
1
+ import "core-js/modules/es.symbol.js";
2
+ import "core-js/modules/es.symbol.description.js";
3
+ import "core-js/modules/es.object.to-string.js";
4
+ import "core-js/modules/es.symbol.iterator.js";
5
+ import "core-js/modules/es.array.iterator.js";
6
+ import "core-js/modules/es.string.iterator.js";
7
+ import "core-js/modules/web.dom-collections.iterator.js";
8
+ import "core-js/modules/es.array.slice.js";
9
+ import "core-js/modules/es.array.from.js";
10
+ import "core-js/modules/es.regexp.exec.js";
11
+
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+
14
+ 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."); }
15
+
16
+ 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); }
17
+
18
+ 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; }
19
+
20
+ 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; }
21
+
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+
24
+ import { useEffect, useState } from 'react';
25
+ export function useKeyPress(targetKey) {
26
+ var _useState = useState(false),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ keyPressed = _useState2[0],
29
+ setKeyPressed = _useState2[1];
30
+
31
+ function downHandler(_ref) {
32
+ var key = _ref.key;
33
+
34
+ if (key === targetKey) {
35
+ setKeyPressed(true);
36
+ }
37
+ }
38
+
39
+ var upHandler = function upHandler(_ref2) {
40
+ var key = _ref2.key;
41
+
42
+ if (key === targetKey) {
43
+ setKeyPressed(false);
44
+ }
45
+ };
46
+
47
+ useEffect(function () {
48
+ window.addEventListener('keydown', downHandler);
49
+ window.addEventListener('keyup', upHandler);
50
+ return function () {
51
+ window.removeEventListener('keydown', downHandler);
52
+ window.removeEventListener('keyup', upHandler);
53
+ };
54
+ }, []);
55
+ return keyPressed;
56
+ }
@@ -0,0 +1,19 @@
1
+ import { useEffect } from 'react';
2
+ export function useOnClickOutside(ref, handler) {
3
+ useEffect(function () {
4
+ var listener = function listener(event) {
5
+ if (!ref.current || ref.current.contains(event.target)) {
6
+ return;
7
+ }
8
+
9
+ handler(event);
10
+ };
11
+
12
+ document.addEventListener('mousedown', listener);
13
+ document.addEventListener('touchstart', listener);
14
+ return function () {
15
+ document.removeEventListener('mousedown', listener);
16
+ document.removeEventListener('touchstart', listener);
17
+ };
18
+ }, [ref, handler]);
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "5.8.2",
3
+ "version": "5.9.2",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",
@@ -23,7 +23,6 @@
23
23
  "dependencies": {
24
24
  "@emotion/react": "^11.9.0",
25
25
  "@emotion/styled": "^11.8.1",
26
- "@headlessui/react": "^1.6.6",
27
26
  "core-js": "^3.22.8",
28
27
  "prop-types": "^15.8.1"
29
28
  },
@@ -36,6 +35,8 @@
36
35
  "@babel/plugin-transform-runtime": "^7.18.2",
37
36
  "@babel/preset-env": "^7.18.2",
38
37
  "@babel/preset-react": "^7.17.12",
38
+ "@emotion/babel-preset-css-prop": "^11.10.0",
39
+ "@headlessui/react": "^1.6.6",
39
40
  "@mdx-js/loader": "^2.1.1",
40
41
  "@next/mdx": "^12.1.6",
41
42
  "@semantic-release/git": "^10.0.1",