@instructure/ui-table 10.25.1-pr-snapshot-1758274491790 → 10.25.1-snapshot-1

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 (74) hide show
  1. package/CHANGELOG.md +2 -5
  2. package/es/Table/Body/index.js +16 -4
  3. package/es/Table/Body/props.js +5 -1
  4. package/es/Table/Cell/index.js +2 -2
  5. package/es/Table/Cell/props.js +7 -1
  6. package/es/Table/ColHeader/index.js +2 -2
  7. package/es/Table/ColHeader/props.js +14 -2
  8. package/es/Table/Head/index.js +6 -4
  9. package/es/Table/Head/props.js +6 -1
  10. package/es/Table/Row/index.js +5 -2
  11. package/es/Table/Row/props.js +6 -1
  12. package/es/Table/RowHeader/index.js +2 -2
  13. package/es/Table/RowHeader/props.js +6 -1
  14. package/es/Table/index.js +2 -2
  15. package/es/Table/props.js +10 -1
  16. package/lib/Table/Body/index.js +15 -3
  17. package/lib/Table/Body/props.js +6 -1
  18. package/lib/Table/Cell/index.js +1 -1
  19. package/lib/Table/Cell/props.js +8 -1
  20. package/lib/Table/ColHeader/index.js +1 -1
  21. package/lib/Table/ColHeader/props.js +15 -2
  22. package/lib/Table/Head/index.js +5 -3
  23. package/lib/Table/Head/props.js +7 -1
  24. package/lib/Table/Row/index.js +4 -1
  25. package/lib/Table/Row/props.js +7 -1
  26. package/lib/Table/RowHeader/index.js +1 -1
  27. package/lib/Table/RowHeader/props.js +7 -1
  28. package/lib/Table/index.js +1 -1
  29. package/lib/Table/props.js +11 -1
  30. package/package.json +18 -15
  31. package/src/Table/Body/index.tsx +14 -10
  32. package/src/Table/Body/props.ts +9 -1
  33. package/src/Table/Cell/index.tsx +2 -1
  34. package/src/Table/Cell/props.ts +11 -1
  35. package/src/Table/ColHeader/index.tsx +2 -1
  36. package/src/Table/ColHeader/props.ts +21 -1
  37. package/src/Table/Head/index.tsx +25 -26
  38. package/src/Table/Head/props.ts +10 -1
  39. package/src/Table/Row/index.tsx +7 -9
  40. package/src/Table/Row/props.ts +11 -3
  41. package/src/Table/RowHeader/index.tsx +2 -1
  42. package/src/Table/RowHeader/props.ts +10 -1
  43. package/src/Table/index.tsx +9 -15
  44. package/src/Table/props.ts +18 -2
  45. package/tsconfig.build.json +2 -0
  46. package/tsconfig.build.tsbuildinfo +1 -1
  47. package/types/Table/Body/index.d.ts +1 -0
  48. package/types/Table/Body/index.d.ts.map +1 -1
  49. package/types/Table/Body/props.d.ts +3 -2
  50. package/types/Table/Body/props.d.ts.map +1 -1
  51. package/types/Table/Cell/index.d.ts +5 -0
  52. package/types/Table/Cell/index.d.ts.map +1 -1
  53. package/types/Table/Cell/props.d.ts +3 -2
  54. package/types/Table/Cell/props.d.ts.map +1 -1
  55. package/types/Table/ColHeader/index.d.ts +14 -0
  56. package/types/Table/ColHeader/index.d.ts.map +1 -1
  57. package/types/Table/ColHeader/props.d.ts +7 -2
  58. package/types/Table/ColHeader/props.d.ts.map +1 -1
  59. package/types/Table/Head/index.d.ts +4 -0
  60. package/types/Table/Head/index.d.ts.map +1 -1
  61. package/types/Table/Head/props.d.ts +3 -2
  62. package/types/Table/Head/props.d.ts.map +1 -1
  63. package/types/Table/Row/index.d.ts +5 -1
  64. package/types/Table/Row/index.d.ts.map +1 -1
  65. package/types/Table/Row/props.d.ts +4 -3
  66. package/types/Table/Row/props.d.ts.map +1 -1
  67. package/types/Table/RowHeader/index.d.ts +4 -0
  68. package/types/Table/RowHeader/index.d.ts.map +1 -1
  69. package/types/Table/RowHeader/props.d.ts +3 -2
  70. package/types/Table/RowHeader/props.d.ts.map +1 -1
  71. package/types/Table/index.d.ts +8 -0
  72. package/types/Table/index.d.ts.map +1 -1
  73. package/types/Table/props.d.ts +3 -2
  74. package/types/Table/props.d.ts.map +1 -1
