@instructure/ui-toggle-details 9.6.1-snapshot-2 → 9.7.2

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.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [9.6.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v9.6.0...v9.6.1-snapshot-2) (2024-09-06)
6
+ ## [9.7.2](https://github.com/instructure/instructure-ui/compare/v9.7.0...v9.7.2) (2024-10-10)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-toggle-details
9
9
 
@@ -11,6 +11,25 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
+ ## [9.7.1](https://github.com/instructure/instructure-ui/compare/v9.7.0...v9.7.1) (2024-10-10)
15
+
16
+ **Note:** Version bump only for package @instructure/ui-toggle-details
17
+
18
+
19
+
20
+
21
+
22
+ # [9.7.0](https://github.com/instructure/instructure-ui/compare/v9.6.0...v9.7.0) (2024-09-23)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **ui-toggle-details:** fix ToggleDetails flickering ([4c55bc9](https://github.com/instructure/instructure-ui/commit/4c55bc9cf751944cae4fceda983ea060f9398c54))
28
+
29
+
30
+
31
+
32
+
14
33
  # [9.6.0](https://github.com/instructure/instructure-ui/compare/v9.5.2...v9.6.0) (2024-08-14)
15
34
 
16
35
  **Note:** Version bump only for package @instructure/ui-toggle-details
@@ -46,13 +46,9 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
46
46
  this._button = null;
47
47
  this.getButtonRef = el => this._button = el;
48
48
  this.handleToggle = (event, expanded) => {
49
- var _this$props$makeStyle, _this$props;
50
49
  if (typeof this.props.onToggle === 'function') {
51
50
  this.props.onToggle(event, expanded);
52
51
  }
53
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
54
- animate: true
55
- });
56
52
  };
57
53
  }
58
54
  get focused() {
@@ -63,22 +59,18 @@ let ToggleDetails = (_dec = withStyle(generateStyle, generateComponentTheme), _d
63
59
  (_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
64
60
  }
65
61
  componentDidMount() {
66
- var _this$props$makeStyle2, _this$props2;
67
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
68
- animate: false
69
- });
62
+ var _this$props$makeStyle, _this$props;
63
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
70
64
  }
