@ntbjs/react-components 0.0.1-beta.25 → 0.0.1-beta.26
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/{AssetGallery-424224f2.js → AssetGallery-16efec65.js} +2 -1
- package/Button-ad55d102.js +140 -0
- package/{TextInput-d286c90e.js → TextInput-099562d7.js} +11 -5
- package/inputs/Button/index.js +10 -0
- package/inputs/TextInput/index.js +1 -1
- package/inputs/index.js +3 -1
- package/package.json +2 -2
- package/widgets/AssetGallery/index.js +3 -2
- package/widgets/index.js +3 -2
|
@@ -5,9 +5,10 @@ var React = require('react');
|
|
|
5
5
|
var lodash = require('lodash');
|
|
6
6
|
var reactLazyLoadImageComponent = require('react-lazy-load-image-component');
|
|
7
7
|
var ActionButton = require('./ActionButton-10a681b9.js');
|
|
8
|
+
require('./Button-ad55d102.js');
|
|
8
9
|
require('./Checkbox-791a409f.js');
|
|
9
10
|
require('./Radio-9271a4b6.js');
|
|
10
|
-
require('./TextInput-
|
|
11
|
+
require('./TextInput-099562d7.js');
|
|
11
12
|
require('./Popover-0ff13419.js');
|
|
12
13
|
var Tooltip = require('./Tooltip-85e7d561.js');
|
|
13
14
|
var styled = require('styled-components');
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultTheme = require('./defaultTheme-18d7c1ee.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var styled = require('styled-components');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
|
|
12
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
13
|
+
var Button$1 = styled__default['default'].button.attrs(defaultTheme.applyDefaultTheme)(_templateObject || (_templateObject = defaultTheme._taggedTemplateLiteral(["\n position: relative;\n border-radius: 3px;\n font-family: inherit;\n font-size: inherit;\n font-weight: 500;\n padding: 8px 18px;\n cursor: pointer;\n transition: opacity 200ms;\n background: ", ";\n border: 2px solid ", ";\n\n ", "\n\n && {\n ", ";\n }\n\n && {\n ", ";\n }\n\n ", ";\n\n ", ";\n\n ", ";\n"])), function (props) {
|
|
14
|
+
return props.theme.getColor('emerald-500');
|
|
15
|
+
}, function (props) {
|
|
16
|
+
return props.theme.getColor('emerald-500');
|
|
17
|
+
}, function (props) {
|
|
18
|
+
return props.theme.themeProp('color', props.theme.getColor('white'), props.theme.getColor('white'));
|
|
19
|
+
}, function (props) {
|
|
20
|
+
return props.secondary && styled.css(_templateObject2 || (_templateObject2 = defaultTheme._taggedTemplateLiteral(["\n background: ", ";\n ", "\n border-color: ", ";\n "])), function (props) {
|
|
21
|
+
return props.theme.getColor('gray-200');
|
|
22
|
+
}, props.theme.themeProp('color', props.theme.getColor('gray-700'), props.theme.getColor('gray-700')), function (props) {
|
|
23
|
+
return props.theme.getColor('gray-200');
|
|
24
|
+
});
|
|
25
|
+
}, function (props) {
|
|
26
|
+
return props.outlined && styled.css(_templateObject3 || (_templateObject3 = defaultTheme._taggedTemplateLiteral(["\n background: transparent;\n ", "\n "])), props.theme.themeProp('color', props.theme.getColor('emerald-500'), props.theme.getColor('emerald-500')));
|
|
27
|
+
}, function (props) {
|
|
28
|
+
return props.outlined && props.secondary && styled.css(_templateObject4 || (_templateObject4 = defaultTheme._taggedTemplateLiteral(["\n background: transparent;\n ", "\n "])), props.theme.themeProp('color', props.theme.getColor('gray-200'), props.theme.getColor('gray-700')));
|
|
29
|
+
}, function (props) {
|
|
30
|
+
return props.block && styled.css(_templateObject5 || (_templateObject5 = defaultTheme._taggedTemplateLiteral(["\n width: 100%;\n "])));
|
|
31
|
+
}, function (props) {
|
|
32
|
+
return props.disabled && styled.css(_templateObject6 || (_templateObject6 = defaultTheme._taggedTemplateLiteral(["\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n "])));
|
|
33
|
+
});
|
|
34
|
+
var ButtonContent = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject7 || (_templateObject7 = defaultTheme._taggedTemplateLiteral(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n font-size: 0.875rem;\n transform: scale(1);\n opacity: 1;\n transition: all 200ms;\n\n > svg {\n width: 100%;\n max-width: 13px;\n max-height: 13px;\n margin-right: 7px;\n }\n\n ", "\n"])), function (props) {
|
|
35
|
+
return props.loading && styled.css(_templateObject8 || (_templateObject8 = defaultTheme._taggedTemplateLiteral(["\n transform: scale(0.95);\n opacity: 0;\n "])));
|
|
36
|
+
});
|
|
37
|
+
var LoadingIndicator = styled__default['default'].div.attrs(defaultTheme.applyDefaultTheme)(_templateObject9 || (_templateObject9 = defaultTheme._taggedTemplateLiteral(["\n position: absolute;\n height: 100%;\n width: 100%;\n top: 0;\n left: 0;\n padding: 4px;\n background: inherit;\n opacity: 0;\n transition: opacity 200ms;\n box-sizing: border-box;\n\n ", "\n"])), function (props) {
|
|
38
|
+
return props.loading && styled.css(_templateObject10 || (_templateObject10 = defaultTheme._taggedTemplateLiteral(["\n opacity: 1;\n "])));
|
|
39
|
+
});
|
|
40
|
+
var LoadingIndicatorSvg = styled__default['default'].svg.attrs(defaultTheme.applyDefaultTheme)(_templateObject11 || (_templateObject11 = defaultTheme._taggedTemplateLiteral(["\n height: 100%;\n color: inherit;\n transform: rotate(-88deg);\n"])));
|
|
41
|
+
var LoadingIndicatorSvgCircle = styled__default['default'].circle.attrs(defaultTheme.applyDefaultTheme)(_templateObject12 || (_templateObject12 = defaultTheme._taggedTemplateLiteral(["\n transition: stroke-dashoffset 300ms linear;\n stroke-dasharray: 113;\n"])));
|
|
42
|
+
|
|
43
|
+
function Button(_ref) {
|
|
44
|
+
var secondary = _ref.secondary,
|
|
45
|
+
outlined = _ref.outlined,
|
|
46
|
+
block = _ref.block,
|
|
47
|
+
icon = _ref.icon,
|
|
48
|
+
disabled = _ref.disabled,
|
|
49
|
+
loading = _ref.loading,
|
|
50
|
+
className = _ref.className,
|
|
51
|
+
children = _ref.children,
|
|
52
|
+
props = defaultTheme._objectWithoutProperties(_ref, ["secondary", "outlined", "block", "icon", "disabled", "loading", "className", "children"]);
|
|
53
|
+
|
|
54
|
+
var _useState = React.useState(loading || false),
|
|
55
|
+
_useState2 = defaultTheme._slicedToArray(_useState, 2),
|
|
56
|
+
loadingState = _useState2[0],
|
|
57
|
+
setLoadingState = _useState2[1];
|
|
58
|
+
|
|
59
|
+
var _useState3 = React.useState(113),
|
|
60
|
+
_useState4 = defaultTheme._slicedToArray(_useState3, 2),
|
|
61
|
+
loadingStep = _useState4[0],
|
|
62
|
+
setLoadingStep = _useState4[1];
|
|
63
|
+
|
|
64
|
+
var loadingInterval = React.useRef(0);
|
|
65
|
+
|
|
66
|
+
var enableLoading = function enableLoading() {
|
|
67
|
+
loadingInterval.current = setInterval(function () {
|
|
68
|
+
setLoadingStep(function (currentLoadingStep) {
|
|
69
|
+
var newLoadingStep = Math.round(currentLoadingStep - 15 * currentLoadingStep / 100);
|
|
70
|
+
|
|
71
|
+
if (newLoadingStep === currentLoadingStep) {
|
|
72
|
+
clearInterval(loadingInterval.current);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return newLoadingStep;
|
|
76
|
+
});
|
|
77
|
+
}, 300);
|
|
78
|
+
setLoadingState(true);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var disableLoading = function disableLoading() {
|
|
82
|
+
clearInterval(loadingInterval.current);
|
|
83
|
+
setLoadingStep(0);
|
|
84
|
+
setTimeout(function () {
|
|
85
|
+
setLoadingState(false);
|
|
86
|
+
setLoadingStep(113);
|
|
87
|
+
}, 500);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
React.useEffect(function () {
|
|
91
|
+
if (loading) {
|
|
92
|
+
enableLoading();
|
|
93
|
+
} else {
|
|
94
|
+
disableLoading();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return function () {
|
|
98
|
+
return clearInterval(loadingInterval.current);
|
|
99
|
+
};
|
|
100
|
+
}, [loading]);
|
|
101
|
+
return React__default['default'].createElement(Button$1, defaultTheme._extends({
|
|
102
|
+
secondary: secondary,
|
|
103
|
+
outlined: outlined,
|
|
104
|
+
block: block,
|
|
105
|
+
disabled: disabled,
|
|
106
|
+
className: className
|
|
107
|
+
}, props), React__default['default'].createElement(ButtonContent, {
|
|
108
|
+
loading: loadingState
|
|
109
|
+
}, icon, children), React__default['default'].createElement(LoadingIndicator, {
|
|
110
|
+
loading: loadingState,
|
|
111
|
+
style: {
|
|
112
|
+
opacity: loadingState ? 1 : 0
|
|
113
|
+
}
|
|
114
|
+
}, React__default['default'].createElement(LoadingIndicatorSvg, {
|
|
115
|
+
viewBox: "22 22 44 44"
|
|
116
|
+
}, React__default['default'].createElement(LoadingIndicatorSvgCircle, {
|
|
117
|
+
cx: "44",
|
|
118
|
+
cy: "44",
|
|
119
|
+
r: "18",
|
|
120
|
+
fill: "none",
|
|
121
|
+
strokeWidth: "4",
|
|
122
|
+
stroke: "currentColor",
|
|
123
|
+
style: {
|
|
124
|
+
strokeDashoffset: "".concat(loadingStep, "px")
|
|
125
|
+
}
|
|
126
|
+
}))));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Button.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
130
|
+
secondary: defaultTheme.PropTypes.bool,
|
|
131
|
+
outlined: defaultTheme.PropTypes.bool,
|
|
132
|
+
block: defaultTheme.PropTypes.bool,
|
|
133
|
+
icon: defaultTheme.PropTypes.element,
|
|
134
|
+
disabled: defaultTheme.PropTypes.bool,
|
|
135
|
+
loading: defaultTheme.PropTypes.bool,
|
|
136
|
+
className: defaultTheme.PropTypes.string,
|
|
137
|
+
children: defaultTheme.PropTypes.any.isRequired
|
|
138
|
+
} : {};
|
|
139
|
+
|
|
140
|
+
exports.Button = Button;
|
|
@@ -36,18 +36,20 @@ var TextInputField = styled__default['default'].input.attrs(defaultTheme.applyDe
|
|
|
36
36
|
|
|
37
37
|
var TextInput = React__default['default'].forwardRef(function TextInput(_ref, forwardedRef) {
|
|
38
38
|
var value = _ref.value,
|
|
39
|
+
name = _ref.name,
|
|
39
40
|
label = _ref.label,
|
|
40
41
|
placeholder = _ref.placeholder,
|
|
41
42
|
required = _ref.required,
|
|
42
43
|
disabled = _ref.disabled,
|
|
43
44
|
error = _ref.error,
|
|
44
|
-
onChange = _ref.onChange
|
|
45
|
+
onChange = _ref.onChange,
|
|
46
|
+
onBlur = _ref.onBlur;
|
|
45
47
|
|
|
46
48
|
var _useState = React.useState(nanoid.nanoid()),
|
|
47
49
|
_useState2 = defaultTheme._slicedToArray(_useState, 1),
|
|
48
50
|
uniqueId = _useState2[0];
|
|
49
51
|
|
|
50
|
-
var _useState3 = React.useState(value),
|
|
52
|
+
var _useState3 = React.useState(value || ''),
|
|
51
53
|
_useState4 = defaultTheme._slicedToArray(_useState3, 2),
|
|
52
54
|
controlledValue = _useState4[0],
|
|
53
55
|
setControlledValue = _useState4[1];
|
|
@@ -58,7 +60,7 @@ var TextInput = React__default['default'].forwardRef(function TextInput(_ref, fo
|
|
|
58
60
|
|
|
59
61
|
var onInputChange = function onInputChange(event) {
|
|
60
62
|
if (lodash.isFunction(onChange)) {
|
|
61
|
-
onChange(event
|
|
63
|
+
onChange(event);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
setControlledValue(event.target.value);
|
|
@@ -73,12 +75,14 @@ var TextInput = React__default['default'].forwardRef(function TextInput(_ref, fo
|
|
|
73
75
|
}, label, required && ' *'), React__default['default'].createElement(TextInputField, {
|
|
74
76
|
ref: forwardedRef,
|
|
75
77
|
value: controlledValue,
|
|
78
|
+
name: name,
|
|
76
79
|
placeholder: placeholder,
|
|
77
80
|
required: required,
|
|
78
81
|
disabled: disabled,
|
|
79
82
|
error: error,
|
|
80
83
|
id: "text-input-".concat(uniqueId),
|
|
81
|
-
onChange: onInputChange
|
|
84
|
+
onChange: onInputChange,
|
|
85
|
+
onBlur: onBlur
|
|
82
86
|
}));
|
|
83
87
|
});
|
|
84
88
|
TextInput.defaultProps = {
|
|
@@ -86,12 +90,14 @@ TextInput.defaultProps = {
|
|
|
86
90
|
};
|
|
87
91
|
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
88
92
|
value: defaultTheme.PropTypes.string,
|
|
93
|
+
name: defaultTheme.PropTypes.string,
|
|
89
94
|
label: defaultTheme.PropTypes.string,
|
|
90
95
|
placeholder: defaultTheme.PropTypes.string,
|
|
91
96
|
required: defaultTheme.PropTypes.bool,
|
|
92
97
|
disabled: defaultTheme.PropTypes.bool,
|
|
93
98
|
error: defaultTheme.PropTypes.bool,
|
|
94
|
-
onChange: defaultTheme.PropTypes.func
|
|
99
|
+
onChange: defaultTheme.PropTypes.func,
|
|
100
|
+
onBlur: defaultTheme.PropTypes.func
|
|
95
101
|
} : {};
|
|
96
102
|
|
|
97
103
|
exports.TextInput = TextInput;
|
package/inputs/index.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var ActionButton = require('../ActionButton-10a681b9.js');
|
|
6
|
+
var Button = require('../Button-ad55d102.js');
|
|
6
7
|
var Checkbox = require('../Checkbox-791a409f.js');
|
|
7
8
|
var Radio = require('../Radio-9271a4b6.js');
|
|
8
|
-
var TextInput = require('../TextInput-
|
|
9
|
+
var TextInput = require('../TextInput-099562d7.js');
|
|
9
10
|
require('../defaultTheme-18d7c1ee.js');
|
|
10
11
|
require('styled-components');
|
|
11
12
|
require('react');
|
|
@@ -16,6 +17,7 @@ require('lodash');
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
exports.ActionButton = ActionButton.ActionButton;
|
|
20
|
+
exports.Button = Button.Button;
|
|
19
21
|
exports.Checkbox = Checkbox.Checkbox;
|
|
20
22
|
exports.Radio = Radio.Radio;
|
|
21
23
|
exports.TextInput = TextInput.TextInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntbjs/react-components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.26",
|
|
4
4
|
"description": "NTBs common front-end design utilities and React components.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "cross-env NODE_ENV=production rollup -c",
|
|
@@ -77,6 +77,6 @@
|
|
|
77
77
|
"nanoid": "^3.1.25",
|
|
78
78
|
"polished": "^4.1.3",
|
|
79
79
|
"react-lazy-load-image-component": "^1.5.1",
|
|
80
|
-
"styled-components": "^5.3.
|
|
80
|
+
"styled-components": "^5.3.1"
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var AssetGallery = require('../../AssetGallery-
|
|
3
|
+
var AssetGallery = require('../../AssetGallery-16efec65.js');
|
|
4
4
|
require('../../defaultTheme-18d7c1ee.js');
|
|
5
5
|
require('styled-components');
|
|
6
6
|
require('react');
|
|
7
7
|
require('lodash');
|
|
8
8
|
require('react-lazy-load-image-component');
|
|
9
9
|
require('../../ActionButton-10a681b9.js');
|
|
10
|
+
require('../../Button-ad55d102.js');
|
|
10
11
|
require('../../Checkbox-791a409f.js');
|
|
11
12
|
require('nanoid');
|
|
12
13
|
require('../../Radio-9271a4b6.js');
|
|
13
14
|
require('polished');
|
|
14
|
-
require('../../TextInput-
|
|
15
|
+
require('../../TextInput-099562d7.js');
|
|
15
16
|
require('../../Popover-0ff13419.js');
|
|
16
17
|
require('@tippyjs/react');
|
|
17
18
|
require('../../Tooltip-85e7d561.js');
|
package/widgets/index.js
CHANGED
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var AssetGallery = require('../AssetGallery-
|
|
5
|
+
var AssetGallery = require('../AssetGallery-16efec65.js');
|
|
6
6
|
require('../defaultTheme-18d7c1ee.js');
|
|
7
7
|
require('styled-components');
|
|
8
8
|
require('react');
|
|
9
9
|
require('lodash');
|
|
10
10
|
require('react-lazy-load-image-component');
|
|
11
11
|
require('../ActionButton-10a681b9.js');
|
|
12
|
+
require('../Button-ad55d102.js');
|
|
12
13
|
require('../Checkbox-791a409f.js');
|
|
13
14
|
require('nanoid');
|
|
14
15
|
require('../Radio-9271a4b6.js');
|
|
15
16
|
require('polished');
|
|
16
|
-
require('../TextInput-
|
|
17
|
+
require('../TextInput-099562d7.js');
|
|
17
18
|
require('../Popover-0ff13419.js');
|
|
18
19
|
require('@tippyjs/react');
|
|
19
20
|
require('../Tooltip-85e7d561.js');
|