iguazio.dashboard-react-controls 1.9.2 → 2.0.0
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 +7 -7
- package/dist/components/Button/Button.js +20 -26
- package/dist/components/ConfirmDialog/ConfirmDialog.js +18 -17
- package/dist/components/FormCheckBox/FormCheckBox.js +28 -32
- package/dist/components/FormChipCell/FormChip/FormChip.js +46 -50
- package/dist/components/FormChipCell/FormChipCell.js +122 -142
- package/dist/components/FormChipCell/FormChipCellView.js +44 -47
- package/dist/components/FormChipCell/HiddenChipsBlock/HiddenChipsBlock.js +23 -20
- package/dist/components/FormChipCell/NewChipForm/NewChipForm.js +129 -152
- package/dist/components/FormChipCell/NewChipInput/NewChipInput.js +24 -27
- package/dist/components/FormChipCell/formChipCell.util.js +6 -16
- package/dist/components/FormCombobox/FormCombobox.js +134 -195
- package/dist/components/FormInput/FormInput.js +134 -212
- package/dist/components/FormInput/InputNumberButtons/InputNumberButtons.js +15 -14
- package/dist/components/FormKeyValueTable/FormKeyValueTable.js +72 -72
- package/dist/components/FormRadio/FormRadio.js +21 -25
- package/dist/components/FormSelect/FormSelect.js +98 -126
- package/dist/components/FormSelect/FormSelect.test.js +56 -60
- package/dist/components/FormTextarea/FormTextarea.js +55 -71
- package/dist/components/FormToggle/FormToggle.js +25 -29
- package/dist/components/Modal/Modal.js +17 -18
- package/dist/components/PopUpDialog/PopUpDialog.js +53 -63
- package/dist/components/RoundedIcon/RoundedIcon.js +14 -13
- package/dist/components/Tip/Tip.js +58 -64
- package/dist/components/Tip/Tip.test.js +41 -64
- package/dist/components/Tooltip/Tooltip.js +75 -89
- package/dist/components/TooltipTemplate/ProducerTooltipTemplate.js +6 -5
- package/dist/components/TooltipTemplate/TextTooltipTemplate.js +10 -10
- package/dist/components/Wizard/Wizard.js +73 -107
- package/dist/components/Wizard/WizardSteps/WizardSteps.js +19 -20
- package/dist/components/index.js +18 -18
- package/dist/constants.js +26 -44
- package/dist/elements/FormActionButton/FormActionButton.js +12 -13
- package/dist/elements/FormRowActions/FormRowActions.js +19 -22
- package/dist/elements/OptionsMenu/OptionsMenu.js +10 -8
- package/dist/elements/SelectOption/SelectOption.js +14 -13
- package/dist/elements/SelectOption/SelectOption.test.js +39 -47
- package/dist/elements/ValidationTemplate/ValidationTemplate.js +7 -6
- package/dist/elements/index.js +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/hooks/useChipCell.hook.js +66 -85
- package/dist/hooks/useDebounce.hook.js +22 -24
- package/dist/hooks/useDetectOutsideClick.hook.js +4 -4
- package/dist/hooks/useFormTable.hook.js +99 -112
- package/dist/hooks/useHiddenChipsBlock.hook.js +40 -55
- package/dist/index.js +2 -3
- package/dist/scss/borders.scss +6 -0
- package/dist/scss/mixins.scss +32 -0
- package/dist/types.js +43 -67
- package/dist/utils/common.util.js +19 -23
- package/dist/utils/form.util.js +33 -39
- package/dist/utils/generateChipsList.util.js +7 -7
- package/dist/utils/getFirstScrollableParent.util.js +4 -10
- package/dist/utils/math.util.js +3 -3
- package/dist/utils/validation.util.js +74 -131
- package/package.json +34 -34
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -15,7 +14,9 @@ var _Tooltip = _interopRequireDefault(require("../Tooltip/Tooltip"));
|
|
|
15
14
|
var _exclamationMark = require("../../images/exclamation-mark.svg");
|
|
16
15
|
require("./formTextarea.scss");
|
|
17
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
|
|
17
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
20
|
/*
|
|
20
21
|
Copyright 2022 Iguazio Systems Ltd.
|
|
21
22
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -32,78 +33,60 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
32
33
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
33
34
|
such restriction.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
withoutBorder = _ref.withoutBorder,
|
|
66
|
-
textareaProps = _objectWithoutProperties(_ref, _excluded);
|
|
67
|
-
var _useField = (0, _reactFinalForm.useField)(name),
|
|
68
|
-
input = _useField.input,
|
|
69
|
-
meta = _useField.meta;
|
|
70
|
-
var _useState = (0, _react.useState)(false),
|
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
-
isInvalid = _useState2[0],
|
|
73
|
-
setIsInvalid = _useState2[1];
|
|
74
|
-
var _useState3 = (0, _react.useState)(input.value.length),
|
|
75
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
|
-
textAreaCount = _useState4[0],
|
|
77
|
-
setTextAreaCount = _useState4[1];
|
|
78
|
-
var textAreaRef = /*#__PURE__*/_react.default.createRef();
|
|
79
|
-
var formFieldClassNames = (0, _classnames.default)('form-field-textarea', className);
|
|
80
|
-
var labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
|
|
81
|
-
var textAreaClassNames = (0, _classnames.default)('form-field__wrapper', disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
|
|
82
|
-
(0, _react.useLayoutEffect)(function () {
|
|
36
|
+
|
|
37
|
+
const FormTextarea = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
38
|
+
let {
|
|
39
|
+
className,
|
|
40
|
+
disabled,
|
|
41
|
+
focused,
|
|
42
|
+
iconClass,
|
|
43
|
+
invalidText,
|
|
44
|
+
label,
|
|
45
|
+
maxLength,
|
|
46
|
+
name,
|
|
47
|
+
onBlur,
|
|
48
|
+
onChange,
|
|
49
|
+
required,
|
|
50
|
+
textAreaIcon,
|
|
51
|
+
tip,
|
|
52
|
+
withoutBorder,
|
|
53
|
+
...textareaProps
|
|
54
|
+
} = _ref;
|
|
55
|
+
const {
|
|
56
|
+
input,
|
|
57
|
+
meta
|
|
58
|
+
} = (0, _reactFinalForm.useField)(name);
|
|
59
|
+
const [isInvalid, setIsInvalid] = (0, _react.useState)(false);
|
|
60
|
+
const [textAreaCount, setTextAreaCount] = (0, _react.useState)(input.value.length);
|
|
61
|
+
const textAreaRef = /*#__PURE__*/_react.default.createRef();
|
|
62
|
+
const formFieldClassNames = (0, _classnames.default)('form-field-textarea', className);
|
|
63
|
+
const labelClassNames = (0, _classnames.default)('form-field__label', disabled && 'form-field__label-disabled');
|
|
64
|
+
const textAreaClassNames = (0, _classnames.default)('form-field__wrapper', disabled && 'form-field__wrapper-disabled', isInvalid && 'form-field__wrapper-invalid', withoutBorder && 'without-border');
|
|
65
|
+
(0, _react.useLayoutEffect)(() => {
|
|
83
66
|
setTextAreaCount(input.value.length);
|
|
84
67
|
}, [input.value.length]);
|
|
85
|
-
(0, _react.useEffect)(
|
|
68
|
+
(0, _react.useEffect)(() => {
|
|
86
69
|
if (focused) {
|
|
87
70
|
textAreaRef.current.focus();
|
|
88
71
|
}
|
|
89
72
|
}, [focused, textAreaRef]);
|
|
90
|
-
(0, _react.useEffect)(
|
|
73
|
+
(0, _react.useEffect)(() => {
|
|
91
74
|
setIsInvalid(meta.invalid && (meta.validating || meta.modified || meta.submitFailed && meta.touched));
|
|
92
75
|
}, [meta.invalid, meta.modified, meta.submitFailed, meta.touched, meta.validating]);
|
|
93
|
-
|
|
76
|
+
const handleInputBlur = event => {
|
|
94
77
|
input.onBlur(event);
|
|
95
78
|
onBlur && onBlur(event);
|
|
96
79
|
};
|
|
97
|
-
|
|
80
|
+
const handleInputChange = event => {
|
|
98
81
|
input.onChange(event);
|
|
99
82
|
onChange && onChange(event.target.value);
|
|
100
83
|
};
|
|
101
|
-
|
|
84
|
+
const handleInputFocus = event => {
|
|
102
85
|
input.onFocus(event);
|
|
103
86
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
87
|
+
const validateField = value => {
|
|
88
|
+
const valueToValidate = value !== null && value !== void 0 ? value : '';
|
|
89
|
+
let validationError = null;
|
|
107
90
|
if (valueToValidate.startsWith(' ')) {
|
|
108
91
|
validationError = {
|
|
109
92
|
name: 'empty',
|
|
@@ -120,10 +103,12 @@ var FormTextarea = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
120
103
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
121
104
|
validate: validateField,
|
|
122
105
|
name: name,
|
|
123
|
-
children:
|
|
106
|
+
children: _ref2 => {
|
|
124
107
|
var _meta$error$label, _meta$error;
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
let {
|
|
109
|
+
input,
|
|
110
|
+
meta
|
|
111
|
+
} = _ref2;
|
|
127
112
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
128
113
|
ref: ref,
|
|
129
114
|
className: formFieldClassNames,
|
|
@@ -141,19 +126,19 @@ var FormTextarea = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
141
126
|
className: textAreaClassNames,
|
|
142
127
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
143
128
|
className: "form-field__control",
|
|
144
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea",
|
|
129
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
|
|
145
130
|
"data-testid": "textarea",
|
|
146
131
|
id: input.name,
|
|
147
132
|
maxLength: maxLength,
|
|
148
133
|
ref: textAreaRef,
|
|
149
|
-
required: isInvalid || required
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
134
|
+
required: isInvalid || required,
|
|
135
|
+
disabled,
|
|
136
|
+
...textareaProps,
|
|
137
|
+
...input,
|
|
153
138
|
onBlur: handleInputBlur,
|
|
154
139
|
onChange: handleInputChange,
|
|
155
140
|
onFocus: handleInputFocus
|
|
156
|
-
})
|
|
141
|
+
})
|
|
157
142
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
158
143
|
className: "form-field__icons",
|
|
159
144
|
children: [isInvalid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
|
|
@@ -189,8 +174,8 @@ FormTextarea.defaultProps = {
|
|
|
189
174
|
invalidText: 'This field is invalid',
|
|
190
175
|
label: '',
|
|
191
176
|
maxLength: null,
|
|
192
|
-
onBlur:
|
|
193
|
-
onChange:
|
|
177
|
+
onBlur: () => {},
|
|
178
|
+
onChange: () => {},
|
|
194
179
|
placeholder: '',
|
|
195
180
|
required: false,
|
|
196
181
|
rows: 3,
|
|
@@ -212,5 +197,4 @@ FormTextarea.propTypes = {
|
|
|
212
197
|
required: _propTypes.default.bool,
|
|
213
198
|
tip: _propTypes.default.string
|
|
214
199
|
};
|
|
215
|
-
var _default = /*#__PURE__*/_react.default.memo(FormTextarea);
|
|
216
|
-
exports.default = _default;
|
|
200
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(FormTextarea);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -11,7 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
10
|
var _reactFinalForm = require("react-final-form");
|
|
12
11
|
require("./formToggle.scss");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
14
|
/*
|
|
16
15
|
Copyright 2022 Iguazio Systems Ltd.
|
|
17
16
|
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
@@ -28,44 +27,42 @@ illegal under applicable law, and the grant of the foregoing license
|
|
|
28
27
|
under the Apache 2.0 license is conditioned upon your compliance with
|
|
29
28
|
such restriction.
|
|
30
29
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
label = _ref.label,
|
|
43
|
-
name = _ref.name,
|
|
44
|
-
_onChange = _ref.onChange,
|
|
45
|
-
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
46
|
-
var toggleWrapperClassNames = (0, _classnames.default)('form-field__wrapper', density && "form-field__wrapper-".concat(density));
|
|
30
|
+
|
|
31
|
+
const FormToggle = _ref => {
|
|
32
|
+
let {
|
|
33
|
+
className,
|
|
34
|
+
density,
|
|
35
|
+
label,
|
|
36
|
+
name,
|
|
37
|
+
onChange,
|
|
38
|
+
...inputProps
|
|
39
|
+
} = _ref;
|
|
40
|
+
const toggleWrapperClassNames = (0, _classnames.default)('form-field__wrapper', density && "form-field__wrapper-".concat(density));
|
|
47
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
|
|
48
42
|
name: name,
|
|
49
43
|
value: inputProps.value,
|
|
50
44
|
type: "checkbox",
|
|
51
|
-
children:
|
|
52
|
-
|
|
45
|
+
children: _ref2 => {
|
|
46
|
+
let {
|
|
47
|
+
input
|
|
48
|
+
} = _ref2;
|
|
53
49
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
|
|
54
50
|
className: "form-field-toggle",
|
|
55
51
|
"data-testid": name ? "".concat(name, "-form-field-toggle") : 'form-field-toggle',
|
|
56
52
|
children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
57
53
|
className: "form-field__label",
|
|
58
54
|
children: label
|
|
59
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input",
|
|
55
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
60
56
|
"data-testid": name ? "".concat(name, "-form-toggle") : 'form-toggle',
|
|
61
|
-
id: name
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
id: name,
|
|
58
|
+
...input,
|
|
59
|
+
...inputProps,
|
|
60
|
+
onChange: event => {
|
|
61
|
+
onChange && onChange(event);
|
|
65
62
|
input.onChange(event);
|
|
66
63
|
},
|
|
67
64
|
type: "checkbox"
|
|
68
|
-
})
|
|
65
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
69
66
|
className: toggleWrapperClassNames,
|
|
70
67
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
71
68
|
className: "form-field-toggle__switch"
|
|
@@ -78,7 +75,7 @@ var FormToggle = function FormToggle(_ref) {
|
|
|
78
75
|
FormToggle.defaultProps = {
|
|
79
76
|
className: '',
|
|
80
77
|
label: '',
|
|
81
|
-
onChange:
|
|
78
|
+
onChange: () => {}
|
|
82
79
|
};
|
|
83
80
|
FormToggle.propTypes = {
|
|
84
81
|
className: _propTypes.default.string,
|
|
@@ -87,5 +84,4 @@ FormToggle.propTypes = {
|
|
|
87
84
|
name: _propTypes.default.string.isRequired,
|
|
88
85
|
onChange: _propTypes.default.func
|
|
89
86
|
};
|
|
90
|
-
var _default = FormToggle;
|
|
91
|
-
exports.default = _default;
|
|
87
|
+
var _default = exports.default = FormToggle;
|
|
@@ -33,17 +33,19 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
33
33
|
such restriction.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
const Modal = _ref => {
|
|
37
|
+
let {
|
|
38
|
+
actions,
|
|
39
|
+
children,
|
|
40
|
+
className,
|
|
41
|
+
onClose,
|
|
42
|
+
previewText,
|
|
43
|
+
size,
|
|
44
|
+
show,
|
|
45
|
+
subTitle,
|
|
46
|
+
title
|
|
47
|
+
} = _ref;
|
|
48
|
+
const modalClassNames = (0, _classnames.default)('modal', className, size && "modal-".concat(size));
|
|
47
49
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
48
50
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Backdrop.default, {
|
|
49
51
|
onClose: onClose,
|
|
@@ -85,11 +87,9 @@ var Modal = function Modal(_ref) {
|
|
|
85
87
|
className: "modal__footer",
|
|
86
88
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
87
89
|
className: "modal__footer-actions",
|
|
88
|
-
children: actions.map(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, idx);
|
|
92
|
-
})
|
|
90
|
+
children: actions.map((action, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
91
|
+
children: action
|
|
92
|
+
}, idx))
|
|
93
93
|
})
|
|
94
94
|
})]
|
|
95
95
|
})]
|
|
@@ -115,5 +115,4 @@ Modal.propTypes = {
|
|
|
115
115
|
subTitle: _propTypes.default.string,
|
|
116
116
|
title: _propTypes.default.string
|
|
117
117
|
};
|
|
118
|
-
var _default = Modal;
|
|
119
|
-
exports.default = _default;
|
|
118
|
+
var _default = exports.default = Modal;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
@@ -18,68 +17,60 @@ var _close = require("../../images/close.svg");
|
|
|
18
17
|
require("./popUpDialog.scss");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
function _getRequireWildcardCache(
|
|
22
|
-
function _interopRequireWildcard(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
under the Apache 2.0 license is conditioned upon your compliance with
|
|
42
|
-
such restriction.
|
|
43
|
-
*/
|
|
44
|
-
var PopUpDialog = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
/*
|
|
23
|
+
Copyright 2022 Iguazio Systems Ltd.
|
|
24
|
+
Licensed under the Apache License, Version 2.0 (the "License") with
|
|
25
|
+
an addition restriction as set forth herein. You may not use this
|
|
26
|
+
file except in compliance with the License. You may obtain a copy of
|
|
27
|
+
the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
28
|
+
Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
31
|
+
implied. See the License for the specific language governing
|
|
32
|
+
permissions and limitations under the License.
|
|
33
|
+
In addition, you may not use the software for any purposes that are
|
|
34
|
+
illegal under applicable law, and the grant of the foregoing license
|
|
35
|
+
under the Apache 2.0 license is conditioned upon your compliance with
|
|
36
|
+
such restriction.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
const PopUpDialog = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
45
40
|
var _ref2;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var popUpOverlayRef = (0, _react.useRef)(null);
|
|
41
|
+
let {
|
|
42
|
+
children,
|
|
43
|
+
className,
|
|
44
|
+
closePopUp,
|
|
45
|
+
customPosition,
|
|
46
|
+
headerIsHidden,
|
|
47
|
+
headerText,
|
|
48
|
+
showPopUpDialog,
|
|
49
|
+
style,
|
|
50
|
+
tooltipText
|
|
51
|
+
} = _ref;
|
|
52
|
+
const [showPopUp, setShowPopUp] = (0, _react.useState)(showPopUpDialog !== null && showPopUpDialog !== void 0 ? showPopUpDialog : true);
|
|
53
|
+
const popUpOverlayRef = (0, _react.useRef)(null);
|
|
60
54
|
(_ref2 = ref) !== null && _ref2 !== void 0 ? _ref2 : ref = popUpOverlayRef;
|
|
61
|
-
|
|
62
|
-
|
|
55
|
+
const popUpClassNames = (0, _classnames.default)(className, 'pop-up-dialog__overlay', customPosition.element && 'custom-position');
|
|
56
|
+
const handleClosePopUp = (0, _react.useCallback)(() => {
|
|
63
57
|
closePopUp && closePopUp();
|
|
64
58
|
setShowPopUp(false);
|
|
65
59
|
}, [closePopUp]);
|
|
66
|
-
|
|
60
|
+
const calculateCustomPopUpPosition = (0, _react.useCallback)(() => {
|
|
67
61
|
var _customPosition$eleme, _ref3;
|
|
68
62
|
if (customPosition !== null && customPosition !== void 0 && (_customPosition$eleme = customPosition.element) !== null && _customPosition$eleme !== void 0 && _customPosition$eleme.current && (_ref3 = ref) !== null && _ref3 !== void 0 && _ref3.current) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var isEnoughSpaceFromBottom = elementRect.bottom + popUpRect.height + popupMargin + elementMargin <= window.innerHeight;
|
|
81
|
-
var leftPosition = horizontalPosition === 'left' ? elementRect.right - popUpRect.width : elementRect.left;
|
|
82
|
-
var topPosition;
|
|
63
|
+
const elementRect = customPosition.element.current.getBoundingClientRect();
|
|
64
|
+
const popUpRect = ref.current.getBoundingClientRect();
|
|
65
|
+
const [verticalPosition, horizontalPosition] = customPosition.position.split('-');
|
|
66
|
+
const popupMargin = 15;
|
|
67
|
+
const elementMargin = 5;
|
|
68
|
+
const isEnoughSpaceFromLeft = elementRect.right >= popUpRect.width + popupMargin;
|
|
69
|
+
const isEnoughSpaceFromRight = window.innerWidth - elementRect.left >= popUpRect.width + popupMargin;
|
|
70
|
+
const isEnoughSpaceFromTop = elementRect.top > popUpRect.height + popupMargin + elementMargin;
|
|
71
|
+
const isEnoughSpaceFromBottom = elementRect.bottom + popUpRect.height + popupMargin + elementMargin <= window.innerHeight;
|
|
72
|
+
let leftPosition = horizontalPosition === 'left' ? elementRect.right - popUpRect.width : elementRect.left;
|
|
73
|
+
let topPosition;
|
|
83
74
|
if (verticalPosition === 'top') {
|
|
84
75
|
topPosition = isEnoughSpaceFromTop ? elementRect.top - popUpRect.height - elementMargin : popupMargin;
|
|
85
76
|
} else {
|
|
@@ -119,16 +110,16 @@ var PopUpDialog = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
119
110
|
}
|
|
120
111
|
}
|
|
121
112
|
}, [customPosition, style.left, ref]);
|
|
122
|
-
(0, _react.useLayoutEffect)(
|
|
113
|
+
(0, _react.useLayoutEffect)(() => {
|
|
123
114
|
calculateCustomPopUpPosition();
|
|
124
115
|
}, [calculateCustomPopUpPosition]);
|
|
125
|
-
(0, _react.useEffect)(
|
|
126
|
-
|
|
116
|
+
(0, _react.useEffect)(() => {
|
|
117
|
+
const throttledCalculatedCustomPopUpPosition = (0, _lodash.throttle)(calculateCustomPopUpPosition, 100, {
|
|
127
118
|
trailing: true,
|
|
128
119
|
leading: true
|
|
129
120
|
});
|
|
130
121
|
window.addEventListener('resize', throttledCalculatedCustomPopUpPosition);
|
|
131
|
-
return
|
|
122
|
+
return () => {
|
|
132
123
|
window.removeEventListener('resize', throttledCalculatedCustomPopUpPosition);
|
|
133
124
|
};
|
|
134
125
|
});
|
|
@@ -165,7 +156,7 @@ var PopUpDialog = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
|
165
156
|
});
|
|
166
157
|
PopUpDialog.defaultProps = {
|
|
167
158
|
className: '',
|
|
168
|
-
closePopUp:
|
|
159
|
+
closePopUp: () => {},
|
|
169
160
|
customPosition: {},
|
|
170
161
|
headerIsHidden: false,
|
|
171
162
|
headerText: '',
|
|
@@ -183,5 +174,4 @@ PopUpDialog.propTypes = {
|
|
|
183
174
|
style: _propTypes.default.object,
|
|
184
175
|
tooltipText: _propTypes.default.string
|
|
185
176
|
};
|
|
186
|
-
var _default = PopUpDialog;
|
|
187
|
-
exports.default = _default;
|
|
177
|
+
var _default = exports.default = PopUpDialog;
|
|
@@ -29,16 +29,18 @@ under the Apache 2.0 license is conditioned upon your compliance with
|
|
|
29
29
|
such restriction.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
const RoundedIcon = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
33
|
+
let {
|
|
34
|
+
children,
|
|
35
|
+
className,
|
|
36
|
+
disabled,
|
|
37
|
+
id,
|
|
38
|
+
isActive,
|
|
39
|
+
onClick,
|
|
40
|
+
tooltipText
|
|
41
|
+
} = _ref;
|
|
42
|
+
const wrapperClassNames = (0, _classnames.default)('round-icon-cp', className);
|
|
43
|
+
const IconClassNames = (0, _classnames.default)('round-icon-cp__circle', isActive && 'round-icon-cp__circle-active', disabled && 'round-icon-cp__circle-disabled');
|
|
42
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
45
|
className: wrapperClassNames,
|
|
44
46
|
ref: ref,
|
|
@@ -63,7 +65,7 @@ RoundedIcon.defaultProps = {
|
|
|
63
65
|
disabled: false,
|
|
64
66
|
id: '',
|
|
65
67
|
isActive: false,
|
|
66
|
-
onClick:
|
|
68
|
+
onClick: () => {},
|
|
67
69
|
tooltipText: ''
|
|
68
70
|
};
|
|
69
71
|
RoundedIcon.propTypes = {
|
|
@@ -75,5 +77,4 @@ RoundedIcon.propTypes = {
|
|
|
75
77
|
onClick: _propTypes.default.func,
|
|
76
78
|
tooltipText: _propTypes.default.string
|
|
77
79
|
};
|
|
78
|
-
var _default = /*#__PURE__*/_react.default.memo(RoundedIcon);
|
|
79
|
-
exports.default = _default;
|
|
80
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(RoundedIcon);
|