@flodesk/grain 2.20.0 → 2.20.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.
- package/es/components/arrange.js +33 -260
- package/es/components/box.js +62 -995
- package/es/components/button.js +36 -100
- package/es/components/icon-button.js +30 -93
- package/es/components/icon-toggle.js +39 -94
- package/es/components/icon.js +30 -126
- package/es/components/index.js +11 -107
- package/es/components/stack.js +26 -81
- package/es/components/text-button.js +28 -66
- package/es/components/text-input.js +76 -138
- package/es/components/text-toggle.js +32 -78
- package/es/components/text.js +33 -159
- package/es/foundational/index.js +9 -23
- package/es/hooks/index.js +1 -15
- package/es/hooks/useMedia.js +21 -17
- package/es/icons/icon-align-center.js +5 -43
- package/es/icons/icon-align-left.js +6 -44
- package/es/icons/icon-align-right.js +6 -44
- package/es/icons/icon-arrow-down.js +5 -43
- package/es/icons/icon-arrow-left.js +5 -43
- package/es/icons/icon-arrow-right.js +5 -43
- package/es/icons/icon-arrow-up.js +5 -43
- package/es/icons/icon-browser.js +9 -47
- package/es/icons/icon-chart.js +5 -43
- package/es/icons/icon-check.js +7 -45
- package/es/icons/icon-chevron-down.js +5 -43
- package/es/icons/icon-chevron-horizontal.js +5 -43
- package/es/icons/icon-chevron-left.js +5 -43
- package/es/icons/icon-chevron-right.js +10 -48
- package/es/icons/icon-chevron-up.js +10 -48
- package/es/icons/icon-chevron-vertical.js +13 -51
- package/es/icons/icon-clip.js +5 -43
- package/es/icons/icon-clock.js +6 -44
- package/es/icons/icon-crop.js +5 -43
- package/es/icons/icon-cross.js +5 -43
- package/es/icons/icon-download.js +8 -46
- package/es/icons/icon-duplicate.js +6 -44
- package/es/icons/icon-ellipsis.js +7 -45
- package/es/icons/icon-file.js +5 -43
- package/es/icons/icon-folder-add.js +5 -43
- package/es/icons/icon-folder.js +5 -43
- package/es/icons/icon-gear.js +6 -44
- package/es/icons/icon-globe.js +5 -43
- package/es/icons/icon-heart.js +5 -43
- package/es/icons/icon-image.js +5 -43
- package/es/icons/icon-link.js +6 -44
- package/es/icons/icon-mail.js +5 -43
- package/es/icons/icon-minus.js +5 -43
- package/es/icons/icon-monitor.js +5 -43
- package/es/icons/icon-pencil.js +5 -43
- package/es/icons/icon-phone.js +5 -43
- package/es/icons/icon-plus.js +5 -43
- package/es/icons/icon-redo.js +5 -43
- package/es/icons/icon-search.js +6 -44
- package/es/icons/icon-send.js +5 -43
- package/es/icons/icon-share.js +5 -43
- package/es/icons/icon-smile.js +8 -46
- package/es/icons/icon-switch.js +5 -43
- package/es/icons/icon-tablet.js +5 -43
- package/es/icons/icon-text-align-center.js +5 -43
- package/es/icons/icon-text-align-left.js +5 -43
- package/es/icons/icon-text-align-right.js +5 -43
- package/es/icons/icon-trash.js +5 -43
- package/es/icons/icon-type.js +5 -43
- package/es/icons/icon-undo.js +5 -43
- package/es/icons/icon-upload.js +8 -46
- package/es/icons/index.js +51 -417
- package/es/index.js +3 -52
- package/es/types.js +23 -38
- package/es/utilities/helpers.js +22 -50
- package/es/utilities/index.js +22 -145
- package/es/utilities/responsive.js +59 -79
- package/es/utilities/styles.js +45 -89
- package/es/variables.js +14 -26
- package/package.json +2 -2
package/es/components/index.js
CHANGED
|
@@ -1,107 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "Box", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function get() {
|
|
17
|
-
return _box.Box;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(exports, "Button", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function get() {
|
|
23
|
-
return _button.Button;
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "TextInput", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function get() {
|
|
29
|
-
return _textInput.TextInput;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(exports, "Arrange", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function get() {
|
|
35
|
-
return _arrange.Arrange;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports, "Icon", {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function get() {
|
|
41
|
-
return _icon.Icon;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(exports, "IconButton", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function get() {
|
|
47
|
-
return _iconButton.IconButton;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(exports, "TextButton", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function get() {
|
|
53
|
-
return _textButton.TextButton;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(exports, "IconToggleGroup", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function get() {
|
|
59
|
-
return _iconToggle.IconToggleGroup;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "IconToggle", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function get() {
|
|
65
|
-
return _iconToggle.IconToggle;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "TextToggleGroup", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function get() {
|
|
71
|
-
return _textToggle.TextToggleGroup;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, "TextToggle", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function get() {
|
|
77
|
-
return _textToggle.TextToggle;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, "Stack", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function get() {
|
|
83
|
-
return _stack.Stack;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
var _text = require("./text");
|
|
88
|
-
|
|
89
|
-
var _box = require("./box");
|
|
90
|
-
|
|
91
|
-
var _button = require("./button");
|
|
92
|
-
|
|
93
|
-
var _textInput = require("./text-input");
|
|
94
|
-
|
|
95
|
-
var _arrange = require("./arrange");
|
|
96
|
-
|
|
97
|
-
var _icon = require("./icon");
|
|
98
|
-
|
|
99
|
-
var _iconButton = require("./icon-button");
|
|
100
|
-
|
|
101
|
-
var _textButton = require("./text-button");
|
|
102
|
-
|
|
103
|
-
var _iconToggle = require("./icon-toggle");
|
|
104
|
-
|
|
105
|
-
var _textToggle = require("./text-toggle");
|
|
106
|
-
|
|
107
|
-
var _stack = require("./stack");
|
|
1
|
+
export { Text } from "./text";
|
|
2
|
+
export { Box } from "./box";
|
|
3
|
+
export { Button } from "./button";
|
|
4
|
+
export { TextInput } from "./text-input";
|
|
5
|
+
export { Arrange } from "./arrange";
|
|
6
|
+
export { Icon } from "./icon";
|
|
7
|
+
export { IconButton } from "./icon-button";
|
|
8
|
+
export { TextButton } from "./text-button";
|
|
9
|
+
export { IconToggleGroup, IconToggle } from "./icon-toggle";
|
|
10
|
+
export { TextToggleGroup, TextToggle } from "./text-toggle";
|
|
11
|
+
export { Stack } from "./stack";
|
package/es/components/stack.js
CHANGED
|
@@ -1,94 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.Stack = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _utilities = require("../utilities");
|
|
19
|
-
|
|
20
|
-
var _react = _interopRequireDefault(require("react"));
|
|
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.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", "gap"];
|
|
21
8
|
|
|
22
|
-
var
|
|
9
|
+
var _templateObject;
|
|
23
10
|
|
|
24
|
-
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
25
12
|
|
|
26
|
-
var
|
|
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; }
|
|
27
14
|
|
|
28
|
-
var
|
|
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; }
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
import { getColor, getIconSize, getResponsiveSpace } from '../utilities';
|
|
20
|
+
import { PropTypes } from 'prop-types';
|
|
21
|
+
import React from "react";
|
|
22
|
+
import styled from "@emotion/styled";
|
|
23
|
+
import { types } from '../types';
|
|
24
|
+
var Wrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & > * + * {\n ", ";\n }\n"])), function (p) {
|
|
25
|
+
return getResponsiveSpace('margin-top', p.gap);
|
|
34
26
|
});
|
|
35
|
-
|
|
36
|
-
var Stack = function Stack(_ref) {
|
|
27
|
+
export var Stack = function Stack(_ref) {
|
|
37
28
|
var children = _ref.children,
|
|
38
29
|
gap = _ref.gap,
|
|
39
|
-
props = (
|
|
40
|
-
|
|
30
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
31
|
+
|
|
32
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
41
33
|
gap: gap
|
|
42
34
|
}, props), children);
|
|
43
35
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"description": "",
|
|
48
|
-
"methods": [],
|
|
49
|
-
"displayName": "Stack",
|
|
50
|
-
"props": {
|
|
51
|
-
"children": {
|
|
52
|
-
"type": {
|
|
53
|
-
"name": "node"
|
|
54
|
-
},
|
|
55
|
-
"required": false,
|
|
56
|
-
"description": ""
|
|
57
|
-
},
|
|
58
|
-
"gap": {
|
|
59
|
-
"type": {
|
|
60
|
-
"name": "union",
|
|
61
|
-
"value": [{
|
|
62
|
-
"name": "enum",
|
|
63
|
-
"value": [{
|
|
64
|
-
"value": "\"xs\"",
|
|
65
|
-
"computed": false
|
|
66
|
-
}, {
|
|
67
|
-
"value": "\"s\"",
|
|
68
|
-
"computed": false
|
|
69
|
-
}, {
|
|
70
|
-
"value": "\"m\"",
|
|
71
|
-
"computed": false
|
|
72
|
-
}, {
|
|
73
|
-
"value": "\"l\"",
|
|
74
|
-
"computed": false
|
|
75
|
-
}, {
|
|
76
|
-
"value": "\"xl\"",
|
|
77
|
-
"computed": false
|
|
78
|
-
}, {
|
|
79
|
-
"value": "\"xxl\"",
|
|
80
|
-
"computed": false
|
|
81
|
-
}]
|
|
82
|
-
}, {
|
|
83
|
-
"name": "number"
|
|
84
|
-
}, {
|
|
85
|
-
"name": "string"
|
|
86
|
-
}, {
|
|
87
|
-
"name": "object"
|
|
88
|
-
}]
|
|
89
|
-
},
|
|
90
|
-
"required": false,
|
|
91
|
-
"description": ""
|
|
92
|
-
}
|
|
93
|
-
}
|
|
36
|
+
Stack.propTypes = {
|
|
37
|
+
children: PropTypes.node,
|
|
38
|
+
gap: types.space
|
|
94
39
|
};
|
|
@@ -1,81 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.TextButton = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _components = require("../components");
|
|
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.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", "isDisabled", "icon"];
|
|
19
8
|
|
|
20
|
-
var
|
|
9
|
+
var _templateObject;
|
|
21
10
|
|
|
22
|
-
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
23
12
|
|
|
24
|
-
var
|
|
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; }
|
|
25
14
|
|
|
26
|
-
var
|
|
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; }
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
import { Icon } from '../components';
|
|
20
|
+
import React from "react";
|
|
21
|
+
import styled from "@emotion/styled";
|
|
22
|
+
import PropTypes from "prop-types";
|
|
23
|
+
import { ClearButtonBox } from '../foundational';
|
|
24
|
+
var Wrapper = styled(ClearButtonBox)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 0 8px;\n gap: 8px;\n"])));
|
|
25
|
+
export var TextButton = function TextButton(_ref) {
|
|
34
26
|
var children = _ref.children,
|
|
35
27
|
isDisabled = _ref.isDisabled,
|
|
36
28
|
icon = _ref.icon,
|
|
37
|
-
props = (
|
|
38
|
-
|
|
29
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
39
32
|
disabled: isDisabled,
|
|
40
33
|
icon: icon
|
|
41
|
-
}, props), icon &&
|
|
34
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
42
35
|
icon: icon
|
|
43
36
|
}), children && children);
|
|
44
37
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"displayName": "TextButton",
|
|
51
|
-
"props": {
|
|
52
|
-
"children": {
|
|
53
|
-
"type": {
|
|
54
|
-
"name": "node"
|
|
55
|
-
},
|
|
56
|
-
"required": false,
|
|
57
|
-
"description": ""
|
|
58
|
-
},
|
|
59
|
-
"icon": {
|
|
60
|
-
"type": {
|
|
61
|
-
"name": "node"
|
|
62
|
-
},
|
|
63
|
-
"required": false,
|
|
64
|
-
"description": ""
|
|
65
|
-
},
|
|
66
|
-
"onClick": {
|
|
67
|
-
"type": {
|
|
68
|
-
"name": "func"
|
|
69
|
-
},
|
|
70
|
-
"required": false,
|
|
71
|
-
"description": ""
|
|
72
|
-
},
|
|
73
|
-
"isDisabled": {
|
|
74
|
-
"type": {
|
|
75
|
-
"name": "bool"
|
|
76
|
-
},
|
|
77
|
-
"required": false,
|
|
78
|
-
"description": ""
|
|
79
|
-
}
|
|
80
|
-
}
|
|
38
|
+
TextButton.propTypes = {
|
|
39
|
+
children: PropTypes.node,
|
|
40
|
+
icon: PropTypes.node,
|
|
41
|
+
onClick: PropTypes.func,
|
|
42
|
+
isDisabled: PropTypes.bool
|
|
81
43
|
};
|
|
@@ -1,88 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
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.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
import "core-js/modules/es.symbol.description.js";
|
|
8
|
+
import "core-js/modules/es.object.to-string.js";
|
|
9
|
+
import "core-js/modules/es.symbol.iterator.js";
|
|
10
|
+
import "core-js/modules/es.array.iterator.js";
|
|
11
|
+
import "core-js/modules/es.string.iterator.js";
|
|
12
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
13
|
+
import "core-js/modules/es.array.from.js";
|
|
14
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
15
|
+
var _excluded = ["value", "placeholder", "size", "label", "id", "icon"];
|
|
17
16
|
|
|
18
|
-
var
|
|
17
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
import "core-js/modules/es.object.assign.js";
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
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."); }
|
|
25
24
|
|
|
26
|
-
var
|
|
25
|
+
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); }
|
|
27
26
|
|
|
28
|
-
var
|
|
27
|
+
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; }
|
|
29
28
|
|
|
30
|
-
var
|
|
29
|
+
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; }
|
|
31
30
|
|
|
32
|
-
|
|
31
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
32
|
|
|
34
|
-
var
|
|
33
|
+
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; }
|
|
35
34
|
|
|
36
|
-
var
|
|
35
|
+
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; }
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
import { getColor, getRadius, getTextSize } from '../utilities';
|
|
40
|
+
import { PropTypes } from 'prop-types';
|
|
41
|
+
import React from "react";
|
|
42
|
+
import styled from "@emotion/styled";
|
|
43
|
+
import { types } from '../types';
|
|
44
|
+
import { css } from '@emotion/react';
|
|
45
|
+
import { Box } from './box';
|
|
46
|
+
import { Icon } from './icon';
|
|
47
|
+
import { transitions } from '../foundational';
|
|
48
|
+
var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-color-fieldBorder: var(--grn-color-fade3);\n --grn-color-fieldBorder-hover: var(--grn-color-fade6);\n"])));
|
|
49
|
+
var sizesStyles = {
|
|
43
50
|
s: {
|
|
44
51
|
height: 'var(--grn-textBoxHeight-s)',
|
|
45
|
-
padding: '0
|
|
52
|
+
padding: '0 8px',
|
|
53
|
+
labelGap: '2px',
|
|
54
|
+
iconOffsetPx: 8,
|
|
55
|
+
iconTextGapPx: 4
|
|
46
56
|
},
|
|
47
57
|
m: {
|
|
48
58
|
height: 'var(--grn-textBoxHeight-m)',
|
|
49
|
-
padding: '0
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
s: {
|
|
54
|
-
labelGap: 2,
|
|
55
|
-
iconOffset: 8,
|
|
56
|
-
iconTextGap: 4
|
|
57
|
-
},
|
|
58
|
-
m: {
|
|
59
|
-
labelGap: 4,
|
|
60
|
-
iconOffset: 12,
|
|
61
|
-
iconTextGap: 8
|
|
59
|
+
padding: '0 12px',
|
|
60
|
+
labelGap: '4px',
|
|
61
|
+
iconOffsetPx: 12,
|
|
62
|
+
iconTextGapPx: 8
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return (0, _utilities.getTextSize)(p.size);
|
|
65
|
+
var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n font-size: ", ";\n"])), variables, function (p) {
|
|
66
|
+
return getTextSize(p.size);
|
|
67
67
|
});
|
|
68
|
-
|
|
69
|
-
var Label = _styled.default.label(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: block;\n margin-bottom: ", "px;\n"])), function (p) {
|
|
68
|
+
var Label = styled.label(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: block;\n margin-bottom: ", ";\n"])), function (p) {
|
|
70
69
|
return sizesStyles[p.size].labelGap;
|
|
71
70
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return (0, _utilities.getRadius)('s');
|
|
71
|
+
var InputField = styled.input(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n font-family: inherit;\n background-color: transparent;\n color: inherit;\n font-size: inherit;\n transition-property: border-color; \n border: 1px solid var(--grn-color-fieldBorder);\n width: 100%;\n border-radius: ", ";\n height: ", ";\n padding: ", ";\n ", ";\n outline: none;\n\n &::placeholder {\n color: ", ";\n }\n\n &:hover {\n border-color: var(--grn-color-fieldBorder-hover);\n }\n \n &:focus {\n transition: 0s;\n border-color: var(--grn-color-grey6);\n }\n"])), transitions, function (p) {
|
|
72
|
+
return getRadius('s');
|
|
75
73
|
}, function (p) {
|
|
76
|
-
return
|
|
74
|
+
return sizesStyles[p.size].height;
|
|
75
|
+
}, function (p) {
|
|
76
|
+
return sizesStyles[p.size].padding;
|
|
77
77
|
}, function (p) {
|
|
78
78
|
return p.paddingLeft && "padding-left: ".concat(p.paddingLeft, "px");
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return sizesStyles[p.size].iconOffset;
|
|
79
|
+
}, getColor('grey5'));
|
|
80
|
+
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"])), function (p) {
|
|
81
|
+
return sizesStyles[p.size].iconOffsetPx;
|
|
83
82
|
});
|
|
84
|
-
|
|
85
|
-
var TextInput = function TextInput(_ref) {
|
|
83
|
+
export var TextInput = function TextInput(_ref) {
|
|
86
84
|
var value = _ref.value,
|
|
87
85
|
placeholder = _ref.placeholder,
|
|
88
86
|
_ref$size = _ref.size,
|
|
@@ -90,37 +88,36 @@ var TextInput = function TextInput(_ref) {
|
|
|
90
88
|
label = _ref.label,
|
|
91
89
|
id = _ref.id,
|
|
92
90
|
icon = _ref.icon,
|
|
93
|
-
props = (
|
|
91
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
94
92
|
|
|
95
|
-
var iconRef =
|
|
93
|
+
var iconRef = React.useRef(null);
|
|
96
94
|
|
|
97
|
-
var _React$useState =
|
|
98
|
-
_React$useState2 = (
|
|
95
|
+
var _React$useState = React.useState(),
|
|
96
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
99
97
|
iconWidth = _React$useState2[0],
|
|
100
98
|
setIconWidth = _React$useState2[1];
|
|
101
99
|
|
|
102
|
-
|
|
100
|
+
React.useEffect(function () {
|
|
103
101
|
if (iconRef.current) {
|
|
104
102
|
setIconWidth(iconRef.current.getBoundingClientRect().width);
|
|
105
103
|
}
|
|
106
104
|
}, []);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return __jsx(Wrapper, {
|
|
105
|
+
var paddingLeft = icon && sizesStyles[size].iconOffsetPx + iconWidth + sizesStyles[size].iconTextGapPx;
|
|
106
|
+
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
110
107
|
size: size,
|
|
111
108
|
type: "text"
|
|
112
|
-
}, label &&
|
|
109
|
+
}, label && /*#__PURE__*/React.createElement(Label, {
|
|
113
110
|
htmlFor: id,
|
|
114
111
|
size: size
|
|
115
|
-
}, label),
|
|
112
|
+
}, label), /*#__PURE__*/React.createElement(Box, {
|
|
116
113
|
position: "relative"
|
|
117
|
-
}, icon &&
|
|
114
|
+
}, icon && /*#__PURE__*/React.createElement(IconSection, {
|
|
118
115
|
size: size
|
|
119
|
-
},
|
|
116
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
120
117
|
ref: iconRef,
|
|
121
118
|
icon: icon,
|
|
122
119
|
size: size
|
|
123
|
-
})),
|
|
120
|
+
})), /*#__PURE__*/React.createElement(InputField, Object.assign({
|
|
124
121
|
value: value,
|
|
125
122
|
placeholder: placeholder,
|
|
126
123
|
size: size,
|
|
@@ -130,70 +127,11 @@ var TextInput = function TextInput(_ref) {
|
|
|
130
127
|
paddingLeft: paddingLeft
|
|
131
128
|
}, props))));
|
|
132
129
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
"size": {
|
|
141
|
-
"defaultValue": {
|
|
142
|
-
"value": "'m'",
|
|
143
|
-
"computed": false
|
|
144
|
-
},
|
|
145
|
-
"type": {
|
|
146
|
-
"name": "enum",
|
|
147
|
-
"value": [{
|
|
148
|
-
"value": "\"s\"",
|
|
149
|
-
"computed": false
|
|
150
|
-
}, {
|
|
151
|
-
"value": "\"m\"",
|
|
152
|
-
"computed": false
|
|
153
|
-
}]
|
|
154
|
-
},
|
|
155
|
-
"required": false,
|
|
156
|
-
"description": ""
|
|
157
|
-
},
|
|
158
|
-
"id": {
|
|
159
|
-
"type": {
|
|
160
|
-
"name": "string"
|
|
161
|
-
},
|
|
162
|
-
"required": true,
|
|
163
|
-
"description": ""
|
|
164
|
-
},
|
|
165
|
-
"placeholder": {
|
|
166
|
-
"type": {
|
|
167
|
-
"name": "string"
|
|
168
|
-
},
|
|
169
|
-
"required": false,
|
|
170
|
-
"description": ""
|
|
171
|
-
},
|
|
172
|
-
"value": {
|
|
173
|
-
"type": {
|
|
174
|
-
"name": "string"
|
|
175
|
-
},
|
|
176
|
-
"required": false,
|
|
177
|
-
"description": ""
|
|
178
|
-
},
|
|
179
|
-
"label": {
|
|
180
|
-
"type": {
|
|
181
|
-
"name": "union",
|
|
182
|
-
"value": [{
|
|
183
|
-
"name": "string"
|
|
184
|
-
}, {
|
|
185
|
-
"name": "node"
|
|
186
|
-
}]
|
|
187
|
-
},
|
|
188
|
-
"required": false,
|
|
189
|
-
"description": ""
|
|
190
|
-
},
|
|
191
|
-
"icon": {
|
|
192
|
-
"type": {
|
|
193
|
-
"name": "node"
|
|
194
|
-
},
|
|
195
|
-
"required": false,
|
|
196
|
-
"description": ""
|
|
197
|
-
}
|
|
198
|
-
}
|
|
130
|
+
TextInput.propTypes = {
|
|
131
|
+
id: PropTypes.string.isRequired,
|
|
132
|
+
placeholder: PropTypes.string,
|
|
133
|
+
value: PropTypes.string,
|
|
134
|
+
size: types.fieldSize,
|
|
135
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
136
|
+
icon: PropTypes.node
|
|
199
137
|
};
|