@occmundial/occ-atomic 1.19.0 → 1.20.0
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/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# [1.20.0](https://github.com/occmundial/occ-atomic/compare/v1.19.0...v1.20.0) (2022-01-19)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Change in TextField icons ([989abb3](https://github.com/occmundial/occ-atomic/commit/989abb35e3d7e346a68519939f5cc4b489affb7b))
|
7
|
+
* Simplify TextField status logic ([574824a](https://github.com/occmundial/occ-atomic/commit/574824a63c6ba8e83cefafaca102566e53578d0e))
|
8
|
+
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* Add searchField theme to the TextField component ([3f36f4f](https://github.com/occmundial/occ-atomic/commit/3f36f4fcef97130a11afd0ed1e857d289295e491))
|
13
|
+
|
1
14
|
# [1.19.0](https://github.com/occmundial/occ-atomic/compare/v1.18.4...v1.19.0) (2021-12-20)
|
2
15
|
|
3
16
|
|
@@ -154,7 +154,7 @@ describe("Autocomplete", function () {
|
|
154
154
|
wrapper.setState({
|
155
155
|
focus: true
|
156
156
|
});
|
157
|
-
wrapper.find('.Droplist-item-0-1-
|
157
|
+
wrapper.find('.Droplist-item-0-1-34').at(0).simulate('mousedown');
|
158
158
|
expect(onMouseDown.mock.calls[0][0]).toEqual({
|
159
159
|
id: 1,
|
160
160
|
text: 'Administrador',
|
@@ -164,7 +164,7 @@ describe("Autocomplete", function () {
|
|
164
164
|
focus: true,
|
165
165
|
value: 'a'
|
166
166
|
});
|
167
|
-
wrapper.find('.Droplist-item-0-1-
|
167
|
+
wrapper.find('.Droplist-item-0-1-34').at(1).simulate('mousedown');
|
168
168
|
expect(onMouseDown.mock.calls[1][0]).toEqual({
|
169
169
|
id: 2,
|
170
170
|
text: 'Administrador Sr',
|
@@ -209,7 +209,7 @@ describe("Autocomplete", function () {
|
|
209
209
|
wrapper.setState({
|
210
210
|
focus: true
|
211
211
|
});
|
212
|
-
wrapper.find('.Droplist-item-0-1-
|
212
|
+
wrapper.find('.Droplist-item-0-1-34').at(0).simulate('mousedown');
|
213
213
|
expect(onMouseDown.mock.calls.length).toBe(1);
|
214
214
|
});
|
215
215
|
it('calls the onFocus function', function () {
|
@@ -222,60 +222,82 @@ var TextField = /*#__PURE__*/function (_React$Component) {
|
|
222
222
|
type = _this$props7.type,
|
223
223
|
inputClassName = _this$props7.inputClassName,
|
224
224
|
alignRight = _this$props7.alignRight,
|
225
|
-
hjWhitelist = _this$props7.hjWhitelist
|
225
|
+
hjWhitelist = _this$props7.hjWhitelist,
|
226
|
+
searchField = _this$props7.searchField;
|
226
227
|
var className = classes.input;
|
227
|
-
if (
|
228
|
-
if (
|
229
|
-
if (
|
230
|
-
if (
|
231
|
-
if (
|
232
|
-
if (type == "
|
228
|
+
if (searchField) className += " ".concat(classes.searchField);
|
229
|
+
if (iconName) className += " ".concat(classes.hasIcon);
|
230
|
+
if (searchField && iconName) className += " ".concat(classes.searchFieldHasIcon);
|
231
|
+
if (clear) className += " ".concat(classes.hasClear);
|
232
|
+
if (alignRight) className += " ".concat(classes.alignRight);
|
233
|
+
if (type == "select") className += " ".concat(classes.select);
|
234
|
+
if (type == "textarea") className += " ".concat(classes.textarea);
|
235
|
+
if (type == "password") className += " ".concat(classes.hasPass);
|
233
236
|
if (hjWhitelist) className += ' data-hj-whitelist';
|
234
|
-
if (inputClassName) className +=
|
237
|
+
if (inputClassName) className += " ".concat(inputClassName);
|
235
238
|
return className;
|
236
239
|
}
|
237
240
|
}, {
|
238
|
-
key: "
|
239
|
-
value: function
|
240
|
-
var _this2 = this;
|
241
|
-
|
241
|
+
key: "setIconColor",
|
242
|
+
value: function setIconColor() {
|
242
243
|
var _this$state = this.state,
|
243
244
|
status = _this$state.status,
|
244
245
|
value = _this$state.value,
|
245
|
-
touched = _this$state.touched
|
246
|
-
showPass = _this$state.showPass,
|
247
|
-
passIconBeingClicked = _this$state.passIconBeingClicked;
|
246
|
+
touched = _this$state.touched;
|
248
247
|
var _this$props8 = this.props,
|
249
|
-
classes = _this$props8.classes,
|
250
|
-
input = _this$props8.input,
|
251
|
-
meta = _this$props8.meta,
|
252
|
-
label = _this$props8.label,
|
253
|
-
placeholder = _this$props8.placeholder,
|
254
|
-
counter = _this$props8.counter,
|
255
|
-
maxLength = _this$props8.maxLength,
|
256
|
-
type = _this$props8.type,
|
257
|
-
name = _this$props8.name,
|
258
|
-
options = _this$props8.options,
|
259
|
-
id = _this$props8.id,
|
260
|
-
style = _this$props8.style,
|
261
248
|
disabled = _this$props8.disabled,
|
262
|
-
|
249
|
+
searchField = _this$props8.searchField,
|
263
250
|
error = _this$props8.error,
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
251
|
+
allowError = _this$props8.allowError;
|
252
|
+
if (disabled) return _colors["default"].grey500;
|
253
|
+
if (status === 'focus' && searchField) return _colors["default"].prim;
|
254
|
+
if (error && (allowError || touched)) return _colors["default"].error;
|
255
|
+
if (status !== 'focus' && searchField && value) return _colors["default"].grey900;
|
256
|
+
return _colors["default"].grey500;
|
257
|
+
}
|
258
|
+
}, {
|
259
|
+
key: "render",
|
260
|
+
value: function render() {
|
261
|
+
var _this2 = this;
|
262
|
+
|
263
|
+
var _this$state2 = this.state,
|
264
|
+
status = _this$state2.status,
|
265
|
+
value = _this$state2.value,
|
266
|
+
touched = _this$state2.touched,
|
267
|
+
showPass = _this$state2.showPass,
|
268
|
+
passIconBeingClicked = _this$state2.passIconBeingClicked;
|
269
|
+
var _this$props9 = this.props,
|
270
|
+
classes = _this$props9.classes,
|
271
|
+
input = _this$props9.input,
|
272
|
+
meta = _this$props9.meta,
|
273
|
+
label = _this$props9.label,
|
274
|
+
placeholder = _this$props9.placeholder,
|
275
|
+
counter = _this$props9.counter,
|
276
|
+
maxLength = _this$props9.maxLength,
|
277
|
+
type = _this$props9.type,
|
278
|
+
name = _this$props9.name,
|
279
|
+
options = _this$props9.options,
|
280
|
+
id = _this$props9.id,
|
281
|
+
style = _this$props9.style,
|
282
|
+
disabled = _this$props9.disabled,
|
283
|
+
autoFocus = _this$props9.autoFocus,
|
284
|
+
error = _this$props9.error,
|
285
|
+
assistiveText = _this$props9.assistiveText,
|
286
|
+
clear = _this$props9.clear,
|
287
|
+
iconName = _this$props9.iconName,
|
288
|
+
allowError = _this$props9.allowError,
|
289
|
+
lockHeight = _this$props9.lockHeight,
|
290
|
+
required = _this$props9.required,
|
291
|
+
mask = _this$props9.mask,
|
292
|
+
guide = _this$props9.guide,
|
293
|
+
inputMode = _this$props9.inputMode,
|
294
|
+
disableAutoComplete = _this$props9.disableAutoComplete,
|
295
|
+
pattern = _this$props9.pattern,
|
296
|
+
searchField = _this$props9.searchField;
|
275
297
|
var realStatus = status;
|
276
298
|
var InputType = type == "select" ? "select" : type == "textarea" ? "textarea" : "input";
|
277
299
|
var errorStatus = meta && meta.error && (meta.touched || allowError) || error && (touched || allowError) && !passIconBeingClicked;
|
278
|
-
if (disabled) realStatus = 'disabled';else if (status != 'focus' && errorStatus) realStatus = 'error';
|
300
|
+
if (disabled) realStatus = 'disabled';else if (status != 'focus' && errorStatus) realStatus = 'error';else if (status !== 'focus' && searchField && value) realStatus = 'filled';
|
279
301
|
var element, passIcon;
|
280
302
|
var commonProps = {
|
281
303
|
name: name,
|
@@ -326,7 +348,7 @@ var TextField = /*#__PURE__*/function (_React$Component) {
|
|
326
348
|
iconName: "eyeSolid",
|
327
349
|
width: _iconSizes["default"].small,
|
328
350
|
height: _iconSizes["default"].small,
|
329
|
-
colors: [_colors["default"].
|
351
|
+
colors: [_colors["default"].grey200]
|
330
352
|
}));
|
331
353
|
} else if (type == "select") {
|
332
354
|
element = /*#__PURE__*/_react["default"].createElement(InputType, commonProps, /*#__PURE__*/_react["default"].createElement("option", {
|
@@ -380,7 +402,7 @@ var TextField = /*#__PURE__*/function (_React$Component) {
|
|
380
402
|
iconName: "eyeSolid",
|
381
403
|
width: _iconSizes["default"].small,
|
382
404
|
height: _iconSizes["default"].small,
|
383
|
-
colors: showPass ? [_colors["default"].
|
405
|
+
colors: showPass ? [_colors["default"].grey900] : [_colors["default"].grey400]
|
384
406
|
}));
|
385
407
|
}
|
386
408
|
|
@@ -395,10 +417,10 @@ var TextField = /*#__PURE__*/function (_React$Component) {
|
|
395
417
|
className: classes.inputWrap
|
396
418
|
}, iconName && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
397
419
|
iconName: iconName,
|
398
|
-
width: _iconSizes["default"].
|
399
|
-
height: _iconSizes["default"].
|
420
|
+
width: _iconSizes["default"].small,
|
421
|
+
height: _iconSizes["default"].small,
|
400
422
|
className: classes.icon,
|
401
|
-
colors:
|
423
|
+
colors: [this.setIconColor()]
|
402
424
|
}), type == 'select' && /*#__PURE__*/_react["default"].createElement("div", {
|
403
425
|
className: classes.selectIcon
|
404
426
|
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
@@ -410,7 +432,9 @@ var TextField = /*#__PURE__*/function (_React$Component) {
|
|
410
432
|
onClick: this.onClear,
|
411
433
|
className: classes.clear
|
412
434
|
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
413
|
-
iconName: "close"
|
435
|
+
iconName: "close",
|
436
|
+
width: _iconSizes["default"].small,
|
437
|
+
height: _iconSizes["default"].small
|
414
438
|
})), element), (assistiveText || counter && maxLength || lockHeight) && /*#__PURE__*/_react["default"].createElement("div", {
|
415
439
|
className: classes.bottom
|
416
440
|
}, assistiveText && /*#__PURE__*/_react["default"].createElement("label", {
|
@@ -549,7 +573,10 @@ TextField.propTypes = {
|
|
549
573
|
style: _propTypes["default"].object,
|
550
574
|
|
551
575
|
/** Regular expression to validate the input content. */
|
552
|
-
pattern: _propTypes["default"].string
|
576
|
+
pattern: _propTypes["default"].string,
|
577
|
+
|
578
|
+
/** Size of the TextField. */
|
579
|
+
searchField: _propTypes["default"].bool
|
553
580
|
};
|
554
581
|
var _default = TextField;
|
555
582
|
exports["default"] = _default;
|
@@ -228,6 +228,14 @@ describe("TextField", function () {
|
|
228
228
|
});
|
229
229
|
expect(wrapper.state('value')).toBe('123abc');
|
230
230
|
});
|
231
|
+
it('renders as a SearchField', function () {
|
232
|
+
var wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
|
233
|
+
searchField: true,
|
234
|
+
classes: classes
|
235
|
+
}));
|
236
|
+
var input = wrapper.find('input');
|
237
|
+
expect(input.hasClass('searchField')).toBe(true);
|
238
|
+
});
|
231
239
|
});
|
232
240
|
describe("TextFieldJSS", function () {
|
233
241
|
it('matches the snapshot', function () {
|
@@ -15,6 +15,8 @@ var _spacing = _interopRequireDefault(require("../subatomic/spacing"));
|
|
15
15
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
17
17
|
|
18
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
+
|
18
20
|
var _default = {
|
19
21
|
container: {
|
20
22
|
position: 'relative',
|
@@ -44,6 +46,13 @@ var _default = {
|
|
44
46
|
focus: {
|
45
47
|
'& $input': {
|
46
48
|
borderColor: _colors["default"].prim
|
49
|
+
},
|
50
|
+
'& $searchField': {
|
51
|
+
borderWidth: 2,
|
52
|
+
paddingLeft: _spacing["default"].tiny - 1
|
53
|
+
},
|
54
|
+
'& $searchFieldHasIcon': {
|
55
|
+
paddingLeft: 41
|
47
56
|
}
|
48
57
|
},
|
49
58
|
error: {
|
@@ -51,6 +60,24 @@ var _default = {
|
|
51
60
|
borderColor: _colors["default"].error,
|
52
61
|
color: _colors["default"].errorText,
|
53
62
|
background: (0, _hexRgba["default"])(_colors["default"].errorText, 4)
|
63
|
+
},
|
64
|
+
'& $searchField': {
|
65
|
+
borderWidth: 2,
|
66
|
+
color: _colors["default"].ink,
|
67
|
+
paddingLeft: _spacing["default"].tiny - 1
|
68
|
+
},
|
69
|
+
'& $searchFieldHasIcon': {
|
70
|
+
paddingLeft: 41
|
71
|
+
}
|
72
|
+
},
|
73
|
+
filled: {
|
74
|
+
'& $input': {
|
75
|
+
borderColor: _colors["default"].grey900,
|
76
|
+
borderWidth: 2,
|
77
|
+
paddingLeft: _spacing["default"].tiny - 1
|
78
|
+
},
|
79
|
+
'& $searchFieldHasIcon': {
|
80
|
+
paddingLeft: 41
|
54
81
|
}
|
55
82
|
},
|
56
83
|
label: {
|
@@ -92,7 +119,7 @@ var _default = {
|
|
92
119
|
background: _colors["default"].bgWhite,
|
93
120
|
border: "1px solid ".concat(_colors["default"].grey200),
|
94
121
|
borderRadius: 4,
|
95
|
-
padding:
|
122
|
+
padding: [_spacing["default"].tiny, _spacing["default"].small],
|
96
123
|
boxShadow: 'none',
|
97
124
|
outline: 'none',
|
98
125
|
transition: '0.3s all',
|
@@ -157,8 +184,9 @@ var _default = {
|
|
157
184
|
},
|
158
185
|
icon: {
|
159
186
|
position: 'absolute',
|
160
|
-
left: _spacing["default"].
|
161
|
-
top:
|
187
|
+
left: _spacing["default"].small,
|
188
|
+
top: '50%',
|
189
|
+
transform: 'translateY(-50%)'
|
162
190
|
},
|
163
191
|
passIcon: {
|
164
192
|
width: 24,
|
@@ -191,7 +219,7 @@ var _default = {
|
|
191
219
|
hasClear: {
|
192
220
|
paddingRight: 42
|
193
221
|
},
|
194
|
-
clear: {
|
222
|
+
clear: _defineProperty({
|
195
223
|
width: 24,
|
196
224
|
height: 24,
|
197
225
|
background: 'none',
|
@@ -200,11 +228,12 @@ var _default = {
|
|
200
228
|
margin: 0,
|
201
229
|
position: 'absolute',
|
202
230
|
right: 12,
|
203
|
-
top:
|
231
|
+
top: '50%',
|
232
|
+
transform: 'translateY(-50%)',
|
204
233
|
zIndex: 1,
|
205
234
|
outline: 0,
|
206
235
|
cursor: 'pointer'
|
207
|
-
},
|
236
|
+
}, "padding", 3),
|
208
237
|
alignRight: {
|
209
238
|
textAlign: 'right'
|
210
239
|
},
|
@@ -220,6 +249,13 @@ var _default = {
|
|
220
249
|
bottom: {
|
221
250
|
height: 20,
|
222
251
|
marginTop: 4
|
223
|
-
}
|
252
|
+
},
|
253
|
+
searchField: {
|
254
|
+
height: _spacing["default"].large,
|
255
|
+
borderRadius: _spacing["default"].base,
|
256
|
+
borderColor: _colors["default"].grey600,
|
257
|
+
background: [_colors["default"].bgWhite, '!important']
|
258
|
+
},
|
259
|
+
searchFieldHasIcon: {}
|
224
260
|
};
|
225
261
|
exports["default"] = _default;
|
package/package.json
CHANGED