intelicoreact 0.0.43 → 0.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,13 +40,10 @@ var Dropdown = function Dropdown(_ref) {
40
40
 
41
41
  var options = _ref.options,
42
42
  value = _ref.value,
43
+ error = _ref.error,
43
44
  onChange = _ref.onChange,
44
45
  placeholder = _ref.placeholder,
45
46
  className = _ref.className,
46
- label = _ref.label,
47
- isLabelBold = _ref.isLabelBold,
48
- hint = _ref.hint,
49
- hintSide = _ref.hintSide,
50
47
  isSearchable = _ref.isSearchable;
51
48
 
52
49
  var _useState = (0, _react.useState)(false),
@@ -89,6 +86,8 @@ var Dropdown = function Dropdown(_ref) {
89
86
  var filteredOptions = [].concat((0, _toConsumableArray2.default)(filteredItems), (0, _toConsumableArray2.default)(filteredGroups));
90
87
 
91
88
  var handleClickOutside = function handleClickOutside(event) {
89
+ console.log(dropdownRef.current.contains(event.target));
90
+
92
91
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
93
92
  setIsOpen(false);
94
93
  setSearchValue(null);
@@ -121,6 +120,7 @@ var Dropdown = function Dropdown(_ref) {
121
120
  }, /*#__PURE__*/_react.default.createElement("span", {
122
121
  className: (0, _classnames.default)("".concat(RC, "__active-icon"), (0, _defineProperty2.default)({}, "".concat(RC, "__active-icon_active"), item.value === value))
123
122
  }, /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null)), /*#__PURE__*/_react.default.createElement("div", {
123
+ className: item.className || '',
124
124
  dangerouslySetInnerHTML: {
125
125
  __html: hightlightedText(item.label)
126
126
  }
@@ -159,26 +159,28 @@ var Dropdown = function Dropdown(_ref) {
159
159
  return /*#__PURE__*/_react.default.createElement("div", {
160
160
  className: (0, _classnames.default)(RC, className),
161
161
  ref: dropdownRef
162
- }, label && /*#__PURE__*/_react.default.createElement(_Label.default, {
163
- className: "".concat(RC, "-label"),
164
- isBold: isLabelBold,
165
- label: label,
166
- hint: hint,
167
- hintSide: hintSide
168
- }), /*#__PURE__*/_react.default.createElement("button", {
169
- className: "".concat(RC, "__trigger"),
170
- onClick: function onClick() {
171
- return setIsOpen(!isOpen);
172
- }
162
+ }, /*#__PURE__*/_react.default.createElement("button", {
163
+ className: "".concat(RC, "__trigger input__wrap ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : '')
173
164
  }, isSearchable ? /*#__PURE__*/_react.default.createElement("input", {
174
165
  className: "".concat(RC, "__input"),
175
166
  value: searchValue !== null && searchValue !== void 0 ? searchValue : selectedLabel,
176
167
  onChange: function onChange(e) {
177
168
  return onSearchHandler(e.target.value);
178
169
  },
179
- placeholder: placeholder
180
- }) : selectedLabel || placeholder, /*#__PURE__*/_react.default.createElement("span", {
181
- className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen))
170
+ placeholder: placeholder,
171
+ onFocus: function onFocus() {
172
+ return setIsOpen(true);
173
+ }
174
+ }) : /*#__PURE__*/_react.default.createElement("span", {
175
+ className: "text",
176
+ onClick: function onClick() {
177
+ return setIsOpen(!isOpen);
178
+ }
179
+ }, selectedLabel || placeholder), /*#__PURE__*/_react.default.createElement("span", {
180
+ className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen)),
181
+ onClick: function onClick() {
182
+ return setIsOpen(!isOpen);
183
+ }
182
184
  }, isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null))), isOpen && filteredOptions.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
183
185
  className: "".concat(RC, "__list")
184
186
  }, filteredOptions.map(function (filteredOption) {
@@ -13,7 +13,6 @@
13
13
  border-radius: 3px;
14
14
  width: 100%;
15
15
  height: 28px;
16
- display: flex;
17
16
  align-items: center;
18
17
  cursor: pointer;
19
18
  padding-left: 9px;
@@ -26,9 +25,12 @@
26
25
  position: relative;
27
26
  text-align: left;
28
27
 
29
- &_error {
28
+ &.error {
30
29
  border-color: $color--secondary;
31
30
  }
31
+ &.placeholder .text{
32
+ opacity: .7;
33
+ }
32
34
  }
33
35
 
34
36
  &__input {
@@ -71,6 +73,8 @@
71
73
  display: flex;
72
74
  align-items: center;
73
75
  //justify-content: center;
76
+ border: none;
77
+ background: transparent;
74
78
  padding: 0 20px 0 30px;
75
79
  position: relative;
76
80
  cursor: pointer;
@@ -101,6 +105,7 @@
101
105
  display: flex;
102
106
  align-items: center;
103
107
  width: 16px;
108
+ height: 16px;
104
109
  position: absolute;
105
110
  right: 4px;
106
111
  top: 50%;
@@ -24,12 +24,26 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
24
  global.lng = 'en';
25
25
  var _default = {
26
26
  title: 'Dropdown',
27
- component: _Dropdown.default
27
+ component: _Dropdown.default,
28
+ argTypes: {
29
+ className: {
30
+ description: 'string'
31
+ },
32
+ value: {
33
+ description: 'string - current option'
34
+ },
35
+ isSearchable: {
36
+ description: 'boolean - enable search'
37
+ },
38
+ onChange: {
39
+ description: 'callback return selected value'
40
+ }
41
+ }
28
42
  };
29
43
  exports.default = _default;
30
44
 
31
45
  var Template = function Template(args) {
32
- var _useState = (0, _react.useState)({}),
46
+ var _useState = (0, _react.useState)(''),
33
47
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
34
48
  value = _useState2[0],
35
49
  setValue = _useState2[1];
@@ -48,11 +62,11 @@ var DropdownTemplate = Template.bind({});
48
62
  exports.DropdownTemplate = DropdownTemplate;
49
63
  DropdownTemplate.args = {
50
64
  placeholder: 'Placeholder',
51
- label: '',
52
65
  isSearchable: true,
53
66
  options: [{
54
67
  label: 'Dropdown1',
55
- value: 'drop1'
68
+ value: 'drop1',
69
+ className: 'status status--approved'
56
70
  }, {
57
71
  label: 'Dropdown2',
58
72
  value: 'drop2'
@@ -94,5 +108,6 @@ DropdownTemplate.args = {
94
108
  label: 'Group 23',
95
109
  value: 'group23'
96
110
  }]
97
- }]
111
+ }],
112
+ error: ''
98
113
  };
@@ -63,15 +63,6 @@
63
63
  border-radius: 4px;
64
64
  }
65
65
 
66
- &__error {
67
- margin-top: 2px;
68
- margin-left: 1px;
69
- position: absolute;
70
- display: block;
71
- font-size: 10px;
72
- color: #f06d8d;
73
- }
74
-
75
66
  &__close {
76
67
  position: relative;
77
68
  opacity: 0.6;
@@ -142,3 +133,4 @@
142
133
  visibility: visible;
143
134
  pointer-events: all;
144
135
  }
136
+
@@ -2,7 +2,7 @@
2
2
  display: flex;
3
3
  color: #1e1e2d;
4
4
  font-size: 13px;
5
- margin-top: 5px;
5
+ margin-bottom: 5px;
6
6
  align-items: center;
7
7
 
8
8
  &_bold {
@@ -13,6 +13,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
14
  var _Label = _interopRequireDefault(require("../../Atomic/FormElements/Label/Label"));
15
15
 
16
+ require("./FormElement.scss");
17
+
16
18
  var RC = 'form-element';
17
19
 
18
20
  var FormElement = function FormElement(_ref) {
@@ -0,0 +1,8 @@
1
+ .form-element__error {
2
+ margin-top: 2px;
3
+ margin-left: 1px;
4
+ position: absolute;
5
+ display: block;
6
+ font-size: 10px;
7
+ color: #f06d8d;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "0.0.43",
3
+ "version": "0.0.48",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ import './Dropdown.scss';
7
7
 
8
8
  const RC = 'dropdown';
9
9
 
10
- const Dropdown = ({ options, value, onChange, placeholder, className, label, isLabelBold, hint, hintSide, isSearchable }) => {
10
+ const Dropdown = ({ options, value, error, onChange, placeholder, className, isSearchable }) => {
11
11
  const [isOpen, setIsOpen] = useState(false);
12
12
  const [searchValue, setSearchValue] = useState('');
13
13
  const dropdownRef = useRef(null);
@@ -24,6 +24,7 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
24
24
  const filteredOptions = [...filteredItems, ...filteredGroups];
25
25
 
26
26
  const handleClickOutside = event => {
27
+ console.log(dropdownRef.current.contains(event.target));
27
28
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
28
29
  setIsOpen(false);
29
30
  setSearchValue(null);
@@ -53,7 +54,7 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
53
54
  <span className={cn(`${RC}__active-icon`, { [`${RC}__active-icon_active`]: item.value === value })}>
54
55
  <Check />
55
56
  </span>
56
- <div dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
57
+ <div className={item.className || ''} dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
57
58
  </button>
58
59
  ) : null;
59
60
 
@@ -75,19 +76,23 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
75
76
 
76
77
  return (
77
78
  <div className={cn(RC, className)} ref={dropdownRef}>
78
- {label && <Label className={`${RC}-label`} isBold={isLabelBold} label={label} hint={hint} hintSide={hintSide} />}
79
- <button className={`${RC}__trigger`} onClick={() => setIsOpen(!isOpen)}>
79
+ <button className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`} >
80
80
  {isSearchable ? (
81
81
  <input
82
82
  className={`${RC}__input`}
83
83
  value={searchValue ?? selectedLabel}
84
84
  onChange={e => onSearchHandler(e.target.value)}
85
85
  placeholder={placeholder}
86
+ onFocus={() => setIsOpen(true)}
86
87
  />
87
88
  ) : (
88
- selectedLabel || placeholder
89
+ <span className="text" onClick={() => setIsOpen(!isOpen)}>
90
+ {selectedLabel || placeholder}
91
+ </span>
89
92
  )}
90
- <span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })}>{isOpen ? <ChevronUp /> : <ChevronDown />}</span>
93
+ <span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })} onClick={() => setIsOpen(!isOpen)}>
94
+ {isOpen ? <ChevronUp /> : <ChevronDown />}
95
+ </span>
91
96
  </button>
92
97
  {isOpen && filteredOptions.length > 0 && (
93
98
  <div className={`${RC}__list`}>
@@ -13,7 +13,6 @@
13
13
  border-radius: 3px;
14
14
  width: 100%;
15
15
  height: 28px;
16
- display: flex;
17
16
  align-items: center;
18
17
  cursor: pointer;
19
18
  padding-left: 9px;
@@ -26,9 +25,12 @@
26
25
  position: relative;
27
26
  text-align: left;
28
27
 
29
- &_error {
28
+ &.error {
30
29
  border-color: $color--secondary;
31
30
  }
31
+ &.placeholder .text{
32
+ opacity: .7;
33
+ }
32
34
  }
33
35
 
34
36
  &__input {
@@ -71,6 +73,8 @@
71
73
  display: flex;
72
74
  align-items: center;
73
75
  //justify-content: center;
76
+ border: none;
77
+ background: transparent;
74
78
  padding: 0 20px 0 30px;
75
79
  position: relative;
76
80
  cursor: pointer;
@@ -101,6 +105,7 @@
101
105
  display: flex;
102
106
  align-items: center;
103
107
  width: 16px;
108
+ height: 16px;
104
109
  position: absolute;
105
110
  right: 4px;
106
111
  top: 50%;
@@ -1,15 +1,24 @@
1
1
  import React, { useState } from 'react';
2
2
  import Dropdown from './Dropdown';
3
3
 
4
-
5
4
  global.lng = 'en';
6
5
  export default {
7
6
  title: 'Dropdown',
8
- component: Dropdown
7
+ component: Dropdown,
8
+ argTypes: {
9
+ className: {
10
+ description: 'string'
11
+ },
12
+ value: { description: 'string - current option'},
13
+ isSearchable: {
14
+ description: 'boolean - enable search',
15
+ },
16
+ onChange: { description: 'callback return selected value'}
17
+ }
9
18
  };
10
19
 
11
20
  const Template = args => {
12
- const [value, setValue] = useState({});
21
+ const [value, setValue] = useState('');
13
22
  return (
14
23
  <div style={{ width: 200 }}>
15
24
  <Dropdown {...args} value={value} onChange={setValue} />
@@ -21,10 +30,9 @@ export const DropdownTemplate = Template.bind({});
21
30
 
22
31
  DropdownTemplate.args = {
23
32
  placeholder: 'Placeholder',
24
- label: '',
25
33
  isSearchable: true,
26
34
  options: [
27
- { label: 'Dropdown1', value: 'drop1' },
35
+ { label: 'Dropdown1', value: 'drop1', className: 'status status--approved' },
28
36
  { label: 'Dropdown2', value: 'drop2' },
29
37
  { label: 'Dropdown3', value: 'drop3', disabled: true },
30
38
  { label: 'Dropdown4', value: 'drop4' },
@@ -46,5 +54,6 @@ DropdownTemplate.args = {
46
54
  { label: 'Group 23', value: 'group23' }
47
55
  ]
48
56
  }
49
- ]
57
+ ],
58
+ error: ''
50
59
  };
@@ -63,15 +63,6 @@
63
63
  border-radius: 4px;
64
64
  }
65
65
 
66
- &__error {
67
- margin-top: 2px;
68
- margin-left: 1px;
69
- position: absolute;
70
- display: block;
71
- font-size: 10px;
72
- color: #f06d8d;
73
- }
74
-
75
66
  &__close {
76
67
  position: relative;
77
68
  opacity: 0.6;
@@ -142,3 +133,4 @@
142
133
  visibility: visible;
143
134
  pointer-events: all;
144
135
  }
136
+
@@ -2,7 +2,7 @@
2
2
  display: flex;
3
3
  color: #1e1e2d;
4
4
  font-size: 13px;
5
- margin-top: 5px;
5
+ margin-bottom: 5px;
6
6
  align-items: center;
7
7
 
8
8
  &_bold {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import cn from 'classnames';
3
3
  import Label from '../../Atomic/FormElements/Label/Label';
4
+ import './FormElement.scss';
4
5
 
5
6
  const RC = 'form-element';
6
7
 
@@ -0,0 +1,8 @@
1
+ .form-element__error {
2
+ margin-top: 2px;
3
+ margin-left: 1px;
4
+ position: absolute;
5
+ display: block;
6
+ font-size: 10px;
7
+ color: #f06d8d;
8
+ }