intelicoreact 0.0.42 → 0.0.46

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),
@@ -159,14 +156,8 @@ var Dropdown = function Dropdown(_ref) {
159
156
  return /*#__PURE__*/_react.default.createElement("div", {
160
157
  className: (0, _classnames.default)(RC, className),
161
158
  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"),
159
+ }, /*#__PURE__*/_react.default.createElement("button", {
160
+ className: "".concat(RC, "__trigger input__wrap ").concat(!value ? 'placeholder' : '', " ").concat(error ? 'error' : ''),
170
161
  onClick: function onClick() {
171
162
  return setIsOpen(!isOpen);
172
163
  }
@@ -177,7 +168,9 @@ var Dropdown = function Dropdown(_ref) {
177
168
  return onSearchHandler(e.target.value);
178
169
  },
179
170
  placeholder: placeholder
180
- }) : selectedLabel || placeholder, /*#__PURE__*/_react.default.createElement("span", {
171
+ }) : /*#__PURE__*/_react.default.createElement("span", {
172
+ className: "text"
173
+ }, selectedLabel || placeholder), /*#__PURE__*/_react.default.createElement("span", {
181
174
  className: (0, _classnames.default)("".concat(RC, "__arrow"), (0, _defineProperty2.default)({}, "".concat(RC, "__arrow_active"), isOpen))
182
175
  }, 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
176
  className: "".concat(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%;
@@ -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,7 +62,6 @@ 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',
@@ -94,5 +107,6 @@ DropdownTemplate.args = {
94
107
  label: 'Group 23',
95
108
  value: 'group23'
96
109
  }]
97
- }]
110
+ }],
111
+ error: ''
98
112
  };
@@ -48,7 +48,8 @@ var Input = function Input(_ref) {
48
48
  onFocus = _ref.onFocus,
49
49
  onKeyUp = _ref.onKeyUp,
50
50
  mask = _ref.mask,
51
- error = _ref.error;
51
+ error = _ref.error,
52
+ icon = _ref.icon;
52
53
 
53
54
  // STATES
54
55
  var _useState = (0, _react.useState)(false),
@@ -98,7 +99,7 @@ var Input = function Input(_ref) {
98
99
  if (isEditing) inputRef.current.focus();
99
100
  }, [isEditing, isFocused]);
