-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: table supports the use of attributes #420
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CdkCell, CdkColumnDef } from '@angular/cdk/table'; | ||
import { Directive, ElementRef, Input } from '@angular/core'; | ||
|
||
import { buildBem } from '../../utils'; | ||
|
||
const bem = buildBem('aui-table'); | ||
|
||
/** Cell template container that adds the right classes and role. */ | ||
@Directive({ | ||
selector: '[auiTableCell]', | ||
host: { | ||
class: 'aui-table__cell', | ||
role: 'gridcell', | ||
'[class.aui-table__cell--column]': 'direction === "column"', | ||
}, | ||
}) | ||
export class NewTableCellDirective extends CdkCell { | ||
@Input() | ||
direction: 'row' | 'column' = 'row'; | ||
|
||
constructor(columnDef: CdkColumnDef, elementRef: ElementRef<HTMLElement>) { | ||
super(columnDef, elementRef); | ||
elementRef.nativeElement.classList.add( | ||
bem.element(`column-${columnDef.cssClassFriendlyName}`), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { CdkColumnDef, CdkHeaderCell } from '@angular/cdk/table'; | ||
import { Directive, ElementRef } from '@angular/core'; | ||
|
||
import { buildBem } from '../../utils'; | ||
|
||
const bem = buildBem('aui-table'); | ||
|
||
/** Header cell template container that adds the right classes and role. */ | ||
@Directive({ | ||
selector: '[auiTableHeaderCell]', | ||
host: { | ||
class: 'aui-table__header-cell', | ||
role: 'columnheader', | ||
}, | ||
}) | ||
export class NewTableHeaderCellDirective extends CdkHeaderCell { | ||
constructor(columnDef: CdkColumnDef, elementRef: ElementRef<HTMLElement>) { | ||
super(columnDef, elementRef); | ||
elementRef.nativeElement.classList.add( | ||
bem.element(`column-${columnDef.cssClassFriendlyName}`), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { CDK_ROW_TEMPLATE, CdkHeaderRow } from '@angular/cdk/table'; | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ViewEncapsulation, | ||
} from '@angular/core'; | ||
|
||
/** Header template container that contains the cell outlet. Adds the right class and role. */ | ||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'tr[auiTableHeaderRow]', | ||
template: CDK_ROW_TEMPLATE, | ||
host: { | ||
class: 'aui-table__header-row', | ||
role: 'row', | ||
}, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
exportAs: 'auiTableHeaderRow', | ||
preserveWhitespaces: false, | ||
}) | ||
export class NewTableHeaderRowComponent extends CdkHeaderRow {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CDK_ROW_TEMPLATE, CdkRow } from '@angular/cdk/table'; | ||
import { | ||
AfterContentInit, | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
HostBinding, | ||
Input, | ||
ViewEncapsulation, | ||
} from '@angular/core'; | ||
|
||
/** Data row template container that contains the cell outlet. Adds the right class and role. */ | ||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'tr[auiTableRow]', | ||
template: CDK_ROW_TEMPLATE, | ||
host: { | ||
class: 'aui-table__row', | ||
role: 'row', | ||
}, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
exportAs: 'auiTableRow', | ||
preserveWhitespaces: false, | ||
}) | ||
export class NewTableRowComponent extends CdkRow implements AfterContentInit { | ||
@Input() | ||
@HostBinding('class.isDisabled') | ||
disabled = false; | ||
|
||
@HostBinding('class.hasPanel') | ||
hasPanel = false; | ||
|
||
constructor(private readonly elRef: ElementRef<HTMLElement>) { | ||
super(); | ||
} | ||
|
||
ngAfterContentInit() { | ||
const panel = this.elRef.nativeElement.querySelector( | ||
'[auiTableCell][auiExpandPanel]', | ||
); | ||
this.hasPanel = !!panel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
@import '../../theme/var'; | ||
@import '../../theme/mixin'; | ||
|
||
$stickyCssClass: 'aui-table-sticky'; | ||
|
||
// stylelint-disable plugin/no-low-performance-animation-properties | ||
|
||
// style for column shadow | ||
.aui-table__scroll-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
max-height: 100%; | ||
overflow: hidden; | ||
background-color: use-rgb(n-9); | ||
padding: 0 $table-padding $table-padding; | ||
border-radius: use-var(border-radius-l); | ||
@include scroll-bar; | ||
|
||
.aui-table { | ||
padding: 0; | ||
border-radius: 0; | ||
} | ||
|
||
.aui-table__scroll-shadow { | ||
&.hasTableTopShadow:before, | ||
&.hasTableBottomShadow:after { | ||
transform: none; | ||
width: 100%; | ||
left: 0; | ||
} | ||
} | ||
} | ||
|
||
// style for vertical shadow | ||
.aui-table__scroll-shadow { | ||
&.aui-table { | ||
overflow: auto; | ||
@include scroll-bar; | ||
} | ||
|
||
&.hasTableTopShadow:before { | ||
content: ''; | ||
position: sticky; | ||
display: block; | ||
height: 16px; | ||
margin: -16px -12px 0; | ||
z-index: 99; | ||
top: 28px; | ||
@include theme-light { | ||
box-shadow: 0 10px 10px -4px use-rgba(n-1, 0.16); | ||
} | ||
@include theme-dark { | ||
box-shadow: 0 10px 10px -4px use-rgba(n-9, 0.75); | ||
} | ||
} | ||
|
||
&.hasTableBottomShadow:after { | ||
content: ''; | ||
position: sticky; | ||
display: block; | ||
height: 16px; | ||
transform: translate3d(0, 12px, 0); | ||
z-index: 99; | ||
bottom: 0; | ||
margin: -16px -12px 0; | ||
@include theme-light { | ||
box-shadow: 0 -10px 10px -4px use-rgba(n-1, 0.16) inset; | ||
} | ||
@include theme-dark { | ||
box-shadow: 0 -10px 10px -4px use-rgba(n-9, 0.75) inset; | ||
} | ||
} | ||
|
||
.aui-table__header-row { | ||
margin: 0; | ||
padding: 0; | ||
align-items: stretch; | ||
|
||
.aui-table__header-cell { | ||
&:first-of-type { | ||
padding-left: $table-cell-padding-h * 2; | ||
} | ||
|
||
&:last-of-type { | ||
padding-right: $table-cell-padding-h * 2; | ||
} | ||
} | ||
|
||
+ .aui-table__row { | ||
.aui-table__cell { | ||
&:first-of-type { | ||
border-top-left-radius: use-var(border-radius-l); | ||
} | ||
|
||
&:last-of-type { | ||
border-top-right-radius: use-var(border-radius-l); | ||
} | ||
} | ||
} | ||
} | ||
|
||
.aui-table__row { | ||
border: none; | ||
padding: 0; | ||
align-items: stretch; | ||
min-height: $table-row-min-height + 1; | ||
|
||
.aui-table__cell { | ||
border-width: 1px 0; | ||
border-style: solid; | ||
border-color: use-rgb(n-8); | ||
|
||
&:first-of-type { | ||
border-left-width: 1px; | ||
padding-left: $table-cell-padding-h * 2 - 1; | ||
} | ||
|
||
&:last-of-type { | ||
border-right-width: 1px; | ||
padding-right: $table-cell-padding-h * 2 - 1; | ||
} | ||
} | ||
|
||
&:last-child { | ||
min-height: $table-row-min-height + 2; | ||
|
||
.aui-table__cell { | ||
&:first-of-type { | ||
border-bottom-left-radius: use-var(border-radius-l); | ||
} | ||
|
||
&:last-of-type { | ||
border-bottom-right-radius: use-var(border-radius-l); | ||
} | ||
} | ||
} | ||
|
||
&:not(&:last-child) { | ||
.aui-table__cell { | ||
border-bottom-width: 0; | ||
} | ||
} | ||
} | ||
|
||
&--has-scroll { | ||
.#{$stickyCssClass} { | ||
&-border-elem-left:after, | ||
&-border-elem-right:after { | ||
position: absolute; | ||
top: 0; | ||
bottom: -1px; | ||
width: 20px; | ||
transition: box-shadow 0.3s; | ||
content: ''; | ||
pointer-events: none; | ||
} | ||
|
||
&-border-elem-left:before, | ||
&-border-elem-right:before { | ||
position: absolute; | ||
top: 0; | ||
bottom: -1px; | ||
content: ''; | ||
@include vertical-dashed-line(1px, 'n-7'); | ||
} | ||
|
||
&-border-elem-left { | ||
padding-right: $table-cell-padding-h * 3; | ||
|
||
&:after { | ||
right: -$table-cell-padding-h; | ||
} | ||
|
||
&:before { | ||
right: $table-cell-padding-h; | ||
} | ||
} | ||
|
||
&-border-elem-right { | ||
padding-left: $table-cell-padding-h * 3; | ||
|
||
&:after { | ||
left: -$table-cell-padding-h; | ||
} | ||
|
||
&:before { | ||
left: $table-cell-padding-h; | ||
} | ||
} | ||
} | ||
} | ||
|
||
&--scrolling { | ||
.#{$stickyCssClass} { | ||
&-border-elem-left:not(.aui-table__header-row) { | ||
&:after { | ||
@include theme-light { | ||
box-shadow: inset 8px 0 4px -4px use-rgba(n-1, 0.16); | ||
} | ||
@include theme-dark { | ||
box-shadow: inset 8px 0 4px -4px use-rgba(n-9, 0.75); | ||
} | ||
} | ||
|
||
&:before { | ||
@include vertical-dashed-line(1px, 'primary'); | ||
} | ||
} | ||
} | ||
} | ||
|
||
&--before-end { | ||
.#{$stickyCssClass} { | ||
&-border-elem-right:not(.aui-table__header-row) { | ||
&:after { | ||
@include theme-light { | ||
box-shadow: inset -8px 0 4px -4px use-rgba(n-1, 0.16); | ||
} | ||
@include theme-dark { | ||
box-shadow: inset -8px 0 4px -4px use-rgba(n-9, 0.75); | ||
} | ||
} | ||
|
||
&:before { | ||
@include vertical-dashed-line(1px, 'primary'); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不需要限制宿主是td?