@alauda/ui 7.3.3-beta.33 → 7.3.3-beta.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -332,9 +332,7 @@ class StylesRenderer {
332
332
  this.styleElement.innerHTML = styles;
333
333
  }
334
334
  cleanup() {
335
- if (this.styleElement) {
336
- this.styleElement.remove();
337
- }
335
+ this.styleElement?.remove();
338
336
  }
339
337
  }
340
338
  class CSSStyleSheetRenderer {
@@ -354,8 +352,11 @@ class CSSStyleSheetRenderer {
354
352
  this.styleSheet.replaceSync(styles);
355
353
  }
356
354
  cleanup() {
357
- if (this.styleSheet) {
358
- const i = document.adoptedStyleSheets.indexOf(this.styleSheet);
355
+ if (!this.styleSheet) {
356
+ return;
357
+ }
358
+ const i = document.adoptedStyleSheets.indexOf(this.styleSheet);
359
+ if (i >= 0) {
359
360
  document.adoptedStyleSheets.splice(i, 1);
360
361
  }
361
362
  }
@@ -9885,6 +9886,149 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
9885
9886
  type: Input
9886
9887
  }] } });
9887
9888
 
9889
+ let tableColumnResizableID = 0;
9890
+ const resizableBem = buildBem('aui-table-column-resizable');
9891
+ const markLineWidth = 1;
9892
+ class TableColumnResizableDirective {
9893
+ minWidth = '40px';
9894
+ maxWidth = '80%';
9895
+ renderer2 = inject(Renderer2);
9896
+ tableColumnDefDirective = inject(TableColumnDefDirective);
9897
+ tableComponent = inject(TableComponent);
9898
+ columnElement = inject(ElementRef).nativeElement;
9899
+ containerElement = this.tableComponent.elementRef.nativeElement;
9900
+ hostAttr = `table-column-resizable-${tableColumnResizableID++}`;
9901
+ stylesRenderer = getCompatibleStylesRenderer();
9902
+ resizeSubscription;
9903
+ ngOnInit() {
9904
+ this.containerElement.setAttribute(this.hostAttr, '');
9905
+ }
9906
+ ngAfterViewInit() {
9907
+ const resizeHandle = this.createResizeHandle();
9908
+ this.bindResizable(resizeHandle);
9909
+ }
9910
+ ngOnDestroy() {
9911
+ this.resizeSubscription?.unsubscribe();
9912
+ this.containerElement.removeAttribute(this.hostAttr);
9913
+ this.stylesRenderer.cleanup();
9914
+ }
9915
+ bindResizable(resizeHandle) {
9916
+ const mouseUp$ = fromEvent(document, 'mouseup').pipe(take(1));
9917
+ const mouseMove$ = fromEvent(document, 'mousemove').pipe(takeUntil(mouseUp$));
9918
+ this.resizeSubscription = fromEvent(resizeHandle, 'mousedown')
9919
+ .pipe(switchMap(mouseDownEvent => {
9920
+ mouseDownEvent.preventDefault();
9921
+ mouseDownEvent.stopPropagation();
9922
+ this.renderer2.setStyle(resizeHandle, 'visibility', 'hidden');
9923
+ const resizeRange = this.getResizeRange();
9924
+ const initialMouseX = mouseDownEvent.clientX;
9925
+ const columnWidth = this.getColumnWidth();
9926
+ const columnOffset = this.getColumnOffset();
9927
+ const resizeMarkLine = this.createResizeMarkLine(columnOffset + columnWidth);
9928
+ const resizeOverlay = this.createResizeOverlay();
9929
+ return merge$1(mouseMove$.pipe(map(mouseMoveEvent => () => resizeMarkLine.updateOffset(columnOffset +
9930
+ this.getWidthInRange(resizeRange, columnWidth + mouseMoveEvent.clientX - initialMouseX)))), mouseUp$.pipe(map(mouseUpEvent => () => {
9931
+ this.renderer2.removeStyle(resizeHandle, 'visibility');
9932
+ resizeMarkLine.destroy();
9933
+ resizeOverlay.destroy();
9934
+ this.renderWidthStyles(this.getWidthInRange(resizeRange, columnWidth + mouseUpEvent.clientX - initialMouseX));
9935
+ })));
9936
+ }))
9937
+ .subscribe(exec => {
9938
+ exec();
9939
+ });
9940
+ }
9941
+ createResizeHandle() {
9942
+ const resizeHandle = this.renderer2.createElement('div');
9943
+ this.renderer2.addClass(resizeHandle, resizableBem.element('handle'));
9944
+ this.renderer2.appendChild(this.columnElement, resizeHandle);
9945
+ return resizeHandle;
9946
+ }
9947
+ createResizeMarkLine(initialOffset) {
9948
+ const markLine = this.renderer2.createElement('div');
9949
+ this.renderer2.addClass(markLine, resizableBem.element('mark-line'));
9950
+ this.renderer2.setStyle(markLine, 'left', initialOffset - markLineWidth + 'px');
9951
+ if (this.isStickyLeftBorderColumn()) {
9952
+ this.renderer2.addClass(markLine, 'inStickyBorderElemLeft');
9953
+ }
9954
+ this.renderer2.appendChild(this.containerElement, markLine);
9955
+ return {
9956
+ element: markLine,
9957
+ updateOffset: (offset) => {
9958
+ this.renderer2.setStyle(markLine, 'left', offset - markLineWidth + 'px');
9959
+ },
9960
+ destroy: () => {
9961
+ this.renderer2.removeChild(this.containerElement, markLine);
9962
+ },
9963
+ };
9964
+ }
9965
+ createResizeOverlay() {
9966
+ const resizeOverlay = this.renderer2.createElement('div');
9967
+ this.renderer2.addClass(resizeOverlay, resizableBem.element('overlay'));
9968
+ this.renderer2.appendChild(this.containerElement, resizeOverlay);
9969
+ return {
9970
+ element: resizeOverlay,
9971
+ destroy: () => {
9972
+ this.renderer2.removeChild(this.containerElement, resizeOverlay);
9973
+ },
9974
+ };
9975
+ }
9976
+ getColumnWidth() {
9977
+ return this.columnElement.clientWidth;
9978
+ }
9979
+ getColumnOffset() {
9980
+ return (this.columnElement.getBoundingClientRect().left -
9981
+ this.containerElement.getBoundingClientRect().left);
9982
+ }
9983
+ getWidthInRange([minWidth, maxWidth], width) {
9984
+ return Math.min(Math.max(width, minWidth), maxWidth);
9985
+ }
9986
+ getResizeRange() {
9987
+ const minWidth = this.getActualWidth(this.minWidth);
9988
+ const maxWidth = this.getActualWidth(this.maxWidth);
9989
+ return [minWidth, maxWidth];
9990
+ }
9991
+ getActualWidth(width) {
9992
+ if (typeof width === 'number') {
9993
+ return width;
9994
+ }
9995
+ if (width.endsWith('%')) {
9996
+ return ((this.containerElement.clientWidth * parseInt(width.slice(0, -1))) / 100);
9997
+ }
9998
+ if (width.endsWith('px')) {
9999
+ return parseInt(width.slice(0, -2));
10000
+ }
10001
+ return parseInt(width);
10002
+ }
10003
+ isStickyLeftBorderColumn() {
10004
+ return this.columnElement.classList.contains('aui-table-sticky-border-elem-left');
10005
+ }
10006
+ renderWidthStyles(width) {
10007
+ const className = tableBem.element(`column-${this.tableColumnDefDirective.cssClassFriendlyName}`);
10008
+ const styleString = `[${this.hostAttr}] .${className} {
10009
+ flex: none !important;
10010
+ width: ${width}px !important;
10011
+ min-width: ${width}px !important;
10012
+ max-width: ${width}px !important;
10013
+ }`;
10014
+ this.stylesRenderer.render(styleString);
10015
+ this.tableComponent.updateStickyColumnStyles();
10016
+ }
10017
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableColumnResizableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
10018
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.3", type: TableColumnResizableDirective, isStandalone: true, selector: "[auiTableColumnResizable]", inputs: { minWidth: "minWidth", maxWidth: "maxWidth" }, ngImport: i0 });
10019
+ }
10020
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableColumnResizableDirective, decorators: [{
10021
+ type: Directive,
10022
+ args: [{
10023
+ selector: '[auiTableColumnResizable]',
10024
+ standalone: true,
10025
+ }]
10026
+ }], propDecorators: { minWidth: [{
10027
+ type: Input
10028
+ }], maxWidth: [{
10029
+ type: Input
10030
+ }] } });
10031
+
9888
10032
  class TableHeaderCellDefDirective extends CdkHeaderCellDef {
9889
10033
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableHeaderCellDefDirective, deps: null, target: i0.ɵɵFactoryTarget.Directive });
9890
10034
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.3", type: TableHeaderCellDefDirective, isStandalone: true, selector: "[auiTableHeaderCellDef]", providers: [
@@ -10176,12 +10320,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImpor
10176
10320
  args: ['class']