100
101
  var uniProps = {
101
- className: "input-classic ".concat(className),
102
+ className: "input ".concat(className),
102
103
  placeholder: placeholder,
103
104
  value: value || '',
104
105
  disabled: disabled,
@@ -122,28 +123,28 @@ var Input = function Input(_ref) {
122
123
  ref: inputRef,
123
124
  type: isNumeric ? 'number' : type
124
125
  })), isNumeric && /*#__PURE__*/_react.default.createElement("div", {
125
- className: "input-classic__nums"
126
+ className: "input__nums"
126
127
  }, /*#__PURE__*/_react.default.createElement("button", {
127
128
  onClick: function onClick() {
128
129
  return handle.change(value - numStep);
129
130
  },
130
- className: (0, _classnames.default)("input-classic__num-btn", {
131
+ className: (0, _classnames.default)("input__num-btn", {
131
132
  disabled: value <= min
132
133
  })
133
134
  }, /*#__PURE__*/_react.default.createElement(_reactFeather.Minus, null)), /*#__PURE__*/_react.default.createElement("button", {
134
135
  onClick: function onClick() {
135
136
  return handle.change(+value + +numStep);
136
137
  },
137
- className: (0, _classnames.default)("input-classic__num-btn", {
138
+ className: (0, _classnames.default)("input__num-btn", {
138
139
  disabled: value >= max
139
140
  })
140
141
  }, /*#__PURE__*/_react.default.createElement(_reactFeather.Plus, null))));
141
142
  }
142
143
 
143
144
  return /*#__PURE__*/_react.default.createElement("div", {
144
- className: (0, _classnames.default)("input-classic__wrap", (0, _defineProperty2.default)({}, "input-classic__wrap_focus", isFocused), (0, _defineProperty2.default)({}, "input-classic__wrap_error", error), (0, _defineProperty2.default)({}, "input-classic__wrap_disabled", disabled))
145
- }, renderInput(), withDelete && !isNumeric && /*#__PURE__*/_react.default.createElement("span", {
146
- className: (0, _classnames.default)("input-classic__close", {
145
+ className: (0, _classnames.default)("input__wrap", (0, _defineProperty2.default)({}, "input__wrap_focus", isFocused), (0, _defineProperty2.default)({}, "input__wrap_error", error), (0, _defineProperty2.default)({}, "input__wrap_disabled", disabled))
146
+ }, renderInput(), icon, withDelete && !isNumeric && /*#__PURE__*/_react.default.createElement("span", {
147
+ className: (0, _classnames.default)("input__close", {
147
148
  hidden: !value
148
149
  }),
149
150
  onClick: handle.toggleEdit
@@ -1,4 +1,4 @@
1
- .input-classic {
1
+ .input {
2
2
  position: relative;
3
3
  word-break: break-all;
4
4
  border: none;
@@ -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;
@@ -138,7 +129,8 @@
138
129
  }
139
130
  }
140
131
 
141
- .input-classic__wrap:hover .input-classic__close {
132
+ .input__wrap:hover .input__close {
142
133
  visibility: visible;
143
134
  pointer-events: all;
144
135
  }
136
+
@@ -15,6 +15,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
15
15
 
16
16
  var _react = _interopRequireWildcard(require("react"));
17
17
 
18
+ var _reactFeather = require("react-feather");
19
+
18
20
  var _Input = _interopRequireDefault(require("./Input"));
19
21
 
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -57,6 +59,9 @@ var _default = {
57
59
  options: ['text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range']
58
60
  }
59
61
  },
62
+ icon: {
63
+ description: 'JSX'
64
+ },
60
65
  value: {
61
66
  description: '(* - required prop)'
62
67
  },
@@ -103,5 +108,6 @@ InputTemplate.args = {
103
108
  min: '0',
104
109
  max: '5',
105
110
  placeholder: 'Placeholder',
106
- mask: ''
111
+ mask: '',
112
+ icon: /*#__PURE__*/_react.default.createElement(_reactFeather.User, null)
107
113
  };
@@ -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,7 +13,9 @@ var _classnames = _interopRequireDefault(require("classnames"));
13
13
 
14
14
  var _Label = _interopRequireDefault(require("../../Atomic/FormElements/Label/Label"));
15
15
 
16
- var RC = 'input-classic';
16
+ require("./FormElement.scss");
17
+
18
+ var RC = 'form-element';
17
19
 
18
20
  var FormElement = function FormElement(_ref) {
19
21
  var label = _ref.label,
@@ -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.42",
3
+ "version": "0.0.46",
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);
@@ -75,8 +75,7 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
75
75
 
76
76
  return (
77
77
  <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)}>
78
+ <button className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`} onClick={() => setIsOpen(!isOpen)}>
80
79
  {isSearchable ? (
81
80
  <input
82
81
  className={`${RC}__input`}
@@ -85,7 +84,7 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
85
84
  placeholder={placeholder}
86
85
  />
87
86
  ) : (
88
- selectedLabel || placeholder
87
+ <span className="text">{selectedLabel || placeholder}</span>
89
88
  )}
90
89
  <span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })}>{isOpen ? <ChevronUp /> : <ChevronDown />}</span>
91
90
  </button>
@@ -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,7 +30,6 @@ 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
35
  { label: 'Dropdown1', value: 'drop1' },
@@ -46,5 +54,6 @@ DropdownTemplate.args = {
46
54
  { label: 'Group 23', value: 'group23' }
47
55
  ]
48
56
  }
49
- ]
57
+ ],
58
+ error: ''
50
59
  };
@@ -21,7 +21,8 @@ const Input = ({
21
21
  onFocus,
22
22
  onKeyUp,
23
23
  mask,
24
- error
24
+ error,
25
+ icon,
25
26
  }) => {
26
27
  // STATES
27
28
  const [isFocused, setIsFocused] = useState(false);
@@ -60,7 +61,7 @@ const Input = ({
60
61
  }, [isEditing, isFocused]);
61
62
 
62
63
  const uniProps = {
63
- className: `input-classic ${className}`,
64
+ className: `input ${className}`,
64
65
  placeholder,
65
66
  value: value || '',
66
67
  disabled,
@@ -81,11 +82,11 @@ const Input = ({
81
82
  <>
82
83
  <input {...uniProps} ref={inputRef} type={isNumeric ? 'number' : type} />
83
84
  {isNumeric && (
84
- <div className="input-classic__nums">
85
- <button onClick={() => handle.change(value - numStep)} className={cn(`input-classic__num-btn`, { disabled: value <= min })}>
85
+ <div className="input__nums">
86
+ <button onClick={() => handle.change(value - numStep)} className={cn(`input__num-btn`, { disabled: value <= min })}>
86
87
  <Minus />
87
88
  </button>
88
- <button onClick={() => handle.change(+value + +numStep)} className={cn(`input-classic__num-btn`, { disabled: value >= max })}>
89
+ <button onClick={() => handle.change(+value + +numStep)} className={cn(`input__num-btn`, { disabled: value >= max })}>
89
90
  <Plus />
90
91
  </button>
91
92
  </div>
@@ -97,15 +98,15 @@ const Input = ({
97
98
  return (
98
99
  <div
99
100
  className={cn(
100
- `input-classic__wrap`,
101
- { [`input-classic__wrap_focus`]: isFocused },
102
- { [`input-classic__wrap_error`]: error },
103
- { [`input-classic__wrap_disabled`]: disabled }
101
+ `input__wrap`,
102
+ { [`input__wrap_focus`]: isFocused },
103
+ { [`input__wrap_error`]: error },
104
+ { [`input__wrap_disabled`]: disabled }
104
105
  )}
105
106
  >
106
107
  {renderInput()}
107
-
108
- {withDelete && !isNumeric && <span className={cn(`input-classic__close`, { hidden: !value })} onClick={handle.toggleEdit} />}
108
+ {icon}
109
+ {withDelete && !isNumeric && <span className={cn(`input__close`, { hidden: !value })} onClick={handle.toggleEdit} />}
109
110
  </div>
110
111
  );
111
112
  };
@@ -1,4 +1,4 @@
1
- .input-classic {
1
+ .input {
2
2
  position: relative;
3
3
  word-break: break-all;
4
4
  border: none;
@@ -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;
@@ -138,7 +129,8 @@
138
129
  }
139
130
  }
140
131
 
141
- .input-classic__wrap:hover .input-classic__close {
132
+ .input__wrap:hover .input__close {
142
133
  visibility: visible;
143
134
  pointer-events: all;
144
135
  }
136
+
@@ -1,4 +1,5 @@
1
1
  import React, { useState } from 'react';
2
+ import {User} from 'react-feather';
2
3
  import Input from './Input';
3
4
 
4
5
  global.lng = 'en';
@@ -38,6 +39,7 @@ export default {
38
39
  options: ['text', 'number', 'password', 'color', 'date', 'datetime-local', 'month', 'time', 'email', 'range']
39
40
  }
40
41
  },
42
+ icon: { description: 'JSX' },
41
43
  value: { description: '(* - required prop)' },
42
44
  className: { description: 'string' },
43
45
  mask: { description: 'string: force input to masked https://www.npmjs.com/package/react-input-mask' },
@@ -64,5 +66,6 @@ InputTemplate.args = {
64
66
  min: '0',
65
67
  max: '5',
66
68
  placeholder: 'Placeholder',
67
- mask: ''
69
+ mask: '',
70
+ icon: <User />
68
71
  };
@@ -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,8 +1,9 @@
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
- const RC = 'input-classic';
6
+ const RC = 'form-element';
6
7
 
7
8
  const FormElement = ({ label, required, children, error, className, hint }) => {
8
9
  return (
@@ -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
+ }