@elderbyte/ngx-starter 21.4.0 → 21.4.2
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.
|
@@ -37971,8 +37971,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
|
|
|
37971
37971
|
args: ['class']
|
|
37972
37972
|
}] } });
|
|
37973
37973
|
|
|
37974
|
-
const DEFAULT_MIN_WIDTH = 5;
|
|
37975
|
-
const DEFAULT_MAX_WIDTH = 95;
|
|
37974
|
+
const DEFAULT_MIN_WIDTH = '5%';
|
|
37975
|
+
const DEFAULT_MAX_WIDTH = '95%';
|
|
37976
37976
|
const DEFAULT_HANDLE_POSITION = 'end';
|
|
37977
37977
|
|
|
37978
37978
|
class ElderResizeBehaviorDirective {
|
|
@@ -38001,7 +38001,7 @@ class ElderResizeBehaviorDirective {
|
|
|
38001
38001
|
this.isInComputedWidthMode = signal(false, ...(ngDevMode ? [{ debugName: "isInComputedWidthMode" }] : []));
|
|
38002
38002
|
this.widthInPercent = signal(null, ...(ngDevMode ? [{ debugName: "widthInPercent" }] : []));
|
|
38003
38003
|
this._isDragging = signal(false, ...(ngDevMode ? [{ debugName: "_isDragging" }] : []));
|
|
38004
|
-
this.containerWidth = 0;
|
|
38004
|
+
this.containerWidth = signal(0, ...(ngDevMode ? [{ debugName: "containerWidth" }] : []));
|
|
38005
38005
|
this.dragStartMousePosX = 0;
|
|
38006
38006
|
this.dragStartPaneWidthInPercent = 0;
|
|
38007
38007
|
/***************************************************************************
|
|
@@ -38015,7 +38015,12 @@ class ElderResizeBehaviorDirective {
|
|
|
38015
38015
|
if (width === null) {
|
|
38016
38016
|
return null;
|
|
38017
38017
|
}
|
|
38018
|
-
|
|
38018
|
+
const containerW = this.containerWidth();
|
|
38019
|
+
const minParsed = this.parseWidthConstraint(this.minWidth());
|
|
38020
|
+
const maxParsed = this.parseWidthConstraint(this.maxWidth());
|
|
38021
|
+
const minPercent = this.toPercent(minParsed, containerW);
|
|
38022
|
+
const maxPercent = this.toPercent(maxParsed, containerW);
|
|
38023
|
+
return Math.max(minPercent, Math.min(maxPercent, width));
|
|
38019
38024
|
}, ...(ngDevMode ? [{ debugName: "constrainedWidth" }] : []));
|
|
38020
38025
|
/***************************************************************************
|
|
38021
38026
|
* *
|
|
@@ -38067,6 +38072,23 @@ class ElderResizeBehaviorDirective {
|
|
|
38067
38072
|
* Private methods *
|
|
38068
38073
|
* *
|
|
38069
38074
|
**************************************************************************/
|
|
38075
|
+
parseWidthConstraint(input) {
|
|
38076
|
+
const trimmed = String(input).trim().toLowerCase();
|
|
38077
|
+
const floatValue = parseFloat(trimmed);
|
|
38078
|
+
const isValidEnding = trimmed.endsWith('px') || trimmed.endsWith('%');
|
|
38079
|
+
if (Number.isNaN(floatValue) || !isValidEnding) {
|
|
38080
|
+
this.logger.error(`Invalid width constraint: ${input}`);
|
|
38081
|
+
return { value: 0, unit: 'percent' };
|
|
38082
|
+
}
|
|
38083
|
+
return { value: floatValue, unit: trimmed.endsWith('px') ? 'px' : 'percent' };
|
|
38084
|
+
}
|
|
38085
|
+
toPercent(parsed, containerWidth) {
|
|
38086
|
+
if (parsed.unit === 'percent')
|
|
38087
|
+
return parsed.value;
|
|
38088
|
+
if (containerWidth <= 0)
|
|
38089
|
+
return parsed.value <= 0 ? 0 : 100;
|
|
38090
|
+
return (parsed.value / containerWidth) * 100;
|
|
38091
|
+
}
|
|
38070
38092
|
removeExternalWidthStyles() {
|
|
38071
38093
|
const stylesToRemove = [
|
|
38072
38094
|
'flex',
|
|
@@ -38106,24 +38128,23 @@ class ElderResizeBehaviorDirective {
|
|
|
38106
38128
|
}
|
|
38107
38129
|
setWidthInPercentFromElementWidth() {
|
|
38108
38130
|
this.updateContainerWidth();
|
|
38109
|
-
if (this.containerWidth === 0) {
|
|
38131
|
+
if (this.containerWidth() === 0) {
|
|
38110
38132
|
this.logger.error('Container width is 0. Can not calculate percent.');
|
|
38111
38133
|
return;
|
|
38112
38134
|
}
|
|
38113
38135
|
// Calculate the current element width as a percentage of container width
|
|
38114
38136
|
const paneWidth = this.elementRef.nativeElement.offsetWidth;
|
|
38115
|
-
const percentage = (paneWidth / this.containerWidth) * 100;
|
|
38137
|
+
const percentage = (paneWidth / this.containerWidth()) * 100;
|
|
38116
38138
|
this.widthInPercent.set(percentage);
|
|
38117
38139
|
}
|
|
38118
38140
|
updateContainerWidth() {
|
|
38119
38141
|
const containerElement = this.elementRef.nativeElement.parentElement;
|
|
38120
38142
|
if (!containerElement) {
|
|
38121
38143
|
this.logger.error('Container element not found for percentage calculation');
|
|
38122
|
-
return
|
|
38144
|
+
return;
|
|
38123
38145
|
}
|
|
38124
38146
|
// Use clientWidth which excludes borders and scrollbars, then subtract padding
|
|
38125
|
-
this.containerWidth
|
|
38126
|
-
return this.containerWidth;
|
|
38147
|
+
this.containerWidth.set(containerElement.clientWidth - this.getContainerPadding());
|
|
38127
38148
|
}
|
|
38128
38149
|
getContainerPadding() {
|
|
38129
38150
|
const containerElement = this.elementRef.nativeElement.parentElement;
|
|
@@ -38134,14 +38155,14 @@ class ElderResizeBehaviorDirective {
|
|
|
38134
38155
|
parseFloat(window.getComputedStyle(containerElement).paddingRight));
|
|
38135
38156
|
}
|
|
38136
38157
|
calcWidthInPercent(event, position) {
|
|
38137
|
-
if (this.containerWidth === 0 ||
|
|
38158
|
+
if (this.containerWidth() === 0 ||
|
|
38138
38159
|
this.dragStartPaneWidthInPercent === null ||
|
|
38139
38160
|
isNaN(this.dragStartPaneWidthInPercent)) {
|
|
38140
38161
|
return undefined;
|
|
38141
38162
|
}
|
|
38142
38163
|
const deltaX = event.clientX - this.dragStartMousePosX;
|
|
38143
38164
|
// Convert pixel delta to percentage delta
|
|
38144
|
-
let delta = (deltaX / this.containerWidth) * 100;
|
|
38165
|
+
let delta = (deltaX / this.containerWidth()) * 100;
|
|
38145
38166
|
// Invert delta for left-side handles
|
|
38146
38167
|
if (position === 'start') {
|
|
38147
38168
|
delta = -delta;
|
|
@@ -38188,8 +38209,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
|
|
|
38188
38209
|
}] });
|
|
38189
38210
|
|
|
38190
38211
|
class ElderResizeContainerComponent {
|
|
38212
|
+
constructor() {
|
|
38213
|
+
this.resizeHandleDirective = inject(ElderResizeBehaviorDirective);
|
|
38214
|
+
}
|
|
38191
38215
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ElderResizeContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
38192
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
38216
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.2", type: ElderResizeContainerComponent, isStandalone: true, selector: "elder-resize-container", host: { classAttribute: "elder-resize-container" }, hostDirectives: [{ directive: ElderResizeBehaviorDirective, inputs: ["minWidth", "minWidth", "maxWidth", "maxWidth", "handlePosition", "handlePosition"] }], ngImport: i0, template: "@if (resizeHandleDirective.handlePosition() !== 'none') {\n <elder-resize-handle-bar></elder-resize-handle-bar>\n}\n<div class=\"elder-resize-container-inner\">\n <ng-content></ng-content>\n</div>\n", styles: [":host{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch;position:relative}:host.resize-mode{flex:none!important}.elder-resize-container-inner{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch}\n"], dependencies: [{ kind: "component", type: ElderResizeHandleBarComponent, selector: "elder-resize-handle-bar" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
38193
38217
|
}
|
|
38194
38218
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImport: i0, type: ElderResizeContainerComponent, decorators: [{
|
|
38195
38219
|
type: Component,
|
|
@@ -38200,7 +38224,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.2", ngImpor
|
|
|
38200
38224
|
directive: ElderResizeBehaviorDirective,
|
|
38201
38225
|
inputs: ['minWidth', 'maxWidth', 'handlePosition'],
|
|
38202
38226
|
},
|
|
38203
|
-
], changeDetection: ChangeDetectionStrategy.OnPush, template: "<elder-resize-handle-bar></elder-resize-handle-bar>\n<div class=\"elder-resize-container-inner\">\n <ng-content></ng-content>\n</div>\n", styles: [":host{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch;position:relative}:host.resize-mode{flex:none!important}.elder-resize-container-inner{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch}\n"] }]
|
|
38227
|
+
], changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (resizeHandleDirective.handlePosition() !== 'none') {\n <elder-resize-handle-bar></elder-resize-handle-bar>\n}\n<div class=\"elder-resize-container-inner\">\n <ng-content></ng-content>\n</div>\n", styles: [":host{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch;position:relative}:host.resize-mode{flex:none!important}.elder-resize-container-inner{height:100%;display:flex;flex-flow:column nowrap;justify-content:flex-start;align-items:stretch}\n"] }]
|
|
38204
38228
|
}] });
|
|
38205
38229
|
|
|
38206
38230
|
const DEFAULT_CONFIG = {
|