table.scss 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. @import "./variables.scss";
  2. @import "./mixin.scss";
  3. @import "./operationPanel.scss";
  4. $module: #{$prefix}-table;
  5. .#{$module} {
  6. width: 100%;
  7. text-align: left;
  8. border-collapse: separate;
  9. border-spacing: 0;
  10. font-size: inherit;
  11. display: table;
  12. &-wrapper {
  13. zoom: 1;
  14. position: relative;
  15. clear: both;
  16. box-sizing: border-box;
  17. margin: 0;
  18. padding: 0;
  19. @include font-size-regular;
  20. color: $color-table-text-default;
  21. width: 100%;
  22. &[data-column-fixed=true] {
  23. z-index: 1;
  24. }
  25. }
  26. &-middle {
  27. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  28. padding-top: $spacing-table_middle-paddingY;
  29. padding-bottom: $spacing-table_middle-paddingY;
  30. }
  31. }
  32. &-small {
  33. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  34. padding-top: $spacing-table_small-paddingY;
  35. padding-bottom: $spacing-table_small-paddingY;
  36. }
  37. }
  38. &-title {
  39. position: relative;
  40. padding-top: $spacing-table_title-paddingY;
  41. padding-bottom: $spacing-table_title-paddingY;
  42. padding-left: $spacing-table_title-paddingX;
  43. padding-right: $spacing-table_title-paddingX;
  44. }
  45. &-container {
  46. position: relative;
  47. }
  48. &-header {
  49. overflow: hidden;
  50. &::-webkit-scrollbar {
  51. background-color: transparent;
  52. border-bottom: $border-table_head-bottom;
  53. }
  54. scrollbar-base-color: transparent;
  55. }
  56. &-body {
  57. overflow: auto;
  58. width: 100%;
  59. box-sizing: border-box;
  60. }
  61. &-colgroup {
  62. display: table-column-group;
  63. .#{$module}-col {
  64. display: table-column;
  65. }
  66. .#{$module}-column {
  67. &-expand,
  68. &-selection {
  69. width: $width-table_column_selection;
  70. }
  71. }
  72. }
  73. &-thead {
  74. & > .#{$module}-row {
  75. & > .#{$module}-row-head {
  76. background-color: $color-table_th-bg-default;
  77. color: $color-table_th-text-default;
  78. font-weight: $font-weight-bold;
  79. text-align: left;
  80. border-bottom: $border-table_head-bottom;
  81. padding-left: $spacing-table_row_head-paddingX;
  82. padding-right: $spacing-table_row_head-paddingX;
  83. padding-top: $spacing-table_row_head-paddingY;
  84. padding-bottom: $spacing-table_row_head-paddingY;
  85. vertical-align: middle;
  86. word-break: break-all;
  87. word-wrap: break-word;
  88. position: relative;
  89. user-select: none;
  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. }
  226. & > .#{$module}-row-section {
  227. display: table-row;
  228. & > .#{$module}-row-cell {
  229. background-color: $color-table_selection-bg-default;
  230. border-bottom: $border-table;
  231. }
  232. & > .#{$module}-row-cell:not(.#{$module}-column-selection) {
  233. padding: $spacing-table_tbody_rowSelection_rowCell_notSelection-paddingY $spacing-table_tbody_rowSelection_rowCell_notSelection-paddingX;
  234. }
  235. .#{$module}-section-inner {
  236. display: inline-flex;
  237. align-items: center;
  238. }
  239. }
  240. }
  241. &-virtualized .#{$module}-tbody {
  242. display: block;
  243. & > .#{$module}-row {
  244. display: flex;
  245. & > .#{$module}-row-cell {
  246. word-wrap: unset;
  247. word-break: unset;
  248. white-space: nowrap;
  249. display: inline-flex;
  250. align-items: center;
  251. overflow: hidden;
  252. }
  253. &-section {
  254. & > .#{$module}-row-cell {
  255. padding-top: $spacing-table-paddingY;
  256. padding-bottom: $spacing-table-paddingY;
  257. display: flex;
  258. }
  259. }
  260. &-expand {
  261. & > .#{$module}-row-cell {
  262. padding: 0;
  263. overflow: unset;
  264. }
  265. }
  266. }
  267. }
  268. &-footer {
  269. background-color: $color-table_footer-bg-default;
  270. padding: $spacing-table_footer-padding;
  271. margin: 0;
  272. position: relative;
  273. }
  274. .#{$module}-selection {
  275. &-wrap {
  276. // inline-flex vertical-align baseline 会导致父元素高度异常
  277. display: inline-flex;
  278. vertical-align: bottom;
  279. }
  280. &-disabled {
  281. cursor: not-allowed;
  282. & > .#{$prefix}-checkbox {
  283. pointer-events: none;
  284. }
  285. }
  286. }
  287. .#{$module}-column {
  288. &-hidden {
  289. display: none;
  290. }
  291. &-selection {
  292. text-align: center;
  293. // width: $width-table_column_selection;
  294. .#{$prefix}-checkbox-inner-display {
  295. .#{$prefix}-icon {
  296. left: 0;
  297. top: 0;
  298. }
  299. }
  300. }
  301. &-expand {
  302. .#{$module}-expand-icon {
  303. transform: translateY(2px);
  304. &:last-child {
  305. margin-right: 0;
  306. }
  307. }
  308. }
  309. &-sorter {
  310. margin-left: $spacing-table_column_sorter-marginLeft;
  311. display: inline-block;
  312. width: $width-table_column_sorter-icon;
  313. height: $height-table_column_sorter-icon;
  314. cursor: pointer;
  315. vertical-align: middle;
  316. text-align: center;
  317. &-up,
  318. &-down {
  319. height: 0;
  320. display: block;
  321. color: $color-table_sorter-text-default;
  322. &:hover .anticon {
  323. color: $color-table_sorter-text-hover;
  324. }
  325. svg {
  326. width: $width-table_column_sorter-icon;
  327. height: $height-table_column_sorter-icon;
  328. }
  329. &.on {
  330. .#{$prefix}-icon-caretup,
  331. .#{$prefix}-icon-caretdown {
  332. color: $color-table_sorter_on-text-default;
  333. }
  334. }
  335. }
  336. }
  337. &-filter {
  338. margin-left: $spacing-table_column_filter-marginLeft;
  339. display: inline-flex;
  340. cursor: pointer;
  341. color: $color-table_filter-text-default;
  342. vertical-align: middle;
  343. svg {
  344. width: $width-table_column_filter-icon;
  345. height: $height-table_column_filter-icon;
  346. }
  347. &.on {
  348. color: $color-table_filter_on-text-default;
  349. }
  350. }
  351. }
  352. &-bordered {
  353. .#{$module}-title {
  354. padding-left: $spacing-table_bordered_titler-paddingLeft;
  355. padding-right: $spacing-table_bordered_titler-paddingRight;
  356. border-top: $border-table;
  357. border-right: $border-table;
  358. border-left: $border-table;
  359. }
  360. .#{$module}-container {
  361. border: $border-table;
  362. border-right: 0;
  363. border-bottom: 0;
  364. }
  365. .#{$module}-header {
  366. &::-webkit-scrollbar {
  367. border-right: $border-table;
  368. }
  369. }
  370. .#{$module}-footer {
  371. border-left: $border-table;
  372. border-right: $border-table;
  373. border-bottom: $border-table;
  374. }
  375. .#{$module}-thead > .#{$module}-row > .#{$module}-row-head {
  376. .react-resizable-handle {
  377. background-color: transparent;
  378. }
  379. }
  380. .#{$module}-thead > .#{$module}-row > .#{$module}-row-head,
  381. .#{$module}-tbody > .#{$module}-row > .#{$module}-row-cell {
  382. border-right: $border-table;
  383. }
  384. .#{$module}-placeholder {
  385. border-right: $border-table;
  386. }
  387. }
  388. &-placeholder {
  389. position: relative;
  390. z-index: 1;
  391. padding: #{$spacing-table-paddingY} #{$spacing-table-paddingX};
  392. color: $color-table_disabled-bg-default;
  393. font-size: #{$font-table_base-fontSize};
  394. text-align: center;
  395. background: $color-table_pl-bg-default;
  396. border-bottom: $border-table;
  397. border-radius: 0 0 #{$radius-table_base} #{$radius-table_base};
  398. }
  399. &-fixed {
  400. table-layout: fixed;
  401. min-width: 100%;
  402. & > .#{$module}-tbody {
  403. & > .#{$module}-row-expand > .#{$module}-row-cell > .#{$module}-expand-inner,
  404. & > .#{$module}-row-section > .#{$module}-row-cell > .#{$module}-section-inner {
  405. position: sticky;
  406. overflow: auto;
  407. left: 0;
  408. margin-left: -$spacing-table_expand_row-paddingLeft;
  409. margin-right: -$spacing-table_expand_row-paddingRight;
  410. padding-left: $spacing-table_expand_row-paddingLeft;
  411. padding-right: $spacing-table_expand_row-paddingRight;
  412. height: 100%;
  413. display: flex;
  414. align-items: center;
  415. }
  416. }
  417. // when header is fixed, table should use `table-layout: fixed` to avoid align bug
  418. &-header {
  419. table {
  420. table-layout: fixed;
  421. }
  422. }
  423. }
  424. &-scroll {
  425. &-position {
  426. &-left {
  427. .#{$module}-tbody,
  428. .#{$module}-thead {
  429. & > .#{$module}-row > .#{$module}-cell-fixed-left-last {
  430. box-shadow: none;
  431. }
  432. }
  433. }
  434. &-right {
  435. .#{$module}-tbody,
  436. .#{$module}-thead {
  437. & > .#{$module}-row > .#{$module}-cell-fixed-right-first {
  438. box-shadow: none;
  439. }
  440. }
  441. }
  442. }
  443. }
  444. &-pagination-outer {
  445. color: $color-table_page-text-default;
  446. min-height: $height-table_pagination_outer_min;
  447. }
  448. }
  449. .#{$module}-expand-icon {
  450. color: $color-table_expanded_icon-default;
  451. cursor: pointer;
  452. display: inline-flex;
  453. align-items: center;
  454. user-select: none;
  455. background: $color-table_expanded-bg-default;
  456. position: relative;
  457. margin-right: $spacing-table_expand_icon-marginRight;
  458. &-cell {
  459. display: inline-flex;
  460. align-items: center;
  461. justify-content: center;
  462. }
  463. }
  464. @import "./rtl.scss";