@ntbjs/react-components 1.3.0-rc.4 → 1.3.0-rc.41
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/.eslintrc +7 -8
- package/{ActionButton-46735b89.js → ActionButton-581e717e.js} +23 -18
- package/{Alert-13b75102.js → Alert-b79a8fcc.js} +30 -29
- package/{AssetGallery-7d05ac94.js → AssetAction-06d40708.js} +790 -655
- package/AssetPreviewTopBar-1b5dfde2.js +118 -0
- package/{Badge-757b0a39.js → Badge-a35c7018.js} +44 -54
- package/Button-70230131.js +284 -0
- package/Checkbox-92d07052.js +152 -0
- package/CompactAutocompleteSelect-c7a11d3d.js +478 -0
- package/CompactStarRating-86673c4f.js +343 -0
- package/CompactTextInput-f1824946.js +380 -0
- package/{ContextMenu-4ec3d9f3.js → ContextMenu-999756c8.js} +9 -7
- package/ContextMenuItem-ae4357ba.js +114 -0
- package/{InputGroup-49fbc423.js → InputGroup-0423e24c.js} +9 -7
- package/{Instructions-e5947be9.js → Instructions-9910f44d.js} +109 -82
- package/{MultiLevelCheckboxSelect-b897d605.js → MultiLevelCheckboxSelect-7a036b16.js} +158 -168
- package/MultiSelect-9d8c24e5.js +406 -0
- package/{Popover-569cd272.js → Popover-0d9a689b.js} +24 -24
- package/Radio-a0610a91.js +90 -0
- package/{SectionSeparator-259a22ed.js → SectionSeparator-5025c8f4.js} +9 -7
- package/Switch-b7193858.js +122 -0
- package/{Tab-f499ecbc.js → Tab-7c817d4d.js} +10 -8
- package/{Tabs-a8c77f71.js → Tabs-318feff9.js} +54 -44
- package/TextArea-ecfd3418.js +382 -0
- package/TextInput-91d6341d.js +252 -0
- package/{Tooltip-66daf6e3.js → Tooltip-478ec993.js} +16 -14
- package/{VerificationStatusIcon-d5bfb67a.js → VerificationStatusIcon-ecec5f07.js} +30 -32
- package/{close-ebf2f3cf.js → close-1751121a.js} +8 -12
- package/data/Alert/index.js +2 -2
- package/data/Badge/index.js +2 -2
- package/data/Popover/index.js +3 -3
- package/data/Tab/index.js +2 -2
- package/data/Tabs/index.js +3 -3
- package/data/Tooltip/index.js +3 -3
- package/data/index.js +9 -9
- package/{defaultTheme-ea44e34a.js → defaultTheme-573a9150.js} +205 -263
- package/edit-note-cefe2215.js +37 -0
- package/{expand-more-94585605.js → expand-more-d74e2bd2.js} +8 -12
- package/inputs/ActionButton/index.js +2 -2
- package/inputs/Button/index.js +6 -6
- package/inputs/Checkbox/index.js +2 -2
- package/inputs/CompactAutocompleteSelect/index.js +13 -13
- package/inputs/CompactStarRating/index.js +10 -10
- package/inputs/CompactTextInput/index.js +11 -11
- package/inputs/MultiSelect/index.js +4 -4
- package/inputs/Radio/index.js +2 -2
- package/inputs/Switch/index.js +2 -2
- package/inputs/TextArea/index.js +12 -12
- package/inputs/TextInput/index.js +3 -3
- package/inputs/index.js +28 -28
- package/layout/InputGroup/index.js +2 -2
- package/layout/SectionSeparator/index.js +2 -2
- package/layout/index.js +3 -3
- package/package.json +6 -5
- package/{react-select-creatable.esm-2f23d6c6.js → react-select-creatable.esm-8bf8566a.js} +1500 -1074
- package/{shift-away-subtle-0bed9a3c.js → shift-away-subtle-a9da38b8.js} +1 -1
- package/ssr/index.js +1 -3
- package/widgets/AssetGallery/index.js +34 -32
- package/widgets/AssetPreview/AssetPreviewTopBar/index.js +3 -3
- package/widgets/ContextMenu/ContextMenuItem/index.js +2 -2
- package/widgets/ContextMenu/ContextMenuItemsGroup/index.js +9 -7
- package/widgets/ContextMenu/index.js +2 -2
- package/widgets/Instructions/index.js +16 -17
- package/widgets/index.js +37 -35
- package/AssetPreviewTopBar-912c3469.js +0 -99
- package/Button-49f82b31.js +0 -264
- package/Checkbox-68dc38a8.js +0 -140
- package/CompactAutocompleteSelect-755b1869.js +0 -451
- package/CompactStarRating-bcfb78ac.js +0 -339
- package/CompactTextInput-9e507306.js +0 -349
- package/ContextMenuItem-ba2b697e.js +0 -110
- package/MultiSelect-efd60232.js +0 -377
- package/Radio-32d0513a.js +0 -86
- package/Switch-4a41585f.js +0 -107
- package/TextArea-8f62da6e.js +0 -353
- package/TextInput-0d109708.js +0 -236
- package/edit-note-c47d292e.js +0 -41
- package/warning-circle-24522402.js +0 -41
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultTheme = require('./defaultTheme-573a9150.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lodash = require('lodash');
|
|
6
|
+
var useMergedRefs = require('./useMergedRefs-b6d2f8fc.js');
|
|
7
|
+
var nanoid = require('nanoid');
|
|
8
|
+
require('./Alert-b79a8fcc.js');
|
|
9
|
+
require('./Badge-a35c7018.js');
|
|
10
|
+
require('./Popover-0d9a689b.js');
|
|
11
|
+
require('./Tab-7c817d4d.js');
|
|
12
|
+
require('./Tabs-318feff9.js');
|
|
13
|
+
var Tooltip = require('./Tooltip-478ec993.js');
|
|
14
|
+
require('./VerificationStatusIcon-ecec5f07.js');
|
|
15
|
+
var editNote = require('./edit-note-cefe2215.js');
|
|
16
|
+
var styled = require('styled-components');
|
|
17
|
+
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
+
|
|
20
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
21
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
22
|
+
|
|
23
|
+
var fadeInCheck = styled.keyframes(["from{opacity:0}to{opacity:1}"]);
|
|
24
|
+
var fadeOutCheck = styled.keyframes(["from{opacity:1}to{opacity:0}"]);
|
|
25
|
+
var activeLabel = styled.css(["font-size:0.75rem;padding:0 3px;top:-7px;letter-spacing:0.03em;left:8px !important;opacity:1 !important;"]);
|
|
26
|
+
var placeholderBaseStyle = styled.css(["", " ", ""], function (props) {
|
|
27
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'));
|
|
28
|
+
}, function (props) {
|
|
29
|
+
return props.theme.themeProp('opacity', 0.6, 0.5);
|
|
30
|
+
});
|
|
31
|
+
var warningPlaceholder = styled.css(["", ""], function (props) {
|
|
32
|
+
return props.type === 'warning' && props.theme.themeProp('color', props.theme.getColor('gray-200'), props.theme.getColor('gray-700'), 1);
|
|
33
|
+
});
|
|
34
|
+
var errorPlaceholder = styled.css(["", ""], function (props) {
|
|
35
|
+
return props.type === 'error' && props.theme.themeProp('color', props.theme.getColor('gray-200'), props.theme.getColor('gray-700'), 1);
|
|
36
|
+
});
|
|
37
|
+
var warningPlaceholderHover = styled.css(["", ""], function (props) {
|
|
38
|
+
return props.type === 'warning' && props.theme.themeProp('color', props.theme.getColor('gray-900'), props.theme.getColor('gray-900'), 1);
|
|
39
|
+
});
|
|
40
|
+
var errorPlaceholderHover = styled.css(["", ""], function (props) {
|
|
41
|
+
return props.type === 'error' && props.theme.themeProp('color', props.theme.getColor('red-600'), props.theme.getColor('red-600'), 1);
|
|
42
|
+
});
|
|
43
|
+
var TextAreaContainter = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
44
|
+
displayName: "TextAreastyled__TextAreaContainter",
|
|
45
|
+
componentId: "sc-bwbwn7-0"
|
|
46
|
+
})(["display:flex;"]);
|
|
47
|
+
var Label = styled__default["default"].label.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
48
|
+
displayName: "TextAreastyled__Label",
|
|
49
|
+
componentId: "sc-bwbwn7-1"
|
|
50
|
+
})(["", ";flex-basis:33.33%;font-size:0.875rem;line-height:1rem;height:19px;display:flex;justify-content:space-between;align-items:center;padding-top:13px;", ""], function (props) {
|
|
51
|
+
return props.theme.themeProp('color', props.theme.getColor('white'), props.theme.getColor('gray-700'));
|
|
52
|
+
}, function (props) {
|
|
53
|
+
return props.disabled && styled.css(["cursor:not-allowed;"]);
|
|
54
|
+
});
|
|
55
|
+
var InputIconContainer = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
56
|
+
displayName: "TextAreastyled__InputIconContainer",
|
|
57
|
+
componentId: "sc-bwbwn7-2"
|
|
58
|
+
})(["opacity:0;pointer-events:none;border-top-right-radius:3px;border-bottom-right-radius:3px;display:flex;align-items:flex-start;position:absolute;right:15px;top:10px;bottom:0;> .smallPadingIcon{padding:4px;width:15px;height:15px;border-radius:5px;opacity:1;margin-top:-5px;", "}svg{width:15px;opacity:0.7;transition:opacity 250ms;", "}"], function (props) {
|
|
59
|
+
return props.theme.themeProp('background-color', props.theme.getColor('gray-900'), props.theme.getColor('gray-300'), '!important');
|
|
60
|
+
}, function (props) {
|
|
61
|
+
return props.disabled && styled.css(["display:none;"]);
|
|
62
|
+
});
|
|
63
|
+
var TextInputField = styled__default["default"].textarea.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
64
|
+
displayName: "TextAreastyled__TextInputField",
|
|
65
|
+
componentId: "sc-bwbwn7-3"
|
|
66
|
+
})(["width:100%;font-family:inherit;font-size:0.875rem;border-radius:2px;padding:5px 10px;resize:vertical;z-index:0;border-radius:3px;box-sizing:border-box;appearance:none;border:1px solid;transition:height 550ms ease-in-out;border-color 350ms;", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " &&:hover:not(:focus){", ";", ";", ";", ";", ";transition:background 350ms;& + ", "{opacity:1;", ";transition:opacity 350ms;}}&::placeholder{", " ", " ", "}&:hover::placeholder{", " ", "}&:focus::placeholder{", " ", "}&&:focus{outline:none;", " ", ";", " ", "}&&:not(:hover):not(:focus){", ";", ";", "}"], function (props) {
|
|
67
|
+
return props.borderRadius && styled.css(["border-radius:", "px;"], props.borderRadius);
|
|
68
|
+
}, function (props) {
|
|
69
|
+
return props.theme.themeProp('color', 'white', 'black');
|
|
70
|
+
}, function (props) {
|
|
71
|
+
return props.readOnly && styled.css(["cursor:default;border-color:transparent !important;padding:12px 10px;;"]);
|
|
72
|
+
}, function (props) {
|
|
73
|
+
return props.disabled && styled.css(["cursor:not-allowed;"]);
|
|
74
|
+
}, function (props) {
|
|
75
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-900'));
|
|
76
|
+
}, function (props) {
|
|
77
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
78
|
+
}, function (props) {
|
|
79
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
80
|
+
}, function (props) {
|
|
81
|
+
return props.noBorder && styled.css(["", ""], function (props) {
|
|
82
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
83
|
+
});
|
|
84
|
+
}, function (props) {
|
|
85
|
+
return props.type === 'warning' && styled.css(["", " ", " ", ""], props.theme.themeProp('color', 'white', 'black'), props.theme.themeProp('background', '#634E01', '#FFFDE8'), props.theme.themeProp('border-color', '#634E01 ', '#FFFDE8'));
|
|
86
|
+
}, function (props) {
|
|
87
|
+
return props.type === 'error' && styled.css(["", " ", " ", ""], props.theme.themeProp('color', 'white', 'black'), props.theme.themeProp('background', '#7f1b1b', '#FBEAE6'), props.theme.themeProp('border-color', '#7f1b1b', '#FBEAE6'));
|
|
88
|
+
}, function (props) {
|
|
89
|
+
return props.noBorder && props.type === 'warning' && styled.css(["", ""], function (props) {
|
|
90
|
+
return props.theme.themeProp('border-color', '#634E01', '#FFFDE8');
|
|
91
|
+
});
|
|
92
|
+
}, function (props) {
|
|
93
|
+
return props.noBorder && props.type === 'error' && styled.css(["", ""], function (props) {
|
|
94
|
+
return props.theme.themeProp('border-color', '#7f1b1b', '#FBEAE6');
|
|
95
|
+
});
|
|
96
|
+
}, function (props) {
|
|
97
|
+
return props.type === 'warning-border' && styled.css(["", ""], props.theme.themeProp('border-color', props.theme.getColor('red-200'), props.theme.getColor('orange-500')));
|
|
98
|
+
}, function (props) {
|
|
99
|
+
return props.type === 'error-border' && styled.css(["", ""], props.theme.themeProp('border-color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
100
|
+
}, function (props) {
|
|
101
|
+
return props.padding === 'small' && styled.css(["padding:5px 10px;"]);
|
|
102
|
+
}, function (props) {
|
|
103
|
+
return props.padding === 'medium' && styled.css(["padding:13px 15px;"]);
|
|
104
|
+
}, function (props) {
|
|
105
|
+
return props.padding === 'large' && styled.css(["padding:15px 55px;"]);
|
|
106
|
+
}, function (props) {
|
|
107
|
+
return props.hasIcon && styled.css(["padding-left:55px;padding-right:35px;padding-top:13.5px;"]);
|
|
108
|
+
}, function (props) {
|
|
109
|
+
return !props.readOnly && !props.disabled && props.theme.themeProp('background', props.theme.getColor('gray-700'), props.theme.getColor('gray-100'));
|
|
110
|
+
}, function (props) {
|
|
111
|
+
return props.edit && props.theme.themeProp('border-color', props.theme.getColor('gray-700'), props.theme.getColor('gray-100'));
|
|
112
|
+
}, function (props) {
|
|
113
|
+
return props.type === 'warning' && props.theme.themeProp('background', '#806403', '#FFFEBF');
|
|
114
|
+
}, function (props) {
|
|
115
|
+
return props.type === 'error' && props.theme.themeProp('background', '#901d1d', '#F7D5D0');
|
|
116
|
+
}, function (props) {
|
|
117
|
+
return props.noBorder && !props.readOnly && props.type != 'warning' && props.type != 'error' ? props.theme.themeProp('background', props.theme.getColor('gray-700'), props.theme.getColor('gray-100')) : 'background: transparent';
|
|
118
|
+
}, InputIconContainer, function (props) {
|
|
119
|
+
return props.type === 'success' && styled.css(["opacity:0;"]);
|
|
120
|
+
}, placeholderBaseStyle, warningPlaceholder, errorPlaceholder, warningPlaceholderHover, errorPlaceholderHover, warningPlaceholderHover, errorPlaceholderHover, function (props) {
|
|
121
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'));
|
|
122
|
+
}, function (props) {
|
|
123
|
+
return props.theme.themeProp('background', 'transparent', props.theme.getColor('white'));
|
|
124
|
+
}, function (props) {
|
|
125
|
+
return props.type === 'warning' && styled.css(["", " ", " ", ""], function (props) {
|
|
126
|
+
return props.theme.themeProp('border-color', '#F4E21E', '#F4E21E');
|
|
127
|
+
}, props.theme.themeProp('background', 'white', 'white'), props.theme.themeProp('color', 'black', 'black'));
|
|
128
|
+
}, function (props) {
|
|
129
|
+
return props.type === 'error' && styled.css(["", " ", " ", ""], function (props) {
|
|
130
|
+
return props.theme.themeProp('border-color', '#D83018', '#D83018');
|
|
131
|
+
}, props.theme.themeProp('background', 'white', 'white'), props.theme.themeProp('color', 'black', 'black'));
|
|
132
|
+
}, function (props) {
|
|
133
|
+
return props.edit && props.theme.themeProp('background', 'rgba(39,39,42, 0.7)', 'rgba(244,244,245, 0.3)');
|
|
134
|
+
}, function (props) {
|
|
135
|
+
return props.edit && props.theme.themeProp('border-color', 'rgba(39,39,42, 0.7)', 'rgba(228,228,231, 0.3)');
|
|
136
|
+
}, function (props) {
|
|
137
|
+
return props.noBorder && props.edit && styled.css(["", ""], function (props) {
|
|
138
|
+
return props.theme.themeProp('border-color', '#27272A', 'rgba(244,244,245, 0.3)');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
var TextInputLabel = styled__default["default"].label.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
142
|
+
displayName: "TextAreastyled__TextInputLabel",
|
|
143
|
+
componentId: "sc-bwbwn7-4"
|
|
144
|
+
})(["position:absolute;top:13px;left:11px;line-height:1.2;font-size:0.875rem;transition:all 150ms;margin-botton:50px;", ";", ";", " ", " ", " content:\"\";", ""], function (props) {
|
|
145
|
+
return props.theme.themeProp('color', props.theme.getColor('white'), props.theme.getColor('gray-700'));
|
|
146
|
+
}, placeholderBaseStyle, function (props) {
|
|
147
|
+
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%)"));
|
|
148
|
+
}, function (props) {
|
|
149
|
+
return !props.inputIsEmpty && styled.css(["", ""], activeLabel);
|
|
150
|
+
}, function (props) {
|
|
151
|
+
return props.hasPlaceholder && styled.css(["", ";"], activeLabel);
|
|
152
|
+
}, function (props) {
|
|
153
|
+
return props.hasIcon && styled.css(["left:55px;"]);
|
|
154
|
+
});
|
|
155
|
+
var TextInputFieldIcon = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
156
|
+
displayName: "TextAreastyled__TextInputFieldIcon",
|
|
157
|
+
componentId: "sc-bwbwn7-5"
|
|
158
|
+
})(["position:absolute;top:0;left:0;height:2.625rem;display:flex;padding:0 10px;svg{width:15px;opacity:0.6;transition:opacity 250ms;}"]);
|
|
159
|
+
var TextInputFieldIconAlert = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
160
|
+
displayName: "TextAreastyled__TextInputFieldIconAlert",
|
|
161
|
+
componentId: "sc-bwbwn7-6"
|
|
162
|
+
})(["position:absolute;top:2.8px;display:flex;padding:0 10px 0 30px;opacity:0.6;transition:opacity 250ms;", " svg{margin-top:12px;width:15px;}"], function (props) {
|
|
163
|
+
return props.type === 'warning' && props.theme.themeProp('color', '#EAB308', '#2F2402');
|
|
164
|
+
});
|
|
165
|
+
var TextInput = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
166
|
+
displayName: "TextAreastyled__TextInput",
|
|
167
|
+
componentId: "sc-bwbwn7-7"
|
|
168
|
+
})(["position:relative;flex-basis:", ";", " ", " &:focus-within{", "{", ";}", "{svg{opacity:1;}}}", ":not(:placeholder-shown) + ", "{", ";", "}}"], function (props) {
|
|
169
|
+
return props.$fieldLabel ? '66.66%' : '100%';
|
|
170
|
+
}, function (props) {
|
|
171
|
+
return props.readOnly && styled.css(["overflow:auto;"]);
|
|
172
|
+
}, function (props) {
|
|
173
|
+
return props.disabled && styled.css(["opacity:0.5;> *{cursor:not-allowed;}"]);
|
|
174
|
+
}, TextInputLabel, activeLabel, TextInputFieldIcon, TextInputField, TextInputLabel, activeLabel, function (props) {
|
|
175
|
+
return props.type === 'error' && props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500'));
|
|
176
|
+
});
|
|
177
|
+
var Description = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
178
|
+
displayName: "TextAreastyled__Description",
|
|
179
|
+
componentId: "sc-bwbwn7-8"
|
|
180
|
+
})(["margin:8px 0 0 0;padding:0 0.6875rem;font-size:0.75rem;line-height:1.333;", ";", " ", ""], function (props) {
|
|
181
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
182
|
+
}, function (props) {
|
|
183
|
+
return (props.type === 'warning-border' || props.type === 'warning') && styled.css(["", ""], props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('orange-500')));
|
|
184
|
+
}, function (props) {
|
|
185
|
+
return (props.type === 'error-border' || props.type === 'error') && styled.css(["", ""], props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
186
|
+
});
|
|
187
|
+
var SuccessContainer = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
188
|
+
displayName: "TextAreastyled__SuccessContainer",
|
|
189
|
+
componentId: "sc-bwbwn7-9"
|
|
190
|
+
})(["opacity:1;pointer-events:none;opacity:", ";animation:", " 0.5s ease-in-out;transition:opacity 0.5s ease-in-out;position:absolute;margin-top:-35px;margin-left:5px;width:15px;height:15px;padding:5px;", " > svg{width:15px;}"], function (props) {
|
|
191
|
+
return props.fadeIn ? 0 : 1;
|
|
192
|
+
}, function (props) {
|
|
193
|
+
return props.fadeIn ? fadeOutCheck : fadeInCheck;
|
|
194
|
+
}, function (props) {
|
|
195
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-500'));
|
|
196
|
+
});
|
|
197
|
+
var SuccessContainerLabel = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
198
|
+
displayName: "TextAreastyled__SuccessContainerLabel",
|
|
199
|
+
componentId: "sc-bwbwn7-10"
|
|
200
|
+
})(["opacity:1;pointer-events:none;opacity:", ";animation:", " 0.5s ease-in-out;transition:opacity 0.5s ease-in-out;margin-right:5px;margin-top:-7px;width:15px;height:15px;padding:5px;", " > svg{width:13px;}"], function (props) {
|
|
201
|
+
return props.fadeIn ? 0 : 1;
|
|
202
|
+
}, function (props) {
|
|
203
|
+
return props.fadeIn ? fadeOutCheck : fadeInCheck;
|
|
204
|
+
}, function (props) {
|
|
205
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-500'));
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
var _excluded = ["value", "defaultValue", "name", "label", "placeholder", "required", "disabled", "hidden", "readOnly", "edit", "autoComplete", "description", "type", "icon", "rows", "className", "style", "onChange", "onBlur", "noBorder", "instructionsTextArea", "loadingIcon", "successIcon", "padding", "descriptionToolTip", "borderRadius", "fieldLabel"];
|
|
209
|
+
var TextArea = React__default["default"].forwardRef(function TextArea(_ref, forwardedRef) {
|
|
210
|
+
var value = _ref.value,
|
|
211
|
+
defaultValue = _ref.defaultValue,
|
|
212
|
+
name = _ref.name,
|
|
213
|
+
label = _ref.label,
|
|
214
|
+
placeholder = _ref.placeholder,
|
|
215
|
+
required = _ref.required,
|
|
216
|
+
disabled = _ref.disabled,
|
|
217
|
+
hidden = _ref.hidden,
|
|
218
|
+
readOnly = _ref.readOnly,
|
|
219
|
+
edit = _ref.edit,
|
|
220
|
+
autoComplete = _ref.autoComplete,
|
|
221
|
+
description = _ref.description,
|
|
222
|
+
type = _ref.type,
|
|
223
|
+
icon = _ref.icon,
|
|
224
|
+
rows = _ref.rows,
|
|
225
|
+
className = _ref.className,
|
|
226
|
+
style = _ref.style,
|
|
227
|
+
_onChange = _ref.onChange,
|
|
228
|
+
onBlur = _ref.onBlur,
|
|
229
|
+
noBorder = _ref.noBorder,
|
|
230
|
+
instructionsTextArea = _ref.instructionsTextArea,
|
|
231
|
+
loadingIcon = _ref.loadingIcon,
|
|
232
|
+
successIcon = _ref.successIcon,
|
|
233
|
+
padding = _ref.padding,
|
|
234
|
+
descriptionToolTip = _ref.descriptionToolTip,
|
|
235
|
+
borderRadius = _ref.borderRadius,
|
|
236
|
+
fieldLabel = _ref.fieldLabel,
|
|
237
|
+
rest = defaultTheme._objectWithoutProperties(_ref, _excluded);
|
|
238
|
+
var textInputDomNode = React.useRef(null);
|
|
239
|
+
var textInputRef = useMergedRefs.useMergedRefs(forwardedRef, textInputDomNode);
|
|
240
|
+
var _useState = React.useState(!(value || defaultValue)),
|
|
241
|
+
_useState2 = defaultTheme._slicedToArray(_useState, 2),
|
|
242
|
+
inputIsEmpty = _useState2[0],
|
|
243
|
+
setInputIsEmpty = _useState2[1];
|
|
244
|
+
var _useState3 = React.useState(false),
|
|
245
|
+
_useState4 = defaultTheme._slicedToArray(_useState3, 2),
|
|
246
|
+
autoFocus = _useState4[0],
|
|
247
|
+
setAutoFocus = _useState4[1];
|
|
248
|
+
var _useState5 = React.useState(nanoid.nanoid()),
|
|
249
|
+
_useState6 = defaultTheme._slicedToArray(_useState5, 1),
|
|
250
|
+
uniqueId = _useState6[0];
|
|
251
|
+
var memoizedDescriptionToolTip = React.useMemo(function () {
|
|
252
|
+
return descriptionToolTip;
|
|
253
|
+
}, [descriptionToolTip]);
|
|
254
|
+
React.useEffect(function () {
|
|
255
|
+
setAutoFocus(false);
|
|
256
|
+
}, [value, defaultValue]);
|
|
257
|
+
var onKeyDown = React.useCallback(function (event) {
|
|
258
|
+
if (event.key === 'Enter') {
|
|
259
|
+
event.stopPropagation();
|
|
260
|
+
}
|
|
261
|
+
}, []);
|
|
262
|
+
var input = function input() {
|
|
263
|
+
return React__default["default"].createElement(TextAreaContainter, null, fieldLabel && React__default["default"].createElement(Label, {
|
|
264
|
+
htmlFor: uniqueId,
|
|
265
|
+
disabled: disabled
|
|
266
|
+
}, fieldLabel, React__default["default"].createElement(SuccessContainerLabel, null, type === 'loading' && loadingIcon, type === 'success' && successIcon)), React__default["default"].createElement(TextInput, {
|
|
267
|
+
$fieldLabel: !lodash.isEmpty(fieldLabel),
|
|
268
|
+
disabled: disabled,
|
|
269
|
+
readOnly: readOnly,
|
|
270
|
+
type: type,
|
|
271
|
+
className: className,
|
|
272
|
+
style: style
|
|
273
|
+
}, React__default["default"].createElement(TextInputFieldIconAlert, {
|
|
274
|
+
type: type
|
|
275
|
+
}, icon), React__default["default"].createElement(TextInputField, defaultTheme._extends({
|
|
276
|
+
autoFocus: autoFocus,
|
|
277
|
+
borderRadius: borderRadius,
|
|
278
|
+
ref: textInputRef,
|
|
279
|
+
rows: rows,
|
|
280
|
+
value: value,
|
|
281
|
+
defaultValue: defaultValue,
|
|
282
|
+
name: name,
|
|
283
|
+
placeholder: placeholder || ' ',
|
|
284
|
+
required: required,
|
|
285
|
+
readOnly: readOnly,
|
|
286
|
+
disabled: disabled,
|
|
287
|
+
edit: edit,
|
|
288
|
+
instructionsTextArea: instructionsTextArea,
|
|
289
|
+
type: type,
|
|
290
|
+
autoComplete: autoComplete,
|
|
291
|
+
hasIcon: Boolean(icon),
|
|
292
|
+
icon: icon,
|
|
293
|
+
id: "text-input-".concat(uniqueId),
|
|
294
|
+
key: uniqueId,
|
|
295
|
+
padding: padding,
|
|
296
|
+
onChange: function onChange(e) {
|
|
297
|
+
if (e.target.value) {
|
|
298
|
+
setInputIsEmpty(false);
|
|
299
|
+
if (!autoFocus) {
|
|
300
|
+
setAutoFocus(true);
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
setInputIsEmpty(true);
|
|
304
|
+
if (!autoFocus) {
|
|
305
|
+
setAutoFocus(true);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
_onChange(e);
|
|
309
|
+
},
|
|
310
|
+
onKeyDown: onKeyDown,
|
|
311
|
+
onBlur: onBlur,
|
|
312
|
+
noBorder: noBorder
|
|
313
|
+
}, rest)), !fieldLabel && (type === 'loading' || type === 'success') && React__default["default"].createElement(SuccessContainer, null, type === 'loading' && loadingIcon, type === 'success' && successIcon), !readOnly && noBorder && React__default["default"].createElement(InputIconContainer, {
|
|
314
|
+
disabled: disabled
|
|
315
|
+
}, React__default["default"].createElement(editNote.SvgEditNote, {
|
|
316
|
+
className: padding === 'small' ? 'smallPadingIcon' : undefined
|
|
317
|
+
})), label && React__default["default"].createElement(TextInputLabel, {
|
|
318
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
319
|
+
hasPlaceholder: Boolean(placeholder),
|
|
320
|
+
hasIcon: Boolean(icon),
|
|
321
|
+
inputIsEmpty: inputIsEmpty
|
|
322
|
+
}, label, required && ' *'), typeof description === 'string' && description.length > 0 && React__default["default"].createElement(Description, {
|
|
323
|
+
type: type
|
|
324
|
+
}, description)));
|
|
325
|
+
};
|
|
326
|
+
if (hidden) return null;
|
|
327
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, !memoizedDescriptionToolTip && input(), memoizedDescriptionToolTip && React__default["default"].createElement("div", null, React__default["default"].createElement(Tooltip.Tooltip, {
|
|
328
|
+
content: memoizedDescriptionToolTip,
|
|
329
|
+
key: "tooltipTextArea1",
|
|
330
|
+
placement: "bottom-end",
|
|
331
|
+
trigger: 'mouseenter',
|
|
332
|
+
zIndex: 999999
|
|
333
|
+
}, input())));
|
|
334
|
+
});
|
|
335
|
+
TextArea.defaultProps = {
|
|
336
|
+
rows: 4,
|
|
337
|
+
noBorder: false,
|
|
338
|
+
readOnly: false,
|
|
339
|
+
edit: false,
|
|
340
|
+
hidden: false,
|
|
341
|
+
type: '',
|
|
342
|
+
padding: 'medium',
|
|
343
|
+
instructionsTextArea: false,
|
|
344
|
+
descriptionToolTip: '',
|
|
345
|
+
isExpanded: function isExpanded() {},
|
|
346
|
+
onChange: function onChange() {},
|
|
347
|
+
borderRadius: 0
|
|
348
|
+
};
|
|
349
|
+
TextArea.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
350
|
+
value: defaultTheme.PropTypes.string,
|
|
351
|
+
defaultValue: defaultTheme.PropTypes.string,
|
|
352
|
+
name: defaultTheme.PropTypes.string,
|
|
353
|
+
label: defaultTheme.PropTypes.string,
|
|
354
|
+
fieldLabel: defaultTheme.PropTypes.string,
|
|
355
|
+
placeholder: defaultTheme.PropTypes.string,
|
|
356
|
+
required: defaultTheme.PropTypes.bool,
|
|
357
|
+
disabled: defaultTheme.PropTypes.bool,
|
|
358
|
+
hidden: defaultTheme.PropTypes.bool,
|
|
359
|
+
readOnly: defaultTheme.PropTypes.bool,
|
|
360
|
+
edit: defaultTheme.PropTypes.bool,
|
|
361
|
+
autoComplete: defaultTheme.PropTypes.string,
|
|
362
|
+
description: defaultTheme.PropTypes.string,
|
|
363
|
+
error: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
364
|
+
warning: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
365
|
+
icon: defaultTheme.PropTypes.element,
|
|
366
|
+
rows: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.number, defaultTheme.PropTypes.string]),
|
|
367
|
+
className: defaultTheme.PropTypes.string,
|
|
368
|
+
style: defaultTheme.PropTypes.object,
|
|
369
|
+
padding: defaultTheme.PropTypes.oneOf(['small', 'medium', 'large']),
|
|
370
|
+
onChange: defaultTheme.PropTypes.func,
|
|
371
|
+
onBlur: defaultTheme.PropTypes.func,
|
|
372
|
+
noBorder: defaultTheme.PropTypes.bool,
|
|
373
|
+
isExpanded: defaultTheme.PropTypes.func,
|
|
374
|
+
type: defaultTheme.PropTypes.oneOf(['', 'error', 'error-border', 'warning-border', 'warning', 'loading', 'success']),
|
|
375
|
+
instructionsTextArea: defaultTheme.PropTypes.bool,
|
|
376
|
+
loadingIcon: defaultTheme.PropTypes.element,
|
|
377
|
+
successIcon: defaultTheme.PropTypes.element,
|
|
378
|
+
descriptionToolTip: defaultTheme.PropTypes.string,
|
|
379
|
+
borderRadius: defaultTheme.PropTypes.number
|
|
380
|
+
} : {};
|
|
381
|
+
|
|
382
|
+
exports.TextArea = TextArea;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultTheme = require('./defaultTheme-573a9150.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var nanoid = require('nanoid');
|
|
6
|
+
var useMergedRefs = require('./useMergedRefs-b6d2f8fc.js');
|
|
7
|
+
var lodash = require('lodash');
|
|
8
|
+
var editNote = require('./edit-note-cefe2215.js');
|
|
9
|
+
var styled = require('styled-components');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
15
|
+
|
|
16
|
+
var activeLabel = styled.css(["font-size:0.75rem;padding:0 3px;top:-7px;letter-spacing:0.03em;left:8px !important;opacity:1 !important;"]);
|
|
17
|
+
var Adornment = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
18
|
+
displayName: "TextInputstyled__Adornment",
|
|
19
|
+
componentId: "sc-z540v7-0"
|
|
20
|
+
})(["flex-shrink:0;font-family:inherit;font-size:0.875rem;line-height:initial;padding:13px 10px;", " ", " border:1px solid;", " border-radius:3px;", " box-sizing:border-box;appearance:none;transition:border-color 350ms;height:2.75rem;", " ", ""], function (props) {
|
|
21
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
22
|
+
}, function (props) {
|
|
23
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
24
|
+
}, function (props) {
|
|
25
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
26
|
+
}, function (props) {
|
|
27
|
+
return props.isPrefix ? styled.css(["padding-right:0;margin-right:-3px;border-right:0;border-top-right-radius:0;border-bottom-right-radius:0;"]) : styled.css(["padding-left:0;margin-left:-3px;border-left:0;border-top-left-radius:0;border-bottom-left-radius:0;"]);
|
|
28
|
+
}, function (props) {
|
|
29
|
+
return props.warning && styled.css(["border-color:", " !important;"], props.theme.getColor('orange-500'));
|
|
30
|
+
}, function (props) {
|
|
31
|
+
return props.error && styled.css(["border-color:", " !important;"], props.theme.getColor('red-500'));
|
|
32
|
+
});
|
|
33
|
+
var TextInputWrapper = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
34
|
+
displayName: "TextInputstyled__TextInputWrapper",
|
|
35
|
+
componentId: "sc-z540v7-1"
|
|
36
|
+
})(["display:flex;align-content:center;&:focus-within{", "{outline:none;", "}}"], Adornment, function (props) {
|
|
37
|
+
return props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-600'), 1);
|
|
38
|
+
});
|
|
39
|
+
var InputIconContainer = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
40
|
+
displayName: "TextInputstyled__InputIconContainer",
|
|
41
|
+
componentId: "sc-z540v7-2"
|
|
42
|
+
})(["opacity:0;pointer-events:none;border-top-right-radius:3px;border-bottom-right-radius:3px;padding-right:4px;padding-left:30px;display:flex;align-items:center;position:absolute;right:0;top:0;bottom:0;color:", ";", " ", " > svg{width:12px;}"], function (props) {
|
|
43
|
+
return props.theme.getColor('gray-400');
|
|
44
|
+
}, function (props) {
|
|
45
|
+
return props.warning && props.theme.themeProp('color', '#C3AF43', '#C3AF43');
|
|
46
|
+
}, function (props) {
|
|
47
|
+
return props.error && props.theme.themeProp('color', '#CB968F', '#CB968F');
|
|
48
|
+
});
|
|
49
|
+
var TextInputField = styled__default["default"].input.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
50
|
+
displayName: "TextInputstyled__TextInputField",
|
|
51
|
+
componentId: "sc-z540v7-3"
|
|
52
|
+
})(["display:block;width:100%;font-family:inherit;font-size:0.875rem;line-height:1;padding:13px 10px;border-radius:3px;box-sizing:border-box;appearance:none;transition:border-color 350ms;height:2.75rem !important;margin-bottom:0;", " ", " border:1px solid;", ";", " ", " ", " ", " &::placeholder{", " ", "}&&:hover:not(:focus){", ";transition:background 350ms;& + ", "{opacity:1;transition:opacity 350ms;}}:focus{outline:none;border-color:", " !important ", ""], function (props) {
|
|
53
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-100'), props.theme.getColor('gray-900'));
|
|
54
|
+
}, function (props) {
|
|
55
|
+
return props.theme.themeProp('background', props.theme.getColor('gray-900'), props.theme.getColor('white'));
|
|
56
|
+
}, function (props) {
|
|
57
|
+
return props.noBorder || props.readOnly ? 'border-color: transparent !important' : props.theme.themeProp('border-color', props.theme.getColor('gray-500'), props.theme.getColor('gray-400'));
|
|
58
|
+
}, function (props) {
|
|
59
|
+
return props.readOnly && styled.css(["user-select:text;cursor:default;"]);
|
|
60
|
+
}, function (props) {
|
|
61
|
+
return props.warning && styled.css(["border-color:", " !important;"], props.theme.getColor('orange-500'));
|
|
62
|
+
}, function (props) {
|
|
63
|
+
return props.error && styled.css(["border-color:", " !important;"], props.theme.getColor('red-500'));
|
|
64
|
+
}, function (props) {
|
|
65
|
+
return props.hasIcon && styled.css(["padding-left:35px;"]);
|
|
66
|
+
}, function (props) {
|
|
67
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'), 1);
|
|
68
|
+
}, function (props) {
|
|
69
|
+
return props.theme.themeProp('opacity', 0.6, 0.5, 1);
|
|
70
|
+
}, function (props) {
|
|
71
|
+
return props.noBorder ? props.theme.themeProp('background', props.theme.getColor('gray-700'), props.theme.getColor('gray-200')) : 'background: transparent';
|
|
72
|
+
}, InputIconContainer, function (props) {
|
|
73
|
+
return props.theme.getColor('gray-600');
|
|
74
|
+
}, function (props) {
|
|
75
|
+
return props.readOnly && styled.css(["outline:none;"]);
|
|
76
|
+
});
|
|
77
|
+
var TextInputLabel = styled__default["default"].label.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
78
|
+
displayName: "TextInputstyled__TextInputLabel",
|
|
79
|
+
componentId: "sc-z540v7-4"
|
|
80
|
+
})(["position:absolute;top:15px;left:11px;line-height:1.2;font-size:0.875rem;transition:all 150ms;", " ", " ", " ", " ", ""], function (props) {
|
|
81
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-300'), props.theme.getColor('gray-600'));
|
|
82
|
+
}, function (props) {
|
|
83
|
+
return props.theme.themeProp('opacity', 0.6, 0.5);
|
|
84
|
+
}, function (props) {
|
|
85
|
+
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%)"));
|
|
86
|
+
}, function (props) {
|
|
87
|
+
return (props.hasPlaceholder || props.hasAdornments) && styled.css(["", ";"], activeLabel);
|
|
88
|
+
}, function (props) {
|
|
89
|
+
return props.hasIcon && styled.css(["left:35px;"]);
|
|
90
|
+
});
|
|
91
|
+
var TextInputFieldIcon = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
92
|
+
displayName: "TextInputstyled__TextInputFieldIcon",
|
|
93
|
+
componentId: "sc-z540v7-5"
|
|
94
|
+
})(["position:absolute;top:0;left:0;height:2.625rem;display:flex;padding:0 10px;svg{width:15px;opacity:0.6;transition:opacity 250ms;}"]);
|
|
95
|
+
var TextInput$1 = styled__default["default"].div.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
96
|
+
displayName: "TextInputstyled__TextInput",
|
|
97
|
+
componentId: "sc-z540v7-6"
|
|
98
|
+
})(["position:relative;", " &:focus-within{", "{", ";}", "{svg{opacity:1;}}}", ":not(:placeholder-shown) + ", "{", ";", " ", " ", "}}"], function (props) {
|
|
99
|
+
return props.disabled && styled.css(["user-select:none;opacity:0.5;cursor:not-allowed;> *{pointer-events:none;}"]);
|
|
100
|
+
}, TextInputLabel, activeLabel, TextInputFieldIcon, TextInputField, TextInputLabel, activeLabel, function (props) {
|
|
101
|
+
return props.error && props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500'));
|
|
102
|
+
}, function (props) {
|
|
103
|
+
return props.error && styled.css(["color:", ";"], props.theme.getColor('red-500'));
|
|
104
|
+
}, function (props) {
|
|
105
|
+
return props.warning && styled.css(["color:", ";"], props.theme.getColor('orange-500'));
|
|
106
|
+
});
|
|
107
|
+
var Description = styled__default["default"].p.attrs(defaultTheme.applyDefaultTheme).withConfig({
|
|
108
|
+
displayName: "TextInputstyled__Description",
|
|
109
|
+
componentId: "sc-z540v7-7"
|
|
110
|
+
})(["margin:8px 0 0 0;padding:0 0.6875rem;font-size:0.75rem;line-height:1.333;", ";", " ", ""], function (props) {
|
|
111
|
+
return props.theme.themeProp('color', props.theme.getColor('gray-400'), props.theme.getColor('gray-500'));
|
|
112
|
+
}, function (props) {
|
|
113
|
+
return props.error && styled.css(["", ""], props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('red-500')));
|
|
114
|
+
}, function (props) {
|
|
115
|
+
return props.warning && styled.css(["", ""], props.theme.themeProp('color', props.theme.getColor('red-200'), props.theme.getColor('orange-500')));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
var _excluded = ["value", "defaultValue", "name", "label", "placeholder", "type", "required", "disabled", "readOnly", "autoComplete", "description", "error", "warning", "icon", "adornments", "className", "style", "onChange", "onBlur", "noBorder"];
|
|
119
|
+
var TextInput = React__default["default"].forwardRef(function TextInput(_ref, forwardedRef) {
|
|
120
|
+
var value = _ref.value,
|
|
121
|
+
defaultValue = _ref.defaultValue,
|
|
122
|
+
name = _ref.name,
|
|
123
|
+
label = _ref.label,
|
|
124
|
+
placeholder = _ref.placeholder,
|
|
125
|
+
type = _ref.type,
|
|
126
|
+
required = _ref.required,
|
|
127
|
+
disabled = _ref.disabled,
|
|
128
|
+
readOnly = _ref.readOnly,
|
|
129
|
+
autoComplete = _ref.autoComplete,
|
|
130
|
+
description = _ref.description,
|
|
131
|
+
error = _ref.error,
|
|
132
|
+
warning = _ref.warning,
|
|
133
|
+
icon = _ref.icon,
|
|
134
|
+
adornments = _ref.adornments,
|
|
135
|
+
className = _ref.className,
|
|
136
|
+
style = _ref.style,
|
|
137
|
+
onChange = _ref.onChange,
|
|
138
|
+
onBlur = _ref.onBlur,
|
|
139
|
+
noBorder = _ref.noBorder,
|
|
140
|
+
rest = defaultTheme._objectWithoutProperties(_ref, _excluded);
|
|
141
|
+
var textInputDomNode = React.useRef(null);
|
|
142
|
+
var textInputRef = useMergedRefs.useMergedRefs(forwardedRef, textInputDomNode);
|
|
143
|
+
var _useState = React.useState(nanoid.nanoid()),
|
|
144
|
+
_useState2 = defaultTheme._slicedToArray(_useState, 1),
|
|
145
|
+
uniqueId = _useState2[0];
|
|
146
|
+
var hasError = React.useMemo(function () {
|
|
147
|
+
if (lodash.isBoolean(error)) {
|
|
148
|
+
return error;
|
|
149
|
+
}
|
|
150
|
+
return !lodash.isEmpty(error);
|
|
151
|
+
}, [error]);
|
|
152
|
+
var hasWarning = React.useMemo(function () {
|
|
153
|
+
if (lodash.isBoolean(warning)) {
|
|
154
|
+
return warning;
|
|
155
|
+
}
|
|
156
|
+
return !lodash.isEmpty(warning);
|
|
157
|
+
}, [warning]);
|
|
158
|
+
var descriptionText = React.useMemo(function () {
|
|
159
|
+
if (!lodash.isEmpty(error)) {
|
|
160
|
+
return error;
|
|
161
|
+
}
|
|
162
|
+
if (!lodash.isEmpty(warning)) {
|
|
163
|
+
return warning;
|
|
164
|
+
}
|
|
165
|
+
if (!lodash.isEmpty(description)) {
|
|
166
|
+
return description;
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}, [description, error, warning]);
|
|
170
|
+
return React__default["default"].createElement(TextInput$1, {
|
|
171
|
+
error: hasError,
|
|
172
|
+
disabled: disabled,
|
|
173
|
+
warning: hasWarning,
|
|
174
|
+
className: className,
|
|
175
|
+
style: style
|
|
176
|
+
}, 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, {
|
|
177
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
178
|
+
error: hasError,
|
|
179
|
+
warning: hasWarning,
|
|
180
|
+
isPrefix: true,
|
|
181
|
+
onClick: function onClick() {
|
|
182
|
+
return textInputDomNode.current.focus();
|
|
183
|
+
}
|
|
184
|
+
}, adornments.prefix), React__default["default"].createElement(TextInputField, defaultTheme._extends({
|
|
185
|
+
ref: textInputRef,
|
|
186
|
+
value: value,
|
|
187
|
+
defaultValue: defaultValue,
|
|
188
|
+
name: name,
|
|
189
|
+
placeholder: placeholder || ' ',
|
|
190
|
+
type: type,
|
|
191
|
+
required: required,
|
|
192
|
+
autoComplete: autoComplete,
|
|
193
|
+
hasIcon: Boolean(icon),
|
|
194
|
+
error: hasError,
|
|
195
|
+
warning: hasWarning,
|
|
196
|
+
id: "text-input-".concat(uniqueId),
|
|
197
|
+
onChange: onChange,
|
|
198
|
+
onBlur: onBlur,
|
|
199
|
+
readOnly: readOnly,
|
|
200
|
+
noBorder: noBorder
|
|
201
|
+
}, rest)), !readOnly && noBorder && React__default["default"].createElement(InputIconContainer, {
|
|
202
|
+
error: error,
|
|
203
|
+
warning: warning
|
|
204
|
+
}, React__default["default"].createElement(editNote.SvgEditNote, null)), label && React__default["default"].createElement(TextInputLabel, {
|
|
205
|
+
htmlFor: "text-input-".concat(uniqueId),
|
|
206
|
+
hasPlaceholder: Boolean(placeholder),
|
|
207
|
+
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),
|
|
208
|
+
hasIcon: Boolean(icon),
|
|
209
|
+
error: hasError
|
|
210
|
+
}, label, required && ' *'), typeof (adornments === null || adornments === void 0 ? void 0 : adornments.suffix) === 'string' && adornments.suffix.length > 0 && React__default["default"].createElement(Adornment, {
|
|
211
|
+
error: hasError,
|
|
212
|
+
warning: hasWarning,
|
|
213
|
+
isPrefix: false,
|
|
214
|
+
onClick: function onClick() {
|
|
215
|
+
return textInputDomNode.current.focus();
|
|
216
|
+
}
|
|
217
|
+
}, adornments.suffix)), typeof descriptionText === 'string' && descriptionText.length > 0 && React__default["default"].createElement(Description, {
|
|
218
|
+
error: hasError,
|
|
219
|
+
warning: hasWarning
|
|
220
|
+
}, descriptionText));
|
|
221
|
+
});
|
|
222
|
+
TextInput.defaultProps = {
|
|
223
|
+
type: 'text',
|
|
224
|
+
noBorder: false
|
|
225
|
+
};
|
|
226
|
+
TextInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
227
|
+
value: defaultTheme.PropTypes.string,
|
|
228
|
+
defaultValue: defaultTheme.PropTypes.string,
|
|
229
|
+
name: defaultTheme.PropTypes.string,
|
|
230
|
+
label: defaultTheme.PropTypes.string,
|
|
231
|
+
placeholder: defaultTheme.PropTypes.string,
|
|
232
|
+
type: defaultTheme.PropTypes.string,
|
|
233
|
+
required: defaultTheme.PropTypes.bool,
|
|
234
|
+
disabled: defaultTheme.PropTypes.bool,
|
|
235
|
+
readOnly: defaultTheme.PropTypes.bool,
|
|
236
|
+
autoComplete: defaultTheme.PropTypes.string,
|
|
237
|
+
description: defaultTheme.PropTypes.string,
|
|
238
|
+
error: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
239
|
+
warning: defaultTheme.PropTypes.oneOfType([defaultTheme.PropTypes.bool, defaultTheme.PropTypes.string]),
|
|
240
|
+
icon: defaultTheme.PropTypes.element,
|
|
241
|
+
adornments: defaultTheme.PropTypes.shape({
|
|
242
|
+
prefix: defaultTheme.PropTypes.string,
|
|
243
|
+
suffix: defaultTheme.PropTypes.string
|
|
244
|
+
}),
|
|
245
|
+
className: defaultTheme.PropTypes.string,
|
|
246
|
+
style: defaultTheme.PropTypes.object,
|
|
247
|
+
onChange: defaultTheme.PropTypes.func,
|
|
248
|
+
onBlur: defaultTheme.PropTypes.func,
|
|
249
|
+
noBorder: defaultTheme.PropTypes.bool
|
|
250
|
+
} : {};
|
|
251
|
+
|
|
252
|
+
exports.TextInput = TextInput;
|