@bigbinary/neeto-tags-frontend 2.2.34 → 2.2.35
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/.ready +1 -1
- package/dist/cjs/v2/TagsComponent.js +189 -130
- package/dist/cjs/v2/TagsComponent.js.map +1 -1
- package/dist/v2/TagsComponent.js +190 -131
- package/dist/v2/TagsComponent.js.map +1 -1
- package/package.json +7 -7
package/dist/.ready
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Built at 2026-09-
|
|
1
|
+
Built at 2026-09-25T08:16:15.538Z
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
5
5
|
var react = require('react');
|
|
6
|
-
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
7
6
|
var lucideReact = require('lucide-react');
|
|
7
|
+
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
8
8
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
9
9
|
var constants = require('@bigbinary/neeto-commons-frontend/v2/constants');
|
|
10
10
|
var utils = require('@bigbinary/neeto-commons-frontend/v2/utils');
|
|
@@ -74,17 +74,22 @@ var Title = function Title(_ref) {
|
|
|
74
74
|
|
|
75
75
|
var TitleActionBlock = function TitleActionBlock(_ref) {
|
|
76
76
|
var isDisabled = _ref.isDisabled,
|
|
77
|
-
setIsTagsDropdownVisible = _ref.setIsTagsDropdownVisible
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
77
|
+
setIsTagsDropdownVisible = _ref.setIsTagsDropdownVisible,
|
|
78
|
+
anchorRef = _ref.anchorRef;
|
|
79
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
80
|
+
className: "inline-flex",
|
|
81
|
+
ref: anchorRef,
|
|
82
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, {
|
|
83
|
+
"data-testid": "neeto-tags-add-tag-button",
|
|
84
|
+
disabled: isDisabled,
|
|
85
|
+
icon: lucideReact.Settings,
|
|
86
|
+
size: "icon-sm",
|
|
87
|
+
variant: "ghost",
|
|
88
|
+
onClick: function onClick(event) {
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
setIsTagsDropdownVisible(ramda.not);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
88
93
|
});
|
|
89
94
|
};
|
|
90
95
|
|
|
@@ -97,7 +102,9 @@ var Container = function Container(_ref) {
|
|
|
97
102
|
titleComponentProps = _ref.titleComponentProps,
|
|
98
103
|
children = _ref.children,
|
|
99
104
|
isTagsBodyVisible = _ref.isTagsBodyVisible,
|
|
100
|
-
bodyProps = _ref.bodyProps
|
|
105
|
+
bodyProps = _ref.bodyProps,
|
|
106
|
+
_ref$isHeaderInteract = _ref.isHeaderInteractive,
|
|
107
|
+
isHeaderInteractive = _ref$isHeaderInteract === void 0 ? true : _ref$isHeaderInteract;
|
|
101
108
|
if (isMetadataBlock) {
|
|
102
109
|
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
103
110
|
className: "space-y-4 rounded-lg border border-border bg-background p-4"
|
|
@@ -111,13 +118,13 @@ var Container = function Container(_ref) {
|
|
|
111
118
|
var isDisabled = actionBlockProps.isDisabled,
|
|
112
119
|
setIsTagsDropdownVisible = actionBlockProps.setIsTagsDropdownVisible;
|
|
113
120
|
var onHeaderClick = function onHeaderClick() {
|
|
114
|
-
!isDisabled && setIsTagsDropdownVisible(ramda.not);
|
|
121
|
+
isHeaderInteractive && !isDisabled && setIsTagsDropdownVisible(ramda.not);
|
|
115
122
|
};
|
|
116
123
|
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread$4(_objectSpread$4({
|
|
117
124
|
className: "flex w-full flex-col items-start gap-2"
|
|
118
125
|
}, containerProps), {}, {
|
|
119
126
|
children: [titleComponentProps.showTitleBar && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
120
|
-
className: classNames("flex w-full
|
|
127
|
+
className: classNames("flex w-full items-center justify-between gap-2 text-foreground", isHeaderInteractive && "cursor-pointer", titleComponentProps.containerClassName),
|
|
121
128
|
onClick: onHeaderClick,
|
|
122
129
|
children: [/*#__PURE__*/jsxRuntime.jsx(Title, _objectSpread$4({}, titleComponentProps)), titleComponentProps.showAddTagsOnTitle && /*#__PURE__*/jsxRuntime.jsx(TitleActionBlock, _objectSpread$4({}, actionBlockProps))]
|
|
123
130
|
}), isTagsBodyVisible && /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$4(_objectSpread$4({
|
|
@@ -140,7 +147,11 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
140
147
|
_ref$buttonProps = _ref.buttonProps,
|
|
141
148
|
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
142
149
|
_ref$isDisabled = _ref.isDisabled,
|
|
143
|
-
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled
|
|
150
|
+
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
151
|
+
dataTestId = _ref.dataTestId,
|
|
152
|
+
anchorRef = _ref.anchorRef,
|
|
153
|
+
_ref$hideTriggerButto = _ref.hideTriggerButton,
|
|
154
|
+
hideTriggerButton = _ref$hideTriggerButto === void 0 ? false : _ref$hideTriggerButto;
|
|
144
155
|
var _useTranslation = reactI18next.useTranslation(),
|
|
145
156
|
t = _useTranslation.t;
|
|
146
157
|
var triggerRef = react.useRef(null);
|
|
@@ -178,12 +189,16 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
178
189
|
var optionId = function optionId(index) {
|
|
179
190
|
return "".concat(listboxId, "-option-").concat(index);
|
|
180
191
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
|
|
193
|
+
// Positioning and focus target the external anchor (the gear) when the
|
|
194
|
+
// in-body trigger button is hidden, otherwise this component's own wrapper.
|
|
195
|
+
var focusTrigger = react.useCallback(function () {
|
|
196
|
+
var _anchor$querySelector;
|
|
197
|
+
var anchor = hideTriggerButton && (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || triggerRef.current;
|
|
198
|
+
anchor === null || anchor === void 0 || (_anchor$querySelector = anchor.querySelector("button")) === null || _anchor$querySelector === void 0 || _anchor$querySelector.focus({
|
|
184
199
|
preventScroll: true
|
|
185
200
|
});
|
|
186
|
-
};
|
|
201
|
+
}, [hideTriggerButton, anchorRef]);
|
|
187
202
|
var close = react.useCallback(function () {
|
|
188
203
|
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
189
204
|
_ref4$restoreFocus = _ref4.restoreFocus,
|
|
@@ -195,7 +210,7 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
195
210
|
// Return focus to the trigger only for keyboard / selection dismissals;
|
|
196
211
|
// an outside click should leave focus wherever the user clicked.
|
|
197
212
|
if (restoreFocus) focusTrigger();
|
|
198
|
-
}, [onOpenChange]);
|
|
213
|
+
}, [onOpenChange, focusTrigger]);
|
|
199
214
|
var handleSelect = function handleSelect(tag) {
|
|
200
215
|
onChange(tag);
|
|
201
216
|
close({
|
|
@@ -239,7 +254,7 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
239
254
|
};
|
|
240
255
|
var updatePosition = react.useCallback(function () {
|
|
241
256
|
var _panelRef$current$off, _panelRef$current;
|
|
242
|
-
var trigger = triggerRef.current;
|
|
257
|
+
var trigger = hideTriggerButton && (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) || triggerRef.current;
|
|
243
258
|
if (!trigger) return;
|
|
244
259
|
var rect = trigger.getBoundingClientRect();
|
|
245
260
|
var panelHeight = (_panelRef$current$off = (_panelRef$current = panelRef.current) === null || _panelRef$current === void 0 ? void 0 : _panelRef$current.offsetHeight) !== null && _panelRef$current$off !== void 0 ? _panelRef$current$off : 0;
|
|
@@ -252,7 +267,7 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
252
267
|
top: top,
|
|
253
268
|
left: left
|
|
254
269
|
});
|
|
255
|
-
}, []);
|
|
270
|
+
}, [hideTriggerButton, anchorRef]);
|
|
256
271
|
|
|
257
272
|
// Position on open and whenever the panel's height changes (list filtering),
|
|
258
273
|
// synchronously before paint so the panel is never seen mispositioned.
|
|
@@ -268,8 +283,12 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
268
283
|
preventScroll: true
|
|
269
284
|
});
|
|
270
285
|
var handleClickOutside = function handleClickOutside(event) {
|
|
271
|
-
var _triggerRef$
|
|
272
|
-
if ((_triggerRef$
|
|
286
|
+
var _triggerRef$current, _anchorRef$current, _panelRef$current3;
|
|
287
|
+
if ((_triggerRef$current = triggerRef.current) !== null && _triggerRef$current !== void 0 && _triggerRef$current.contains(event.target)) return;
|
|
288
|
+
|
|
289
|
+
// Treat the external anchor (the gear) as inside, so its own toggle
|
|
290
|
+
// governs open/close instead of this handler racing it.
|
|
291
|
+
if (anchorRef !== null && anchorRef !== void 0 && (_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && _anchorRef$current.contains(event.target)) return;
|
|
273
292
|
if ((_panelRef$current3 = panelRef.current) !== null && _panelRef$current3 !== void 0 && _panelRef$current3.contains(event.target)) return;
|
|
274
293
|
close();
|
|
275
294
|
};
|
|
@@ -293,10 +312,90 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
293
312
|
if (rafRef.current) window.cancelAnimationFrame(rafRef.current);
|
|
294
313
|
rafRef.current = null;
|
|
295
314
|
};
|
|
296
|
-
}, [open, close, updatePosition]);
|
|
315
|
+
}, [open, close, updatePosition, anchorRef]);
|
|
297
316
|
var optionClassName = function optionClassName(isActive) {
|
|
298
317
|
return classNames("flex w-full cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-start text-sm", isActive ? "bg-accent text-accent-foreground" : "hover:bg-accent");
|
|
299
318
|
};
|
|
319
|
+
var panel = open && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
320
|
+
className: "bg-popover text-popover-foreground border-border fixed z-50 overflow-hidden rounded-md border shadow-md",
|
|
321
|
+
ref: panelRef,
|
|
322
|
+
style: {
|
|
323
|
+
top: (_coords$top = coords === null || coords === void 0 ? void 0 : coords.top) !== null && _coords$top !== void 0 ? _coords$top : 0,
|
|
324
|
+
left: (_coords$left = coords === null || coords === void 0 ? void 0 : coords.left) !== null && _coords$left !== void 0 ? _coords$left : 0,
|
|
325
|
+
width: POPOVER_PANEL_WIDTH,
|
|
326
|
+
visibility: coords ? "visible" : "hidden"
|
|
327
|
+
},
|
|
328
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
329
|
+
className: "border-border border-b p-2",
|
|
330
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
331
|
+
"aria-autocomplete": "list",
|
|
332
|
+
"aria-controls": listboxId,
|
|
333
|
+
"aria-expanded": open,
|
|
334
|
+
"data-testid": dataTestId,
|
|
335
|
+
placeholder: t("neetoTags.placeholder.searchOrCreateTags"),
|
|
336
|
+
prefix: /*#__PURE__*/jsxRuntime.jsx(lucideReact.Search, {
|
|
337
|
+
size: 14
|
|
338
|
+
}),
|
|
339
|
+
role: "combobox",
|
|
340
|
+
size: "small",
|
|
341
|
+
value: query,
|
|
342
|
+
"aria-activedescendant": optionCount > 0 ? optionId(activeIndex) : undefined,
|
|
343
|
+
onChange: handleQueryChange,
|
|
344
|
+
onKeyDown: handleKeyDown
|
|
345
|
+
})
|
|
346
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
347
|
+
className: "max-h-56 overflow-y-auto p-1",
|
|
348
|
+
id: listboxId,
|
|
349
|
+
role: "listbox",
|
|
350
|
+
children: [filteredTags.map(function (tag, index) {
|
|
351
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
352
|
+
"aria-selected": index === activeIndex,
|
|
353
|
+
className: optionClassName(index === activeIndex),
|
|
354
|
+
"data-testid": "".concat(neetoCist.hyphenate(tag.label), "-select-option"),
|
|
355
|
+
id: optionId(index),
|
|
356
|
+
role: "option",
|
|
357
|
+
type: "button",
|
|
358
|
+
onClick: function onClick() {
|
|
359
|
+
return handleSelect(tag);
|
|
360
|
+
},
|
|
361
|
+
onMouseEnter: function onMouseEnter() {
|
|
362
|
+
return setActiveIndex(index);
|
|
363
|
+
},
|
|
364
|
+
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Badge, {
|
|
365
|
+
label: tag.label,
|
|
366
|
+
variant: constants$1.TAG_STYLE_TO_BADGE_VARIANT[tag.style] || "secondary"
|
|
367
|
+
})
|
|
368
|
+
}, tag.value);
|
|
369
|
+
}), canCreate && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
370
|
+
"aria-selected": activeIndex === filteredTags.length,
|
|
371
|
+
className: optionClassName(activeIndex === filteredTags.length),
|
|
372
|
+
"data-testid": "create-new-tag-select-option",
|
|
373
|
+
id: optionId(filteredTags.length),
|
|
374
|
+
role: "option",
|
|
375
|
+
type: "button",
|
|
376
|
+
onClick: handleCreate,
|
|
377
|
+
onMouseEnter: function onMouseEnter() {
|
|
378
|
+
return setActiveIndex(filteredTags.length);
|
|
379
|
+
},
|
|
380
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(lucideReact.Plus, {
|
|
381
|
+
size: 14
|
|
382
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
383
|
+
className: "truncate",
|
|
384
|
+
children: [t("neetoTags.button.createNewTag"), ": ", /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
385
|
+
className: "font-medium",
|
|
386
|
+
children: trimmedQuery
|
|
387
|
+
})]
|
|
388
|
+
})]
|
|
389
|
+
}), optionCount === 0 && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
390
|
+
className: "text-muted-foreground px-2 py-2 text-sm",
|
|
391
|
+
children: t("neetoTags.common.noTagsFound")
|
|
392
|
+
})]
|
|
393
|
+
})]
|
|
394
|
+
}), document.body);
|
|
395
|
+
|
|
396
|
+
// Gear-anchored mode: render only the floating panel (the gear is the
|
|
397
|
+
// trigger), with no in-body wrapper or button of its own.
|
|
398
|
+
if (hideTriggerButton) return panel || null;
|
|
300
399
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
301
400
|
className: "inline-block",
|
|
302
401
|
ref: triggerRef,
|
|
@@ -311,79 +410,7 @@ var PopoverTagsSelector = function PopoverTagsSelector(_ref) {
|
|
|
311
410
|
onClick: function onClick() {
|
|
312
411
|
return onOpenChange(!open);
|
|
313
412
|
}
|
|
314
|
-
}, buttonProps)),
|
|
315
|
-
className: "bg-popover text-popover-foreground border-border fixed z-50 overflow-hidden rounded-md border shadow-md",
|
|
316
|
-
ref: panelRef,
|
|
317
|
-
style: {
|
|
318
|
-
top: (_coords$top = coords === null || coords === void 0 ? void 0 : coords.top) !== null && _coords$top !== void 0 ? _coords$top : 0,
|
|
319
|
-
left: (_coords$left = coords === null || coords === void 0 ? void 0 : coords.left) !== null && _coords$left !== void 0 ? _coords$left : 0,
|
|
320
|
-
width: POPOVER_PANEL_WIDTH,
|
|
321
|
-
visibility: coords ? "visible" : "hidden"
|
|
322
|
-
},
|
|
323
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
324
|
-
className: "border-border border-b p-2",
|
|
325
|
-
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Input, {
|
|
326
|
-
"aria-autocomplete": "list",
|
|
327
|
-
"aria-controls": listboxId,
|
|
328
|
-
"aria-expanded": open,
|
|
329
|
-
placeholder: t("neetoTags.placeholder.searchOrCreateTags"),
|
|
330
|
-
prefix: /*#__PURE__*/jsxRuntime.jsx(lucideReact.Search, {
|
|
331
|
-
size: 14
|
|
332
|
-
}),
|
|
333
|
-
role: "combobox",
|
|
334
|
-
size: "small",
|
|
335
|
-
value: query,
|
|
336
|
-
"aria-activedescendant": optionCount > 0 ? optionId(activeIndex) : undefined,
|
|
337
|
-
onChange: handleQueryChange,
|
|
338
|
-
onKeyDown: handleKeyDown
|
|
339
|
-
})
|
|
340
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
341
|
-
className: "max-h-56 overflow-y-auto p-1",
|
|
342
|
-
id: listboxId,
|
|
343
|
-
role: "listbox",
|
|
344
|
-
children: [filteredTags.map(function (tag, index) {
|
|
345
|
-
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
346
|
-
"aria-selected": index === activeIndex,
|
|
347
|
-
className: optionClassName(index === activeIndex),
|
|
348
|
-
id: optionId(index),
|
|
349
|
-
role: "option",
|
|
350
|
-
type: "button",
|
|
351
|
-
onClick: function onClick() {
|
|
352
|
-
return handleSelect(tag);
|
|
353
|
-
},
|
|
354
|
-
onMouseEnter: function onMouseEnter() {
|
|
355
|
-
return setActiveIndex(index);
|
|
356
|
-
},
|
|
357
|
-
children: /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Badge, {
|
|
358
|
-
label: tag.label,
|
|
359
|
-
variant: constants$1.TAG_STYLE_TO_BADGE_VARIANT[tag.style] || "secondary"
|
|
360
|
-
})
|
|
361
|
-
}, tag.value);
|
|
362
|
-
}), canCreate && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
363
|
-
"aria-selected": activeIndex === filteredTags.length,
|
|
364
|
-
id: optionId(filteredTags.length),
|
|
365
|
-
role: "option",
|
|
366
|
-
type: "button",
|
|
367
|
-
className: optionClassName(activeIndex === filteredTags.length),
|
|
368
|
-
onClick: handleCreate,
|
|
369
|
-
onMouseEnter: function onMouseEnter() {
|
|
370
|
-
return setActiveIndex(filteredTags.length);
|
|
371
|
-
},
|
|
372
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(lucideReact.Plus, {
|
|
373
|
-
size: 14
|
|
374
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
375
|
-
className: "truncate",
|
|
376
|
-
children: [t("neetoTags.button.createNewTag"), ": ", /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
377
|
-
className: "font-medium",
|
|
378
|
-
children: trimmedQuery
|
|
379
|
-
})]
|
|
380
|
-
})]
|
|
381
|
-
}), optionCount === 0 && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
382
|
-
className: "text-muted-foreground px-2 py-2 text-sm",
|
|
383
|
-
children: t("neetoTags.common.noTagsFound")
|
|
384
|
-
})]
|
|
385
|
-
})]
|
|
386
|
-
}), document.body)]
|
|
413
|
+
}, buttonProps)), panel]
|
|
387
414
|
});
|
|
388
415
|
};
|
|
389
416
|
|
|
@@ -466,6 +493,7 @@ var TagsSelector = function TagsSelector(_ref) {
|
|
|
466
493
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
467
494
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
468
495
|
var Tags = function Tags(_ref) {
|
|
496
|
+
var _ref3;
|
|
469
497
|
var _ref$title = _ref.title,
|
|
470
498
|
title = _ref$title === void 0 ? "" : _ref$title,
|
|
471
499
|
allTags = _ref.allTags,
|
|
@@ -497,14 +525,19 @@ var Tags = function Tags(_ref) {
|
|
|
497
525
|
_ref$isMetadataBlock = _ref.isMetadataBlock,
|
|
498
526
|
isMetadataBlock = _ref$isMetadataBlock === void 0 ? false : _ref$isMetadataBlock,
|
|
499
527
|
_ref$pickerVariant = _ref.pickerVariant,
|
|
500
|
-
pickerVariant = _ref$pickerVariant === void 0 ? "
|
|
528
|
+
pickerVariant = _ref$pickerVariant === void 0 ? "popover" : _ref$pickerVariant,
|
|
529
|
+
dataTestId = _ref.dataTestId;
|
|
501
530
|
var _useTranslation = reactI18next.useTranslation(),
|
|
502
531
|
t = _useTranslation.t;
|
|
503
532
|
var _useState = react.useState(false),
|
|
504
533
|
_useState2 = _slicedToArray(_useState, 2),
|
|
505
534
|
isTagsDropdownVisible = _useState2[0],
|
|
506
535
|
setIsTagsDropdownVisible = _useState2[1];
|
|
536
|
+
|
|
537
|
+
// The title-bar/metadata settings gear, used as the popover's trigger anchor.
|
|
538
|
+
var gearAnchorRef = react.useRef(null);
|
|
507
539
|
useHotkeys(KEYBOARD_SHORTCUTS.addTag.sequence, function (event) {
|
|
540
|
+
if (isDisabled) return;
|
|
508
541
|
event.preventDefault();
|
|
509
542
|
setIsTagsDropdownVisible(true);
|
|
510
543
|
});
|
|
@@ -532,9 +565,24 @@ var Tags = function Tags(_ref) {
|
|
|
532
565
|
setIsTagsDropdownVisible(false);
|
|
533
566
|
onTagCreate(tagName);
|
|
534
567
|
};
|
|
568
|
+
|
|
569
|
+
// Fall back to a `dataTestId` carried on `selectProps` so consumers that only
|
|
570
|
+
// targeted the inline select can keep addressing the picker after the popover
|
|
571
|
+
// default. Accept both the camelCase key and the kebab-case `data-testid`
|
|
572
|
+
// React prop key, since consumers use either.
|
|
573
|
+
var resolvedDataTestId = (_ref3 = dataTestId !== null && dataTestId !== void 0 ? dataTestId : selectProps.dataTestId) !== null && _ref3 !== void 0 ? _ref3 : selectProps["data-testid"];
|
|
535
574
|
var isPopoverPicker = pickerVariant === "popover";
|
|
536
|
-
|
|
537
|
-
|
|
575
|
+
// A settings gear in the title bar (always shown in a metadata block) acts as
|
|
576
|
+
// the popover's trigger and positioning anchor. When present, the popover
|
|
577
|
+
// drops its own in-body "Add tag" button and opens directly below the gear.
|
|
578
|
+
var hasTitleGear = isMetadataBlock || showTitleBar && showAddTagsOnTitle;
|
|
579
|
+
var isGearAnchoredPopover = isPopoverPicker && hasTitleGear;
|
|
580
|
+
// Without a gear to anchor to, the popover renders its own in-body "Add tag"
|
|
581
|
+
// button as the trigger (kept permanently visible so there is always an
|
|
582
|
+
// anchor), e.g. when `showAddTagsOnTitle` is false or the title bar is hidden.
|
|
583
|
+
var isInBodyPopoverPicker = isPopoverPicker && !hasTitleGear;
|
|
584
|
+
var isAddTagsButtonVisible = !isPopoverPicker && !showAddTagsOnTitle && !isTagsDropdownVisible;
|
|
585
|
+
var isTagsBodyVisible = neetoCist.isNotEmpty(selectedTags) || !isPopoverPicker && isTagsDropdownVisible || isAddTagsButtonVisible || isInBodyPopoverPicker;
|
|
538
586
|
var titleComponentProps = {
|
|
539
587
|
isLoading: isLoading,
|
|
540
588
|
isUpdating: isUpdating,
|
|
@@ -545,7 +593,8 @@ var Tags = function Tags(_ref) {
|
|
|
545
593
|
};
|
|
546
594
|
var actionBlockProps = {
|
|
547
595
|
isDisabled: isDisabled,
|
|
548
|
-
setIsTagsDropdownVisible: setIsTagsDropdownVisible
|
|
596
|
+
setIsTagsDropdownVisible: setIsTagsDropdownVisible,
|
|
597
|
+
anchorRef: isGearAnchoredPopover ? gearAnchorRef : undefined
|
|
549
598
|
};
|
|
550
599
|
var tagsListProps = {
|
|
551
600
|
handleDeleteTag: handleDeleteTag,
|
|
@@ -560,33 +609,43 @@ var Tags = function Tags(_ref) {
|
|
|
560
609
|
onCreateOption: handleCreateTag,
|
|
561
610
|
selectProps: selectProps
|
|
562
611
|
};
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
612
|
+
var popoverTagsSelectorProps = {
|
|
613
|
+
buttonProps: buttonProps,
|
|
614
|
+
isDisabled: isDisabled,
|
|
615
|
+
tags: tags,
|
|
616
|
+
dataTestId: resolvedDataTestId,
|
|
617
|
+
open: isTagsDropdownVisible,
|
|
618
|
+
onChange: handleAddExistingTag,
|
|
619
|
+
onCreateOption: handleCreateTag,
|
|
620
|
+
onOpenChange: setIsTagsDropdownVisible
|
|
621
|
+
};
|
|
622
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
623
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Container, {
|
|
624
|
+
actionBlockProps: actionBlockProps,
|
|
625
|
+
bodyProps: bodyProps,
|
|
626
|
+
containerProps: containerProps,
|
|
627
|
+
isMetadataBlock: isMetadataBlock,
|
|
628
|
+
isTagsBodyVisible: isTagsBodyVisible,
|
|
629
|
+
titleComponentProps: titleComponentProps,
|
|
630
|
+
// The gear is the popover's sole trigger; letting the header row toggle
|
|
631
|
+
// too would race the panel's outside-click close and reopen it.
|
|
632
|
+
isHeaderInteractive: !isGearAnchoredPopover,
|
|
633
|
+
children: [neetoCist.isNotEmpty(selectedTags) && /*#__PURE__*/jsxRuntime.jsx(TagsList, _objectSpread({}, tagsListProps)), isInBodyPopoverPicker && /*#__PURE__*/jsxRuntime.jsx(PopoverTagsSelector, _objectSpread({}, popoverTagsSelectorProps)), !isPopoverPicker && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
634
|
+
children: [isTagsDropdownVisible && /*#__PURE__*/jsxRuntime.jsx(TagsSelector, _objectSpread({}, tagsSelectorProps)), isAddTagsButtonVisible && /*#__PURE__*/jsxRuntime.jsx(neetoAtoms.Button, _objectSpread({
|
|
635
|
+
disabled: isDisabled,
|
|
636
|
+
icon: lucideReact.Plus,
|
|
637
|
+
label: t("neetoTags.button.addTag", constants.SINGULAR),
|
|
638
|
+
size: "sm",
|
|
639
|
+
variant: "link",
|
|
640
|
+
onClick: function onClick() {
|
|
641
|
+
return setIsTagsDropdownVisible(true);
|
|
642
|
+
}
|
|
643
|
+
}, buttonProps))]
|
|
644
|
+
})]
|
|
645
|
+
}), isGearAnchoredPopover && /*#__PURE__*/jsxRuntime.jsx(PopoverTagsSelector, _objectSpread(_objectSpread({}, popoverTagsSelectorProps), {}, {
|
|
646
|
+
hideTriggerButton: true,
|
|
647
|
+
anchorRef: gearAnchorRef
|
|
648
|
+
}))]
|
|
590
649
|
});
|
|
591
650
|
};
|
|
592
651
|
|