@instructure/ui-table 11.6.0 → 11.6.1-snapshot-129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (303) hide show
  1. package/CHANGELOG.md +43 -308
  2. package/es/Table/{Body → v1/Body}/index.js +2 -2
  3. package/es/Table/{Cell → v1/Cell}/index.js +2 -2
  4. package/es/Table/{ColHeader → v1/ColHeader}/index.js +1 -1
  5. package/es/Table/{Head → v1/Head}/index.js +2 -2
  6. package/es/Table/{Row → v1/Row}/index.js +2 -2
  7. package/es/Table/{RowHeader → v1/RowHeader}/index.js +2 -2
  8. package/es/Table/{index.js → v1/index.js} +2 -2
  9. package/es/Table/v2/Body/index.js +73 -0
  10. package/es/Table/v2/Body/props.js +26 -0
  11. package/es/Table/v2/Body/styles.js +45 -0
  12. package/es/Table/v2/Cell/index.js +68 -0
  13. package/es/Table/v2/Cell/props.js +26 -0
  14. package/es/Table/v2/Cell/styles.js +54 -0
  15. package/es/Table/v2/ColHeader/index.js +117 -0
  16. package/es/Table/v2/ColHeader/props.js +26 -0
  17. package/es/Table/v2/ColHeader/styles.js +93 -0
  18. package/es/Table/v2/Head/index.js +173 -0
  19. package/es/Table/v2/Head/props.js +26 -0
  20. package/es/Table/v2/Head/styles.js +45 -0
  21. package/es/Table/v2/Row/index.js +82 -0
  22. package/es/Table/v2/Row/props.js +26 -0
  23. package/es/Table/v2/Row/styles.js +67 -0
  24. package/es/Table/v2/RowHeader/index.js +68 -0
  25. package/es/Table/v2/RowHeader/props.js +26 -0
  26. package/es/Table/v2/RowHeader/styles.js +54 -0
  27. package/es/Table/v2/TableContext.js +46 -0
  28. package/es/Table/v2/index.js +135 -0
  29. package/es/Table/v2/props.js +26 -0
  30. package/es/Table/v2/styles.js +58 -0
  31. package/es/exports/a.js +31 -0
  32. package/es/exports/b.js +31 -0
  33. package/lib/Table/{Body → v1/Body}/index.js +4 -4
  34. package/lib/Table/{Cell → v1/Cell}/index.js +4 -4
  35. package/lib/Table/{ColHeader → v1/ColHeader}/index.js +4 -4
  36. package/lib/Table/{Head → v1/Head}/index.js +5 -5
  37. package/lib/Table/{Row → v1/Row}/index.js +4 -4
  38. package/lib/Table/{RowHeader → v1/RowHeader}/index.js +4 -4
  39. package/lib/Table/{index.js → v1/index.js} +4 -4
  40. package/lib/Table/v2/Body/index.js +79 -0
  41. package/lib/Table/v2/Body/props.js +31 -0
  42. package/lib/Table/v2/Body/styles.js +51 -0
  43. package/lib/Table/v2/Cell/index.js +74 -0
  44. package/lib/Table/v2/Cell/props.js +31 -0
  45. package/lib/Table/v2/Cell/styles.js +60 -0
  46. package/lib/Table/v2/ColHeader/index.js +122 -0
  47. package/lib/Table/v2/ColHeader/props.js +31 -0
  48. package/lib/Table/v2/ColHeader/styles.js +99 -0
  49. package/lib/Table/v2/Head/index.js +179 -0
  50. package/lib/Table/v2/Head/props.js +31 -0
  51. package/lib/Table/v2/Head/styles.js +51 -0
  52. package/lib/Table/v2/Row/index.js +88 -0
  53. package/lib/Table/v2/Row/props.js +31 -0
  54. package/lib/Table/v2/Row/styles.js +73 -0
  55. package/lib/Table/v2/RowHeader/index.js +74 -0
  56. package/lib/Table/v2/RowHeader/props.js +31 -0
  57. package/lib/Table/v2/RowHeader/styles.js +60 -0
  58. package/lib/Table/v2/TableContext.js +51 -0
  59. package/lib/Table/v2/index.js +140 -0
  60. package/lib/Table/v2/props.js +31 -0
  61. package/lib/Table/v2/styles.js +64 -0
  62. package/lib/{index.js → exports/a.js} +9 -9
  63. package/lib/exports/b.js +61 -0
  64. package/package.json +43 -21
  65. package/src/Table/{Body → v1/Body}/index.tsx +2 -2
  66. package/src/Table/{Cell → v1/Cell}/index.tsx +2 -2
  67. package/src/Table/{ColHeader → v1/ColHeader}/index.tsx +1 -1
  68. package/src/Table/{Head → v1/Head}/index.tsx +3 -3
  69. package/src/Table/{README.md → v1/README.md} +1 -1
  70. package/src/Table/{Row → v1/Row}/index.tsx +2 -2
  71. package/src/Table/{RowHeader → v1/RowHeader}/index.tsx +2 -2
  72. package/src/Table/{index.tsx → v1/index.tsx} +2 -2
  73. package/src/Table/v2/Body/index.tsx +91 -0
  74. package/src/Table/v2/Body/props.ts +50 -0
  75. package/src/Table/v2/Body/styles.ts +51 -0
  76. package/src/Table/v2/Cell/index.tsx +83 -0
  77. package/src/Table/v2/Cell/props.ts +54 -0
  78. package/src/Table/v2/Cell/styles.ts +60 -0
  79. package/src/Table/v2/ColHeader/index.tsx +118 -0
  80. package/src/Table/v2/ColHeader/props.ts +93 -0
  81. package/src/Table/v2/ColHeader/styles.ts +95 -0
  82. package/src/Table/v2/Head/index.tsx +200 -0
  83. package/src/Table/v2/Head/props.ts +64 -0
  84. package/src/Table/v2/Head/styles.ts +51 -0
  85. package/src/Table/v2/README.md +1155 -0
  86. package/src/Table/v2/Row/index.tsx +105 -0
  87. package/src/Table/v2/Row/props.ts +67 -0
  88. package/src/Table/v2/Row/styles.ts +78 -0
  89. package/src/Table/v2/RowHeader/index.tsx +84 -0
  90. package/src/Table/v2/RowHeader/props.ts +48 -0
  91. package/src/Table/v2/RowHeader/styles.ts +60 -0
  92. package/src/Table/v2/TableContext.ts +66 -0
  93. package/src/Table/v2/index.tsx +160 -0
  94. package/src/Table/v2/props.ts +98 -0
  95. package/src/Table/v2/styles.ts +63 -0
  96. package/src/exports/a.ts +39 -0
  97. package/src/exports/b.ts +39 -0
  98. package/tsconfig.build.tsbuildinfo +1 -1
  99. package/types/Table/v1/Body/index.d.ts.map +1 -0
  100. package/types/Table/v1/Body/props.d.ts.map +1 -0
  101. package/types/Table/v1/Body/styles.d.ts.map +1 -0
  102. package/types/Table/v1/Body/theme.d.ts.map +1 -0
  103. package/types/Table/v1/Cell/index.d.ts.map +1 -0
  104. package/types/Table/v1/Cell/props.d.ts.map +1 -0
  105. package/types/Table/v1/Cell/styles.d.ts.map +1 -0
  106. package/types/Table/v1/Cell/theme.d.ts.map +1 -0
  107. package/types/Table/v1/ColHeader/index.d.ts.map +1 -0
  108. package/types/Table/v1/ColHeader/props.d.ts.map +1 -0
  109. package/types/Table/v1/ColHeader/styles.d.ts.map +1 -0
  110. package/types/Table/v1/ColHeader/theme.d.ts.map +1 -0
  111. package/types/Table/v1/Head/index.d.ts.map +1 -0
  112. package/types/Table/v1/Head/props.d.ts.map +1 -0
  113. package/types/Table/v1/Head/styles.d.ts.map +1 -0
  114. package/types/Table/v1/Head/theme.d.ts.map +1 -0
  115. package/types/Table/v1/Row/index.d.ts.map +1 -0
  116. package/types/Table/v1/Row/props.d.ts.map +1 -0
  117. package/types/Table/v1/Row/styles.d.ts.map +1 -0
  118. package/types/Table/v1/Row/theme.d.ts.map +1 -0
  119. package/types/Table/v1/RowHeader/index.d.ts.map +1 -0
  120. package/types/Table/v1/RowHeader/props.d.ts.map +1 -0
  121. package/types/Table/v1/RowHeader/styles.d.ts.map +1 -0
  122. package/types/Table/v1/RowHeader/theme.d.ts.map +1 -0
  123. package/types/Table/v1/TableContext.d.ts.map +1 -0
  124. package/types/Table/v1/index.d.ts.map +1 -0
  125. package/types/Table/v1/props.d.ts.map +1 -0
  126. package/types/Table/v1/styles.d.ts.map +1 -0
  127. package/types/Table/v1/theme.d.ts.map +1 -0
  128. package/types/Table/v2/Body/index.d.ts +24 -0
  129. package/types/Table/v2/Body/index.d.ts.map +1 -0
  130. package/types/Table/v2/Body/props.d.ts +20 -0
  131. package/types/Table/v2/Body/props.d.ts.map +1 -0
  132. package/types/Table/v2/Body/styles.d.ts +13 -0
  133. package/types/Table/v2/Body/styles.d.ts.map +1 -0
  134. package/types/Table/v2/Cell/index.d.ts +29 -0
  135. package/types/Table/v2/Cell/index.d.ts.map +1 -0
  136. package/types/Table/v2/Cell/props.d.ts +23 -0
  137. package/types/Table/v2/Cell/props.d.ts.map +1 -0
  138. package/types/Table/v2/Cell/styles.d.ts +14 -0
  139. package/types/Table/v2/Cell/styles.d.ts.map +1 -0
  140. package/types/Table/v2/ColHeader/index.d.ts +37 -0
  141. package/types/Table/v2/ColHeader/index.d.ts.map +1 -0
  142. package/types/Table/v2/ColHeader/props.d.ts +47 -0
  143. package/types/Table/v2/ColHeader/props.d.ts.map +1 -0
  144. package/types/Table/v2/ColHeader/styles.d.ts +15 -0
  145. package/types/Table/v2/ColHeader/styles.d.ts.map +1 -0
  146. package/types/Table/v2/Head/index.d.ts +38 -0
  147. package/types/Table/v2/Head/index.d.ts.map +1 -0
  148. package/types/Table/v2/Head/props.d.ts +34 -0
  149. package/types/Table/v2/Head/props.d.ts.map +1 -0
  150. package/types/Table/v2/Head/styles.d.ts +13 -0
  151. package/types/Table/v2/Head/styles.d.ts.map +1 -0
  152. package/types/Table/v2/Row/index.d.ts +27 -0
  153. package/types/Table/v2/Row/index.d.ts.map +1 -0
  154. package/types/Table/v2/Row/props.d.ts +29 -0
  155. package/types/Table/v2/Row/props.d.ts.map +1 -0
  156. package/types/Table/v2/Row/styles.d.ts +19 -0
  157. package/types/Table/v2/Row/styles.d.ts.map +1 -0
  158. package/types/Table/v2/RowHeader/index.d.ts +28 -0
  159. package/types/Table/v2/RowHeader/index.d.ts.map +1 -0
  160. package/types/Table/v2/RowHeader/props.d.ts +17 -0
  161. package/types/Table/v2/RowHeader/props.d.ts.map +1 -0
  162. package/types/Table/v2/RowHeader/styles.d.ts +14 -0
  163. package/types/Table/v2/RowHeader/styles.d.ts.map +1 -0
  164. package/types/Table/v2/TableContext.d.ts +36 -0
  165. package/types/Table/v2/TableContext.d.ts.map +1 -0
  166. package/types/Table/v2/index.d.ts +45 -0
  167. package/types/Table/v2/index.d.ts.map +1 -0
  168. package/types/Table/v2/props.d.ts +53 -0
  169. package/types/Table/v2/props.d.ts.map +1 -0
  170. package/types/Table/v2/styles.d.ts +15 -0
  171. package/types/Table/v2/styles.d.ts.map +1 -0
  172. package/types/exports/a.d.ts +16 -0
  173. package/types/exports/a.d.ts.map +1 -0
  174. package/types/exports/b.d.ts +16 -0
  175. package/types/exports/b.d.ts.map +1 -0
  176. package/es/index.js +0 -31
  177. package/src/index.ts +0 -39
  178. package/types/Table/Body/index.d.ts.map +0 -1
  179. package/types/Table/Body/props.d.ts.map +0 -1
  180. package/types/Table/Body/styles.d.ts.map +0 -1
  181. package/types/Table/Body/theme.d.ts.map +0 -1
  182. package/types/Table/Cell/index.d.ts.map +0 -1
  183. package/types/Table/Cell/props.d.ts.map +0 -1
  184. package/types/Table/Cell/styles.d.ts.map +0 -1
  185. package/types/Table/Cell/theme.d.ts.map +0 -1
  186. package/types/Table/ColHeader/index.d.ts.map +0 -1
  187. package/types/Table/ColHeader/props.d.ts.map +0 -1
  188. package/types/Table/ColHeader/styles.d.ts.map +0 -1
  189. package/types/Table/ColHeader/theme.d.ts.map +0 -1
  190. package/types/Table/Head/index.d.ts.map +0 -1
  191. package/types/Table/Head/props.d.ts.map +0 -1
  192. package/types/Table/Head/styles.d.ts.map +0 -1
  193. package/types/Table/Head/theme.d.ts.map +0 -1
  194. package/types/Table/Row/index.d.ts.map +0 -1
  195. package/types/Table/Row/props.d.ts.map +0 -1
  196. package/types/Table/Row/styles.d.ts.map +0 -1
  197. package/types/Table/Row/theme.d.ts.map +0 -1
  198. package/types/Table/RowHeader/index.d.ts.map +0 -1
  199. package/types/Table/RowHeader/props.d.ts.map +0 -1
  200. package/types/Table/RowHeader/styles.d.ts.map +0 -1
  201. package/types/Table/RowHeader/theme.d.ts.map +0 -1
  202. package/types/Table/TableContext.d.ts.map +0 -1
  203. package/types/Table/index.d.ts.map +0 -1
  204. package/types/Table/props.d.ts.map +0 -1
  205. package/types/Table/styles.d.ts.map +0 -1
  206. package/types/Table/theme.d.ts.map +0 -1
  207. package/types/index.d.ts +0 -16
  208. package/types/index.d.ts.map +0 -1
  209. /package/es/Table/{Body → v1/Body}/props.js +0 -0
  210. /package/es/Table/{Body → v1/Body}/styles.js +0 -0
  211. /package/es/Table/{Body → v1/Body}/theme.js +0 -0
  212. /package/es/Table/{Cell → v1/Cell}/props.js +0 -0
  213. /package/es/Table/{Cell → v1/Cell}/styles.js +0 -0
  214. /package/es/Table/{Cell → v1/Cell}/theme.js +0 -0
  215. /package/es/Table/{ColHeader → v1/ColHeader}/props.js +0 -0
  216. /package/es/Table/{ColHeader → v1/ColHeader}/styles.js +0 -0
  217. /package/es/Table/{ColHeader → v1/ColHeader}/theme.js +0 -0
  218. /package/es/Table/{Head → v1/Head}/props.js +0 -0
  219. /package/es/Table/{Head → v1/Head}/styles.js +0 -0
  220. /package/es/Table/{Head → v1/Head}/theme.js +0 -0
  221. /package/es/Table/{Row → v1/Row}/props.js +0 -0
  222. /package/es/Table/{Row → v1/Row}/styles.js +0 -0
  223. /package/es/Table/{Row → v1/Row}/theme.js +0 -0
  224. /package/es/Table/{RowHeader → v1/RowHeader}/props.js +0 -0
  225. /package/es/Table/{RowHeader → v1/RowHeader}/styles.js +0 -0
  226. /package/es/Table/{RowHeader → v1/RowHeader}/theme.js +0 -0
  227. /package/es/Table/{TableContext.js → v1/TableContext.js} +0 -0
  228. /package/es/Table/{props.js → v1/props.js} +0 -0
  229. /package/es/Table/{styles.js → v1/styles.js} +0 -0
  230. /package/es/Table/{theme.js → v1/theme.js} +0 -0
  231. /package/lib/Table/{Body → v1/Body}/props.js +0 -0
  232. /package/lib/Table/{Body → v1/Body}/styles.js +0 -0
  233. /package/lib/Table/{Body → v1/Body}/theme.js +0 -0
  234. /package/lib/Table/{Cell → v1/Cell}/props.js +0 -0
  235. /package/lib/Table/{Cell → v1/Cell}/styles.js +0 -0
  236. /package/lib/Table/{Cell → v1/Cell}/theme.js +0 -0
  237. /package/lib/Table/{ColHeader → v1/ColHeader}/props.js +0 -0
  238. /package/lib/Table/{ColHeader → v1/ColHeader}/styles.js +0 -0
  239. /package/lib/Table/{ColHeader → v1/ColHeader}/theme.js +0 -0
  240. /package/lib/Table/{Head → v1/Head}/props.js +0 -0
  241. /package/lib/Table/{Head → v1/Head}/styles.js +0 -0
  242. /package/lib/Table/{Head → v1/Head}/theme.js +0 -0
  243. /package/lib/Table/{Row → v1/Row}/props.js +0 -0
  244. /package/lib/Table/{Row → v1/Row}/styles.js +0 -0
  245. /package/lib/Table/{Row → v1/Row}/theme.js +0 -0
  246. /package/lib/Table/{RowHeader → v1/RowHeader}/props.js +0 -0
  247. /package/lib/Table/{RowHeader → v1/RowHeader}/styles.js +0 -0
  248. /package/lib/Table/{RowHeader → v1/RowHeader}/theme.js +0 -0
  249. /package/lib/Table/{TableContext.js → v1/TableContext.js} +0 -0
  250. /package/lib/Table/{props.js → v1/props.js} +0 -0
  251. /package/lib/Table/{styles.js → v1/styles.js} +0 -0
  252. /package/lib/Table/{theme.js → v1/theme.js} +0 -0
  253. /package/src/Table/{Body → v1/Body}/props.ts +0 -0
  254. /package/src/Table/{Body → v1/Body}/styles.ts +0 -0
  255. /package/src/Table/{Body → v1/Body}/theme.ts +0 -0
  256. /package/src/Table/{Cell → v1/Cell}/props.ts +0 -0
  257. /package/src/Table/{Cell → v1/Cell}/styles.ts +0 -0
  258. /package/src/Table/{Cell → v1/Cell}/theme.ts +0 -0
  259. /package/src/Table/{ColHeader → v1/ColHeader}/props.ts +0 -0
  260. /package/src/Table/{ColHeader → v1/ColHeader}/styles.ts +0 -0
  261. /package/src/Table/{ColHeader → v1/ColHeader}/theme.ts +0 -0
  262. /package/src/Table/{Head → v1/Head}/props.ts +0 -0
  263. /package/src/Table/{Head → v1/Head}/styles.ts +0 -0
  264. /package/src/Table/{Head → v1/Head}/theme.ts +0 -0
  265. /package/src/Table/{Row → v1/Row}/props.ts +0 -0
  266. /package/src/Table/{Row → v1/Row}/styles.ts +0 -0
  267. /package/src/Table/{Row → v1/Row}/theme.ts +0 -0
  268. /package/src/Table/{RowHeader → v1/RowHeader}/props.ts +0 -0
  269. /package/src/Table/{RowHeader → v1/RowHeader}/styles.ts +0 -0
  270. /package/src/Table/{RowHeader → v1/RowHeader}/theme.ts +0 -0
  271. /package/src/Table/{TableContext.ts → v1/TableContext.ts} +0 -0
  272. /package/src/Table/{props.ts → v1/props.ts} +0 -0
  273. /package/src/Table/{styles.ts → v1/styles.ts} +0 -0
  274. /package/src/Table/{theme.ts → v1/theme.ts} +0 -0
  275. /package/types/Table/{Body → v1/Body}/index.d.ts +0 -0
  276. /package/types/Table/{Body → v1/Body}/props.d.ts +0 -0
  277. /package/types/Table/{Body → v1/Body}/styles.d.ts +0 -0
  278. /package/types/Table/{Body → v1/Body}/theme.d.ts +0 -0
  279. /package/types/Table/{Cell → v1/Cell}/index.d.ts +0 -0
  280. /package/types/Table/{Cell → v1/Cell}/props.d.ts +0 -0
  281. /package/types/Table/{Cell → v1/Cell}/styles.d.ts +0 -0
  282. /package/types/Table/{Cell → v1/Cell}/theme.d.ts +0 -0
  283. /package/types/Table/{ColHeader → v1/ColHeader}/index.d.ts +0 -0
  284. /package/types/Table/{ColHeader → v1/ColHeader}/props.d.ts +0 -0
  285. /package/types/Table/{ColHeader → v1/ColHeader}/styles.d.ts +0 -0
  286. /package/types/Table/{ColHeader → v1/ColHeader}/theme.d.ts +0 -0
  287. /package/types/Table/{Head → v1/Head}/index.d.ts +0 -0
  288. /package/types/Table/{Head → v1/Head}/props.d.ts +0 -0
  289. /package/types/Table/{Head → v1/Head}/styles.d.ts +0 -0
  290. /package/types/Table/{Head → v1/Head}/theme.d.ts +0 -0
  291. /package/types/Table/{Row → v1/Row}/index.d.ts +0 -0
  292. /package/types/Table/{Row → v1/Row}/props.d.ts +0 -0
  293. /package/types/Table/{Row → v1/Row}/styles.d.ts +0 -0
  294. /package/types/Table/{Row → v1/Row}/theme.d.ts +0 -0
  295. /package/types/Table/{RowHeader → v1/RowHeader}/index.d.ts +0 -0
  296. /package/types/Table/{RowHeader → v1/RowHeader}/props.d.ts +0 -0
  297. /package/types/Table/{RowHeader → v1/RowHeader}/styles.d.ts +0 -0
  298. /package/types/Table/{RowHeader → v1/RowHeader}/theme.d.ts +0 -0
  299. /package/types/Table/{TableContext.d.ts → v1/TableContext.d.ts} +0 -0
  300. /package/types/Table/{index.d.ts → v1/index.d.ts} +0 -0
  301. /package/types/Table/{props.d.ts → v1/props.d.ts} +0 -0
  302. /package/types/Table/{styles.d.ts → v1/styles.d.ts} +0 -0
  303. /package/types/Table/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,54 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { ComponentStyle, WithStyleProps } from '@instructure/emotion'
