@instructure/ui-editable 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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.
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { EditableState } from './props';
2
+ import { EditableState } from './props.js';
3
3
  import type { EditableProps, GetContainerProps, GetEditButtonProps, GetEditorProps, GetViewerProps } from './props';
4
4
  /**
5
5
  ---
@@ -7,11 +7,12 @@ category: components
7
7
  ---
8
8
  **/
9
9
  declare class Editable extends Component<EditableProps> {
10
+ static displayName: string;
10
11
  static allowedProps: readonly (keyof {
11
12
  mode: "view" | "edit";
12
13
  onChangeMode: (newMode: string) => void;
13
- children?: (props: import("./props").EditableRenderProps) => React.ReactNode;
14
- render?: (props: import("./props").EditableRenderProps) => React.ReactNode;
14
+ children?: (props: import("./props.js").EditableRenderProps) => React.ReactNode;
15
+ render?: (props: import("./props.js").EditableRenderProps) => React.ReactNode;
15
16
  value?: any;
16
17
  onChange?: (value: any) => void;
17
18
  readOnly?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Editable/v1/index.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMjC,OAAO,EAAgB,aAAa,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,SAAS,CAAA;AAEhB;;;;GAIG;AACH,cAAM,QAAS,SAAQ,SAAS,CAAC,aAAa,CAAC;IAC7C,MAAM,CAAC,YAAY;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;MAGlB;IAED,KAAK,EAAE,aAAa,CAGnB;IAED,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAO;IAC1C,cAAc,EAAE,iBAAiB,GAAG,IAAI,CAAO;gBAEnC,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E,iBAAiB,GAAG,IAAI,CAAO;gBAEnC,KAAK,EAAE,aAAa;IAShC,iBAAiB;IAMjB,kBAAkB,CAAC,SAAS,EAAE,aAAa;IAkB3C,WAAW;IAUX,SAAS;IAOT,SAAS;IAST,aAAa,GAAI,OAAO,KAAK,CAAC,aAAa,UAK1C;IAED,mBAAmB,GAAI,OAAO,KAAK,CAAC,UAAU,UAM7C;IAED,kBAAkB,GAAI,OAAO,KAAK,CAAC,UAAU,UAO5C;IAED,eAAe,GAAI,OAAO,KAAK,CAAC,UAAU,UAMzC;IAED,cAAc,aAEb;IAED,qBAAqB,aAEpB;IAED,oBAAoB,aAEnB;IAED,qBAAqB,aAEpB;IAED,GAAG,EAAE,OAAO,GAAG,IAAI,CAAO;IAE1B,kBAAkB,GAAI,IAAI,OAAO,GAAG,IAAI,UAQvC;IAGD,iBAAiB,EAAE,iBAAiB,CAWnC;IAED,cAAc,EAAE,cAAc,CAM7B;IAED,cAAc,EAAE,cAAc,CAU7B;IAED,kBAAkB,EAAE,kBAAkB,CAYrC;IAED,MAAM;CAeP;AAED,eAAe,QAAQ,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -8,6 +8,7 @@ category: components
8
8
  ---
9
9
  **/
10
10
  declare class InPlaceEdit extends Component<InPlaceEditProps> {
11
+ static displayName: string;
11
12
  static readonly componentId = "InPlaceEdit";
12
13
  static allowedProps: readonly (keyof {
13
14
  renderViewer: () => React.ReactNode;
@@ -24,9 +25,9 @@ declare class InPlaceEdit extends Component<InPlaceEditProps> {
24
25
  readOnly?: boolean;
25
26
  }) => React.ReactNode | null;
26
27
  mode: "view" | "edit";
27
- onChangeMode: import("../../exports/b").EditableProps["onChangeMode"];
28
+ onChangeMode: import("../../exports/b.js").EditableProps["onChangeMode"];
28
29
  value?: any;
29
- onChange?: import("../../exports/b").EditableProps["onChange"];
30
+ onChange?: import("../../exports/b.js").EditableProps["onChange"];
30
31
  readOnly?: boolean;
31
32
  showFocusRing?: bool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GAAG,IAAI,EACR,EAAE,UAAU,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;IASxD,MAAM,CAAC,uBAAuB,GAAI,gDAK/B;QACD,SAAS,EAAE,OAAO,CAAA;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;KACd,GAAG,OAAO,CAAC,eAAe,CAAC,6DAe3B;IAED,SAAS,GAAI,2EAKV,mBAAmB,sDAwBrB;IAED,MAAM;CAeP;AAED,eAAe,WAAW,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -8,6 +8,7 @@ category: components
8
8
  ---
9
9
  **/
10
10
  declare class InPlaceEdit extends Component<InPlaceEditProps> {
11
+ static displayName: string;
11
12
  static readonly componentId = "InPlaceEdit";
12
13
  static allowedProps: readonly (keyof {
13
14
  renderViewer: () => React.ReactNode;
@@ -24,9 +25,9 @@ declare class InPlaceEdit extends Component<InPlaceEditProps> {
24
25
  readOnly?: boolean;
25
26
  }) => React.ReactNode | null;
26
27
  mode: "view" | "edit";
27
- onChangeMode: import("../../exports/b").EditableProps["onChangeMode"];
28
+ onChangeMode: import("../../exports/b.js").EditableProps["onChangeMode"];
28
29
  value?: any;
29
- onChange?: import("../../exports/b").EditableProps["onChange"];
30
+ onChange?: import("../../exports/b.js").EditableProps["onChange"];
30
31
  readOnly?: boolean;
31
32
  showFocusRing?: boolean;
32
33
  editButtonPlacement?: "start" | "end";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/InPlaceEdit/v2/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAIjC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAWrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAElE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EAAE,CAAA"}
@@ -1,5 +1,5 @@
1
- export { Editable } from '../Editable/v1';
2
- export { InPlaceEdit } from '../InPlaceEdit/v1';
1
+ export { Editable } from '../Editable/v1/index.js';
2
+ export { InPlaceEdit } from '../InPlaceEdit/v1/index.js';
3
3
  export type { EditableProps } from '../Editable/v1/props';
4
4
  export type { InPlaceEditProps } from '../InPlaceEdit/v1/props';
5
5
  //# sourceMappingURL=a.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,5 +1,5 @@
1
- export { Editable } from '../Editable/v1';
2
- export { InPlaceEdit } from '../InPlaceEdit/v2';
1
+ export { Editable } from '../Editable/v1/index.js';
2
+ export { InPlaceEdit } from '../InPlaceEdit/v2/index.js';
3
3
  export type { EditableProps } from '../Editable/v1/props';
4
4
  export type { InPlaceEditProps } from '../InPlaceEdit/v2/props';
5
5
  //# sourceMappingURL=b.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
1
+ {"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAExD,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA"}
@@ -1,234 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.Editable = void 0;
7
- var _react = require("react");
8
- var _deepEqual = require("@instructure/ui-utils/lib/deepEqual.js");
9
- var _console = require("@instructure/console");
10
- var _requestAnimationFrame = require("@instructure/ui-dom-utils/lib/requestAnimationFrame.js");
11
- var _props = require("./props");
12
- /*
13
- * The MIT License (MIT)
14
- *
15
- * Copyright (c) 2018 - present Instructure, Inc.
16
- *
17
- * Permission is hereby granted, free of charge, to any person obtaining a copy
18
- * of this software and associated documentation files (the "Software"), to deal
19
- * in the Software without restriction, including without limitation the rights
20
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
- * copies of the Software, and to permit persons to whom the Software is
22
- * furnished to do so, subject to the following conditions:
23
- *
24
- * The above copyright notice and this permission notice shall be included in all
25
- * copies or substantial portions of the Software.
26
- *
27
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
- * SOFTWARE.
34
- */
35
-
36
- /**
37
- ---
38
- category: components
39
- ---
40
- **/
41
- class Editable extends _react.Component {
42
- static displayName = "Editable";
43
- static allowedProps = _props.allowedProps;
44
- static defaultProps = {
45
- readOnly: false,
46
- children: null
47
- };
48
- state = {
49
- showModeToggle: false,
50
- valueOnEdit: null // the value when mode flips from view -> edit
51
- };
52
- _editorRef = null;
53
- _editButtonRef = null;
54
- constructor(props) {
55
- super(props);
56
- (0, _console.logWarn)(props.readOnly ? props.mode === 'view' : true, '[Editable] When readOnly is true, mode must be "view"');
57
- }
58
- componentDidMount() {
59
- if (this.props.mode === 'edit') {
60
- this.focusEditor();
61
- }
62
- }
63
- componentDidUpdate(prevProps) {
64
- const {
65
- mode,
66
- value,
67
- onChange
68
- } = this.props;
69
-
70
- // on the switch from view -> edit
71
- if (prevProps.mode !== 'edit' && mode === 'edit') {
72
- this.setState({
73
- valueOnEdit: value
74
- });
75
- this.focusEditor();
76
- }
77
-
78
- // on the switch from edit to view
79
- if (prevProps.mode === 'edit' && mode !== 'edit') {
80
- this._editButtonRef && this._editButtonRef.focus();
81
- if (onChange && !(0, _deepEqual.deepEqual)(this.state.valueOnEdit, value)) {
82
- onChange(value);
83
- }
84
- }
85
- }
86
- focusEditor() {
87
- (0, _console.logWarn)(!!this._editorRef && !this.props.readOnly, '[Editable] Did you forget to connect editorRef to your editor component?');
88
- if (this._editorRef) {
89
- this._editorRef.focus();
90
- }
91
- }
92
- enterView() {
93
- if (this.props.mode !== 'view') {
94
- this.setState({
95
- showModeToggle: true
96
- });
97
- this.props.onChangeMode('view');
98
- }
99
- }
100
- enterEdit() {
101
- if (!this.props.readOnly) {
102
- this.setState({
103
- showModeToggle: false
104
- });
105
- if (this.props.mode !== 'edit') {
106
- this.props.onChangeMode('edit');
107
- }
108
- }
109
- }
110
- handleEditESC = event => {
111
- if (event.key === 'Escape') {
112
- event.stopPropagation();
113
- this.enterView();
114
- }
115
- };
116
- handleViewMouseOver = event => {
117
- if (this.props.mode === 'view') {
118
- // because the mouse event handlers are on the container, not the view
119
- event.stopPropagation();
120
- this.setState({
121
- showModeToggle: true
122
- });
123
- }
124
- };
125
- handleViewMouseOut = event => {
126
- if (this.props.mode === 'view') {
127
- event.stopPropagation();
128
- this.setState({
129
- showModeToggle: document.activeElement === this._editButtonRef
130
- });
131
- }
132
- };
133
- handleViewClick = event => {
134
- if (event.buttons === 1) {
135
- (0, _requestAnimationFrame.requestAnimationFrame)(() => {
136
- this.enterEdit();
137
- });
138
- }
139
- };
140
- handleEditBlur = () => {
141
- this.enterView();
142
- };
143
- handleEditButtonFocus = () => {
144
- this.setState({
145
- showModeToggle: true
146
- });
147
- };
148
- handleEditButtonBlur = () => {
149
- this.setState({
150
- showModeToggle: false
151
- });
152
- };
153
- handleEditButtonClick = () => {
154
- this.enterEdit();
155
- };
156
- ref = null;
157
- handleContainerRef = el => {
158
- const {
159
- elementRef
160
- } = this.props;
161
- this.ref = el;
162
- if (typeof elementRef === 'function') {
163
- elementRef(el);
164
- }
165
- };
166
-
167
- // ------- prop getters ------
168
- getContainerProps = (props = {}) => {
169
- const {
170
- mode,
171
- readOnly
172
- } = this.props;
173
- return {
174
- onMouseOver: this.handleViewMouseOver,
175
- onMouseOut: this.handleViewMouseOut,
176
- onMouseDown: mode !== 'edit' ? this.handleViewClick : undefined,
177
- onKeyUp: mode === 'edit' ? this.handleEditESC : undefined,
178
- readOnly,
179
- ...props,
180
- ref: this.handleContainerRef
181
- };
182
- };
183
- getViewerProps = (props = {}) => {
184
- return {
185
- mode: this.props.mode,
186
- readOnly: this.props.readOnly,
187
- ...props
188
- };
189
- };
190
- getEditorProps = (props = {}) => {
191
- return {
192
- mode: this.props.mode,
193
- onBlur: this.handleEditBlur,
194
- editorRef: el => {
195
- this._editorRef = el;
196
- },
197
- readOnly: this.props.readOnly,
198
- ...props
199
- };
200
- };
201
- getEditButtonProps = (props = {}) => {
202
- return {
203
- onClick: this.handleEditButtonClick,
204
- onFocus: this.handleEditButtonFocus,
205
- onBlur: this.handleEditButtonBlur,
206
- isVisible: this.state.showModeToggle,
207
- buttonRef: el => {
208
- this._editButtonRef = el;
209
- },
210
- readOnly: this.props.readOnly,
211
- ...props
212
- };
213
- };
214
- render() {
215
- const {
216
- children,
217
- render = children,
218
- mode
219
- } = this.props;
220
- if (typeof render === 'function') {
221
- return render({
222
- mode,
223
- getContainerProps: this.getContainerProps,
224
- getViewerProps: this.getViewerProps,
225
- getEditorProps: this.getEditorProps,
226
- getEditButtonProps: this.getEditButtonProps
227
- });
228
- } else {
229
- return null;
230
- }
231
- }
232
- }
233
- exports.Editable = Editable;
234
- var _default = exports.default = Editable;
@@ -1,181 +0,0 @@
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 _v11_ = require("@instructure/ui-flex/v11_6");
10
- var _v11_2 = require("@instructure/ui-buttons/v11_6");
11
- var _IconEditLine = require("@instructure/ui-icons/lib/generated/IconEditLine.js");
12
- var _console = require("@instructure/console");
13
- var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
14
- var _emotion = require("@instructure/emotion");
15
- var _v11_3 = require("@instructure/ui-view/v11_6");
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;
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, null), _dec(_class = class InPlaceEdit extends _react.Component {
50
- static displayName = "InPlaceEdit";
51
- static componentId = 'InPlaceEdit';
52
- static allowedProps = _props.allowedProps;
53
- static defaultProps = {
54
- readOnly: false,
55
- showFocusRing: true,
56
- inline: true,
57
- editButtonPlacement: 'end'
58
- };
59
- ref = null;
60
- _editButtonRef = null;
61
- handleRef = el => {
62
- this.ref = el;
63
- };
64
- constructor(props) {
65
- super(props);
66
- (0, _console.logWarn)(props.readOnly ? props.mode === 'view' : true, '[InPlaceEdit] When readOnly is true, mode is forced to "view"');
67
- }
68
- componentDidMount() {
69
- this.props.makeStyles?.();
70
- }
71
- componentDidUpdate() {
72
- this.props.makeStyles?.();
73
- }
74
- handleEditButtonRef = el => {
75
- this._editButtonRef = el;
76
- };
77
- renderEditor({
78
- mode,
79
- onBlur,
80
- editorRef,
81
- readOnly
82
- }) {
83
- const {
84
- showFocusRing,
85
- renderEditor
86
- } = this.props;
87
- const isEditMode = !readOnly && mode === 'edit';
88
- return isEditMode ? (0, _jsxRuntime.jsx)(_v11_3.View, {
89
- as: "span",
90
- display: "block",
91
- withFocusOutline: showFocusRing,
92
- position: "relative",
93
- css: this.props.styles?.inPlaceEdit,
94
- borderRadius: "medium",
95
- margin: "auto",
96
- children: renderEditor({
97
- onBlur,
98
- editorRef
99
- })
100
- }) : null;
101
- }
102
- renderViewer({
103
- readOnly,
104
- mode
105
- }) {
106
- return readOnly || mode === 'view' ? this.props.renderViewer() : null;
107
- }
108
- renderEditButton({
109
- buttonRef,
110
- ...rest
111
- }) {
112
- return this.props.renderEditButton({
113
- elementRef: (0, _createChainedFunction.createChainedFunction)(this.handleEditButtonRef, buttonRef),
114
- ...rest
115
- });
116
- }
117
-
118
- // Render a default edit button, an icon button with the edit icon
119
- // the margin makes room for the focus ring
120
- static renderDefaultEditButton = ({
121
- isVisible,
122
- readOnly,
123
- label,
124
- ...buttonProps
125
- }) => {
126
- if (readOnly) {
127
- return null;
128
- }
129
- return (0, _jsxRuntime.jsx)(_v11_2.IconButton, {
130
- size: "small",
131
- screenReaderLabel: label,
132
- withBackground: false,
133
- withBorder: false,
134
- ...buttonProps,
135
- children: isVisible ? _IconEditLine.IconEditLine : null
136
- });
137
- };
138
- renderAll = ({
139
- getContainerProps,
140
- getViewerProps,
141
- getEditorProps,
142
- getEditButtonProps
143
- }) => {
144
- const flexDir = this.props.editButtonPlacement === 'start' ? 'row-reverse' : 'row';
145
- const justifyItems = flexDir === 'row-reverse' ? 'end' : 'start';
146
- const buttonMargin = this.props.editButtonPlacement === 'start' ? '0 xx-small 0 0' : '0 0 0 xx-small';
147
- return (0, _jsxRuntime.jsxs)(_v11_.Flex, {
148
- display: this.props.inline ? 'inline-flex' : 'flex',
149
- direction: flexDir,
150
- justifyItems: justifyItems,
151
- ...getContainerProps(),
152
- children: [(0, _jsxRuntime.jsxs)(_v11_.Flex.Item, {
153
- shouldGrow: true,
154
- shouldShrink: true,
155
- children: [this.renderEditor(getEditorProps()), this.renderViewer(getViewerProps())]
156
- }), (0, _jsxRuntime.jsx)(_v11_.Flex.Item, {
157
- margin: buttonMargin,
158
- children: this.renderEditButton(getEditButtonProps())
159
- })]
160
- });
161
- };
162
- render() {
163
- const {
164
- mode,
165
- value,
166
- onChange,
167
- onChangeMode,
168
- readOnly
169
- } = this.props;
170
- return (0, _jsxRuntime.jsx)(_v.Editable, {
171
- mode: mode,
172
- onChangeMode: onChangeMode,
173
- render: this.renderAll,
174
- value: value,
175
- onChange: onChange,
176
- readOnly: readOnly,
177
- elementRef: this.handleRef
178
- });
179
- }
180
- }) || _class);
181
- var _default = exports.default = InPlaceEdit;
@@ -1,31 +0,0 @@
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'];
@@ -1,61 +0,0 @@
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;