@topconsultnpm/sdkui-react 6.22.0-dev3.13 → 6.22.0-dev3.14
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.
|
@@ -21,6 +21,8 @@ export interface TMTabPanelProps {
|
|
|
21
21
|
closable?: boolean;
|
|
22
22
|
/** Se false disabilita la rinomina su questo tab. Default true. */
|
|
23
23
|
renamable?: boolean;
|
|
24
|
+
/** Se false il tab non si trascina e non accetta il rilascio di altri: resta al suo posto. Default true. */
|
|
25
|
+
movable?: boolean;
|
|
24
26
|
children?: React.ReactNode;
|
|
25
27
|
}
|
|
26
28
|
/** Contenitore dichiarativo di un tab: figlio diretto di TMTabControl, non renderizza nulla di suo. */
|
|
@@ -70,6 +72,9 @@ export interface TMTabControlProps {
|
|
|
70
72
|
contentStyle?: React.CSSProperties;
|
|
71
73
|
/** Stile del contenitore esterno. */
|
|
72
74
|
style?: React.CSSProperties;
|
|
75
|
+
/** Contenuto del chiamante in coda alla barra, a destra dei tab: es. i pulsanti di azione della pagina.
|
|
76
|
+
Fa parte della barra, quindi con hideBarWhenSingle e un solo tab non viene mostrato. */
|
|
77
|
+
toolbar?: React.ReactNode;
|
|
73
78
|
children: React.ReactNode;
|
|
74
79
|
}
|
|
75
80
|
declare const TMTabControl: React.FC<TMTabControlProps>;
|
|
@@ -18,10 +18,11 @@ import { getAppModuleButtonColors, getAppModuleGradient, IconAdd, IconCloseOutli
|
|
|
18
18
|
// I tab non attivi restano sempre montati e solo spostati fuori schermo: nulla si ricarica ne perde stato.
|
|
19
19
|
// onTabClose -> mostra la 'x' sui tab e la voce Chiudi nel menu contestuale.
|
|
20
20
|
// onTabRename -> doppio clic (o voce Rinomina) per modificare il titolo in linea.
|
|
21
|
-
// onTabReorder -> tab spostabili con il trascinamento.
|
|
21
|
+
// onTabReorder -> tab spostabili con il trascinamento; il singolo tab si blocca con movable={false}.
|
|
22
22
|
// tabMenuItems -> voci del chiamante nel menu del tasto destro sul tab, prima di Rinomina e Chiudi.
|
|
23
23
|
// contentAnimation -> effetto del contenuto al cambio tab: 'fade' (default), 'slide', 'zoom' o 'none'.
|
|
24
24
|
// swipeEnabled -> su touch si cambia tab trascinando il contenuto di lato.
|
|
25
|
+
// toolbar -> contenuto del chiamante in coda alla barra, a destra dei tab (azioni di pagina).
|
|
25
26
|
//
|
|
26
27
|
// Da tastiera, con il focus sulla barra: frecce destra/giu al tab successivo, sinistra/su al precedente,
|
|
27
28
|
// Home ed End al primo e all'ultimo. I tab disabilitati vengono saltati.
|
|
@@ -90,7 +91,7 @@ const VARIANTS = {
|
|
|
90
91
|
joins: false
|
|
91
92
|
})
|
|
92
93
|
};
|
|
93
|
-
/** Contenitore della barra: frecce ai lati
|
|
94
|
+
/** Contenitore della barra: frecce ai lati, striscia dei tab in mezzo ed eventuale toolbar in coda. */
|
|
94
95
|
const TabsHeader = styled.div `
|
|
95
96
|
display: flex;
|
|
96
97
|
align-items: flex-end;
|
|
@@ -152,6 +153,16 @@ const AddButton = styled.button `
|
|
|
152
153
|
&:active { background: ${({ $v }) => $v.buttonActive}; }
|
|
153
154
|
&:focus, &:focus-visible { outline: none; }
|
|
154
155
|
`;
|
|
156
|
+
/** Contenuto libero del chiamante in coda alla barra: azioni di pagina allineate a destra dei tab.
|
|
157
|
+
E' position: relative cosi un menu a tendina del chiamante puo posizionarsi rispetto a quest'area. */
|
|
158
|
+
const TabsToolbar = styled.div `
|
|
159
|
+
display: flex;
|
|
160
|
+
align-items: center;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
margin-bottom: 3px;
|
|
163
|
+
padding-left: 8px;
|
|
164
|
+
position: relative;
|
|
165
|
+
`;
|
|
155
166
|
/** Area del contenuto: fa da riferimento ai pannelli nascosti, che restano montati ma non impaginati. */
|
|
156
167
|
const ContentArea = styled.div `
|
|
157
168
|
position: relative;
|
|
@@ -341,7 +352,7 @@ const shortenLabel = (label) => {
|
|
|
341
352
|
/** Contenitore dichiarativo di un tab: figlio diretto di TMTabControl, non renderizza nulla di suo. */
|
|
342
353
|
export const TMTabPanel = ({ children }) => _jsx(_Fragment, { children: children });
|
|
343
354
|
const TMTabControl = (props) => {
|
|
344
|
-
const { selectedId, defaultSelectedId, onSelectedIdChange, hideBarWhenSingle = false, onTabClose, closableWhenSingle = false, onTabRename, onTabReorder, onTabAdd, tabMenuItems, addCaption = SDKUI_Localizator.AddTab, renameCaption = SDKUI_Localizator.Rename, closeCaption = SDKUI_Localizator.Close, closeOtherCaption = SDKUI_Localizator.CloseOtherTabs, variant = 'module', textColor, idleTextColor, contentAnimation = 'none', animationDuration = 300, swipeEnabled = true, contentStyle, style, children } = props;
|
|
355
|
+
const { selectedId, defaultSelectedId, onSelectedIdChange, hideBarWhenSingle = false, onTabClose, closableWhenSingle = false, onTabRename, onTabReorder, onTabAdd, tabMenuItems, addCaption = SDKUI_Localizator.AddTab, renameCaption = SDKUI_Localizator.Rename, closeCaption = SDKUI_Localizator.Close, closeOtherCaption = SDKUI_Localizator.CloseOtherTabs, variant = 'module', textColor, idleTextColor, contentAnimation = 'none', animationDuration = 300, swipeEnabled = true, contentStyle, style, toolbar, children } = props;
|
|
345
356
|
const v = useMemo(() => VARIANTS[variant](), [variant]);
|
|
346
357
|
const titleColor = textColor ?? v.textColor;
|
|
347
358
|
const titleIdleColor = idleTextColor ?? v.idleTextColor;
|
|
@@ -578,11 +589,11 @@ const TMTabControl = (props) => {
|
|
|
578
589
|
tabIndex: isActive ? 0 : -1,
|
|
579
590
|
// Con il titolo accorciato il nome per esteso lo mostra gia il tooltip
|
|
580
591
|
title: canRename && !shortLabel ? 'Doppio clic per rinominare' : undefined, $active: isActive, $textColor: titleColor, $idleColor: titleIdleColor, disabled: p.props.disabled, onClick: () => handleSelect(p.props.id), onDoubleClick: () => canRename && setEditingId(p.props.id), children: [shortLabel ?? p.props.label, (p.props.badge ?? 0) > 0 && _jsx(TabBadge, { $color: p.props.badgeColor ?? '#E53935', children: p.props.badge })] }));
|
|
581
|
-
return (_jsxs(React.Fragment, { children: [showSeparator && _jsx(TabSeparator, { $v: v }), _jsxs(TabItem, { "data-tab-id": p.props.id, $v: v, $active: isActive, $dragging: dragId === p.props.id, draggable: !!onTabReorder && editingId !== p.props.id,
|
|
592
|
+
return (_jsxs(React.Fragment, { children: [showSeparator && _jsx(TabSeparator, { $v: v }), _jsxs(TabItem, { "data-tab-id": p.props.id, $v: v, $active: isActive, $dragging: dragId === p.props.id, draggable: !!onTabReorder && p.props.movable !== false && editingId !== p.props.id,
|
|
582
593
|
// Tipo MIME privato invece di 'text/plain': il tab non e rilasciabile fuori dalla barra
|
|
583
594
|
// (barra indirizzi, campi di ricerca, altre applicazioni) scrivendoci dentro il suo id
|
|
584
|
-
onDragStart: (e) => { setDragId(p.props.id); e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData(TAB_DRAG_MIME, p.props.id); }, onDragOver: (e) => { if (!dragId || dragId === p.props.id)
|
|
585
|
-
return; e.preventDefault(); e.dataTransfer.dropEffect = 'move'; setDropId(p.props.id); }, onDragLeave: () => setDropId(prev => prev === p.props.id ? undefined : prev), onDrop: (e) => { e.preventDefault(); if (dragId && dragId !== p.props.id)
|
|
595
|
+
onDragStart: (e) => { setDragId(p.props.id); e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData(TAB_DRAG_MIME, p.props.id); }, onDragOver: (e) => { if (!dragId || dragId === p.props.id || p.props.movable === false)
|
|
596
|
+
return; e.preventDefault(); e.dataTransfer.dropEffect = 'move'; setDropId(p.props.id); }, onDragLeave: () => setDropId(prev => prev === p.props.id ? undefined : prev), onDrop: (e) => { e.preventDefault(); if (dragId && dragId !== p.props.id && p.props.movable !== false)
|
|
586
597
|
onTabReorder?.(dragId, p.props.id); setDragId(undefined); setDropId(undefined); }, onDragEnd: () => { setDragId(undefined); setDropId(undefined); }, onContextMenu: (e) => openMenu(e, p.props.id), children: [editingId === p.props.id
|
|
587
598
|
// In rinomina: Invio conferma, Esc annulla, uscendo dal campo si conferma
|
|
588
599
|
? _jsx(RenameInput, { autoFocus: true, defaultValue: String(p.props.label), onFocus: (e) => e.currentTarget.select(), onBlur: (e) => commitRename(p.props.id, e.currentTarget.value), onKeyDown: (e) => {
|
|
@@ -595,7 +606,7 @@ const TMTabControl = (props) => {
|
|
|
595
606
|
// width: auto annulla il max-content del tooltip, che impedirebbe al titolo di restringersi
|
|
596
607
|
? _jsx(TMTooltip, { content: labelText, parentStyle: { display: 'flex', minWidth: 0 }, childStyle: { width: 'auto', minWidth: 0 }, children: tabButton })
|
|
597
608
|
: tabButton, canClose && _jsx(CloseButton, { $color: isActive ? v.textColor : v.idleTextColor, type: 'button', tabIndex: isActive ? 0 : -1, title: closeCaption, onClick: () => onTabClose?.(p.props.id), children: "\u00D7" }), isDropTarget && _jsx(DropMark, { $side: draggedIndex > index ? 'left' : 'right' })] })] }, p.props.id));
|
|
598
|
-
}), onTabAdd && _jsx(AddButton, { $v: v, type: 'button', title: addCaption, onClick: onTabAdd, children: _jsx(IconAdd, { fontSize: 18 }) })] }), arrows.right && _jsx(NavButton, { $v: v, type: 'button', tabIndex: -1, onClick: () => scrollTabs(1), children: _jsx(IconRight, { fontSize: 18 }) })] }), menu.visible && menuItems.length > 0 &&
|
|
609
|
+
}), onTabAdd && _jsx(AddButton, { $v: v, type: 'button', title: addCaption, onClick: onTabAdd, children: _jsx(IconAdd, { fontSize: 18 }) })] }), arrows.right && _jsx(NavButton, { $v: v, type: 'button', tabIndex: -1, onClick: () => scrollTabs(1), children: _jsx(IconRight, { fontSize: 18 }) }), toolbar && _jsx(TabsToolbar, { children: toolbar })] }), menu.visible && menuItems.length > 0 &&
|
|
599
610
|
_jsx(TMContextMenu, { items: menuItems, externalControl: { visible: menu.visible, position: menu.position, onClose: closeMenu } }), _jsx(ContentArea, { onTouchStart: handleTouchStart, onTouchEnd: handleTouchEnd, children: mountedPanels.map(p => {
|
|
600
611
|
const isActive = p.props.id === activeId;
|
|
601
612
|
return (_jsx(ContentPane, { role: 'tabpanel', "aria-hidden": !isActive, $active: isActive, $anim: animation, $duration: animationDuration, $phase: animPhase,
|