@instructure/ui-table 8.8.1-snapshot.8 → 8.9.0

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 (113) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/Table/Body/index.js +16 -28
  3. package/{src/Table/Cell/types.ts → es/Table/Body/props.js} +14 -8
  4. package/es/Table/Cell/index.js +16 -28
  5. package/{src/Table/types.ts → es/Table/Cell/props.js} +12 -11
  6. package/es/Table/ColHeader/index.js +22 -63
  7. package/es/Table/ColHeader/props.js +66 -0
  8. package/es/Table/Head/index.js +18 -29
  9. package/{src/Table/Body/types.ts → es/Table/Head/props.js} +13 -8
  10. package/es/Table/Row/index.js +16 -28
  11. package/{src/Table/ColHeader/types.ts → es/Table/Row/props.js} +16 -12
  12. package/es/Table/RowHeader/index.js +15 -26
  13. package/{src/Table/Head/types.ts → es/Table/RowHeader/props.js} +11 -6
  14. package/es/Table/index.js +21 -60
  15. package/es/Table/props.js +66 -0
  16. package/lib/Table/Body/index.js +16 -29
  17. package/lib/Table/Body/props.js +50 -0
  18. package/lib/Table/Cell/index.js +16 -28
  19. package/lib/Table/Cell/props.js +47 -0
  20. package/lib/Table/ColHeader/index.js +22 -63
  21. package/lib/Table/ColHeader/props.js +77 -0
  22. package/lib/Table/Head/index.js +18 -30
  23. package/lib/Table/Head/props.js +49 -0
  24. package/lib/Table/Row/index.js +16 -29
  25. package/lib/Table/Row/props.js +54 -0
  26. package/lib/Table/RowHeader/index.js +15 -26
  27. package/lib/Table/RowHeader/props.js +46 -0
  28. package/lib/Table/index.js +20 -60
  29. package/lib/Table/props.js +81 -0
  30. package/package.json +17 -18
  31. package/src/Table/Body/index.tsx +7 -25
  32. package/src/Table/{Row/types.ts → Body/props.ts} +39 -3
  33. package/src/Table/Cell/index.tsx +8 -24
  34. package/src/Table/Cell/props.ts +62 -0
  35. package/src/Table/Cell/styles.ts +1 -1
  36. package/src/Table/ColHeader/index.tsx +9 -51
  37. package/src/Table/ColHeader/props.ts +94 -0
  38. package/src/Table/ColHeader/styles.ts +1 -1
  39. package/src/Table/Head/index.tsx +8 -24
  40. package/src/Table/Head/props.ts +62 -0
  41. package/src/Table/Row/index.tsx +8 -27
  42. package/src/Table/Row/props.ts +70 -0
  43. package/src/Table/Row/styles.ts +1 -1
  44. package/src/Table/RowHeader/index.tsx +8 -23
  45. package/src/Table/RowHeader/{types.ts → props.ts} +28 -3
  46. package/src/Table/RowHeader/styles.ts +1 -1
  47. package/src/Table/index.tsx +10 -49
  48. package/src/Table/props.ts +93 -0
  49. package/src/Table/styles.ts +1 -1
  50. package/src/index.ts +7 -7
  51. package/types/Table/Body/index.d.ts +13 -16
  52. package/types/Table/Body/index.d.ts.map +1 -1
  53. package/types/Table/Body/props.d.ts +17 -0
  54. package/types/Table/Body/props.d.ts.map +1 -0
  55. package/types/Table/Cell/index.d.ts +14 -14
  56. package/types/Table/Cell/index.d.ts.map +1 -1
  57. package/types/Table/Cell/props.d.ts +17 -0
  58. package/types/Table/Cell/props.d.ts.map +1 -0
  59. package/types/Table/Cell/styles.d.ts +1 -1
  60. package/types/Table/ColHeader/index.d.ts +22 -40
  61. package/types/Table/ColHeader/index.d.ts.map +1 -1
  62. package/types/Table/ColHeader/props.d.ts +21 -0
  63. package/types/Table/ColHeader/props.d.ts.map +1 -0
  64. package/types/Table/ColHeader/styles.d.ts +1 -1
  65. package/types/Table/Head/index.d.ts +11 -15
  66. package/types/Table/Head/index.d.ts.map +1 -1
  67. package/types/Table/Head/props.d.ts +16 -0
  68. package/types/Table/Head/props.d.ts.map +1 -0
  69. package/types/Table/Row/index.d.ts +14 -17
  70. package/types/Table/Row/index.d.ts.map +1 -1
  71. package/types/Table/Row/props.d.ts +17 -0
  72. package/types/Table/Row/props.d.ts.map +1 -0
  73. package/types/Table/Row/styles.d.ts +1 -1
  74. package/types/Table/RowHeader/index.d.ts +12 -13
  75. package/types/Table/RowHeader/index.d.ts.map +1 -1
  76. package/types/Table/RowHeader/props.d.ts +16 -0
  77. package/types/Table/RowHeader/props.d.ts.map +1 -0
  78. package/types/Table/RowHeader/styles.d.ts +1 -1
  79. package/types/Table/index.d.ts +18 -41
  80. package/types/Table/index.d.ts.map +1 -1
  81. package/types/Table/props.d.ts +19 -0
  82. package/types/Table/props.d.ts.map +1 -0
  83. package/types/Table/styles.d.ts +1 -1
  84. package/types/index.d.ts +7 -7
  85. package/LICENSE.md +0 -27
  86. package/es/Table/Body/types.js +0 -1
  87. package/es/Table/Cell/types.js +0 -1
  88. package/es/Table/ColHeader/types.js +0 -1
  89. package/es/Table/Head/types.js +0 -1
  90. package/es/Table/Row/types.js +0 -1
  91. package/es/Table/RowHeader/types.js +0 -1
  92. package/es/Table/types.js +0 -1
  93. package/lib/Table/Body/types.js +0 -1
  94. package/lib/Table/Cell/types.js +0 -1
  95. package/lib/Table/ColHeader/types.js +0 -1
  96. package/lib/Table/Head/types.js +0 -1
  97. package/lib/Table/Row/types.js +0 -1
  98. package/lib/Table/RowHeader/types.js +0 -1
  99. package/lib/Table/types.js +0 -1
  100. package/types/Table/Body/types.d.ts +0 -9
  101. package/types/Table/Body/types.d.ts.map +0 -1
  102. package/types/Table/Cell/types.d.ts +0 -9
  103. package/types/Table/Cell/types.d.ts.map +0 -1
  104. package/types/Table/ColHeader/types.d.ts +0 -12
  105. package/types/Table/ColHeader/types.d.ts.map +0 -1
  106. package/types/Table/Head/types.d.ts +0 -8
  107. package/types/Table/Head/types.d.ts.map +0 -1
  108. package/types/Table/Row/types.d.ts +0 -9
  109. package/types/Table/Row/types.d.ts.map +0 -1
  110. package/types/Table/RowHeader/types.d.ts +0 -7
  111. package/types/Table/RowHeader/types.d.ts.map +0 -1
  112. package/types/Table/types.d.ts +0 -12
  113. package/types/Table/types.d.ts.map +0 -1
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { TableColHeaderTheme } from '@instructure/shared-types'
26
- import { TableColHeaderProps } from './types'
26
+ import { TableColHeaderProps } from './props'
27
27
 
