@nova-design-system/nova-react 3.22.0 → 3.24.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/cjs/_commonjsHelpers-B85MJLTf-CFO10eej.js +7 -0
- package/dist/cjs/{collapse.animation-6e0b08df-AHWzNGm_.js → collapse.animation-DZDm0vSK-C2TOIhIK.js} +3 -3
- package/dist/cjs/events.utils-B6GgGra--01N__3wY.js +23 -0
- package/dist/cjs/{fade.animation-9b939939-DV--bM4S.js → fade.animation-DcRL9lcm-DAZeHoKN.js} +75 -75
- package/dist/cjs/generated/components.server.js +292 -50
- package/dist/cjs/{grow.animation-24ad5cf8-LUp_ITEx.js → grow.animation-D7ep_aVl-BuXEDSK-.js} +5 -26
- package/dist/cjs/i18n.utils-IlwlcG9l-ku0bScip.js +2494 -0
- package/dist/cjs/{index-WPRkQD3O.js → index-kU2nW5aN.js} +12692 -7009
- package/dist/cjs/{nv-dialog.entry-CDSK9pUH.js → index.esm-D3eWMME9-CG1TVKfu.js} +1 -296
- package/dist/cjs/index.js +15 -1
- package/dist/cjs/inputmask-CSo292ul-DlvupPk6.js +3758 -0
- package/dist/cjs/{nv-accordion-item.entry-BuTvA6w9.js → nv-accordion-item.entry-Bu1tAcCq.js} +11 -10
- package/dist/cjs/{nv-accordion.entry-Dtsfw6He.js → nv-accordion.entry-jWjLdX8w.js} +9 -11
- package/dist/cjs/{nv-alert.entry-TIdfdU7Y.js → nv-alert.entry-E9ZJay_K.js} +22 -23
- package/dist/cjs/{nv-avatar.entry-CaxrhPuw.js → nv-avatar.entry-CUX7u0kR.js} +11 -11
- package/dist/cjs/{nv-badge_2.entry-CfYvTZxX.js → nv-badge_2.entry-bxpV5gxE.js} +24 -24
- package/dist/cjs/{nv-breadcrumb.entry-BCZ4MmfD.js → nv-breadcrumb.entry-Cbbb9Qeh.js} +5 -5
- package/dist/cjs/{nv-breadcrumbs.entry-DwzCE7F6.js → nv-breadcrumbs.entry-BTqnp9zO.js} +3 -3
- package/dist/cjs/{nv-button.entry-Cr_86bcZ.js → nv-button.entry-upWH19y6.js} +12 -14
- package/dist/cjs/{nv-buttongroup.entry-CWjRoHY1.js → nv-buttongroup.entry-CuZCRsnV.js} +3 -3
- package/dist/cjs/{nv-calendar.entry-CXfwNt6G.js → nv-calendar.entry-CT3mASW6.js} +113 -97
- package/dist/cjs/{nv-col.entry-CJLDS3LY.js → nv-col.entry--pCxkaTh.js} +5 -5
- package/dist/cjs/{nv-datagrid.entry-Cns8XSud.js → nv-datagrid.entry-CGCEhO8C.js} +80 -85
- package/dist/cjs/{nv-datagridcolumn.entry-CFFAipHF.js → nv-datagridcolumn.entry-Fsqc7CT_.js} +2 -1
- package/dist/cjs/nv-dialog.entry-B6OYcZxQ.js +300 -0
- package/dist/cjs/{nv-dialogfooter_2.entry-To_dGUn4.js → nv-dialogfooter_2.entry-C4fP_n2-.js} +10 -11
- package/dist/cjs/nv-drawer.entry-C5O4KvHU.js +445 -0
- package/dist/cjs/nv-drawerfooter_2.entry-C-reYJXG.js +146 -0
- package/dist/cjs/nv-fieldcheckbox.entry-bk7UNQny.js +177 -0
- package/dist/cjs/{nv-fielddate.entry-C3pXtMHL.js → nv-fielddate.entry-dqZDBVmm.js} +89 -46
- package/dist/cjs/{nv-fielddaterange.entry-CjVVPEK_.js → nv-fielddaterange.entry-wNRasXky.js} +151 -103
- package/dist/cjs/nv-fielddropdown.entry-BA15piWa.js +678 -0
- package/dist/cjs/{nv-fielddropdownitem.entry-Dah-PaE8.js → nv-fielddropdownitem.entry-DEWaf9dC.js} +7 -7
- package/dist/cjs/{nv-fieldmultiselect.entry-BMLjhqoJ.js → nv-fieldmultiselect.entry-BWY5xOAd.js} +343 -236
- package/dist/cjs/nv-fieldnumber.entry-DoYORd0d.js +187 -0
- package/dist/cjs/nv-fieldpassword.entry-CPaLj9aD.js +165 -0
- package/dist/cjs/{nv-fieldradio.entry-X_2VT1Dj.js → nv-fieldradio.entry-CvUmEaCa.js} +11 -11
- package/dist/cjs/{nv-fieldselect.entry-pSp-2rNn.js → nv-fieldselect.entry-uUIZ6hmN.js} +52 -13
- package/dist/cjs/{nv-fieldslider.entry-pZf7zzLU.js → nv-fieldslider.entry-DnvmxxYY.js} +16 -31
- package/dist/cjs/nv-fieldtext.entry-BYAJp3n_.js +163 -0
- package/dist/cjs/{nv-fieldtextarea.entry-t3Ixxi23.js → nv-fieldtextarea.entry-DU2bWYeg.js} +52 -14
- package/dist/cjs/{nv-fieldtime.entry-DY7D5_6K.js → nv-fieldtime.entry-DlMNDTht.js} +128 -84
- package/dist/cjs/{nv-icon.entry-6oYPSf4c.js → nv-icon.entry-CnUkRzaA.js} +12 -12
- package/dist/cjs/{nv-iconbutton_2.entry-ChULGovr.js → nv-iconbutton_2.entry-hqp4AcRq.js} +10 -12
- package/dist/cjs/{nv-menu.entry-sd0tatWq.js → nv-menu.entry-Dc_FvIx7.js} +18 -32
- package/dist/cjs/{nv-menuitem.entry-CCOqR7UF.js → nv-menuitem.entry-DzMhx6c_.js} +6 -5
- package/dist/cjs/nv-notification-bullet.entry-BwhHCMQF.js +76 -0
- package/dist/cjs/{nv-notification.entry-Cc3zE3yY.js → nv-notification.entry-C3m5p5BL.js} +42 -128
- package/dist/cjs/{nv-notificationcontainer.entry-DV4D6oOH.js → nv-notificationcontainer.entry-DTRNn7VE.js} +4 -4
- package/dist/cjs/{nv-popover.entry-DQSwI2jT.js → nv-popover.entry-B0c-2rO4.js} +51 -47
- package/dist/cjs/{nv-row.entry-UUuMSAY5.js → nv-row.entry-CdcjVGZv.js} +4 -4
- package/dist/cjs/nv-sidebar.entry-CiN813gQ.js +177 -0
- package/dist/cjs/nv-sidebarcontent.entry-D9hpAhK8.js +22 -0
- package/dist/cjs/nv-sidebardivider.entry-B4EMyca5.js +22 -0
- package/dist/cjs/nv-sidebarfooter.entry-CHi4qOFe.js +22 -0
- package/dist/cjs/nv-sidebargroup.entry-RVqrsyIU.js +23 -0
- package/dist/cjs/nv-sidebarheader.entry-_7ch0O3G.js +22 -0
- package/dist/cjs/nv-sidebarlogo.entry-Ch9F-JnT.js +32 -0
- package/dist/cjs/nv-sidebarnavitem.entry-DVrafSMr.js +296 -0
- package/dist/cjs/nv-sidebarnavsubitem.entry-C0XDAzma.js +35 -0
- package/dist/cjs/{nv-split.entry-CYP2bTTM.js → nv-split.entry-0HTslRAX.js} +47 -45
- package/dist/cjs/{nv-stack.entry-D35-75Vw.js → nv-stack.entry-CqO7uTQf.js} +5 -5
- package/dist/cjs/{nv-table.entry-DevWJBnL.js → nv-table.entry-DH85n8Mc.js} +9 -11
- package/dist/cjs/{nv-tableheader.entry-Hs7nUSOC.js → nv-tableheader.entry-CKfocdxD.js} +7 -7
- package/dist/cjs/{nv-toggle.entry-Eje9d--6.js → nv-toggle.entry-BHUl76Im.js} +9 -9
- package/dist/cjs/nv-togglebutton.entry-D_9COjY-.js +67 -0
- package/dist/cjs/{nv-togglebuttongroup.entry-CWN_Ucry.js → nv-togglebuttongroup.entry-C0NLbsq7.js} +10 -8
- package/dist/cjs/{nv-tooltip.entry-BGkKDEFg.js → nv-tooltip.entry-BfViGE_U.js} +5 -5
- package/dist/cjs/slide.animation-CmH5d1of-BZuw607U.js +90 -0
- package/dist/cjs/{style-value-types.es-f5d10b79-D0QCM8OB.js → style-value-types.es-xlgmw4x8-B1vLqX9m.js} +6 -3
- package/dist/cjs/{v4-a79185f4-2n0dOd_Y.js → v4-BdYh22OP-C1vaJ4yP.js} +1 -1
- package/dist/components/NvDatatable/NvDatatable.js +40 -24
- package/dist/generated/components.js +107 -0
- package/dist/generated/components.server.js +260 -50
- package/dist/providers/NotificationProvider.js +3 -4
- package/dist/types/components/NvDatatable/NvDatatable.d.ts +1 -1
- package/dist/types/components/NvDatatable/types.d.ts +8 -3
- package/dist/types/generated/components.d.ts +46 -0
- package/dist/types/generated/components.server.d.ts +46 -0
- package/package.json +2 -2
- package/dist/cjs/_commonjsHelpers-1789f0cf-BJu3ubxk.js +0 -10
- package/dist/cjs/inputmask-edcad3c1-B9Omti4z.js +0 -3749
- package/dist/cjs/nv-fieldcheckbox.entry-fdonR07Z.js +0 -138
- package/dist/cjs/nv-fielddropdown.entry-C9mXuNNj.js +0 -392
- package/dist/cjs/nv-fieldnumber.entry-DBdJviXu.js +0 -148
- package/dist/cjs/nv-fieldpassword.entry-Cim_usSM.js +0 -122
- package/dist/cjs/nv-fieldtext.entry-DlI_ExaV.js +0 -124
- package/dist/cjs/nv-togglebutton.entry-LGI7pIeK.js +0 -56
- /package/dist/cjs/{clsx-297c1ffe-BtxeOLZW.js → clsx-ChV9xqsO-BtxeOLZW.js} +0 -0
- /package/dist/cjs/{constants-69bafca2-DpB_ghPF.js → constants-BReL3Lsa-DpB_ghPF.js} +0 -0
- /package/dist/cjs/{timeline.animation-79215cd4-KteJaZPb.js → timeline.animation-CgHCo_Ho-KteJaZPb.js} +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-kU2nW5aN.js');
|
|
4
|
+
require('@stencil/react-output-target/runtime');
|
|
5
|
+
require('react');
|
|
6
|
+
require('react-dom');
|
|
7
|
+
|
|
8
|
+
const nvSidebarnavitemCss = "nv-sidebarnavitem{display:flex;flex-direction:column;gap:0}nv-sidebarnavitem .nv-sidebarnavitem-trigger{display:flex;align-items:center;gap:var(--sidebar-item-gap-x);padding:var(--sidebar-item-padding-y) var(--sidebar-item-padding-x);border-radius:var(--sidebar-item-radius);cursor:pointer;transition:all 0.15s ease;font-size:var(--sidebar-item-font-size);font-weight:var(--font-weight-medium-emphasis);color:var(--color-content-low-text);background:var(--components-sidebar-background);text-decoration:none;--nv-component-background:var(--components-sidebar-background);--nv-sidebarnavitem-background:var(--components-sidebar-background)}nv-sidebarnavitem .nv-sidebarnavitem-trigger:hover{background-color:var(--color-interaction-container-neutral-background-hover);color:var(--color-content-medium-text);--nv-component-background:var(--color-interaction-container-neutral-background-hover);--nv-sidebarnavitem-background:var(--color-interaction-container-neutral-background-hover)}nv-sidebarnavitem .nv-sidebarnavitem-trigger:focus,nv-sidebarnavitem .nv-sidebarnavitem-trigger:focus-within{outline:none}nv-sidebarnavitem .nv-sidebarnavitem-trigger:focus-visible,nv-sidebarnavitem .nv-sidebarnavitem-trigger:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--color-focus-brand);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-sidebarnavitem[active] .nv-sidebarnavitem-trigger{background-color:var(--color-interaction-container-neutral-background-active);color:var(--color-interaction-container-neutral-text-active);font-weight:var(--font-weight-medium-emphasis);--nv-component-background:var(--color-interaction-container-neutral-background-active);--nv-sidebarnavitem-background:var(--color-interaction-container-neutral-background-active)}nv-sidebarnavitem .nv-sidebarnavitem-icon{display:flex;align-items:center;justify-content:center;flex-shrink:0;color:inherit;width:var(--sidebar-item-icon-size);height:var(--sidebar-item-icon-size);position:relative}nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-icon{overflow:visible;margin:0;justify-content:center}nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-icon nv-notification-bullet{position:absolute;transform:translate(50%, -50%);z-index:1;--sidebar-notification-bullet-size-reduced:calc(\n var(--sidebar-item-icon-size) * 0.4\n )}nv-sidebarnavitem .nv-sidebarnavitem-content{flex:1;display:flex;align-items:center}nv-sidebarnavitem .nv-sidebarnavitem-content a{color:inherit !important;text-decoration:none !important;font-weight:var(--font-weight-medium-emphasis) !important;flex:1}nv-sidebarnavitem .nv-sidebarnavitem-trailing{display:flex;align-items:center;gap:var(--spacing-2);margin-left:auto}nv-sidebarnavitem .nv-sidebarnavitem-chevron{transition:transform 0.2s ease;color:inherit}nv-sidebarnavitem[open] .nv-sidebarnavitem-chevron{transform:rotate(180deg)}nv-sidebarnavitem .nv-sidebarnavitem-subitems{display:flex;flex-direction:column;gap:0;max-height:0;overflow:hidden;opacity:0;transition:max-height 0.3s ease, opacity 0.2s ease;padding-left:0}nv-sidebarnavitem[open] .nv-sidebarnavitem-subitems{opacity:1;margin-top:var(--spacing-1)}nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-trigger{justify-content:center;gap:0;padding:var(--sidebar-item-padding-y-collapsed) var(--sidebar-item-padding-x-collapsed)}nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-content{display:none}nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-trailing,nv-sidebar[collapsed] nv-sidebarnavitem .nv-sidebarnavitem-chevron{display:none}";
|
|
9
|
+
|
|
10
|
+
const NvSidebarnavitem = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
/**
|
|
14
|
+
* Whether this item represents the active/current page.
|
|
15
|
+
* Can be set automatically when a sub-item becomes active.
|
|
16
|
+
*/
|
|
17
|
+
this.active = false;
|
|
18
|
+
/**
|
|
19
|
+
* Whether this item can be collapsed/expanded (has sub-items).
|
|
20
|
+
*/
|
|
21
|
+
this.collapsible = false;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the collapsible item is currently open (showing sub-items).
|
|
24
|
+
*/
|
|
25
|
+
this.open = false;
|
|
26
|
+
//#endregion PROPERTIES
|
|
27
|
+
/****************************************************************************/
|
|
28
|
+
//#region STATE
|
|
29
|
+
this.hasSubitems = false;
|
|
30
|
+
this.isSidebarCollapsed = false;
|
|
31
|
+
this.wasActiveFromSubitem = false; // Track if active was set by subitem logic
|
|
32
|
+
//#endregion STATE
|
|
33
|
+
/****************************************************************************/
|
|
34
|
+
//#region METHODS
|
|
35
|
+
this.handleToggle = (event) => {
|
|
36
|
+
// Ignore clicks that originated from subitems (they bubble up but shouldn't toggle)
|
|
37
|
+
const target = event.target;
|
|
38
|
+
if (target.closest('nv-sidebarnavsubitem')) {
|
|
39
|
+
return; // Let the subitem's link handle navigation normally
|
|
40
|
+
}
|
|
41
|
+
// In collapsed sidebar mode, navigate to the main link instead of toggling
|
|
42
|
+
if (this.isSidebarCollapsed) {
|
|
43
|
+
// Find the first link that is NOT inside subitems
|
|
44
|
+
const link = this.el.querySelector('.nv-sidebarnavitem-content a, :scope > a');
|
|
45
|
+
if (link?.href) {
|
|
46
|
+
// Check if click was directly on the link - if so, let it handle naturally
|
|
47
|
+
if (target.closest('a')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Trigger navigation by clicking the link programmatically
|
|
51
|
+
link.click();
|
|
52
|
+
}
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// Only handle toggle for collapsible items when sidebar is expanded
|
|
56
|
+
if (this.collapsible) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
this.open = !this.open;
|
|
60
|
+
}
|
|
61
|
+
// For non-collapsible items in expanded mode, let the link handle the navigation
|
|
62
|
+
// Don't prevent default or stop propagation - allow the link to work normally
|
|
63
|
+
};
|
|
64
|
+
this.isAnimating = false;
|
|
65
|
+
this.hasInitializedHeight = false;
|
|
66
|
+
/** Tracks the last open state that was animated to, to prevent redundant animations */
|
|
67
|
+
this.lastAnimatedOpenState = null;
|
|
68
|
+
this.updateSubitemsHeight = (force = false) => {
|
|
69
|
+
if (!this.subitemsRef)
|
|
70
|
+
return;
|
|
71
|
+
// Skip animation if we're already in the target state (prevents animation on active change)
|
|
72
|
+
// Only animate if:
|
|
73
|
+
// 1. forced (explicit toggle by user via @Watch)
|
|
74
|
+
// 2. OR this is the first animation (lastAnimatedOpenState is null)
|
|
75
|
+
// 3. OR the open state has actually changed since last animation
|
|
76
|
+
if (!force &&
|
|
77
|
+
this.lastAnimatedOpenState !== null &&
|
|
78
|
+
this.lastAnimatedOpenState === this.open) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Don't re-animate if already animating and not forced
|
|
82
|
+
if (this.isAnimating && !force) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.isAnimating = true;
|
|
86
|
+
this.lastAnimatedOpenState = this.open;
|
|
87
|
+
if (this.open) {
|
|
88
|
+
// Calculate real height and animate to it
|
|
89
|
+
this.subitemsRef.style.transition = 'none';
|
|
90
|
+
this.subitemsRef.style.maxHeight = '0px';
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
if (this.subitemsRef) {
|
|
93
|
+
this.subitemsRef.style.transition =
|
|
94
|
+
'max-height 0.3s ease, opacity 0.2s ease';
|
|
95
|
+
this.subitemsRef.style.maxHeight =
|
|
96
|
+
this.subitemsRef.scrollHeight + 'px';
|
|
97
|
+
// Reset animation flag after animation completes
|
|
98
|
+
setTimeout(() => {
|
|
99
|
+
this.isAnimating = false;
|
|
100
|
+
}, 300); // Match animation duration
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Animate to 0
|
|
106
|
+
this.subitemsRef.style.transition = 'none';
|
|
107
|
+
this.subitemsRef.style.maxHeight = this.subitemsRef.scrollHeight + 'px';
|
|
108
|
+
requestAnimationFrame(() => {
|
|
109
|
+
if (this.subitemsRef) {
|
|
110
|
+
this.subitemsRef.style.transition =
|
|
111
|
+
'max-height 0.3s ease, opacity 0.2s ease';
|
|
112
|
+
this.subitemsRef.style.maxHeight = '0px';
|
|
113
|
+
// Reset animation flag after animation completes
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
this.isAnimating = false;
|
|
116
|
+
}, 300); // Match animation duration
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
this.checkSidebarCollapsed = () => {
|
|
122
|
+
const sidebar = this.el.closest('nv-sidebar');
|
|
123
|
+
const wasCollapsed = this.isSidebarCollapsed;
|
|
124
|
+
this.isSidebarCollapsed = sidebar?.hasAttribute('collapsed') ?? false;
|
|
125
|
+
// When sidebar collapse state changes, update active state based on subitems
|
|
126
|
+
if (wasCollapsed !== this.isSidebarCollapsed) {
|
|
127
|
+
this.updateActiveFromSubitems();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Checks if any sub-item is active and updates parent active state.
|
|
132
|
+
* - When sidebar is collapsed: if a sub-item is active, parent should be active
|
|
133
|
+
* - When sidebar is expanded: if a sub-item is active AND parent is not open, parent should be active
|
|
134
|
+
* (because sub-items are hidden, we need to indicate the parent contains an active child)
|
|
135
|
+
*/
|
|
136
|
+
this.updateActiveFromSubitems = () => {
|
|
137
|
+
if (!this.hasSubitems)
|
|
138
|
+
return;
|
|
139
|
+
// Find all sub-items
|
|
140
|
+
const subItems = Array.from(this.el.querySelectorAll('nv-sidebarnavsubitem'));
|
|
141
|
+
// Check if any sub-item is active
|
|
142
|
+
const hasActiveSubitem = subItems.some(subItem => subItem.active);
|
|
143
|
+
if (this.isSidebarCollapsed) {
|
|
144
|
+
// When sidebar is collapsed AND a sub-item is active, make parent active
|
|
145
|
+
if (hasActiveSubitem) {
|
|
146
|
+
this.active = true;
|
|
147
|
+
this.wasActiveFromSubitem = true;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// When collapsed and no sub-item is active, remove active state only if we set it
|
|
151
|
+
if (this.wasActiveFromSubitem) {
|
|
152
|
+
this.active = false;
|
|
153
|
+
this.wasActiveFromSubitem = false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// When sidebar is expanded
|
|
159
|
+
if (hasActiveSubitem && !this.open) {
|
|
160
|
+
// If a sub-item is active AND parent is not open (sub-items hidden),
|
|
161
|
+
// make parent active to indicate it contains an active child
|
|
162
|
+
this.active = true;
|
|
163
|
+
this.wasActiveFromSubitem = true;
|
|
164
|
+
}
|
|
165
|
+
else if (hasActiveSubitem && this.open) {
|
|
166
|
+
// If a sub-item is active BUT parent is open (sub-items visible),
|
|
167
|
+
// remove active state from parent (only sub-item should be active)
|
|
168
|
+
if (this.wasActiveFromSubitem) {
|
|
169
|
+
this.active = false;
|
|
170
|
+
this.wasActiveFromSubitem = false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
// No active sub-item, remove active state if we set it
|
|
175
|
+
if (this.wasActiveFromSubitem) {
|
|
176
|
+
this.active = false;
|
|
177
|
+
this.wasActiveFromSubitem = false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// Note: activePath logic in nv-sidebar can also manage parent active state
|
|
181
|
+
// (when parent href matches activePath exactly)
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//#endregion METHODS
|
|
186
|
+
/****************************************************************************/
|
|
187
|
+
//#region LIFECYCLE
|
|
188
|
+
componentWillLoad() {
|
|
189
|
+
// Check if there are sub-items in any slot
|
|
190
|
+
const subItems = Array.from(this.el.children).filter(child => child.tagName.toLowerCase() === 'nv-sidebarnavsubitem');
|
|
191
|
+
this.hasSubitems = subItems.length > 0;
|
|
192
|
+
// Move sub-items to the subitems slot
|
|
193
|
+
if (this.hasSubitems) {
|
|
194
|
+
subItems.forEach(item => {
|
|
195
|
+
item.setAttribute('slot', 'subitems');
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
// Check sidebar collapsed state
|
|
199
|
+
this.checkSidebarCollapsed();
|
|
200
|
+
// Watch for sidebar state changes
|
|
201
|
+
const sidebar = this.el.closest('nv-sidebar');
|
|
202
|
+
if (sidebar) {
|
|
203
|
+
this.mutationObserver = new MutationObserver(() => {
|
|
204
|
+
this.checkSidebarCollapsed();
|
|
205
|
+
});
|
|
206
|
+
this.mutationObserver.observe(sidebar, {
|
|
207
|
+
attributes: true,
|
|
208
|
+
attributeFilter: ['collapsed'],
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// Watch for sub-items active state changes
|
|
212
|
+
if (this.hasSubitems) {
|
|
213
|
+
// Observe the subitems container for changes (including new sub-items being added)
|
|
214
|
+
// Using subtree: true to catch all attribute changes in descendants
|
|
215
|
+
const subitemsContainer = this.el.querySelector('.nv-sidebarnavitem-subitems');
|
|
216
|
+
if (subitemsContainer) {
|
|
217
|
+
this.subitemsMutationObserver = new MutationObserver(() => {
|
|
218
|
+
this.updateActiveFromSubitems();
|
|
219
|
+
});
|
|
220
|
+
// Observe the container for child list changes and attribute changes in descendants
|
|
221
|
+
this.subitemsMutationObserver.observe(subitemsContainer, {
|
|
222
|
+
childList: true,
|
|
223
|
+
subtree: true,
|
|
224
|
+
attributes: true,
|
|
225
|
+
attributeFilter: ['active'],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
// If container doesn't exist yet (not collapsible or not rendered), observe the element itself
|
|
230
|
+
// This handles cases where sub-items are direct children
|
|
231
|
+
this.subitemsMutationObserver = new MutationObserver(() => {
|
|
232
|
+
this.updateActiveFromSubitems();
|
|
233
|
+
});
|
|
234
|
+
this.subitemsMutationObserver.observe(this.el, {
|
|
235
|
+
childList: true,
|
|
236
|
+
subtree: true,
|
|
237
|
+
attributes: true,
|
|
238
|
+
attributeFilter: ['active'],
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Initial check for active subitems
|
|
243
|
+
this.updateActiveFromSubitems();
|
|
244
|
+
}
|
|
245
|
+
disconnectedCallback() {
|
|
246
|
+
if (this.mutationObserver) {
|
|
247
|
+
this.mutationObserver.disconnect();
|
|
248
|
+
}
|
|
249
|
+
if (this.subitemsMutationObserver) {
|
|
250
|
+
this.subitemsMutationObserver.disconnect();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
//#endregion LIFECYCLE
|
|
254
|
+
/****************************************************************************/
|
|
255
|
+
//#region WATCHERS
|
|
256
|
+
onOpenChanged(newValue, oldValue) {
|
|
257
|
+
// Only animate if the value actually changed (prevents false triggers from React re-renders)
|
|
258
|
+
if (newValue === oldValue) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// Force update when open state changes (user clicked toggle)
|
|
262
|
+
this.updateSubitemsHeight(true);
|
|
263
|
+
// Update active state based on subitems when open state changes
|
|
264
|
+
this.updateActiveFromSubitems();
|
|
265
|
+
}
|
|
266
|
+
//#endregion WATCHERS
|
|
267
|
+
/****************************************************************************/
|
|
268
|
+
//#region RENDER
|
|
269
|
+
render() {
|
|
270
|
+
const showNotificationBullet = this.notificationCount !== undefined && this.notificationCount > 0;
|
|
271
|
+
const notificationSize = this.isSidebarCollapsed ? 'reduced' : 'default';
|
|
272
|
+
return (index.h(index.Host, { key: '7a3523c68080b90ef262a2fa3fa63f1f34baaaf1', role: "listitem" }, index.h("div", { key: '21abd8cf4e5d4a368b25db79306cb0ac747edfce', class: "nv-sidebarnavitem-trigger", onClick: this.handleToggle, "aria-expanded": this.collapsible ? String(this.open) : undefined, "aria-current": this.active && !this.collapsible ? 'page' : undefined }, this.icon && (index.h("div", { key: '8255f2f75b751e5005b4bbb7178e553123c7c109', class: "nv-sidebarnavitem-icon" }, index.h("nv-icon", { key: '5396567c08fc46084f085b544aeee3f874b7b439', name: this.icon, size: "md" }), showNotificationBullet && this.isSidebarCollapsed && (index.h("nv-notification-bullet", { key: '63dfbd2a986124a9c1ba1741e4d1079ec2b38a18', count: this.notificationCount, size: notificationSize, contrastingBorder: true })))), index.h("div", { key: 'a4d8df28b532018d6961d6d779d77ba88bbea756', class: "nv-sidebarnavitem-content" }, index.h("slot", { key: '7394c3534de567f9230ff872b57b4211939bc142' })), index.h("div", { key: 'c8f8451e9ebc42e6ee16407a5ba9c6f6c32f4a66', class: "nv-sidebarnavitem-trailing" }, index.h("slot", { key: '2e901538498c62fe5a5bc21c76c66b493c215e32', name: "trailing" }), showNotificationBullet && !this.isSidebarCollapsed && (index.h("nv-notification-bullet", { key: '9a7c172f0b7dbf78068135344e469d261b80d368', count: this.notificationCount, size: notificationSize })), this.collapsible && (index.h("nv-icon", { key: 'f1caa3750edb35376d8b45121ffb443b033735d4', name: "chevron-down", size: "sm", class: "nv-sidebarnavitem-chevron" })))), this.collapsible && this.hasSubitems && (index.h("div", { key: '4b141fd9639afd78351b01df146866d4d091381f', class: "nv-sidebarnavitem-subitems", ref: el => {
|
|
273
|
+
// Only update ref and initialize if element changed or not yet initialized
|
|
274
|
+
if (el !== this.subitemsRef) {
|
|
275
|
+
this.subitemsRef = el;
|
|
276
|
+
if (el && !this.hasInitializedHeight) {
|
|
277
|
+
// Initialize height only on first mount, not on re-renders
|
|
278
|
+
this.hasInitializedHeight = true;
|
|
279
|
+
requestAnimationFrame(() => {
|
|
280
|
+
// Only animate if item is open, otherwise it will animate when opened
|
|
281
|
+
if (this.open) {
|
|
282
|
+
this.updateSubitemsHeight();
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
} }, index.h("slot", { key: '6a38e07d0559b6eaf2fafb4c9928047a9cfd19b4', name: "subitems" })))));
|
|
288
|
+
}
|
|
289
|
+
get el() { return index.getElement(this); }
|
|
290
|
+
static get watchers() { return {
|
|
291
|
+
"open": ["onOpenChanged"]
|
|
292
|
+
}; }
|
|
293
|
+
};
|
|
294
|
+
NvSidebarnavitem.style = nvSidebarnavitemCss;
|
|
295
|
+
|
|
296
|
+
exports.nv_sidebarnavitem = NvSidebarnavitem;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-kU2nW5aN.js');
|
|
4
|
+
require('@stencil/react-output-target/runtime');
|
|
5
|
+
require('react');
|
|
6
|
+
require('react-dom');
|
|
7
|
+
|
|
8
|
+
const nvSidebarnavsubitemCss = "nv-sidebarnavsubitem{display:flex;align-items:center;gap:var(--spacing-2);padding:var(--sidebar-item-padding-y) var(--sidebar-item-padding-x) var(--sidebar-item-padding-y) calc(var(--sidebar-sub-item-padding-left) + var(--sidebar-item-padding-x));cursor:pointer;transition:all 0.15s ease;position:relative;min-height:var(--spacing-10);background-color:var(--color-interaction-container-neutral-background);border-radius:var(--sidebar-item-radius);--nv-component-background:var(--color-interaction-container-neutral-background)}nv-sidebarnavsubitem:hover{background-color:var(--color-interaction-container-neutral-background-hover);--nv-component-background:var(--color-interaction-container-neutral-background-hover)}nv-sidebarnavsubitem:focus,nv-sidebarnavsubitem:focus-within{outline:none}nv-sidebarnavsubitem:focus-visible,nv-sidebarnavsubitem:has(:focus-visible){outline:calc(var(--focus-outline-stroke) * 1) solid var(--color-focus-brand);outline-offset:calc(var(--focus-outline-offset) * 1)}nv-sidebarnavsubitem .nv-sidebarnavsubitem-indicator{display:none}nv-sidebarnavsubitem .nv-sidebarnavsubitem-content{flex:1;display:flex;align-items:center;gap:var(--spacing-2);font-size:var(--font-size-sm);color:var(--color-content-medium-text);text-decoration:none;font-weight:var(--font-weight-medium-emphasis)}nv-sidebarnavsubitem .nv-sidebarnavsubitem-content a{color:inherit !important;text-decoration:none !important;font-weight:var(--font-weight-medium-emphasis) !important;flex:1}nv-sidebarnavsubitem:hover .nv-sidebarnavsubitem-content{color:var(--color-content-medium-text)}nv-sidebarnavsubitem[active]{background-color:var(--color-interaction-container-neutral-background-active);--nv-component-background:var(--color-interaction-container-neutral-background-active)}nv-sidebarnavsubitem[active] .nv-sidebarnavsubitem-content{color:var(--color-interaction-container-neutral-text-active);font-weight:var(--font-weight-high-emphasis)}nv-sidebarnavsubitem .nv-sidebarnavsubitem-trailing{display:flex;align-items:center}nv-sidebar[collapsed] nv-sidebarnavsubitem .nv-sidebarnavsubitem-content{max-width:0;opacity:0;margin:0;overflow:hidden;transition:opacity 0.2s ease, max-width 0.2s ease}nv-sidebar[collapsed] nv-sidebarnavsubitem .nv-sidebarnavsubitem-indicator{margin-right:0;width:var(--spacing-6);justify-content:center}nv-sidebar[collapsed] nv-sidebarnavsubitem .nv-sidebarnavsubitem-trailing{display:none}";
|
|
9
|
+
|
|
10
|
+
const NvSidebarnavsubitem = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
/****************************************************************************/
|
|
14
|
+
//#region PROPERTIES
|
|
15
|
+
/**
|
|
16
|
+
* Whether this sub-item represents the active/current page.
|
|
17
|
+
*/
|
|
18
|
+
this.active = false;
|
|
19
|
+
}
|
|
20
|
+
//#endregion PROPERTIES
|
|
21
|
+
/****************************************************************************/
|
|
22
|
+
//#region METHODS
|
|
23
|
+
// Note: We no longer use stopPropagation() here because it prevents React Router
|
|
24
|
+
// (and other SPA routers) from receiving the click event due to event delegation.
|
|
25
|
+
// Instead, the parent nv-sidebarnavitem checks if clicks originate from subitems.
|
|
26
|
+
//#endregion METHODS
|
|
27
|
+
/****************************************************************************/
|
|
28
|
+
//#region RENDER
|
|
29
|
+
render() {
|
|
30
|
+
return (index.h(index.Host, { key: '7e9b3aaf42bc7ca19cc3ceeed4afc74058ea48f2', role: "listitem", "aria-current": this.active ? 'page' : undefined }, index.h("div", { key: 'd865d9cff0e9632dd0ca5f97334e09ae3ad6ddf8', class: "nv-sidebarnavsubitem-indicator" }), index.h("div", { key: '28bddb32eea17dbc3b33f2e1c3ef6744e6646cbe', class: "nv-sidebarnavsubitem-content" }, index.h("slot", { key: '0f58fbe30b054e42ac3f431cb8cafe0374994856' })), index.h("div", { key: '3b1b74c67b1e338e158a67dab828941f40f3a147', class: "nv-sidebarnavsubitem-trailing" }, index.h("slot", { key: '98ad3fde4a5295f6835ba6b15ac832fc0426b75b', name: "trailing" }))));
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
NvSidebarnavsubitem.style = nvSidebarnavsubitemCss;
|
|
34
|
+
|
|
35
|
+
exports.nv_sidebarnavsubitem = NvSidebarnavsubitem;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-kU2nW5aN.js');
|
|
4
|
+
require('@stencil/react-output-target/runtime');
|
|
4
5
|
require('react');
|
|
5
6
|
require('react-dom');
|
|
6
7
|
|
|
7
|
-
const nvSplitCss = "nv-split{display:flex;width:100%;height:100%;position:relative}nv-split[direction=horizontal]{flex-direction:row}nv-split[direction=vertical]{flex-direction:column}nv-split .nv-split-gutter{position:absolute;z-index:10;background:transparent;display:flex;align-items:center;justify-content:center;flex:0 0 auto;transition:background-color 0.2s ease}nv-split .nv-split-gutter::after{content:\"\";position:absolute;background:var(--
|
|
8
|
-
const NvSplitStyle0 = nvSplitCss;
|
|
8
|
+
const nvSplitCss = "nv-split{display:flex;width:100%;height:100%;position:relative}nv-split[direction=horizontal]{flex-direction:row}nv-split[direction=vertical]{flex-direction:column}nv-split .nv-split-gutter{position:absolute;z-index:10;background:transparent;display:flex;align-items:center;justify-content:center;flex:0 0 auto;transition:background-color 0.2s ease}nv-split .nv-split-gutter::after{content:\"\";position:absolute;background:var(--components-splitter-line-background);transition:background-color 0.2s ease}nv-split .nv-split-gutter:hover::after{background:var(--components-splitter-line-background-hover)}nv-split .nv-split-gutter::before{content:\"\";background:var(--components-splitter-handle-background);position:absolute;background-repeat:no-repeat;background-position:center;transition:all 0.2s ease;pointer-events:none}nv-split[direction=horizontal]>.nv-split-gutter{width:var(--splitter-gutter);top:0;bottom:0;transform:translateX(-50%);cursor:col-resize}nv-split[direction=horizontal]>.nv-split-gutter::after{width:var(--splitter-line-width);background-color:var(--components-splitter-line-background);height:100%;left:50%;top:0%;transform:translateX(-50%)}nv-split[direction=horizontal]>.nv-split-gutter:hover::after{background-color:var(--components-splitter-line-background-hover)}nv-split[direction=horizontal]>.nv-split-gutter:active::after{background-color:var(--components-splitter-line-background-active)}nv-split[direction=horizontal]>.nv-split-gutter::before{background-color:var(--components-splitter-handle-background);width:var(--splitter-handle-wide);height:var(--splitter-handle-long);border-radius:var(--splitter-handle-radius);z-index:11;transition:all 0.2s ease}nv-split[direction=horizontal]>.nv-split-gutter:hover::before{background-color:var(--components-splitter-handle-background-hover)}nv-split[direction=horizontal]>.nv-split-gutter:active::before{background-color:var(--components-splitter-handle-background-active)}nv-split[direction=vertical]>.nv-split-gutter{height:var(--splitter-gutter);left:0;right:0;transform:translateY(-50%);cursor:row-resize}nv-split[direction=vertical]>.nv-split-gutter::after{height:var(--splitter-line-width);background-color:var(--components-splitter-line-background);width:100%;top:50%;left:0%;transform:translateY(-50%)}nv-split[direction=vertical]>.nv-split-gutter:hover::after{background-color:var(--components-splitter-line-background-hover)}nv-split[direction=vertical]>.nv-split-gutter:active::after{background-color:var(--components-splitter-line-background-active)}nv-split[direction=vertical]>.nv-split-gutter::before{background-color:var(--components-splitter-handle-background);width:var(--splitter-handle-long);height:var(--splitter-handle-wide);border-radius:var(--splitter-handle-radius);z-index:11;transition:all 0.2s ease}nv-split[direction=vertical]>.nv-split-gutter:hover::before{background-color:var(--components-splitter-handle-background-hover)}nv-split[direction=vertical]>.nv-split-gutter:active::before{background-color:var(--components-splitter-handle-background-active)}nv-split[data-dragging=true]>.nv-split-gutter::after{background:var(--components-splitter-line-background-active)}nv-split>[slot=pane]{box-sizing:border-box;flex:1 1 auto;overflow:hidden;min-width:0;min-height:0;display:flex;flex-direction:column;margin:0 !important}nv-split>[slot=pane]>nv-split{flex:1 1 auto;width:100%;height:100%}";
|
|
9
9
|
|
|
10
10
|
const NvSplit = class {
|
|
11
11
|
constructor(hostRef) {
|
|
12
12
|
index.registerInstance(this, hostRef);
|
|
13
|
-
this.sizesChanged = index.createEvent(this, "sizesChanged");
|
|
13
|
+
this.sizesChanged = index.createEvent(this, "sizesChanged", 3);
|
|
14
14
|
/****************************************************************************/
|
|
15
15
|
//#region PROPERTIES
|
|
16
16
|
/**
|
|
@@ -38,7 +38,7 @@ const NvSplit = class {
|
|
|
38
38
|
this.startPos = 0;
|
|
39
39
|
this.startSizes = [];
|
|
40
40
|
// Handlers stored to be able to detach them
|
|
41
|
-
this.onDocMove = (
|
|
41
|
+
this.onDocMove = (e) => this.handleMouseMove(e);
|
|
42
42
|
this.onDocUp = () => this.stopDragging();
|
|
43
43
|
}
|
|
44
44
|
//#endregion
|
|
@@ -59,18 +59,20 @@ const NvSplit = class {
|
|
|
59
59
|
componentDidLoad() {
|
|
60
60
|
// Initialization (once)
|
|
61
61
|
this.ensureGutters();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
// Defer applySizes to ensure CSS (margins, padding) is computed
|
|
63
|
+
requestAnimationFrame(() => {
|
|
64
|
+
this.applySizes();
|
|
65
|
+
this.positionGutters();
|
|
66
|
+
});
|
|
67
|
+
// Observer: reposition gutters when resized
|
|
65
68
|
this.ro = new ResizeObserver(() => this.positionGutters());
|
|
66
69
|
this.ro.observe(this.el);
|
|
67
70
|
window.addEventListener('resize', () => this.positionGutters());
|
|
68
71
|
}
|
|
69
72
|
disconnectedCallback() {
|
|
70
|
-
var _a;
|
|
71
73
|
// Security cleanup (in case a drag was in progress)
|
|
72
74
|
this.detachDocumentListeners();
|
|
73
|
-
|
|
75
|
+
this.ro?.disconnect();
|
|
74
76
|
this.ro = undefined;
|
|
75
77
|
}
|
|
76
78
|
//#endregion
|
|
@@ -118,13 +120,12 @@ const NvSplit = class {
|
|
|
118
120
|
* @returns {Promise<void>}
|
|
119
121
|
*/
|
|
120
122
|
async destroy() {
|
|
121
|
-
var _a;
|
|
122
123
|
this.sizes = [];
|
|
123
124
|
this.isDragging = false;
|
|
124
125
|
this.dragIndex = -1;
|
|
125
126
|
this.removeOwnGutters();
|
|
126
127
|
this.detachDocumentListeners();
|
|
127
|
-
|
|
128
|
+
this.ro?.disconnect();
|
|
128
129
|
}
|
|
129
130
|
//#endregion
|
|
130
131
|
/****************************************************************************/
|
|
@@ -199,15 +200,14 @@ const NvSplit = class {
|
|
|
199
200
|
this.sizes = Array(n).fill(100 / n);
|
|
200
201
|
}
|
|
201
202
|
panes.forEach((pane, i) => {
|
|
202
|
-
|
|
203
|
-
const size = Math.max(0, (_a = this.sizes[i]) !== null && _a !== void 0 ? _a : 100 / n);
|
|
204
|
-
// Flex-basis via flex shorthand (https://developer.mozilla.org/en-US/docs/Web/CSS/flex)
|
|
203
|
+
const size = Math.max(0, this.sizes[i] ?? 100 / n);
|
|
205
204
|
pane.style.flex = `0 0 ${size}%`;
|
|
206
205
|
pane.style.minWidth = '0';
|
|
207
206
|
pane.style.minHeight = '0';
|
|
208
|
-
pane.style.overflow = 'hidden';
|
|
207
|
+
pane.style.overflow = 'hidden';
|
|
209
208
|
pane.style.display = 'flex';
|
|
210
209
|
pane.style.flexDirection = 'column';
|
|
210
|
+
pane.style.boxSizing = 'border-box';
|
|
211
211
|
});
|
|
212
212
|
this.positionGutters();
|
|
213
213
|
}
|
|
@@ -229,7 +229,6 @@ const NvSplit = class {
|
|
|
229
229
|
* Positions the gutters based on the current sizes of the panes.
|
|
230
230
|
*/
|
|
231
231
|
positionGutters() {
|
|
232
|
-
var _a, _b;
|
|
233
232
|
const panes = this.getPanes();
|
|
234
233
|
const gutters = this.getOwnGutters();
|
|
235
234
|
if (panes.length <= 1 || gutters.length === 0)
|
|
@@ -237,7 +236,7 @@ const NvSplit = class {
|
|
|
237
236
|
const horizontal = this.direction === 'horizontal';
|
|
238
237
|
let cumPct = 0;
|
|
239
238
|
for (let i = 0; i < gutters.length; i++) {
|
|
240
|
-
const sizePct =
|
|
239
|
+
const sizePct = this.sizes?.[i] ?? 100 / panes.length;
|
|
241
240
|
cumPct += sizePct;
|
|
242
241
|
const g = gutters[i];
|
|
243
242
|
g.style.position = 'absolute';
|
|
@@ -246,68 +245,70 @@ const NvSplit = class {
|
|
|
246
245
|
g.style.top = '0';
|
|
247
246
|
g.style.bottom = '0';
|
|
248
247
|
g.style.height = '100%';
|
|
248
|
+
g.style.transform = 'translateX(-50%)';
|
|
249
249
|
}
|
|
250
250
|
else {
|
|
251
251
|
g.style.top = `${cumPct}%`;
|
|
252
252
|
g.style.left = '0';
|
|
253
253
|
g.style.right = '0';
|
|
254
254
|
g.style.width = '100%';
|
|
255
|
+
g.style.transform = 'translateY(-50%)';
|
|
255
256
|
}
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
/**
|
|
259
260
|
* Starts the dragging process.
|
|
260
|
-
* @param {MouseEvent}
|
|
261
|
+
* @param {MouseEvent} e - The mouse event.
|
|
261
262
|
* @param {number} index - The index of the gutter.
|
|
262
263
|
*/
|
|
263
|
-
startDragging(
|
|
264
|
+
startDragging(e, index) {
|
|
265
|
+
e.preventDefault();
|
|
264
266
|
this.isDragging = true;
|
|
265
267
|
this.dragIndex = index;
|
|
266
|
-
this.startPos = this.direction === 'horizontal' ?
|
|
268
|
+
this.startPos = this.direction === 'horizontal' ? e.clientX : e.clientY;
|
|
267
269
|
this.startSizes = [...this.sizes];
|
|
268
270
|
this.attachDocumentListeners();
|
|
271
|
+
this.sizesChanged.emit([...this.sizes]);
|
|
269
272
|
}
|
|
270
273
|
/**
|
|
271
274
|
* Handles the mouse movement during dragging.
|
|
272
|
-
* @param {MouseEvent}
|
|
275
|
+
* @param {MouseEvent} e - The mouse event.
|
|
273
276
|
*/
|
|
274
|
-
handleMouseMove(
|
|
275
|
-
var _a, _b, _c, _d;
|
|
277
|
+
handleMouseMove(e) {
|
|
276
278
|
if (!this.isDragging || this.dragIndex < 0)
|
|
277
279
|
return;
|
|
278
280
|
const panes = this.getPanes();
|
|
279
281
|
if (panes.length < 2)
|
|
280
282
|
return;
|
|
281
283
|
const rect = this.el.getBoundingClientRect();
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
const deltaPx = (this.direction === 'horizontal' ? ev.clientX : ev.clientY) -
|
|
286
|
-
this.startPos;
|
|
284
|
+
const horizontal = this.direction === 'horizontal';
|
|
285
|
+
const totalPx = Math.max(horizontal ? rect.width : rect.height, 1);
|
|
286
|
+
const deltaPx = (horizontal ? e.clientX : e.clientY) - this.startPos;
|
|
287
287
|
const deltaPct = (deltaPx / totalPx) * 100;
|
|
288
288
|
const i = this.dragIndex;
|
|
289
289
|
const j = i + 1;
|
|
290
|
-
|
|
291
|
-
|
|
290
|
+
const startLeft = this.startSizes[i];
|
|
291
|
+
const startRight = this.startSizes[j];
|
|
292
292
|
// minSizes (px) -> %
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const k = targetSum / (pairSum || 1);
|
|
302
|
-
left *= k;
|
|
303
|
-
right *= k;
|
|
293
|
+
let minLeftPct = ((this.minSizes?.[i] ?? 0) / totalPx) * 100;
|
|
294
|
+
let minRightPct = ((this.minSizes?.[j] ?? 0) / totalPx) * 100;
|
|
295
|
+
const minSum = minLeftPct + minRightPct;
|
|
296
|
+
const availableSum = startLeft + startRight;
|
|
297
|
+
if (minSum > availableSum) {
|
|
298
|
+
const scale = availableSum / minSum;
|
|
299
|
+
minLeftPct *= scale;
|
|
300
|
+
minRightPct *= scale;
|
|
304
301
|
}
|
|
302
|
+
const minDelta = minLeftPct - startLeft;
|
|
303
|
+
const maxDelta = startRight - minRightPct;
|
|
304
|
+
const clampedDelta = Math.min(Math.max(deltaPct, minDelta), maxDelta);
|
|
305
|
+
const left = startLeft + clampedDelta;
|
|
306
|
+
const right = startRight - clampedDelta;
|
|
305
307
|
const next = [...this.startSizes];
|
|
306
308
|
next[i] = left;
|
|
307
309
|
next[j] = right;
|
|
308
310
|
this.sizes = next;
|
|
309
311
|
this.applySizes();
|
|
310
|
-
this.sizesChanged.emit([...this.sizes]);
|
|
311
312
|
this.positionGutters();
|
|
312
313
|
}
|
|
313
314
|
/**
|
|
@@ -319,12 +320,13 @@ const NvSplit = class {
|
|
|
319
320
|
this.isDragging = false;
|
|
320
321
|
this.dragIndex = -1;
|
|
321
322
|
this.detachDocumentListeners();
|
|
323
|
+
this.sizesChanged.emit([...this.sizes]);
|
|
322
324
|
}
|
|
323
325
|
//#endregion
|
|
324
326
|
/****************************************************************************/
|
|
325
327
|
//#region RENDER
|
|
326
328
|
render() {
|
|
327
|
-
return (index.h(index.Host, { key: '
|
|
329
|
+
return (index.h(index.Host, { key: '850cf8fb9d492e1da39da0037c1fd8d414960d28', "data-dragging": this.isDragging.toString() }, index.h("slot", { key: '4d2f540ca147abe4778bcc0d02be2e87ee2cf3b4', name: "pane" }), index.h("slot", { key: '1ceb2dc6375c50fe7786ba03fb2a753f852980ba', name: "gutter" })));
|
|
328
330
|
}
|
|
329
331
|
get el() { return index.getElement(this); }
|
|
330
332
|
static get watchers() { return {
|
|
@@ -332,6 +334,6 @@ const NvSplit = class {
|
|
|
332
334
|
"direction": ["onDirectionChanged"]
|
|
333
335
|
}; }
|
|
334
336
|
};
|
|
335
|
-
NvSplit.style =
|
|
337
|
+
NvSplit.style = nvSplitCss;
|
|
336
338
|
|
|
337
339
|
exports.nv_split = NvSplit;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var
|
|
3
|
+
var index = require('./index-kU2nW5aN.js');
|
|
4
|
+
var clsxChV9xqsO = require('./clsx-ChV9xqsO-BtxeOLZW.js');
|
|
5
|
+
require('@stencil/react-output-target/runtime');
|
|
5
6
|
require('react');
|
|
6
7
|
require('react-dom');
|
|
7
8
|
|
|
8
9
|
const nvStackCss = "nv-stack{display:flex;align-items:center;justify-content:flex-start;flex-direction:row}nv-stack nv-col{display:flex}nv-stack:not(nv-row){flex-wrap:nowrap}nv-stack>.nv-stack-item-flex{flex-shrink:1;flex-grow:1}nv-stack>.nv-stack-item-lead{margin-right:auto}nv-stack>.nv-stack-item-lead+*{margin-left:0}nv-stack>.nv-stack-item-center{margin-right:auto;margin-left:auto}nv-stack>.nv-stack-item-tail{margin-left:auto}nv-stack>.nv-stack-nowrap{white-space:nowrap}nv-stack.nv-stack-vertical{align-items:stretch;flex-direction:column}nv-stack.nv-stack-vertical>.nv-stack-item-lead{margin-right:0;margin-bottom:auto}nv-stack.nv-stack-vertical>.nv-stack-item-lead+*{margin-top:0}nv-stack.nv-stack-vertical>.nv-stack-item-tail{margin-left:0;margin-top:auto}nv-stack.nv-stack-vertical>.nv-stack-item-center{margin:auto 0}nv-stack.nv-stack-flex>*{flex-shrink:1;flex-grow:1}nv-stack.nv-stack-fill>*{height:100%}nv-stack.nv-stack-fill.nv-stack-vertical>*{height:auto;width:100%}";
|
|
9
|
-
const NvStackStyle0 = nvStackCss;
|
|
10
10
|
|
|
11
11
|
const NvStack = class {
|
|
12
12
|
constructor(hostRef) {
|
|
@@ -23,9 +23,9 @@ const NvStack = class {
|
|
|
23
23
|
/****************************************************************************/
|
|
24
24
|
//#region RENDER
|
|
25
25
|
render() {
|
|
26
|
-
return (index.h(index.Host, { key: '
|
|
26
|
+
return (index.h(index.Host, { key: '7b44b30e42b8df1c456f70b1f3be986e2fce1617', class: clsxChV9xqsO.clsx(this.fill && 'nv-stack-fill', this.flex && 'nv-stack-flex', this.full && 'w-full', this.gutter && !this.vertical && `gap-x-${this.gutter}`, this.gutter && this.vertical && `gap-y-${this.gutter}`, this.vertical && 'nv-stack-vertical') }, index.h("slot", { key: 'd38b6f0c043959ed97b3e90d21309ab832713b4e' })));
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
NvStack.style =
|
|
29
|
+
NvStack.style = nvStackCss;
|
|
30
30
|
|
|
31
31
|
exports.nv_stack = NvStack;
|