@bigbinary/neeto-molecules 1.1.74 → 1.1.76
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/Breadcrumbs.js +12 -5
- package/dist/Breadcrumbs.js.map +1 -1
- package/dist/Metadata.js +1 -1
- package/dist/Metadata.js.map +1 -1
- package/dist/NavigationHeader.js +292 -177
- package/dist/NavigationHeader.js.map +1 -1
- package/dist/Rename.js +305 -190
- package/dist/Rename.js.map +1 -1
- package/dist/Search.js.map +1 -1
- package/package.json +1 -1
- package/src/translations/en.json +3 -1
- package/types/Breadcrumbs.d.ts +1 -0
- package/types/Rename.d.ts +3 -0
package/dist/Rename.js
CHANGED
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { useStateWithDependency, useOnClickOutside
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { mergeRight, isEmpty } from 'ramda';
|
|
8
|
-
import { useTranslation } from 'react-i18next';
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { isPresent, isNotEmpty } from '@bigbinary/neeto-cist';
|
|
4
|
+
import { useHotKeys, withT, useStateWithDependency, useOnClickOutside } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
5
|
+
import { isEmpty, mergeRight } from 'ramda';
|
|
6
|
+
import { Typography, Input, Button, Dropdown, Tooltip } from '@bigbinary/neetoui';
|
|
9
7
|
import { Link } from 'react-router-dom';
|
|
8
|
+
import { withEventTargetValue } from '@bigbinary/neeto-commons-frontend/utils';
|
|
9
|
+
import { Check, Close, MenuVertical, MenuHorizontal } from '@bigbinary/neeto-icons';
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
if (
|
|
13
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
14
|
-
return arr2;
|
|
11
|
+
function _arrayWithHoles(arr) {
|
|
12
|
+
if (Array.isArray(arr)) return arr;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
function
|
|
18
|
-
|
|
15
|
+
function _iterableToArrayLimit(r, l) {
|
|
16
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
17
|
+
if (null != t) {
|
|
18
|
+
var e,
|
|
19
|
+
n,
|
|
20
|
+
i,
|
|
21
|
+
u,
|
|
22
|
+
a = [],
|
|
23
|
+
f = !0,
|
|
24
|
+
o = !1;
|
|
25
|
+
try {
|
|
26
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
27
|
+
if (Object(t) !== t) return;
|
|
28
|
+
f = !1;
|
|
29
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
30
|
+
} catch (r) {
|
|
31
|
+
o = !0, n = r;
|
|
32
|
+
} finally {
|
|
33
|
+
try {
|
|
34
|
+
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
|
|
35
|
+
} finally {
|
|
36
|
+
if (o) throw n;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return a;
|
|
40
|
+
}
|
|
19
41
|
}
|
|
20
42
|
|
|
21
|
-
function
|
|
22
|
-
if (
|
|
43
|
+
function _arrayLikeToArray(arr, len) {
|
|
44
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
45
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
46
|
+
return arr2;
|
|
23
47
|
}
|
|
24
48
|
|
|
25
49
|
function _unsupportedIterableToArray(o, minLen) {
|
|
@@ -31,14 +55,75 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
31
55
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
32
56
|
}
|
|
33
57
|
|
|
34
|
-
function
|
|
35
|
-
throw new TypeError("Invalid attempt to
|
|
58
|
+
function _nonIterableRest() {
|
|
59
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
36
60
|
}
|
|
37
61
|
|
|
38
|
-
function
|
|
39
|
-
return
|
|
62
|
+
function _slicedToArray(arr, i) {
|
|
63
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
40
64
|
}
|
|
41
65
|
|
|
66
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
67
|
+
|
|
68
|
+
var css$1 = ".neeto-molecules-breadcrumbs-wrap{display:flex}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb{align-items:center;display:flex;flex-direction:row;justify-content:flex-start;line-height:1}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb a{text-decoration:none;transition:all .3s ease-in-out}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb a:focus-visible{border-radius:var(--neeto-ui-rounded-sm);outline:3px solid rgba(var(--neeto-ui-primary-500),50%)}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb-link{color:rgb(var(--neeto-ui-gray-500));padding:8px 5px}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb-link:hover{color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-breadcrumbs-wrap .neeto-molecules-breadcrumb-separator{margin:0 4px}";
|
|
69
|
+
n(css$1,{});
|
|
70
|
+
|
|
71
|
+
var Breadcrumbs = function Breadcrumbs(_ref) {
|
|
72
|
+
var breadcrumbs = _ref.breadcrumbs,
|
|
73
|
+
_ref$hasTrailingSepar = _ref.hasTrailingSeparator,
|
|
74
|
+
hasTrailingSeparator = _ref$hasTrailingSepar === void 0 ? false : _ref$hasTrailingSepar;
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
className: "neeto-molecules-breadcrumbs-wrap"
|
|
77
|
+
}, breadcrumbs.map(function (_ref2, index) {
|
|
78
|
+
var text = _ref2.text,
|
|
79
|
+
_ref2$link = _ref2.link,
|
|
80
|
+
link = _ref2$link === void 0 ? "#" : _ref2$link;
|
|
81
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
82
|
+
className: "neeto-molecules-breadcrumb",
|
|
83
|
+
"data-cy": "header-breadcrumb",
|
|
84
|
+
key: index
|
|
85
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
86
|
+
to: link
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
88
|
+
className: "neeto-ui-text-gray-700 hover:neeto-ui-text-gray-800 neeto-molecules-breadcrumb-link",
|
|
89
|
+
component: "p",
|
|
90
|
+
"data-cy": text,
|
|
91
|
+
"data-test-id": text,
|
|
92
|
+
style: "body2",
|
|
93
|
+
weight: "normal"
|
|
94
|
+
}, text)), (index + 1 !== breadcrumbs.length || hasTrailingSeparator) && /*#__PURE__*/React.createElement(Typography, {
|
|
95
|
+
className: "neeto-molecules-breadcrumb-separator neeto-ui-text-gray-500",
|
|
96
|
+
component: "p",
|
|
97
|
+
"data-cy": "breadcrumb-divider-".concat(index),
|
|
98
|
+
"data-test-id": "breadcrumb-divider-".concat(index),
|
|
99
|
+
style: "body2",
|
|
100
|
+
weight: "normal"
|
|
101
|
+
}, "/"));
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var MIN_WIDTH = 150;
|
|
106
|
+
|
|
107
|
+
var DummySpan = function DummySpan(_ref) {
|
|
108
|
+
var name = _ref.name,
|
|
109
|
+
placeholderRef = _ref.placeholderRef,
|
|
110
|
+
setInputWidth = _ref.setInputWidth;
|
|
111
|
+
useEffect(function () {
|
|
112
|
+
var _placeholderRef$curre;
|
|
113
|
+
//To handle the input width on initial render.
|
|
114
|
+
var placeholderSpanWidth = (_placeholderRef$curre = placeholderRef.current) === null || _placeholderRef$curre === void 0 ? void 0 : _placeholderRef$curre.offsetWidth;
|
|
115
|
+
setInputWidth(placeholderSpanWidth);
|
|
116
|
+
}, [name]);
|
|
117
|
+
return (
|
|
118
|
+
/*#__PURE__*/
|
|
119
|
+
// Dummy element to calculate the width to be set for the input. Do not remove.
|
|
120
|
+
React.createElement("div", {
|
|
121
|
+
className: "dummy-span pointer-events-none invisible absolute",
|
|
122
|
+
ref: placeholderRef
|
|
123
|
+
}, name.split(" ").join("."))
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
|
|
42
127
|
function _extends() {
|
|
43
128
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
44
129
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -54,44 +139,100 @@ function _extends() {
|
|
|
54
139
|
return _extends.apply(this, arguments);
|
|
55
140
|
}
|
|
56
141
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
142
|
+
var mergeRefs = function mergeRefs() {
|
|
143
|
+
for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
144
|
+
refs[_key] = arguments[_key];
|
|
145
|
+
}
|
|
146
|
+
return function (node) {
|
|
147
|
+
return refs.forEach(function (ref) {
|
|
148
|
+
return typeof ref === "function" ? ref(node) : ref.current = node;
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
};
|
|
60
152
|
|
|
61
|
-
function
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
153
|
+
var Editor = function Editor(_ref) {
|
|
154
|
+
var placeholder = _ref.placeholder,
|
|
155
|
+
inputWidth = _ref.inputWidth,
|
|
156
|
+
allowEmptySubmission = _ref.allowEmptySubmission,
|
|
157
|
+
name = _ref.name,
|
|
158
|
+
isLoading = _ref.isLoading,
|
|
159
|
+
handleRename = _ref.handleRename,
|
|
160
|
+
submitButtonProps = _ref.submitButtonProps,
|
|
161
|
+
handleClose = _ref.handleClose,
|
|
162
|
+
cancelButtonProps = _ref.cancelButtonProps,
|
|
163
|
+
setName = _ref.setName,
|
|
164
|
+
inputProps = _ref.inputProps,
|
|
165
|
+
editMode = _ref.editMode;
|
|
166
|
+
var closeRef = useHotKeys("escape", handleClose, {
|
|
167
|
+
mode: "scoped",
|
|
168
|
+
enabled: editMode
|
|
169
|
+
});
|
|
170
|
+
var submitRef = useHotKeys(["command+return", "return"], function (event) {
|
|
171
|
+
if (isEmpty(name) && !allowEmptySubmission) return;
|
|
172
|
+
handleRename(event, name);
|
|
173
|
+
}, {
|
|
174
|
+
mode: "scoped",
|
|
175
|
+
enabled: editMode
|
|
176
|
+
});
|
|
177
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: "flex min-w-0 max-w-full flex-grow"
|
|
179
|
+
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
180
|
+
placeholder: placeholder,
|
|
181
|
+
autoFocus: true,
|
|
182
|
+
className: "neeto-molecules-rename__input flex-grow",
|
|
183
|
+
"data-cy": "form-rename-text-field",
|
|
184
|
+
"data-testid": "neeto-molecules-name-input",
|
|
185
|
+
ref: mergeRefs(closeRef, submitRef),
|
|
186
|
+
style: {
|
|
187
|
+
width: inputWidth
|
|
188
|
+
},
|
|
189
|
+
value: name,
|
|
190
|
+
suffix: /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
className: "flex items-center justify-end"
|
|
192
|
+
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
193
|
+
className: "neeto-ui-rounded-none",
|
|
194
|
+
"data-cy": "form-rename-submit-button",
|
|
195
|
+
"data-testid": "neeto-molecules-rename-button",
|
|
196
|
+
disabled: !allowEmptySubmission && isEmpty(name) || isLoading,
|
|
197
|
+
icon: Check,
|
|
198
|
+
loading: isLoading,
|
|
199
|
+
style: "text",
|
|
200
|
+
onClick: function onClick(event) {
|
|
201
|
+
return handleRename(event, name);
|
|
83
202
|
}
|
|
203
|
+
}, submitButtonProps)), /*#__PURE__*/React.createElement(Button, _extends({
|
|
204
|
+
className: "neeto-ui-rounded-none",
|
|
205
|
+
"data-cy": "form-rename-close-button",
|
|
206
|
+
"data-testid": "neeto-molecules-cancel-button",
|
|
207
|
+
disabled: isLoading,
|
|
208
|
+
icon: Close,
|
|
209
|
+
style: "text",
|
|
210
|
+
onClick: handleClose
|
|
211
|
+
}, cancelButtonProps))),
|
|
212
|
+
onChange: withEventTargetValue(setName),
|
|
213
|
+
onClick: function onClick(event) {
|
|
214
|
+
return event.stopPropagation();
|
|
84
215
|
}
|
|
85
|
-
|
|
86
|
-
|
|
216
|
+
}, inputProps)));
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
var css = ".neeto-molecules-rename__input{height:32px;margin-left:4px;max-width:100%;position:relative;transition:width .2s ease-in-out;width:-moz-max-content;width:max-content}.neeto-molecules-rename__input .neeto-ui-input{border-color:transparent}.neeto-molecules-rename__input .neeto-ui-input:focus-within{border-color:rgb(var(--neeto-ui-primary-500))}.neeto-molecules-rename__input .neeto-ui-input .neeto-ui-input__suffix{margin-right:0!important}.neeto-molecules-rename__input .neeto-ui-input input{min-width:0}.neeto-molecules-rename__text{background-color:rgb(var(--neeto-ui-white));border:thin solid rgb(var(--neeto-ui-white));border-radius:var(--neeto-ui-rounded);cursor:pointer;font-size:var(--neeto-ui-text-sm);font-weight:400;letter-spacing:.005em;line-height:1;margin:0 1px;max-height:32px;max-width:448px;padding:8px 5px;transition:var(--neeto-ui-transition)}.neeto-molecules-rename__display-text{color:rgb(var(--neeto-ui-gray-800))}.neeto-molecules-rename__display-text:hover{border:thin solid rgb(var(--neeto-ui-gray-300))}.dummy-span{font-size:14px;font-weight:400;padding:5px 8px}";
|
|
220
|
+
n(css,{});
|
|
221
|
+
|
|
222
|
+
function _arrayWithoutHoles(arr) {
|
|
223
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
87
224
|
}
|
|
88
225
|
|
|
89
|
-
function
|
|
90
|
-
|
|
226
|
+
function _iterableToArray(iter) {
|
|
227
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
91
228
|
}
|
|
92
229
|
|
|
93
|
-
function
|
|
94
|
-
|
|
230
|
+
function _nonIterableSpread() {
|
|
231
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function _toConsumableArray(arr) {
|
|
235
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
95
236
|
}
|
|
96
237
|
|
|
97
238
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
@@ -276,48 +417,91 @@ var MoreDropdown = function MoreDropdown(_ref) {
|
|
|
276
417
|
}), menuBottomChildren));
|
|
277
418
|
};
|
|
278
419
|
|
|
279
|
-
var
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
420
|
+
var RenameMenu = withT(function (_ref) {
|
|
421
|
+
var t = _ref.t,
|
|
422
|
+
handleRenameClick = _ref.handleRenameClick,
|
|
423
|
+
disabled = _ref.disabled,
|
|
424
|
+
dropdownItems = _ref.dropdownItems,
|
|
425
|
+
onArchive = _ref.onArchive,
|
|
426
|
+
onClone = _ref.onClone,
|
|
427
|
+
onDelete = _ref.onDelete;
|
|
428
|
+
return /*#__PURE__*/React.createElement(MoreDropdown, {
|
|
429
|
+
dropdownButtonProps: {
|
|
430
|
+
"data-testid": "neeto-molecules-menu-button"
|
|
431
|
+
},
|
|
432
|
+
dropdownProps: {
|
|
433
|
+
position: "bottom-start",
|
|
434
|
+
onClick: function onClick(event) {
|
|
435
|
+
return event.stopPropagation();
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
menuItems: [{
|
|
439
|
+
"data-cy": "form-rename-button",
|
|
440
|
+
onClick: handleRenameClick,
|
|
441
|
+
label: t("neetoMolecules.common.actions.rename"),
|
|
442
|
+
isVisible: !disabled,
|
|
443
|
+
key: "edit-name-menu"
|
|
444
|
+
}, {
|
|
445
|
+
"data-cy": "form-clone-button",
|
|
446
|
+
onClick: onClone,
|
|
447
|
+
label: t("neetoMolecules.common.actions.clone"),
|
|
448
|
+
isVisible: isPresent(onClone),
|
|
449
|
+
key: "clone-entity-menu"
|
|
450
|
+
}, {
|
|
451
|
+
"data-cy": "form-archive-button",
|
|
452
|
+
onClick: onArchive,
|
|
453
|
+
label: t("neetoMolecules.common.actions.archive"),
|
|
454
|
+
isVisible: isPresent(onArchive),
|
|
455
|
+
key: "archive-entity-menu"
|
|
456
|
+
}, {
|
|
457
|
+
"data-cy": "form-delete-button",
|
|
458
|
+
onClick: onDelete,
|
|
459
|
+
label: t("neetoMolecules.common.actions.delete"),
|
|
460
|
+
isVisible: isPresent(onDelete),
|
|
461
|
+
key: "delete-entity-menu"
|
|
462
|
+
}].concat(_toConsumableArray(dropdownItems))
|
|
463
|
+
});
|
|
464
|
+
});
|
|
305
465
|
|
|
306
|
-
var
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
466
|
+
var ViewName = function ViewName(_ref) {
|
|
467
|
+
var disabled = _ref.disabled,
|
|
468
|
+
textProps = _ref.textProps,
|
|
469
|
+
formatText = _ref.formatText,
|
|
470
|
+
dropdownItems = _ref.dropdownItems,
|
|
471
|
+
hideMenu = _ref.hideMenu,
|
|
472
|
+
handleRenameClick = _ref.handleRenameClick,
|
|
473
|
+
onArchive = _ref.onArchive,
|
|
474
|
+
onClone = _ref.onClone,
|
|
475
|
+
onDelete = _ref.onDelete,
|
|
476
|
+
name = _ref.name;
|
|
477
|
+
var isDefaultMenuCallbacksPresent = isPresent(onArchive) || isPresent(onDelete) || isPresent(onClone);
|
|
478
|
+
var isMenuVisible = !hideMenu && (isNotEmpty(dropdownItems) || !disabled || isDefaultMenuCallbacksPresent);
|
|
479
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, _extends({
|
|
480
|
+
component: "p",
|
|
481
|
+
"data-cy": "form-title",
|
|
482
|
+
"data-testid": "neeto-molecules-value-display",
|
|
483
|
+
style: "body2",
|
|
484
|
+
className: classNames("neeto-molecules-rename__text neeto-molecules-rename__display-text w-full truncate", {
|
|
485
|
+
"cursor-pointer": !disabled,
|
|
486
|
+
"pointer-events-none cursor-text": disabled
|
|
487
|
+
}),
|
|
488
|
+
onClick: handleRenameClick
|
|
489
|
+
}, textProps), typeof formatText === "function" ? formatText(name) : name), isMenuVisible && /*#__PURE__*/React.createElement(RenameMenu, {
|
|
490
|
+
disabled: disabled,
|
|
491
|
+
dropdownItems: dropdownItems,
|
|
492
|
+
handleRenameClick: handleRenameClick,
|
|
493
|
+
onArchive: onArchive,
|
|
494
|
+
onClone: onClone,
|
|
495
|
+
onDelete: onDelete
|
|
496
|
+
}));
|
|
315
497
|
};
|
|
316
498
|
|
|
317
499
|
var Rename = function Rename(_ref) {
|
|
318
500
|
var value = _ref.value,
|
|
319
|
-
|
|
320
|
-
|
|
501
|
+
onRename = _ref.onRename,
|
|
502
|
+
onClone = _ref.onClone,
|
|
503
|
+
onArchive = _ref.onArchive,
|
|
504
|
+
onDelete = _ref.onDelete,
|
|
321
505
|
_ref$isOpen = _ref.isOpen,
|
|
322
506
|
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
323
507
|
_ref$isLoading = _ref.isLoading,
|
|
@@ -347,8 +531,6 @@ var Rename = function Rename(_ref) {
|
|
|
347
531
|
_ref$defaultName = _ref.defaultName,
|
|
348
532
|
defaultName = _ref$defaultName === void 0 ? "" : _ref$defaultName,
|
|
349
533
|
formatText = _ref.formatText;
|
|
350
|
-
var _useTranslation = useTranslation(),
|
|
351
|
-
t = _useTranslation.t;
|
|
352
534
|
var _useStateWithDependen = useStateWithDependency(value !== null && value !== void 0 ? value : ""),
|
|
353
535
|
_useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
|
|
354
536
|
name = _useStateWithDependen2[0],
|
|
@@ -370,7 +552,7 @@ var Rename = function Rename(_ref) {
|
|
|
370
552
|
event.stopPropagation();
|
|
371
553
|
var newName = allowEmptySubmission && isEmpty(name) ? defaultName : name;
|
|
372
554
|
setName(newName);
|
|
373
|
-
onRename(newName);
|
|
555
|
+
onRename === null || onRename === void 0 ? void 0 : onRename(newName);
|
|
374
556
|
setEditMode(false);
|
|
375
557
|
};
|
|
376
558
|
var handleClose = function handleClose(event) {
|
|
@@ -378,114 +560,47 @@ var Rename = function Rename(_ref) {
|
|
|
378
560
|
setName(value);
|
|
379
561
|
setEditMode(false);
|
|
380
562
|
};
|
|
381
|
-
var
|
|
563
|
+
var handleRenameClick = function handleRenameClick(event) {
|
|
382
564
|
event.stopPropagation();
|
|
383
|
-
setEditMode(true);
|
|
565
|
+
!disabled && setEditMode(true);
|
|
384
566
|
};
|
|
385
|
-
var
|
|
386
|
-
|
|
387
|
-
|
|
567
|
+
var editNameProps = {
|
|
568
|
+
allowEmptySubmission: allowEmptySubmission,
|
|
569
|
+
cancelButtonProps: cancelButtonProps,
|
|
570
|
+
handleClose: handleClose,
|
|
571
|
+
handleRename: handleRename,
|
|
572
|
+
inputProps: inputProps,
|
|
573
|
+
inputWidth: inputWidth,
|
|
574
|
+
isLoading: isLoading,
|
|
575
|
+
name: name,
|
|
576
|
+
placeholder: placeholder,
|
|
577
|
+
setName: setName,
|
|
578
|
+
submitButtonProps: submitButtonProps,
|
|
579
|
+
editMode: editMode
|
|
580
|
+
};
|
|
581
|
+
var viewNameProps = {
|
|
582
|
+
disabled: disabled,
|
|
583
|
+
dropdownItems: dropdownItems,
|
|
584
|
+
formatText: formatText,
|
|
585
|
+
handleRenameClick: handleRenameClick,
|
|
586
|
+
hideMenu: hideMenu,
|
|
587
|
+
name: name,
|
|
588
|
+
onArchive: onArchive,
|
|
589
|
+
onClone: onClone,
|
|
590
|
+
onDelete: onDelete,
|
|
591
|
+
textProps: textProps
|
|
388
592
|
};
|
|
389
|
-
var closeRef = useHotKeys("escape", handleClose, {
|
|
390
|
-
mode: "scoped",
|
|
391
|
-
enabled: editMode
|
|
392
|
-
});
|
|
393
|
-
var submitRef = useHotKeys(["command+return", "return"], function (event) {
|
|
394
|
-
if (isEmpty(name) && !allowEmptySubmission) return;
|
|
395
|
-
handleRename(event, name);
|
|
396
|
-
}, {
|
|
397
|
-
mode: "scoped",
|
|
398
|
-
enabled: editMode
|
|
399
|
-
});
|
|
400
593
|
return /*#__PURE__*/React.createElement("div", {
|
|
401
594
|
ref: renameRef,
|
|
402
|
-
className:
|
|
403
|
-
}, breadcrumbs.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return /*#__PURE__*/React.createElement(Fragment, {
|
|
407
|
-
key: text
|
|
408
|
-
}, /*#__PURE__*/React.createElement(Link, _extends({
|
|
409
|
-
className: "neeto-molecules-rename__text neeto-molecules-rename__breadcrumb-text",
|
|
410
|
-
"data-testid": "neeto-molecules-value-display",
|
|
411
|
-
to: link
|
|
412
|
-
}, textProps), text), /*#__PURE__*/React.createElement(Typography, {
|
|
413
|
-
className: "neeto-molecules-rename__breadcrumb-text neeto-molecules-breadcrumb__divider",
|
|
414
|
-
component: "span"
|
|
415
|
-
}, "/"));
|
|
595
|
+
className: classNames("flex min-w-0 max-w-md flex-row items-center", className)
|
|
596
|
+
}, isNotEmpty(breadcrumbs) && /*#__PURE__*/React.createElement(Breadcrumbs, {
|
|
597
|
+
breadcrumbs: breadcrumbs,
|
|
598
|
+
hasTrailingSeparator: true
|
|
416
599
|
}), /*#__PURE__*/React.createElement(DummySpan, {
|
|
417
600
|
name: name,
|
|
418
601
|
placeholderRef: placeholderRef,
|
|
419
602
|
setInputWidth: setInputWidth
|
|
420
|
-
}), editMode ? /*#__PURE__*/React.createElement(
|
|
421
|
-
className: "flex min-w-0 max-w-full flex-grow"
|
|
422
|
-
}, /*#__PURE__*/React.createElement(Input, _extends({
|
|
423
|
-
autoFocus: true,
|
|
424
|
-
className: "neeto-molecules-rename__input flex-grow",
|
|
425
|
-
"data-cy": "form-rename-text-field",
|
|
426
|
-
"data-testid": "neeto-molecules-name-input",
|
|
427
|
-
onClick: function onClick(event) {
|
|
428
|
-
return event.stopPropagation();
|
|
429
|
-
},
|
|
430
|
-
placeholder: placeholder,
|
|
431
|
-
ref: mergeRefs(closeRef, submitRef),
|
|
432
|
-
style: {
|
|
433
|
-
width: inputWidth
|
|
434
|
-
},
|
|
435
|
-
value: name,
|
|
436
|
-
suffix: /*#__PURE__*/React.createElement("div", {
|
|
437
|
-
className: "flex items-center justify-end"
|
|
438
|
-
}, /*#__PURE__*/React.createElement(Button, _extends({
|
|
439
|
-
className: "neeto-ui-rounded-none",
|
|
440
|
-
"data-cy": "form-rename-submit-button",
|
|
441
|
-
"data-testid": "neeto-molecules-rename-button",
|
|
442
|
-
icon: Check,
|
|
443
|
-
loading: isLoading,
|
|
444
|
-
style: "text",
|
|
445
|
-
disabled: !allowEmptySubmission && isEmpty(name) || isLoading,
|
|
446
|
-
onClick: function onClick(event) {
|
|
447
|
-
return handleRename(event, name);
|
|
448
|
-
}
|
|
449
|
-
}, submitButtonProps)), /*#__PURE__*/React.createElement(Button, _extends({
|
|
450
|
-
className: "neeto-ui-rounded-none",
|
|
451
|
-
"data-cy": "form-rename-close-button",
|
|
452
|
-
"data-testid": "neeto-molecules-cancel-button",
|
|
453
|
-
disabled: isLoading,
|
|
454
|
-
icon: Close,
|
|
455
|
-
style: "text",
|
|
456
|
-
onClick: handleClose
|
|
457
|
-
}, cancelButtonProps))),
|
|
458
|
-
onChange: function onChange(event) {
|
|
459
|
-
return setName(event.target.value);
|
|
460
|
-
}
|
|
461
|
-
}, inputProps))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, _extends({
|
|
462
|
-
component: "p",
|
|
463
|
-
"data-cy": "form-title",
|
|
464
|
-
"data-testid": "neeto-molecules-value-display",
|
|
465
|
-
style: "body2",
|
|
466
|
-
className: classnames("neeto-molecules-rename__text neeto-molecules-rename__display-text w-full truncate", {
|
|
467
|
-
"cursor-pointer": !disabled,
|
|
468
|
-
"pointer-events-none cursor-text": disabled
|
|
469
|
-
}),
|
|
470
|
-
onClick: handleDisplayText
|
|
471
|
-
}, textProps), typeof formatText === "function" ? formatText(name) : name), !hideMenu && (isNotEmpty(dropdownItems) || !disabled) && /*#__PURE__*/React.createElement(MoreDropdown, {
|
|
472
|
-
dropdownButtonProps: {
|
|
473
|
-
"data-testid": "neeto-molecules-menu-button"
|
|
474
|
-
},
|
|
475
|
-
dropdownProps: {
|
|
476
|
-
position: "bottom-start",
|
|
477
|
-
onClick: function onClick(event) {
|
|
478
|
-
return event.stopPropagation();
|
|
479
|
-
}
|
|
480
|
-
},
|
|
481
|
-
menuItems: [{
|
|
482
|
-
"data-cy": "form-rename-button",
|
|
483
|
-
onClick: handleRenameButton,
|
|
484
|
-
label: t("neetoMolecules.common.actions.rename"),
|
|
485
|
-
isVisible: !disabled,
|
|
486
|
-
key: "edit-name-menu"
|
|
487
|
-
}].concat(_toConsumableArray(dropdownItems))
|
|
488
|
-
})));
|
|
603
|
+
}), editMode ? /*#__PURE__*/React.createElement(Editor, editNameProps) : /*#__PURE__*/React.createElement(ViewName, viewNameProps));
|
|
489
604
|
};
|
|
490
605
|
|
|
491
606
|
export { Rename as default };
|