table.scss 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. @import './variables.scss';
  2. @import './mixin.scss';
  3. @import './operationPanel.scss';
  4. @import './animation.scss';
  5. $module: #{$prefix}-table;
  6. .#{$module} {
  7. width: 100%;
  8. text-align: left;
  9. border-collapse: separate;
  10. border-spacing: 0;
  11. font-size: inherit;
  12. display: table;
  13. &-wrapper {
  14. zoom: 1;
  15. position: relative;
  16. clear: both;
  17. box-sizing: border-box;
  18. margin: 0;
  19. padding: 0;
  20. @include font-size-regular;
  21. color: $color-table-text-default;
  22. width: 100%;
  23. &[data-column-fixed='true'] {
  24. z-index: 1;
  25. }
  26. }
  27. &-middle {
  28. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  29. padding-top: $spacing-table_middle-paddingY;
  30. padding-bottom: $spacing-table_middle-paddingY;
  31. }
  32. }
  33. &-small {
  34. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  35. padding-top: $spacing-table_small-paddingY;
  36. padding-bottom: $spacing-table_small-paddingY;
  37. }
  38. }
  39. &-title {
  40. position: relative;
  41. padding-top: $spacing-table_title-paddingY;
  42. padding-bottom: $spacing-table_title-paddingY;
  43. padding-left: $spacing-table_title-paddingX;
  44. padding-right: $spacing-table_title-paddingX;
  45. }
  46. &-container {
  47. position: relative;
  48. }
  49. &-header {
  50. overflow: hidden;
  51. &::-webkit-scrollbar {
  52. background-color: transparent;
  53. border-bottom: $border-table_head-bottom;
  54. }
  55. scrollbar-base-color: transparent;
  56. }
  57. &-body {
  58. overflow: auto;
  59. width: 100%;
  60. box-sizing: border-box;
  61. }
  62. &-colgroup {
  63. display: table-column-group;
  64. .#{$module}-col {
  65. display: table-column;
  66. }
  67. .#{$module}-column {
  68. &-expand,
  69. &-selection {
  70. width: $width-table_column_selection;
  71. }
  72. }
  73. }
  74. &-thead {
  75. & > .#{$module}-row {
  76. & > .#{$module}-row-head {
  77. background-color: $color-table_th-bg-default;
  78. color: $color-table_th-text-default;
  79. font-weight: $font-weight-bold;
  80. text-align: left;
  81. border-bottom: $border-table_head-bottom;
  82. padding-left: $spacing-table_row_head-paddingX;
  83. padding-right: $spacing-table_row_head-paddingX;
  84. padding-top: $spacing-table_row_head-paddingY;
  85. padding-bottom: $spacing-table_row_head-paddingY;
  86. vertical-align: middle;
  87. word-break: break-all;
  88. word-wrap: break-word;
  89. position: relative;
  90. &.#{$module}-cell-fixed {
  91. &-left,
  92. &-right {
  93. z-index: $z-table_fixed_column;
  94. position: sticky;
  95. background-color: $color-table-bg-default;
  96. &::before {
  97. background-color: $color-table_th-bg-default;
  98. content: '';
  99. position: absolute;
  100. left: 0;
  101. top: 0;
  102. right: 0;
  103. bottom: 0;
  104. display: block;
  105. z-index: -1;
  106. }
  107. }
  108. &-left-last {
  109. border-right: $width-table_cell_fixed_left_last solid $color-table_shadow-border-default;
  110. box-shadow: #{$shadow-table_right};
  111. &.resizing {
  112. @include genResizing();
  113. }
  114. }
  115. &-right-first {
  116. border-left: $width-table_cell_fixed_right_first solid $color-table_shadow-border-default;
  117. box-shadow: #{$shadow-table_left};
  118. &.resizing {
  119. @include genResizing();
  120. }
  121. // scroll-bar 列无需有box-shadow
  122. &[x-type='column-scrollbar'] {
  123. box-shadow: none;
  124. border-left: transparent;
  125. }
  126. }
  127. }
  128. &.#{$module}-column-selection {
  129. text-align: center;
  130. }
  131. &[colspan]:not([colspan='1']) {
  132. text-align: center;
  133. }
  134. .#{$module}-header-column {
  135. display: inline-flex;
  136. align-items: center;
  137. }
  138. }
  139. .react-resizable {
  140. position: relative;
  141. background-clip: padding-box;
  142. }
  143. .resizing {
  144. @include genResizing();
  145. }
  146. .react-resizable-handle {
  147. position: absolute;
  148. width: $width-table_react_resizable_handle;
  149. height: calc(100% - #{$spacing-table_resizable-offset-y} * 2);
  150. background-color: $color-table-border-default;
  151. bottom: $spacing-table_resizable-bottom;
  152. right: $spacing-table_react_resizable_handle-right;
  153. cursor: col-resize;
  154. z-index: 0;
  155. &:hover {
  156. background-color: $color-table_resizer-bg-default;
  157. }
  158. }
  159. }
  160. }
  161. &-tbody {
  162. display: table-row-group;
  163. & > .#{$module}-row {
  164. display: table-row;
  165. &:hover {
  166. & > .#{$module}-row-cell {
  167. background-color: $color-table_body-bg-hover;
  168. &.#{$module}-cell-fixed {
  169. &-left,
  170. &-right {
  171. background-color: $color-table_body-bg-default;
  172. &::before {
  173. background-color: $color-table_body-bg-hover;
  174. content: '';
  175. position: absolute;
  176. left: 0;
  177. top: 0;
  178. right: 0;
  179. bottom: 0;
  180. display: block;
  181. z-index: -1;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. & > .#{$module}-row-cell {
  188. display: table-cell;
  189. word-wrap: break-word;
  190. word-break: break-all;
  191. border-left: none;
  192. border-right: none;
  193. border-bottom: $border-table;
  194. padding: $spacing-table_tbody_rowCell-padding;
  195. box-sizing: border-box;
  196. position: relative;
  197. vertical-align: middle;
  198. &.resizing {
  199. border-right: $border-table_resizer;
  200. }
  201. }
  202. &.#{$module}-row {
  203. &-expand {
  204. & > .#{$module}-row-cell {
  205. background-color: $color-table_row_expanded-bg-default;
  206. }
  207. }
  208. }
  209. & > .#{$module}-cell-fixed {
  210. &-left,
  211. &-right {
  212. z-index: $z-table_fixed_column;
  213. position: sticky;
  214. background-color: $color-table-bg-default;
  215. }
  216. &-left-last {
  217. border-right: $width-table_cell_fixed_left_last solid $color-table_shadow-border-default;
  218. box-shadow: #{$shadow-table_right};
  219. }
  220. &-right-first {
  221. border-left: $width-table_cell_fixed_right_first solid $color-table_shadow-border-default;
  222. box-shadow: #{$shadow-table_left};
  223. }
  224. & > * {
  225. transition: background-color $transition_duration-table_body-bg $transition_function-table_body-bg
  226. $transition_delay-table_body-bg;
  227. }
  228. }
  229. & > * {
  230. transition: background-color $transition_duration-table_body-bg $transition_function-table_body-bg
  231. $transition_delay-table_body-bg;
  232. }
  233. }
  234. & > .#{$module}-row-section {
  235. display: table-row;
  236. & > .#{$module}-row-cell {
  237. background-color: $color-table_selection-bg-default;
  238. border-bottom: $border-table;
  239. }
  240. & > .#{$module}-row-cell:not(.#{$module}-column-selection) {
  241. padding: $spacing-table_tbody_rowSelection_rowCell_notSelection-paddingY $spacing-table_tbody_rowSelection_rowCell_notSelection-paddingX;
  242. }
  243. .#{$module}-section-inner {
  244. display: inline-flex;
  245. align-items: center;
  246. }
  247. }
  248. }
  249. &-virtualized .#{$module}-tbody {
  250. display: block;
  251. & > .#{$module}-row {
  252. display: flex;
  253. & > .#{$module}-row-cell {
  254. word-wrap: unset;
  255. word-break: unset;
  256. white-space: nowrap;
  257. display: inline-flex;
  258. align-items: center;
  259. overflow: hidden;
  260. }
  261. &-section {
  262. & > .#{$module}-row-cell {
  263. padding-top: $spacing-table-paddingY;
  264. padding-bottom: $spacing-table-paddingY;
  265. display: flex;
  266. }
  267. }
  268. &-expand {
  269. & > .#{$module}-row-cell {
  270. padding: 0;
  271. overflow: unset;
  272. }
  273. }
  274. }
  275. }
  276. &-footer {
  277. background-color: $color-table_footer-bg-default;
  278. padding: $spacing-table_footer-padding;
  279. margin: 0;
  280. position: relative;
  281. }
  282. .#{$module}-selection {
  283. &-wrap {
  284. // inline-flex vertical-align baseline 会导致父元素高度异常
  285. display: inline-flex;
  286. vertical-align: bottom;
  287. }
  288. &-disabled {
  289. cursor: not-allowed;
  290. & > .#{$prefix}-checkbox {
  291. pointer-events: none;
  292. }
  293. }
  294. }
  295. .#{$module}-column {
  296. &-hidden {
  297. display: none;
  298. }
  299. &-selection {
  300. text-align: center;
  301. // width: $width-table_column_selection;
  302. .#{$prefix}-checkbox-inner-display {
  303. .#{$prefix}-icon {
  304. left: 0;
  305. top: 0;
  306. }
  307. }
  308. }
  309. &-expand {
  310. .#{$module}-expand-icon {
  311. transform: translateY(2px);
  312. &:last-child {
  313. margin-right: 0;
  314. }
  315. }
  316. }
  317. &-sorter {
  318. margin-left: $spacing-table_column_sorter-marginLeft;
  319. display: inline-block;
  320. width: $width-table_column_sorter-icon;
  321. height: $height-table_column_sorter-icon;
  322. vertical-align: middle;
  323. text-align: center;
  324. &-wrapper {
  325. display: inline-flex;
  326. align-items: center;
  327. cursor: pointer;
  328. }
  329. &-up,
  330. &-down {
  331. height: 0;
  332. display: block;
  333. color: $color-table_sorter-text-default;
  334. &:hover .anticon {
  335. color: $color-table_sorter-text-hover;
  336. }
  337. svg {
  338. width: $width-table_column_sorter-icon;
  339. height: $height-table_column_sorter-icon;
  340. }
  341. &.on {
  342. .#{$prefix}-icon-caretup,
  343. .#{$prefix}-icon-caretdown {
  344. color: $color-table_sorter_on-text-default;
  345. }
  346. }
  347. }
  348. }
  349. &-filter {
  350. margin-left: $spacing-table_column_filter-marginLeft;
  351. display: inline-flex;
  352. cursor: pointer;
  353. color: $color-table_filter-text-default;
  354. // vertical-align: middle;
  355. align-items: center;
  356. svg {
  357. width: $width-table_column_filter-icon;
  358. height: $height-table_column_filter-icon;
  359. }
  360. &.on {
  361. color: $color-table_filter_on-text-default;
  362. }
  363. }
  364. }
  365. &-bordered {
  366. .#{$module}-title {
  367. padding-left: $spacing-table_bordered_titler-paddingLeft;
  368. padding-right: $spacing-table_bordered_titler-paddingRight;
  369. border-top: $border-table;
  370. border-right: $border-table;
  371. border-left: $border-table;
  372. }
  373. .#{$module}-container {
  374. border: $border-table;
  375. border-right: 0;
  376. border-bottom: 0;
  377. }
  378. .#{$module}-header {
  379. &::-webkit-scrollbar {
  380. border-right: $border-table;
  381. }
  382. }
  383. .#{$module}-footer {
  384. border-left: $border-table;
  385. border-right: $border-table;
  386. border-bottom: $border-table;
  387. }
  388. .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
  389. .react-resizable-handle {
  390. background-color: transparent;
  391. }
  392. }
  393. .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
  394. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  395. border-right: $border-table;
  396. }
  397. .#{$module}-placeholder {
  398. border-right: $border-table;
  399. }
  400. }
  401. &-placeholder {
  402. position: relative;
  403. z-index: 1;
  404. padding: #{$spacing-table-paddingY} #{$spacing-table-paddingX};
  405. color: $color-table_placeholder-text-default;
  406. font-size: #{$font-table_base-fontSize};
  407. text-align: center;
  408. background: $color-table_pl-bg-default;
  409. border-bottom: $border-table;
  410. border-radius: 0 0 #{$radius-table_base} #{$radius-table_base};
  411. }
  412. &-fixed {
  413. table-layout: fixed;
  414. min-width: 100%;
  415. & > .#{$module}-tbody {
  416. & > .#{$module}-row-expand > .#{$module}-row-cell > .#{$module}-expand-inner,
  417. & > .#{$module}-row-section > .#{$module}-row-cell > .#{$module}-section-inner {
  418. position: sticky;
  419. overflow: auto;
  420. left: 0;
  421. margin-left: -$spacing-table_expand_row-paddingLeft;
  422. margin-right: -$spacing-table_expand_row-paddingRight;
  423. padding-left: $spacing-table_expand_row-paddingLeft;
  424. padding-right: $spacing-table_expand_row-paddingRight;
  425. height: 100%;
  426. display: flex;
  427. align-items: center;
  428. }
  429. }
  430. // when header is fixed, table should use `table-layout: fixed` to avoid align bug
  431. &-header {
  432. table {
  433. table-layout: fixed;
  434. }
  435. }
  436. }
  437. &-scroll {
  438. &-position {
  439. &-left {
  440. .#{$module}-tbody,
  441. .#{$module}-thead {
  442. & > .#{$module}-row > .#{$module}-cell-fixed-left-last {
  443. box-shadow: none;
  444. }
  445. }
  446. }
  447. &-right {
  448. .#{$module}-tbody,
  449. .#{$module}-thead {
  450. & > .#{$module}-row > .#{$module}-cell-fixed-right-first {
  451. box-shadow: none;
  452. }
  453. }
  454. }
  455. }
  456. }
  457. &-pagination-outer {
  458. color: $color-table_page-text-default;
  459. min-height: $height-table_pagination_outer_min;
  460. }
  461. }
  462. .#{$module}-expand-icon {
  463. color: $color-table_expanded_icon-default;
  464. cursor: pointer;
  465. display: inline-flex;
  466. align-items: center;
  467. user-select: none;
  468. background: $color-table_expanded-bg-default;
  469. position: relative;
  470. margin-right: $spacing-table_expand_icon-marginRight;
  471. &-cell {
  472. display: inline-flex;
  473. align-items: center;
  474. justify-content: center;
  475. }
  476. }
  477. @import './rtl.scss';