iguazio.dashboard-react-controls 0.0.6 → 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.
@@ -0,0 +1,89 @@
1
+ @import '../../scss/colors';
2
+
3
+ $arrowLength: 10px;
4
+ $iconLength: 16px;
5
+ $arrowOffset: 20px;
6
+
7
+ .tip-container {
8
+ position: relative;
9
+ display: inline-flex;
10
+ align-items: center;
11
+ }
12
+
13
+ .tip {
14
+ position: fixed;
15
+ display: block;
16
+ padding: 10px;
17
+ color: $white;
18
+ white-space: pre-line;
19
+ background: $primary;
20
+ border-radius: 4px;
21
+ z-index: 9;
22
+
23
+ &_top {
24
+ &::after {
25
+ bottom: calc(-#{$arrowLength} / 2);
26
+ }
27
+ }
28
+
29
+ &_bottom {
30
+ &::after {
31
+ top: calc(-#{$arrowLength} / 2);
32
+ }
33
+ }
34
+
35
+ &_left {
36
+ &::after {
37
+ right: calc(#{$arrowOffset});
38
+ }
39
+ }
40
+
41
+ &_right {
42
+ &::after {
43
+ left: calc(#{$arrowOffset});
44
+ }
45
+ }
46
+
47
+ &_small {
48
+ min-width: 100px;
49
+ max-width: 250px;
50
+ }
51
+
52
+ &_big {
53
+ min-width: 250px;
54
+ max-width: 400px;
55
+ }
56
+
57
+ &::after {
58
+ position: absolute;
59
+ width: $arrowLength;
60
+ height: $arrowLength;
61
+ background: $primary;
62
+ transform: rotate(45deg);
63
+ content: '';
64
+ }
65
+ }
66
+
67
+ .fade-enter {
68
+ opacity: 0;
69
+ }
70
+
71
+ .fade-enter-active {
72
+ opacity: 1;
73
+ transition: opacity 200ms;
74
+ }
75
+
76
+ .fade-exit {
77
+ opacity: 1;
78
+ }
79
+
80
+ .fade-exit-active {
81
+ opacity: 0;
82
+ transition: opacity 200ms;
83
+ }
84
+
85
+ :export {
86
+ arrowlength: $arrowLength;
87
+ iconlength: $iconLength;
88
+ arrowoffset: $arrowOffset;
89
+ }
@@ -211,9 +211,11 @@ var Wizard = function Wizard(_ref) {
211
211
  activeStepNumber: activeStepNumber,
212
212
  jumpToStep: jumpToStep,
213
213
  steps: stepsMenu
214
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
214
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
215
215
  className: "wizard-form__content",
216
- children: activeStepTemplate
216
+ children: [activeStepTemplate, /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
217
+ children: JSON.stringify(FormState, null, 2)
218
+ })]
217
219
  })]
218
220
  });
219
221
  }
@@ -15,6 +15,24 @@ Object.defineProperty(exports, "ConfirmDialog", {
15
15
  return _ConfirmDialog.default;
16
16
  }
17
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
+ });
18
36
  Object.defineProperty(exports, "Modal", {
19
37
  enumerable: true,
20
38
  get: function get() {
@@ -39,6 +57,12 @@ Object.defineProperty(exports, "TextTooltipTemplate", {
39
57
  return _TextTooltipTemplate.default;
40
58
  }
41
59
  });
60
+ Object.defineProperty(exports, "Tip", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _Tip.default;
64
+ }
65
+ });
42
66
  Object.defineProperty(exports, "Tooltip", {
43
67
  enumerable: true,
44
68
  get: function get() {
@@ -56,6 +80,12 @@ var _Button = _interopRequireDefault(require("./Button/Button"));
56
80
 
57
81
  var _ConfirmDialog = _interopRequireDefault(require("./ConfirmDialog/ConfirmDialog"));
58
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
+
59
89
  var _Modal = _interopRequireDefault(require("./Modal/Modal"));
60
90
 
61
91
  var _PopUpDialog = _interopRequireDefault(require("./PopUpDialog/PopUpDialog"));
@@ -64,6 +94,8 @@ var _RoundedIcon = _interopRequireDefault(require("./RoundedIcon/RoundedIcon"));
64
94
 
65
95
  var _TextTooltipTemplate = _interopRequireDefault(require("./TooltipTemplate/TextTooltipTemplate"));
66
96
 
97
+ var _Tip = _interopRequireDefault(require("./Tip/Tip"));
98
+
67
99
  var _Tooltip = _interopRequireDefault(require("./Tooltip/Tooltip"));
68
100
 
69
101
  var _Wizard = _interopRequireDefault(require("./Wizard/Wizard"));
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.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;
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,9 +15,27 @@ 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
- /*=========== STATUS CODES =============*/
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;
@@ -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;