@instructure/ui-toggle-details 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 (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/ToggleDetails/index.js +38 -72
  3. package/es/ToggleDetails/props.js +76 -0
  4. package/es/ToggleGroup/index.js +3 -67
  5. package/es/ToggleGroup/props.js +90 -0
  6. package/lib/ToggleDetails/index.js +38 -73
  7. package/lib/ToggleDetails/props.js +88 -0
  8. package/lib/ToggleGroup/index.js +3 -70
  9. package/lib/ToggleGroup/props.js +102 -0
  10. package/package.json +22 -23
  11. package/src/ToggleDetails/index.tsx +16 -64
  12. package/src/ToggleDetails/props.ts +112 -0
  13. package/src/ToggleDetails/styles.ts +1 -1
  14. package/src/ToggleGroup/index.tsx +5 -58
  15. package/src/ToggleGroup/props.ts +124 -0
  16. package/src/index.ts +2 -2
  17. package/types/ToggleDetails/index.d.ts +27 -45
  18. package/types/ToggleDetails/index.d.ts.map +1 -1
  19. package/types/ToggleDetails/props.d.ts +27 -0
  20. package/types/ToggleDetails/props.d.ts.map +1 -0
  21. package/types/ToggleDetails/styles.d.ts +1 -1
  22. package/types/ToggleGroup/index.d.ts +32 -56
  23. package/types/ToggleGroup/index.d.ts.map +1 -1
  24. package/types/ToggleGroup/props.d.ts +25 -0
  25. package/types/ToggleGroup/props.d.ts.map +1 -0
  26. package/types/index.d.ts +2 -2
  27. package/LICENSE.md +0 -27
  28. package/es/ToggleDetails/types.js +0 -1
  29. package/es/ToggleGroup/types.js +0 -1
  30. package/lib/ToggleDetails/types.js +0 -1
  31. package/lib/ToggleGroup/types.js +0 -1
  32. package/src/ToggleDetails/types.ts +0 -42
  33. package/src/ToggleGroup/types.ts +0 -41
  34. package/types/ToggleDetails/types.d.ts +0 -19
  35. package/types/ToggleDetails/types.d.ts.map +0 -1
  36. package/types/ToggleGroup/types.d.ts +0 -17
  37. package/types/ToggleGroup/types.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-toggle-details",
3
- "version": "8.8.1-snapshot.8+7b83164f4",
3
+ "version": "8.9.0",
4
4
  "description": "A styled toggleable, accordion-like component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -24,29 +24,29 @@
24
24
  },
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@instructure/ui-babel-preset": "8.8.1-snapshot.8+7b83164f4",
28
- "@instructure/ui-test-locator": "8.8.1-snapshot.8+7b83164f4",
29
- "@instructure/ui-test-queries": "8.8.1-snapshot.8+7b83164f4",
30
- "@instructure/ui-test-utils": "8.8.1-snapshot.8+7b83164f4",
31
- "@instructure/ui-themes": "8.8.1-snapshot.8+7b83164f4"
27
+ "@instructure/ui-babel-preset": "8.9.0",
28
+ "@instructure/ui-test-locator": "8.9.0",
29
+ "@instructure/ui-test-queries": "8.9.0",
30
+ "@instructure/ui-test-utils": "8.9.0",
31
+ "@instructure/ui-themes": "8.9.0"
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.13.10",
35
- "@instructure/emotion": "8.8.1-snapshot.8+7b83164f4",
36
- "@instructure/shared-types": "8.8.1-snapshot.8+7b83164f4",
37
- "@instructure/ui-buttons": "8.8.1-snapshot.8+7b83164f4",
38
- "@instructure/ui-dom-utils": "8.8.1-snapshot.8+7b83164f4",
39
- "@instructure/ui-expandable": "8.8.1-snapshot.8+7b83164f4",
40
- "@instructure/ui-flex": "8.8.1-snapshot.8+7b83164f4",
41
- "@instructure/ui-icons": "8.8.1-snapshot.8+7b83164f4",
42
- "@instructure/ui-menu": "8.8.1-snapshot.8+7b83164f4",
43
- "@instructure/ui-motion": "8.8.1-snapshot.8+7b83164f4",
44
- "@instructure/ui-prop-types": "8.8.1-snapshot.8+7b83164f4",
45
- "@instructure/ui-react-utils": "8.8.1-snapshot.8+7b83164f4",
46
- "@instructure/ui-testable": "8.8.1-snapshot.8+7b83164f4",
47
- "@instructure/ui-utils": "8.8.1-snapshot.8+7b83164f4",
48
- "@instructure/ui-view": "8.8.1-snapshot.8+7b83164f4",
49
- "@instructure/uid": "8.8.1-snapshot.8+7b83164f4",
35
+ "@instructure/emotion": "8.9.0",
36
+ "@instructure/shared-types": "8.9.0",
37
+ "@instructure/ui-buttons": "8.9.0",
38
+ "@instructure/ui-dom-utils": "8.9.0",
39
+ "@instructure/ui-expandable": "8.9.0",
40
+ "@instructure/ui-flex": "8.9.0",
41
+ "@instructure/ui-icons": "8.9.0",
42
+ "@instructure/ui-menu": "8.9.0",
43
+ "@instructure/ui-motion": "8.9.0",
44
+ "@instructure/ui-prop-types": "8.9.0",
45
+ "@instructure/ui-react-utils": "8.9.0",
46
+ "@instructure/ui-testable": "8.9.0",
47
+ "@instructure/ui-utils": "8.9.0",
48
+ "@instructure/ui-view": "8.9.0",
49
+ "@instructure/uid": "8.9.0",
50
50
  "prop-types": "^15"
