@occmundial/occ-atomic 2.0.0 → 3.0.0-beta.1

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.
@@ -5,70 +5,100 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
 
8
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
8
+ var _spacing = _interopRequireDefault(require("../tokens/spacing.json"));
9
9
 
10
- var _spacing = _interopRequireDefault(require("../subatomic/spacing"));
10
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
11
+
12
+ var _shadows = _interopRequireDefault(require("../tokens/shadows.json"));
13
+
14
+ var _fonts = _interopRequireDefault(require("../tokens/fonts.json"));
15
+
16
+ var _borderRadius = _interopRequireDefault(require("../tokens/borderRadius.json"));
17
+
18
+ var _styles = require("../Text/styles");
11
19
 
12
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
21
 
14
- var gutter = _spacing["default"].gutter,
15
- tiny = _spacing["default"].tiny,
16
- small = _spacing["default"].small,
17
- base = _spacing["default"].base,
18
- xTiny = _spacing["default"].xTiny;
19
- var primLighter = _colors["default"].primLighter,
20
- grey50 = _colors["default"].grey50,
21
- grey200 = _colors["default"].grey200,
22
- bgWhite = _colors["default"].bgWhite,
23
- textLink = _colors["default"].textLink;
24
22
  var _default = {
25
23
  block: {
26
- background: bgWhite,
27
- border: "1px solid ".concat(grey200),
28
- borderRadius: xTiny,
29
- overflow: 'hidden'
24
+ background: _colors["default"]['text-field'].bg["default"],
25
+ border: "1px solid ".concat(_colors["default"]['text-field'].border["default"]),
26
+ borderRadius: _borderRadius["default"]['br-xs'],
27
+ overflow: 'hidden',
28
+ padding: _spacing["default"]['size-2'],
29
+ boxShadow: _shadows["default"]['elevation-elevation-4']
30
+ },
31
+ text: {
32
+ margin: 0
30
33
  },
31
34
  group: {
32
- padding: [small, small, xTiny]
35
+ padding: [_spacing["default"]['size-2'], _spacing["default"]['size-4'], 0],
36
+ display: 'inline-block'
37
+ },
38
+ groupText: {
39
+ font: (0, _styles.parseFontValue)(_fonts["default"]['text-field-label'])
33
40
  },
34
41
  item: {
35
42
  display: 'flex',
36
43
  justifyContent: 'space-between',
37
- padding: [tiny, small],
44
+ alignItems: 'center',
45
+ padding: [_spacing["default"]['size-3'], _spacing["default"]['size-4']],
38
46
  transition: '0.1s all',
47
+ borderRadius: _borderRadius["default"]['br-xs'],
39
48
  position: 'relative',
40
49
  '&:hover': {
41
- background: grey50
50
+ background: _colors["default"].dropdown.bg.hover
51
+ },
52
+ '&:active, &:focus': {
53
+ background: _colors["default"].dropdown.bg.active,
54
+ '& > $rightText': {
55
+ color: _colors["default"].text.corp.primary
56
+ }
42
57
  }
43
58
  },
44
59
  itemPointer: {
45
60
  cursor: 'pointer'
46
61
  },
62
+ disabled: {
63
+ pointerEvents: 'none'
64
+ },
47
65
  right: {
48
- "float": 'right',
49
- transition: '0.1s all',
50
- marginLeft: small
66
+ marginLeft: _spacing["default"]['size-4']
67
+ },
68
+ rightText: {
69
+ font: (0, _styles.parseFontValue)(_fonts["default"]['text-field-label']),
70
+ color: _colors["default"].text.corp.secondary
51
71
  },
52
72
  onFocus: {
53
- background: primLighter,
73
+ background: _colors["default"].dropdown.bg.active,
54
74
  '&:hover': {
55
- background: primLighter
75
+ background: _colors["default"].dropdown.bg.active
56
76
  }
57
77
  },
58
78
  icon: {
59
- marginRight: tiny,
60
- position: 'absolute',
61
- top: gutter
79
+ marginRight: _spacing["default"]['size-2']
62
80
  },
63
- iconText: {
81
+ mainText: {
64
82
  display: 'inline-block',
65
- marginLeft: base
83
+ font: (0, _styles.parseFontValue)(_fonts["default"]['text-field-placeholder']),
84
+ color: _colors["default"].text.corp.primary
85
+ },
86
+ corpDisabled: {
87
+ color: _colors["default"].text.corp.disabled
66
88
  },
67
89
  extraText: {
68
- marginLeft: tiny
90
+ marginLeft: _spacing["default"]['size-1'],
91
+ display: 'inline-block',
92
+ font: (0, _styles.parseFontValue)(_fonts["default"]['heading-tag']),
93
+ color: _colors["default"].text.indigo.primary
94
+ },
95
+ highlighted: {
96
+ background: _colors["default"].bg.action.secondary["default"],
97
+ font: (0, _styles.parseFontValue)(_fonts["default"]['text-field-placeholder'])
69
98
  },
70
- extraTextColor: {
71
- color: textLink
99
+ itemContainer: {
100
+ display: 'flex',
101
+ alignItems: 'center'
72
102
  }
73
103
  };
74
104
  exports["default"] = _default;
@@ -3,6 +3,7 @@
3
3
  exports[`FAB matches the snapshot 1`] = `
4
4
  <button
5
5
  className="Button-btn-0-1-28 Button-btn-0-1-1 Button-tertiary-0-1-23 Button-tertiary-0-1-6 fab Button-iconOnly-0-1-38 Button-iconOnly-0-1-18 Button-round-0-1-40 Button-round-0-1-20"
6
+ disabled={false}
6
7
  >
7
8
  <span
8
9
  className="Button-cont-0-1-29 Button-cont-0-1-2"
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports["default"] = exports.parseFontValue = void 0;
7
7
 
8
8
  var _colors = _interopRequireDefault(require("../subatomic/colors"));
9
9
 
@@ -46,6 +46,7 @@ var parseFontValue = function parseFontValue(font) {
46
46
  return "".concat(font.fontWeight, " ").concat(font.fontSize, "/").concat(font.lineHeight, " ").concat(_fonts["default"].body);
47
47
  };
48
48
 
49
+ exports.parseFontValue = parseFontValue;
49
50
  var _default = {
50
51
  text: {
51
52
  letterSpacing: 0,
@@ -15,9 +15,9 @@ var _reactTextMask = _interopRequireDefault(require("react-text-mask"));
15
15
 
16
16
  var _Icon = _interopRequireDefault(require("../Icon"));
17
17
 
18
- var _colors = _interopRequireDefault(require("../subatomic/colors"));
18
+ var _Button = _interopRequireDefault(require("../Button"));
19
19
 
20
- var _iconSizes = _interopRequireDefault(require("../subatomic/iconSizes"));
20
+ var _colors = _interopRequireDefault(require("../tokens/colors.json"));
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
23
 
@@ -222,12 +222,9 @@ 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,
226
- searchField = _this$props7.searchField;
225
+ hjWhitelist = _this$props7.hjWhitelist;
227
226
  var className = classes.input;
228
- if (searchField) className += " ".concat(classes.searchField);
229
227
  if (iconName) className += " ".concat(classes.hasIcon);
230
- if (searchField && iconName) className += " ".concat(classes.searchFieldHasIcon);
231
228
  if (clear) className += " ".concat(classes.hasClear);
232
229
  if (alignRight) className += " ".concat(classes.alignRight);
233
230
  if (type == 'select') className += " ".concat(classes.select);
@@ -240,65 +237,54 @@ var TextField = /*#__PURE__*/function (_React$Component) {
240
237
  }, {
241
238
  key: "setIconColor",
242
239
  value: function setIconColor() {
243
- var _this$state = this.state,
244
- status = _this$state.status,
245
- value = _this$state.value,
246
- touched = _this$state.touched;
247
- var _this$props8 = this.props,
248
- disabled = _this$props8.disabled,
249
- searchField = _this$props8.searchField,
250
- error = _this$props8.error,
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;
240
+ var status = this.state.status;
241
+ var disabled = this.props.disabled;
242
+ if (disabled) return _colors["default"].icon["default"].disabled;
243
+ if (status === 'focus') return _colors["default"].icon.brand.bold;
244
+ return _colors["default"].icon["default"]["default"];
257
245
  }
258
246
  }, {
259
247
  key: "render",
260
248
  value: function render() {
261
249
  var _this2 = this;
262
250
 
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,
297
- testId = _this$props9.testId;
251
+ var _this$state = this.state,
252
+ status = _this$state.status,
253
+ value = _this$state.value,
254
+ touched = _this$state.touched,
255
+ showPass = _this$state.showPass,
256
+ passIconBeingClicked = _this$state.passIconBeingClicked;
257
+ var _this$props8 = this.props,
258
+ classes = _this$props8.classes,
259
+ input = _this$props8.input,
260
+ meta = _this$props8.meta,
261
+ label = _this$props8.label,
262
+ placeholder = _this$props8.placeholder,
263
+ counter = _this$props8.counter,
264
+ maxLength = _this$props8.maxLength,
265
+ type = _this$props8.type,
266
+ name = _this$props8.name,
267
+ options = _this$props8.options,
268
+ id = _this$props8.id,
269
+ style = _this$props8.style,
270
+ disabled = _this$props8.disabled,
271
+ autoFocus = _this$props8.autoFocus,
272
+ error = _this$props8.error,
273
+ assistiveText = _this$props8.assistiveText,
274
+ clear = _this$props8.clear,
275
+ iconName = _this$props8.iconName,
276
+ allowError = _this$props8.allowError,
277
+ required = _this$props8.required,
278
+ mask = _this$props8.mask,
279
+ guide = _this$props8.guide,
280
+ inputMode = _this$props8.inputMode,
281
+ disableAutoComplete = _this$props8.disableAutoComplete,
282
+ pattern = _this$props8.pattern,
283
+ testId = _this$props8.testId;
298
284
  var realStatus = status;
299
285
  var InputType = type == 'select' ? 'select' : type == 'textarea' ? 'textarea' : 'input';
300
286
  var errorStatus = meta && meta.error && (meta.touched || allowError) || error && (touched || allowError) && !passIconBeingClicked;
301
- if (disabled) realStatus = 'disabled';else if (status != 'focus' && errorStatus) realStatus = 'error';else if (status !== 'focus' && searchField && value) realStatus = 'filled';
287
+ if (disabled) realStatus = 'disabled';else if (status != 'focus' && errorStatus) realStatus = 'error';
302
288
  var element, passIcon;
303
289
  var commonProps = {
304
290
  name: name,
@@ -344,14 +330,13 @@ var TextField = /*#__PURE__*/function (_React$Component) {
344
330
  }, input && input.value ? input.value : value ? value : placeholder));
345
331
  }
346
332
 
347
- passIcon = /*#__PURE__*/_react["default"].createElement("div", {
348
- className: classes.passIcon
349
- }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
350
- iconName: "eyeClosed",
351
- width: _iconSizes["default"].small,
352
- height: _iconSizes["default"].small,
353
- colors: [_colors["default"].grey200]
354
- }));
333
+ passIcon = /*#__PURE__*/_react["default"].createElement(_Button["default"], {
334
+ theme: "ghostGrey",
335
+ icon: "eye",
336
+ size: "md",
337
+ disabled: true,
338
+ className: classes.rightButton
339
+ });
355
340
  } else if (type == 'select') {
356
341
  element = /*#__PURE__*/_react["default"].createElement(InputType, commonProps, /*#__PURE__*/_react["default"].createElement("option", {
357
342
  value: "",
@@ -369,7 +354,7 @@ var TextField = /*#__PURE__*/function (_React$Component) {
369
354
  value: option.value,
370
355
  disabled: option.disabled
371
356
  }, testId && {
372
- 'data-testid': "".concat(testId, "__item-").concat(item.value)
357
+ 'data-testid': "".concat(testId, "__item-").concat(option.value)
373
358
  }), option.label);
374
359
  }));
375
360
  } else {
@@ -399,61 +384,55 @@ var TextField = /*#__PURE__*/function (_React$Component) {
399
384
  }, disableAutoComplete && {
400
385
  autoComplete: 'off'
401
386
  }));
402
- passIcon = /*#__PURE__*/_react["default"].createElement("div", {
387
+ passIcon = /*#__PURE__*/_react["default"].createElement(_Button["default"], {
388
+ theme: "ghostGrey",
389
+ icon: showPass ? 'eye' : 'eye-slash',
390
+ size: "md",
391
+ className: classes.rightButton,
403
392
  onMouseDown: this.togglePass,
404
393
  onMouseUp: this.focusInput,
405
- onMouseOut: this.outOfPassIcon,
406
- className: classes.passIcon
407
- }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
408
- iconName: showPass ? 'eye' : 'eyeClosed',
409
- width: _iconSizes["default"].small,
410
- height: _iconSizes["default"].small,
411
- colors: showPass ? [_colors["default"].grey900] : [_colors["default"].grey400]
412
- }));
394
+ onMouseOut: this.outOfPassIcon
395
+ });
413
396
  }
414
397
 
415
398
  return /*#__PURE__*/_react["default"].createElement("div", {
416
399
  className: this.setClassName(realStatus),
417
400
  style: style
418
- }, (label || lockHeight) && /*#__PURE__*/_react["default"].createElement("div", {
401
+ }, label && /*#__PURE__*/_react["default"].createElement("div", {
419
402
  className: classes.top
420
403
  }, label && /*#__PURE__*/_react["default"].createElement("label", {
421
- className: "".concat(classes.label, " ").concat(classes.left)
404
+ className: classes.label
422
405
  }, label)), /*#__PURE__*/_react["default"].createElement("div", {
423
406
  className: classes.inputWrap
424
407
  }, iconName && /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
425
408
  iconName: iconName,
426
- width: _iconSizes["default"].small,
427
- height: _iconSizes["default"].small,
409
+ width: 24,
410
+ height: 24,
428
411
  className: classes.icon,
429
412
  colors: [this.setIconColor()]
430
413
  }), type == 'select' && /*#__PURE__*/_react["default"].createElement("div", {
431
414
  className: classes.selectIcon
432
415
  }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
433
- iconName: "arrowDown",
434
- width: _iconSizes["default"].small,
435
- height: _iconSizes["default"].small,
436
- colors: disabled ? [_colors["default"].grey200] : [_colors["default"].grey900]
437
- })), type == 'password' && passIcon, value && clear && /*#__PURE__*/_react["default"].createElement("div", _extends({
438
- onClick: this.onClear,
439
- className: classes.clear
416
+ iconName: "chevron-down",
417
+ width: 24,
418
+ height: 24,
419
+ colors: disabled ? [_colors["default"].icon["default"].disabled] : [_colors["default"].icon["default"]["default"]]
420
+ })), element, type == 'password' && passIcon, value && clear && /*#__PURE__*/_react["default"].createElement(_Button["default"], _extends({
421
+ icon: "x",
422
+ theme: "ghostGrey",
423
+ size: "md",
424
+ className: classes.rightButton,
425
+ onClick: this.onClear
440
426
  }, testId && {
441
427
  'data-testid': "".concat(testId, "__container-close-icon")
442
- }), /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
443
- iconName: "close",
444
- width: _iconSizes["default"].small,
445
- height: _iconSizes["default"].small
446
- })), element), (assistiveText || counter && maxLength || lockHeight) && /*#__PURE__*/_react["default"].createElement("div", {
428
+ }))), (assistiveText || counter && maxLength) && /*#__PURE__*/_react["default"].createElement("div", {
447
429
  className: classes.bottom
430
+ }, /*#__PURE__*/_react["default"].createElement("span", {
431
+ className: classes.assistiveTextWrap
448
432
  }, assistiveText && /*#__PURE__*/_react["default"].createElement("label", {
449
- className: "".concat(classes.label, " ").concat(classes.left, " ").concat(realStatus == 'error' ? classes.errorAssistiveText : classes.assistiveText)
450
- }, realStatus == 'error' ? /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
451
- iconName: "warningSolid",
452
- width: _iconSizes["default"].tiny,
453
- height: _iconSizes["default"].tiny,
454
- className: classes.errorIcon
455
- }) : null, ' ', assistiveText), counter && maxLength && /*#__PURE__*/_react["default"].createElement("label", {
456
- className: "".concat(classes.label, " ").concat(classes.right, " ").concat(classes.counter)
433
+ className: "".concat(classes.assistiveText, " ").concat(realStatus == 'error' ? classes.assistiveError : null)
434
+ }, assistiveText)), counter && maxLength && /*#__PURE__*/_react["default"].createElement("label", {
435
+ className: "".concat(classes.counter)
457
436
  }, value.length, " / ", maxLength)));
458
437
  }
459
438
  }]);
@@ -511,9 +490,6 @@ TextField.propTypes = {
511
490
  /** It allows the component to display the error messages even if it hasn't been touched. */
512
491
  allowError: _propTypes["default"].bool,
513
492
 
514
- /** By default the TextField container would be smaller without a label or an assistive text. lockHeight will maintain the same height as if it had both, label and assistive text. */
515
- lockHeight: _propTypes["default"].bool,
516
-
517
493
  /** Use as a default value. */
518
494
  valueProp: _propTypes["default"].node,
519
495
 
@@ -583,9 +559,6 @@ TextField.propTypes = {
583
559
  /** Regular expression to validate the input content. */
584
560
  pattern: _propTypes["default"].string,
585
561
 
586
- /** Size of the TextField. */
587
- searchField: _propTypes["default"].bool,
588
-
589
562
  /** The testId property adds the data attribute data-testid to the main element and should be used for testing only. */
590
563
  testId: _propTypes["default"].string
591
564
  };
@@ -105,13 +105,13 @@ describe("TextField", function () {
105
105
  classes: classes,
106
106
  clear: true
107
107
  }));
108
- expect(wrapper.find('.clear').length).toBe(0);
108
+ expect(wrapper.find('.rightButton').length).toBe(0);
109
109
  wrapper.setState({
110
110
  value: 'Value'
111
111
  });
112
- expect(wrapper.find('.clear').length).toBe(1);
113
- wrapper.find('.clear').simulate('click');
114
- expect(wrapper.find('.clear').length).toBe(0);
112
+ expect(wrapper.find('.rightButton').length).toBe(1);
113
+ wrapper.find('.rightButton').simulate('click');
114
+ expect(wrapper.find('.rightButton').length).toBe(0);
115
115
  expect(wrapper.state('value')).toBe('');
116
116
  });
117
117
  it('shows the TextField with an error', function () {
@@ -121,12 +121,12 @@ describe("TextField", function () {
121
121
  error: true
122
122
  }));
123
123
  expect(wrapper.find('.error').length).toBe(0);
124
- expect(wrapper.find('.errorAssistiveText').length).toBe(0);
124
+ expect(wrapper.find('.assistiveError').length).toBe(0);
125
125
  wrapper.setState({
126
126
  touched: true
127
127
  });
128
128
  expect(wrapper.find('.error').length).toBe(1);
129
- expect(wrapper.find('.errorAssistiveText').length).toBe(1);
129
+ expect(wrapper.find('.assistiveError').length).toBe(1);
130
130
  expect(wrapper.find('.error').at(0).hasClass('container')).toBe(true);
131
131
  });
132
132
  it('sets a default value', function () {
@@ -179,7 +179,7 @@ describe("TextField", function () {
179
179
  onClear: onClear,
180
180
  valueProp: "Value"
181
181
  }));
182
- wrapper.find('.clear').simulate('click');
182
+ wrapper.find('.rightButton').simulate('click');
183
183
  expect(onClear.mock.calls.length).toBe(1);
184
184
  });
185
185
  it('calls the onRef function', function () {
@@ -228,14 +228,6 @@ 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
- });
239
231
  });
240
232
  describe("TextFieldJSS", function () {
241
233
  it('matches the snapshot', function () {