123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672 |
- @use 'sass:map';
- @use 'mixins/mixins' as *;
- @use 'mixins/var' as *;
- @use 'common/var' as *;
- @include b(table) {
- @include set-component-css-var('table', $table);
- }
- @include b(table) {
- position: relative;
- overflow: hidden;
- box-sizing: border-box;
- height: fit-content;
- width: 100%;
- max-width: 100%;
- background-color: getCssVar('table-bg-color');
- font-size: 14px;
- color: getCssVar('table-text-color');
- @include e(inner-wrapper) {
- position: relative;
- display: flex;
- flex-direction: column;
- height: 100%;
- // 表格底部伪 border,总是有的
- &::before {
- @include extend-rule(border-pseudo);
- left: 0;
- bottom: 0px;
- width: 100%;
- height: 1px;
- }
- }
- tbody {
- &:focus-visible {
- outline: none;
- }
- }
- &.has-footer {
- &.#{$namespace}-table--scrollable-y,
- &.#{$namespace}-table--fluid-height {
- tr:last-child td.#{$namespace}-table__cell {
- border-bottom-color: transparent;
- }
- }
- }
- // when data is empty
- @include e(empty-block) {
- position: sticky;
- left: 0;
- min-height: 60px;
- text-align: center;
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- @include e(empty-text) {
- // min-height doesn't work in IE10 and IE11 https://github.com/philipwalton/flexbugs#3-min-height-on-a-flex-container-wont-apply-to-its-flex-items
- // set empty text line height up to contrainer min-height as workaround.
- line-height: 60px;
- width: 50%;
- color: getCssVar('text-color', 'secondary');
- }
- // expand the row
- @include e(expand-column) {
- .cell {
- padding: 0;
- text-align: center;
- user-select: none;
- }
- }
- @include e(expand-icon) {
- position: relative;
- cursor: pointer;
- color: getCssVar('text-color', 'regular');
- font-size: 12px;
- transition: transform getCssVar('transition-duration-fast') ease-in-out;
- height: 20px;
- @include m(expanded) {
- transform: rotate(90deg);
- }
- > .#{$namespace}-icon {
- font-size: 12px;
- }
- }
- @include e(expanded-cell) {
- background-color: getCssVar('table-expanded-cell-bg-color');
- // increase the weight purely
- &[class*='cell'] {
- padding: 20px 50px;
- }
- &:hover {
- background-color: transparent !important;
- }
- }
- @include e(placeholder) {
- display: inline-block;
- width: 20px;
- }
- @include e(append-wrapper) {
- // avoid overlapping margin https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
- overflow: hidden;
- }
- @include m(fit) {
- border-right: 0;
- border-bottom: 0;
- .#{$namespace}-table__cell.gutter {
- border-right-width: 1px;
- }
- }
- thead {
- color: getCssVar('table-header-text-color');
- th {
- font-weight: 600;
- }
- &.is-group {
- th.#{$namespace}-table__cell {
- background: getCssVar('fill-color', 'light');
- }
- }
- }
- .#{$namespace}-table__cell {
- padding: map.get($table-padding, 'default');
- min-width: 0;
- box-sizing: border-box;
- text-overflow: ellipsis;
- vertical-align: middle;
- position: relative;
- text-align: left;
- z-index: getCssVar('table-index');
- @include when(center) {
- text-align: center;
- }
- @include when(right) {
- text-align: right;
- }
- &.gutter {
- width: 15px;
- border-right-width: 0;
- border-bottom-width: 0;
- padding: 0;
- }
- &.is-hidden {
- > * {
- visibility: hidden;
- }
- }
- }
- .cell {
- box-sizing: border-box;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: normal;
- overflow-wrap: break-word;
- line-height: 23px;
- padding: 0 12px;
- &.#{$namespace}-tooltip {
- white-space: nowrap;
- min-width: 50px;
- }
- }
- @each $size in (large, default, small) {
- @include m($size) {
- font-size: map.get($table-font-size, $size);
- .#{$namespace}-table__cell {
- padding: map.get($table-padding, $size);
- }
- .cell {
- padding: map.get($table-cell-padding, $size);
- }
- }
- }
- tr {
- background-color: getCssVar('table-tr-bg-color');
- input[type='checkbox'] {
- margin: 0;
- }
- }
- th.#{$namespace}-table__cell.is-leaf,
- td.#{$namespace}-table__cell {
- border-bottom: getCssVar('table-border');
- }
- th.#{$namespace}-table__cell.is-sortable {
- cursor: pointer;
- }
- th.#{$namespace}-table__cell {
- user-select: none;
- background-color: getCssVar('table-header-bg-color');
- > .cell.highlight {
- color: getCssVar('color-primary');
- }
- &.required > div::before {
- display: inline-block;
- content: '';
- width: 8px;
- height: 8px;
- border-radius: 50%;
- background: #ff4d51;
- margin-right: 5px;
- vertical-align: middle;
- }
- }
- td.#{$namespace}-table__cell {
- div {
- box-sizing: border-box;
- }
- &.gutter {
- width: 0;
- }
- }
- // 拥有多级表头
- @include m((group, border)) {
- @include share-rule(border-pseudo) {
- content: '';
- position: absolute;
- background-color: getCssVar('table-border-color');
- z-index: calc(getCssVar('table-index') + 2);
- }
- }
- // table--border
- @include m(border) {
- @include e(inner-wrapper) {
- &::after {
- @include extend-rule(border-pseudo);
- left: 0;
- top: 0;
- width: 100%;
- height: 1px;
- z-index: calc(getCssVar('table-index') + 2);
- }
- }
- &::before {
- @include extend-rule(border-pseudo);
- top: -1px;
- left: 0;
- width: 1px;
- height: 100%;
- }
- &::after {
- @include extend-rule(border-pseudo);
- top: -1px;
- right: 0;
- width: 1px;
- height: 100%;
- }
- @include e(inner-wrapper) {
- border-right: none;
- border-bottom: none;
- }
- @include e(footer-wrapper) {
- position: relative;
- flex-shrink: 0;
- }
- .#{$namespace}-table__cell {
- border-right: getCssVar('table-border');
- }
- th.#{$namespace}-table__cell.gutter:last-of-type {
- border-bottom: getCssVar('table-border');
- border-bottom-width: 1px;
- }
- & th.#{$namespace}-table__cell {
- border-bottom: getCssVar('table-border');
- }
- }
- @include m(hidden) {
- visibility: hidden;
- }
- @include e((header-wrapper, body-wrapper, footer-wrapper)) {
- width: 100%;
- tr {
- td,
- th {
- &.#{$namespace}-table-fixed-column--left,
- &.#{$namespace}-table-fixed-column--right {
- position: sticky !important;
- background: inherit;
- z-index: calc(getCssVar('table-index') + 1);
- &.is-last-column,
- &.is-first-column {
- &::before {
- content: '';
- position: absolute;
- top: 0px;
- width: 10px;
- bottom: -1px;
- overflow-x: hidden;
- overflow-y: hidden;
- box-shadow: none;
- touch-action: none;
- pointer-events: none;
- }
- }
- &.is-first-column {
- &::before {
- left: -10px;
- }
- }
- &.is-last-column {
- &::before {
- right: -10px;
- box-shadow: none;
- }
- }
- }
- &.#{$namespace}-table__fixed-right-patch {
- position: sticky !important;
- z-index: calc(getCssVar('table-index') + 1);
- background: #fff;
- right: 0;
- }
- }
- }
- }
- @include e(header-wrapper) {
- flex-shrink: 0;
- tr {
- th {
- &.#{$namespace}-table-fixed-column--left,
- &.#{$namespace}-table-fixed-column--right {
- background-color: getCssVar('table-header-bg-color');
- }
- }
- }
- }
- @include e((header, body, footer)) {
- table-layout: fixed;
- border-collapse: separate;
- }
- @include e((header-wrapper)) {
- overflow: hidden;
- & tbody td.#{$namespace}-table__cell {
- background-color: getCssVar('table-row-hover-bg-color');
- color: getCssVar('table-text-color');
- }
- }
- @include e((footer-wrapper)) {
- overflow: hidden;
- flex-shrink: 0;
- tfoot td.#{$namespace}-table__cell {
- background-color: getCssVar('table-row-hover-bg-color');
- color: getCssVar('table-text-color');
- }
- }
- @include e((header-wrapper, body-wrapper)) {
- .#{$namespace}-table-column--selection {
- > .cell {
- display: inline-flex;
- align-items: center;
- height: 23px;
- }
- .#{$namespace}-checkbox {
- height: unset;
- }
- }
- }
- @include when(scrolling-left) {
- .#{$namespace}-table-fixed-column--right.is-first-column {
- &::before {
- box-shadow: getCssVar('table-fixed-right-column');
- }
- }
- &.#{$namespace}-table--border {
- .#{$namespace}-table-fixed-column--left {
- &.is-last-column {
- &.#{$namespace}-table__cell {
- border-right: getCssVar('table-border');
- }
- }
- }
- }
- th.#{$namespace}-table-fixed-column--left {
- background-color: getCssVar('table-header-bg-color');
- }
- }
- @include when(scrolling-right) {
- .#{$namespace}-table-fixed-column--left.is-last-column {
- &::before {
- box-shadow: getCssVar('table-fixed-left-column');
- }
- }
- .#{$namespace}-table-fixed-column--left.is-last-column.#{$namespace}-table__cell {
- border-right: none;
- }
- th.#{$namespace}-table-fixed-column--right {
- background-color: getCssVar('table-header-bg-color');
- }
- }
- @include when(scrolling-middle) {
- .#{$namespace}-table-fixed-column--left.is-last-column.#{$namespace}-table__cell {
- border-right: none;
- }
- .#{$namespace}-table-fixed-column--right.is-first-column {
- &::before {
- box-shadow: getCssVar('table-fixed-right-column');
- }
- }
- .#{$namespace}-table-fixed-column--left.is-last-column {
- &::before {
- box-shadow: getCssVar('table-fixed-left-column');
- }
- }
- }
- @include when(scrolling-none) {
- .#{$namespace}-table-fixed-column--left,
- .#{$namespace}-table-fixed-column--right {
- &.is-first-column,
- &.is-last-column {
- &::before {
- box-shadow: none;
- }
- }
- }
- th.#{$namespace}-table-fixed-column--left,
- th.#{$namespace}-table-fixed-column--right {
- background-color: getCssVar('table-header-bg-color');
- }
- }
- @include e(body-wrapper) {
- overflow: hidden;
- position: relative;
- flex: 1;
- .#{$namespace}-scrollbar__bar {
- z-index: calc(getCssVar('table-index') + 2);
- }
- }
- .caret-wrapper {
- display: inline-flex;
- flex-direction: column;
- align-items: center;
- height: 14px;
- width: 24px;
- vertical-align: middle;
- cursor: pointer;
- overflow: initial;
- position: relative;
- }
- .sort-caret {
- width: 0;
- height: 0;
- border: solid 5px transparent;
- position: absolute;
- left: 7px;
- &.ascending {
- border-bottom-color: getCssVar('text-color', 'placeholder');
- top: -5px;
- }
- &.descending {
- border-top-color: getCssVar('text-color', 'placeholder');
- bottom: -3px;
- }
- }
- .ascending .sort-caret.ascending {
- border-bottom-color: getCssVar('color-primary');
- }
- .descending .sort-caret.descending {
- border-top-color: getCssVar('color-primary');
- }
- .hidden-columns {
- visibility: hidden;
- position: absolute;
- z-index: -1;
- }
- @include m(striped) {
- & .#{$namespace}-table__body {
- & tr.#{$namespace}-table__row--striped {
- td.#{$namespace}-table__cell {
- background: getCssVar('fill-color', 'lighter');
- }
- &.current-row td.#{$namespace}-table__cell {
- background-color: getCssVar('table-current-row-bg-color');
- }
- }
- }
- }
- @include e(body) {
- tr.hover-row {
- &,
- &.#{$namespace}-table__row--striped {
- &,
- &.current-row {
- > td.#{$namespace}-table__cell {
- background-color: getCssVar('table-row-hover-bg-color');
- }
- }
- }
- }
- tr > td.hover-cell {
- background-color: getCssVar('table-row-hover-bg-color');
- }
- tr.current-row > td.#{$namespace}-table__cell {
- background-color: getCssVar('table-current-row-bg-color');
- }
- }
- &.#{$namespace}-table--scrollable-y {
- @include e(body-header) {
- position: sticky;
- top: 0;
- z-index: calc(getCssVar('table-index') + 2);
- }
- @include e(body-footer) {
- position: sticky;
- bottom: 0;
- z-index: calc(getCssVar('table-index') + 2);
- }
- }
- @include e(column-resize-proxy) {
- position: absolute;
- left: 200px;
- top: 0;
- bottom: 0;
- width: 0;
- border-left: getCssVar('table-border');
- z-index: calc(getCssVar('table-index') + 9);
- }
- @include e(column-filter-trigger) {
- display: inline-block;
- cursor: pointer;
- & i {
- color: getCssVar('color-info');
- font-size: 14px;
- vertical-align: middle;
- }
- }
- @include e(border-left-patch) {
- top: 0;
- left: 0;
- width: 1px;
- height: 100%;
- z-index: calc(getCssVar('table-index') + 2);
- position: absolute;
- background-color: getCssVar('table-border-color');
- }
- @include e(border-bottom-patch) {
- left: 0;
- height: 1px;
- z-index: calc(getCssVar('table-index') + 2);
- position: absolute;
- background-color: getCssVar('table-border-color');
- }
- @include e(border-right-patch) {
- top: 0;
- height: 100%;
- width: 1px;
- z-index: calc(getCssVar('table-index') + 2);
- position: absolute;
- background-color: getCssVar('table-border-color');
- }
- @include m(enable-row-transition) {
- .#{$namespace}-table__body td.#{$namespace}-table__cell {
- transition: background-color 0.25s ease;
- }
- }
- @include m(enable-row-hover) {
- .#{$namespace}-table__body tr:hover > td.#{$namespace}-table__cell {
- background-color: getCssVar('table-row-hover-bg-color');
- }
- }
- [class*='#{$namespace}-table__row--level'] {
- .#{$namespace}-table__expand-icon {
- display: inline-block;
- width: 12px;
- line-height: 12px;
- height: 12px;
- text-align: center;
- margin-right: 8px;
- }
- }
- @include b(table) {
- &.#{$namespace}-table--border {
- .#{$namespace}-table__cell {
- border-right: getCssVar('table-border');
- }
- }
- }
- &:not(.#{$namespace}-table--border) {
- .#{$namespace}-table__cell {
- border-right: none;
- }
- > .#{$namespace}-table__inner-wrapper {
- &::after {
- content: none;
- }
- }
- }
- }
|