intelicoreact 0.0.4 → 0.0.8
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/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +6 -2
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +2 -1
- package/dist/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +64 -32
- package/dist/Atomic/FormElements/Dropdown/Dropdown.scss +26 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.stories.js +40 -9
- package/dist/Atomic/FormElements/Input/Input.js +141 -97
- package/dist/Atomic/FormElements/Input/Input.scss +18 -15
- package/dist/Atomic/FormElements/Input/Input.stories.js +46 -29
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +89 -0
- package/dist/Atomic/FormElements/{Calendar/Calendar.stories.js → InputCalendar/InputCalendar.stories.js} +19 -20
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +234 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.scss +626 -0
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +91 -0
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +491 -0
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +156 -0
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +46 -0
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +249 -0
- package/dist/Atomic/FormElements/Label/Label.js +3 -10
- package/dist/Atomic/FormElements/Label/Label.scss +2 -0
- package/dist/Atomic/FormElements/Label/Label.stories.js +5 -4
- package/dist/Atomic/FormElements/Modal/Modal.stories.js +64 -18
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +254 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
- package/dist/Atomic/FormElements/NumericInput/NumericInput.stories.js +121 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +167 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +81 -0
- package/dist/Atomic/FormElements/Table/Table.scss +1 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/dist/Atomic/MainMenu/MainMenu.scss +2 -2
- package/dist/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/dist/Atomic/UI/Arrow/Arrow.js +80 -0
- package/dist/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/dist/Atomic/UI/Arrow/Arrow.stories.js +46 -0
- package/dist/Atomic/UI/Button/Button.js +4 -2
- package/dist/Atomic/UI/Button/Button.scss +26 -0
- package/dist/Atomic/UI/Button/Button.stories.js +2 -2
- package/dist/Atomic/UI/Calendar/Calendar.js +146 -0
- package/dist/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/dist/Atomic/UI/Calendar/Calendar.stories.js +38 -0
- package/dist/Atomic/UI/Price/Price.js +1 -0
- package/dist/Atomic/UI/Status/Status.scss +1 -1
- package/dist/Constants/index.constants.js +8 -0
- package/dist/Functions/inputExecutor.js +58 -0
- package/dist/Functions/useClickOutside.js +25 -0
- package/dist/Functions/utils.js +10 -2
- package/dist/Molecular/Datepicker/Datepicker.js +451 -0
- package/dist/Molecular/Datepicker/Datepicker.scss +8 -0
- package/dist/Molecular/Datepicker/Datepicker.stories.js +44 -0
- package/dist/Molecular/Datepicker/components/Calendar.js +156 -0
- package/dist/Molecular/FormElements/FormElement.js +40 -0
- package/dist/Molecular/FormElements/FormElement.scss +8 -0
- package/dist/Molecular/FormElements/FormElement.stories.js +73 -0
- package/dist/scss/_vars.scss +3 -1
- package/dist/scss/main.scss +3 -3
- package/package.json +9 -4
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.js +12 -2
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.scss +91 -60
- package/src/Atomic/FormElements/CheckboxInput/CheckboxInput.stories.js +4 -3
- package/src/Atomic/FormElements/DateTime/DateTime.stories.js +1 -1
- package/src/Atomic/FormElements/Dropdown/Dropdown.js +57 -19
- package/src/Atomic/FormElements/Dropdown/Dropdown.scss +26 -3
- package/src/Atomic/FormElements/Dropdown/Dropdown.stories.js +37 -15
- package/src/Atomic/FormElements/Input/Input.js +136 -79
- package/src/Atomic/FormElements/Input/Input.scss +18 -15
- package/src/Atomic/FormElements/Input/Input.stories.js +48 -31
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.js +43 -0
- package/src/Atomic/FormElements/InputCalendar/InputCalendar.stories.js +27 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.js +214 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.scss +626 -0
- package/src/Atomic/FormElements/InputDateRange/InputDateRange.stories.js +61 -0
- package/src/Atomic/FormElements/InputDateRange/components/Datepicker.js +412 -0
- package/src/Atomic/FormElements/InputDateRange/components/OpenedPart.js +114 -0
- package/src/Atomic/FormElements/InputDateRange/components/SelectItem.js +24 -0
- package/src/Atomic/FormElements/InputDateRange/dependencies.js +161 -0
- package/src/Atomic/FormElements/Label/Label.js +3 -4
- package/src/Atomic/FormElements/Label/Label.scss +2 -0
- package/src/Atomic/FormElements/Label/Label.stories.js +5 -4
- package/src/Atomic/FormElements/Modal/Modal.stories.js +60 -15
- package/src/Atomic/FormElements/NumericInput/NumericInput.js +220 -0
- package/src/Atomic/FormElements/NumericInput/NumericInput.scss +135 -0
- package/src/Atomic/FormElements/NumericInput/NumericInput.stories.js +94 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.js +146 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.scss +101 -0
- package/src/Atomic/FormElements/RangeCalendar/RangeCalendar.stories.js +54 -0
- package/src/Atomic/FormElements/Table/Table.scss +1 -1
- package/src/Atomic/FormElements/Textarea/Textarea.scss +1 -1
- package/src/Atomic/MainMenu/MainMenu.scss +2 -2
- package/src/Atomic/UI/Accordion/Accordion.scss +2 -2
- package/src/Atomic/UI/Arrow/Arrow.js +41 -0
- package/src/Atomic/UI/Arrow/Arrow.scss +19 -0
- package/src/Atomic/UI/Arrow/Arrow.stories.js +32 -0
- package/src/Atomic/UI/Button/Button.js +3 -3
- package/src/Atomic/UI/Button/Button.scss +26 -0
- package/src/Atomic/UI/Button/Button.stories.js +4 -3
- package/src/Atomic/{FormElements → UI}/Calendar/Calendar.js +26 -23
- package/src/Atomic/UI/Calendar/Calendar.scss +544 -0
- package/src/Atomic/UI/Calendar/Calendar.stories.js +24 -0
- package/src/Atomic/UI/Price/Price.js +1 -0
- package/src/Atomic/UI/Status/Status.scss +1 -1
- package/src/Constants/index.constants.js +41 -0
- package/src/Functions/inputExecutor.js +62 -0
- package/src/Functions/useClickOutside.js +15 -0
- package/src/Functions/utils.js +10 -1
- package/src/Molecular/Datepicker/Datepicker.js +346 -0
- package/src/Molecular/Datepicker/Datepicker.scss +8 -0
- package/src/Molecular/Datepicker/Datepicker.stories.js +27 -0
- package/src/Molecular/Datepicker/components/Calendar.js +118 -0
- package/src/Molecular/FormElements/FormElement.js +18 -0
- package/src/Molecular/FormElements/FormElement.scss +8 -0
- package/src/Molecular/FormElements/FormElement.stories.js +59 -0
- package/src/scss/_vars.scss +3 -1
- package/src/scss/main.scss +3 -3
- package/dist/Atomic/FormElements/Calendar/Calendar.js +0 -127
- package/dist/Atomic/FormElements/Calendar/Calendar.scss +0 -498
- package/dist/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/dist/scss/anme/_anme-elements.scss +0 -269
- package/dist/scss/anme/_anme-grid.scss +0 -111
- package/dist/scss/anme/_anme-justify.scss +0 -111
- package/dist/scss/anme/_anme-mixins-media.scss +0 -116
- package/dist/scss/anme/_anme-mixins.scss +0 -166
- package/dist/scss/anme/_anme-normalize.scss +0 -8
- package/dist/scss/anme/_anme-overall.scss +0 -34
- package/dist/scss/anme/_anme-padding-margins.scss +0 -419
- package/dist/scss/anme/_anme-table.scss +0 -81
- package/dist/scss/anme/_anme-theme.scss +0 -275
- package/dist/scss/anme/_anme-vars.scss +0 -91
- package/dist/scss/anme/_code-styling.scss +0 -23
- package/dist/scss/anme/styles.scss +0 -12
- package/src/Atomic/FormElements/Calendar/Calendar.scss +0 -498
- package/src/Atomic/FormElements/Calendar/Calendar.stories.js +0 -26
- package/src/scss/anme/_anme-bootstrap-grid.scss +0 -748
- package/src/scss/anme/_anme-elements.scss +0 -269
- package/src/scss/anme/_anme-grid.scss +0 -111
- package/src/scss/anme/_anme-justify.scss +0 -111
- package/src/scss/anme/_anme-mixins-media.scss +0 -116
- package/src/scss/anme/_anme-mixins.scss +0 -166
- package/src/scss/anme/_anme-normalize.scss +0 -8
- package/src/scss/anme/_anme-overall.scss +0 -34
- package/src/scss/anme/_anme-padding-margins.scss +0 -419
- package/src/scss/anme/_anme-table.scss +0 -81
- package/src/scss/anme/_anme-theme.scss +0 -275
- package/src/scss/anme/_anme-vars.scss +0 -91
- package/src/scss/anme/_code-styling.scss +0 -23
- package/src/scss/anme/styles.scss +0 -12
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _Label = _interopRequireDefault(require("../../Atomic/FormElements/Label/Label"));
|
|
15
|
+
|
|
16
|
+
require("./FormElement.scss");
|
|
17
|
+
|
|
18
|
+
var RC = 'form-element';
|
|
19
|
+
|
|
20
|
+
var FormElement = function FormElement(_ref) {
|
|
21
|
+
var label = _ref.label,
|
|
22
|
+
required = _ref.required,
|
|
23
|
+
children = _ref.children,
|
|
24
|
+
error = _ref.error,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
hint = _ref.hint;
|
|
27
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
28
|
+
className: (0, _classnames.default)(className, RC)
|
|
29
|
+
}, label && /*#__PURE__*/_react.default.createElement(_Label.default, {
|
|
30
|
+
className: "".concat(RC, "__label"),
|
|
31
|
+
label: label,
|
|
32
|
+
hint: hint,
|
|
33
|
+
isRequired: required
|
|
34
|
+
}), children, error && /*#__PURE__*/_react.default.createElement("span", {
|
|
35
|
+
className: "".concat(RC, "__error")
|
|
36
|
+
}, error));
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
var _default = FormElement;
|
|
40
|
+
exports.default = _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.InputTemplate = exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _Input = _interopRequireDefault(require("../../Atomic/FormElements/Input/Input"));
|
|
15
|
+
|
|
16
|
+
var _FormElement = _interopRequireDefault(require("./FormElement"));
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
global.lng = 'en';
|
|
23
|
+
var _default = {
|
|
24
|
+
title: 'Form Elements/Form Element',
|
|
25
|
+
component: _FormElement.default,
|
|
26
|
+
argTypes: {
|
|
27
|
+
label: {
|
|
28
|
+
description: 'string/JSX'
|
|
29
|
+
},
|
|
30
|
+
children: {
|
|
31
|
+
description: 'JSX'
|
|
32
|
+
},
|
|
33
|
+
error: {
|
|
34
|
+
description: 'string - print error if is errored'
|
|
35
|
+
},
|
|
36
|
+
required: {
|
|
37
|
+
description: 'boolean'
|
|
38
|
+
},
|
|
39
|
+
className: {
|
|
40
|
+
description: 'string'
|
|
41
|
+
},
|
|
42
|
+
hint: {
|
|
43
|
+
description: 'object {text: string, hintSide: bottom/right',
|
|
44
|
+
control: {
|
|
45
|
+
type: 'object'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.default = _default;
|
|
51
|
+
|
|
52
|
+
var Template = function Template(args) {
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_FormElement.default, args, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
54
|
+
error: args.error
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var InputTemplate = Template.bind({});
|
|
59
|
+
exports.InputTemplate = InputTemplate;
|
|
60
|
+
InputTemplate.args = {
|
|
61
|
+
label: 'Text label',
|
|
62
|
+
error: 'error',
|
|
63
|
+
required: true,
|
|
64
|
+
hint: {
|
|
65
|
+
text: 'hint',
|
|
66
|
+
hintSide: 'bottom'
|
|
67
|
+
},
|
|
68
|
+
numStep: 1,
|
|
69
|
+
min: '0',
|
|
70
|
+
max: '5',
|
|
71
|
+
placeholder: 'Placeholder',
|
|
72
|
+
mask: ''
|
|
73
|
+
};
|
package/dist/scss/_vars.scss
CHANGED
package/dist/scss/main.scss
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intelicoreact",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,14 +10,19 @@
|
|
|
10
10
|
"author": "Andrey Isakov",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"moment": "^2.29.1",
|
|
14
|
+
"moment-timezone": "^0.5.34",
|
|
15
|
+
"react": "^17.0.2",
|
|
13
16
|
"react-feather": "^2.0.9",
|
|
14
|
-
"
|
|
17
|
+
"react-input-mask": "^2.0.4",
|
|
18
|
+
"classnames": "^2.3.1"
|
|
15
19
|
},
|
|
16
20
|
"devDependencies": {
|
|
17
21
|
"@babel/cli": "^7.15.7",
|
|
18
22
|
"@babel/core": "^7.15.5",
|
|
19
|
-
"@babel/preset-env": "^7.15.6",
|
|
20
23
|
"@babel/polyfill": "^7.12.1",
|
|
21
|
-
"
|
|
24
|
+
"@babel/preset-env": "^7.15.6",
|
|
25
|
+
"anme": "^1.0.0"
|
|
26
|
+
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -3,11 +3,21 @@ import cn from 'classnames';
|
|
|
3
3
|
|
|
4
4
|
import './CheckboxInput.scss';
|
|
5
5
|
|
|
6
|
-
const CheckboxInput = ({ label, id, value, onChange, disabled, className }) => {
|
|
6
|
+
const CheckboxInput = ({ label, id, value, onChange, disabled, className, isStark }) => {
|
|
7
7
|
return (
|
|
8
8
|
<label className={cn('checkbox-input', className, { [`checkbox-input_disabled`]: disabled })} htmlFor={id}>
|
|
9
9
|
<div className={cn(`checkbox-input__input`, { [`checkbox-input__input_checked`]: value })}>
|
|
10
|
-
<input
|
|
10
|
+
<input
|
|
11
|
+
id={id}
|
|
12
|
+
type="checkbox"
|
|
13
|
+
className="checkbox-input__checkbox"
|
|
14
|
+
onChange={(e) => onChange(!value, e)}
|
|
15
|
+
checked={value}
|
|
16
|
+
disabled={disabled}
|
|
17
|
+
ref={(elem) => {
|
|
18
|
+
if (elem) elem.indeterminate = isStark;
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
11
21
|
<span className="checkbox-input__mark" />
|
|
12
22
|
</div>
|
|
13
23
|
{label && <div className="checkbox-input__label">{label}</div>}
|
|
@@ -1,76 +1,107 @@
|
|
|
1
1
|
.checkbox-input {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
cursor: pointer;
|
|
5
|
+
|
|
6
|
+
&_disabled {
|
|
7
|
+
opacity: 0.5;
|
|
8
|
+
pointer-events: none;
|
|
9
|
+
cursor: auto;
|
|
10
|
+
}
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
cursor: auto;
|
|
12
|
+
&:hover {
|
|
13
|
+
.checkbox-input__input {
|
|
14
|
+
background-color: rgba(#6b81dd, 0.2);
|
|
10
15
|
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__input {
|
|
19
|
+
position: relative;
|
|
20
|
+
height: 14px;
|
|
21
|
+
width: 14px;
|
|
22
|
+
min-width: 14px;
|
|
23
|
+
border: 1px solid #9aa0b9;
|
|
24
|
+
border-radius: 2px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
margin-right: 5px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
transition: background-color 0.2s ease;
|
|
29
|
+
background-color: #ffff;
|
|
11
30
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
background-color: rgba(#6b81dd, .2);
|
|
15
|
-
}
|
|
31
|
+
&_checked {
|
|
32
|
+
border-color: #6b81dd;
|
|
16
33
|
}
|
|
17
34
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
min-width: 14px;
|
|
23
|
-
border: 1px solid #9AA0B9;
|
|
24
|
-
border-radius: 2px;
|
|
25
|
-
overflow: hidden;
|
|
26
|
-
margin-right: 5px;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
transition: background-color .2s ease;
|
|
29
|
-
background-color: #ffff;
|
|
35
|
+
.checkbox-input__checkbox:checked ~ .checkbox-input__mark {
|
|
36
|
+
display: block;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
30
39
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
&__checkbox {
|
|
41
|
+
opacity: 0;
|
|
42
|
+
position: absolute;
|
|
43
|
+
height: 0;
|
|
44
|
+
width: 0;
|
|
45
|
+
}
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
&__mark {
|
|
48
|
+
display: none;
|
|
49
|
+
position: absolute;
|
|
50
|
+
width: 14px;
|
|
51
|
+
height: 14px;
|
|
52
|
+
background-color: #6b81dd;
|
|
38
53
|
|
|
54
|
+
&:after {
|
|
55
|
+
content: "";
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: -2px;
|
|
58
|
+
bottom: 0;
|
|
59
|
+
left: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
margin: auto;
|
|
62
|
+
width: 4px;
|
|
63
|
+
height: 8px;
|
|
64
|
+
border: solid white;
|
|
65
|
+
border-radius: 2px;
|
|
66
|
+
border-width: 0 2px 2px 0;
|
|
67
|
+
transform: rotate(45deg);
|
|
39
68
|
}
|
|
69
|
+
}
|
|
40
70
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
width: 0;
|
|
46
|
-
}
|
|
71
|
+
&__label {
|
|
72
|
+
font-size: 13px;
|
|
73
|
+
user-select: none;
|
|
74
|
+
}
|
|
47
75
|
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
input[type="checkbox" i] {
|
|
77
|
+
&:indeterminate {
|
|
78
|
+
display: block;
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
&:after {
|
|
82
|
+
content: "";
|
|
50
83
|
position: absolute;
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
top: 0;
|
|
85
|
+
bottom: 0;
|
|
86
|
+
left: 0;
|
|
87
|
+
right: 0;
|
|
88
|
+
margin: auto;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100%;
|
|
53
91
|
background-color: #6b81dd;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
border-width: 0 2px 2px 0;
|
|
68
|
-
transform: rotate(45deg);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
&__label{
|
|
73
|
-
font-size: 13px;
|
|
74
|
-
user-select: none;
|
|
92
|
+
}
|
|
93
|
+
&:before {
|
|
94
|
+
content: "";
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 50%;
|
|
97
|
+
left: 50%;
|
|
98
|
+
transform: translate(-50%, -50%);
|
|
99
|
+
width: 65%;
|
|
100
|
+
border: solid white;
|
|
101
|
+
border-radius: 2px;
|
|
102
|
+
border-width: 0 2px 2px 0;
|
|
103
|
+
z-index: 1;
|
|
104
|
+
}
|
|
75
105
|
}
|
|
106
|
+
}
|
|
76
107
|
}
|
|
@@ -5,10 +5,10 @@ global.lng = 'en';
|
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Form Elements/CheckboxInput',
|
|
8
|
-
component: CheckboxInput
|
|
8
|
+
component: CheckboxInput,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const Template = args => {
|
|
11
|
+
const Template = (args) => {
|
|
12
12
|
const { value: argsValue } = args;
|
|
13
13
|
const [value, setValue] = useState(argsValue);
|
|
14
14
|
|
|
@@ -21,5 +21,6 @@ Checkbox.args = {
|
|
|
21
21
|
label: 'Test label',
|
|
22
22
|
value: true,
|
|
23
23
|
disabled: false,
|
|
24
|
-
forced: false
|
|
24
|
+
forced: false,
|
|
25
|
+
isStark: true,
|
|
25
26
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import { Check, ChevronDown, ChevronUp } from 'react-feather';
|
|
4
|
-
import Label from '../Label/Label';
|
|
5
4
|
|
|
6
5
|
import './Dropdown.scss';
|
|
7
6
|
|
|
8
7
|
const RC = 'dropdown';
|
|
9
8
|
|
|
10
|
-
const Dropdown = ({ options, value, onChange, placeholder, className,
|
|
9
|
+
const Dropdown = ({ options = [], value, error, onChange, placeholder, className, isSearchable, entity }) => {
|
|
11
10
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
11
|
const [searchValue, setSearchValue] = useState('');
|
|
13
12
|
const dropdownRef = useRef(null);
|
|
14
|
-
|
|
13
|
+
if (!options) return null;
|
|
15
14
|
const filteredGroups = options
|
|
16
15
|
.filter(item => item.items?.length)
|
|
17
16
|
.map(item => ({ ...item, items: item.items.filter(el => el?.label?.toLowerCase().includes(searchValue?.toLowerCase() || '')) }))
|
|
@@ -23,6 +22,38 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
|
|
|
23
22
|
|
|
24
23
|
const filteredOptions = [...filteredItems, ...filteredGroups];
|
|
25
24
|
|
|
25
|
+
const modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
26
|
+
const onChangeHandler = item => {
|
|
27
|
+
setIsOpen(false);
|
|
28
|
+
setSearchValue(null);
|
|
29
|
+
onChange(item.value);
|
|
30
|
+
};
|
|
31
|
+
// decorator
|
|
32
|
+
const getDepends = getDependsTrigger => {
|
|
33
|
+
const newOnChange = e => {
|
|
34
|
+
if (e.value === 'open_modal') {
|
|
35
|
+
onChange('open_modal');
|
|
36
|
+
} else {
|
|
37
|
+
onChangeHandler(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// add pseudo option
|
|
42
|
+
const newOptions = [
|
|
43
|
+
{
|
|
44
|
+
label: `New ${entity}`,
|
|
45
|
+
value: 'open_modal',
|
|
46
|
+
className: 'dropdown__list-item--modal'
|
|
47
|
+
},
|
|
48
|
+
...filteredOptions
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
onChange: changeItem => (getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem)),
|
|
53
|
+
options: getDependsTrigger ? newOptions : options
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
26
57
|
const handleClickOutside = event => {
|
|
27
58
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
28
59
|
setIsOpen(false);
|
|
@@ -30,12 +61,6 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
|
|
|
30
61
|
}
|
|
31
62
|
};
|
|
32
63
|
|
|
33
|
-
const onChangeHandler = item => {
|
|
34
|
-
setIsOpen(false);
|
|
35
|
-
setSearchValue(null);
|
|
36
|
-
onChange(item.value);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
64
|
const onSearchHandler = name => {
|
|
40
65
|
setSearchValue(name);
|
|
41
66
|
};
|
|
@@ -43,24 +68,27 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
|
|
|
43
68
|
const hightlightedText = text =>
|
|
44
69
|
searchValue ? text?.replace(new RegExp(searchValue, 'i'), match => `<span class="bg--yellow">${match}</span>`) : text;
|
|
45
70
|
|
|
71
|
+
const depend = getDepends(modalBtnTrigger);
|
|
72
|
+
|
|
46
73
|
const getMarkupForElement = item =>
|
|
47
74
|
item.label.toLowerCase().includes(searchValue?.toLowerCase() || '') ? (
|
|
48
75
|
<button
|
|
49
76
|
key={item.value}
|
|
50
|
-
onClick={() =>
|
|
77
|
+
onClick={() => depend.onChange(item)}
|
|
51
78
|
className={cn(`${RC}__list-item`, { [`${RC}__list-item_active`]: item.value === value }, { [`${RC}__list-item_disabled`]: item.disabled })}
|
|
52
79
|
>
|
|
53
80
|
<span className={cn(`${RC}__active-icon`, { [`${RC}__active-icon_active`]: item.value === value })}>
|
|
54
81
|
<Check />
|
|
55
82
|
</span>
|
|
56
|
-
<div dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
|
|
83
|
+
<div className={item.className || ''} dangerouslySetInnerHTML={{ __html: hightlightedText(item.label) }} />
|
|
57
84
|
</button>
|
|
58
85
|
) : null;
|
|
59
86
|
|
|
60
87
|
useEffect(() => {
|
|
88
|
+
if (!value) setSearchValue(null);
|
|
61
89
|
document.addEventListener('click', handleClickOutside, true);
|
|
62
90
|
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
63
|
-
});
|
|
91
|
+
}, [value]);
|
|
64
92
|
|
|
65
93
|
const filteredOptionList = filteredOption =>
|
|
66
94
|
filteredOption.items?.length > 0 ? (
|
|
@@ -75,23 +103,33 @@ const Dropdown = ({ options, value, onChange, placeholder, className, label, isL
|
|
|
75
103
|
|
|
76
104
|
return (
|
|
77
105
|
<div className={cn(RC, className)} ref={dropdownRef}>
|
|
78
|
-
|
|
79
|
-
|
|
106
|
+
<button
|
|
107
|
+
className={`${RC}__trigger input__wrap ${!value ? 'placeholder' : ''} ${error ? 'error' : ''}`}
|
|
108
|
+
onClick={() => (!isSearchable ? setIsOpen(!isOpen) : null)}
|
|
109
|
+
>
|
|
80
110
|
{isSearchable ? (
|
|
81
111
|
<input
|
|
82
112
|
className={`${RC}__input`}
|
|
83
|
-
value={searchValue
|
|
84
|
-
onChange={e =>
|
|
113
|
+
value={searchValue || filteredOptions.find(el => el.value === value)?.label || ''}
|
|
114
|
+
onChange={e => {
|
|
115
|
+
onSearchHandler(e.target.value);
|
|
116
|
+
}}
|
|
85
117
|
placeholder={placeholder}
|
|
118
|
+
onFocus={e => {
|
|
119
|
+
e.target.select();
|
|
120
|
+
setIsOpen(true);
|
|
121
|
+
}}
|
|
86
122
|
/>
|
|
87
123
|
) : (
|
|
88
|
-
selectedLabel || placeholder
|
|
124
|
+
<span className="text">{selectedLabel || placeholder}</span>
|
|
89
125
|
)}
|
|
90
|
-
<span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })}
|
|
126
|
+
<span className={cn(`${RC}__arrow`, { [`${RC}__arrow_active`]: isOpen })} onClick={() => setIsOpen(!isOpen)}>
|
|
127
|
+
{isOpen ? <ChevronUp /> : <ChevronDown />}
|
|
128
|
+
</span>
|
|
91
129
|
</button>
|
|
92
130
|
{isOpen && filteredOptions.length > 0 && (
|
|
93
131
|
<div className={`${RC}__list`}>
|
|
94
|
-
{
|
|
132
|
+
{depend.options.map(filteredOption =>
|
|
95
133
|
filteredOption.items?.length ? filteredOptionList(filteredOption) : getMarkupForElement(filteredOption)
|
|
96
134
|
)}
|
|
97
135
|
</div>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
flex-direction: column;
|
|
6
6
|
position: relative;
|
|
7
7
|
width: 100%;
|
|
8
|
+
border-radius: 7px;
|
|
8
9
|
|
|
9
10
|
&__trigger {
|
|
10
11
|
background: #ffffff;
|
|
@@ -13,7 +14,6 @@
|
|
|
13
14
|
border-radius: 3px;
|
|
14
15
|
width: 100%;
|
|
15
16
|
height: 28px;
|
|
16
|
-
display: flex;
|
|
17
17
|
align-items: center;
|
|
18
18
|
cursor: pointer;
|
|
19
19
|
padding-left: 9px;
|
|
@@ -26,9 +26,12 @@
|
|
|
26
26
|
position: relative;
|
|
27
27
|
text-align: left;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
&.error {
|
|
30
30
|
border-color: $color--secondary;
|
|
31
31
|
}
|
|
32
|
+
&.placeholder .text {
|
|
33
|
+
opacity: 0.7;
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
&__input {
|
|
@@ -71,6 +74,8 @@
|
|
|
71
74
|
display: flex;
|
|
72
75
|
align-items: center;
|
|
73
76
|
//justify-content: center;
|
|
77
|
+
border: none;
|
|
78
|
+
background: transparent;
|
|
74
79
|
padding: 0 20px 0 30px;
|
|
75
80
|
position: relative;
|
|
76
81
|
cursor: pointer;
|
|
@@ -81,7 +86,24 @@
|
|
|
81
86
|
width: 100%;
|
|
82
87
|
height: 24px;
|
|
83
88
|
white-space: nowrap;
|
|
84
|
-
|
|
89
|
+
overflow-x: hidden;
|
|
90
|
+
|
|
91
|
+
&--modal {
|
|
92
|
+
color: #1f7499;
|
|
93
|
+
font-size: 14px;
|
|
94
|
+
line-height: 20px;
|
|
95
|
+
letter-spacing: 0.2px;
|
|
96
|
+
position: relative;
|
|
97
|
+
&:after {
|
|
98
|
+
content: "";
|
|
99
|
+
position: absolute;
|
|
100
|
+
bottom: -2px;
|
|
101
|
+
height: 1px;
|
|
102
|
+
width: 300%;
|
|
103
|
+
transform: translateX(-50%);
|
|
104
|
+
background-color: #e8e9ec;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
85
107
|
&:hover,
|
|
86
108
|
&_active {
|
|
87
109
|
background: $color--gray--gentle;
|
|
@@ -101,6 +123,7 @@
|
|
|
101
123
|
display: flex;
|
|
102
124
|
align-items: center;
|
|
103
125
|
width: 16px;
|
|
126
|
+
height: 16px;
|
|
104
127
|
position: absolute;
|
|
105
128
|
right: 4px;
|
|
106
129
|
top: 50%;
|