table.scss 16 KB

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