@@ -22,13 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import {
26
- Component,
27
- Children,
28
- ContextType,
29
- isValidElement,
30
- type ReactElement
31
- } from 'react'
25
+ import { Component, Children, ContextType, isValidElement } from 'react'
32
26
 
33
27
  import { safeCloneElement, omitProps } from '@instructure/ui-react-utils'
34
28
  import { View } from '@instructure/ui-view'
@@ -37,7 +31,7 @@ import { withStyle } from '@instructure/emotion'
37
31
  import generateStyle from './styles'
38
32
  import generateComponentTheme from './theme'
39
33
  import type { TableBodyProps } from './props'
40
- import { allowedProps } from './props'
34
+ import { allowedProps, propTypes } from './props'
41
35
  import TableContext from '../TableContext'
42
36
 
43
37
  /**
@@ -52,6 +46,7 @@ class Body extends Component<TableBodyProps> {
52
46
  static contextType = TableContext
53
47
  declare context: ContextType<typeof TableContext>
54
48
  static allowedProps = allowedProps
49
+ static propTypes = propTypes
55
50
  static defaultProps = {
56
51
  children: null
57
52
  }
@@ -66,7 +61,7 @@ class Body extends Component<TableBodyProps> {
66
61
 
67
62
  render() {
68
63
  const { children, styles } = this.props
69
- const { isStacked } = this.context
64
+ const { isStacked, hover, headers } = this.context
70
65
 
71
66
  return (
72
67
  <View
@@ -78,7 +73,16 @@ class Body extends Component<TableBodyProps> {
78
73
  {Children.map(children, (child) => {
79
74
  if (isValidElement(child)) {
80
75
  return safeCloneElement(child, {
81
- key: (child as ReactElement<any>).props.name
76
+ key: child.props.name,
77
+ // Sent down for compatibility with custom components
78
+ // TODO DEPRECATED, remove in v11
79
+ hover,
80
+ // Sent down for compatibility with custom components
81
+ // TODO DEPRECATED, remove in v11
82
+ isStacked,
83
+ // Sent down for compatibility with custom components
84
+ // TODO DEPRECATED, remove in v11
85
+ headers
82
86
  })
83
87
  }
84
88
  return child
@@ -22,8 +22,11 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import React from 'react'
25
+ import PropTypes from 'prop-types'
26
+
25
27
  import type {
26
28
  OtherHTMLAttributes,
29
+ PropValidators,
27
30
  TableBodyTheme
28
31
  } from '@instructure/shared-types'
29
32
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
@@ -47,7 +50,12 @@ type TableBodyProps = TableBodyOwnProps &
47
50
  OtherHTMLAttributes<TableBodyOwnProps>
48
51
 
49
52
  type TableBodyStyle = ComponentStyle<'body'>
53
+
54
+ const propTypes: PropValidators<PropKeys> = {
55
+ children: PropTypes.node
56
+ }
57
+
50
58
  const allowedProps: AllowedPropKeys = ['children']
51
59
 
52
60
  export type { TableBodyProps, TableBodyStyle }
53
- export { allowedProps }
61
+ export { propTypes, allowedProps }
@@ -32,7 +32,7 @@ import { withStyle } from '@instructure/emotion'
32
32
  import generateStyle from './styles'
33
33
  import generateComponentTheme from './theme'
34
34
  import type { TableCellProps } from './props'
35
- import { allowedProps } from './props'
35
+ import { allowedProps, propTypes } from './props'
36
36
  import TableContext from '../TableContext'
37
37
 
38
38
  /**
@@ -47,6 +47,7 @@ class Cell extends Component<TableCellProps> {
47
47
  static contextType = TableContext
48
48
  declare context: ContextType<typeof TableContext>
49
49
  static allowedProps = allowedProps
50
+ static propTypes = propTypes
50
51
 
51
52
  static defaultProps = {
52
53
  textAlign: 'start',
@@ -22,9 +22,12 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import PropTypes from 'prop-types'
26
+
25
27
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
26
28
  import type {
27
29
  OtherHTMLAttributes,
30
+ PropValidators,
28
31
  Renderable,
29
32
  TableCellTheme
30
33
  } from '@instructure/shared-types'
@@ -52,7 +55,14 @@ type TableCellProps = TableCellOwnProps &
52
55
  OtherHTMLAttributes<TableCellOwnProps>
53
56
 
54
57
  type TableCellStyle = ComponentStyle<'cell'>
58
+
59
+ const propTypes: PropValidators<PropKeys> = {
60
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
61
+ header: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
62
+ textAlign: PropTypes.oneOf(['start', 'center', 'end'])
63
+ }
64
+
55
65
  const allowedProps: AllowedPropKeys = ['children', 'header', 'textAlign']
56
66
 
57
67
  export type { TableCellProps, TableCellStyle }
58
- export { allowedProps }
68
+ export { propTypes, allowedProps }
@@ -36,7 +36,7 @@ import { withStyle } from '@instructure/emotion'
36
36
  import generateStyle from './styles'
37
37
  import generateComponentTheme from './theme'
38
38
  import type { TableColHeaderProps } from './props'
39
- import { allowedProps } from './props'
39
+ import { allowedProps, propTypes } from './props'
40
40
 
41
41
  /**
42
42
  ---
@@ -49,6 +49,7 @@ class ColHeader extends Component<TableColHeaderProps> {
49
49
  static readonly componentId = 'Table.ColHeader'
50
50
 
51
51
  static allowedProps = allowedProps
52
+ static propTypes = propTypes
52
53
 
53
54
  static defaultProps = {
54
55
  textAlign: 'start',
@@ -22,14 +22,20 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import { ThHTMLAttributes } from 'react'
25
+ import PropTypes from 'prop-types'
25
26
 
26
27
  import type {
27
28
  OtherHTMLAttributes,
29
+ PropValidators,
28
30
  TableColHeaderTheme
29
31
  } from '@instructure/shared-types'
30
32
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
31
33
 
32
34
  type TableColHeaderOwnProps = {
35
+ /**
36
+ * DEPRECATED. Use `TableContext` to read this value
37
+ */
38
+ isStacked?: boolean
33
39
  /**
34
40
  * A unique id for this column. The `id` is also used as option in combobox,
35
41
  * when sortable table is in stacked layout,
@@ -85,8 +91,22 @@ type TableColHeaderStyle = ComponentStyle<
85
91
  | 'unSortedIconColor'
86
92
  | 'sortedIconColor'
87
93
  >
94
+
95
+ const propTypes: PropValidators<PropKeys> = {
96
+ isStacked: PropTypes.bool,
97
+ id: PropTypes.string.isRequired,
98
+ stackedSortByLabel: PropTypes.string,
99
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
100
+ width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
101
+ textAlign: PropTypes.oneOf(['start', 'center', 'end']),
102
+ sortDirection: PropTypes.oneOf(['none', 'ascending', 'descending']),
103
+ onRequestSort: PropTypes.func,
104
+ scope: PropTypes.oneOf(['row', 'col', 'rowgroup', 'colgroup', 'auto'])
105
+ }
106
+
88
107
  const allowedProps: AllowedPropKeys = [
89
108
  'id',
109
+ 'isStacked',
90
110
  'stackedSortByLabel',
91
111
  'children',
92
112
  'width',
@@ -97,4 +117,4 @@ const allowedProps: AllowedPropKeys = [
97
117
  ]
98
118
 
99
119
  export type { TableColHeaderProps, TableColHeaderStyle }
100
- export { allowedProps }
120
+ export { propTypes, allowedProps }
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { Component, Children, ContextType, type ReactElement } from 'react'
25
+ import { Component, Children, ContextType } from 'react'
26
26
 
27
27
  import { omitProps, callRenderProp } from '@instructure/ui-react-utils'
28
28
  import { SimpleSelect } from '@instructure/ui-simple-select'
@@ -39,7 +39,7 @@ import generateComponentTheme from './theme'
39
39
  import type { TableColHeaderProps } from '../ColHeader/props'
40
40
  import type { TableHeadProps } from './props'
41
41
  import type { RowChild } from '../props'
42
- import { allowedProps } from './props'
42
+ import { allowedProps, propTypes } from './props'
43
43
  import TableContext from '../TableContext'
44
44
 
45
45
  /**
@@ -54,6 +54,7 @@ class Head extends Component<TableHeadProps> {
54
54
  static contextType = TableContext
55
55
  declare context: ContextType<typeof TableContext>
56
56
  static allowedProps = allowedProps
57
+ static propTypes = propTypes
57
58
  static defaultProps = {
58
59
  children: null
59
60
  }
@@ -65,15 +66,12 @@ class Head extends Component<TableHeadProps> {
65
66
  const [firstRow] = Children.toArray(this.props.children) as RowChild[]
66
67
  let sortable = false
67
68
  if (firstRow && firstRow.props && firstRow.props.children) {
68
- Children.forEach(
69
- firstRow.props.children,
70
- (grandchild: ReactElement<any>) => {
71
- if (grandchild?.props?.onRequestSort) {
72
- sortable = true
73
- return
74
- }
69
+ Children.forEach(firstRow.props.children, (grandchild) => {
70
+ if (grandchild?.props?.onRequestSort) {
71
+ sortable = true
72
+ return
75
73
  }
76
- )
74
+ })
77
75
  }
78
76
  return sortable
79
77
  }
@@ -117,23 +115,20 @@ class Head extends Component<TableHeadProps> {
117
115
  > = {}
118
116
  let selectedOption: TableColHeaderProps['id'] | undefined
119
117
  let count = 0
120
- Children.forEach(
121
- firstRow.props.children,
122
- (grandchild: ReactElement<any>) => {
123
- count += 1
124
- if (!grandchild?.props) return // grandchild can be false
125
- const { id, stackedSortByLabel, sortDirection, onRequestSort } =
126
- grandchild.props
127
- if (id && onRequestSort) {
128
- const label = stackedSortByLabel || id
129
- options.push({ id, label })
130
- clickHandlers[id] = onRequestSort
131
- if (sortDirection !== 'none') {
132
- selectedOption = id
133
- }
118
+ Children.forEach(firstRow.props.children, (grandchild) => {
119
+ count += 1
120
+ if (!grandchild?.props) return // grandchild can be false
121
+ const { id, stackedSortByLabel, sortDirection, onRequestSort } =
122
+ grandchild.props
123
+ if (id && onRequestSort) {
124
+ const label = stackedSortByLabel || id
125
+ options.push({ id, label })
126
+ clickHandlers[id] = onRequestSort
127
+ if (sortDirection !== 'none') {
128
+ selectedOption = id
134
129
  }
135
130
  }
136
- )
131
+ })
137
132
  if (!options.length) {
138
133
  return null
139
134
  }
@@ -184,7 +179,11 @@ class Head extends Component<TableHeadProps> {
184
179
  return this.context.isStacked ? (
185
180
  this.renderSelect()
186
181
  ) : (
187
- <thead {...omitProps(this.props, Head.allowedProps)} css={styles?.head}>
182
+ // TODO remove 'hover' exclude in v11, its passed down for compatibility with custom components
183
+ <thead
184
+ {...omitProps(this.props, Head.allowedProps, ['hover'])}
185
+ css={styles?.head}
186
+ >
188
187
  {children}
189
188
  </thead>
190
189
  )
@@ -22,8 +22,11 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import PropTypes from 'prop-types'
26
+
25
27
  import type {
26
28
  OtherHTMLAttributes,
29
+ PropValidators,
27
30
  Renderable,
28
31
  TableHeadTheme
29
32
  } from '@instructure/shared-types'
@@ -62,7 +65,13 @@ type TableHeadProps = TableHeadOwnProps &
62
65
  OtherHTMLAttributes<TableHeadOwnProps>
63
66
 
64
67
  type TableHeadStyle = ComponentStyle<'head'>
68
+
69
+ const propTypes: PropValidators<PropKeys> = {
70
+ children: PropTypes.node,
71
+ renderSortLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
72
+ }
73
+
65
74
  const allowedProps: AllowedPropKeys = ['children', 'renderSortLabel']
66
75
 
67
76
  export type { TableHeadProps, TableHeadStyle }
68
- export { allowedProps }
77
+ export { propTypes, allowedProps }
@@ -22,13 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import {
26
- Component,
27
- Children,
28
- ContextType,
29
- isValidElement,
30
- type ReactElement
31
- } from 'react'
25
+ import { Component, Children, ContextType, isValidElement } from 'react'
32
26
 
33
27
  import { omitProps, safeCloneElement } from '@instructure/ui-react-utils'
34
28
  import { View } from '@instructure/ui-view'
@@ -39,7 +33,7 @@ import generateStyle from './styles'
39
33
  import generateComponentTheme from './theme'
40
34
 
41
35
  import type { TableRowProps } from './props'
42
- import { allowedProps } from './props'
36
+ import { allowedProps, propTypes } from './props'
43
37
  import TableContext from '../TableContext'
44
38
 
45
39
  /**
@@ -54,6 +48,7 @@ class Row extends Component<TableRowProps> {
54
48
  static contextType = TableContext
55
49
  declare context: ContextType<typeof TableContext>
56
50
  static allowedProps = allowedProps
51
+ static propTypes = propTypes
57
52
 
58
53
  static defaultProps = {
59
54
  children: null
@@ -90,7 +85,10 @@ class Row extends Component<TableRowProps> {
90
85
  .map((child, index) => {
91
86
  if (isValidElement(child)) {
92
87
  return safeCloneElement(child, {
93
- key: (child as ReactElement<any>).props.name,
88
+ key: child.props.name,
89
+ // Sent down for compatibility with custom components
90
+ // TODO DEPRECATED, remove in v11
91
+ isStacked,
94
92
  // used by `Cell` to render its column title in `stacked` layout
95
93
  header: headers && headers[index]
96
94
  })
@@ -23,8 +23,11 @@
23
23
  */