71
65
  componentDidUpdate() {
72
- var _this$props$makeStyle3, _this$props3;
73
- (_this$props$makeStyle3 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle3 === void 0 ? void 0 : _this$props$makeStyle3.call(_this$props3, {
74
- animate: true
75
- });
66
+ var _this$props$makeStyle2, _this$props2;
67
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
76
68
  }
77
69
  renderSummary(expanded) {
78
70
  var _this$props$styles, _this$props$styles2;
79
- const _this$props4 = this.props,
80
- summary = _this$props4.summary,
81
- iconPosition = _this$props4.iconPosition;
71
+ const _this$props3 = this.props,
72
+ summary = _this$props3.summary,
73
+ iconPosition = _this$props3.iconPosition;
82
74
  return jsx("span", {
83
75
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.summary
84
76
  }, iconPosition === 'start' && this.renderIcon(expanded), jsx("span", {
@@ -38,12 +38,11 @@ const contentAnimation = keyframes`
38
38
  * @param {Object} state the state of the component, the style is applied to
39
39
  * @return {Object} The final style object, which will be used in the component
40
40
  */
41
- const generateStyle = (componentTheme, props, state) => {
41
+ const generateStyle = (componentTheme, props, _state) => {
42
42
  const fluidWidth = props.fluidWidth,
43
43
  iconPosition = props.iconPosition,
44
44
  size = props.size,
45
45
  variant = props.variant;
46
- const animate = state.animate;
47
46
  const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
48
47
  const fluidWidthStyles = fluidWidth ? {
49
48
  display: 'block',
@@ -183,13 +182,13 @@ const generateStyle = (componentTheme, props, state) => {
183
182
  ...fontSizeStyles[size],
184
183
  ...indentDetailsStyles[size]
185
184
  },
186
- content: animate ? {
185
+ content: {
187
186
  label: 'toggleDetails__content',
188
187
  opacity: 0.01,
189
188
  animationName: contentAnimation,
190
189
  animationFillMode: 'forwards',
191
190
  animationDuration: '.3s'
192
- } : {}
191
+ }
193
192
  };
194
193
  };
195
194
  export default generateStyle;
@@ -56,13 +56,9 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
56
56
  this._button = null;
57
57
  this.getButtonRef = el => this._button = el;
58
58
  this.handleToggle = (event, expanded) => {
59
- var _this$props$makeStyle, _this$props;
60
59
  if (typeof this.props.onToggle === 'function') {
61
60
  this.props.onToggle(event, expanded);
62
61
  }
63
- (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, {
64
- animate: true
65
- });
66
62
  };
67
63
  }
68
64
  get focused() {
@@ -73,22 +69,18 @@ let ToggleDetails = exports.ToggleDetails = (_dec = (0, _emotion.withStyle)(_sty
73
69
  (_this$_button = this._button) === null || _this$_button === void 0 ? void 0 : _this$_button.focus();
74
70
  }
75
71
  componentDidMount() {
76
- var _this$props$makeStyle2, _this$props2;
77
- (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, {
78
- animate: false
79
- });
72
+ var _this$props$makeStyle, _this$props;
73
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
80
74
  }
81
75
  componentDidUpdate() {
82
- var _this$props$makeStyle3, _this$props3;
83
- (_this$props$makeStyle3 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle3 === void 0 ? void 0 : _this$props$makeStyle3.call(_this$props3, {
84
- animate: true
85
- });
76
+ var _this$props$makeStyle2, _this$props2;
77
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
86
78
  }
87
79
  renderSummary(expanded) {
88
80
  var _this$props$styles, _this$props$styles2;
89
- const _this$props4 = this.props,
90
- summary = _this$props4.summary,
91
- iconPosition = _this$props4.iconPosition;
81
+ const _this$props3 = this.props,
82
+ summary = _this$props3.summary,
83
+ iconPosition = _this$props3.iconPosition;
92
84
  return (0, _emotion.jsx)("span", {
93
85
  css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.summary
94
86
  }, iconPosition === 'start' && this.renderIcon(expanded), (0, _emotion.jsx)("span", {
@@ -44,12 +44,11 @@ const contentAnimation = (0, _emotion.keyframes)`
44
44
  * @param {Object} state the state of the component, the style is applied to
45
45
  * @return {Object} The final style object, which will be used in the component
46
46
  */
47
- const generateStyle = (componentTheme, props, state) => {
47
+ const generateStyle = (componentTheme, props, _state) => {
48
48
  const fluidWidth = props.fluidWidth,
49
49
  iconPosition = props.iconPosition,
50
50
  size = props.size,
51
51
  variant = props.variant;
52
- const animate = state.animate;
53
52
  const positionIconAtEnd = iconPosition === 'end' && (variant === 'filled' || fluidWidth);
54
53
  const fluidWidthStyles = fluidWidth ? {
55
54
  display: 'block',
@@ -189,13 +188,13 @@ const generateStyle = (componentTheme, props, state) => {
189
188
  ...fontSizeStyles[size],
190
189
  ...indentDetailsStyles[size]
191
190
  },
192
- content: animate ? {
191
+ content: {
193
192
  label: 'toggleDetails__content',
194
193
  opacity: 0.01,
195
194
  animationName: contentAnimation,
196
195
  animationFillMode: 'forwards',
197
196
  animationDuration: '.3s'
198
- } : {}
197
+ }
199
198
  };
200
199
  };
201
200
  var _default = exports.default = generateStyle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-toggle-details",
3
- "version": "9.6.1-snapshot-2",
3
+ "version": "9.7.2",
4
4
  "description": "A styled toggleable, accordion-like component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,28 +23,28 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "9.6.1-snapshot-2",
27
- "@instructure/ui-test-locator": "9.6.1-snapshot-2",
28
- "@instructure/ui-test-queries": "9.6.1-snapshot-2",
29
- "@instructure/ui-test-utils": "9.6.1-snapshot-2",
30
- "@instructure/ui-themes": "9.6.1-snapshot-2"
26
+ "@instructure/ui-babel-preset": "9.7.2",
27
+ "@instructure/ui-test-locator": "9.7.2",
28
+ "@instructure/ui-test-queries": "9.7.2",
29
+ "@instructure/ui-test-utils": "9.7.2",
30
+ "@instructure/ui-themes": "9.7.2"
31
31
  },
32
32
  "dependencies": {
33
33
  "@babel/runtime": "^7.24.5",
34
- "@instructure/emotion": "9.6.1-snapshot-2",
35
- "@instructure/shared-types": "9.6.1-snapshot-2",
36
- "@instructure/ui-buttons": "9.6.1-snapshot-2",
37
- "@instructure/ui-dom-utils": "9.6.1-snapshot-2",
38
- "@instructure/ui-expandable": "9.6.1-snapshot-2",
39
- "@instructure/ui-flex": "9.6.1-snapshot-2",
40
- "@instructure/ui-icons": "9.6.1-snapshot-2",
41
- "@instructure/ui-motion": "9.6.1-snapshot-2",
42
- "@instructure/ui-prop-types": "9.6.1-snapshot-2",
43
- "@instructure/ui-react-utils": "9.6.1-snapshot-2",
44
- "@instructure/ui-testable": "9.6.1-snapshot-2",
45
- "@instructure/ui-utils": "9.6.1-snapshot-2",
46
- "@instructure/ui-view": "9.6.1-snapshot-2",
47
- "@instructure/uid": "9.6.1-snapshot-2",
34
+ "@instructure/emotion": "9.7.2",
35
+ "@instructure/shared-types": "9.7.2",
36
+ "@instructure/ui-buttons": "9.7.2",
37
+ "@instructure/ui-dom-utils": "9.7.2",
38
+ "@instructure/ui-expandable": "9.7.2",
39
+ "@instructure/ui-flex": "9.7.2",
40
+ "@instructure/ui-icons": "9.7.2",
41
+ "@instructure/ui-motion": "9.7.2",
42
+ "@instructure/ui-prop-types": "9.7.2",
43
+ "@instructure/ui-react-utils": "9.7.2",
44
+ "@instructure/ui-testable": "9.7.2",
45
+ "@instructure/ui-utils": "9.7.2",
46
+ "@instructure/ui-view": "9.7.2",
47
+ "@instructure/uid": "9.7.2",
48
48
  "prop-types": "^15.8.1"
49
49
  },
50
50
  "peerDependencies": {
@@ -131,6 +131,89 @@ type: example
131
131
  </ToggleDetails>
132
132
  ```
133
133
 
134
+ ### Example to demonstrate more properties
135
+
136
+ ```js
137
+ ---
138
+ type: example
139
+ ---
140
+ const Example = () => {
141
+ const [state, setState] = useState({
142
+ expanded: true,
143
+ fluidWidth: true,
144
+ iconPosition: 'start',
145
+ size: 'small',
146
+ variant: 'default'
147
+ });
148
+
149
+ const handleChange = (field, value) => setState(prevState => ({ ...prevState, [field]: value }));
150
+ const handleToggle = () => setState(prevState => ({ ...prevState, expanded: !prevState.expanded }));
151
+
152
+ const renderOptions = () => {
153
+ const { fluidWidth, iconPosition, size, variant } = state;
154
+ const options = [
155
+ { name: 'iconPosition', values: ['start', 'end'] },
156
+ { name: 'size', values: ['small', 'medium', 'large'] },
157
+ { name: 'variant', values: ['default', 'filled'] },
158
+ ];
159
+
160
+ return (
161
+ <Flex alignItems="start">
162
+ {options.map(({ name, values }) => (
163
+ <Flex.Item margin="small" key={name}>
164
+ <RadioInputGroup
165
+ name={name}
166
+ description={name}
167
+ value={state[name]}
168
+ onChange={(e, value) => handleChange(name, value)}
169
+ >
170
+ {values.map(val => (
171
+ <RadioInput label={val} value={val} key={val} />
172
+ ))}
173
+ </RadioInputGroup>
174
+ </Flex.Item>
175
+ ))}
176
+ <Flex.Item margin="small">
177
+ <Checkbox
178
+ label="fluidWidth"
179
+ checked={fluidWidth}
180
+ onChange={() => handleChange('fluidWidth', !fluidWidth)}
181
+ />
182
+ </Flex.Item>
183
+ </Flex>
184
+ );
185
+ };
186
+
187
+ const { expanded, iconPosition, size, variant, fluidWidth } = state;
188
+
189
+ return (
190
+ <div>
191
+ {renderOptions()}
192
+ <Button onClick={handleToggle}>
193
+ This Button {expanded ? 'Collapses' : 'Expands'}
194
+ </Button>
195
+ <br />
196
+ <br />
197
+ <ToggleDetails
198
+ summary="Click to hide me!"
199
+ expanded={expanded}
200
+ onToggle={(_, expanded) => handleChange('expanded', expanded)}
201
+ fluidWidth={fluidWidth}
202
+ iconPosition={iconPosition}
203
+ size={size}
204
+ variant={variant}
205
+ >
206
+ <Text weight="bold">
207
+ I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!I am controlled and expanded!
208
+ </Text>
209
+ </ToggleDetails>
210
+ </div>
211
+ );
212
+ };
213
+
214
+ render(<Example />)
215
+ ```
216
+
134
217
  ### Guidelines
135
218
 
136
219
  ```js
@@ -36,7 +36,7 @@ import { testable } from '@instructure/ui-testable'
36
36
  import { withStyle, jsx } from '@instructure/emotion'
37
37
  import generateStyle from './styles'
38
38
  import generateComponentTheme from './theme'
39
- import type { ToggleDetailsProps, ToggleDetailsStyleProps } from './props'
39
+ import type { ToggleDetailsProps } from './props'
40
40
  import { allowedProps, propTypes } from './props'
41
41
  import type { ExpandableToggleProps } from '@instructure/ui-expandable'
42
42
 
@@ -75,11 +75,11 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
75
75
  }
76
76
 
77
77
  componentDidMount() {
78
- this.props.makeStyles?.({ animate: false } as ToggleDetailsStyleProps)
78
+ this.props.makeStyles?.()
79
79
  }
80
80
 
81
81
  componentDidUpdate() {
82
- this.props.makeStyles?.({ animate: true } as ToggleDetailsStyleProps)
82
+ this.props.makeStyles?.()
83
83
  }
84
84
 
85
85
  getButtonRef = (el: Element | null) => (this._button = el as HTMLElement)
@@ -169,7 +169,6 @@ class ToggleDetails extends Component<ToggleDetailsProps> {
169
169
  if (typeof this.props.onToggle === 'function') {
170
170
  this.props.onToggle(event, expanded)
171
171
  }
172
- this.props.makeStyles?.({ animate: true })
173
172
  }
174
173
 
175
174
  render() {
@@ -49,10 +49,9 @@ const contentAnimation = keyframes`
49
49
  const generateStyle = (
50
50
  componentTheme: ToggleDetailsTheme,
51
51
  props: ToggleDetailsProps,
52
- state: ToggleDetailsStyleProps
52
+ _state: ToggleDetailsStyleProps
53
53
  ): ToggleDetailsStyle => {
54
54
  const { fluidWidth, iconPosition, size, variant } = props
55
- const { animate } = state
56
55
 
57
56
  const positionIconAtEnd =
58
57
  iconPosition === 'end' && (variant === 'filled' || fluidWidth)
@@ -178,15 +177,13 @@ const generateStyle = (
178
177
  ...fontSizeStyles[size!],
179
178
  ...indentDetailsStyles[size!]
180
179
  },
181
- content: animate
182
- ? {
183
- label: 'toggleDetails__content',
184
- opacity: 0.01,
185
- animationName: contentAnimation,
186
- animationFillMode: 'forwards',
187
- animationDuration: '.3s'
188
- }
189
- : {}
180
+ content: {
181
+ label: 'toggleDetails__content',
182
+ opacity: 0.01,
183
+ animationName: contentAnimation,
184
+ animationFillMode: 'forwards',
185
+ animationDuration: '.3s'
186
+ }
190
187
  }
191
188
  }
192
189