28
28
  /**
29
29
  * ---
@@ -24,14 +24,12 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component, Children } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import {
30
29
  omitProps,
31
30
  matchComponentTypes,
32
31
  callRenderProp
33
32
  } from '@instructure/ui-react-utils'
34
- import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
35
33
  import { SimpleSelect } from '@instructure/ui-simple-select'
36
34
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
37
35
  import { IconCheckLine } from '@instructure/ui-icons'
@@ -44,7 +42,8 @@ import generateComponentTheme from './theme'
44
42
 
45
43
  import { Row } from '../Row'
46
44
  import { ColHeader } from '../ColHeader'
47
- import { TableHeadProps } from './types'
45
+ import type { TableHeadProps } from './props'
46
+ import { allowedProps, propTypes } from './props'
48
47
 
49
48
  /**
50
49
  ---
@@ -56,20 +55,8 @@ id: Table.Head
56
55
  class Head extends Component<TableHeadProps> {
57
56
  static readonly componentId = 'Table.Head'
58
57
 
59
- /* eslint-disable react/require-default-props */
60
- static propTypes = {
61
- /**
62
- * `Table.Row`
63
- */
64
- // eslint-disable-next-line react/require-default-props
65
- makeStyles: PropTypes.func,
66
- // eslint-disable-next-line react/require-default-props
67
- styles: PropTypes.object,
68
- children: ChildrenPropTypes.oneOf([Row]),
69
- isStacked: PropTypes.bool,
70
- renderSortLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
71
- }
72
- /* eslint-enable react/require-default-props */
58
+ static allowedProps = allowedProps
59
+ static propTypes = propTypes
73
60
 
