@jetbrains/ring-ui 5.0.96 → 5.0.97
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.
|
@@ -11,7 +11,7 @@ export { Levels };
|
|
|
11
11
|
export { Size };
|
|
12
12
|
function noop() { }
|
|
13
13
|
export const EditableHeading = (props) => {
|
|
14
|
-
const { level = Levels.H1, className, headingClassName, inputClassName, children, isEditing = false, isSavingPossible = false, isSaving = false, embedded = false, size = Size.L, onEdit = noop, onSave = noop, onCancel = noop, autoFocus = true, 'data-test': dataTest, error, disabled, multiline = false, renderMenu = () => null, translations = {
|
|
14
|
+
const { level = Levels.H1, className, headingClassName, inputClassName, children, isEditing = false, isSavingPossible = false, isSaving = false, embedded = false, size = Size.L, onEdit = noop, onSave = noop, onCancel = noop, autoFocus = true, 'data-test': dataTest, error, disabled, multiline = false, renderMenu = () => null, onFocus, onBlur, translations = {
|
|
15
15
|
save: 'Save',
|
|
16
16
|
cancel: 'Cancel'
|
|
17
17
|
}, ...restProps } = props;
|
|
@@ -40,19 +40,21 @@ export const EditableHeading = (props) => {
|
|
|
40
40
|
}
|
|
41
41
|
return onEdit();
|
|
42
42
|
}, [disabled, onEdit]);
|
|
43
|
-
const onInputFocus = React.useCallback(() => {
|
|
43
|
+
const onInputFocus = React.useCallback((e) => {
|
|
44
44
|
setIsInFocus(true);
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
onFocus?.(e);
|
|
46
|
+
}, [onFocus]);
|
|
47
|
+
const onInputBlur = React.useCallback((e) => {
|
|
47
48
|
setIsInFocus(false);
|
|
48
|
-
|
|
49
|
+
onBlur?.(e);
|
|
50
|
+
}, [onBlur]);
|
|
49
51
|
return (<>
|
|
50
52
|
<div className={classes}>
|
|
51
53
|
{!disabled && isEditing
|
|
52
54
|
? (<>
|
|
53
55
|
<Shortcuts map={shortcutsMap} scope={shortcutsScope} disabled={isShortcutsDisabled}/>
|
|
54
56
|
|
|
55
|
-
<input className={inputClasses} value={children} autoFocus={autoFocus} data-test={dataTest} disabled={isSaving} onFocus={onInputFocus} onBlur={onInputBlur}
|
|
57
|
+
<input className={inputClasses} value={children} autoFocus={autoFocus} data-test={dataTest} disabled={isSaving} {...restProps} onFocus={onInputFocus} onBlur={onInputBlur}/>
|
|
56
58
|
</>)
|
|
57
59
|
: (<button type="button" className={styles.headingWrapperButton} onClick={onHeadingClick}>
|
|
58
60
|
<Heading className={headingClasses} level={level} data-test={dataTest}>{children}</Heading>
|
|
@@ -52,6 +52,8 @@ const EditableHeading = props => {
|
|
|
52
52
|
disabled,
|
|
53
53
|
multiline = false,
|
|
54
54
|
renderMenu = () => null,
|
|
55
|
+
onFocus,
|
|
56
|
+
onBlur,
|
|
55
57
|
translations = {
|
|
56
58
|
save: 'Save',
|
|
57
59
|
cancel: 'Cancel'
|
|
@@ -83,12 +85,14 @@ const EditableHeading = props => {
|
|
|
83
85
|
}
|
|
84
86
|
return onEdit();
|
|
85
87
|
}, [disabled, onEdit]);
|
|
86
|
-
const onInputFocus = React.useCallback(
|
|
88
|
+
const onInputFocus = React.useCallback(e => {
|
|
87
89
|
setIsInFocus(true);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
onFocus?.(e);
|
|
91
|
+
}, [onFocus]);
|
|
92
|
+
const onInputBlur = React.useCallback(e => {
|
|
90
93
|
setIsInFocus(false);
|
|
91
|
-
|
|
94
|
+
onBlur?.(e);
|
|
95
|
+
}, [onBlur]);
|
|
92
96
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
93
97
|
className: classes
|
|
94
98
|
}, !disabled && isEditing ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Shortcuts, {
|
|
@@ -100,10 +104,11 @@ const EditableHeading = props => {
|
|
|
100
104
|
value: children,
|
|
101
105
|
autoFocus: autoFocus,
|
|
102
106
|
"data-test": dataTest,
|
|
103
|
-
disabled: isSaving
|
|
107
|
+
disabled: isSaving
|
|
108
|
+
}, restProps, {
|
|
104
109
|
onFocus: onInputFocus,
|
|
105
110
|
onBlur: onInputBlur
|
|
106
|
-
}
|
|
111
|
+
}))) : /*#__PURE__*/React.createElement("button", {
|
|
107
112
|
type: "button",
|
|
108
113
|
className: modules_6e69b0fe.headingWrapperButton,
|
|
109
114
|
onClick: onHeadingClick
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.97",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@types/chai-dom": "0.0.10",
|
|
105
105
|
"@types/chai-enzyme": "^0.6.8",
|
|
106
106
|
"@types/enzyme": "^3.10.12",
|
|
107
|
-
"@types/react": "^18.0.
|
|
107
|
+
"@types/react": "^18.0.27",
|
|
108
108
|
"@types/react-dom": "^18.0.10",
|
|
109
109
|
"@types/sinon": "^10.0.13",
|
|
110
110
|
"@types/sinon-chai": "^3.2.9",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"chai-dom": "^1.10.0",
|
|
122
122
|
"chai-enzyme": "1.0.0-beta.1",
|
|
123
123
|
"cheerio": "^1.0.0-rc.12",
|
|
124
|
-
"core-js": "^3.27.
|
|
124
|
+
"core-js": "^3.27.2",
|
|
125
125
|
"cpy-cli": "^3.1.1",
|
|
126
126
|
"enzyme": "^3.11.0",
|
|
127
127
|
"eslint": "^8.32.0",
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
"react-test-renderer": "^18.2.0",
|
|
158
158
|
"regenerator-runtime": "^0.13.11",
|
|
159
159
|
"rimraf": "^4.1.1",
|
|
160
|
-
"rollup": "^3.10.
|
|
160
|
+
"rollup": "^3.10.1",
|
|
161
161
|
"rollup-plugin-clear": "^2.0.7",
|
|
162
162
|
"rollup-plugin-styles": "^4.0.0",
|
|
163
163
|
"sinon": "^15.0.1",
|