@instructure/ui-editable 11.7.2-snapshot-23 → 11.7.2-snapshot-24
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 +12 -2
- package/es/InPlaceEdit/v2/index.js +173 -0
- package/es/InPlaceEdit/v2/props.js +26 -0
- package/es/InPlaceEdit/v2/styles.js +55 -0
- package/es/exports/b.js +25 -0
- package/lib/InPlaceEdit/v2/index.js +178 -0
- package/lib/InPlaceEdit/v2/props.js +31 -0
- package/lib/InPlaceEdit/v2/styles.js +61 -0
- package/lib/exports/b.js +19 -0
- package/package.json +24 -24
- package/src/Editable/v1/README.md +5 -3
- package/src/InPlaceEdit/v2/README.md +338 -0
- package/src/InPlaceEdit/v2/index.tsx +205 -0
- package/src/InPlaceEdit/v2/props.ts +146 -0
- package/src/InPlaceEdit/v2/styles.ts +58 -0
- package/src/exports/b.ts +29 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/InPlaceEdit/v2/index.d.ts +61 -0
- package/types/InPlaceEdit/v2/index.d.ts.map +1 -0
- package/types/InPlaceEdit/v2/props.d.ts +103 -0
- package/types/InPlaceEdit/v2/props.d.ts.map +1 -0
- package/types/InPlaceEdit/v2/styles.d.ts +14 -0
- package/types/InPlaceEdit/v2/styles.d.ts.map +1 -0
- package/types/exports/b.d.ts +5 -0
- package/types/exports/b.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +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.2-snapshot-
|
|
6
|
+
## [11.7.2-snapshot-24](https://github.com/instructure/instructure-ui/compare/v11.7.1...v11.7.2-snapshot-24) (2026-04-01)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-text,ui-editable:** rework InPlaceEdit and Editable ([10f637b](https://github.com/instructure/instructure-ui/commit/10f637b938d49e23ceddc6b52535f927dd91e37b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* **ui-text,ui-editable:** contains breaking changes due to component using the new theming system
|
|
17
|
+
|
|
18
|
+
INSTUI-4969
|
|
9
19
|
|
|
10
20
|
|
|
11
21
|
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
var _dec, _class, _InPlaceEdit;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2018 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { Component } from 'react';
|
|
27
|
+
import { Flex } from '@instructure/ui-flex/latest';
|
|
28
|
+
import { IconButton } from '@instructure/ui-buttons/latest';
|
|
29
|
+
import { PencilInstUIIcon } from '@instructure/ui-icons';
|
|
30
|
+
import { logWarn as warn } from '@instructure/console';
|
|
31
|
+
import { createChainedFunction } from '@instructure/ui-utils';
|
|
32
|
+
import { withStyle } from '@instructure/emotion';
|
|
33
|
+
import { View } from '@instructure/ui-view/latest';
|
|
34
|
+
import { Editable } from "../../Editable/v1/index.js";
|
|
35
|
+
import generateStyle from "./styles.js";
|
|
36
|
+
import { allowedProps } from "./props.js";
|
|
37
|
+
import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
38
|
+
/**
|
|
39
|
+
---
|
|
40
|
+
category: components
|
|
41
|
+
---
|
|
42
|
+
**/
|
|
43
|
+
let InPlaceEdit = (_dec = withStyle(generateStyle), _dec(_class = (_InPlaceEdit = class InPlaceEdit extends Component {
|
|
44
|
+
constructor(props) {
|
|
45
|
+
super(props);
|
|
46
|
+
this.ref = null;
|
|
47
|
+
this._editButtonRef = null;
|
|
48
|
+
this.handleRef = el => {
|
|
49
|
+
this.ref = el;
|
|
50
|
+
};
|
|
51
|
+
this.handleEditButtonRef = el => {
|
|
52
|
+
this._editButtonRef = el;
|
|
53
|
+
};
|
|
54
|
+
this.renderAll = ({
|
|
55
|
+
getContainerProps,
|
|
56
|
+
getViewerProps,
|
|
57
|
+
getEditorProps,
|
|
58
|
+
getEditButtonProps
|
|
59
|
+
}) => {
|
|
60
|
+
const flexDir = this.props.editButtonPlacement === 'start' ? 'row-reverse' : 'row';
|
|
61
|
+
const justifyItems = flexDir === 'row-reverse' ? 'end' : 'start';
|
|
62
|
+
const buttonMargin = this.props.editButtonPlacement === 'start' ? '0 xx-small 0 0' : '0 0 0 xx-small';
|
|
63
|
+
return _jsxs(Flex, {
|
|
64
|
+
display: this.props.inline ? 'inline-flex' : 'flex',
|
|
65
|
+
direction: flexDir,
|
|
66
|
+
justifyItems: justifyItems,
|
|
67
|
+
...getContainerProps(),
|
|
68
|
+
children: [_jsxs(Flex.Item, {
|
|
69
|
+
shouldGrow: true,
|
|
70
|
+
shouldShrink: true,
|
|
71
|
+
children: [this.renderEditor(getEditorProps()), this.renderViewer(getViewerProps())]
|
|
72
|
+
}), _jsx(Flex.Item, {
|
|
73
|
+
margin: buttonMargin,
|
|
74
|
+
children: this.renderEditButton(getEditButtonProps())
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
warn(props.readOnly ? props.mode === 'view' : true, '[InPlaceEdit] When readOnly is true, mode is forced to "view"');
|
|
79
|
+
}
|
|
80
|
+
componentDidMount() {
|
|
81
|
+
var _this$props$makeStyle, _this$props;
|
|
82
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
83
|
+
}
|
|
84
|
+
componentDidUpdate() {
|
|
85
|
+
var _this$props$makeStyle2, _this$props2;
|
|
86
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
87
|
+
}
|
|
88
|
+
renderEditor({
|
|
89
|
+
mode,
|
|
90
|
+
onBlur,
|
|
91
|
+
editorRef,
|
|
92
|
+
readOnly
|
|
93
|
+
}) {
|
|
94
|
+
var _this$props$styles;
|
|
95
|
+
const _this$props3 = this.props,
|
|
96
|
+
showFocusRing = _this$props3.showFocusRing,
|
|
97
|
+
renderEditor = _this$props3.renderEditor;
|
|
98
|
+
const isEditMode = !readOnly && mode === 'edit';
|
|
99
|
+
return isEditMode ? _jsx(View, {
|
|
100
|
+
as: "span",
|
|
101
|
+
display: "block",
|
|
102
|
+
withFocusOutline: showFocusRing,
|
|
103
|
+
position: "relative",
|
|
104
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.inPlaceEdit,
|
|
105
|
+
borderRadius: "medium",
|
|
106
|
+
margin: "auto",
|
|
107
|
+
children: renderEditor({
|
|
108
|
+
onBlur,
|
|
109
|
+
editorRef
|
|
110
|
+
})
|
|
111
|
+
}) : null;
|
|
112
|
+
}
|
|
113
|
+
renderViewer({
|
|
114
|
+
readOnly,
|
|
115
|
+
mode
|
|
116
|
+
}) {
|
|
117
|
+
return readOnly || mode === 'view' ? this.props.renderViewer() : null;
|
|
118
|
+
}
|
|
119
|
+
renderEditButton({
|
|
120
|
+
buttonRef,
|
|
121
|
+
...rest
|
|
122
|
+
}) {
|
|
123
|
+
return this.props.renderEditButton({
|
|
124
|
+
elementRef: createChainedFunction(this.handleEditButtonRef, buttonRef),
|
|
125
|
+
...rest
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Render a default edit button, an icon button with the edit icon
|
|
130
|
+
// the margin makes room for the focus ring
|
|
131
|
+
|
|
132
|
+
render() {
|
|
133
|
+
const _this$props4 = this.props,
|
|
134
|
+
mode = _this$props4.mode,
|
|
135
|
+
value = _this$props4.value,
|
|
136
|
+
onChange = _this$props4.onChange,
|
|
137
|
+
onChangeMode = _this$props4.onChangeMode,
|
|
138
|
+
readOnly = _this$props4.readOnly;
|
|
139
|
+
return _jsx(Editable, {
|
|
140
|
+
mode: mode,
|
|
141
|
+
onChangeMode: onChangeMode,
|
|
142
|
+
render: this.renderAll,
|
|
143
|
+
value: value,
|
|
144
|
+
onChange: onChange,
|
|
145
|
+
readOnly: readOnly,
|
|
146
|
+
elementRef: this.handleRef
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}, _InPlaceEdit.displayName = "InPlaceEdit", _InPlaceEdit.componentId = 'InPlaceEdit', _InPlaceEdit.allowedProps = allowedProps, _InPlaceEdit.defaultProps = {
|
|
150
|
+
readOnly: false,
|
|
151
|
+
showFocusRing: true,
|
|
152
|
+
inline: true,
|
|
153
|
+
editButtonPlacement: 'end'
|
|
154
|
+
}, _InPlaceEdit.renderDefaultEditButton = ({
|
|
155
|
+
isVisible,
|
|
156
|
+
readOnly,
|
|
157
|
+
label,
|
|
158
|
+
...buttonProps
|
|
159
|
+
}) => {
|
|
160
|
+
if (readOnly) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
return _jsx(IconButton, {
|
|
164
|
+
size: "small",
|
|
165
|
+
screenReaderLabel: label,
|
|
166
|
+
withBackground: false,
|
|
167
|
+
withBorder: false,
|
|
168
|
+
...buttonProps,
|
|
169
|
+
children: isVisible ? PencilInstUIIcon : null
|
|
170
|
+
});
|
|
171
|
+
}, _InPlaceEdit)) || _class);
|
|
172
|
+
export default InPlaceEdit;
|
|
173
|
+
export { InPlaceEdit };
|
|
@@ -0,0 +1,26 @@
|
|
|
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 = ['renderViewer', 'renderEditor', 'renderEditButton', 'mode', 'onChangeMode', 'value', 'onChange', 'readOnly', 'showFocusRing', 'editButtonPlacement', 'inline'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
/**
|
|
26
|
+
* ---
|
|
27
|
+
* private: true
|
|
28
|
+
* ---
|
|
29
|
+
* Generates the style object from the theme and provided additional information
|
|
30
|
+
* @param {Object} componentTheme The theme variable object.
|
|
31
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
32
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = () => {
|
|
36
|
+
return {
|
|
37
|
+
inPlaceEdit: {
|
|
38
|
+
label: 'inPlaceEdit',
|
|
39
|
+
boxSizing: 'border-box',
|
|
40
|
+
maxWidth: '100%',
|
|
41
|
+
position: 'relative',
|
|
42
|
+
overflow: 'visible',
|
|
43
|
+
direction: 'inherit',
|
|
44
|
+
margin: 0,
|
|
45
|
+
textDecoration: 'none' /* for links styled as buttons */,
|
|
46
|
+
textAlign: 'inherit',
|
|
47
|
+
userSelect: 'none',
|
|
48
|
+
touchAction: 'manipulation',
|
|
49
|
+
background: 'transparent',
|
|
50
|
+
border: 'none',
|
|
51
|
+
outline: 'none'
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export default generateStyle;
|
package/es/exports/b.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2018 - 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
|
+
export { Editable } from "../Editable/v1/index.js";
|
|
25
|
+
export { InPlaceEdit } from "../InPlaceEdit/v2/index.js";
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.InPlaceEdit = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _latest = require("@instructure/ui-flex/latest");
|
|
10
|
+
var _latest2 = require("@instructure/ui-buttons/latest");
|
|
11
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
12
|
+
var _console = require("@instructure/console");
|
|
13
|
+
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
14
|
+
var _emotion = require("@instructure/emotion");
|
|
15
|
+
var _latest3 = require("@instructure/ui-view/latest");
|
|
16
|
+
var _v = require("../../Editable/v1");
|
|
17
|
+
var _styles = _interopRequireDefault(require("./styles"));
|
|
18
|
+
var _props = require("./props");
|
|
19
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
20
|
+
var _dec, _class, _InPlaceEdit;
|
|
21
|
+
/*
|
|
22
|
+
* The MIT License (MIT)
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) 2018 - present Instructure, Inc.
|
|
25
|
+
*
|
|
26
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
27
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
28
|
+
* in the Software without restriction, including without limitation the rights
|
|
29
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
30
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
31
|
+
* furnished to do so, subject to the following conditions:
|
|
32
|
+
*
|
|
33
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
34
|
+
* copies or substantial portions of the Software.
|
|
35
|
+
*
|
|
36
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
37
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
38
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
39
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
40
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
41
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
42
|
+
* SOFTWARE.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
---
|
|
46
|
+
category: components
|
|
47
|
+
---
|
|
48
|
+
**/
|
|
49
|
+
let InPlaceEdit = exports.InPlaceEdit = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_InPlaceEdit = class InPlaceEdit extends _react.Component {
|
|
50
|
+
constructor(props) {
|
|
51
|
+
super(props);
|
|
52
|
+
this.ref = null;
|
|
53
|
+
this._editButtonRef = null;
|
|
54
|
+
this.handleRef = el => {
|
|
55
|
+
this.ref = el;
|
|
56
|
+
};
|
|
57
|
+
this.handleEditButtonRef = el => {
|
|
58
|
+
this._editButtonRef = el;
|
|
59
|
+
};
|
|
60
|
+
this.renderAll = ({
|
|
61
|
+
getContainerProps,
|
|
62
|
+
getViewerProps,
|
|
63
|
+
getEditorProps,
|
|
64
|
+
getEditButtonProps
|
|
65
|
+
}) => {
|
|
66
|
+
const flexDir = this.props.editButtonPlacement === 'start' ? 'row-reverse' : 'row';
|
|
67
|
+
const justifyItems = flexDir === 'row-reverse' ? 'end' : 'start';
|
|
68
|
+
const buttonMargin = this.props.editButtonPlacement === 'start' ? '0 xx-small 0 0' : '0 0 0 xx-small';
|
|
69
|
+
return (0, _jsxRuntime.jsxs)(_latest.Flex, {
|
|
70
|
+
display: this.props.inline ? 'inline-flex' : 'flex',
|
|
71
|
+
direction: flexDir,
|
|
72
|
+
justifyItems: justifyItems,
|
|
73
|
+
...getContainerProps(),
|
|
74
|
+
children: [(0, _jsxRuntime.jsxs)(_latest.Flex.Item, {
|
|
75
|
+
shouldGrow: true,
|
|
76
|
+
shouldShrink: true,
|
|
77
|
+
children: [this.renderEditor(getEditorProps()), this.renderViewer(getViewerProps())]
|
|
78
|
+
}), (0, _jsxRuntime.jsx)(_latest.Flex.Item, {
|
|
79
|
+
margin: buttonMargin,
|
|
80
|
+
children: this.renderEditButton(getEditButtonProps())
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
(0, _console.logWarn)(props.readOnly ? props.mode === 'view' : true, '[InPlaceEdit] When readOnly is true, mode is forced to "view"');
|
|
85
|
+
}
|
|
86
|
+
componentDidMount() {
|
|
87
|
+
var _this$props$makeStyle, _this$props;
|
|
88
|
+
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
|
|
89
|
+
}
|
|
90
|
+
componentDidUpdate() {
|
|
91
|
+
var _this$props$makeStyle2, _this$props2;
|
|
92
|
+
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
93
|
+
}
|
|
94
|
+
renderEditor({
|
|
95
|
+
mode,
|
|
96
|
+
onBlur,
|
|
97
|
+
editorRef,
|
|
98
|
+
readOnly
|
|
99
|
+
}) {
|
|
100
|
+
var _this$props$styles;
|
|
101
|
+
const _this$props3 = this.props,
|
|
102
|
+
showFocusRing = _this$props3.showFocusRing,
|
|
103
|
+
renderEditor = _this$props3.renderEditor;
|
|
104
|
+
const isEditMode = !readOnly && mode === 'edit';
|
|
105
|
+
return isEditMode ? (0, _jsxRuntime.jsx)(_latest3.View, {
|
|
106
|
+
as: "span",
|
|
107
|
+
display: "block",
|
|
108
|
+
withFocusOutline: showFocusRing,
|
|
109
|
+
position: "relative",
|
|
110
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.inPlaceEdit,
|
|
111
|
+
borderRadius: "medium",
|
|
112
|
+
margin: "auto",
|
|
113
|
+
children: renderEditor({
|
|
114
|
+
onBlur,
|
|
115
|
+
editorRef
|
|
116
|
+
})
|
|
117
|
+
}) : null;
|
|
118
|
+
}
|
|
119
|
+
renderViewer({
|
|
120
|
+
readOnly,
|
|
121
|
+
mode
|
|
122
|
+
}) {
|
|
123
|
+
return readOnly || mode === 'view' ? this.props.renderViewer() : null;
|
|
124
|
+
}
|
|
125
|
+
renderEditButton({
|
|
126
|
+
buttonRef,
|
|
127
|
+
...rest
|
|
128
|
+
}) {
|
|
129
|
+
return this.props.renderEditButton({
|
|
130
|
+
elementRef: (0, _createChainedFunction.createChainedFunction)(this.handleEditButtonRef, buttonRef),
|
|
131
|
+
...rest
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Render a default edit button, an icon button with the edit icon
|
|
136
|
+
// the margin makes room for the focus ring
|
|
137
|
+
|
|
138
|
+
render() {
|
|
139
|
+
const _this$props4 = this.props,
|
|
140
|
+
mode = _this$props4.mode,
|
|
141
|
+
value = _this$props4.value,
|
|
142
|
+
onChange = _this$props4.onChange,
|
|
143
|
+
onChangeMode = _this$props4.onChangeMode,
|
|
144
|
+
readOnly = _this$props4.readOnly;
|
|
145
|
+
return (0, _jsxRuntime.jsx)(_v.Editable, {
|
|
146
|
+
mode: mode,
|
|
147
|
+
onChangeMode: onChangeMode,
|
|
148
|
+
render: this.renderAll,
|
|
149
|
+
value: value,
|
|
150
|
+
onChange: onChange,
|
|
151
|
+
readOnly: readOnly,
|
|
152
|
+
elementRef: this.handleRef
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, _InPlaceEdit.displayName = "InPlaceEdit", _InPlaceEdit.componentId = 'InPlaceEdit', _InPlaceEdit.allowedProps = _props.allowedProps, _InPlaceEdit.defaultProps = {
|
|
156
|
+
readOnly: false,
|
|
157
|
+
showFocusRing: true,
|
|
158
|
+
inline: true,
|
|
159
|
+
editButtonPlacement: 'end'
|
|
160
|
+
}, _InPlaceEdit.renderDefaultEditButton = ({
|
|
161
|
+
isVisible,
|
|
162
|
+
readOnly,
|
|
163
|
+
label,
|
|
164
|
+
...buttonProps
|
|
165
|
+
}) => {
|
|
166
|
+
if (readOnly) {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
return (0, _jsxRuntime.jsx)(_latest2.IconButton, {
|
|
170
|
+
size: "small",
|
|
171
|
+
screenReaderLabel: label,
|
|
172
|
+
withBackground: false,
|
|
173
|
+
withBorder: false,
|
|
174
|
+
...buttonProps,
|
|
175
|
+
children: isVisible ? _uiIcons.PencilInstUIIcon : null
|
|
176
|
+
});
|
|
177
|
+
}, _InPlaceEdit)) || _class);
|
|
178
|
+
var _default = exports.default = InPlaceEdit;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.allowedProps = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const allowedProps = exports.allowedProps = ['renderViewer', 'renderEditor', 'renderEditButton', 'mode', 'onChangeMode', 'value', 'onChange', 'readOnly', 'showFocusRing', 'editButtonPlacement', 'inline'];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ---
|
|
33
|
+
* private: true
|
|
34
|
+
* ---
|
|
35
|
+
* Generates the style object from the theme and provided additional information
|
|
36
|
+
* @param {Object} componentTheme The theme variable object.
|
|
37
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
38
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
39
|
+
* @return {Object} The final style object, which will be used in the component
|
|
40
|
+
*/
|
|
41
|
+
const generateStyle = () => {
|
|
42
|
+
return {
|
|
43
|
+
inPlaceEdit: {
|
|
44
|
+
label: 'inPlaceEdit',
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
maxWidth: '100%',
|
|
47
|
+
position: 'relative',
|
|
48
|
+
overflow: 'visible',
|
|
49
|
+
direction: 'inherit',
|
|
50
|
+
margin: 0,
|
|
51
|
+
textDecoration: 'none' /* for links styled as buttons */,
|
|
52
|
+
textAlign: 'inherit',
|
|
53
|
+
userSelect: 'none',
|
|
54
|
+
touchAction: 'manipulation',
|
|
55
|
+
background: 'transparent',
|
|
56
|
+
border: 'none',
|
|
57
|
+
outline: 'none'
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var _default = exports.default = generateStyle;
|
package/lib/exports/b.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Editable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _v.Editable;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "InPlaceEdit", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _v2.InPlaceEdit;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _v = require("../Editable/v1");
|
|
19
|
+
var _v2 = require("../InPlaceEdit/v2");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-editable",
|
|
3
|
-
"version": "11.7.2-snapshot-
|
|
3
|
+
"version": "11.7.2-snapshot-24",
|
|
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",
|
|
@@ -15,25 +15,25 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/console": "11.7.2-snapshot-
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/shared-types": "11.7.2-snapshot-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/
|
|
24
|
-
"@instructure/ui-flex": "11.7.2-snapshot-
|
|
25
|
-
"@instructure/ui-
|
|
26
|
-
"@instructure/ui-
|
|
27
|
-
"@instructure/ui-utils": "11.7.2-snapshot-
|
|
28
|
-
"@instructure/ui-
|
|
18
|
+
"@instructure/console": "11.7.2-snapshot-24",
|
|
19
|
+
"@instructure/ui-a11y-content": "11.7.2-snapshot-24",
|
|
20
|
+
"@instructure/shared-types": "11.7.2-snapshot-24",
|
|
21
|
+
"@instructure/ui-buttons": "11.7.2-snapshot-24",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.7.2-snapshot-24",
|
|
23
|
+
"@instructure/emotion": "11.7.2-snapshot-24",
|
|
24
|
+
"@instructure/ui-flex": "11.7.2-snapshot-24",
|
|
25
|
+
"@instructure/ui-focusable": "11.7.2-snapshot-24",
|
|
26
|
+
"@instructure/ui-view": "11.7.2-snapshot-24",
|
|
27
|
+
"@instructure/ui-utils": "11.7.2-snapshot-24",
|
|
28
|
+
"@instructure/ui-icons": "11.7.2-snapshot-24"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@testing-library/jest-dom": "^6.6.3",
|
|
32
32
|
"@testing-library/react": "15.0.7",
|
|
33
33
|
"@testing-library/user-event": "^14.6.1",
|
|
34
34
|
"vitest": "^3.2.2",
|
|
35
|
-
"@instructure/ui-axe-check": "11.7.2-snapshot-
|
|
36
|
-
"@instructure/ui-babel-preset": "11.7.2-snapshot-
|
|
35
|
+
"@instructure/ui-axe-check": "11.7.2-snapshot-24",
|
|
36
|
+
"@instructure/ui-babel-preset": "11.7.2-snapshot-24"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": ">=18 <=19",
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
"default": "./es/exports/a.js"
|
|
65
65
|
},
|
|
66
66
|
"./v11_7": {
|
|
67
|
-
"src": "./src/exports/
|
|
68
|
-
"types": "./types/exports/
|
|
69
|
-
"import": "./es/exports/
|
|
70
|
-
"require": "./lib/exports/
|
|
71
|
-
"default": "./es/exports/
|
|
67
|
+
"src": "./src/exports/b.ts",
|
|
68
|
+
"types": "./types/exports/b.d.ts",
|
|
69
|
+
"import": "./es/exports/b.js",
|
|
70
|
+
"require": "./lib/exports/b.js",
|
|
71
|
+
"default": "./es/exports/b.js"
|
|
72
72
|
},
|
|
73
73
|
"./latest": {
|
|
74
|
-
"src": "./src/exports/
|
|
75
|
-
"types": "./types/exports/
|
|
76
|
-
"import": "./es/exports/
|
|
77
|
-
"require": "./lib/exports/
|
|
78
|
-
"default": "./es/exports/
|
|
74
|
+
"src": "./src/exports/b.ts",
|
|
75
|
+
"types": "./types/exports/b.d.ts",
|
|
76
|
+
"import": "./es/exports/b.js",
|
|
77
|
+
"require": "./lib/exports/b.js",
|
|
78
|
+
"default": "./es/exports/b.js"
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|