@ntbjs/react-components 0.0.1-beta.46 → 0.0.1-beta.48
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/{ActionButton-9e502e55.js → ActionButton-90485300.js} +9 -9
- package/{AssetGallery-247242ac.js → AssetGallery-4c4801e3.js} +379 -278
- package/{Button-88652184.js → Button-0d728b52.js} +36 -28
- package/Checkbox-5a78a73e.js +126 -0
- package/{Popover-6ca643ba.js → Popover-d3e2f6c0.js} +15 -15
- package/Radio-73a1a897.js +80 -0
- package/Switch-fcbf628c.js +100 -0
- package/TextArea-167d2528.js +170 -0
- package/TextInput-b61b7333.js +247 -0
- package/{Tooltip-25b6f5fa.js → Tooltip-f95a39f4.js} +11 -11
- package/data/Popover/index.js +2 -2
- package/data/index.js +3 -3
- package/{defaultTheme-d8298500.js → defaultTheme-870f7df1.js} +108 -95
- package/inputs/ActionButton/index.js +2 -2
- package/inputs/Button/index.js +2 -2
- package/inputs/Checkbox/index.js +3 -2
- package/inputs/Radio/index.js +2 -2
- package/inputs/Switch/index.js +12 -0
- package/inputs/TextArea/index.js +2 -2
- package/inputs/TextInput/index.js +2 -2
- package/inputs/index.js +10 -8
- package/package.json +1 -1
- package/ssr/index.js +3 -1
- package/widgets/AssetGallery/index.js +12 -11
- package/widgets/index.js +12 -11
- package/Checkbox-25c75a7c.js +0 -122
- package/Radio-1521b33c.js +0 -71
- package/TextArea-a73b1729.js +0 -103
- package/TextInput-143d6346.js +0 -109
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultTheme = require('./defaultTheme-870f7df1.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var nanoid = require('nanoid');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var lodash = require('lodash');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
13
|
+
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
15
|
+
var activeLabel = styled.css(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n font-size: 0.75rem;\n padding: 0 3px;\n top: -7px;\n letter-spacing: 0.03em;\n left: 8px !important;\n opacity: 1 !important;\n"])));
|
|
16
|
+
var placeholderBaseStyle = styled.css(_templateObject2 || (_templateObject2 = defaultTheme._taggedTemplateLiteral(["\n ", "\n\n ", "\n"])), function (props) {
|
|
17
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'));
|
|
18
|
+
}, function (props) {
|
|
19
|
+
return props.theme.themeProp('opacity', 0.6, 0.5);
|
|
20
|
+
});
|
|
21
|
+
var TextInputField = styled__default['default'].textarea.attrs(defaultTheme.applyDefaultTheme)(_templateObject3 || (_templateObject3 = defaultTheme._taggedTemplateLiteral(["\n display: block;\n width: 100%;\n font-family: inherit;\n font-size: 0.875rem;\n border-radius: 2px;\n padding: 13px 10px;\n resize: vertical;\n ", "\n ", "\n border: 1px solid;\n ", "\n border-radius: 3px;\n box-sizing: border-box;\n appearance: none;\n transition: border-color 350ms;\n\n ", "\n ", "\n ", "\n\n &::placeholder {\n ", "\n\n ", "\n }\n\n :focus {\n outline: none;\n ", "\n }\n"])), function (props) {
|
|
22
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-900'));
|
|
23
|
+
}, function (props) {
|
|
24
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
25
|
+
}, function (props) {
|
|
26
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
27
|
+
}, function (props) {
|
|
28
|
+
return props.warning && styled.css(_templateObject4 || (_templateObject4 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
29
|
+
}, function (props) {
|
|
30
|
+
return props.error && styled.css(_templateObject5 || (_templateObject5 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('red-500'));
|
|
31
|
+
}, function (props) {
|
|
32
|
+
return props.hasIcon && styled.css(_templateObject6 || (_templateObject6 = defaultTheme._taggedTemplateLiteral(["\n padding-left: 35px;\n "])));
|
|
33
|
+
}, function (props) {
|
|
34
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'), 1);
|
|
35
|
+
}, function (props) {
|
|
36
|
+
return props.theme.themeProp('opacity', 0.6, 0.5, 1);
|
|
37
|
+
}, function (props) {
|
|
38
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'));
|
|
39
|
+
});
|
|
40
|
+
var TextInputLabel = styled__default['default'].label.attrs(defaultTheme.applyDefaultTheme)(_templateObject7 || (_templateObject7 = defaultTheme._taggedTemplateLiteral(["\n position: absolute;\n top: 13px;\n left: 11px;\n line-height: 1.2;\n font-size: 0.875rem;\n transition: all 150ms;\n\n ", ";\n\n ", "\n\n ", "\n\n content: \"\";\n\n ", "\n"])), placeholderBaseStyle, function (props) {
|
|
41
|
+
return props.theme.themeProp('background', "linear-gradient(0deg, ".concat(props.theme.getColor('gray-900'), " calc(50% + 1px), transparent 50%)"), "linear-gradient(0deg, ".concat(props.theme.getColor('white'), " calc(50% + 1px), transparent 50%)"));
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return props.hasPlaceholder && styled.css(_templateObject8 || (_templateObject8 = defaultTheme._taggedTemplateLiteral(["\n ", ";\n ", "\n "])), activeLabel, props.error && styled.css(_templateObject9 || (_templateObject9 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('red-500')));
|
|
44
|
+
}, function (props) {
|
|
45
|
+
return props.hasIcon && styled.css(_templateObject10 || (_templateObject10 = defaultTheme._taggedTemplateLiteral(["\n left: 35px;\n "])));
|
|
46
|
+
});
|
|
47
|
+
var TextInputFieldIcon = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject11 || (_templateObject11 = defaultTheme._taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n height: 2.625rem;\n display: flex;\n padding: 0 10px;\n\n svg {\n width: 15px;\n opacity: 0.6;\n transition: opacity 250ms;\n }\n"])));
|
|
48
|
+
var TextInput = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject12 || (_templateObject12 = defaultTheme._taggedTemplateLiteral(["\n position: relative;\n\n &:focus-within {\n ", " {\n ", ";\n }\n\n ", " {\n svg {\n opacity: 1;\n }\n }\n }\n\n ", ":not(:placeholder-shown) + ", " {\n ", ";\n ", "\n // ", "\n ", "\n }\n\n ", "\n"])), TextInputLabel, activeLabel, TextInputFieldIcon, TextInputField, TextInputLabel, activeLabel, function (props) {
|
|
49
|
+
return props.error && props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500'));
|
|
50
|
+
}, function (props) {
|
|
51
|
+
return props.error && styled.css(_templateObject13 || (_templateObject13 = defaultTheme._taggedTemplateLiteral(["\n // color: ", " !important;\n //\n "])), props.theme.getColor('red-500'));
|
|
52
|
+
}, function (props) {
|
|
53
|
+
return props.warning && styled.css(_templateObject14 || (_templateObject14 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
54
|
+
}, function (props) {
|
|
55
|
+
return props.disabled && styled.css(_templateObject15 || (_templateObject15 = defaultTheme._taggedTemplateLiteral(["\n opacity: 0.5;\n\n > * {\n cursor: not-allowed;\n }\n "])));
|
|
56
|
+
});
|
|
57
|
+
var Description = styled__default['default'].p.attrs(defaultTheme.applyDefaultTheme)(_templateObject16 || (_templateObject16 = defaultTheme._taggedTemplateLiteral(["\n margin: 8px 0 0 0;\n padding: 0 0.6875rem;\n font-size: 0.75rem;\n line-height: 1.333;\n\n ", ";\n\n ", "\n"])), function (props) {
|
|
58
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
59
|
+
}, function (props) {
|
|
60
|
+
return props.error && styled.css(_templateObject17 || (_templateObject17 = defaultTheme._taggedTemplateLiteral(["\n content: 'error';\n ", "\n "])), props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
var TextArea = React__default['default'].forwardRef(function TextArea(_ref, forwardedRef) {
|
|
64
|
+
var value = _ref.value,
|
|
65
|
+
defaultValue = _ref.defaultValue,
|
|
66
|
+
name = _ref.name,
|
|
67
|
+
label = _ref.label,
|
|
68
|
+
placeholder = _ref.placeholder,
|
|
69
|
+
required = _ref.required,
|
|
70
|
+
disabled = _ref.disabled,
|
|
71
|
+
autoComplete = _ref.autoComplete,
|
|
72
|
+
description = _ref.description,
|
|
73
|
+
error = _ref.error,
|
|
74
|
+
warning = _ref.warning,
|
|
75
|
+
icon = _ref.icon,
|
|
76
|
+
rows = _ref.rows,
|
|
77
|
+
className = _ref.className,
|
|
78
|
+
style = _ref.style,
|
|
79
|
+
onChange = _ref.onChange,
|
|
80
|
+
onBlur = _ref.onBlur,
|
|
81
|
+
rest = defaultTheme._objectWithoutProperties(_ref, ["value", "defaultValue", "name", "label", "placeholder", "required", "disabled", "autoComplete", "description", "error", "warning", "icon", "rows", "className", "style", "onChange", "onBlur"]);
|
|
82
|
+
|
|
83
|
+
var _useState = React.useState(nanoid.nanoid()),
|
|
84
|
+
_useState2 = defaultTheme._slicedToArray(_useState, 1),
|
|
85
|
+
uniqueId = _useState2[0];
|
|
86
|
+
|
|
87
|
+
var hasError = React.useMemo(function () {
|
|
88
|
+
if (lodash.isBoolean(error)) {
|
|
89
|
+
return error;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return !lodash.isEmpty(error);
|
|
93
|
+
}, [error]);
|
|
94
|
+
var hasWarning = React.useMemo(function () {
|
|
95
|
+
if (lodash.isBoolean(warning)) {
|
|
96
|
+
return warning;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return !lodash.isEmpty(warning);
|
|
100
|
+
}, [warning]);
|
|
101
|
+
var descriptionText = React.useMemo(function () {
|
|
102
|
+
if (!lodash.isEmpty(error)) {
|
|
103
|
+
return error;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (!lodash.isEmpty(warning)) {
|
|
107
|
+
return warning;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!lodash.isEmpty(description)) {
|
|
111
|
+
return description;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return null;
|
|
115
|
+
}, [description, error, warning]);
|
|
116
|
+
return React__default['default'].createElement(TextInput, {
|
|
117
|
+
disabled: disabled,
|
|
118
|
+
error: hasError,
|
|
119
|
+
warning: hasWarning,
|
|
120
|
+
className: className,
|
|
121
|
+
style: style
|
|
122
|
+
}, typeof icon !== 'undefined' && React__default['default'].createElement(TextInputFieldIcon, null, icon), React__default['default'].createElement(TextInputField, defaultTheme._extends({
|
|
123
|
+
ref: forwardedRef,
|
|
124
|
+
rows: rows,
|
|
125
|
+
value: value,
|
|
126
|
+
defaultValue: defaultValue,
|
|
127
|
+
name: name,
|
|
128
|
+
placeholder: placeholder || ' ',
|
|
129
|
+
required: required,
|
|
130
|
+
disabled: disabled,
|
|
131
|
+
autoComplete: autoComplete,
|
|
132
|
+
hasIcon: Boolean(icon),
|
|
133
|
+
error: hasError,
|
|
134
|
+
warning: hasWarning,
|
|
135
|
+
id: "text-input-".concat(uniqueId),
|
|
136
|
+
onChange: onChange,
|
|
137
|
+
onBlur: onBlur
|
|
138
|
+
}, rest)), label && React__default['default'].createElement(TextInputLabel, {
|
|
139
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
140
|
+
hasPlaceholder: Boolean(placeholder),
|
|
141
|
+
hasIcon: Boolean(icon),
|
|
142
|
+
error: hasError
|
|
143
|
+
}, label, required && ' *'), typeof descriptionText === 'string' && descriptionText.length > 0 && React__default['default'].createElement(Description, {
|
|
144
|
+
error: hasError
|
|
145
|
+
}, descriptionText));
|
|
146
|
+
});
|
|
147
|
+
TextArea.defaultProps = {
|
|
148
|
+
rows: 4
|
|
149
|
+
};
|
|
150
|
+
TextArea.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
151
|
+
value: defaultTheme.PropTypes.string,
|
|
152
|
+
defaultValue: defaultTheme.PropTypes.string,
|
|
153
|
+
name: defaultTheme.PropTypes.string,
|
|
154
|
+
label: defaultTheme.PropTypes.string,
|
|
155
|
+
placeholder: defaultTheme.PropTypes.string,
|
|
156
|
+
required: defaultTheme.PropTypes.bool,
|
|
157
|
+
disabled: defaultTheme.PropTypes.bool,
|
|
158
|
+
autoComplete: defaultTheme.PropTypes.string,
|
|
159
|
+
description: defaultTheme.PropTypes.string,
|
|
160
|
+
error: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
161
|
+
warning: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
162
|
+
icon: defaultTheme.PropTypes.element,
|
|
163
|
+
rows: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.number, defaultTheme.PropTypes.string]),
|
|
164
|
+
className: defaultTheme.PropTypes.string,
|
|
165
|
+
style: defaultTheme.PropTypes.object,
|
|
166
|
+
onChange: defaultTheme.PropTypes.func,
|
|
167
|
+
onBlur: defaultTheme.PropTypes.func
|
|
168
|
+
} : {};
|
|
169
|
+
|
|
170
|
+
exports.TextArea = TextArea;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultTheme = require('./defaultTheme-870f7df1.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var nanoid = require('nanoid');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
var lodash = require('lodash');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
13
|
+
|
|
14
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22;
|
|
15
|
+
var activeLabel = styled.css(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n font-size: 0.75rem;\n padding: 0 3px;\n top: -7px;\n letter-spacing: 0.03em;\n left: 8px !important;\n opacity: 1 !important;\n"])));
|
|
16
|
+
var Adornment = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject2 || (_templateObject2 = defaultTheme._taggedTemplateLiteral(["\n flex-shrink: 0;\n font-family: inherit;\n font-size: 0.875rem;\n line-height: 1;\n padding: 13px 10px;\n ", "\n ", "\n border: 1px solid;\n ", "\n border-radius: 3px;\n z-index: 1;\n ", "\n box-sizing: border-box;\n appearance: none;\n transition: border-color 350ms;\n height: 2.5rem;\n\n ", "\n ", "\n"])), function (props) {
|
|
17
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
18
|
+
}, function (props) {
|
|
19
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
20
|
+
}, function (props) {
|
|
21
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.isPrefix ? styled.css(_templateObject3 || (_templateObject3 = defaultTheme._taggedTemplateLiteral(["\n padding-right: 0;\n margin-right: -3px;\n border-right: 0;\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n "]))) : styled.css(_templateObject4 || (_templateObject4 = defaultTheme._taggedTemplateLiteral(["\n padding-left: 0;\n margin-left: -3px;\n border-left: 0;\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n "])));
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.warning && styled.css(_templateObject5 || (_templateObject5 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
26
|
+
}, function (props) {
|
|
27
|
+
return props.error && styled.css(_templateObject6 || (_templateObject6 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('red-500'));
|
|
28
|
+
});
|
|
29
|
+
var TextInputWrapper = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject7 || (_templateObject7 = defaultTheme._taggedTemplateLiteral(["\n display: flex;\n align-content: center;\n\n &:focus-within {\n ", " {\n outline: none;\n ", "\n }\n }\n"])), Adornment, function (props) {
|
|
30
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'), 1);
|
|
31
|
+
});
|
|
32
|
+
var TextInputField = styled__default['default'].input.attrs(defaultTheme.applyDefaultTheme)(_templateObject8 || (_templateObject8 = defaultTheme._taggedTemplateLiteral(["\n display: block;\n width: 100%;\n font-family: inherit;\n font-size: 0.875rem;\n line-height: 1;\n padding: 13px 10px;\n ", "\n ", "\n border: 1px solid;\n ", "\n border-radius: 3px;\n box-sizing: border-box;\n appearance: none;\n transition: border-color 350ms;\n height: 2.5rem !important; // important is needed to override the default Foundation styling used in the Mediebank\n margin-bottom: 0; // needed to override the default Foundation styling used in the Mediebank\n\n ", "\n ", "\n ", "\n\n &::placeholder {\n ", "\n\n ", "\n }\n\n :focus {\n outline: none;\n ", "\n }\n"])), function (props) {
|
|
33
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-900'));
|
|
34
|
+
}, function (props) {
|
|
35
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
36
|
+
}, function (props) {
|
|
37
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
38
|
+
}, function (props) {
|
|
39
|
+
return props.warning && styled.css(_templateObject9 || (_templateObject9 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
40
|
+
}, function (props) {
|
|
41
|
+
return props.error && styled.css(_templateObject10 || (_templateObject10 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('red-500'));
|
|
42
|
+
}, function (props) {
|
|
43
|
+
return props.hasIcon && styled.css(_templateObject11 || (_templateObject11 = defaultTheme._taggedTemplateLiteral(["\n padding-left: 35px;\n "])));
|
|
44
|
+
}, function (props) {
|
|
45
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'), 1);
|
|
46
|
+
}, function (props) {
|
|
47
|
+
return props.theme.themeProp('opacity', 0.6, 0.5, 1);
|
|
48
|
+
}, function (props) {
|
|
49
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'));
|
|
50
|
+
});
|
|
51
|
+
var TextInputLabel = styled__default['default'].label.attrs(defaultTheme.applyDefaultTheme)(_templateObject12 || (_templateObject12 = defaultTheme._taggedTemplateLiteral(["\n position: absolute;\n z-index: 1;\n top: 12px;\n left: 11px;\n line-height: 1.2;\n font-size: 0.875rem;\n transition: all 150ms;\n\n ", "\n\n ", "\n\n ", "\n\n ", "\n\n content: \"\";\n\n ", "\n"])), function (props) {
|
|
52
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'));
|
|
53
|
+
}, function (props) {
|
|
54
|
+
return props.theme.themeProp('opacity', 0.6, 0.5);
|
|
55
|
+
}, function (props) {
|
|
56
|
+
return props.theme.themeProp('background', "linear-gradient(0deg, ".concat(props.theme.getColor('gray-900'), " calc(50% + 1px), transparent 50%)"), "linear-gradient(0deg, ".concat(props.theme.getColor('white'), " calc(50% + 1px), transparent 50%)"));
|
|
57
|
+
}, function (props) {
|
|
58
|
+
return (props.hasPlaceholder || props.hasAdornments) && styled.css(_templateObject13 || (_templateObject13 = defaultTheme._taggedTemplateLiteral(["\n ", ";\n ", "\n "])), activeLabel, props.error && styled.css(_templateObject14 || (_templateObject14 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('red-500')));
|
|
59
|
+
}, function (props) {
|
|
60
|
+
return props.hasIcon && styled.css(_templateObject15 || (_templateObject15 = defaultTheme._taggedTemplateLiteral(["\n left: 35px;\n "])));
|
|
61
|
+
});
|
|
62
|
+
var TextInputFieldIcon = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject16 || (_templateObject16 = defaultTheme._taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n left: 0;\n height: 2.625rem;\n display: flex;\n padding: 0 10px;\n\n svg {\n width: 15px;\n opacity: 0.6;\n transition: opacity 250ms;\n }\n"])));
|
|
63
|
+
var TextInput$1 = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject17 || (_templateObject17 = defaultTheme._taggedTemplateLiteral(["\n position: relative;\n\n &:focus-within {\n ", " {\n ", ";\n }\n\n ", " {\n svg {\n opacity: 1;\n }\n }\n }\n\n ", ":not(:placeholder-shown) + ", " {\n ", ";\n ", "\n // ", "\n ", "\n }\n\n ", "\n"])), TextInputLabel, activeLabel, TextInputFieldIcon, TextInputField, TextInputLabel, activeLabel, function (props) {
|
|
64
|
+
return props.error && props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500'));
|
|
65
|
+
}, function (props) {
|
|
66
|
+
return props.error && styled.css(_templateObject18 || (_templateObject18 = defaultTheme._taggedTemplateLiteral(["\n // color: ", " !important;\n //\n "])), props.theme.getColor('red-500'));
|
|
67
|
+
}, function (props) {
|
|
68
|
+
return props.warning && styled.css(_templateObject19 || (_templateObject19 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
69
|
+
}, function (props) {
|
|
70
|
+
return props.disabled && styled.css(_templateObject20 || (_templateObject20 = defaultTheme._taggedTemplateLiteral(["\n opacity: 0.5;\n\n > * {\n cursor: not-allowed;\n }\n "])));
|
|
71
|
+
});
|
|
72
|
+
var Description = styled__default['default'].p.attrs(defaultTheme.applyDefaultTheme)(_templateObject21 || (_templateObject21 = defaultTheme._taggedTemplateLiteral(["\n margin: 8px 0 0 0;\n padding: 0 0.6875rem;\n font-size: 0.75rem;\n line-height: 1.333;\n\n ", ";\n\n ", "\n"])), function (props) {
|
|
73
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
74
|
+
}, function (props) {
|
|
75
|
+
return props.error && styled.css(_templateObject22 || (_templateObject22 = defaultTheme._taggedTemplateLiteral(["\n content: 'error';\n ", "\n "])), props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
var toFnRef = function toFnRef(ref) {
|
|
79
|
+
return !ref || typeof ref === 'function' ? ref : function (value) {
|
|
80
|
+
ref.current = value;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
function mergeRefs(refA, refB) {
|
|
85
|
+
var a = toFnRef(refA);
|
|
86
|
+
var b = toFnRef(refB);
|
|
87
|
+
return function (value) {
|
|
88
|
+
if (a) a(value);
|
|
89
|
+
if (b) b(value);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create and returns a single callback ref composed from two other Refs.
|
|
94
|
+
*
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const Button = React.forwardRef((props, ref) => {
|
|
97
|
+
* const [element, attachRef] = useCallbackRef<HTMLButtonElement>();
|
|
98
|
+
* const mergedRef = useMergedRefs(ref, attachRef);
|
|
99
|
+
*
|
|
100
|
+
* return <button ref={mergedRef} {...props}/>
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param refA A Callback or mutable Ref
|
|
105
|
+
* @param refB A Callback or mutable Ref
|
|
106
|
+
* @category refs
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
function useMergedRefs(refA, refB) {
|
|
110
|
+
return React.useMemo(function () {
|
|
111
|
+
return mergeRefs(refA, refB);
|
|
112
|
+
}, [refA, refB]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var TextInput = React__default['default'].forwardRef(function TextInput(_ref, forwardedRef) {
|
|
116
|
+
var value = _ref.value,
|
|
117
|
+
defaultValue = _ref.defaultValue,
|
|
118
|
+
name = _ref.name,
|
|
119
|
+
label = _ref.label,
|
|
120
|
+
placeholder = _ref.placeholder,
|
|
121
|
+
type = _ref.type,
|
|
122
|
+
required = _ref.required,
|
|
123
|
+
disabled = _ref.disabled,
|
|
124
|
+
autoComplete = _ref.autoComplete,
|
|
125
|
+
description = _ref.description,
|
|
126
|
+
error = _ref.error,
|
|
127
|
+
warning = _ref.warning,
|
|
128
|
+
icon = _ref.icon,
|
|
129
|
+
adornments = _ref.adornments,
|
|
130
|
+
className = _ref.className,
|
|
131
|
+
style = _ref.style,
|
|
132
|
+
onChange = _ref.onChange,
|
|
133
|
+
onBlur = _ref.onBlur,
|
|
134
|
+
rest = defaultTheme._objectWithoutProperties(_ref, ["value", "defaultValue", "name", "label", "placeholder", "type", "required", "disabled", "autoComplete", "description", "error", "warning", "icon", "adornments", "className", "style", "onChange", "onBlur"]);
|
|
135
|
+
|
|
136
|
+
var textInputDomNode = React.useRef(null);
|
|
137
|
+
var textInputRef = useMergedRefs(forwardedRef, textInputDomNode);
|
|
138
|
+
|
|
139
|
+
var _useState = React.useState(nanoid.nanoid()),
|
|
140
|
+
_useState2 = defaultTheme._slicedToArray(_useState, 1),
|
|
141
|
+
uniqueId = _useState2[0];
|
|
142
|
+
|
|
143
|
+
var hasError = React.useMemo(function () {
|
|
144
|
+
if (lodash.isBoolean(error)) {
|
|
145
|
+
return error;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return !lodash.isEmpty(error);
|
|
149
|
+
}, [error]);
|
|
150
|
+
var hasWarning = React.useMemo(function () {
|
|
151
|
+
if (lodash.isBoolean(warning)) {
|
|
152
|
+
return warning;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return !lodash.isEmpty(warning);
|
|
156
|
+
}, [warning]);
|
|
157
|
+
var descriptionText = React.useMemo(function () {
|
|
158
|
+
if (!lodash.isEmpty(error)) {
|
|
159
|
+
return error;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!lodash.isEmpty(warning)) {
|
|
163
|
+
return warning;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!lodash.isEmpty(description)) {
|
|
167
|
+
return description;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return null;
|
|
171
|
+
}, [description, error, warning]);
|
|
172
|
+
return React__default['default'].createElement(TextInput$1, {
|
|
173
|
+
disabled: disabled,
|
|
174
|
+
error: hasError,
|
|
175
|
+
warning: hasWarning,
|
|
176
|
+
className: className,
|
|
177
|
+
style: style
|
|
178
|
+
}, typeof icon !== 'undefined' && React__default['default'].createElement(TextInputFieldIcon, null, icon), React__default['default'].createElement(TextInputWrapper, null, typeof (adornments === null || adornments === void 0 ? void 0 : adornments.prefix) === 'string' && adornments.prefix.length > 0 && React__default['default'].createElement(Adornment, {
|
|
179
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
180
|
+
error: hasError,
|
|
181
|
+
warning: hasWarning,
|
|
182
|
+
isPrefix: true,
|
|
183
|
+
onClick: function onClick() {
|
|
184
|
+
return textInputDomNode.current.focus();
|
|
185
|
+
}
|
|
186
|
+
}, adornments.prefix), React__default['default'].createElement(TextInputField, defaultTheme._extends({
|
|
187
|
+
ref: textInputRef,
|
|
188
|
+
value: value,
|
|
189
|
+
defaultValue: defaultValue,
|
|
190
|
+
name: name,
|
|
191
|
+
placeholder: placeholder || ' ',
|
|
192
|
+
type: type,
|
|
193
|
+
required: required,
|
|
194
|
+
disabled: disabled,
|
|
195
|
+
autoComplete: autoComplete,
|
|
196
|
+
hasIcon: Boolean(icon),
|
|
197
|
+
error: hasError,
|
|
198
|
+
warning: hasWarning,
|
|
199
|
+
id: "text-input-".concat(uniqueId),
|
|
200
|
+
onChange: onChange,
|
|
201
|
+
onBlur: onBlur
|
|
202
|
+
}, rest)), typeof (adornments === null || adornments === void 0 ? void 0 : adornments.suffix) === 'string' && adornments.suffix.length > 0 && React__default['default'].createElement(Adornment, {
|
|
203
|
+
error: hasError,
|
|
204
|
+
warning: hasWarning,
|
|
205
|
+
isPrefix: false,
|
|
206
|
+
onClick: function onClick() {
|
|
207
|
+
return textInputDomNode.current.focus();
|
|
208
|
+
}
|
|
209
|
+
}, adornments.suffix)), label && React__default['default'].createElement(TextInputLabel, {
|
|
210
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
211
|
+
hasPlaceholder: Boolean(placeholder),
|
|
212
|
+
hasAdornments: Boolean(typeof (adornments === null || adornments === void 0 ? void 0 : adornments.prefix) === 'string' && adornments.prefix.length > 0 || typeof (adornments === null || adornments === void 0 ? void 0 : adornments.suffix) === 'string' && adornments.suffix.length > 0),
|
|
213
|
+
hasIcon: Boolean(icon),
|
|
214
|
+
error: hasError
|
|
215
|
+
}, label, required && ' *'), typeof descriptionText === 'string' && descriptionText.length > 0 && React__default['default'].createElement(Description, {
|
|
216
|
+
error: hasError
|
|
217
|
+
}, descriptionText));
|
|
218
|
+
});
|
|
219
|
+
TextInput.defaultProps = {
|
|
220
|
+
type: 'text'
|
|
221
|
+
};
|
|
222
|
+
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
223
|
+
value: defaultTheme.PropTypes.string,
|
|
224
|
+
defaultValue: defaultTheme.PropTypes.string,
|
|
225
|
+
name: defaultTheme.PropTypes.string,
|
|
226
|
+
label: defaultTheme.PropTypes.string,
|
|
227
|
+
placeholder: defaultTheme.PropTypes.string,
|
|
228
|
+
type: defaultTheme.PropTypes.string,
|
|
229
|
+
required: defaultTheme.PropTypes.bool,
|
|
230
|
+
disabled: defaultTheme.PropTypes.bool,
|
|
231
|
+
autoComplete: defaultTheme.PropTypes.string,
|
|
232
|
+
description: defaultTheme.PropTypes.string,
|
|
233
|
+
error: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
234
|
+
warning: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
235
|
+
icon: defaultTheme.PropTypes.element,
|
|
236
|
+
adornments: defaultTheme.PropTypes.shape({
|
|
237
|
+
prefix: defaultTheme.PropTypes.string,
|
|
238
|
+
suffix: defaultTheme.PropTypes.string
|
|
239
|
+
}),
|
|
240
|
+
className: defaultTheme.PropTypes.string,
|
|
241
|
+
style: defaultTheme.PropTypes.object,
|
|
242
|
+
onChange: defaultTheme.PropTypes.func,
|
|
243
|
+
onBlur: defaultTheme.PropTypes.func
|
|
244
|
+
} : {};
|
|
245
|
+
|
|
246
|
+
exports.TextInput = TextInput;
|
|
247
|
+
exports.useMergedRefs = useMergedRefs;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var defaultTheme = require('./defaultTheme-
|
|
3
|
+
var defaultTheme = require('./defaultTheme-870f7df1.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var styled = require('styled-components');
|
|
6
6
|
var TippyTooltip = require('@tippyjs/react');
|
|
7
|
-
require('./Popover-
|
|
7
|
+
require('./Popover-d3e2f6c0.js');
|
|
8
8
|
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
|
13
13
|
var TippyTooltip__default = /*#__PURE__*/_interopDefaultLegacy(TippyTooltip);
|
|
14
14
|
|
|
15
15
|
var _templateObject;
|
|
16
|
-
var Tooltip$1 = styled__default[
|
|
16
|
+
var Tooltip$1 = styled__default['default'](TippyTooltip__default['default']).attrs(defaultTheme.applyDefaultTheme)(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n font-family: ", ";\n font-size: 1rem;\n font-weight: 400;\n background: ", ";\n border-radius: 3px;\n\n .tippy-content {\n padding: 9px 12px;\n }\n\n .tippy-arrow {\n color: ", ";\n }\n\n a {\n color: inherit;\n }\n"])), function (props) {
|
|
17
17
|
return props.theme.primaryFontFamily;
|
|
18
18
|
}, function (props) {
|
|
19
19
|
return props.theme.getColor('gray-700');
|
|
@@ -21,15 +21,15 @@ var Tooltip$1 = styled__default["default"](TippyTooltip__default["default"]).att
|
|
|
21
21
|
return props.theme.getColor('gray-700');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
var
|
|
25
|
-
var Tooltip = React__default["default"].forwardRef(function Tooltip(_ref, ref) {
|
|
24
|
+
var Tooltip = React__default['default'].forwardRef(function Tooltip(_ref, ref) {
|
|
26
25
|
var content = _ref.content,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
interactive = _ref.interactive,
|
|
27
|
+
placement = _ref.placement,
|
|
28
|
+
duration = _ref.duration,
|
|
29
|
+
children = _ref.children,
|
|
30
|
+
props = defaultTheme._objectWithoutProperties(_ref, ["content", "interactive", "placement", "duration", "children"]);
|
|
31
|
+
|
|
32
|
+
return React__default['default'].createElement(Tooltip$1, defaultTheme._extends({
|
|
33
33
|
ref: ref,
|
|
34
34
|
content: content,
|
|
35
35
|
interactive: interactive,
|
package/data/Popover/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var Popover = require('../../Popover-
|
|
4
|
-
require('../../defaultTheme-
|
|
3
|
+
var Popover = require('../../Popover-d3e2f6c0.js');
|
|
4
|
+
require('../../defaultTheme-870f7df1.js');
|
|
5
5
|
require('styled-components');
|
|
6
6
|
require('react');
|
|
7
7
|
require('lodash');
|
package/data/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Popover = require('../Popover-
|
|
6
|
-
var Tooltip = require('../Tooltip-
|
|
7
|
-
require('../defaultTheme-
|
|
5
|
+
var Popover = require('../Popover-d3e2f6c0.js');
|
|
6
|
+
var Tooltip = require('../Tooltip-f95a39f4.js');
|
|
7
|
+
require('../defaultTheme-870f7df1.js');
|
|
8
8
|
require('styled-components');
|
|
9
9
|
require('react');
|
|
10
10
|
require('lodash');
|