@scion/components 18.1.1 → 19.1.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/dimension/dimension.directive.d.ts +2 -2
- package/dimension/dimension.module.d.ts +2 -0
- package/dimension/public_api.d.ts +1 -1
- package/fesm2022/scion-components-dimension.mjs +18 -17
- package/fesm2022/scion-components-dimension.mjs.map +1 -1
- package/fesm2022/scion-components-sashbox.mjs +222 -215
- package/fesm2022/scion-components-sashbox.mjs.map +1 -1
- package/fesm2022/scion-components-splitter.mjs +69 -74
- package/fesm2022/scion-components-splitter.mjs.map +1 -1
- package/fesm2022/scion-components-throbber.mjs +43 -45
- package/fesm2022/scion-components-throbber.mjs.map +1 -1
- package/fesm2022/scion-components-viewport.mjs +94 -99
- package/fesm2022/scion-components-viewport.mjs.map +1 -1
- package/package.json +4 -16
- package/sashbox/element-ref.directive.d.ts +1 -4
- package/sashbox/sash-initializer.directive.d.ts +4 -7
- package/sashbox/sash.directive.d.ts +21 -20
- package/sashbox/sashbox-accessor.d.ts +3 -4
- package/sashbox/sashbox.component.d.ts +36 -27
- package/sashbox/sashbox.module.d.ts +2 -0
- package/splitter/public_api.d.ts +1 -1
- package/splitter/splitter.component.d.ts +22 -26
- package/splitter/splitter.module.d.ts +2 -0
- package/throbber/spinner-throbber/spinner-throbber.component.d.ts +1 -1
- package/throbber/throbber.component.d.ts +2 -2
- package/throbber/throbber.module.d.ts +2 -0
- package/viewport/native-scrollbar-track-size-provider.service.d.ts +2 -2
- package/viewport/public_api.d.ts +1 -1
- package/viewport/scrollable.directive.d.ts +4 -4
- package/viewport/scrollbar/scrollbar.component.d.ts +16 -22
- package/viewport/viewport.component.d.ts +13 -12
- package/viewport/viewport.module.d.ts +2 -0
- package/esm2022/dimension/bounding-client-rect.signal.mjs +0 -54
- package/esm2022/dimension/dimension.directive.mjs +0 -67
- package/esm2022/dimension/dimension.mjs +0 -11
- package/esm2022/dimension/dimension.module.mjs +0 -34
- package/esm2022/dimension/dimension.signal.mjs +0 -63
- package/esm2022/dimension/public_api.mjs +0 -19
- package/esm2022/dimension/scion-components-dimension.mjs +0 -5
- package/esm2022/public-api.mjs +0 -11
- package/esm2022/sashbox/element-ref.directive.mjs +0 -31
- package/esm2022/sashbox/public_api.mjs +0 -18
- package/esm2022/sashbox/sash-initializer.directive.mjs +0 -35
- package/esm2022/sashbox/sash.directive.mjs +0 -145
- package/esm2022/sashbox/sashbox-accessor.mjs +0 -6
- package/esm2022/sashbox/sashbox.component.mjs +0 -282
- package/esm2022/sashbox/sashbox.module.mjs +0 -55
- package/esm2022/sashbox/scion-components-sashbox.mjs +0 -5
- package/esm2022/scion-components.mjs +0 -5
- package/esm2022/splitter/public_api.mjs +0 -17
- package/esm2022/splitter/scion-components-splitter.mjs +0 -5
- package/esm2022/splitter/splitter.component.mjs +0 -226
- package/esm2022/splitter/splitter.module.mjs +0 -38
- package/esm2022/throbber/ellipsis-throbber/ellipsis-throbber.component.mjs +0 -25
- package/esm2022/throbber/public_api.mjs +0 -17
- package/esm2022/throbber/ripple-throbber/ripple-throbber.component.mjs +0 -25
- package/esm2022/throbber/roller-throbber/roller-throbber.component.mjs +0 -25
- package/esm2022/throbber/scion-components-throbber.mjs +0 -5
- package/esm2022/throbber/spinner-throbber/spinner-throbber.component.mjs +0 -26
- package/esm2022/throbber/throbber.component.mjs +0 -72
- package/esm2022/throbber/throbber.module.mjs +0 -32
- package/esm2022/viewport/native-scrollbar-track-size-provider.service.mjs +0 -91
- package/esm2022/viewport/public_api.mjs +0 -19
- package/esm2022/viewport/scion-components-viewport.mjs +0 -5
- package/esm2022/viewport/scrollable.directive.mjs +0 -92
- package/esm2022/viewport/scrollbar/scrollbar.component.mjs +0 -305
- package/esm2022/viewport/viewport.component.mjs +0 -264
- package/esm2022/viewport/viewport.module.mjs +0 -42
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import { switchMap, map, startWith, takeUntil } from 'rxjs/operators';
|
|
4
|
-
import { BehaviorSubject, merge, Subject } from 'rxjs';
|
|
2
|
+
import { input, inject, TemplateRef, computed, signal, linkedSignal, Directive, ElementRef, effect, output, contentChildren, NgZone, Component, HostBinding, NgModule } from '@angular/core';
|
|
5
3
|
import { SciSplitterComponent } from '@scion/components/splitter';
|
|
6
|
-
import {
|
|
4
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* Allows accessing the sashbox component from sashes.
|
|
@@ -42,114 +40,145 @@ class SciSashBoxAccessor {
|
|
|
42
40
|
class SciSashDirective {
|
|
43
41
|
/**
|
|
44
42
|
* Specifies the sash size, either as fixed size with an explicit unit,
|
|
45
|
-
* or as a unitless proportion to
|
|
43
|
+
* or as a unitless proportion to distribute remaining space. A proportional
|
|
46
44
|
* sash has the ability to grow or shrink if necessary, and must be >= 1.
|
|
47
45
|
*
|
|
48
46
|
* If not set, remaining space is distributed equally.
|
|
49
47
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
size = input('1', { transform: (size) => size ?? '1' });
|
|
49
|
+
/**
|
|
50
|
+
* Specifies the minimal sash size in pixel or percent.
|
|
51
|
+
* The min-size prevents the user from shrinking the sash below this minimal size.
|
|
52
|
+
*
|
|
53
|
+
* If the unit is omitted, the value is interpreted as a pixel value.
|
|
54
|
+
*/
|
|
55
|
+
minSize = input();
|
|
56
56
|
/**
|
|
57
|
+
* Optional key to identify this sash.
|
|
58
|
+
*
|
|
59
|
+
* If set, this key is used as the property key in the object emitted by {@link SciSashboxComponent.sashEnd2} to associate the size of this sash.
|
|
60
|
+
*/
|
|
61
|
+
key = input();
|
|
62
|
+
/**
|
|
63
|
+
* Represents the template used as sash content.
|
|
64
|
+
*
|
|
57
65
|
* @internal
|
|
58
66
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
67
|
+
sashTemplate = inject(TemplateRef);
|
|
68
|
+
_sashBoxAccessor = inject(SciSashBoxAccessor);
|
|
62
69
|
/**
|
|
70
|
+
* Flex properties computed based on the configured {@link size}. Properties are updated when moving this sash.
|
|
71
|
+
*/
|
|
72
|
+
_flexProperties = this.computeFlexProperties();
|
|
73
|
+
/**
|
|
74
|
+
* Flex properties with normalized 'flex-grow' to ensure the sashes fill the entire sash-box space.
|
|
75
|
+
*
|
|
76
|
+
* Use these properties to lay out this sash in the sashbox's flex layout.
|
|
77
|
+
*
|
|
63
78
|
* @internal
|
|
64
79
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
flexProperties = this.normalizeFlexGrow(this._flexProperties);
|
|
81
|
+
/**
|
|
82
|
+
* Returns if this sash has a fixed size, meaning that it has not the ability to grow or shrink.
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
isFixedSize = computed(() => Number.isNaN(+this.size()));
|
|
87
|
+
/**
|
|
88
|
+
* Gets the DOM element that renders this sash.
|
|
89
|
+
*
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
element = signal(undefined);
|
|
93
|
+
/**
|
|
94
|
+
* Gets the effective size of this sash in the DOM.
|
|
95
|
+
*
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
get elementSize() {
|
|
99
|
+
const element = this.element();
|
|
100
|
+
if (!element) {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
if (this._sashBoxAccessor.direction() === 'row') {
|
|
104
|
+
return element.getBoundingClientRect().width;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return element.getBoundingClientRect().height;
|
|
108
|
+
}
|
|
81
109
|
}
|
|
82
110
|
/**
|
|
83
|
-
* Returns
|
|
111
|
+
* Returns the identity of this sash, or the passed index if not configured.
|
|
84
112
|
*
|
|
85
113
|
* @internal
|
|
86
114
|
*/
|
|
87
|
-
|
|
88
|
-
return
|
|
115
|
+
computeKey(index) {
|
|
116
|
+
return this.key() ?? `${index}`;
|
|
89
117
|
}
|
|
90
118
|
/**
|
|
91
|
-
*
|
|
119
|
+
* Updates the flex properties of this sash for layout in the sashbox's flex layout.
|
|
92
120
|
*
|
|
93
121
|
* @internal
|
|
94
122
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// see https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth
|
|
98
|
-
return this._sashBoxAccessor.direction === 'row' ? this.element.getBoundingClientRect().width : this.element.getBoundingClientRect().height;
|
|
123
|
+
updateFlexProperties(flexProperties) {
|
|
124
|
+
this._flexProperties.update(previousFlexProperties => ({ ...previousFlexProperties, ...flexProperties }));
|
|
99
125
|
}
|
|
100
126
|
/**
|
|
101
|
-
* Computes
|
|
127
|
+
* Computes the flex properties to lay out this sash in the sashbox's flex layout based on the configured {@link size}.
|
|
102
128
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (proportion < 1) {
|
|
114
|
-
throw Error(`[IllegalSashSizeError] The proportion for flexible sized sashes must be >=1 [size=${this.size}]`);
|
|
129
|
+
computeFlexProperties() {
|
|
130
|
+
return linkedSignal(() => {
|
|
131
|
+
const size = this.size();
|
|
132
|
+
if (this.isFixedSize()) {
|
|
133
|
+
// fixed-sized sash
|
|
134
|
+
return {
|
|
135
|
+
flexGrow: 0,
|
|
136
|
+
flexShrink: 0,
|
|
137
|
+
flexBasis: `${size}`,
|
|
138
|
+
};
|
|
115
139
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
140
|
+
else {
|
|
141
|
+
// remaining space is distributed according to given proportion
|
|
142
|
+
const proportion = +size;
|
|
143
|
+
if (proportion < 1) {
|
|
144
|
+
throw Error(`[IllegalSashSizeError] The proportion for flexible sized sashes must be >=1 [size=${this.size()}]`);
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
flexGrow: proportion,
|
|
148
|
+
flexShrink: 1,
|
|
149
|
+
flexBasis: '0',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
120
153
|
}
|
|
121
154
|
/**
|
|
122
|
-
*
|
|
155
|
+
* Normalizes the 'flex-grow' of the passed {@link FlexProperties} to ensure that the sum of the 'flex-grow' proportions of all sashes is 1.
|
|
123
156
|
*
|
|
124
|
-
* If the sum of all flex-grow proportions
|
|
125
|
-
* Without normalization
|
|
157
|
+
* If the sum of all flex-grow proportions were less than 1, the sashes would not fill the entire sash-box space.
|
|
158
|
+
* Without normalization, this could occur when a sash is removed.
|
|
126
159
|
*/
|
|
127
|
-
normalizeFlexGrow(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
160
|
+
normalizeFlexGrow(flexProperties) {
|
|
161
|
+
return computed(() => {
|
|
162
|
+
const sashes = this._sashBoxAccessor.sashes();
|
|
163
|
+
const { flexGrow, flexShrink, flexBasis } = flexProperties();
|
|
164
|
+
const flexGrowSum = sashes.reduce((sum, sash) => sum + sash._flexProperties().flexGrow, 0);
|
|
165
|
+
return {
|
|
166
|
+
flexGrow: flexGrow === 0 || flexGrowSum === 0 ? 0 : flexGrow / flexGrowSum, // Sum of normalized flex-grow proportions must be 1;
|
|
167
|
+
flexShrink,
|
|
168
|
+
flexBasis,
|
|
169
|
+
};
|
|
170
|
+
});
|
|
137
171
|
}
|
|
138
|
-
static
|
|
139
|
-
static
|
|
172
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
173
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: SciSashDirective, isStandalone: true, selector: "ng-template[sciSash]", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, minSize: { classPropertyName: "minSize", publicName: "minSize", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, exportAs: ["sciSash"], ngImport: i0 });
|
|
140
174
|
}
|
|
141
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashDirective, decorators: [{
|
|
142
176
|
type: Directive,
|
|
143
177
|
args: [{
|
|
144
178
|
selector: 'ng-template[sciSash]',
|
|
145
179
|
exportAs: 'sciSash',
|
|
146
|
-
standalone: true,
|
|
147
180
|
}]
|
|
148
|
-
}]
|
|
149
|
-
type: Input
|
|
150
|
-
}], minSize: [{
|
|
151
|
-
type: Input
|
|
152
|
-
}] } });
|
|
181
|
+
}] });
|
|
153
182
|
|
|
154
183
|
/*
|
|
155
184
|
* Copyright (c) 2018-2019 Swiss Federal Railways
|
|
@@ -164,25 +193,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
164
193
|
* Initializes {SashDirective} with the target {HTMLDivElement}.
|
|
165
194
|
*/
|
|
166
195
|
class SciSashInitializerDirective {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
this.sash.element = this._host.nativeElement;
|
|
196
|
+
sash = input.required({ alias: 'sciSashInitializer' });
|
|
197
|
+
constructor() {
|
|
198
|
+
const host = inject(ElementRef).nativeElement;
|
|
199
|
+
effect(() => this.sash().element.set(host));
|
|
172
200
|
}
|
|
173
|
-
static
|
|
174
|
-
static
|
|
201
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashInitializerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
202
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: SciSashInitializerDirective, isStandalone: true, selector: "div[sciSashInitializer].sash", inputs: { sash: { classPropertyName: "sash", publicName: "sciSashInitializer", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 });
|
|
175
203
|
}
|
|
176
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashInitializerDirective, decorators: [{
|
|
177
205
|
type: Directive,
|
|
178
206
|
args: [{
|
|
179
207
|
selector: 'div[sciSashInitializer].sash',
|
|
180
|
-
standalone: true,
|
|
181
208
|
}]
|
|
182
|
-
}], ctorParameters: () => [
|
|
183
|
-
type: Input,
|
|
184
|
-
args: [{ alias: 'sciSashInitializer', required: true }]
|
|
185
|
-
}] } });
|
|
209
|
+
}], ctorParameters: () => [] });
|
|
186
210
|
|
|
187
211
|
/*
|
|
188
212
|
* Copyright (c) 2018-2019 Swiss Federal Railways
|
|
@@ -197,21 +221,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
197
221
|
* Provides access to the native {@link HTMLElement} of the host.
|
|
198
222
|
*/
|
|
199
223
|
class SciElementRefDirective {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: SciElementRefDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
205
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.1", type: SciElementRefDirective, isStandalone: true, selector: "[sciElementRef]", exportAs: ["sciElementRef"], ngImport: i0 }); }
|
|
224
|
+
host = inject(ElementRef).nativeElement;
|
|
225
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciElementRefDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
226
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: SciElementRefDirective, isStandalone: true, selector: "[sciElementRef]", exportAs: ["sciElementRef"], ngImport: i0 });
|
|
206
227
|
}
|
|
207
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciElementRefDirective, decorators: [{
|
|
208
229
|
type: Directive,
|
|
209
230
|
args: [{
|
|
210
231
|
selector: '[sciElementRef]',
|
|
211
232
|
exportAs: 'sciElementRef',
|
|
212
|
-
standalone: true,
|
|
213
233
|
}]
|
|
214
|
-
}]
|
|
234
|
+
}] });
|
|
215
235
|
|
|
216
236
|
/*
|
|
217
237
|
* Copyright (c) 2018-2019 Swiss Federal Railways
|
|
@@ -227,10 +247,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
227
247
|
* or column arrangement (as specified by the direction property). A splitter is added between each child to allow the user to
|
|
228
248
|
* shrink or stretch the individual sashes.
|
|
229
249
|
*
|
|
230
|
-
* Sashes are modelled as
|
|
231
|
-
* A sash can have a fixed size with an explicit unit, or a unitless proportion to
|
|
250
|
+
* Sashes are modelled as <ng-template> decorated with the 'sciSash' directive.
|
|
251
|
+
* A sash can have a fixed size with an explicit unit, or a unitless proportion to distribute remaining space.
|
|
232
252
|
* A proportional sash has the ability to grow or shrink if necessary.
|
|
233
253
|
*
|
|
254
|
+
* Sash content is added to a CSS grid container with a single column, stretching the content vertically and horizontally.
|
|
234
255
|
*
|
|
235
256
|
* ### Usage
|
|
236
257
|
*
|
|
@@ -276,33 +297,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
276
297
|
* ```
|
|
277
298
|
*/
|
|
278
299
|
class SciSashboxComponent {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Specifies if to lay out sashes in a row (which is by default) or column arrangement.
|
|
302
|
+
*/
|
|
303
|
+
direction = input('row');
|
|
304
|
+
/**
|
|
305
|
+
* Notifies when start sashing.
|
|
306
|
+
*/
|
|
307
|
+
sashStart = output();
|
|
308
|
+
/**
|
|
309
|
+
* Emits an array with new sash sizes when sashing ends.
|
|
310
|
+
*
|
|
311
|
+
* The array contains the sash sizes in display order.
|
|
312
|
+
*
|
|
313
|
+
* TODO [Angular 20] BREAKING CHANGE: Change signature from `number[]` to `{[key: string]: number}` and remove {@link sashEnd2}.
|
|
314
|
+
*/
|
|
315
|
+
sashEnd = output();
|
|
316
|
+
/**
|
|
317
|
+
* Emits an object with new sash sizes when sashing ends.
|
|
318
|
+
*
|
|
319
|
+
* Each sash size is associated with its {@link SciSashDirective.key} or its display position (zero-based) if not set.
|
|
320
|
+
*
|
|
321
|
+
* Note: This output will be renamed to `sashEnd` in version 20, changing the signature of {@link sashEnd} from `number[]` to `{[key: string]: number}`.
|
|
322
|
+
*
|
|
323
|
+
* TODO [Angular 20] BREAKING CHANGE: Replace with {@link sashEnd}.
|
|
324
|
+
*/
|
|
325
|
+
sashEnd2 = output();
|
|
326
|
+
_host = inject(ElementRef).nativeElement;
|
|
298
327
|
/** @internal */
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
this.sashes$.next(sashes.toArray());
|
|
304
|
-
});
|
|
305
|
-
}
|
|
328
|
+
sashes = contentChildren(SciSashDirective);
|
|
329
|
+
sashing = false;
|
|
330
|
+
maxHeight;
|
|
331
|
+
maxWidth;
|
|
306
332
|
onSashStart() {
|
|
307
333
|
this.sashing = true;
|
|
308
334
|
// Avoid overflow when sashing.
|
|
@@ -310,12 +336,14 @@ class SciSashboxComponent {
|
|
|
310
336
|
this.maxHeight = hostBounds.height;
|
|
311
337
|
this.maxWidth = hostBounds.width;
|
|
312
338
|
this.sashStart.emit();
|
|
313
|
-
//
|
|
314
|
-
this.sashes.forEach(sash => {
|
|
315
|
-
if (!sash.isFixedSize) {
|
|
316
|
-
sash.
|
|
317
|
-
|
|
318
|
-
|
|
339
|
+
// Set the effective sash size as the flex-basis for non-fixed sashes (as sashing operates on pixel deltas).
|
|
340
|
+
this.sashes().forEach(sash => {
|
|
341
|
+
if (!sash.isFixedSize()) {
|
|
342
|
+
sash.updateFlexProperties({
|
|
343
|
+
flexGrow: 0,
|
|
344
|
+
flexShrink: 1,
|
|
345
|
+
flexBasis: `${sash.elementSize}px`,
|
|
346
|
+
});
|
|
319
347
|
}
|
|
320
348
|
});
|
|
321
349
|
}
|
|
@@ -323,86 +351,80 @@ class SciSashboxComponent {
|
|
|
323
351
|
this.sashing = false;
|
|
324
352
|
this.maxHeight = undefined;
|
|
325
353
|
this.maxWidth = undefined;
|
|
326
|
-
//
|
|
327
|
-
const pixelToFlexGrowFactor = computePixelToFlexGrowFactor(this.sashes);
|
|
328
|
-
const
|
|
329
|
-
this.sashes.forEach((sash, i) => {
|
|
330
|
-
if (!sash.isFixedSize) {
|
|
331
|
-
sash.
|
|
332
|
-
|
|
333
|
-
|
|
354
|
+
// Unset the flex-basis for non-fixed sashes and set the flex-grow accordingly.
|
|
355
|
+
const pixelToFlexGrowFactor = computePixelToFlexGrowFactor(this.sashes());
|
|
356
|
+
const sashSizes = this.sashes().reduce((acc, sash, i) => acc.set(sash.computeKey(i), sash.elementSize), new Map());
|
|
357
|
+
this.sashes().forEach((sash, i) => {
|
|
358
|
+
if (!sash.isFixedSize()) {
|
|
359
|
+
sash.updateFlexProperties({
|
|
360
|
+
flexGrow: pixelToFlexGrowFactor * sashSizes.get(sash.computeKey(i)),
|
|
361
|
+
flexShrink: 1,
|
|
362
|
+
flexBasis: '0',
|
|
363
|
+
});
|
|
334
364
|
}
|
|
335
365
|
});
|
|
336
|
-
this.sashEnd.emit(
|
|
366
|
+
this.sashEnd.emit(Array.from(sashSizes.values()));
|
|
367
|
+
this.sashEnd2.emit(Object.fromEntries(sashSizes));
|
|
337
368
|
}
|
|
338
369
|
onSash(splitter, sashIndex, moveEvent) {
|
|
370
|
+
NgZone.assertNotInAngularZone();
|
|
339
371
|
const distance = moveEvent.distance;
|
|
340
372
|
if (distance === 0) {
|
|
341
373
|
return;
|
|
342
374
|
}
|
|
343
|
-
|
|
344
|
-
// compute the splitter position
|
|
375
|
+
// Compute the splitter position.
|
|
345
376
|
const splitterRect = splitter.getBoundingClientRect();
|
|
346
377
|
const splitterStart = (this.isRowDirection ? splitterRect.left : splitterRect.top);
|
|
347
378
|
const splitterEnd = (this.isRowDirection ? splitterRect.left + splitterRect.width : splitterRect.top + splitterRect.height);
|
|
348
|
-
//
|
|
379
|
+
// Ignore the event if outside the splitter's action scope.
|
|
349
380
|
const eventPos = moveEvent.position.clientPos;
|
|
350
|
-
//
|
|
381
|
+
// The sash should not grow after moved the mouse pointer beyond the left bounds of the sash and now moving the mouse pointer back toward the current sash.
|
|
351
382
|
if (distance > 0 && eventPos < splitterStart) {
|
|
352
383
|
return;
|
|
353
384
|
}
|
|
354
|
-
//
|
|
385
|
+
// The sash should not shrink after moved the mouse pointer beyond the right bounds of the sash and now moving the mouse pointer back toward the current sash.
|
|
355
386
|
if (distance < 0 && eventPos > splitterEnd) {
|
|
356
387
|
return;
|
|
357
388
|
}
|
|
358
|
-
//
|
|
359
|
-
const sash1 = this.sashes[sashIndex];
|
|
360
|
-
const sash2 = this.sashes[sashIndex + 1];
|
|
361
|
-
const sashSize1 = sash1.
|
|
362
|
-
const sashSize2 = sash2.
|
|
363
|
-
const sashMinSize1 = sash1.minSize ? this.toPixel(sash1.minSize) : 0;
|
|
364
|
-
const sashMinSize2 = sash2.minSize ? this.toPixel(sash2.minSize) : 0;
|
|
389
|
+
// Compute the new sash sizes.
|
|
390
|
+
const sash1 = this.sashes()[sashIndex];
|
|
391
|
+
const sash2 = this.sashes()[sashIndex + 1];
|
|
392
|
+
const sashSize1 = sash1.elementSize;
|
|
393
|
+
const sashSize2 = sash2.elementSize;
|
|
394
|
+
const sashMinSize1 = sash1.minSize() ? this.toPixel(sash1.minSize()) : 0;
|
|
395
|
+
const sashMinSize2 = sash2.minSize() ? this.toPixel(sash2.minSize()) : 0;
|
|
365
396
|
const newSashSize1 = between(Math.round(sashSize1 + distance), { min: sashMinSize1, max: sashSize1 + sashSize2 - sashMinSize2 });
|
|
366
397
|
const newSashSize2 = between(Math.round(sashSize2 - distance), { min: sashMinSize2, max: sashSize1 + sashSize2 - sashMinSize1 });
|
|
367
|
-
//
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
sash2.flexBasis = `${newSashSize2}px`;
|
|
371
|
-
});
|
|
398
|
+
// Set the new computed sash sizes.
|
|
399
|
+
sash1.updateFlexProperties({ flexBasis: `${newSashSize1}px` });
|
|
400
|
+
sash2.updateFlexProperties({ flexBasis: `${newSashSize2}px` });
|
|
372
401
|
}
|
|
373
402
|
onSashReset(sashIndex) {
|
|
374
|
-
const sash1 = this.sashes[sashIndex];
|
|
375
|
-
const sash2 = this.sashes[sashIndex + 1];
|
|
376
|
-
const equalSashSize = (sash1.
|
|
377
|
-
const pixelToFlexGrowFactor = computePixelToFlexGrowFactor(this.sashes);
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return sash.computedSize;
|
|
383
|
-
});
|
|
403
|
+
const sash1 = this.sashes()[sashIndex];
|
|
404
|
+
const sash2 = this.sashes()[sashIndex + 1];
|
|
405
|
+
const equalSashSize = (sash1.elementSize + sash2.elementSize) / 2;
|
|
406
|
+
const pixelToFlexGrowFactor = computePixelToFlexGrowFactor(this.sashes());
|
|
407
|
+
const sashSizesAfterReset = this.sashes().reduce((acc, sash, index) => {
|
|
408
|
+
const size = index === sashIndex || index === sashIndex + 1 ? equalSashSize : sash.elementSize;
|
|
409
|
+
return acc.set(sash.computeKey(index), size);
|
|
410
|
+
}, new Map());
|
|
384
411
|
[sash1, sash2].forEach(sash => {
|
|
385
|
-
if (sash.isFixedSize) {
|
|
386
|
-
sash.flexBasis
|
|
412
|
+
if (sash.isFixedSize()) {
|
|
413
|
+
sash.updateFlexProperties({ flexBasis: `${equalSashSize}px` });
|
|
387
414
|
}
|
|
388
415
|
else {
|
|
389
|
-
sash.flexGrow
|
|
416
|
+
sash.updateFlexProperties({ flexGrow: pixelToFlexGrowFactor * equalSashSize });
|
|
390
417
|
}
|
|
391
418
|
});
|
|
392
419
|
this.sashStart.emit();
|
|
393
|
-
this.sashEnd.emit(
|
|
420
|
+
this.sashEnd.emit(Array.from(sashSizesAfterReset.values()));
|
|
421
|
+
this.sashEnd2.emit(Object.fromEntries(sashSizesAfterReset));
|
|
394
422
|
}
|
|
395
423
|
get isColumnDirection() {
|
|
396
|
-
return this.direction === 'column';
|
|
424
|
+
return this.direction() === 'column';
|
|
397
425
|
}
|
|
398
426
|
get isRowDirection() {
|
|
399
|
-
return this.direction === 'row';
|
|
400
|
-
}
|
|
401
|
-
get sashes() {
|
|
402
|
-
return this.sashes$.value;
|
|
403
|
-
}
|
|
404
|
-
ngOnDestroy() {
|
|
405
|
-
this._destroy$.next();
|
|
427
|
+
return this.direction() === 'row';
|
|
406
428
|
}
|
|
407
429
|
toPixel(value) {
|
|
408
430
|
if (typeof value === 'number') {
|
|
@@ -415,16 +437,15 @@ class SciSashboxComponent {
|
|
|
415
437
|
}
|
|
416
438
|
return parseInt(value, 10);
|
|
417
439
|
}
|
|
418
|
-
static
|
|
419
|
-
static
|
|
440
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
441
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.0", type: SciSashboxComponent, isStandalone: true, selector: "sci-sashbox", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { sashStart: "sashStart", sashEnd: "sashEnd", sashEnd2: "sashEnd2" }, host: { properties: { "class.sashing": "this.sashing", "style.--\u0275sci-sashbox-max-height": "this.maxHeight", "style.--\u0275sci-sashbox-max-width": "this.maxWidth", "class.column": "this.isColumnDirection", "class.row": "this.isRowDirection" } }, providers: [{
|
|
420
442
|
provide: SciSashBoxAccessor,
|
|
421
443
|
useFactory: provideSashBoxAccessor,
|
|
422
|
-
}], queries: [{ propertyName: "
|
|
444
|
+
}], queries: [{ propertyName: "sashes", predicate: SciSashDirective, isSignal: true }], ngImport: i0, template: "@for (sash of sashes(); track sash; let i = $index; let first = $first; let last = $last) {\n <div class=\"sash\"\n [class.first]=\"first\"\n [class.last]=\"last\"\n [sciSashInitializer]=\"sash\"\n [style.flex-grow]=\"sash.flexProperties().flexGrow\"\n [style.flex-shrink]=\"sash.flexProperties().flexShrink\"\n [style.flex-basis]=\"sash.flexProperties().flexBasis\">\n <ng-container *ngTemplateOutlet=\"sash.sashTemplate\"/>\n </div>\n @if (!last) {\n <sci-splitter sciElementRef #sciElementRef=\"sciElementRef\"\n [orientation]=\"isRowDirection ? 'vertical' : 'horizontal'\"\n (start)=\"onSashStart()\"\n (move)=\"onSash(sciElementRef.host, i, $event)\"\n (end)=\"onSashEnd()\"\n (reset)=\"onSashReset(i)\"/>\n }\n}\n", styles: ["@charset \"UTF-8\";:host{display:flex;align-items:stretch;box-sizing:border-box;overflow:hidden;z-index:0}:host *{box-sizing:border-box}:host.column{flex-direction:column}:host.row{flex-direction:row}:host>div.sash{overflow:hidden;display:grid;grid-auto-rows:100%;grid-auto-columns:100%}:host.row>div.sash{margin:0 var(--sci-sashbox-gap)}:host.row>div.sash.first{margin-left:0}:host.row>div.sash.last{margin-right:0}:host.column>div.sash{margin:var(--sci-sashbox-gap) 0}:host.column>div.sash.first{margin-top:0}:host.column>div.sash.last{margin-bottom:0}:host.sashing{max-height:calc(var(--\\275sci-sashbox-max-height) * 1px);max-width:calc(var(--\\275sci-sashbox-max-width) * 1px)}:host.sashing>div.sash{pointer-events:none}:host>sci-splitter{--sci-splitter-background-color: var(--sci-sashbox-splitter-background-color);--sci-splitter-background-color-hover: var(--sci-sashbox-splitter-background-color-hover);--sci-splitter-size: var(--sci-sashbox-splitter-size);--sci-splitter-size-hover: var(--sci-sashbox-splitter-size-hover);--sci-splitter-touch-target-size: var(--sci-sashbox-splitter-touch-target-size);--sci-splitter-cross-axis-size: var(--sci-sashbox-splitter-cross-axis-size);--sci-splitter-border-radius: var(--sci-sashbox-splitter-border-radius);--sci-splitter-opacity-active: var(--sci-sashbox-splitter-opacity-active);--sci-splitter-opacity-hover: var(--sci-sashbox-splitter-opacity-hover);flex:none;z-index:1}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: SciSashInitializerDirective, selector: "div[sciSashInitializer].sash", inputs: ["sciSashInitializer"] }, { kind: "component", type: SciSplitterComponent, selector: "sci-splitter", inputs: ["orientation"], outputs: ["start", "move", "end", "reset"] }, { kind: "directive", type: SciElementRefDirective, selector: "[sciElementRef]", exportAs: ["sciElementRef"] }] });
|
|
423
445
|
}
|
|
424
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxComponent, decorators: [{
|
|
425
447
|
type: Component,
|
|
426
|
-
args: [{ selector: 'sci-sashbox',
|
|
427
|
-
AsyncPipe,
|
|
448
|
+
args: [{ selector: 'sci-sashbox', imports: [
|
|
428
449
|
NgTemplateOutlet,
|
|
429
450
|
SciSashInitializerDirective,
|
|
430
451
|
SciSplitterComponent,
|
|
@@ -432,7 +453,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
432
453
|
], providers: [{
|
|
433
454
|
provide: SciSashBoxAccessor,
|
|
434
455
|
useFactory: provideSashBoxAccessor,
|
|
435
|
-
}], template: "@for (sash of sashes
|
|
456
|
+
}], template: "@for (sash of sashes(); track sash; let i = $index; let first = $first; let last = $last) {\n <div class=\"sash\"\n [class.first]=\"first\"\n [class.last]=\"last\"\n [sciSashInitializer]=\"sash\"\n [style.flex-grow]=\"sash.flexProperties().flexGrow\"\n [style.flex-shrink]=\"sash.flexProperties().flexShrink\"\n [style.flex-basis]=\"sash.flexProperties().flexBasis\">\n <ng-container *ngTemplateOutlet=\"sash.sashTemplate\"/>\n </div>\n @if (!last) {\n <sci-splitter sciElementRef #sciElementRef=\"sciElementRef\"\n [orientation]=\"isRowDirection ? 'vertical' : 'horizontal'\"\n (start)=\"onSashStart()\"\n (move)=\"onSash(sciElementRef.host, i, $event)\"\n (end)=\"onSashEnd()\"\n (reset)=\"onSashReset(i)\"/>\n }\n}\n", styles: ["@charset \"UTF-8\";:host{display:flex;align-items:stretch;box-sizing:border-box;overflow:hidden;z-index:0}:host *{box-sizing:border-box}:host.column{flex-direction:column}:host.row{flex-direction:row}:host>div.sash{overflow:hidden;display:grid;grid-auto-rows:100%;grid-auto-columns:100%}:host.row>div.sash{margin:0 var(--sci-sashbox-gap)}:host.row>div.sash.first{margin-left:0}:host.row>div.sash.last{margin-right:0}:host.column>div.sash{margin:var(--sci-sashbox-gap) 0}:host.column>div.sash.first{margin-top:0}:host.column>div.sash.last{margin-bottom:0}:host.sashing{max-height:calc(var(--\\275sci-sashbox-max-height) * 1px);max-width:calc(var(--\\275sci-sashbox-max-width) * 1px)}:host.sashing>div.sash{pointer-events:none}:host>sci-splitter{--sci-splitter-background-color: var(--sci-sashbox-splitter-background-color);--sci-splitter-background-color-hover: var(--sci-sashbox-splitter-background-color-hover);--sci-splitter-size: var(--sci-sashbox-splitter-size);--sci-splitter-size-hover: var(--sci-sashbox-splitter-size-hover);--sci-splitter-touch-target-size: var(--sci-sashbox-splitter-touch-target-size);--sci-splitter-cross-axis-size: var(--sci-sashbox-splitter-cross-axis-size);--sci-splitter-border-radius: var(--sci-sashbox-splitter-border-radius);--sci-splitter-opacity-active: var(--sci-sashbox-splitter-opacity-active);--sci-splitter-opacity-hover: var(--sci-sashbox-splitter-opacity-hover);flex:none;z-index:1}\n"] }]
|
|
436
457
|
}], propDecorators: { sashing: [{
|
|
437
458
|
type: HostBinding,
|
|
438
459
|
args: ['class.sashing']
|
|
@@ -442,15 +463,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImpor
|
|
|
442
463
|
}], maxWidth: [{
|
|
443
464
|
type: HostBinding,
|
|
444
465
|
args: ['style.--ɵsci-sashbox-max-width']
|
|
445
|
-
}], direction: [{
|
|
446
|
-
type: Input
|
|
447
|
-
}], sashStart: [{
|
|
448
|
-
type: Output
|
|
449
|
-
}], sashEnd: [{
|
|
450
|
-
type: Output
|
|
451
|
-
}], setSashes: [{
|
|
452
|
-
type: ContentChildren,
|
|
453
|
-
args: [SciSashDirective]
|
|
454
466
|
}], isColumnDirection: [{
|
|
455
467
|
type: HostBinding,
|
|
456
468
|
args: ['class.column']
|
|
@@ -465,24 +477,17 @@ function between(value, minmax) {
|
|
|
465
477
|
* Returns the factor to compute the flex-grow proportion from the pixel size of a sash.
|
|
466
478
|
*/
|
|
467
479
|
function computePixelToFlexGrowFactor(sashes) {
|
|
468
|
-
const flexibleSashes = sashes.filter(sash => !sash.isFixedSize);
|
|
469
|
-
const proportionSum = flexibleSashes.reduce((sum, sash) => sum + Number(sash.size), 0);
|
|
470
|
-
const pixelSum = flexibleSashes.reduce((sum, sash) => sum + sash.
|
|
480
|
+
const flexibleSashes = sashes.filter(sash => !sash.isFixedSize());
|
|
481
|
+
const proportionSum = flexibleSashes.reduce((sum, sash) => sum + Number(sash.size()), 0);
|
|
482
|
+
const pixelSum = flexibleSashes.reduce((sum, sash) => sum + sash.elementSize, 0);
|
|
471
483
|
return proportionSum / pixelSum;
|
|
472
484
|
}
|
|
473
485
|
function provideSashBoxAccessor() {
|
|
474
486
|
const component = inject(SciSashboxComponent);
|
|
475
487
|
return new class {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
get sashes$() {
|
|
480
|
-
return component.sashes$;
|
|
481
|
-
}
|
|
482
|
-
get sashes() {
|
|
483
|
-
return component.sashes$.value;
|
|
484
|
-
}
|
|
485
|
-
};
|
|
488
|
+
direction = component.direction;
|
|
489
|
+
sashes = component.sashes;
|
|
490
|
+
}();
|
|
486
491
|
}
|
|
487
492
|
|
|
488
493
|
/*
|
|
@@ -514,15 +519,17 @@ function provideSashBoxAccessor() {
|
|
|
514
519
|
* </ng-template>
|
|
515
520
|
* </sci-sashbox>
|
|
516
521
|
* ```
|
|
522
|
+
*
|
|
523
|
+
* @deprecated since version 19.0.0; Import standalone component and directive instead; API will be removed in a future release.
|
|
517
524
|
*/
|
|
518
525
|
class SciSashboxModule {
|
|
519
|
-
static
|
|
520
|
-
static
|
|
526
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
527
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxModule, imports: [SciSashboxComponent,
|
|
521
528
|
SciSashDirective], exports: [SciSashboxComponent,
|
|
522
|
-
SciSashDirective] });
|
|
523
|
-
static
|
|
529
|
+
SciSashDirective] });
|
|
530
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxModule, imports: [SciSashboxComponent] });
|
|
524
531
|
}
|
|
525
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
532
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: SciSashboxModule, decorators: [{
|
|
526
533
|
type: NgModule,
|
|
527
534
|
args: [{
|
|
528
535
|
imports: [
|