@flodesk/grain 5.10.0 → 5.11.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/icon.js +1 -3
- package/es/components/select.js +15 -10
- package/es/components/text-button.js +15 -7
- package/es/foundational/index.js +1 -0
- package/package.json +1 -1
package/es/components/icon.js
CHANGED
|
@@ -21,9 +21,7 @@ import PropTypes from 'prop-types';
|
|
|
21
21
|
import React, { forwardRef } from 'react';
|
|
22
22
|
import styled from '@emotion/styled';
|
|
23
23
|
import { types } from '../types';
|
|
24
|
-
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n
|
|
25
|
-
return getColor(p.color);
|
|
26
|
-
}, function (p) {
|
|
24
|
+
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n color: ", ";\n\n svg {\n display: block;\n height: ", ";\n ", "\n"])), function (p) {
|
|
27
25
|
return getColor(p.color);
|
|
28
26
|
}, function (p) {
|
|
29
27
|
return getIconSize(p.size);
|
package/es/components/select.js
CHANGED
|
@@ -38,7 +38,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
38
38
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
39
39
|
|
|
40
40
|
import PropTypes from 'prop-types';
|
|
41
|
-
import React, { useState } from 'react';
|
|
41
|
+
import React, { useState, forwardRef, Fragment } from 'react';
|
|
42
42
|
import styled from '@emotion/styled';
|
|
43
43
|
import { Icon, Box, Text } from '.';
|
|
44
44
|
import { IconChevronDown } from '../icons';
|
|
@@ -46,13 +46,14 @@ import { Listbox } from '@headlessui/react';
|
|
|
46
46
|
import { getColor, getRadius } from '../utilities';
|
|
47
47
|
import { types } from '../types';
|
|
48
48
|
import { fieldXPadding, MenuCard, MenuCardItem, textBoxHeight, transitions } from '../foundational';
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
var SelectButton = function SelectButton(_ref) {
|
|
49
|
+
var DefaultTriggerButton = styled.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
|
+
var DefaultTrigger = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
52
51
|
var children = _ref.children,
|
|
53
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
54
53
|
|
|
55
|
-
return /*#__PURE__*/React.createElement(
|
|
54
|
+
return /*#__PURE__*/React.createElement(DefaultTriggerButton, Object.assign({
|
|
55
|
+
ref: ref
|
|
56
|
+
}, props), /*#__PURE__*/React.createElement(Text, {
|
|
56
57
|
hasEllipsis: true,
|
|
57
58
|
weight: "medium"
|
|
58
59
|
}, children), /*#__PURE__*/React.createElement(Box, {
|
|
@@ -60,7 +61,7 @@ var SelectButton = function SelectButton(_ref) {
|
|
|
60
61
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
61
62
|
icon: /*#__PURE__*/React.createElement(IconChevronDown, null)
|
|
62
63
|
})));
|
|
63
|
-
};
|
|
64
|
+
});
|
|
64
65
|
|
|
65
66
|
var SelectRoot = function SelectRoot(_ref2) {
|
|
66
67
|
var props = Object.assign({}, _ref2);
|
|
@@ -76,7 +77,8 @@ export var Select = function Select(_ref3) {
|
|
|
76
77
|
_ref3$menuAlign = _ref3.menuAlign,
|
|
77
78
|
menuAlign = _ref3$menuAlign === void 0 ? 'left' : _ref3$menuAlign,
|
|
78
79
|
_ref3$menuWidth = _ref3.menuWidth,
|
|
79
|
-
menuWidth = _ref3$menuWidth === void 0 ? '100%' : _ref3$menuWidth
|
|
80
|
+
menuWidth = _ref3$menuWidth === void 0 ? '100%' : _ref3$menuWidth,
|
|
81
|
+
trigger = _ref3.trigger;
|
|
80
82
|
|
|
81
83
|
var _useState = useState(defaultOption || ''),
|
|
82
84
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -92,7 +94,9 @@ export var Select = function Select(_ref3) {
|
|
|
92
94
|
as: SelectRoot,
|
|
93
95
|
value: selectedOption,
|
|
94
96
|
onChange: handleChange
|
|
95
|
-
}, /*#__PURE__*/React.createElement(
|
|
97
|
+
}, /*#__PURE__*/React.createElement(Listbox.Button, {
|
|
98
|
+
as: Fragment
|
|
99
|
+
}, trigger ? trigger(selectedOption) : /*#__PURE__*/React.createElement(DefaultTrigger, null, selectedOption)), /*#__PURE__*/React.createElement(Listbox.Options, {
|
|
96
100
|
menuAlign: menuAlign,
|
|
97
101
|
menuWidth: menuWidth,
|
|
98
102
|
as: MenuCard
|
|
@@ -100,7 +104,7 @@ export var Select = function Select(_ref3) {
|
|
|
100
104
|
return /*#__PURE__*/React.createElement(Listbox.Option, {
|
|
101
105
|
key: index,
|
|
102
106
|
value: option,
|
|
103
|
-
as:
|
|
107
|
+
as: Fragment
|
|
104
108
|
}, function (_ref4) {
|
|
105
109
|
var active = _ref4.active,
|
|
106
110
|
selected = _ref4.selected;
|
|
@@ -116,5 +120,6 @@ Select.propTypes = {
|
|
|
116
120
|
defaultOption: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
117
121
|
onChange: PropTypes.func,
|
|
118
122
|
menuAlign: PropTypes.oneOf(['left', 'right']),
|
|
119
|
-
menuWidth: types.dimension
|
|
123
|
+
menuWidth: types.dimension,
|
|
124
|
+
trigger: PropTypes.func
|
|
120
125
|
};
|
|
@@ -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", "isDisabled", "icon"];
|
|
7
|
+
var _excluded = ["children", "isDisabled", "icon", "iconPosition"];
|
|
8
8
|
|
|
9
9
|
var _templateObject;
|
|
10
10
|
|
|
@@ -17,27 +17,35 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
17
17
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
18
18
|
|
|
19
19
|
import { Icon } from '../components';
|
|
20
|
-
import React from 'react';
|
|
20
|
+
import React, { forwardRef } from 'react';
|
|
21
21
|
import styled from '@emotion/styled';
|
|
22
22
|
import PropTypes from 'prop-types';
|
|
23
23
|
import { ClearButtonBox } from '../foundational';
|
|
24
|
-
var Wrapper = styled(ClearButtonBox)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 0 8px;\n gap: 8px;\n"])))
|
|
25
|
-
|
|
24
|
+
var Wrapper = styled(ClearButtonBox)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 0 8px;\n gap: 8px;\n\n .buttonIcon {\n ", ";\n }\n"])), function (p) {
|
|
25
|
+
return p.iconPosition === 'right' && "order: 1";
|
|
26
|
+
});
|
|
27
|
+
export var TextButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
26
28
|
var children = _ref.children,
|
|
27
29
|
isDisabled = _ref.isDisabled,
|
|
28
30
|
icon = _ref.icon,
|
|
31
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
32
|
+
iconPosition = _ref$iconPosition === void 0 ? 'left' : _ref$iconPosition,
|
|
29
33
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
34
|
|
|
31
35
|
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
32
36
|
disabled: isDisabled,
|
|
33
|
-
icon: icon
|
|
37
|
+
icon: icon,
|
|
38
|
+
iconPosition: iconPosition,
|
|
39
|
+
ref: ref
|
|
34
40
|
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
35
|
-
icon: icon
|
|
41
|
+
icon: icon,
|
|
42
|
+
className: "buttonIcon"
|
|
36
43
|
}), children && children);
|
|
37
|
-
};
|
|
44
|
+
});
|
|
38
45
|
TextButton.propTypes = {
|
|
39
46
|
children: PropTypes.node,
|
|
40
47
|
icon: PropTypes.node,
|
|
48
|
+
iconPosition: PropTypes.oneOf(['left', 'right']),
|
|
41
49
|
onClick: PropTypes.func,
|
|
42
50
|
isDisabled: PropTypes.bool
|
|
43
51
|
};
|
package/es/foundational/index.js
CHANGED
|
@@ -68,6 +68,7 @@ export var MenuCardItem = /*#__PURE__*/forwardRef(function (_ref4, ref) {
|
|
|
68
68
|
hasEvenBoundary: true
|
|
69
69
|
}), /*#__PURE__*/React.createElement(Box, {
|
|
70
70
|
width: "100%",
|
|
71
|
+
minWidth: "0px",
|
|
71
72
|
tag: "span"
|
|
72
73
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
73
74
|
hasEllipsis: true
|