24
24
 
25
25
  import React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
26
28
  import type {
27
29
  OtherHTMLAttributes,
30
+ PropValidators,
28
31
  TableRowTheme
29
32
  } from '@instructure/shared-types'
30
33
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
@@ -40,11 +43,11 @@ type TableRowOwnProps = {
40
43
  * `{condition && <Table.Cell>bla<Table.Cell>}`
41
44
  */
42
45
  children?:
43
- | React.ReactElement<any>
46
+ | React.ReactElement
44
47
  | null
45
48
  | undefined
46
49
  | boolean
47
- | (React.ReactElement<any> | null | undefined | boolean)[]
50
+ | (React.ReactElement | null | undefined | boolean)[]
48
51
 
49
52
  /**
50
53
  * Controls the hover state of the row.
@@ -64,7 +67,12 @@ type TableRowProps = TableRowOwnProps &
64
67
 
65
68
  type TableRowStyle = ComponentStyle<'row'>
66
69
 
70
+ const propTypes: PropValidators<PropKeys> = {
71
+ children: PropTypes.node,
72
+ setHoverStateTo: PropTypes.bool
73
+ }
74
+
67
75
  const allowedProps: AllowedPropKeys = ['children', 'setHoverStateTo']
68
76
 
69
77
  export type { TableRowProps, TableRowStyle }
70
- export { allowedProps }
78
+ export { propTypes, allowedProps }
@@ -32,7 +32,7 @@ import { withStyle } from '@instructure/emotion'
32
32
  import generateStyle from './styles'
33
33
  import generateComponentTheme from './theme'
34
34
  import type { TableRowHeaderProps } from './props'
35
- import { allowedProps } from './props'
35
+ import { allowedProps, propTypes } from './props'
36
36
  import TableContext from '../TableContext'
37
37
 
38
38
  /**
@@ -47,6 +47,7 @@ class RowHeader extends Component<TableRowHeaderProps> {
47
47
  static contextType = TableContext
48
48
  declare context: ContextType<typeof TableContext>
49
49
  static allowedProps = allowedProps
50
+ static propTypes = propTypes
50
51
 
51
52
  static defaultProps = {
52
53
  textAlign: 'start',
@@ -22,8 +22,11 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
+ import PropTypes from 'prop-types'
26
+
25
27
  import type {
26
28
  OtherHTMLAttributes,
29
+ PropValidators,
27
30
  Renderable,
28
31
  TableRowHeaderTheme
29
32
  } from '@instructure/shared-types'
@@ -46,7 +49,13 @@ type TableRowHeaderProps = TableRowHeaderOwnProps &
46
49
  OtherHTMLAttributes<TableRowHeaderOwnProps>
47
50
 
48
51
  type TableRowHeaderStyle = ComponentStyle<'rowHeader'>
52
+
53
+ const propTypes: PropValidators<PropKeys> = {
54
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
55
+ textAlign: PropTypes.oneOf(['start', 'center', 'end'])
56
+ }
57
+
49
58
  const allowedProps: AllowedPropKeys = ['children', 'textAlign']
50
59
 
51
60
  export type { TableRowHeaderProps, TableRowHeaderStyle }
52
- export { allowedProps }
61
+ export { propTypes, allowedProps }
@@ -22,7 +22,7 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { Component, Children, isValidElement, ReactElement } from 'react'
25
+ import { Component, Children, isValidElement } from 'react'
26
26
 
27
27
  import { safeCloneElement, omitProps } from '@instructure/ui-react-utils'
28
28
  import { View } from '@instructure/ui-view'
@@ -42,7 +42,7 @@ import { Cell } from './Cell'
42
42
 
43
43
  import type { TableProps } from './props'
44
44
 
45
- import { allowedProps } from './props'
45
+ import { allowedProps, propTypes } from './props'
46
46
  import TableContext from './TableContext'
47
47
 
48
48
  /**
@@ -55,6 +55,7 @@ class Table extends Component<TableProps> {
55
55
  static readonly componentId = 'Table'
56
56
 
57
57
  static allowedProps = allowedProps
58
+ static propTypes = propTypes
58
59
 
59
60
  static defaultProps = {
60
61
  children: null,
@@ -92,17 +93,12 @@ class Table extends Component<TableProps> {
92
93
  getHeaders() {
93
94
  const [headChild] = Children.toArray(this.props.children)
94
95
  if (!headChild || !isValidElement(headChild)) return undefined
95
- const [firstRow] = Children.toArray(
96
- (headChild as ReactElement<any>).props.children
97
- )
96
+ const [firstRow] = Children.toArray(headChild.props.children)
98
97
  if (!firstRow || !isValidElement(firstRow)) return undefined
99
- return Children.map(
100
- (firstRow as ReactElement<any>).props.children,
101
- (colHeader) => {
102
- if (!isValidElement<{ children?: any }>(colHeader)) return undefined
103
- return colHeader.props.children
104
- }
105
- )
98
+ return Children.map(firstRow.props.children, (colHeader) => {
99
+ if (!isValidElement<{ children?: any }>(colHeader)) return undefined
100
+ return colHeader.props.children
101
+ })
106
102
  }
107
103
 
108
104
  render() {
@@ -137,9 +133,7 @@ class Table extends Component<TableProps> {
137
133
  )}
138
134
  {Children.map(children, (child) => {
139
135
  if (isValidElement(child)) {
140
- return safeCloneElement(child, {
141
- key: (child as ReactElement<any>).props.name
142
- })
136
+ return safeCloneElement(child, { key: child.props.name })
143
137
  }
144
138
  return child
145
139
  })}
@@ -22,12 +22,18 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  import React from 'react'
25
+ import PropTypes from 'prop-types'
26
+
25
27
  import type {
26
28
  Spacing,
27
29
  WithStyleProps,
28
30
  ComponentStyle
29
31
  } from '@instructure/emotion'
30
- import type { OtherHTMLAttributes, TableTheme } from '@instructure/shared-types'
32
+ import type {
33
+ OtherHTMLAttributes,
34
+ PropValidators,
35
+ TableTheme
36
+ } from '@instructure/shared-types'
31
37
 
32
38
  type RowChild = React.ReactElement<{ children: React.ReactElement }>
33
39
 
@@ -75,6 +81,16 @@ type TableProps = TableOwnProps &
75
81
  OtherHTMLAttributes<TableOwnProps>
76
82
 
77
83
  type TableStyle = ComponentStyle<'table'>
84
+
85
+ const propTypes: PropValidators<PropKeys> = {
86
+ caption: PropTypes.node.isRequired,
87
+ children: PropTypes.node,
88
+ margin: PropTypes.string,
89
+ elementRef: PropTypes.func,
90
+ hover: PropTypes.bool,
91
+ layout: PropTypes.oneOf(['auto', 'fixed', 'stacked'])
92
+ }
93
+
78
94
  const allowedProps: AllowedPropKeys = [
79
95
  'caption',
80
96
  'children',
@@ -90,4 +106,4 @@ export type {
90
106
  // children
91
107
  RowChild
92
108
  }
93
- export { allowedProps }
109
+ export { propTypes, allowedProps }
@@ -16,8 +16,10 @@
16
16
  { "path": "../shared-types/tsconfig.build.json" },
17
17
  { "path": "../ui-a11y-content/tsconfig.build.json" },
18
18
  { "path": "../ui-icons/tsconfig.build.json" },
19
+ { "path": "../ui-prop-types/tsconfig.build.json" },
19
20
  { "path": "../ui-react-utils/tsconfig.build.json" },
20
21
  { "path": "../ui-simple-select/tsconfig.build.json" },
22
+ { "path": "../ui-testable/tsconfig.build.json" },
21
23
  { "path": "../ui-utils/tsconfig.build.json" },
22
24
  { "path": "../ui-view/tsconfig.build.json" }
23
25
  ]