@instructure/ui-editable 11.7.10 → 11.7.11-pr-snapshot-1793742294723

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,6 +3,19 @@
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
+ ## [11.7.11-pr-snapshot-1793742294723](https://github.com/instructure/instructure-ui/compare/v11.7.10...v11.7.11-pr-snapshot-1793742294723) (2026-11-03)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([9c2e562](https://github.com/instructure/instructure-ui/commit/9c2e5629e7c509fdfc0d1770d1b81e70e60e083b))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.10](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.10) (2026-10-14)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-editable
@@ -1,228 +1,168 @@
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
1
  import { Component } from 'react';
26
2
  import { deepEqual } from '@instructure/ui-utils';
27
3
  import { logWarn as warn } from '@instructure/console';
28
4
  import { requestAnimationFrame } from '@instructure/ui-dom-utils';
29
5
  import { allowedProps } from './props.js';
30
- /**
31
- ---
32
- category: components
33
- ---
34
- **/
35
6
  class Editable extends Component {
36
- static displayName = 'Editable';
37
- static allowedProps = allowedProps;
38
- static defaultProps = {
39
- readOnly: false,
40
- children: null
41
- };
42
- state = {
43
- showModeToggle: false,
44
- valueOnEdit: null // the value when mode flips from view -> edit
45
- };
46
- _editorRef = null;
47
- _editButtonRef = null;
48
- constructor(props) {
49
- super(props);
50
- warn(props.readOnly ? props.mode === 'view' : true, '[Editable] When readOnly is true, mode must be "view"');
51
- }
52
- componentDidMount() {
53
- if (this.props.mode === 'edit') {
54
- this.focusEditor();
7
+ static{
8
+ this.displayName = 'Editable';
55
9
  }
56
- }
57
- componentDidUpdate(prevProps) {
58
- const {
59
- mode,
60
- value,
61
- onChange
62
- } = this.props;
63
-
64
- // on the switch from view -> edit
65
- if (prevProps.mode !== 'edit' && mode === 'edit') {
66
- this.setState({
67
- valueOnEdit: value
68
- });
69
- this.focusEditor();
10
+ static{
11
+ this.allowedProps = allowedProps;
70
12
  }
71
-
72
- // on the switch from edit to view
73
- if (prevProps.mode === 'edit' && mode !== 'edit') {
74
- this._editButtonRef && this._editButtonRef.focus();
75
- if (onChange && !deepEqual(this.state.valueOnEdit, value)) {
76
- onChange(value);
77
- }
13
+ static{
14
+ this.defaultProps = {
15
+ readOnly: false,
16
+ children: null
17
+ };
78
18
  }
79
- }
80
- focusEditor() {
81
- warn(!!this._editorRef && !this.props.readOnly, '[Editable] Did you forget to connect editorRef to your editor component?');
82
- if (this._editorRef) {
83
- this._editorRef.focus();
19
+ constructor(props){
20
+ super(props), this.state = {
21
+ showModeToggle: false,
22
+ valueOnEdit: null
23
+ }, this._editorRef = null, this._editButtonRef = null, this.handleEditESC = (event)=>{
24
+ if (event.key === 'Escape') {
25
+ event.stopPropagation();
26
+ this.enterView();
27
+ }
28
+ }, this.handleViewMouseOver = (event)=>{
29
+ if (this.props.mode === 'view') {
30
+ event.stopPropagation();
31
+ this.setState({
32
+ showModeToggle: true
33
+ });
34
+ }
35
+ }, this.handleViewMouseOut = (event)=>{
36
+ if (this.props.mode === 'view') {
37
+ event.stopPropagation();
38
+ this.setState({
39
+ showModeToggle: document.activeElement === this._editButtonRef
40
+ });
41
+ }
42
+ }, this.handleViewClick = (event)=>{
43
+ if (event.buttons === 1) {
44
+ requestAnimationFrame(()=>{
45
+ this.enterEdit();
46
+ });
47
+ }
48
+ }, this.handleEditBlur = ()=>{
49
+ this.enterView();
50
+ }, this.handleEditButtonFocus = ()=>{
51
+ this.setState({
52
+ showModeToggle: true
53
+ });
54
+ }, this.handleEditButtonBlur = ()=>{
55
+ this.setState({
56
+ showModeToggle: false
57
+ });
58
+ }, this.handleEditButtonClick = ()=>{
59
+ this.enterEdit();
60
+ }, this.ref = null, this.handleContainerRef = (el)=>{
61
+ const { elementRef } = this.props;
62
+ this.ref = el;
63
+ if (typeof elementRef === 'function') {
64
+ elementRef(el);
65
+ }
66
+ }, this.getContainerProps = (props = {})=>{
67
+ const { mode, readOnly } = this.props;
68
+ return {
69
+ onMouseOver: this.handleViewMouseOver,
70
+ onMouseOut: this.handleViewMouseOut,
71
+ onMouseDown: mode !== 'edit' ? this.handleViewClick : undefined,
72
+ onKeyUp: mode === 'edit' ? this.handleEditESC : undefined,
73
+ readOnly,
74
+ ...props,
75
+ ref: this.handleContainerRef
76
+ };
77
+ }, this.getViewerProps = (props = {})=>{
78
+ return {
79
+ mode: this.props.mode,
80
+ readOnly: this.props.readOnly,
81
+ ...props
82
+ };
83
+ }, this.getEditorProps = (props = {})=>{
84
+ return {
85
+ mode: this.props.mode,
86
+ onBlur: this.handleEditBlur,
87
+ editorRef: (el)=>{
88
+ this._editorRef = el;
89
+ },
90
+ readOnly: this.props.readOnly,
91
+ ...props
92
+ };
93
+ }, this.getEditButtonProps = (props = {})=>{
94
+ return {
95
+ onClick: this.handleEditButtonClick,
96
+ onFocus: this.handleEditButtonFocus,
97
+ onBlur: this.handleEditButtonBlur,
98
+ isVisible: this.state.showModeToggle,
99
+ buttonRef: (el)=>{
100
+ this._editButtonRef = el;
101
+ },
102
+ readOnly: this.props.readOnly,
103
+ ...props
104
+ };
105
+ };
106
+ warn(props.readOnly ? props.mode === 'view' : true, '[Editable] When readOnly is true, mode must be "view"');
84
107
  }
85
- }
86
- enterView() {
87
- if (this.props.mode !== 'view') {
88
- this.setState({
89
- showModeToggle: true
90
- });
91
- this.props.onChangeMode('view');
108
+ componentDidMount() {
109
+ if (this.props.mode === 'edit') {
110
+ this.focusEditor();
111
+ }
92
112
  }
93
- }
94
- enterEdit() {
95
- if (!this.props.readOnly) {
96
- this.setState({
97
- showModeToggle: false
98
- });
99
- if (this.props.mode !== 'edit') {
100
- this.props.onChangeMode('edit');
101
- }
113
+ componentDidUpdate(prevProps) {
114
+ const { mode, value, onChange } = this.props;
115
+ if (prevProps.mode !== 'edit' && mode === 'edit') {
116
+ this.setState({
117
+ valueOnEdit: value
118
+ });
119
+ this.focusEditor();
120
+ }
121
+ if (prevProps.mode === 'edit' && mode !== 'edit') {
122
+ this._editButtonRef && this._editButtonRef.focus();
123
+ if (onChange && !deepEqual(this.state.valueOnEdit, value)) {
124
+ onChange(value);
125
+ }
126
+ }
102
127
  }
103
- }
104
- handleEditESC = event => {
105
- if (event.key === 'Escape') {
106
- event.stopPropagation();
107
- this.enterView();
128
+ focusEditor() {
129
+ warn(!!this._editorRef && !this.props.readOnly, '[Editable] Did you forget to connect editorRef to your editor component?');
130
+ if (this._editorRef) {
131
+ this._editorRef.focus();
132
+ }
108
133
  }
109
- };
110
- handleViewMouseOver = event => {
111
- if (this.props.mode === 'view') {
112
- // because the mouse event handlers are on the container, not the view
113
- event.stopPropagation();
114
- this.setState({
115
- showModeToggle: true
116
- });
134
+ enterView() {
135
+ if (this.props.mode !== 'view') {
136
+ this.setState({
137
+ showModeToggle: true
138
+ });
139
+ this.props.onChangeMode('view');
140
+ }
117
141
  }
118
- };
119
- handleViewMouseOut = event => {
120
- if (this.props.mode === 'view') {
121
- event.stopPropagation();
122
- this.setState({
123
- showModeToggle: document.activeElement === this._editButtonRef
124
- });
142
+ enterEdit() {
143
+ if (!this.props.readOnly) {
144
+ this.setState({
145
+ showModeToggle: false
146
+ });
147
+ if (this.props.mode !== 'edit') {
148
+ this.props.onChangeMode('edit');
149
+ }
150
+ }
125
151
  }
126
- };
127
- handleViewClick = event => {
128
- if (event.buttons === 1) {
129
- requestAnimationFrame(() => {
130
- this.enterEdit();
131
- });
152
+ render() {
153
+ const { children, render = children, mode } = this.props;
154
+ if (typeof render === 'function') {
155
+ return render({
156
+ mode,
157
+ getContainerProps: this.getContainerProps,
158
+ getViewerProps: this.getViewerProps,
159
+ getEditorProps: this.getEditorProps,
160
+ getEditButtonProps: this.getEditButtonProps
161
+ });
162
+ } else {
163
+ return null;
164
+ }
132
165
  }
133
- };
134
- handleEditBlur = () => {
135
- this.enterView();
136
- };
137
- handleEditButtonFocus = () => {
138
- this.setState({
139
- showModeToggle: true
140
- });
141
- };
142
- handleEditButtonBlur = () => {
143
- this.setState({
144
- showModeToggle: false
145
- });
146
- };
147
- handleEditButtonClick = () => {
148
- this.enterEdit();
149
- };
150
- ref = null;
151
- handleContainerRef = el => {
152
- const {
153
- elementRef
154
- } = this.props;
155
- this.ref = el;
156
- if (typeof elementRef === 'function') {
157
- elementRef(el);
158
- }
159
- };
160
-
161
- // ------- prop getters ------
162
- getContainerProps = (props = {}) => {
163
- const {
164
- mode,
165
- readOnly
166
- } = this.props;
167
- return {
168
- onMouseOver: this.handleViewMouseOver,
169
- onMouseOut: this.handleViewMouseOut,
170
- onMouseDown: mode !== 'edit' ? this.handleViewClick : undefined,
171
- onKeyUp: mode === 'edit' ? this.handleEditESC : undefined,
172
- readOnly,
173
- ...props,
174
- ref: this.handleContainerRef
175
- };
176
- };
177
- getViewerProps = (props = {}) => {
178
- return {
179
- mode: this.props.mode,
180
- readOnly: this.props.readOnly,
181
- ...props
182
- };
183
- };
184
- getEditorProps = (props = {}) => {
185
- return {
186
- mode: this.props.mode,
187
- onBlur: this.handleEditBlur,
188
- editorRef: el => {
189
- this._editorRef = el;
190
- },
191
- readOnly: this.props.readOnly,
192
- ...props
193
- };
194
- };
195
- getEditButtonProps = (props = {}) => {
196
- return {
197
- onClick: this.handleEditButtonClick,
198
- onFocus: this.handleEditButtonFocus,
199
- onBlur: this.handleEditButtonBlur,
200
- isVisible: this.state.showModeToggle,
201
- buttonRef: el => {
202
- this._editButtonRef = el;
203
- },
204
- readOnly: this.props.readOnly,
205
- ...props
206
- };
207
- };
208
- render() {
209
- const {
210
- children,
211
- render = children,
212
- mode
213
- } = this.props;
214
- if (typeof render === 'function') {
215
- return render({
216
- mode,
217
- getContainerProps: this.getContainerProps,
218
- getViewerProps: this.getViewerProps,
219
- getEditorProps: this.getEditorProps,
220
- getEditButtonProps: this.getEditButtonProps
221
- });
222
- } else {
223
- return null;
224
- }
225
- }
226
166
  }
227
167
  export default Editable;
228
- export { Editable };
168
+ export { Editable };
@@ -1,26 +1,11 @@
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
- const allowedProps = ['mode', 'onChangeMode', 'children', 'render', 'value', 'onChange', 'readOnly', 'elementRef'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'mode',
3
+ 'onChangeMode',
4
+ 'children',
5
+ 'render',
6
+ 'value',
7
+ 'onChange',
8
+ 'readOnly',
9
+ 'elementRef'
10
+ ];
11
+ export { allowedProps };