26
+ import type { Renderable, OtherHTMLAttributes } from '@instructure/shared-types'
27
+
28
+ type TableCellOwnProps = {
29
+ /**
30
+ * Contains the column header for this cell.
31
+ * This gets rendered in `stacked` layout to identify the column the data
32
+ * belongs to.
33
+ */
34
+ header?: Renderable
35
+ /**
36
+ * Controls the text alignment in cell.
37
+ */
38
+ textAlign?: 'start' | 'center' | 'end'
39
+ children?: Renderable
40
+ }
41
+
42
+ type PropKeys = keyof TableCellOwnProps
43
+
44
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
45
+
46
+ type TableCellProps = TableCellOwnProps &
47
+ WithStyleProps<null, TableCellStyle> &
48
+ OtherHTMLAttributes<TableCellOwnProps>
49
+
50
+ type TableCellStyle = ComponentStyle<'cell'>
51
+ const allowedProps: AllowedPropKeys = ['children', 'header', 'textAlign']
52
+
53
+ export type { TableCellProps, TableCellStyle }
54
+ export { allowedProps }
@@ -0,0 +1,60 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { NewComponentTypes } from '@instructure/ui-themes'
26
+ import type { TableCellProps, TableCellStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @param {Object} props the props of the component, the style is applied to
35
+ * @return {Object} The final style object, which will be used in the component
36
+ */
37
+ const generateStyle = (
38
+ componentTheme: NewComponentTypes['TableCell'],
39
+ props: TableCellProps
40
+ ): TableCellStyle => {
41
+ const { textAlign } = props
42
+
43
+ return {
44
+ cell: {
45
+ label: 'cell',
46
+ fontSize: componentTheme.fontSize,
47
+ fontFamily: componentTheme.fontFamily,
48
+ fontWeight: componentTheme.fontWeight,
49
+ color: componentTheme.color,
50
+ background: componentTheme.background,
51
+ boxSizing: 'border-box',
52
+ verticalAlign: 'middle',
53
+ lineHeight: componentTheme.lineHeight,
54
+ padding: `${componentTheme.paddingVertical} ${componentTheme.paddingHorizontal}`,
55
+ ...(textAlign && { textAlign })
56
+ }
57
+ }
58
+ }
59
+
60
+ export default generateStyle
@@ -0,0 +1,118 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component } from 'react'
26
+
27
+ import { omitProps, callRenderProp } from '@instructure/ui-react-utils'
28
+
29
+ import { withStyle } from '@instructure/emotion'
30
+
31
+ import generateStyle from './styles'
32
+ import type { TableColHeaderProps } from './props'
33
+ import { allowedProps } from './props'
34
+ import {
35
+ ChevronsUpDownInstUIIcon,
36
+ ChevronUpInstUIIcon,
37
+ ChevronDownInstUIIcon
38
+ } from '@instructure/ui-icons'
39
+
40
+ /**
41
+ ---
42
+ parent: Table
43
+ id: Table.ColHeader
44
+ ---
45
+ **/
46
+ @withStyle(generateStyle)
47
+ class ColHeader extends Component<TableColHeaderProps> {
48
+ static readonly componentId = 'Table.ColHeader'
49
+
50
+ static allowedProps = allowedProps
51
+
52
+ static defaultProps = {
53
+ textAlign: 'start',
54
+ sortDirection: 'none',
55
+ children: null,
56
+ scope: 'col'
57
+ }
58
+
59
+ componentDidMount() {
60
+ this.props.makeStyles?.()
61
+ }
62
+
63
+ componentDidUpdate() {
64
+ this.props.makeStyles?.()
65
+ }
66
+
67
+ handleClick = (event: React.SyntheticEvent) => {
68
+ const { id, onRequestSort } = this.props
69
+
70
+ onRequestSort && onRequestSort(event, { id })
71
+ }
72
+
73
+ renderSortArrow() {
74
+ const { sortDirection, onRequestSort } = this.props
75
+
76
+ if (sortDirection === 'ascending') {
77
+ return <ChevronUpInstUIIcon color="infoColor" size="sm" />
78
+ }
79
+ if (sortDirection === 'descending') {
80
+ return <ChevronDownInstUIIcon color="infoColor" size="sm" />
81
+ }
82
+ if (onRequestSort) {
83
+ return <ChevronsUpDownInstUIIcon color="baseColor" size="sm" />
84
+ }
85
+ return undefined
86
+ }
87
+
88
+ render() {
89
+ const { onRequestSort, width, children, sortDirection, scope, styles } =
90
+ this.props
91
+
92
+ return (
93
+ <th
94
+ {...omitProps(this.props, ColHeader.allowedProps)}
95
+ css={styles?.colHeader}
96
+ style={{
97
+ width
98
+ }}
99
+ scope={scope}
100
+ aria-sort={sortDirection}
101
+ >
102
+ {onRequestSort && (
103
+ <button onClick={this.handleClick} css={styles?.button}>
104
+ <div css={styles?.buttonContent}>
105
+ {callRenderProp(children)}
106
+ {this.renderSortArrow()}
107
+ </div>
108
+ </button>
109
+ )}
110
+ {!onRequestSort && children}
111
+ {!onRequestSort && this.renderSortArrow()}
112
+ </th>
113
+ )
114
+ }
115
+ }
116
+
117
+ export default ColHeader
118
+ export { ColHeader }
@@ -0,0 +1,93 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+ import { ThHTMLAttributes } from 'react'
25
+
26
+ import type { OtherHTMLAttributes } from '@instructure/shared-types'
27
+ import type { ComponentStyle, WithStyleProps } from '@instructure/emotion'
28
+
29
+ type TableColHeaderOwnProps = {
30
+ /**
31
+ * A unique id for this column. The `id` is also used as option in combobox,
32
+ * when sortable table is in stacked layout,
33
+ * and no `stackedSortByLabel` is provided.
34
+ */
35
+ id: string
36
+ /**
37
+ * A custom string to display as option text in the combobox (instead of
38
+ * using the `id` prop), when sortable table is in stacked layout.
39
+ */
40
+ stackedSortByLabel?: string
41
+ /**
42
+ * Control the width of column.
43
+ */
44
+ width?: string | number
45
+ /**
46
+ * Control the text alignment in column header
47
+ */
48
+ textAlign?: 'start' | 'center' | 'end'
49
+ /**
50
+ * The sorting direction
51
+ */
52
+ sortDirection?: 'none' | 'ascending' | 'descending'
53
+ /**
54
+ * Callback fired when column header is clicked.
55
+ */
56
+ onRequestSort?: (
57
+ event: React.SyntheticEvent,
58
+ param: { id: TableColHeaderOwnProps['id'] }
59
+ ) => void
60
+ /**
61
+ * The column header scope attribute. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/th#scope
62
+ */
63
+ scope?: 'row' | 'col' | 'rowgroup' | 'colgroup' | 'auto'
64
+ children?: React.ReactNode
65
+ }
66
+
67
+ type PropKeys = keyof TableColHeaderOwnProps
68
+
69
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
70
+
71
+ type TableColHeaderProps = TableColHeaderOwnProps &
72
+ WithStyleProps<null, TableColHeaderStyle> &
73
+ OtherHTMLAttributes<
74
+ TableColHeaderOwnProps,
75
+ ThHTMLAttributes<TableColHeaderOwnProps>
76
+ >
77
+
78
+ type TableColHeaderStyle = ComponentStyle<
79
+ 'colHeader' | 'button' | 'buttonContent'
80
+ >
81
+ const allowedProps: AllowedPropKeys = [
82
+ 'id',
83
+ 'stackedSortByLabel',
84
+ 'children',
85
+ 'width',
86
+ 'textAlign',
87
+ 'sortDirection',
88
+ 'onRequestSort',
89
+ 'scope'
90
+ ]
91
+
92
+ export type { TableColHeaderProps, TableColHeaderStyle }
93
+ export { allowedProps }
@@ -0,0 +1,95 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
26
+ import type { TableColHeaderProps, TableColHeaderStyle } from './props'
27
+
28
+ /**
29
+ * ---
30
+ * private: true
31
+ * ---
32
+ * Generates the style object from the theme and provided additional information
33
+ * @param {Object} componentTheme The theme variable object.
34
+ * @param {Object} props the props of the component, the style is applied to
35
+ * @param {Object} sharedTokens Shared token object that stores common values for the theme.
36
+ * @return {Object} The final style object, which will be used in the component
37
+ */
38
+ const generateStyle = (
39
+ componentTheme: NewComponentTypes['TableColHeader'],
40
+ props: TableColHeaderProps,
41
+ sharedTokens: SharedTokens
42
+ ): TableColHeaderStyle => {
43
+ const { onRequestSort, textAlign } = props
44
+
45
+ const headerStyle = {
46
+ color: componentTheme.color,
47
+ fontSize: componentTheme.fontSize,
48
+ fontFamily: componentTheme.fontFamily,
49
+ fontWeight: 'bold',
50
+ lineHeight: componentTheme.lineHeight,
51
+ padding: `${componentTheme.paddingVertical} ${componentTheme.paddingHorizontal}`
52
+ }
53
+
54
+ const buttonTextAlignVariants = {
55
+ start: { flexDirection: 'row' },
56
+ center: { justifyContent: 'center' },
57
+ end: { flexDirection: 'row-reverse' }
58
+ }
59
+
60
+ return {
61
+ colHeader: {
62
+ label: 'colHeader',
63
+ background: componentTheme.background,
64
+ verticalAlign: 'middle',
65
+ boxSizing: 'border-box',
66
+ ...(!onRequestSort && headerStyle),
67
+ textAlign: textAlign
68
+ },
69
+ button: {
70
+ label: 'colHeader__button',
71
+ ...headerStyle,
72
+ display: 'flex',
73
+ alignItems: 'center',
74
+ boxSizing: 'border-box',
75
+ border: 'none',
76
+ width: '100%',
77
+ height: '100%',
78
+ background: 'transparent',
79
+ cursor: 'pointer',
80
+ outline: 'none',
81
+ '&::-moz-focus-inner': { border: 0 },
82
+ '&:focus': {
83
+ outline: `${sharedTokens.focusOutline.width} ${sharedTokens.focusOutline.style} ${sharedTokens.focusOutline.infoColor}`
84
+ },
85
+ ...(textAlign && buttonTextAlignVariants[textAlign])
86
+ },
87
+ buttonContent: {
88
+ label: 'colHeader__buttonContent',
89
+ display: 'flex',
90
+ alignItems: 'center'
91
+ }
92
+ }
93
+ }
94
+
95
+ export default generateStyle
@@ -0,0 +1,200 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import { Component, Children, ContextType, type ReactElement } from 'react'
26
+
27
+ import { omitProps, callRenderProp } from '@instructure/ui-react-utils'
28
+ import { SimpleSelect } from '@instructure/ui-simple-select/latest'
29
+ import type { SimpleSelectProps } from '@instructure/ui-simple-select/latest'
30
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content'
31
+ import { CheckInstUIIcon } from '@instructure/ui-icons'
32
+ import { warn } from '@instructure/console'
33
+
34
+ import { withStyle } from '@instructure/emotion'
35
+
36
+ import generateStyle from './styles'
37
+
38
+ import type { TableColHeaderProps } from '../ColHeader/props'
39
+ import type { TableHeadProps } from './props'
40
+ import type { RowChild } from '../props'
41
+ import { allowedProps } from './props'
42
+ import TableContext from '../TableContext'
43
+
44
+ /**
45
+ ---
46
+ parent: Table
47
+ id: Table.Head
48
+ ---
49
+ **/
50
+ @withStyle(generateStyle)
51
+ class Head extends Component<TableHeadProps> {
52
+ static readonly componentId = 'Table.Head'
53
+ static contextType = TableContext
54
+ declare context: ContextType<typeof TableContext>
55
+ static allowedProps = allowedProps
56
+ static defaultProps = {
57
+ children: null
58
+ }
59
+
60
+ /**
61
+ * Returns `true` if the first child's children have a `onRequestSort` prop
62
+ */
63
+ get isSortable() {
64
+ const [firstRow] = Children.toArray(this.props.children) as RowChild[]
65
+ let sortable = false
66
+ if (firstRow && firstRow.props && firstRow.props.children) {
67
+ Children.forEach(
68
+ firstRow.props.children,
69
+ (grandchild: ReactElement<any>) => {
70
+ if (grandchild?.props?.onRequestSort) {
71
+ sortable = true
72
+ return
73
+ }
74
+ }
75
+ )
76
+ }
77
+ return sortable
78
+ }
79
+
80
+ componentDidMount() {
81
+ this.props.makeStyles?.()
82
+ }
83
+
84
+ componentDidUpdate() {
85
+ if (this.isSortable && typeof this.props.renderSortLabel === 'undefined') {
86
+ warn(
87
+ false,
88
+ '[Table.Head] The `renderSortLabel` prop should be provided when Table is sortable.'
89
+ )
90
+ }
91
+ this.props.makeStyles?.()
92
+ }
93
+
94
+ /**
95
+ * This `Select` is used in `stacked` layout. It's populated by iterating
96
+ * through the first child's children (by default `ColHeader`) and reading
97
+ * there the `id`, `stackedSortByLabel`, `sortDirection`, `onRequestSort` props
98
+ */
99
+ renderSelect() {
100
+ const { children, renderSortLabel } = this.props
101
+ const [firstRow] = Children.toArray(children) as RowChild[]
102
+
103
+ if (!firstRow?.props?.children) {
104
+ return null
105
+ }
106
+
107
+ const options: {
108
+ id: TableColHeaderProps['id']
109
+ label:
110
+ | TableColHeaderProps['stackedSortByLabel']
111
+ | TableColHeaderProps['id']
112
+ }[] = []
113
+ const clickHandlers: Record<
114
+ TableColHeaderProps['id'],
115
+ TableColHeaderProps['onRequestSort']
116
+ > = {}
117
+ let selectedOption: TableColHeaderProps['id'] | undefined
118
+ let count = 0
119
+ Children.forEach(
120
+ firstRow.props.children,
121
+ (grandchild: ReactElement<any>) => {
122
+ count += 1
123
+ if (!grandchild?.props) return // grandchild can be false
124
+ const { id, stackedSortByLabel, sortDirection, onRequestSort } =
125
+ grandchild.props
126
+ if (id && onRequestSort) {
127
+ const label = stackedSortByLabel || id
128
+ options.push({ id, label })
129
+ clickHandlers[id] = onRequestSort
130
+ if (sortDirection !== 'none') {
131
+ selectedOption = id
132
+ }
133
+ }
134
+ }
135
+ )
136
+ if (!options.length) {
137
+ return null
138
+ }
139
+ const handleSelect: SimpleSelectProps['onChange'] = (event, { value }) => {
140
+ if (value && typeof clickHandlers[value] === 'function') {
141
+ clickHandlers[value]!(event, { id: `${value}` })
142
+ }
143
+ }
144
+ return (
145
+ <div role="rowgroup">
146
+ <div role="row">
147
+ <div role="cell" aria-colspan={count}>
148
+ <SimpleSelect
149
+ renderLabel={
150
+ renderSortLabel ? (
151
+ callRenderProp(renderSortLabel)
152
+ ) : (
153
+ <ScreenReaderContent></ScreenReaderContent>
154
+ )
155
+ }
156
+ renderBeforeInput={
157
+ selectedOption ? () => <CheckInstUIIcon /> : undefined
158
+ }
159
+ value={selectedOption}
160
+ onChange={handleSelect}
161
+ >
162
+ {options.map(({ id, label }) => (
163
+ <SimpleSelect.Option
164
+ id={id}
165
+ key={id}
166
+ value={id}
167
+ renderBeforeLabel={
168
+ id === selectedOption
169
+ ? () => <CheckInstUIIcon />
170
+ : () => (
171
+ <span style={{ visibility: 'hidden' }}>
172
+ <CheckInstUIIcon />
173
+ </span>
174
+ )
175
+ }
176
+ >
177
+ {label}
178
+ </SimpleSelect.Option>
179
+ ))}
180
+ </SimpleSelect>
181
+ </div>
182
+ </div>
183
+ </div>
184
+ )
185
+ }
186
+
187
+ render() {
188
+ const { children, styles } = this.props
189
+ return this.context.isStacked ? (
190
+ this.renderSelect()
191
+ ) : (
192
+ <thead {...omitProps(this.props, Head.allowedProps)} css={styles?.head}>
193
+ {children}
194
+ </thead>
195
+ )
196
+ }
197
+ }
198
+
199
+ export default Head
200
+ export { Head }
@@ -0,0 +1,64 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ import type { Renderable, OtherHTMLAttributes } from '@instructure/shared-types'
26
+ import type { ComponentStyle, WithStyleProps } from '@instructure/emotion'
27
+ import { RowChild } from '../props'
28
+
29
+ type TableHeadOwnProps = {
30
+ /**
31
+ * The sort `Select`'s label when using `stacked` layout and the table is
32
+ * sortable.
33
+ * If you don't want to display anything you should use `ScreenReaderContent`
34
+ * so screen readers can read the `Select`'s purpose
35
+ */
36
+ renderSortLabel?: Renderable
37
+ /**
38
+ * The header row(s).
39
+ * Default type: `Table.Row`
40
+ *
41
+ * Its first child is treated specially if the table is sortable and has
42
+ * `stacked` layout:
43
+ *
44
+ * A `Select` is created which reads options from the first child's
45
+ * children, that tries to read the following props: `id`,
46
+ * `stackedSortByLabel`,`sortDirection`, `onRequestSort` (Available on
47
+ * `Table.ColHeader`).
48
+ * These are used to sort the table in this layout.
49
+ */
50
+ children?: RowChild
51
+ }
52
+ type PropKeys = keyof TableHeadOwnProps
53
+
54
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
55
+
56
+ type TableHeadProps = TableHeadOwnProps &
57
+ WithStyleProps<null, TableHeadStyle> &
58
+ OtherHTMLAttributes<TableHeadOwnProps>
59
+
60
+ type TableHeadStyle = ComponentStyle<'head'>
61
+ const allowedProps: AllowedPropKeys = ['children', 'renderSortLabel']
62
+
63
+ export type { TableHeadProps, TableHeadStyle }
64
+ export { allowedProps }