@ntbjs/react-components 0.0.1-beta.47 → 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-d56265bd.js → ActionButton-90485300.js} +9 -9
- package/{AssetGallery-a5a6d3ee.js → AssetGallery-4c4801e3.js} +379 -279
- package/{Button-2ae8c0dc.js → Button-0d728b52.js} +36 -28
- package/{Checkbox-4037e160.js → Checkbox-5a78a73e.js} +33 -28
- package/{Popover-b16a26a5.js → Popover-d3e2f6c0.js} +15 -15
- package/{Radio-96f0bc13.js → Radio-73a1a897.js} +21 -20
- package/{Switch-7b696313.js → Switch-fcbf628c.js} +26 -24
- package/{TextArea-4be7199f.js → TextArea-167d2528.js} +37 -31
- package/TextInput-b61b7333.js +247 -0
- package/{Tooltip-a9271ef2.js → Tooltip-f95a39f4.js} +11 -11
- package/data/Popover/index.js +2 -2
- package/data/index.js +3 -3
- package/{defaultTheme-38b83bb5.js → defaultTheme-870f7df1.js} +105 -94
- package/inputs/ActionButton/index.js +2 -2
- package/inputs/Button/index.js +2 -2
- package/inputs/Checkbox/index.js +2 -2
- package/inputs/Radio/index.js +2 -2
- package/inputs/Switch/index.js +2 -2
- package/inputs/TextArea/index.js +2 -2
- package/inputs/TextInput/index.js +2 -2
- package/inputs/index.js +8 -8
- package/package.json +1 -1
- package/ssr/index.js +3 -1
- package/widgets/AssetGallery/index.js +12 -12
- package/widgets/index.js +12 -12
- package/TextInput-4deb971c.js +0 -163
package/TextInput-4deb971c.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var defaultTheme = require('./defaultTheme-38b83bb5.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;
|
|
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 TextInputField = styled__default["default"].input.attrs(defaultTheme.applyDefaultTheme)(_templateObject2 || (_templateObject2 = defaultTheme._taggedTemplateLiteral(["\n display: block;\n width: 100%;\n font-family: inherit;\n font-size: 0.875rem;\n line-height: 1;\n border-radius: 2px;\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.47rem !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) {
|
|
17
|
-
return props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-900'));
|
|
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.warning && styled.css(_templateObject3 || (_templateObject3 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
24
|
-
}, function (props) {
|
|
25
|
-
return props.error && styled.css(_templateObject4 || (_templateObject4 = defaultTheme._taggedTemplateLiteral(["\n border-color: ", " !important;\n "])), props.theme.getColor('red-500'));
|
|
26
|
-
}, function (props) {
|
|
27
|
-
return props.hasIcon && styled.css(_templateObject5 || (_templateObject5 = defaultTheme._taggedTemplateLiteral(["\n padding-left: 35px;\n "])));
|
|
28
|
-
}, function (props) {
|
|
29
|
-
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'), 1);
|
|
30
|
-
}, function (props) {
|
|
31
|
-
return props.theme.themeProp('opacity', 0.6, 0.5, 1);
|
|
32
|
-
}, function (props) {
|
|
33
|
-
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'));
|
|
34
|
-
});
|
|
35
|
-
var TextInputLabel = styled__default["default"].label.attrs(defaultTheme.applyDefaultTheme)(_templateObject6 || (_templateObject6 = 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 ", "\n\n content: \"\";\n\n ", "\n"])), function (props) {
|
|
36
|
-
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'));
|
|
37
|
-
}, function (props) {
|
|
38
|
-
return props.theme.themeProp('opacity', 0.6, 0.5);
|
|
39
|
-
}, function (props) {
|
|
40
|
-
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%)"));
|
|
41
|
-
}, function (props) {
|
|
42
|
-
return props.hasPlaceholder && styled.css(_templateObject7 || (_templateObject7 = defaultTheme._taggedTemplateLiteral(["\n ", ";\n ", "\n "])), activeLabel, props.error && styled.css(_templateObject8 || (_templateObject8 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('red-500')));
|
|
43
|
-
}, function (props) {
|
|
44
|
-
return props.hasIcon && styled.css(_templateObject9 || (_templateObject9 = defaultTheme._taggedTemplateLiteral(["\n left: 35px;\n "])));
|
|
45
|
-
});
|
|
46
|
-
var TextInputFieldIcon = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject10 || (_templateObject10 = 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"])));
|
|
47
|
-
var TextInput$1 = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject11 || (_templateObject11 = 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) {
|
|
48
|
-
return props.error && props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500'));
|
|
49
|
-
}, function (props) {
|
|
50
|
-
return props.error && styled.css(_templateObject12 || (_templateObject12 = defaultTheme._taggedTemplateLiteral(["\n // color: ", " !important;\n //\n "])), props.theme.getColor('red-500'));
|
|
51
|
-
}, function (props) {
|
|
52
|
-
return props.warning && styled.css(_templateObject13 || (_templateObject13 = defaultTheme._taggedTemplateLiteral(["\n color: ", " !important;\n "])), props.theme.getColor('orange-500'));
|
|
53
|
-
}, function (props) {
|
|
54
|
-
return props.disabled && styled.css(_templateObject14 || (_templateObject14 = defaultTheme._taggedTemplateLiteral(["\n opacity: 0.5;\n\n > * {\n cursor: not-allowed;\n }\n "])));
|
|
55
|
-
});
|
|
56
|
-
var Description = styled__default["default"].p.attrs(defaultTheme.applyDefaultTheme)(_templateObject15 || (_templateObject15 = 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) {
|
|
57
|
-
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
58
|
-
}, function (props) {
|
|
59
|
-
return props.error && styled.css(_templateObject16 || (_templateObject16 = defaultTheme._taggedTemplateLiteral(["\n content: 'error';\n ", "\n "])), props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
var _excluded = ["value", "defaultValue", "name", "label", "placeholder", "type", "required", "disabled", "autoComplete", "description", "error", "warning", "icon", "className", "style", "onChange", "onBlur"];
|
|
63
|
-
var TextInput = React__default["default"].forwardRef(function TextInput(_ref, forwardedRef) {
|
|
64
|
-
var value = _ref.value,
|
|
65
|
-
defaultValue = _ref.defaultValue,
|
|
66
|
-
name = _ref.name,
|
|
67
|
-
label = _ref.label,
|
|
68
|
-
placeholder = _ref.placeholder,
|
|
69
|
-
type = _ref.type,
|
|
70
|
-
required = _ref.required,
|
|
71
|
-
disabled = _ref.disabled,
|
|
72
|
-
autoComplete = _ref.autoComplete,
|
|
73
|
-
description = _ref.description,
|
|
74
|
-
error = _ref.error,
|
|
75
|
-
warning = _ref.warning,
|
|
76
|
-
icon = _ref.icon,
|
|
77
|
-
className = _ref.className,
|
|
78
|
-
style = _ref.style,
|
|
79
|
-
onChange = _ref.onChange,
|
|
80
|
-
onBlur = _ref.onBlur,
|
|
81
|
-
rest = defaultTheme._objectWithoutProperties(_ref, _excluded);
|
|
82
|
-
var _useState = React.useState(nanoid.nanoid()),
|
|
83
|
-
_useState2 = defaultTheme._slicedToArray(_useState, 1),
|
|
84
|
-
uniqueId = _useState2[0];
|
|
85
|
-
var hasError = React.useMemo(function () {
|
|
86
|
-
if (lodash.isBoolean(error)) {
|
|
87
|
-
return error;
|
|
88
|
-
}
|
|
89
|
-
return !lodash.isEmpty(error);
|
|
90
|
-
}, [error]);
|
|
91
|
-
var hasWarning = React.useMemo(function () {
|
|
92
|
-
if (lodash.isBoolean(warning)) {
|
|
93
|
-
return warning;
|
|
94
|
-
}
|
|
95
|
-
return !lodash.isEmpty(warning);
|
|
96
|
-
}, [warning]);
|
|
97
|
-
var descriptionText = React.useMemo(function () {
|
|
98
|
-
if (!lodash.isEmpty(error)) {
|
|
99
|
-
return error;
|
|
100
|
-
}
|
|
101
|
-
if (!lodash.isEmpty(warning)) {
|
|
102
|
-
return warning;
|
|
103
|
-
}
|
|
104
|
-
if (!lodash.isEmpty(description)) {
|
|
105
|
-
return description;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}, [description, error, warning]);
|
|
109
|
-
return React__default["default"].createElement(TextInput$1, {
|
|
110
|
-
disabled: disabled,
|
|
111
|
-
error: hasError,
|
|
112
|
-
warning: hasWarning,
|
|
113
|
-
className: className,
|
|
114
|
-
style: style
|
|
115
|
-
}, typeof icon !== 'undefined' && React__default["default"].createElement(TextInputFieldIcon, null, icon), React__default["default"].createElement(TextInputField, defaultTheme._extends({
|
|
116
|
-
ref: forwardedRef,
|
|
117
|
-
value: value,
|
|
118
|
-
defaultValue: defaultValue,
|
|
119
|
-
name: name,
|
|
120
|
-
placeholder: placeholder || ' ',
|
|
121
|
-
type: type,
|
|
122
|
-
required: required,
|
|
123
|
-
disabled: disabled,
|
|
124
|
-
autoComplete: autoComplete,
|
|
125
|
-
hasIcon: Boolean(icon),
|
|
126
|
-
error: hasError,
|
|
127
|
-
warning: hasWarning,
|
|
128
|
-
id: "text-input-".concat(uniqueId),
|
|
129
|
-
onChange: onChange,
|
|
130
|
-
onBlur: onBlur
|
|
131
|
-
}, rest)), label && React__default["default"].createElement(TextInputLabel, {
|
|
132
|
-
htmlFor: "text-input-".concat(uniqueId),
|
|
133
|
-
hasPlaceholder: Boolean(placeholder),
|
|
134
|
-
hasIcon: Boolean(icon),
|
|
135
|
-
error: hasError
|
|
136
|
-
}, label, required && ' *'), typeof descriptionText === 'string' && descriptionText.length > 0 && React__default["default"].createElement(Description, {
|
|
137
|
-
error: hasError
|
|
138
|
-
}, descriptionText));
|
|
139
|
-
});
|
|
140
|
-
TextInput.defaultProps = {
|
|
141
|
-
type: 'text'
|
|
142
|
-
};
|
|
143
|
-
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
144
|
-
value: defaultTheme.PropTypes.string,
|
|
145
|
-
defaultValue: defaultTheme.PropTypes.string,
|
|
146
|
-
name: defaultTheme.PropTypes.string,
|
|
147
|
-
label: defaultTheme.PropTypes.string,
|
|
148
|
-
placeholder: defaultTheme.PropTypes.string,
|
|
149
|
-
type: defaultTheme.PropTypes.string,
|
|
150
|
-
required: defaultTheme.PropTypes.bool,
|
|
151
|
-
disabled: defaultTheme.PropTypes.bool,
|
|
152
|
-
autoComplete: defaultTheme.PropTypes.string,
|
|
153
|
-
description: defaultTheme.PropTypes.string,
|
|
154
|
-
error: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
155
|
-
warning: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
156
|
-
icon: defaultTheme.PropTypes.element,
|
|
157
|
-
className: defaultTheme.PropTypes.string,
|
|
158
|
-
style: defaultTheme.PropTypes.object,
|
|
159
|
-
onChange: defaultTheme.PropTypes.func,
|
|
160
|
-
onBlur: defaultTheme.PropTypes.func
|
|
161
|
-
} : {};
|
|
162
|
-
|
|
163
|
-
exports.TextInput = TextInput;
|