10177
10321
  }] } });
10178
10322
 
10323
+ const TABLE_MODULE = [
10324
+ TableComponent,
10325
+ TableRowComponent,
10326
+ TableHeaderRowComponent,
10327
+ TableExpandButtonCellComponent,
10328
+ TableExpandPanelCellComponent,
10329
+ TableCellDirective,
10330
+ TableCellDefDirective,
10331
+ TableHeaderCellDirective,
10332
+ TableRowDefDirective,
10333
+ TableHeaderRowDefDirective,
10334
+ TableHeaderCellDefDirective,
10335
+ TableColumnDefDirective,
10336
+ TableColumnResizableDirective,
10337
+ TablePlaceholderOutletDirective,
10338
+ TablePlaceholderDefDirective,
10339
+ TableScrollWrapperDirective,
10340
+ TableScrollableDirective,
10341
+ ];
10179
10342
  class TableModule {
10180
10343
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10181
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: TableModule, imports: [CommonModule,
10182
- IconModule,
10183
- CdkTableModule,
10184
- TableComponent,
10344
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: TableModule, imports: [TableComponent,
10185
10345
  TableRowComponent,
10186
10346
  TableHeaderRowComponent,
10187
10347
  TableExpandButtonCellComponent,
@@ -10193,10 +10353,11 @@ class TableModule {
10193
10353
  TableHeaderRowDefDirective,
10194
10354
  TableHeaderCellDefDirective,
10195
10355
  TableColumnDefDirective,
10196
- TableScrollableDirective,
10356
+ TableColumnResizableDirective,
10197
10357
  TablePlaceholderOutletDirective,
10198
10358
  TablePlaceholderDefDirective,
10199
- TableScrollWrapperDirective], exports: [TableComponent,
10359
+ TableScrollWrapperDirective,
10360
+ TableScrollableDirective], exports: [TableComponent,
10200
10361
  TableRowComponent,
10201
10362
  TableHeaderRowComponent,
10202
10363
  TableExpandButtonCellComponent,
@@ -10208,222 +10369,22 @@ class TableModule {
10208
10369
  TableHeaderRowDefDirective,
10209
10370
  TableHeaderCellDefDirective,
10210
10371
  TableColumnDefDirective,
10211
- TableScrollableDirective,
10372
+ TableColumnResizableDirective,
10212
10373
  TablePlaceholderOutletDirective,
10213
10374
  TablePlaceholderDefDirective,
10214
- TableScrollWrapperDirective] });
10215
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableModule, imports: [CommonModule,
10216
- IconModule,
10217
- CdkTableModule,
10218
- TableComponent,
10375
+ TableScrollWrapperDirective,
10376
+ TableScrollableDirective] });
10377
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableModule, imports: [TableComponent,
10219
10378
  TableRowComponent,
10220
10379
  TableHeaderRowComponent] });
