@flodesk/grain 5.9.2 → 5.10.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.
- package/es/components/autocomplete.js +4 -4
- package/es/components/box.js +6 -3
- package/es/components/dropdown.js +49 -0
- package/es/components/index.js +3 -1
- package/es/components/multi-autocomplete.js +189 -0
- package/es/components/select.js +4 -4
- package/es/foundational/index.js +21 -10
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ import { Icon, Box, Text } from '.';
|
|
|
40
40
|
import { IconChevronDown } from '../icons';
|
|
41
41
|
import { Combobox } from '@headlessui/react';
|
|
42
42
|
import { types } from '../types';
|
|
43
|
-
import { fieldStyles, fieldXPadding, focusFieldStyles,
|
|
43
|
+
import { fieldStyles, fieldXPadding, focusFieldStyles, MenuCard, MenuCardItem } from '../foundational';
|
|
44
44
|
var Input = styled(Combobox.Input)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n ", ";\n"])), fieldStyles({
|
|
45
45
|
paddingRight: '32px'
|
|
46
46
|
}), focusFieldStyles);
|
|
@@ -76,7 +76,7 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
76
76
|
_ref3$menuAlign = _ref3.menuAlign,
|
|
77
77
|
menuAlign = _ref3$menuAlign === void 0 ? 'left' : _ref3$menuAlign,
|
|
78
78
|
_ref3$menuWidth = _ref3.menuWidth,
|
|
79
|
-
menuWidth = _ref3$menuWidth === void 0 ? '
|
|
79
|
+
menuWidth = _ref3$menuWidth === void 0 ? '100%' : _ref3$menuWidth,
|
|
80
80
|
placeholder = _ref3.placeholder;
|
|
81
81
|
|
|
82
82
|
var _useState = useState(defaultOption ? defaultOption : ''),
|
|
@@ -122,7 +122,7 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
122
122
|
}))), /*#__PURE__*/React.createElement(Combobox.Options, {
|
|
123
123
|
menuAlign: menuAlign,
|
|
124
124
|
menuWidth: menuWidth,
|
|
125
|
-
as:
|
|
125
|
+
as: MenuCard
|
|
126
126
|
}, filteredOptions.map(function (option, index) {
|
|
127
127
|
return /*#__PURE__*/React.createElement(Combobox.Option, {
|
|
128
128
|
key: index,
|
|
@@ -131,7 +131,7 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
131
131
|
}, function (_ref4) {
|
|
132
132
|
var active = _ref4.active,
|
|
133
133
|
selected = _ref4.selected;
|
|
134
|
-
return /*#__PURE__*/React.createElement(
|
|
134
|
+
return /*#__PURE__*/React.createElement(MenuCardItem, {
|
|
135
135
|
isSelected: selected,
|
|
136
136
|
isActive: active
|
|
137
137
|
}, option);
|
package/es/components/box.js
CHANGED
|
@@ -7,7 +7,7 @@ import "core-js/modules/es.object.define-properties.js";
|
|
|
7
7
|
|
|
8
8
|
var _templateObject;
|
|
9
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"];
|
|
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", "tag"];
|
|
11
11
|
import "core-js/modules/es.object.assign.js";
|
|
12
12
|
|
|
13
13
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
@@ -60,11 +60,14 @@ export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
60
60
|
overflow = _ref.overflow,
|
|
61
61
|
aspectRatio = _ref.aspectRatio,
|
|
62
62
|
zIndex = _ref.zIndex,
|
|
63
|
+
_ref$tag = _ref.tag,
|
|
64
|
+
tag = _ref$tag === void 0 ? 'div' : _ref$tag,
|
|
63
65
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
var Tag = tag;
|
|
68
|
+
return /*#__PURE__*/React.createElement(Tag, Object.assign({
|
|
66
69
|
ref: ref,
|
|
67
|
-
css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
70
|
+
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)
|
|
68
71
|
}, props), children);
|
|
69
72
|
});
|
|
70
73
|
Box.propTypes = {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "core-js/modules/es.object.assign.js";
|
|
2
|
+
import "core-js/modules/es.array.map.js";
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { Box } from '.';
|
|
6
|
+
import { Menu } from '@headlessui/react';
|
|
7
|
+
import { types } from '../types';
|
|
8
|
+
import { MenuCard, MenuCardItem } from '../foundational';
|
|
9
|
+
|
|
10
|
+
var Root = function Root(_ref) {
|
|
11
|
+
var props = Object.assign({}, _ref);
|
|
12
|
+
return /*#__PURE__*/React.createElement(Box, Object.assign({
|
|
13
|
+
position: "relative"
|
|
14
|
+
}, props));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export var Dropdown = function Dropdown(_ref2) {
|
|
18
|
+
var options = _ref2.options,
|
|
19
|
+
_ref2$menuAlign = _ref2.menuAlign,
|
|
20
|
+
menuAlign = _ref2$menuAlign === void 0 ? 'left' : _ref2$menuAlign,
|
|
21
|
+
_ref2$menuWidth = _ref2.menuWidth,
|
|
22
|
+
menuWidth = _ref2$menuWidth === void 0 ? 'auto' : _ref2$menuWidth,
|
|
23
|
+
trigger = _ref2.trigger;
|
|
24
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
25
|
+
as: Root
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Menu.Button, {
|
|
27
|
+
as: "div"
|
|
28
|
+
}, trigger), /*#__PURE__*/React.createElement(Menu.Items, {
|
|
29
|
+
as: MenuCard,
|
|
30
|
+
menuAlign: menuAlign,
|
|
31
|
+
menuWidth: menuWidth
|
|
32
|
+
}, options.map(function (option, index) {
|
|
33
|
+
return /*#__PURE__*/React.createElement(Menu.Item, {
|
|
34
|
+
key: index
|
|
35
|
+
}, function (_ref3) {
|
|
36
|
+
var active = _ref3.active;
|
|
37
|
+
return /*#__PURE__*/React.createElement(MenuCardItem, {
|
|
38
|
+
icon: option.icon,
|
|
39
|
+
isActive: active,
|
|
40
|
+
onClick: option.onClick
|
|
41
|
+
}, option.content);
|
|
42
|
+
});
|
|
43
|
+
})));
|
|
44
|
+
};
|
|
45
|
+
Dropdown.propTypes = {
|
|
46
|
+
options: PropTypes.array,
|
|
47
|
+
menuAlign: PropTypes.oneOf(['left', 'right']),
|
|
48
|
+
menuWidth: types.dimension
|
|
49
|
+
};
|
package/es/components/index.js
CHANGED
|
@@ -14,4 +14,6 @@ export { Stack } from './stack';
|
|
|
14
14
|
export { Slider } from './slider';
|
|
15
15
|
export { Spinner } from './spinner';
|
|
16
16
|
export { Switch } from './switch';
|
|
17
|
-
export { Autocomplete } from './autocomplete';
|
|
17
|
+
export { Autocomplete } from './autocomplete';
|
|
18
|
+
export { MultiAutocomplete } from './multi-autocomplete';
|
|
19
|
+
export { Dropdown } from './dropdown';
|
|
@@ -0,0 +1,189 @@
|
|
|
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, _templateObject2, _templateObject3;
|
|
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, Arrange } from '.';
|
|
40
|
+
import { IconChevronDown, IconCross } from '../icons';
|
|
41
|
+
import { Combobox } from '@headlessui/react';
|
|
42
|
+
import { types } from '../types';
|
|
43
|
+
import { ClearButtonBox, fieldStyles, fieldXPadding, focusFieldStyles, MenuCard, MenuCardItem } 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
|
+
var Tags = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: start;\n gap: 4px;\n margin-bottom: 8px;\n flex-wrap: wrap;\n"])));
|
|
73
|
+
var RemoveButton = styled(ClearButtonBox)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n width: 24px;\n height: 24px;\n"])));
|
|
74
|
+
|
|
75
|
+
var Tag = function Tag(_ref3) {
|
|
76
|
+
var children = _ref3.children,
|
|
77
|
+
onRemoveClick = _ref3.onRemoveClick;
|
|
78
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
79
|
+
backgroundColor: "fade1",
|
|
80
|
+
radius: "s",
|
|
81
|
+
height: "32px",
|
|
82
|
+
paddingLeft: "12px",
|
|
83
|
+
paddingRight: "8px"
|
|
84
|
+
}, /*#__PURE__*/React.createElement(Arrange, {
|
|
85
|
+
gap: "4px",
|
|
86
|
+
height: "100%"
|
|
87
|
+
}, children, /*#__PURE__*/React.createElement(RemoveButton, {
|
|
88
|
+
onClick: function onClick() {
|
|
89
|
+
return onRemoveClick();
|
|
90
|
+
}
|
|
91
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
92
|
+
icon: /*#__PURE__*/React.createElement(IconCross, null),
|
|
93
|
+
size: "s"
|
|
94
|
+
}))));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export var MultiAutocomplete = function MultiAutocomplete(_ref4) {
|
|
98
|
+
var options = _ref4.options,
|
|
99
|
+
_ref4$defaultOptions = _ref4.defaultOptions,
|
|
100
|
+
defaultOptions = _ref4$defaultOptions === void 0 ? [] : _ref4$defaultOptions,
|
|
101
|
+
onChange = _ref4.onChange,
|
|
102
|
+
_ref4$menuAlign = _ref4.menuAlign,
|
|
103
|
+
menuAlign = _ref4$menuAlign === void 0 ? 'left' : _ref4$menuAlign,
|
|
104
|
+
_ref4$menuWidth = _ref4.menuWidth,
|
|
105
|
+
menuWidth = _ref4$menuWidth === void 0 ? '100%' : _ref4$menuWidth,
|
|
106
|
+
placeholder = _ref4.placeholder;
|
|
107
|
+
|
|
108
|
+
var _useState = useState(defaultOptions),
|
|
109
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
110
|
+
selectedOptions = _useState2[0],
|
|
111
|
+
setSelectedOptions = _useState2[1];
|
|
112
|
+
|
|
113
|
+
var _useState3 = useState(''),
|
|
114
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
115
|
+
query = _useState4[0],
|
|
116
|
+
setQuery = _useState4[1];
|
|
117
|
+
|
|
118
|
+
var handleChange = function handleChange(option) {
|
|
119
|
+
setSelectedOptions(option);
|
|
120
|
+
onChange && onChange(option);
|
|
121
|
+
setQuery('');
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var filteredOptions = query === '' ? options : options.filter(function (option) {
|
|
125
|
+
return option.content.toLowerCase().includes(query.toLowerCase());
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
var deselectOption = function deselectOption(option) {
|
|
129
|
+
var remaining = selectedOptions.filter(function (item) {
|
|
130
|
+
return item !== option;
|
|
131
|
+
});
|
|
132
|
+
setSelectedOptions(remaining);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return /*#__PURE__*/React.createElement(Combobox, {
|
|
136
|
+
as: Root,
|
|
137
|
+
value: selectedOptions,
|
|
138
|
+
onChange: handleChange,
|
|
139
|
+
multiple: true
|
|
140
|
+
}, selectedOptions.length > 0 && /*#__PURE__*/React.createElement(Tags, null, selectedOptions.map(function (option) {
|
|
141
|
+
return /*#__PURE__*/React.createElement(Tag, {
|
|
142
|
+
onRemoveClick: function onRemoveClick() {
|
|
143
|
+
return deselectOption(option);
|
|
144
|
+
},
|
|
145
|
+
key: option.id
|
|
146
|
+
}, option.content);
|
|
147
|
+
})), /*#__PURE__*/React.createElement(Combobox.Button, {
|
|
148
|
+
as: Trigger
|
|
149
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
150
|
+
autoComplete: "off",
|
|
151
|
+
onChange: function onChange(event) {
|
|
152
|
+
return setQuery(event.target.value);
|
|
153
|
+
},
|
|
154
|
+
placeholder: placeholder
|
|
155
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
156
|
+
right: fieldXPadding,
|
|
157
|
+
position: "absolute",
|
|
158
|
+
top: "0px",
|
|
159
|
+
bottom: "0px",
|
|
160
|
+
margin: "auto",
|
|
161
|
+
height: "fit-content"
|
|
162
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
163
|
+
icon: /*#__PURE__*/React.createElement(IconChevronDown, null)
|
|
164
|
+
}))), /*#__PURE__*/React.createElement(Combobox.Options, {
|
|
165
|
+
menuAlign: menuAlign,
|
|
166
|
+
menuWidth: menuWidth,
|
|
167
|
+
as: MenuCard
|
|
168
|
+
}, filteredOptions.map(function (option, index) {
|
|
169
|
+
return /*#__PURE__*/React.createElement(Combobox.Option, {
|
|
170
|
+
key: index,
|
|
171
|
+
value: option,
|
|
172
|
+
as: React.Fragment
|
|
173
|
+
}, function (_ref5) {
|
|
174
|
+
var active = _ref5.active,
|
|
175
|
+
selected = _ref5.selected;
|
|
176
|
+
return /*#__PURE__*/React.createElement(MenuCardItem, {
|
|
177
|
+
isSelected: selected,
|
|
178
|
+
isActive: active
|
|
179
|
+
}, option.content);
|
|
180
|
+
});
|
|
181
|
+
}), !Boolean(filteredOptions.length) && /*#__PURE__*/React.createElement(EmptyState, null)));
|
|
182
|
+
};
|
|
183
|
+
MultiAutocomplete.propTypes = {
|
|
184
|
+
options: PropTypes.array,
|
|
185
|
+
defaultOption: PropTypes.object,
|
|
186
|
+
onChange: PropTypes.func,
|
|
187
|
+
menuAlign: PropTypes.oneOf(['left', 'right']),
|
|
188
|
+
menuWidth: types.dimension
|
|
189
|
+
};
|
package/es/components/select.js
CHANGED
|
@@ -45,7 +45,7 @@ import { IconChevronDown } from '../icons';
|
|
|
45
45
|
import { Listbox } from '@headlessui/react';
|
|
46
46
|
import { getColor, getRadius } from '../utilities';
|
|
47
47
|
import { types } from '../types';
|
|
48
|
-
import { fieldXPadding,
|
|
48
|
+
import { fieldXPadding, MenuCard, MenuCardItem, textBoxHeight, transitions } from '../foundational';
|
|
49
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
50
|
|
|
51
51
|
var SelectButton = function SelectButton(_ref) {
|
|
@@ -76,7 +76,7 @@ export var Select = function Select(_ref3) {
|
|
|
76
76
|
_ref3$menuAlign = _ref3.menuAlign,
|
|
77
77
|
menuAlign = _ref3$menuAlign === void 0 ? 'left' : _ref3$menuAlign,
|
|
78
78
|
_ref3$menuWidth = _ref3.menuWidth,
|
|
79
|
-
menuWidth = _ref3$menuWidth === void 0 ? '
|
|
79
|
+
menuWidth = _ref3$menuWidth === void 0 ? '100%' : _ref3$menuWidth;
|
|
80
80
|
|
|
81
81
|
var _useState = useState(defaultOption || ''),
|
|
82
82
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -95,7 +95,7 @@ export var Select = function Select(_ref3) {
|
|
|
95
95
|
}, /*#__PURE__*/React.createElement(SelectButton, null, selectedOption), /*#__PURE__*/React.createElement(Listbox.Options, {
|
|
96
96
|
menuAlign: menuAlign,
|
|
97
97
|
menuWidth: menuWidth,
|
|
98
|
-
as:
|
|
98
|
+
as: MenuCard
|
|
99
99
|
}, options.map(function (option, index) {
|
|
100
100
|
return /*#__PURE__*/React.createElement(Listbox.Option, {
|
|
101
101
|
key: index,
|
|
@@ -104,7 +104,7 @@ export var Select = function Select(_ref3) {
|
|
|
104
104
|
}, function (_ref4) {
|
|
105
105
|
var active = _ref4.active,
|
|
106
106
|
selected = _ref4.selected;
|
|
107
|
-
return /*#__PURE__*/React.createElement(
|
|
107
|
+
return /*#__PURE__*/React.createElement(MenuCardItem, {
|
|
108
108
|
isSelected: selected,
|
|
109
109
|
isActive: active
|
|
110
110
|
}, option);
|
package/es/foundational/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import "core-js/modules/es.object.define-properties.js";
|
|
|
4
4
|
import "core-js/modules/es.object.keys.js";
|
|
5
5
|
import "core-js/modules/es.array.index-of.js";
|
|
6
6
|
import "core-js/modules/es.symbol.js";
|
|
7
|
-
var _excluded = ["children", "isSelected", "isActive"];
|
|
7
|
+
var _excluded = ["children", "isSelected", "isActive", "icon"];
|
|
8
8
|
|
|
9
9
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
10
10
|
|
|
@@ -36,31 +36,42 @@ export var fieldStyles = function fieldStyles(_ref) {
|
|
|
36
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
37
|
};
|
|
38
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
|
|
39
|
+
export var MenuCard = 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
40
|
var menuWidth = _ref2.menuWidth;
|
|
41
41
|
return getDimension(menuWidth);
|
|
42
42
|
}, function (_ref3) {
|
|
43
43
|
var menuAlign = _ref3.menuAlign;
|
|
44
44
|
return "".concat(menuAlign, ": 0;");
|
|
45
45
|
});
|
|
46
|
-
var MenuItemWrapper = styled.li(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: grid;\n grid-auto-flow: column;\n
|
|
47
|
-
|
|
46
|
+
var MenuItemWrapper = styled.li(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: grid;\n grid-auto-flow: column;\n grid-template-columns: ", ";\n ", ";\n align-items: center;\n justify-content: start;\n list-style: none;\n padding: 0 12px;\n min-height: ", ";\n cursor: pointer;\n border-radius: ", ";\n appearance: none;\n"])), function (p) {
|
|
47
|
+
return p.hasIcon ? 'auto 1fr' : '1fr auto';
|
|
48
|
+
}, function (p) {
|
|
49
|
+
return (p.hasIcon || p.isSelected) && 'gap: 8px';
|
|
50
|
+
}, textBoxHeight, getRadius('s'));
|
|
51
|
+
export var MenuCardItem = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
48
52
|
var children = _ref4.children,
|
|
49
53
|
isSelected = _ref4.isSelected,
|
|
50
54
|
isActive = _ref4.isActive,
|
|
55
|
+
icon = _ref4.icon,
|
|
51
56
|
props = _objectWithoutProperties(_ref4, _excluded);
|
|
52
57
|
|
|
53
58
|
return /*#__PURE__*/React.createElement(MenuItemWrapper, Object.assign({
|
|
54
59
|
ref: ref,
|
|
55
60
|
isActive: isActive,
|
|
61
|
+
isSelected: isSelected,
|
|
56
62
|
style: {
|
|
57
63
|
background: isActive ? getColor('overlay') : undefined
|
|
58
|
-
}
|
|
59
|
-
|
|
64
|
+
},
|
|
65
|
+
hasIcon: Boolean(icon)
|
|
66
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
67
|
+
icon: icon,
|
|
68
|
+
hasEvenBoundary: true
|
|
69
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
70
|
+
width: "100%",
|
|
71
|
+
tag: "span"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
60
73
|
hasEllipsis: true
|
|
61
|
-
}, children), isSelected && /*#__PURE__*/React.createElement(
|
|
62
|
-
marginLeft: "auto"
|
|
63
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
74
|
+
}, children)), isSelected && /*#__PURE__*/React.createElement(Icon, {
|
|
64
75
|
icon: /*#__PURE__*/React.createElement(IconCheck, null)
|
|
65
|
-
}))
|
|
76
|
+
}));
|
|
66
77
|
});
|