51
51
  },
52
52
  "peerDependencies": {
@@ -55,6 +55,5 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "sideEffects": false,
59
- "gitHead": "7b83164f4c5872f3a217e010563f59bf584ae4fc"
58
+ "sideEffects": false
60
59
  }
@@ -23,7 +23,6 @@
23
23
  */
24
24
  /** @jsx jsx */
25
25
  import { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
28
27
  import { Button } from '@instructure/ui-buttons'
29
28
  import {
@@ -31,7 +30,6 @@ import {
31
30
  IconArrowOpenDownSolid
32
31
  } from '@instructure/ui-icons'
33
32
  import { Expandable } from '@instructure/ui-expandable'
34
- import { controllable } from '@instructure/ui-prop-types'
35
33
  import { omitProps, pickProps } from '@instructure/ui-react-utils'
36
34
  import { isActiveElement } from '@instructure/ui-dom-utils'
37
35
  import { testable } from '@instructure/ui-testable'
@@ -40,7 +38,8 @@ import { withStyle, jsx } from '@instructure/emotion'
40
38
 
41
39
  import generateStyle from './styles'
42
40
  import generateComponentTheme from './theme'
43
- import { ToggleDetailsProps, ToggleDetailsStyleProps } from './types'
41
+ import type { ToggleDetailsProps, ToggleDetailsStyleProps } from './props'
42
+ import { allowedProps, propTypes } from './props'
44
43
 
45
44
  /**
46
45
  ---
@@ -51,51 +50,8 @@ category: components
51
50
  @testable()
52
51
  class ToggleDetails extends Component<ToggleDetailsProps> {
53
52
  static readonly componentId = 'ToggleDetails'
54
-
55
- static propTypes = {
56
- // eslint-disable-next-line react/require-default-props
57
- makeStyles: PropTypes.func,
58
- // eslint-disable-next-line react/require-default-props
59
- styles: PropTypes.object,
60
- variant: PropTypes.oneOf(['default', 'filled']),
61
- /**
62
- * The summary that displays and can be interacted with
63
- */
64
- summary: PropTypes.node.isRequired,
65
- /**
66
- * Whether the content is expanded or hidden
67
- */
68
- expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
69
- /**
70
- * Whether the content is initially expanded or hidden (uncontrolled)
71
- */
72
- defaultExpanded: PropTypes.bool,
73
- onToggle: PropTypes.func,
74
- /**
75
- * The icon to display next to the summary text when content is hidden
76
- */
77
- icon: PropTypes.func,
78
- /**
79
- * The icon to display when content is expanded
80
- */
81
- iconExpanded: PropTypes.func,
82
- /**
83
- * Icon position at the start or end of the summary text
84
- */
85
- iconPosition: PropTypes.oneOf(['start', 'end']),
86
- /**
87
- * should the summary fill the width of its container
88
- */
89
- fluidWidth: PropTypes.bool,
90
- /**
91
- * The toggleable content passed inside the ToggleDetails component
92
- */
93
- children: PropTypes.node,
94
- /**
95
- * Choose a size for the expand/collapse icon
96
- */
97
- size: PropTypes.oneOf(['small', 'medium', 'large'])
98
- }
53
+ static allowedProps = allowedProps
54
+ static propTypes = propTypes
99
55
 
100
56
  static defaultProps = {
101
57
  variant: 'default',
@@ -107,8 +63,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
107
63
  defaultExpanded: false,
108
64
  // @ts-expect-error ts-migrate(6133) FIXME: 'event' is declared but its value is never read.
109
65
  onToggle: function (event, expanded) {},
110
- children: null,
111
- expanded: undefined
66
+ children: null
112
67
  }
113
68
 
114
69
  get focused() {
@@ -122,13 +77,11 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
122
77
  }
123
78
 
124
79
  componentDidMount() {
125
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
126
- this.props.makeStyles({ animate: false } as ToggleDetailsStyleProps)
80
+ this.props.makeStyles?.({ animate: false } as ToggleDetailsStyleProps)
127
81
  }
128
82
 
129
83
  componentDidUpdate() {
130
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
131
- this.props.makeStyles({ animate: true } as ToggleDetailsStyleProps)
84
+ this.props.makeStyles?.({ animate: true } as ToggleDetailsStyleProps)
132
85
  }
133
86
 
134
87
  // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'el' implicitly has an 'any' type.
@@ -139,9 +92,9 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
139
92
  const { summary, iconPosition } = this.props
140
93
 
141
94
  return (
142
- <span css={this.props.styles.summary}>
95
+ <span css={this.props.styles?.summary}>
143
96
  {iconPosition === 'start' && this.renderIcon(expanded)}
144
- <span css={this.props.styles.summaryText}>{summary}</span>
97
+ <span css={this.props.styles?.summaryText}>{summary}</span>
145
98
  {iconPosition === 'end' && this.renderIcon(expanded)}
146
99
  </span>
147
100
  )
@@ -173,7 +126,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
173
126
  )