10221
10380
  }
10222
10381
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableModule, decorators: [{
10223
10382
  type: NgModule,
10224
10383
  args: [{
10225
- imports: [
10226
- CommonModule,
10227
- IconModule,
10228
- CdkTableModule,
10229
- TableComponent,
10230
- TableRowComponent,
10231
- TableHeaderRowComponent,
10232
- TableExpandButtonCellComponent,
10233
- TableExpandPanelCellComponent,
10234
- TableCellDirective,
10235
- TableCellDefDirective,
10236
- TableHeaderCellDirective,
10237
- TableRowDefDirective,
10238
- TableHeaderRowDefDirective,
10239
- TableHeaderCellDefDirective,
10240
- TableColumnDefDirective,
10241
- TableScrollableDirective,
10242
- TablePlaceholderOutletDirective,
10243
- TablePlaceholderDefDirective,
10244
- TableScrollWrapperDirective,
10245
- ],
10246
- exports: [
10247
- TableComponent,
10248
- TableRowComponent,
10249
- TableHeaderRowComponent,
10250
- TableExpandButtonCellComponent,
10251
- TableExpandPanelCellComponent,
10252
- TableCellDirective,
10253
- TableCellDefDirective,
10254
- TableHeaderCellDirective,
10255
- TableRowDefDirective,
10256
- TableHeaderRowDefDirective,
10257
- TableHeaderCellDefDirective,
10258
- TableColumnDefDirective,
10259
- TableScrollableDirective,
10260
- TablePlaceholderOutletDirective,
10261
- TablePlaceholderDefDirective,
10262
- TableScrollWrapperDirective,
10263
- ],
10384
+ imports: [...TABLE_MODULE],
10385
+ exports: [...TABLE_MODULE],
10264
10386
  }]
10265
10387
  }] });
