@flodesk/grain 5.9.0 → 5.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,7 +34,7 @@ import "core-js/modules/es.array.map.js";
|
|
|
34
34
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
35
35
|
|
|
36
36
|
import PropTypes from 'prop-types';
|
|
37
|
-
import React, { useState } from 'react';
|
|
37
|
+
import React, { forwardRef, useState } from 'react';
|
|
38
38
|
import styled from '@emotion/styled';
|
|
39
39
|
import { Icon, Box, Text } from '.';
|
|
40
40
|
import { IconChevronDown } from '../icons';
|
|
@@ -52,12 +52,14 @@ var Root = function Root(_ref) {
|
|
|
52
52
|
}));
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
var Trigger = function
|
|
55
|
+
var Trigger = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
56
56
|
var props = Object.assign({}, _ref2);
|
|
57
|
-
return /*#__PURE__*/React.createElement(Box, Object.assign({
|
|
57
|
+
return /*#__PURE__*/React.createElement(Box, Object.assign({
|
|
58
|
+
ref: ref
|
|
59
|
+
}, props, {
|
|
58
60
|
position: "relative"
|
|
59
61
|
}));
|
|
60
|
-
};
|
|
62
|
+
});
|
|
61
63
|
|
|
62
64
|
var EmptyState = function EmptyState() {
|
|
63
65
|
return /*#__PURE__*/React.createElement(Box, {
|
|
@@ -70,9 +72,14 @@ var EmptyState = function EmptyState() {
|
|
|
70
72
|
export var Autocomplete = function Autocomplete(_ref3) {
|
|
71
73
|
var options = _ref3.options,
|
|
72
74
|
defaultOption = _ref3.defaultOption,
|
|
73
|
-
onChange = _ref3.onChange
|
|
74
|
-
|
|
75
|
-
|
|
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 : ''),
|
|
76
83
|
_useState2 = _slicedToArray(_useState, 2),
|
|
77
84
|
selectedOption = _useState2[0],
|
|
78
85
|
setSelectedOption = _useState2[1];
|
|
@@ -89,7 +96,7 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
89
96
|
};
|
|
90
97
|
|
|
91
98
|
var filteredOptions = query === '' ? options : options.filter(function (option) {
|
|
92
|
-
return option.
|
|
99
|
+
return option.toLowerCase().includes(query.toLowerCase());
|
|
93
100
|
});
|
|
94
101
|
return /*#__PURE__*/React.createElement(Combobox, {
|
|
95
102
|
as: Root,
|
|
@@ -98,11 +105,11 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
98
105
|
}, /*#__PURE__*/React.createElement(Combobox.Button, {
|
|
99
106
|
as: Trigger
|
|
100
107
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
101
|
-
|
|
108
|
+
autoComplete: "off",
|
|
102
109
|
onChange: function onChange(event) {
|
|
103
110
|
return setQuery(event.target.value);
|
|
104
111
|
},
|
|
105
|
-
placeholder:
|
|
112
|
+
placeholder: placeholder
|
|
106
113
|
}), /*#__PURE__*/React.createElement(Box, {
|
|
107
114
|
right: fieldXPadding,
|
|
108
115
|
position: "absolute",
|
|
@@ -113,11 +120,13 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
113
120
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
114
121
|
icon: /*#__PURE__*/React.createElement(IconChevronDown, null)
|
|
115
122
|
}))), /*#__PURE__*/React.createElement(Combobox.Options, {
|
|
123
|
+
menuAlign: menuAlign,
|
|
124
|
+
menuWidth: menuWidth,
|
|
116
125
|
as: Menu
|
|
117
126
|
}, filteredOptions.map(function (option, index) {
|
|
118
127
|
return /*#__PURE__*/React.createElement(Combobox.Option, {
|
|
119
128
|
key: index,
|
|
120
|
-
value: option
|
|
129
|
+
value: option,
|
|
121
130
|
as: React.Fragment
|
|
122
131
|
}, function (_ref4) {
|
|
123
132
|
var active = _ref4.active,
|
|
@@ -125,13 +134,13 @@ export var Autocomplete = function Autocomplete(_ref3) {
|
|
|
125
134
|
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
126
135
|
isSelected: selected,
|
|
127
136
|
isActive: active
|
|
128
|
-
}, option
|
|
137
|
+
}, option);
|
|
129
138
|
});
|
|
130
139
|
}), !Boolean(filteredOptions.length) && /*#__PURE__*/React.createElement(EmptyState, null)));
|
|
131
140
|
};
|
|
132
141
|
Autocomplete.propTypes = {
|
|
133
142
|
options: PropTypes.array,
|
|
134
|
-
defaultOption: PropTypes.
|
|
143
|
+
defaultOption: PropTypes.string,
|
|
135
144
|
onChange: PropTypes.func,
|
|
136
145
|
menuAlign: PropTypes.oneOf(['left', 'right']),
|
|
137
146
|
menuWidth: types.dimension
|
package/es/components/select.js
CHANGED
|
@@ -45,8 +45,8 @@ 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 { Menu, MenuItem } from '../foundational';
|
|
49
|
-
var SelectButtonWrapper = styled(Listbox.Button)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n gap: 8px;\n appearance: none;\n border: none;\n background: ", ";\n padding: 0
|
|
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
50
|
|
|
51
51
|
var SelectButton = function SelectButton(_ref) {
|
|
52
52
|
var children = _ref.children,
|
|
@@ -78,7 +78,7 @@ export var Select = function Select(_ref3) {
|
|
|
78
78
|
_ref3$menuWidth = _ref3.menuWidth,
|
|
79
79
|
menuWidth = _ref3$menuWidth === void 0 ? '240px' : _ref3$menuWidth;
|
|
80
80
|
|
|
81
|
-
var _useState = useState(defaultOption ||
|
|
81
|
+
var _useState = useState(defaultOption || ''),
|
|
82
82
|
_useState2 = _slicedToArray(_useState, 2),
|
|
83
83
|
selectedOption = _useState2[0],
|
|
84
84
|
setSelectedOption = _useState2[1];
|
|
@@ -92,13 +92,13 @@ export var Select = function Select(_ref3) {
|
|
|
92
92
|
as: SelectRoot,
|
|
93
93
|
value: selectedOption,
|
|
94
94
|
onChange: handleChange
|
|
95
|
-
}, /*#__PURE__*/React.createElement(SelectButton, null, selectedOption
|
|
95
|
+
}, /*#__PURE__*/React.createElement(SelectButton, null, selectedOption), /*#__PURE__*/React.createElement(Listbox.Options, {
|
|
96
96
|
menuAlign: menuAlign,
|
|
97
97
|
menuWidth: menuWidth,
|
|
98
98
|
as: Menu
|
|
99
|
-
}, options.map(function (option) {
|
|
99
|
+
}, options.map(function (option, index) {
|
|
100
100
|
return /*#__PURE__*/React.createElement(Listbox.Option, {
|
|
101
|
-
key:
|
|
101
|
+
key: index,
|
|
102
102
|
value: option,
|
|
103
103
|
as: React.Fragment
|
|
104
104
|
}, function (_ref4) {
|
|
@@ -107,13 +107,13 @@ export var Select = function Select(_ref3) {
|
|
|
107
107
|
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
108
108
|
isSelected: selected,
|
|
109
109
|
isActive: active
|
|
110
|
-
}, option
|
|
110
|
+
}, option);
|
|
111
111
|
});
|
|
112
112
|
})));
|
|
113
113
|
};
|
|
114
114
|
Select.propTypes = {
|
|
115
115
|
options: PropTypes.array,
|
|
116
|
-
defaultOption: PropTypes.
|
|
116
|
+
defaultOption: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
117
117
|
onChange: PropTypes.func,
|
|
118
118
|
menuAlign: PropTypes.oneOf(['left', 'right']),
|
|
119
119
|
menuWidth: types.dimension
|
package/es/foundational/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { Box, Icon, Text } from '../components';
|
|
|
23
23
|
import { IconCheck } from '../icons';
|
|
24
24
|
import { forwardRef } from 'react';
|
|
25
25
|
export var fieldXPadding = '12px';
|
|
26
|
+
export var textBoxHeight = '40px';
|
|
26
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'));
|
|
27
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'));
|
|
28
29
|
export var fieldStyles = function fieldStyles(_ref) {
|