iguazio.dashboard-react-controls 0.0.4 → 0.0.7
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/components/Backdrop/Backdrop.js +48 -0
- package/dist/components/Backdrop/Backdrop.scss +32 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.js +100 -0
- package/dist/components/ConfirmDialog/confirmDialog.scss +19 -0
- package/dist/components/FormCheckBox/FormCheckBox.js +57 -0
- package/dist/components/FormCheckBox/formCheckBox.scss +33 -0
- package/dist/components/FormInput/FormInput.js +418 -0
- package/dist/components/FormInput/formInput.scss +169 -0
- package/dist/components/FormSelect/FormSelect.js +306 -0
- package/dist/components/FormSelect/FormSelect.test.js +158 -0
- package/dist/components/FormSelect/formSelect.scss +303 -0
- package/dist/components/Modal/Modal.js +116 -0
- package/dist/components/Modal/Modal.scss +121 -0
- package/dist/components/PopUpDialog/PopUpDialog.js +1 -1
- package/dist/components/PopUpDialog/popUpDialog.scss +2 -2
- package/dist/components/Tip/Tip.js +132 -0
- package/dist/components/Tip/Tip.test.js +96 -0
- package/dist/components/Tip/tip.scss +89 -0
- package/dist/components/Wizard/Wizard.js +253 -0
- package/dist/components/Wizard/Wizard.scss +17 -0
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +65 -0
- package/dist/components/Wizard/WizardSteps/WizardSteps.scss +67 -0
- package/dist/components/index.js +56 -0
- package/dist/constants.js +29 -3
- package/dist/elements/OptionsMenu/OptionsMenu.js +64 -0
- package/dist/elements/OptionsMenu/optionsMenu.scss +49 -0
- package/dist/elements/SelectOption/SelectOption.js +95 -0
- package/dist/elements/SelectOption/SelectOption.test.js +99 -0
- package/dist/elements/SelectOption/selectOption.scss +61 -0
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +48 -0
- package/dist/elements/ValidationTemplate/ValidationTemplate.scss +36 -0
- package/dist/hooks/useDetectOutsideClick.js +34 -0
- package/dist/images/checkmark2.svg +3 -0
- package/dist/index.js +5 -1
- package/dist/scss/colors.scss +1 -0
- package/dist/scss/mixins.scss +11 -23
- package/dist/scss/variables.scss +1 -0
- package/dist/types.js +62 -2
- package/dist/utils/validationService.js +269 -0
- package/package.json +7 -4
package/dist/components/index.js
CHANGED
|
@@ -9,6 +9,36 @@ Object.defineProperty(exports, "Button", {
|
|
|
9
9
|
return _Button.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "ConfirmDialog", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ConfirmDialog.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "FormCheckBox", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _FormCheckBox.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "FormInput", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _FormInput.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "FormSelect", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _FormSelect.default;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "Modal", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _Modal.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
12
42
|
Object.defineProperty(exports, "PopUpDialog", {
|
|
13
43
|
enumerable: true,
|
|
14
44
|
get: function get() {
|
|
@@ -27,21 +57,47 @@ Object.defineProperty(exports, "TextTooltipTemplate", {
|
|
|
27
57
|
return _TextTooltipTemplate.default;
|
|
28
58
|
}
|
|
29
59
|
});
|
|
60
|
+
Object.defineProperty(exports, "Tip", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _Tip.default;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
30
66
|
Object.defineProperty(exports, "Tooltip", {
|
|
31
67
|
enumerable: true,
|
|
32
68
|
get: function get() {
|
|
33
69
|
return _Tooltip.default;
|
|
34
70
|
}
|
|
35
71
|
});
|
|
72
|
+
Object.defineProperty(exports, "Wizard", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _Wizard.default;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
36
78
|
|
|
37
79
|
var _Button = _interopRequireDefault(require("./Button/Button"));
|
|
38
80
|
|
|
81
|
+
var _ConfirmDialog = _interopRequireDefault(require("./ConfirmDialog/ConfirmDialog"));
|
|
82
|
+
|
|
83
|
+
var _FormCheckBox = _interopRequireDefault(require("./FormCheckBox/FormCheckBox"));
|
|
84
|
+
|
|
85
|
+
var _FormInput = _interopRequireDefault(require("./FormInput/FormInput"));
|
|
86
|
+
|
|
87
|
+
var _FormSelect = _interopRequireDefault(require("./FormSelect/FormSelect"));
|
|
88
|
+
|
|
89
|
+
var _Modal = _interopRequireDefault(require("./Modal/Modal"));
|
|
90
|
+
|
|
39
91
|
var _PopUpDialog = _interopRequireDefault(require("./PopUpDialog/PopUpDialog"));
|
|
40
92
|
|
|
41
93
|
var _RoundedIcon = _interopRequireDefault(require("./RoundedIcon/RoundedIcon"));
|
|
42
94
|
|
|
43
95
|
var _TextTooltipTemplate = _interopRequireDefault(require("./TooltipTemplate/TextTooltipTemplate"));
|
|
44
96
|
|
|
97
|
+
var _Tip = _interopRequireDefault(require("./Tip/Tip"));
|
|
98
|
+
|
|
45
99
|
var _Tooltip = _interopRequireDefault(require("./Tooltip/Tooltip"));
|
|
46
100
|
|
|
101
|
+
var _Wizard = _interopRequireDefault(require("./Wizard/Wizard"));
|
|
102
|
+
|
|
47
103
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TERTIARY_BUTTON = exports.SECONDARY_BUTTON = exports.PRIMARY_BUTTON = exports.LABEL_BUTTON = exports.INTERNAL_SERVER_ERROR_STATUS_CODE = exports.FORBIDDEN_ERROR_STATUS_CODE = exports.DANGER_BUTTON = exports.CONFLICT_ERROR_STATUS_CODE = void 0;
|
|
6
|
+
exports.validation = exports.TERTIARY_BUTTON = exports.SECONDARY_BUTTON = exports.PRIMARY_BUTTON = exports.MODAL_SM = exports.MODAL_MD = exports.MODAL_LG = exports.LABEL_BUTTON = exports.INTERNAL_SERVER_ERROR_STATUS_CODE = exports.FORBIDDEN_ERROR_STATUS_CODE = exports.DANGER_BUTTON = exports.CONFLICT_ERROR_STATUS_CODE = void 0;
|
|
7
7
|
|
|
8
8
|
/*=========== BUTTONS =============*/
|
|
9
9
|
var PRIMARY_BUTTON = 'primary';
|
|
@@ -15,12 +15,38 @@ exports.TERTIARY_BUTTON = TERTIARY_BUTTON;
|
|
|
15
15
|
var DANGER_BUTTON = 'danger';
|
|
16
16
|
exports.DANGER_BUTTON = DANGER_BUTTON;
|
|
17
17
|
var LABEL_BUTTON = 'label';
|
|
18
|
-
/*===========
|
|
18
|
+
/*=========== VALITATION =============*/
|
|
19
19
|
|
|
20
20
|
exports.LABEL_BUTTON = LABEL_BUTTON;
|
|
21
|
+
var validation = {
|
|
22
|
+
BEGIN_END_NOT_WITH: 'Must not begin and end with',
|
|
23
|
+
BEGIN_END_WITH: 'Must begin and end with',
|
|
24
|
+
BEGIN_NOT_WITH: 'Must not begin with',
|
|
25
|
+
BEGIN_WITH: 'Must begin with',
|
|
26
|
+
END_NOT_WITH: 'Must not end with',
|
|
27
|
+
END_WITH: 'Must end with',
|
|
28
|
+
MUST_CONTAIN_EXACTLY_ONE: 'Must contain exactly one',
|
|
29
|
+
MUST_HAVE_DOT_AFTER_AT: 'Must have at least one . after @',
|
|
30
|
+
MUST_NOT_BE: 'Must not be',
|
|
31
|
+
NO_CONSECUTIVE_CHARACTER: 'No consecutive characters',
|
|
32
|
+
ONLY_AT_THE_BEGINNING: 'Only at the beginning',
|
|
33
|
+
REQUIRED: 'This field is required',
|
|
34
|
+
VALID_CHARACTERS: 'Valid characters'
|
|
35
|
+
};
|
|
36
|
+
/*=========== STATUS CODES =============*/
|
|
37
|
+
|
|
38
|
+
exports.validation = validation;
|
|
21
39
|
var INTERNAL_SERVER_ERROR_STATUS_CODE = 500;
|
|
22
40
|
exports.INTERNAL_SERVER_ERROR_STATUS_CODE = INTERNAL_SERVER_ERROR_STATUS_CODE;
|
|
23
41
|
var CONFLICT_ERROR_STATUS_CODE = 409;
|
|
24
42
|
exports.CONFLICT_ERROR_STATUS_CODE = CONFLICT_ERROR_STATUS_CODE;
|
|
25
43
|
var FORBIDDEN_ERROR_STATUS_CODE = 403;
|
|
26
|
-
|
|
44
|
+
/*=========== MODAL =============*/
|
|
45
|
+
|
|
46
|
+
exports.FORBIDDEN_ERROR_STATUS_CODE = FORBIDDEN_ERROR_STATUS_CODE;
|
|
47
|
+
var MODAL_SM = 'sm';
|
|
48
|
+
exports.MODAL_SM = MODAL_SM;
|
|
49
|
+
var MODAL_MD = 'md';
|
|
50
|
+
exports.MODAL_MD = MODAL_MD;
|
|
51
|
+
var MODAL_LG = 'lg';
|
|
52
|
+
exports.MODAL_LG = MODAL_LG;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _reactTransitionGroup = require("react-transition-group");
|
|
13
|
+
|
|
14
|
+
var _components = require("../../components");
|
|
15
|
+
|
|
16
|
+
require("./optionsMenu.scss");
|
|
17
|
+
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
var OptionsMenu = function OptionsMenu(_ref) {
|
|
23
|
+
var children = _ref.children,
|
|
24
|
+
parentElement = _ref.parentElement,
|
|
25
|
+
show = _ref.show,
|
|
26
|
+
timeout = _ref.timeout;
|
|
27
|
+
|
|
28
|
+
var _ref2 = parentElement.current ? parentElement.current.getBoundingClientRect() : {},
|
|
29
|
+
dropdownWidth = _ref2.width;
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.CSSTransition, {
|
|
32
|
+
in: show,
|
|
33
|
+
timeout: timeout,
|
|
34
|
+
classNames: "options-menu-transition",
|
|
35
|
+
unmountOnExit: true,
|
|
36
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.PopUpDialog, {
|
|
37
|
+
className: "options-menu",
|
|
38
|
+
customPosition: {
|
|
39
|
+
element: parentElement,
|
|
40
|
+
position: 'bottom-right'
|
|
41
|
+
},
|
|
42
|
+
style: {
|
|
43
|
+
width: "".concat(dropdownWidth, "px")
|
|
44
|
+
},
|
|
45
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
|
|
46
|
+
className: "options-menu__body",
|
|
47
|
+
children: children
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
OptionsMenu.defaultProps = {
|
|
54
|
+
children: [],
|
|
55
|
+
show: false,
|
|
56
|
+
timeout: 300
|
|
57
|
+
};
|
|
58
|
+
OptionsMenu.propTypes = {
|
|
59
|
+
children: _propTypes.default.arrayOf(_propTypes.default.element),
|
|
60
|
+
show: _propTypes.default.bool.isRequired,
|
|
61
|
+
timout: _propTypes.default.number
|
|
62
|
+
};
|
|
63
|
+
var _default = OptionsMenu;
|
|
64
|
+
exports.default = _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@import '../../scss/colors';
|
|
2
|
+
@import '../../scss/shadows';
|
|
3
|
+
@import '../../scss/borders';
|
|
4
|
+
|
|
5
|
+
.options-menu {
|
|
6
|
+
&__body {
|
|
7
|
+
width: 100%;
|
|
8
|
+
max-height: 250px;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
overflow-y: auto;
|
|
12
|
+
color: $mulledWineTwo;
|
|
13
|
+
font-size: 1rem;
|
|
14
|
+
list-style-type: none;
|
|
15
|
+
background-color: $white;
|
|
16
|
+
border: $primaryBorder;
|
|
17
|
+
border-radius: 4px;
|
|
18
|
+
box-shadow: $previewBoxShadow;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pop-up-dialog {
|
|
22
|
+
width: 100%;
|
|
23
|
+
padding: 0;
|
|
24
|
+
|
|
25
|
+
&__header {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&-transition {
|
|
31
|
+
&-enter {
|
|
32
|
+
opacity: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&-enter-active {
|
|
36
|
+
opacity: 1;
|
|
37
|
+
transition: opacity 300ms ease-in-out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&-exit {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&-exit-active {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transition: opacity 300ms ease-in-out;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _components = require("../../components");
|
|
15
|
+
|
|
16
|
+
var _types = require("../../types");
|
|
17
|
+
|
|
18
|
+
var _checkmark = require("../../images/checkmark.svg");
|
|
19
|
+
|
|
20
|
+
require("./selectOption.scss");
|
|
21
|
+
|
|
22
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
var SelectOption = function SelectOption(_ref) {
|
|
27
|
+
var item = _ref.item,
|
|
28
|
+
_onClick = _ref.onClick,
|
|
29
|
+
selectType = _ref.selectType,
|
|
30
|
+
selectedId = _ref.selectedId,
|
|
31
|
+
withSelectedIcon = _ref.withSelectedIcon;
|
|
32
|
+
var selectClassName = (0, _classnames.default)('select__item', item.hidden && 'hidden', item.disabled && 'disabled');
|
|
33
|
+
|
|
34
|
+
if (selectType === 'checkbox') {
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
36
|
+
"data-testid": "select-checkbox",
|
|
37
|
+
className: "select__item",
|
|
38
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.FormCheckBox, {
|
|
39
|
+
item: item,
|
|
40
|
+
selectedId: selectedId,
|
|
41
|
+
onChange: _onClick,
|
|
42
|
+
children: [item.status && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
43
|
+
className: "state-".concat(item.status, "-job status")
|
|
44
|
+
}), item.label]
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
50
|
+
"data-testid": "select-option",
|
|
51
|
+
className: selectClassName,
|
|
52
|
+
onClick: function onClick() {
|
|
53
|
+
!item.disabled && _onClick(item.id);
|
|
54
|
+
},
|
|
55
|
+
children: [item.icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
56
|
+
"data-testid": "select-icon",
|
|
57
|
+
className: "select__icon",
|
|
58
|
+
children: item.icon
|
|
59
|
+
}), item.status && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
60
|
+
className: "state-".concat(item.status, "-job status")
|
|
61
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
62
|
+
className: "data-ellipsis label-row",
|
|
63
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
64
|
+
template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextTooltipTemplate, {
|
|
65
|
+
text: item.label
|
|
66
|
+
}),
|
|
67
|
+
children: item.label
|
|
68
|
+
}), withSelectedIcon && item.id === selectedId && /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkmark.ReactComponent, {
|
|
69
|
+
className: "checkmark"
|
|
70
|
+
})]
|
|
71
|
+
}), item.subLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
72
|
+
className: "sub-label",
|
|
73
|
+
template: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextTooltipTemplate, {
|
|
74
|
+
text: item.subLabel
|
|
75
|
+
}),
|
|
76
|
+
children: item.subLabel
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
SelectOption.defaultProps = {
|
|
82
|
+
onClick: function onClick() {},
|
|
83
|
+
selectType: '',
|
|
84
|
+
withSelectedIcon: false
|
|
85
|
+
};
|
|
86
|
+
SelectOption.propTypes = {
|
|
87
|
+
disabled: _propTypes.default.bool,
|
|
88
|
+
item: _types.SELECT_OPTION.isRequired,
|
|
89
|
+
onClick: _propTypes.default.func,
|
|
90
|
+
selectType: _propTypes.default.string,
|
|
91
|
+
selectedId: _propTypes.default.string,
|
|
92
|
+
withSelectedIcon: _propTypes.default.bool
|
|
93
|
+
};
|
|
94
|
+
var _default = SelectOption;
|
|
95
|
+
exports.default = _default;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _SelectOption = _interopRequireDefault(require("./SelectOption"));
|
|
8
|
+
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
var renderComponent = function renderComponent(props) {
|
|
20
|
+
return (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, _objectSpread({}, props)));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
jest.mock('igz-controls/images/checkbox-unchecked.svg', function () {
|
|
24
|
+
return {
|
|
25
|
+
ReactComponent: 'unchecked-icon'
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
jest.mock('igz-controls/images/checkbox-checked.svg', function () {
|
|
29
|
+
return {
|
|
30
|
+
ReactComponent: 'unchecked-icon'
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
describe('SelectOption component', function () {
|
|
34
|
+
var wrapper;
|
|
35
|
+
beforeEach(function () {
|
|
36
|
+
var props = {
|
|
37
|
+
item: {
|
|
38
|
+
label: 'Test1',
|
|
39
|
+
id: 'test1',
|
|
40
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
41
|
+
children: "icon"
|
|
42
|
+
}),
|
|
43
|
+
subLabel: 'Test1'
|
|
44
|
+
},
|
|
45
|
+
selectType: ''
|
|
46
|
+
};
|
|
47
|
+
wrapper = renderComponent(props);
|
|
48
|
+
});
|
|
49
|
+
afterEach(_react2.cleanup);
|
|
50
|
+
it('renders without crashing', function () {
|
|
51
|
+
expect(wrapper.queryByTestId('select-option')).not.toBeNull();
|
|
52
|
+
});
|
|
53
|
+
it('should display checkbox inside option if props selectType is "checkbox"', function () {
|
|
54
|
+
wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
|
|
55
|
+
item: {
|
|
56
|
+
label: 'Test1',
|
|
57
|
+
id: 'test1'
|
|
58
|
+
},
|
|
59
|
+
selectType: "checkbox",
|
|
60
|
+
selectedId: "test1"
|
|
61
|
+
}));
|
|
62
|
+
expect(wrapper.queryByTestId('select-checkbox')).not.toBeNull();
|
|
63
|
+
});
|
|
64
|
+
it('should display select icon if it exists in the props "item"', function () {
|
|
65
|
+
expect(wrapper.getByTestId('select-icon')).not.toBeNull();
|
|
66
|
+
});
|
|
67
|
+
it('should won\'t call onClick callback if props disable set to "true"', function () {
|
|
68
|
+
var mockCLick = jest.fn();
|
|
69
|
+
wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
|
|
70
|
+
item: {
|
|
71
|
+
label: 'Test1',
|
|
72
|
+
id: 'test1'
|
|
73
|
+
},
|
|
74
|
+
onCLick: mockCLick,
|
|
75
|
+
selectType: "test1",
|
|
76
|
+
disabled: true
|
|
77
|
+
}));
|
|
78
|
+
var selectOption = wrapper.getByTestId('select-option');
|
|
79
|
+
|
|
80
|
+
_react2.fireEvent.click(selectOption);
|
|
81
|
+
|
|
82
|
+
expect(mockCLick).toHaveBeenCalledTimes(0);
|
|
83
|
+
});
|
|
84
|
+
it('should display subLabel if it exists in props item', function () {
|
|
85
|
+
expect(wrapper.queryByTestId('tooltip-wrapper')).not.toBeNull();
|
|
86
|
+
});
|
|
87
|
+
it('should add class "disabled" to SelectOption if props disabled set to "true"', function () {
|
|
88
|
+
wrapper.rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOption.default, {
|
|
89
|
+
item: {
|
|
90
|
+
label: 'Test1',
|
|
91
|
+
id: 'test1'
|
|
92
|
+
},
|
|
93
|
+
selectType: "test1",
|
|
94
|
+
disabled: true
|
|
95
|
+
}));
|
|
96
|
+
var selectOption = wrapper.getByTestId('select-option');
|
|
97
|
+
expect(selectOption.className).toMatch('disabled');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import '../../scss/colors';
|
|
2
|
+
@import '../../scss/mixins';
|
|
3
|
+
|
|
4
|
+
.select {
|
|
5
|
+
&__icon {
|
|
6
|
+
display: flex;
|
|
7
|
+
margin-right: 10px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&__item {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 49px;
|
|
15
|
+
padding: 0 15px;
|
|
16
|
+
|
|
17
|
+
&.hidden {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.checkbox {
|
|
22
|
+
flex: 1;
|
|
23
|
+
height: 100%;
|
|
24
|
+
|
|
25
|
+
svg {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: $alabaster;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.status {
|
|
36
|
+
margin: 0 10px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.all {
|
|
40
|
+
margin: 0;
|
|
41
|
+
|
|
42
|
+
@include statusState(none);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.label-row {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-flow: row nowrap;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.checkmark {
|
|
54
|
+
margin: 0 0 0 10px;
|
|
55
|
+
|
|
56
|
+
path {
|
|
57
|
+
fill: $chateauGreen;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
14
|
+
var _success_done = require("../../images/success_done.svg");
|
|
15
|
+
|
|
16
|
+
var _close = require("../../images/close.svg");
|
|
17
|
+
|
|
18
|
+
require("./ValidationTemplate.scss");
|
|
19
|
+
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
var ValidationTemplate = function ValidationTemplate(_ref) {
|
|
25
|
+
var valid = _ref.valid,
|
|
26
|
+
validationMessage = _ref.validationMessage;
|
|
27
|
+
var validationClasses = (0, _classnames.default)('validation-option', valid && 'text-muted');
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
29
|
+
className: validationClasses,
|
|
30
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
31
|
+
className: "validation-option__icon",
|
|
32
|
+
children: valid ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_success_done.ReactComponent, {
|
|
33
|
+
className: "validation-option__icon_valid"
|
|
34
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_close.ReactComponent, {
|
|
35
|
+
className: "validation-option__icon_invalid"
|
|
36
|
+
})
|
|
37
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
38
|
+
children: validationMessage
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
ValidationTemplate.propTypes = {
|
|
44
|
+
valid: _propTypes.default.bool.isRequired,
|
|
45
|
+
validationMessage: _propTypes.default.string.isRequired
|
|
46
|
+
};
|
|
47
|
+
var _default = ValidationTemplate;
|
|
48
|
+
exports.default = _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import '../../scss/colors';
|
|
2
|
+
|
|
3
|
+
.validation-option {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
margin: 0.6rem 0;
|
|
7
|
+
padding: 0 1rem;
|
|
8
|
+
font-size: 0.875rem;
|
|
9
|
+
|
|
10
|
+
&__icon {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
width: 20px;
|
|
15
|
+
height: 20px;
|
|
16
|
+
margin-right: 0.5rem;
|
|
17
|
+
|
|
18
|
+
&_valid {
|
|
19
|
+
width: 14px;
|
|
20
|
+
height: 15px;
|
|
21
|
+
|
|
22
|
+
path {
|
|
23
|
+
fill: $brightTurquoise;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&_invalid {
|
|
28
|
+
width: 12px;
|
|
29
|
+
height: 12px;
|
|
30
|
+
|
|
31
|
+
path {
|
|
32
|
+
fill: $amaranth;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useDetectOutsideClick = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook for handling closing when clicking outside of an element
|
|
12
|
+
* @function useDetectOutsideClick
|
|
13
|
+
* @param {React.node} ref
|
|
14
|
+
* @param {function} handler A callback function to use on outside click
|
|
15
|
+
*/
|
|
16
|
+
var useDetectOutsideClick = function useDetectOutsideClick(ref, handler) {
|
|
17
|
+
(0, _react.useEffect)(function () {
|
|
18
|
+
var onClick = function onClick(e) {
|
|
19
|
+
e.stopPropagation(); // If the active element exists and is clicked outside of
|
|
20
|
+
|
|
21
|
+
if (ref.current !== null && !ref.current.contains(e.target)) {
|
|
22
|
+
handler(e);
|
|
23
|
+
}
|
|
24
|
+
}; // If the item is active (ie open) then listen for clicks outside
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
window.addEventListener('click', onClick);
|
|
28
|
+
return function () {
|
|
29
|
+
window.removeEventListener('click', onClick);
|
|
30
|
+
};
|
|
31
|
+
}, [ref, handler]);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.useDetectOutsideClick = useDetectOutsideClick;
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,16 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.types = exports.constants = exports.components = void 0;
|
|
8
|
+
exports.types = exports.hooks = exports.constants = exports.components = void 0;
|
|
9
9
|
|
|
10
10
|
var components = _interopRequireWildcard(require("./components"));
|
|
11
11
|
|
|
12
12
|
exports.components = components;
|
|
13
13
|
|
|
14
|
+
var hooks = _interopRequireWildcard(require("./hooks"));
|
|
15
|
+
|
|
16
|
+
exports.hooks = hooks;
|
|
17
|
+
|
|
14
18
|
var types = _interopRequireWildcard(require("./types"));
|
|
15
19
|
|
|
16
20
|
exports.types = types;
|