174
127
  } else if (props.href) {
175
128
  return (
176
- <a {...props} css={this.props.styles.toggle} ref={this.getButtonRef}>
129
+ <a {...props} css={this.props.styles?.toggle} ref={this.getButtonRef}>
177
130
  {summary}
178
131
  </a>
179
132
  )
@@ -182,7 +135,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
182
135
  <button
183
136
  {...props}
184
137
  type="button"
185
- css={this.props.styles.toggle}
138
+ css={this.props.styles?.toggle}
186
139
  ref={this.getButtonRef}
187
140
  >
188
141
  {summary}
@@ -196,7 +149,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
196
149
  const Icon = expanded ? this.props.iconExpanded : this.props.icon
197
150
 
198
151
  return this.props.children ? (
199
- <span css={this.props.styles.icon}>
152
+ <span css={this.props.styles?.icon}>
200
153
  {/* @ts-expect-error ts-migrate(2604) FIXME: JSX element type 'Icon' does not have any construc... Remove this comment to see the full error message */}
201
154
  <Icon />
202
155
  </span>
@@ -208,22 +161,21 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
208
161
  const { children } = this.props
209
162
  const expandedStyles = expanded ? { display: 'block' } : { display: 'none' }
210
163
  return (
211
- <div {...detailsProps} css={[this.props.styles.details, expandedStyles]}>
164
+ <div {...detailsProps} css={[this.props.styles?.details, expandedStyles]}>
212
165
  {children && expanded && this.renderContent()}
213
166
  </div>
214
167
  )
215
168
  }
216
169
 
217
170
  renderContent() {
218
- return <div css={this.props.styles.content}>{this.props.children}</div>
171
+ return <div css={this.props.styles?.content}>{this.props.children}</div>
219
172
  }
220
173
 
221
174
  // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type.
222
175
  handleToggle = (event, expanded) => {
223
176
  // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
224
177
  this.props.onToggle(event, expanded)
225
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
226
- this.props.makeStyles({ animate: true })
178
+ this.props.makeStyles?.({ animate: true })
227
179
  }
228
180
 
229
181
  render() {
@@ -234,7 +186,7 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
234
186
  >
235
187
  {({ expanded, getToggleProps, getDetailsProps }) => {
236
188
  return (
237
- <div css={this.props.styles.toggleDetails}>
189
+ <div css={this.props.styles?.toggleDetails}>
238
190
  {this.renderToggle(getToggleProps(), expanded)}
239
191
  {this.renderDetails(expanded, getDetailsProps())}
240
192
  </div>
@@ -0,0 +1,112 @@
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 React from 'react'
25
+ import PropTypes from 'prop-types'
26
+
27
+ import { controllable } from '@instructure/ui-prop-types'
28
+
29
+ import type { PropValidators } from '@instructure/shared-types'
30
+ import type { WithStyleProps } from '@instructure/emotion'
31
+
32
+ type ToggleDetailsOwnProps = {
33
+ variant?: 'default' | 'filled'
34
+ summary: React.ReactNode
35
+ expanded?: any // TODO: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded')
36
+ defaultExpanded?: boolean
37
+ onToggle?: (...args: any[]) => any
38
+ icon?: (...args: any[]) => any
39
+ iconExpanded?: (...args: any[]) => any
40
+ iconPosition?: 'start' | 'end'
41
+ fluidWidth?: boolean
42
+ size?: 'small' | 'medium' | 'large'
43
+ children?: React.ReactNode
44
+ }
45
+
46
+ type PropKeys = keyof ToggleDetailsOwnProps
47
+
48
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
49
+
50
+ type ToggleDetailsProps = ToggleDetailsOwnProps & WithStyleProps
51
+
52
+ const propTypes: PropValidators<PropKeys> = {
53
+ variant: PropTypes.oneOf(['default', 'filled']),
54
+ /**
55
+ * The summary that displays and can be interacted with
56
+ */
57
+ summary: PropTypes.node.isRequired,
58
+ /**
59
+ * Whether the content is expanded or hidden
60
+ */
61
+ expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
62
+ /**
63
+ * Whether the content is initially expanded or hidden (uncontrolled)
64
+ */
65
+ defaultExpanded: PropTypes.bool,
66
+ onToggle: PropTypes.func,
67
+ /**
68
+ * The icon to display next to the summary text when content is hidden
69
+ */
70
+ icon: PropTypes.func,
71
+ /**
72
+ * The icon to display when content is expanded
73
+ */
74
+ iconExpanded: PropTypes.func,
75
+ /**
76
+ * Icon position at the start or end of the summary text
77
+ */
78
+ iconPosition: PropTypes.oneOf(['start', 'end']),
79
+ /**
80
+ * should the summary fill the width of its container
81
+ */
82
+ fluidWidth: PropTypes.bool,
83
+ /**
84
+ * The toggleable content passed inside the ToggleDetails component
85
+ */
86
+ children: PropTypes.node,
87
+ /**
88
+ * Choose a size for the expand/collapse icon
89
+ */
90
+ size: PropTypes.oneOf(['small', 'medium', 'large'])
91
+ }
92
+
93
+ const allowedProps: AllowedPropKeys = [
94
+ 'variant',
95
+ 'summary',
96
+ 'expanded',
97
+ 'defaultExpanded',
98
+ 'onToggle',
99
+ 'icon',
100
+ 'iconExpanded',
101
+ 'iconPosition',
102
+ 'fluidWidth',
103
+ 'children',
104
+ 'size'
105
+ ]
106
+
107
+ export type { ToggleDetailsProps }
108
+ export { propTypes, allowedProps }
109
+
110
+ export type ToggleDetailsStyleProps = {
111
+ animate: boolean
112
+ }
@@ -24,7 +24,7 @@
24
24
 
25
25
  import { keyframes } from '@instructure/emotion'
26
26
  import { ToggleDetailsTheme } from '@instructure/shared-types'
27
- import { ToggleDetailsProps, ToggleDetailsStyleProps } from './types'
27
+ import { ToggleDetailsProps, ToggleDetailsStyleProps } from './props'
28
28
  const contentAnimation = keyframes`
29
29
  to {
30
30
  opacity: 1;
@@ -23,7 +23,6 @@
23
23
  */
24
24
 
25
25
  import React, { Component } from 'react'
26
- import PropTypes from 'prop-types'
27
26
 
28
27
  import {
29
28
  omitProps,
@@ -33,7 +32,6 @@ import {
33
32
  import { IconButton } from '@instructure/ui-buttons'
34
33
  import { Transition } from '@instructure/ui-motion'
35
34
  import { Expandable } from '@instructure/ui-expandable'
36
- import { controllable } from '@instructure/ui-prop-types'
37
35
  import { isActiveElement } from '@instructure/ui-dom-utils'
38
36
  import { Flex } from '@instructure/ui-flex'
39
37
  import { View } from '@instructure/ui-view'
@@ -42,7 +40,8 @@ import {
42
40
  IconArrowOpenDownSolid
43
41
  } from '@instructure/ui-icons'
44
42
  import { testable } from '@instructure/ui-testable'
45
- import { ToggleGroupProps } from './types'
43
+ import type { ToggleGroupProps } from './props'
44
+ import { allowedProps, propTypes } from './props'
46
45
 
47
46
  /**
48
47
  ---
@@ -53,62 +52,10 @@ category: components
53
52
  class ToggleGroup extends Component<ToggleGroupProps> {
54
53
  static readonly componentId = 'ToggleGroup'
55
54
 
56
- static propTypes = {
57
- /**
58
- * the content to show and hide
59
- */
60
- children: PropTypes.node.isRequired,
61
- /**
62
- * the content area next to the toggle button
63
- */
64
- summary: PropTypes.node.isRequired,
65
- /**
66
- * provides a screenreader label for the toggle button
67
- * (takes `expanded` as an argument if a function)
68
- */
69
- toggleLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
70
- .isRequired,
71
- /**
72
- * the element type to render as
73
- */
74
- as: PropTypes.elementType,
75
- /**
76
- * provides a reference to the underlying html root element
77
- */
78
- elementRef: PropTypes.func,
79
- size: PropTypes.oneOf(['small', 'medium', 'large']),
80
- /**
81
- * Whether the content is expanded or hidden
82
- */
83
- expanded: controllable(PropTypes.bool, 'onToggle', 'defaultExpanded'),
84
- /**
85
- * Whether the content is initially expanded or hidden (uncontrolled)
86
- */
87
- defaultExpanded: PropTypes.bool,
88
- /**
89
- * Fired when the content display is toggled
90
- */
91
- onToggle: PropTypes.func,
92
- /**
93
- * The icon displayed in the toggle button when the content is hidden
94
- */
95
- icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
96
- /**
97
- * The icon displayed in the toggle button when the content is showing
98
- */
99
- iconExpanded: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
100
- /**
101
- * Transition content into view
102
- */
103
- transition: PropTypes.bool,
104
- /**
105
- * Toggle the border around the component
106
- */
107
- border: PropTypes.bool
108
- } as const
55
+ static allowedProps = allowedProps
56
+ static propTypes = propTypes
109
57
 
110
58
  static defaultProps = {
111
- expanded: undefined,
112
59
  size: 'medium',
113
60
  icon: IconArrowOpenEndSolid,
114
61
  iconExpanded: IconArrowOpenDownSolid,
@@ -160,7 +107,7 @@ class ToggleGroup extends Component<ToggleGroupProps> {
160
107
  withBackground={false}
161
108
  withBorder={false}
162
109
  size={size === 'large' ? 'medium' : 'small'}
163
- elementRef={(el) => {
110
+ elementRef={(el: any) => {
164
111
  this._button = el
165
112
  }}
166
113
  screenReaderLabel={label}