74
61
  static defaultProps = {
75
62
  children: null
@@ -92,8 +79,7 @@ class Head extends Component<TableHeadProps> {
92
79
  }
93
80
 
94
81
  componentDidMount() {
95
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
96
- this.props.makeStyles()
82
+ this.props.makeStyles?.()
97
83
  }
98
84
 
99
85
  componentDidUpdate() {
@@ -103,8 +89,7 @@ class Head extends Component<TableHeadProps> {
103
89
  '[Table.Head] The `renderSortLabel` prop should be provided when Table is sortable.'
104
90
  )
105
91
  }
106
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
107
- this.props.makeStyles()
92
+ this.props.makeStyles?.()
108
93
  }
109
94
 
110
95
  renderSelect() {
@@ -118,7 +103,7 @@ class Head extends Component<TableHeadProps> {
118
103
  const options = []
119
104
  const clickHandlers = {}
120
105
  // @ts-expect-error ts-migrate(7034) FIXME: Variable 'selectedOption' implicitly has type 'any... Remove this comment to see the full error message
121
- let selectedOption = null
106
+ let selectedOption = undefined
122
107
  let count = 0
123
108
 
124
109
  // @ts-expect-error ts-migrate(2339) FIXME: Property 'props' does not exist on type 'string | ... Remove this comment to see the full error message
@@ -165,7 +150,6 @@ class Head extends Component<TableHeadProps> {
165
150
  )
166
151
  }
167
152
  renderBeforeInput={selectedOption && IconCheckLine}
168
- // @ts-expect-error FIXME: Type 'null' is not assignable to type 'string | number | undefined'.ts(2322)
169
153
  value={selectedOption}
170
154
  onChange={handleSelect}
171
155
  >
@@ -198,7 +182,7 @@ class Head extends Component<TableHeadProps> {
198
182
  return isStacked ? (
199
183
  this.renderSelect()
200
184
  ) : (
201
- <thead {...omitProps(this.props, Head.propTypes)} css={styles.head}>
185
+ <thead {...omitProps(this.props, Head.propTypes)} css={styles?.head}>
202
186
  {Children.map(children, (child) =>
203
187
  matchComponentTypes(child, [Row]) ? child : null
204
188
  )}
@@ -0,0 +1,62 @@
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 React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
29
+
30
+ import { Row } from '../Row'
31
+
32
+ import type { PropValidators } from '@instructure/shared-types'
33
+ import type { WithStyleProps } from '@instructure/emotion'
34
+
35
+ type TableHeadOwnProps = {
36
+ isStacked?: boolean
37
+ renderSortLabel?: React.ReactNode | ((...args: any[]) => any)
38
+ children?: React.ReactNode
39
+ }
40
+ type PropKeys = keyof TableHeadOwnProps
41
+
42
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
43
+
44
+ type TableHeadProps = TableHeadOwnProps & WithStyleProps
45
+
46
+ const propTypes: PropValidators<PropKeys> = {
47
+ /**
48
+ * `Table.Row`
49
+ */
50
+ children: ChildrenPropTypes.oneOf([Row]),
51
+ isStacked: PropTypes.bool,
52
+ renderSortLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
53
+ }
54
+
55
+ const allowedProps: AllowedPropKeys = [
56
+ 'children',
57
+ 'isStacked',
58
+ 'renderSortLabel'
59
+ ]
60
+
61
+ export type { TableHeadProps }
62
+ export { propTypes, allowedProps }
@@ -24,14 +24,12 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component, Children, ReactElement } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import {
30
29
  omitProps,
31
30
  matchComponentTypes,
32
31
  safeCloneElement
33
32
  } from '@instructure/ui-react-utils'
34
- import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
35
33
  import { View } from '@instructure/ui-view'
36
34
 
37
35
  import { withStyle, jsx } from '@instructure/emotion'
@@ -42,7 +40,8 @@ import generateComponentTheme from './theme'
42
40
  import { ColHeader } from '../ColHeader'
43
41
  import { RowHeader } from '../RowHeader'
44
42
  import { Cell } from '../Cell'
45
- import { TableRowProps } from './types'
43
+ import type { TableRowProps } from './props'
44
+ import { allowedProps, propTypes } from './props'
46
45
 
47
46
  /**
48
47
  ---
@@ -54,37 +53,19 @@ id: Table.Row
54
53
  class Row extends Component<TableRowProps> {
55
54
  static readonly componentId = 'Table.Row'
56
55
 
57
- /* eslint-disable react/require-default-props */
58
- static propTypes = {
59
- /**
60
- * `Table.ColHeader`, `Table.RowHeader` or `Table.Cell`
61
- */
62
- // eslint-disable-next-line react/require-default-props
63
- makeStyles: PropTypes.func,
64
- // eslint-disable-next-line react/require-default-props
65
- styles: PropTypes.object,
66
- children: ChildrenPropTypes.oneOf([ColHeader, RowHeader, Cell]),
67
- hover: PropTypes.bool,
68
- isStacked: PropTypes.bool,
69
- headers: PropTypes.arrayOf(
70
- PropTypes.oneOfType([PropTypes.node, PropTypes.func])
71
- )
72
- }
73
- /* eslint-enable react/require-default-props */
56
+ static allowedProps = allowedProps
57
+ static propTypes = propTypes
74
58
 
75
59
  static defaultProps = {
76
60
  children: null
77
61
  }
78
62
 
79
63
  componentDidMount() {
80
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
81
- this.props.makeStyles()
64
+ this.props.makeStyles?.()
82
65
  }
83
66
 
84
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
85
- componentDidUpdate(prevProps, prevState, snapshot) {
86
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
87
- this.props.makeStyles()
67
+ componentDidUpdate() {
68
+ this.props.makeStyles?.()
88
69
  }
89
70
 
90
71
  render() {
@@ -94,7 +75,7 @@ class Row extends Component<TableRowProps> {
94
75
  <View
95
76
  {...View.omitViewProps(omitProps(this.props, Row.propTypes), Row)}
96
77
  as={isStacked ? 'div' : 'tr'}
97
- css={styles.row}
78
+ css={styles?.row}
98
79
  role={isStacked ? 'row' : undefined}
99
80
  >
100
81
  {Children.toArray(children)
@@ -0,0 +1,70 @@
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 React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
29
+
30
+ import { ColHeader } from '../ColHeader'
31
+ import { RowHeader } from '../RowHeader'
32
+ import { Cell } from '../Cell'
33
+
34
+ import type { PropValidators } from '@instructure/shared-types'
35
+ import type { WithStyleProps } from '@instructure/emotion'
36
+
37
+ type TableRowOwnProps = {
38
+ hover?: boolean
39
+ isStacked?: boolean
40
+ headers?: (React.ReactNode | ((...args: any[]) => any))[]
41
+ children?: React.ReactNode
42
+ }
43
+
44
+ type PropKeys = keyof TableRowOwnProps
45
+
46
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
47
+
48
+ type TableRowProps = TableRowOwnProps & WithStyleProps
49
+
50
+ const propTypes: PropValidators<PropKeys> = {
51
+ /**
52
+ * `Table.ColHeader`, `Table.RowHeader` or `Table.Cell`
53
+ */
54
+ children: ChildrenPropTypes.oneOf([ColHeader, RowHeader, Cell]),
55
+ hover: PropTypes.bool,
56
+ isStacked: PropTypes.bool,
57
+ headers: PropTypes.arrayOf(
58
+ PropTypes.oneOfType([PropTypes.node, PropTypes.func])
59
+ )
60
+ }
61
+
62
+ const allowedProps: AllowedPropKeys = [
63
+ 'children',
64
+ 'hover',
65
+ 'isStacked',
66
+ 'headers'
67
+ ]
68
+
69
+ export type { TableRowProps }
70
+ export { propTypes, allowedProps }
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { TableRowTheme } from '@instructure/shared-types'
26
- import { TableRowProps } from './types'
26
+ import { TableRowProps } from './props'
27
27
 
28
28
  /**
29
29
  * ---
@@ -24,7 +24,6 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import { omitProps, callRenderProp } from '@instructure/ui-react-utils'
30
29
  import { View } from '@instructure/ui-view'
@@ -33,7 +32,8 @@ import { withStyle, jsx } from '@instructure/emotion'
33
32
 
34
33
  import generateStyle from './styles'
35
34
  import generateComponentTheme from './theme'
36
- import { TableRowHeaderProps } from './types'
35
+ import type { TableRowHeaderProps } from './props'
36
+ import { allowedProps, propTypes } from './props'
37
37
 
38
38
  /**
39
39
  ---
@@ -45,20 +45,8 @@ id: Table.RowHeader
45
45
  class RowHeader extends Component<TableRowHeaderProps> {
46
46
  static readonly componentId = 'Table.RowHeader'
47
47
 
48
- /* eslint-disable react/require-default-props */
49
- static propTypes = {
50
- // eslint-disable-next-line react/require-default-props
51
- makeStyles: PropTypes.func,
52
- // eslint-disable-next-line react/require-default-props
53
- styles: PropTypes.object,
54
- children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
55
- isStacked: PropTypes.bool,
56
- /**
57
- * Control the text alignment in row header
58
- */
59
- textAlign: PropTypes.oneOf(['start', 'center', 'end'])
60
- }
61
- /* eslint-enable react/require-default-props */
48
+ static allowedProps = allowedProps
49
+ static propTypes = propTypes
62
50
 
63
51
  static defaultProps = {
64
52
  textAlign: 'start',
@@ -66,14 +54,11 @@ class RowHeader extends Component<TableRowHeaderProps> {
66
54
  }
67
55
 
68
56
  componentDidMount() {
69
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
70
- this.props.makeStyles()
57
+ this.props.makeStyles?.()
71
58
  }
72
59
 
73
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
74
- componentDidUpdate(prevProps, prevState, snapshot) {
75
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
76
- this.props.makeStyles()
60
+ componentDidUpdate() {
61
+ this.props.makeStyles?.()
77
62
  }
78
63
 
79
64
  render() {
@@ -86,7 +71,7 @@ class RowHeader extends Component<TableRowHeaderProps> {
86
71
  RowHeader
87
72
  )}
88
73
  as={isStacked ? 'div' : 'th'}
89
- css={styles.rowHeader}
74
+ css={styles?.rowHeader}
90
75
  scope="row"
91
76
  role={isStacked ? 'rowheader' : undefined}
92
77
  >
@@ -22,9 +22,34 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export type TableRowHeaderProps = {
26
- makeStyles?: (...args: any[]) => any
27
- styles?: any
25
+ import React from 'react'
26
+ import PropTypes from 'prop-types'
27
+
28
+ import type { PropValidators } from '@instructure/shared-types'
29
+ import type { WithStyleProps } from '@instructure/emotion'
30
+
31
+ type TableRowHeaderOwnProps = {
28
32
  isStacked?: boolean
29
33
  textAlign?: 'start' | 'center' | 'end'
34
+ children?: React.ReactNode | ((...args: any[]) => React.ReactNode)
30
35
  }
36
+
37
+ type PropKeys = keyof TableRowHeaderOwnProps
38
+
39
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
40
+
41
+ type TableRowHeaderProps = TableRowHeaderOwnProps & WithStyleProps
42
+
43
+ const propTypes: PropValidators<PropKeys> = {
44
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
45
+ isStacked: PropTypes.bool,
46
+ /**
47
+ * Control the text alignment in row header
48
+ */
49
+ textAlign: PropTypes.oneOf(['start', 'center', 'end'])
50
+ }
51
+
52
+ const allowedProps: AllowedPropKeys = ['children', 'isStacked', 'textAlign']
53
+
54
+ export type { TableRowHeaderProps }
55
+ export { propTypes, allowedProps }
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { TableRowHeaderTheme } from '@instructure/shared-types'
26
- import { TableRowHeaderProps } from './types'
26
+ import { TableRowHeaderProps } from './props'
27
27
 
28
28
  /**
29
29
  * ---
@@ -24,18 +24,16 @@
24
24
 
25
25
  /** @jsx jsx */
26
26
  import { Component, Children, ReactElement } from 'react'
27
- import PropTypes from 'prop-types'
28
27
 
29
28
  import {
30
29
  matchComponentTypes,
31
30
  safeCloneElement,
32
31
  omitProps
33
32
  } from '@instructure/ui-react-utils'
34
- import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
35
33
  import { View } from '@instructure/ui-view'
36
34
  import { ScreenReaderContent } from '@instructure/ui-a11y-content'
37
35
 
38
- import { withStyle, jsx, ThemeablePropTypes } from '@instructure/emotion'
36
+ import { withStyle, jsx } from '@instructure/emotion'
39
37
 
40
38
  import generateStyle from './styles'
41
39
  import generateComponentTheme from './theme'
@@ -46,7 +44,8 @@ import { Row } from './Row'
46
44
  import { ColHeader } from './ColHeader'
47
45
  import { RowHeader } from './RowHeader'
48
46
  import { Cell } from './Cell'
49
- import { TableProps } from './types'
47
+ import type { TableProps } from './props'
48
+ import { allowedProps, propTypes } from './props'
50
49
 
51
50
  /**
52
51
  ---
@@ -57,48 +56,13 @@ category: components
57
56
  class Table extends Component<TableProps> {
58
57
  static readonly componentId = 'Table'
59
58
 
60
- static propTypes = {
61
- // eslint-disable-next-line react/require-default-props
62
- makeStyles: PropTypes.func,
63
- // eslint-disable-next-line react/require-default-props
64
- styles: PropTypes.object,
65
- /**
66
- * Provide a screen reader friendly description. Anything passed to this
67
- * prop will be wrapped by `<ScreenReaderContent>` when it is rendered.
68
- */
69
- caption: PropTypes.node.isRequired,
70
- /**
71
- * Build table via `Table.Head` and `Table.Body`
72
- */
73
- children: ChildrenPropTypes.oneOf([Head, Body]),
74
- /**
75
- * Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
76
- * `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
77
- * familiar CSS-like shorthand. For example: `margin="small auto large"`.
78
- */
79
- margin: ThemeablePropTypes.spacing,
80
- /**
81
- * Provide a reference to the underlying html element
82
- */
83
- elementRef: PropTypes.func,
84
- /**
85
- * Highlight each row on hover
86
- */
87
- hover: PropTypes.bool,
88
- /**
89
- * `auto` lets the browser determine table column widths based on cell content,
90
- * while `fixed` forces columns of equal width. `stacked` renders table in one
91
- * column to be more readable on narrow screens
92
- */
93
- layout: PropTypes.oneOf(['auto', 'fixed', 'stacked'])
94
- }
59
+ static allowedProps = allowedProps
60
+ static propTypes = propTypes
95
61
 
96
62
  static defaultProps = {
97
63
  children: null,
98
64
  hover: false,
99
- layout: 'auto',
100
- margin: undefined,
101
- elementRef: undefined
65
+ layout: 'auto'
102
66
  }
103
67
 
104
68
  static Head = Head
@@ -109,14 +73,11 @@ class Table extends Component<TableProps> {
109
73
  static Cell = Cell
110
74
 
111
75
  componentDidMount() {
112
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
113
- this.props.makeStyles()
76
+ this.props.makeStyles?.()
114
77
  }
115
78
 
116
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
117
- componentDidUpdate(prevProps, prevState, snapshot) {
118
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
119
- this.props.makeStyles()
79
+ componentDidUpdate() {
80
+ this.props.makeStyles?.()
120
81
  }
121
82
 
122
83
  getHeaders() {
@@ -158,7 +119,7 @@ class Table extends Component<TableProps> {
158
119
  as={isStacked ? 'div' : 'table'}
159
120
  margin={margin}
160
121
  elementRef={elementRef}
161
- css={styles.table}
122
+ css={styles?.table}
162
123
  role={isStacked ? 'table' : undefined}
163
124
  aria-label={isStacked ? (caption as string) : undefined}
164
125
  >