@instructure/ui-editable 11.0.1-snapshot-1 → 11.0.1-snapshot-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 +1 -1
- package/package.json +14 -14
- package/src/Editable/README.md +92 -192
- package/src/InPlaceEdit/README.md +20 -322
- package/tsconfig.build.tsbuildinfo +1 -1
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
|
-
## [11.0.1-snapshot-
|
|
6
|
+
## [11.0.1-snapshot-2](https://github.com/instructure/instructure-ui/compare/v11.0.0...v11.0.1-snapshot-2) (2025-10-10)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-editable
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-editable",
|
|
3
|
-
"version": "11.0.1-snapshot-
|
|
3
|
+
"version": "11.0.1-snapshot-2",
|
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-axe-check": "11.0.1-snapshot-
|
|
27
|
-
"@instructure/ui-babel-preset": "11.0.1-snapshot-
|
|
26
|
+
"@instructure/ui-axe-check": "11.0.1-snapshot-2",
|
|
27
|
+
"@instructure/ui-babel-preset": "11.0.1-snapshot-2",
|
|
28
28
|
"@testing-library/jest-dom": "^6.6.3",
|
|
29
29
|
"@testing-library/react": "15.0.7",
|
|
30
30
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.27.6",
|
|
35
|
-
"@instructure/console": "11.0.1-snapshot-
|
|
36
|
-
"@instructure/emotion": "11.0.1-snapshot-
|
|
37
|
-
"@instructure/shared-types": "11.0.1-snapshot-
|
|
38
|
-
"@instructure/ui-a11y-content": "11.0.1-snapshot-
|
|
39
|
-
"@instructure/ui-buttons": "11.0.1-snapshot-
|
|
40
|
-
"@instructure/ui-dom-utils": "11.0.1-snapshot-
|
|
41
|
-
"@instructure/ui-flex": "11.0.1-snapshot-
|
|
42
|
-
"@instructure/ui-focusable": "11.0.1-snapshot-
|
|
43
|
-
"@instructure/ui-icons": "11.0.1-snapshot-
|
|
44
|
-
"@instructure/ui-utils": "11.0.1-snapshot-
|
|
45
|
-
"@instructure/ui-view": "11.0.1-snapshot-
|
|
35
|
+
"@instructure/console": "11.0.1-snapshot-2",
|
|
36
|
+
"@instructure/emotion": "11.0.1-snapshot-2",
|
|
37
|
+
"@instructure/shared-types": "11.0.1-snapshot-2",
|
|
38
|
+
"@instructure/ui-a11y-content": "11.0.1-snapshot-2",
|
|
39
|
+
"@instructure/ui-buttons": "11.0.1-snapshot-2",
|
|
40
|
+
"@instructure/ui-dom-utils": "11.0.1-snapshot-2",
|
|
41
|
+
"@instructure/ui-flex": "11.0.1-snapshot-2",
|
|
42
|
+
"@instructure/ui-focusable": "11.0.1-snapshot-2",
|
|
43
|
+
"@instructure/ui-icons": "11.0.1-snapshot-2",
|
|
44
|
+
"@instructure/ui-utils": "11.0.1-snapshot-2",
|
|
45
|
+
"@instructure/ui-view": "11.0.1-snapshot-2"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18 <=19",
|
package/src/Editable/README.md
CHANGED
|
@@ -17,207 +17,107 @@ will find examples.
|
|
|
17
17
|
Using `Editable` gives you complete control, over how in-place editing
|
|
18
18
|
should look.
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Do it!
|
|
50
|
-
</Button>
|
|
51
|
-
</span>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
renderViewer() {
|
|
56
|
-
return <span>{this.state.value}</span>
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
handleValueChange = (event) => {
|
|
60
|
-
this.setState({ value: event.target.value })
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
handleModeChange = (newMode) => {
|
|
64
|
-
this.setState({ mode: newMode })
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
renderEditor({ onBlur, editorRef }) {
|
|
68
|
-
return (
|
|
69
|
-
<input
|
|
70
|
-
ref={editorRef}
|
|
20
|
+
```js
|
|
21
|
+
---
|
|
22
|
+
type: example
|
|
23
|
+
---
|
|
24
|
+
const Example = (props) => {
|
|
25
|
+
const [mode, setMode] = useState(props.mode || 'view')
|
|
26
|
+
const [value, setValue] = useState(props.value || '')
|
|
27
|
+
const [readOnly, setReadOnly] = useState(false)
|
|
28
|
+
|
|
29
|
+
const renderButton = ({
|
|
30
|
+
isVisible,
|
|
31
|
+
onClick,
|
|
32
|
+
onFocus,
|
|
33
|
+
onBlur,
|
|
34
|
+
buttonRef
|
|
35
|
+
}) => {
|
|
36
|
+
if (readOnly) {
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// To correctly handle focus, always return the Button, but
|
|
41
|
+
// only visible if isVisible (if you want the UI to work in the standard way)
|
|
42
|
+
return (
|
|
43
|
+
<span style={{ opacity: isVisible ? 1 : 0 }}>
|
|
44
|
+
<Button
|
|
45
|
+
size="small"
|
|
46
|
+
margin="0 0 0 x-small"
|
|
47
|
+
onClick={onClick}
|
|
48
|
+
onFocus={onFocus}
|
|
71
49
|
onBlur={onBlur}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
renderMe = ({
|
|
79
|
-
mode,
|
|
80
|
-
getContainerProps,
|
|
81
|
-
getViewerProps,
|
|
82
|
-
getEditorProps,
|
|
83
|
-
getEditButtonProps
|
|
84
|
-
}) => {
|
|
85
|
-
return (
|
|
86
|
-
<View {...getContainerProps()}>
|
|
87
|
-
{mode === 'view' ? this.renderViewer(getViewerProps()) : null}
|
|
88
|
-
{mode === 'edit' ? this.renderEditor(getEditorProps()) : null}
|
|
89
|
-
{this.renderButton(getEditButtonProps())}
|
|
90
|
-
</View>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
onChangeReadOnly = (event) => {
|
|
95
|
-
this.setState({ readOnly: event.target.checked })
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
render() {
|
|
99
|
-
return (
|
|
100
|
-
<View as="div">
|
|
101
|
-
<View as="div" margin="0 0 small 0">
|
|
102
|
-
<Checkbox
|
|
103
|
-
size="small"
|
|
104
|
-
label="Read Only"
|
|
105
|
-
checked={this.state.readOnly}
|
|
106
|
-
onChange={this.onChangeReadOnly}
|
|
107
|
-
/>
|
|
108
|
-
</View>
|
|
109
|
-
<Editable
|
|
110
|
-
mode={this.state.mode}
|
|
111
|
-
onChangeMode={this.handleModeChange}
|
|
112
|
-
render={this.renderMe}
|
|
113
|
-
value={this.state.value}
|
|
114
|
-
readOnly={this.state.readOnly}
|
|
115
|
-
/>
|
|
116
|
-
</View>
|
|
117
|
-
)
|
|
118
|
-
}
|
|
50
|
+
elementRef={buttonRef}
|
|
51
|
+
>
|
|
52
|
+
Do it!
|
|
53
|
+
</Button>
|
|
54
|
+
</span>
|
|
55
|
+
)
|
|
119
56
|
}
|
|
120
|
-
render(<Example value="you can edit me" />)
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
- ```js
|
|
124
|
-
const Example = (props) => {
|
|
125
|
-
const [mode, setMode] = useState(props.mode || 'view')
|
|
126
|
-
const [value, setValue] = useState(props.value || '')
|
|
127
|
-
const [readOnly, setReadOnly] = useState(false)
|
|
128
57
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
onFocus,
|
|
133
|
-
onBlur,
|
|
134
|
-
buttonRef
|
|
135
|
-
}) => {
|
|
136
|
-
if (readOnly) {
|
|
137
|
-
return null
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// To correctly handle focus, always return the Button, but
|
|
141
|
-
// only visible if isVisible (if you want the UI to work in the standard way)
|
|
142
|
-
return (
|
|
143
|
-
<span style={{ opacity: isVisible ? 1 : 0 }}>
|
|
144
|
-
<Button
|
|
145
|
-
size="small"
|
|
146
|
-
margin="0 0 0 x-small"
|
|
147
|
-
onClick={onClick}
|
|
148
|
-
onFocus={onFocus}
|
|
149
|
-
onBlur={onBlur}
|
|
150
|
-
elementRef={buttonRef}
|
|
151
|
-
>
|
|
152
|
-
Do it!
|
|
153
|
-
</Button>
|
|
154
|
-
</span>
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const renderViewer = () => {
|
|
159
|
-
return <span>{value}</span>
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const handleValueChange = (event) => {
|
|
163
|
-
setValue(event.target.value)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const handleModeChange = (newMode) => {
|
|
167
|
-
setMode(newMode)
|
|
168
|
-
}
|
|
58
|
+
const renderViewer = () => {
|
|
59
|
+
return <span>{value}</span>
|
|
60
|
+
}
|
|
169
61
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
ref={editorRef}
|
|
174
|
-
onBlur={onBlur}
|
|
175
|
-
value={value}
|
|
176
|
-
onChange={handleValueChange}
|
|
177
|
-
/>
|
|
178
|
-
)
|
|
179
|
-
}
|
|
62
|
+
const handleValueChange = (event) => {
|
|
63
|
+
setValue(event.target.value)
|
|
64
|
+
}
|
|
180
65
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
getViewerProps,
|
|
185
|
-
getEditorProps,
|
|
186
|
-
getEditButtonProps
|
|
187
|
-
}) => {
|
|
188
|
-
return (
|
|
189
|
-
<View {...getContainerProps()}>
|
|
190
|
-
{mode === 'view' ? renderViewer(getViewerProps()) : null}
|
|
191
|
-
{mode === 'edit' ? renderEditor(getEditorProps()) : null}
|
|
192
|
-
{renderButton(getEditButtonProps())}
|
|
193
|
-
</View>
|
|
194
|
-
)
|
|
195
|
-
}
|
|
66
|
+
const handleModeChange = (newMode) => {
|
|
67
|
+
setMode(newMode)
|
|
68
|
+
}
|
|
196
69
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
70
|
+
const renderEditor = ({ onBlur, editorRef }) => {
|
|
71
|
+
return (
|
|
72
|
+
<input
|
|
73
|
+
ref={editorRef}
|
|
74
|
+
onBlur={onBlur}
|
|
75
|
+
value={value}
|
|
76
|
+
onChange={handleValueChange}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
200
80
|
|
|
81
|
+
const renderMe = ({
|
|
82
|
+
mode,
|
|
83
|
+
getContainerProps,
|
|
84
|
+
getViewerProps,
|
|
85
|
+
getEditorProps,
|
|
86
|
+
getEditButtonProps
|
|
87
|
+
}) => {
|
|
201
88
|
return (
|
|
202
|
-
<View
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
label="Read Only"
|
|
207
|
-
checked={readOnly}
|
|
208
|
-
onChange={onChangeReadOnly}
|
|
209
|
-
/>
|
|
210
|
-
</View>
|
|
211
|
-
<Editable
|
|
212
|
-
mode={mode}
|
|
213
|
-
onChangeMode={handleModeChange}
|
|
214
|
-
render={renderMe}
|
|
215
|
-
value={value}
|
|
216
|
-
readOnly={readOnly}
|
|
217
|
-
/>
|
|
89
|
+
<View {...getContainerProps()}>
|
|
90
|
+
{mode === 'view' ? renderViewer(getViewerProps()) : null}
|
|
91
|
+
{mode === 'edit' ? renderEditor(getEditorProps()) : null}
|
|
92
|
+
{renderButton(getEditButtonProps())}
|
|
218
93
|
</View>
|
|
219
94
|
)
|
|
220
95
|
}
|
|
221
96
|
|
|
222
|
-
|
|
223
|
-
|
|
97
|
+
const onChangeReadOnly = (event) => {
|
|
98
|
+
setReadOnly(event.target.checked)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<View as="div">
|
|
103
|
+
<View as="div" margin="0 0 small 0">
|
|
104
|
+
<Checkbox
|
|
105
|
+
size="small"
|
|
106
|
+
label="Read Only"
|
|
107
|
+
checked={readOnly}
|
|
108
|
+
onChange={onChangeReadOnly}
|
|
109
|
+
/>
|
|
110
|
+
</View>
|
|
111
|
+
<Editable
|
|
112
|
+
mode={mode}
|
|
113
|
+
onChangeMode={handleModeChange}
|
|
114
|
+
render={renderMe}
|
|
115
|
+
value={value}
|
|
116
|
+
readOnly={readOnly}
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
render(<Example value="you can edit me" />)
|
|
123
|
+
```
|