10266
- const TABLE_MODULE = [
10267
- TableComponent,
10268
- TableRowComponent,
10269
- TableHeaderRowComponent,
10270
- TableExpandButtonCellComponent,
10271
- TableExpandPanelCellComponent,
10272
- TableCellDirective,
10273
- TableCellDefDirective,
10274
- TableHeaderCellDirective,
10275
- TableRowDefDirective,
10276
- TableHeaderRowDefDirective,
10277
- TableHeaderCellDefDirective,
10278
- TableColumnDefDirective,
10279
- TableScrollableDirective,
10280
- TablePlaceholderOutletDirective,
10281
- TablePlaceholderDefDirective,
10282
- TableScrollWrapperDirective,
10283
- ];
10284
-
10285
- let tableColumnResizableID = 0;
10286
- const resizableBem = buildBem('aui-table-column-resizable');
10287
- const markLineWidth = 1;
10288
- class TableColumnResizableDirective {
10289
- minWidth = '40px';
10290
- maxWidth = '80%';
10291
- renderer2 = inject(Renderer2);
10292
- tableColumnDefDirective = inject(TableColumnDefDirective);
10293
- tableComponent = inject(TableComponent);
10294
- columnElement = inject(ElementRef).nativeElement;
10295
- containerElement = this.tableComponent.elementRef.nativeElement;
10296
- hostAttr = `table-column-resizable-${tableColumnResizableID++}`;
10297
- stylesRenderer = getCompatibleStylesRenderer();
10298
- resizeSubscription;
10299
- ngOnInit() {
10300
- this.containerElement.setAttribute(this.hostAttr, '');
10301
- }
10302
- ngAfterViewInit() {
10303
- const resizeHandle = this.createResizeHandle();
10304
- this.bindResizable(resizeHandle);
10305
- }
10306
- ngOnDestroy() {
10307
- this.resizeSubscription?.unsubscribe();
10308
- this.containerElement.removeAttribute(this.hostAttr);
10309
- this.stylesRenderer.cleanup();
10310
- }
10311
- bindResizable(resizeHandle) {
10312
- this.resizeSubscription = fromEvent(resizeHandle, 'mousedown')
10313
- .pipe(switchMap(mouseDownEvent => {
10314
- mouseDownEvent.preventDefault();
10315
- mouseDownEvent.stopPropagation();
10316
- this.renderer2.setStyle(resizeHandle, 'visibility', 'hidden');
10317
- const resizeRange = this.getResizeRange();
10318
- const initialMouseX = mouseDownEvent.clientX;
10319
- const columnWidth = this.getColumnWidth();
10320
- const columnOffset = this.getColumnOffset();
10321
- const resizeMarkLine = this.createResizeMarkLine(columnOffset + columnWidth);
10322
- const resizeOverlay = this.createResizeOverlay();
10323
- const mouseUp$ = fromEvent(document, 'mouseup').pipe(take(1));
10324
- const mouseMove$ = fromEvent(document, 'mousemove').pipe(takeUntil(mouseUp$));
10325
- return merge$1(mouseMove$.pipe(map(mouseMoveEvent => () => resizeMarkLine.updateOffset(columnOffset +
10326
- this.getWidthInRange(resizeRange, columnWidth + mouseMoveEvent.clientX - initialMouseX)))), mouseUp$.pipe(map(mouseUpEvent => () => {
10327
- this.renderer2.removeStyle(resizeHandle, 'visibility');
10328
- resizeMarkLine.destroy();
10329
- resizeOverlay.destroy();
10330
- this.renderWidthStyles(this.getWidthInRange(resizeRange, columnWidth + mouseUpEvent.clientX - initialMouseX));
10331
- })));
10332
- }))
10333
- .subscribe(exec => {
10334
- exec();
10335
- });
10336
- }
10337
- createResizeHandle() {
10338
- const resizeHandle = this.renderer2.createElement('div');
10339
- this.renderer2.addClass(resizeHandle, resizableBem.element('handle'));
10340
- this.renderer2.appendChild(this.columnElement, resizeHandle);
10341
- return resizeHandle;
10342
- }
10343
- createResizeMarkLine(initialOffset) {
10344
- const markLine = this.renderer2.createElement('div');
10345
- this.renderer2.addClass(markLine, resizableBem.element('mark-line'));
10346
- this.renderer2.setStyle(markLine, 'left', initialOffset - markLineWidth + 'px');
10347
- if (this.isStickyLeftBorderColumn()) {
10348
- this.renderer2.addClass(markLine, 'inStickyBorderElemLeft');
10349
- }
10350
- this.renderer2.appendChild(this.containerElement, markLine);
10351
- return {
10352
- element: markLine,
10353
- updateOffset: (offset) => {
10354
- this.renderer2.setStyle(markLine, 'left', offset - markLineWidth + 'px');
10355
- },
10356
- destroy: () => {
10357
- this.renderer2.removeChild(this.containerElement, markLine);
10358
- },
10359
- };
10360
- }
10361
- createResizeOverlay() {
10362
- const resizeOverlay = this.renderer2.createElement('div');
10363
- this.renderer2.addClass(resizeOverlay, resizableBem.element('overlay'));
10364
- this.renderer2.appendChild(this.containerElement, resizeOverlay);
10365
- return {
10366
- element: resizeOverlay,
10367
- destroy: () => {
10368
- this.renderer2.removeChild(this.containerElement, resizeOverlay);
10369
- },
10370
- };
10371
- }
10372
- getColumnWidth() {
10373
- return this.columnElement.clientWidth;
10374
- }
10375
- getColumnOffset() {
10376
- return (this.columnElement.getBoundingClientRect().left -
10377
- this.containerElement.getBoundingClientRect().left);
10378
- }
10379
- getWidthInRange([minWidth, maxWidth], width) {
10380
- return Math.min(Math.max(width, minWidth), maxWidth);
10381
- }
10382
- getResizeRange() {
10383
- const minWidth = this.getActualWidth(this.minWidth);
10384
- const maxWidth = this.getActualWidth(this.maxWidth);
10385
- return [minWidth, maxWidth];
10386
- }
10387
- getActualWidth(width) {
10388
- if (typeof width === 'number') {
10389
- return width;
10390
- }
10391
- if (width.endsWith('%')) {
10392
- return ((this.containerElement.clientWidth * parseInt(width.slice(0, -1))) / 100);
10393
- }
10394
- if (width.endsWith('px')) {
10395
- return parseInt(width.slice(0, -2));
10396
- }
10397
- return parseInt(width);
10398
- }
10399
- isStickyLeftBorderColumn() {
10400
- return this.columnElement.classList.contains('aui-table-sticky-border-elem-left');
10401
- }
10402
- renderWidthStyles(width) {
10403
- const className = tableBem.element(`column-${this.tableColumnDefDirective.cssClassFriendlyName}`);
10404
- const styleString = `[${this.hostAttr}] .${className} {
10405
- flex: none !important;
10406
- width: ${width}px !important;
10407
- min-width: ${width}px !important;
10408
- max-width: ${width}px !important;
10409
- }`;
10410
- this.stylesRenderer.render(styleString);
10411
- this.tableComponent.updateStickyColumnStyles();
10412
- }
10413
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableColumnResizableDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
10414
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.3", type: TableColumnResizableDirective, isStandalone: true, selector: "[auiTableColumnResizable]", inputs: { minWidth: "minWidth", maxWidth: "maxWidth" }, ngImport: i0 });
10415
- }
10416
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: TableColumnResizableDirective, decorators: [{
10417
- type: Directive,
10418
- args: [{
10419
- selector: '[auiTableColumnResizable]',
10420
- standalone: true,
10421
- }]
10422
- }], propDecorators: { minWidth: [{
10423
- type: Input
10424
- }], maxWidth: [{
10425
- type: Input
10426
- }] } });
10427
10388
 
10428
10389
  class FixedSizeTableVirtualScrollStrategy {
10429
10390
  _rowHeight = 42;