@jetbrains/ring-ui 5.0.104 → 5.0.105
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/components/editable-heading/editable-heading.js +10 -4
- package/components/http/http.d.ts +10 -0
- package/components/http/http.js +14 -0
- package/components/input/input.d.ts +7 -0
- package/components/input/input.js +7 -3
- package/components/user-card/card.d.ts +3 -3
- package/components/user-card/card.js +3 -3
- package/dist/_helpers/card.js +3 -3
- package/dist/editable-heading/editable-heading.js +10 -4
- package/dist/http/http.d.ts +10 -0
- package/dist/http/http.js +16 -2
- package/dist/input/input.d.ts +7 -0
- package/dist/input/input.js +7 -2
- package/dist/user-card/card.d.ts +3 -3
- package/package.json +7 -7
|
@@ -21,10 +21,16 @@ export const EditableHeading = (props) => {
|
|
|
21
21
|
const isSaveDisabled = !isSavingPossible || !children || children.trim() === '' || hasError || isSaving;
|
|
22
22
|
const isCancelDisabled = isSaving;
|
|
23
23
|
const isShortcutsDisabled = !isInFocus || isSaving;
|
|
24
|
-
const shortcutsMap = React.useMemo(() =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
const shortcutsMap = React.useMemo(() => {
|
|
25
|
+
const map = {};
|
|
26
|
+
if (!isSaveDisabled) {
|
|
27
|
+
map.enter = onSave;
|
|
28
|
+
}
|
|
29
|
+
if (isCancelDisabled) {
|
|
30
|
+
map.esc = onCancel;
|
|
31
|
+
}
|
|
32
|
+
return map;
|
|
33
|
+
}, [isSaveDisabled, isCancelDisabled, onSave, onCancel]);
|
|
28
34
|
const classes = classNames(styles.editableHeading, className, {
|
|
29
35
|
[styles.fullSize]: isEditing && size === Size.FULL,
|
|
30
36
|
[styles.isEditing]: isEditing,
|
|
@@ -11,6 +11,7 @@ export declare class HTTPError extends ExtendableError {
|
|
|
11
11
|
export declare const CODE: {
|
|
12
12
|
UNAUTHORIZED: number;
|
|
13
13
|
};
|
|
14
|
+
type Method<T> = (url: string, params?: RequestParams) => Promise<T>;
|
|
14
15
|
export interface FetchParams<T = unknown> extends Omit<RequestInit, 'body' | 'headers'> {
|
|
15
16
|
body?: T;
|
|
16
17
|
query?: Record<string, unknown> | undefined;
|
|
@@ -48,4 +49,13 @@ export default class HTTP implements Partial<HTTPAuth> {
|
|
|
48
49
|
post: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
49
50
|
delete: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
50
51
|
put: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Usage: const {promise, abort} = http.abortify(http.get<{id: string}>)('http://test.com');
|
|
54
|
+
* @param method
|
|
55
|
+
*/
|
|
56
|
+
abortify: <T>(method: Method<T>) => (url: string, params?: RequestParams<boolean> | undefined) => {
|
|
57
|
+
promise: Promise<T>;
|
|
58
|
+
abort: () => void;
|
|
59
|
+
};
|
|
51
60
|
}
|
|
61
|
+
export {};
|
package/components/http/http.js
CHANGED
|
@@ -187,4 +187,18 @@ export default class HTTP {
|
|
|
187
187
|
...params,
|
|
188
188
|
method: 'PUT'
|
|
189
189
|
}));
|
|
190
|
+
/**
|
|
191
|
+
* Usage: const {promise, abort} = http.abortify(http.get<{id: string}>)('http://test.com');
|
|
192
|
+
* @param method
|
|
193
|
+
*/
|
|
194
|
+
abortify = (method) => (...[url, params]) => {
|
|
195
|
+
const ctrl = new AbortController();
|
|
196
|
+
if (params && !('signal' in params)) {
|
|
197
|
+
params.signal = ctrl.signal;
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
promise: method.call(this, url, params),
|
|
201
|
+
abort: () => ctrl.abort()
|
|
202
|
+
};
|
|
203
|
+
};
|
|
190
204
|
}
|
|
@@ -11,6 +11,9 @@ declare enum Size {
|
|
|
11
11
|
L = "L",
|
|
12
12
|
FULL = "FULL"
|
|
13
13
|
}
|
|
14
|
+
export interface InputTranslations {
|
|
15
|
+
clear: string;
|
|
16
|
+
}
|
|
14
17
|
export interface InputBaseProps {
|
|
15
18
|
size: Size;
|
|
16
19
|
enableShortcuts: boolean | string[];
|
|
@@ -25,6 +28,7 @@ export interface InputBaseProps {
|
|
|
25
28
|
icon?: string | ComponentType | null | undefined;
|
|
26
29
|
height?: ControlsHeight | undefined;
|
|
27
30
|
afterInput?: ReactNode;
|
|
31
|
+
translations: InputTranslations;
|
|
28
32
|
}
|
|
29
33
|
type Override<D, S> = Omit<D, keyof S> & S;
|
|
30
34
|
export type InputSpecificProps = Override<InputHTMLAttributes<HTMLInputElement>, InputBaseProps> & {
|
|
@@ -42,6 +46,9 @@ export declare class Input extends PureComponent<InputProps> {
|
|
|
42
46
|
onChange: typeof noop;
|
|
43
47
|
inputRef: typeof noop;
|
|
44
48
|
enableShortcuts: string[];
|
|
49
|
+
translations: {
|
|
50
|
+
clear: string;
|
|
51
|
+
};
|
|
45
52
|
};
|
|
46
53
|
state: {
|
|
47
54
|
empty: boolean;
|
|
@@ -27,7 +27,10 @@ export class Input extends PureComponent {
|
|
|
27
27
|
size: Size.M,
|
|
28
28
|
onChange: noop,
|
|
29
29
|
inputRef: noop,
|
|
30
|
-
enableShortcuts: ['esc']
|
|
30
|
+
enableShortcuts: ['esc'],
|
|
31
|
+
translations: {
|
|
32
|
+
clear: 'Clear input'
|
|
33
|
+
}
|
|
31
34
|
};
|
|
32
35
|
state = {
|
|
33
36
|
empty: true
|
|
@@ -92,7 +95,7 @@ export class Input extends PureComponent {
|
|
|
92
95
|
// Modifiers
|
|
93
96
|
size, active, multiline, borderless,
|
|
94
97
|
// Props
|
|
95
|
-
label, error, className, inputClassName, children, value, onClear, disabled, inputRef, onChange, enableShortcuts, id, placeholder, icon, height = this.context, afterInput, ...restProps } = this.props;
|
|
98
|
+
label, error, className, inputClassName, children, value, onClear, disabled, inputRef, onChange, enableShortcuts, id, placeholder, icon, translations, height = this.context, afterInput, ...restProps } = this.props;
|
|
96
99
|
const { empty } = this.state;
|
|
97
100
|
const clearable = !!onClear;
|
|
98
101
|
const classes = classNames(className, styles.outerContainer, [styles[`size${size}`]], [styles[`height${height}`]], {
|
|
@@ -124,7 +127,7 @@ export class Input extends PureComponent {
|
|
|
124
127
|
{multiline
|
|
125
128
|
? (<textarea onChange={this.handleTextareaChange} rows={1} {...commonProps} {...restProps}/>)
|
|
126
129
|
: (<input onChange={this.handleInputChange} {...commonProps} {...restProps}/>)}
|
|
127
|
-
{clearable && !disabled && (<Button title=
|
|
130
|
+
{clearable && !disabled && (<Button title={translations.clear} data-test="ring-input-clear" className={styles.clear} icon={closeIcon} onClick={this.clear}/>)}
|
|
128
131
|
{afterInput}
|
|
129
132
|
</div>
|
|
130
133
|
{error && <div className={styles.errorText}>{error}</div>}
|
|
@@ -155,6 +158,7 @@ Input.propTypes = {
|
|
|
155
158
|
disabled: PropTypes.bool,
|
|
156
159
|
id: PropTypes.string,
|
|
157
160
|
placeholder: PropTypes.string,
|
|
161
|
+
translations: PropTypes.object,
|
|
158
162
|
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType])
|
|
159
163
|
};
|
|
160
164
|
export default Input;
|
|
@@ -47,9 +47,9 @@ export default class UserCard extends PureComponent<UserCardProps> {
|
|
|
47
47
|
banned: PropTypes.Validator<string>;
|
|
48
48
|
online: PropTypes.Validator<string>;
|
|
49
49
|
offline: PropTypes.Validator<string>;
|
|
50
|
-
copyToClipboard: PropTypes.
|
|
51
|
-
copiedToClipboard: PropTypes.
|
|
52
|
-
copingToClipboardError: PropTypes.
|
|
50
|
+
copyToClipboard: PropTypes.Requireable<string>;
|
|
51
|
+
copiedToClipboard: PropTypes.Requireable<string>;
|
|
52
|
+
copingToClipboardError: PropTypes.Requireable<string>;
|
|
53
53
|
unverified: PropTypes.Requireable<string>;
|
|
54
54
|
}>>;
|
|
55
55
|
};
|
|
@@ -28,9 +28,9 @@ export default class UserCard extends PureComponent {
|
|
|
28
28
|
banned: PropTypes.string.isRequired,
|
|
29
29
|
online: PropTypes.string.isRequired,
|
|
30
30
|
offline: PropTypes.string.isRequired,
|
|
31
|
-
copyToClipboard: PropTypes.string
|
|
32
|
-
copiedToClipboard: PropTypes.string
|
|
33
|
-
copingToClipboardError: PropTypes.string
|
|
31
|
+
copyToClipboard: PropTypes.string,
|
|
32
|
+
copiedToClipboard: PropTypes.string,
|
|
33
|
+
copingToClipboardError: PropTypes.string,
|
|
34
34
|
unverified: PropTypes.string
|
|
35
35
|
})
|
|
36
36
|
};
|
package/dist/_helpers/card.js
CHANGED
|
@@ -105,9 +105,9 @@ _defineProperty(UserCard, "propTypes", {
|
|
|
105
105
|
banned: PropTypes.string.isRequired,
|
|
106
106
|
online: PropTypes.string.isRequired,
|
|
107
107
|
offline: PropTypes.string.isRequired,
|
|
108
|
-
copyToClipboard: PropTypes.string
|
|
109
|
-
copiedToClipboard: PropTypes.string
|
|
110
|
-
copingToClipboardError: PropTypes.string
|
|
108
|
+
copyToClipboard: PropTypes.string,
|
|
109
|
+
copiedToClipboard: PropTypes.string,
|
|
110
|
+
copingToClipboardError: PropTypes.string,
|
|
111
111
|
unverified: PropTypes.string
|
|
112
112
|
})
|
|
113
113
|
});
|
|
@@ -66,10 +66,16 @@ const EditableHeading = props => {
|
|
|
66
66
|
const isSaveDisabled = !isSavingPossible || !children || children.trim() === '' || hasError || isSaving;
|
|
67
67
|
const isCancelDisabled = isSaving;
|
|
68
68
|
const isShortcutsDisabled = !isInFocus || isSaving;
|
|
69
|
-
const shortcutsMap = React.useMemo(() =>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
const shortcutsMap = React.useMemo(() => {
|
|
70
|
+
const map = {};
|
|
71
|
+
if (!isSaveDisabled) {
|
|
72
|
+
map.enter = onSave;
|
|
73
|
+
}
|
|
74
|
+
if (isCancelDisabled) {
|
|
75
|
+
map.esc = onCancel;
|
|
76
|
+
}
|
|
77
|
+
return map;
|
|
78
|
+
}, [isSaveDisabled, isCancelDisabled, onSave, onCancel]);
|
|
73
79
|
const classes = classNames(modules_6e69b0fe.editableHeading, className, {
|
|
74
80
|
[modules_6e69b0fe.fullSize]: isEditing && size === Size.FULL,
|
|
75
81
|
[modules_6e69b0fe.isEditing]: isEditing,
|
package/dist/http/http.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class HTTPError extends ExtendableError {
|
|
|
11
11
|
export declare const CODE: {
|
|
12
12
|
UNAUTHORIZED: number;
|
|
13
13
|
};
|
|
14
|
+
type Method<T> = (url: string, params?: RequestParams) => Promise<T>;
|
|
14
15
|
export interface FetchParams<T = unknown> extends Omit<RequestInit, 'body' | 'headers'> {
|
|
15
16
|
body?: T;
|
|
16
17
|
query?: Record<string, unknown> | undefined;
|
|
@@ -48,4 +49,13 @@ export default class HTTP implements Partial<HTTPAuth> {
|
|
|
48
49
|
post: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
49
50
|
delete: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
50
51
|
put: <T = any>(url: string, params?: RequestParamsWithoutMethod) => Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Usage: const {promise, abort} = http.abortify(http.get<{id: string}>)('http://test.com');
|
|
54
|
+
* @param method
|
|
55
|
+
*/
|
|
56
|
+
abortify: <T>(method: Method<T>) => (url: string, params?: RequestParams<boolean> | undefined) => {
|
|
57
|
+
promise: Promise<T>;
|
|
58
|
+
abort: () => void;
|
|
59
|
+
};
|
|
51
60
|
}
|
|
61
|
+
export {};
|
package/dist/http/http.js
CHANGED
|
@@ -99,6 +99,20 @@ class HTTP {
|
|
|
99
99
|
...params,
|
|
100
100
|
method: 'PUT'
|
|
101
101
|
}));
|
|
102
|
+
_defineProperty(this, "abortify", method => function () {
|
|
103
|
+
for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
104
|
+
_ref[_key] = arguments[_key];
|
|
105
|
+
}
|
|
106
|
+
let [url, params] = _ref;
|
|
107
|
+
const ctrl = new AbortController();
|
|
108
|
+
if (params && !('signal' in params)) {
|
|
109
|
+
params.signal = ctrl.signal;
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
promise: method.call(_this, url, params),
|
|
113
|
+
abort: () => ctrl.abort()
|
|
114
|
+
};
|
|
115
|
+
});
|
|
102
116
|
if (_auth) {
|
|
103
117
|
this.setAuth(_auth);
|
|
104
118
|
}
|
|
@@ -139,8 +153,8 @@ class HTTP {
|
|
|
139
153
|
} : {}),
|
|
140
154
|
...headers
|
|
141
155
|
};
|
|
142
|
-
Object.entries(combinedHeaders).forEach(
|
|
143
|
-
let [key, header] =
|
|
156
|
+
Object.entries(combinedHeaders).forEach(_ref2 => {
|
|
157
|
+
let [key, header] = _ref2;
|
|
144
158
|
if (header === null || header === undefined) {
|
|
145
159
|
Reflect.deleteProperty(combinedHeaders, key);
|
|
146
160
|
}
|
package/dist/input/input.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ declare enum Size {
|
|
|
11
11
|
L = "L",
|
|
12
12
|
FULL = "FULL"
|
|
13
13
|
}
|
|
14
|
+
export interface InputTranslations {
|
|
15
|
+
clear: string;
|
|
16
|
+
}
|
|
14
17
|
export interface InputBaseProps {
|
|
15
18
|
size: Size;
|
|
16
19
|
enableShortcuts: boolean | string[];
|
|
@@ -25,6 +28,7 @@ export interface InputBaseProps {
|
|
|
25
28
|
icon?: string | ComponentType | null | undefined;
|
|
26
29
|
height?: ControlsHeight | undefined;
|
|
27
30
|
afterInput?: ReactNode;
|
|
31
|
+
translations: InputTranslations;
|
|
28
32
|
}
|
|
29
33
|
type Override<D, S> = Omit<D, keyof S> & S;
|
|
30
34
|
export type InputSpecificProps = Override<InputHTMLAttributes<HTMLInputElement>, InputBaseProps> & {
|
|
@@ -42,6 +46,9 @@ export declare class Input extends PureComponent<InputProps> {
|
|
|
42
46
|
onChange: typeof noop;
|
|
43
47
|
inputRef: typeof noop;
|
|
44
48
|
enableShortcuts: string[];
|
|
49
|
+
translations: {
|
|
50
|
+
clear: string;
|
|
51
|
+
};
|
|
45
52
|
};
|
|
46
53
|
state: {
|
|
47
54
|
empty: boolean;
|
package/dist/input/input.js
CHANGED
|
@@ -115,6 +115,7 @@ class Input extends PureComponent {
|
|
|
115
115
|
id,
|
|
116
116
|
placeholder,
|
|
117
117
|
icon,
|
|
118
|
+
translations,
|
|
118
119
|
height = this.context,
|
|
119
120
|
afterInput,
|
|
120
121
|
...restProps
|
|
@@ -163,7 +164,7 @@ class Input extends PureComponent {
|
|
|
163
164
|
}, commonProps, restProps)) : /*#__PURE__*/React.createElement("input", _extends({
|
|
164
165
|
onChange: this.handleInputChange
|
|
165
166
|
}, commonProps, restProps)), clearable && !disabled && /*#__PURE__*/React.createElement(Button, {
|
|
166
|
-
title:
|
|
167
|
+
title: translations.clear,
|
|
167
168
|
"data-test": "ring-input-clear",
|
|
168
169
|
className: modules_88cfaf40.clear,
|
|
169
170
|
icon: closeIcon,
|
|
@@ -177,7 +178,10 @@ _defineProperty(Input, "defaultProps", {
|
|
|
177
178
|
size: Size.M,
|
|
178
179
|
onChange: noop,
|
|
179
180
|
inputRef: noop,
|
|
180
|
-
enableShortcuts: ['esc']
|
|
181
|
+
enableShortcuts: ['esc'],
|
|
182
|
+
translations: {
|
|
183
|
+
clear: 'Clear input'
|
|
184
|
+
}
|
|
181
185
|
});
|
|
182
186
|
_defineProperty(Input, "contextType", ControlsHeightContext);
|
|
183
187
|
Input.propTypes = {
|
|
@@ -197,6 +201,7 @@ Input.propTypes = {
|
|
|
197
201
|
disabled: PropTypes.bool,
|
|
198
202
|
id: PropTypes.string,
|
|
199
203
|
placeholder: PropTypes.string,
|
|
204
|
+
translations: PropTypes.object,
|
|
200
205
|
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType])
|
|
201
206
|
};
|
|
202
207
|
|
package/dist/user-card/card.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ export default class UserCard extends PureComponent<UserCardProps> {
|
|
|
47
47
|
banned: PropTypes.Validator<string>;
|
|
48
48
|
online: PropTypes.Validator<string>;
|
|
49
49
|
offline: PropTypes.Validator<string>;
|
|
50
|
-
copyToClipboard: PropTypes.
|
|
51
|
-
copiedToClipboard: PropTypes.
|
|
52
|
-
copingToClipboardError: PropTypes.
|
|
50
|
+
copyToClipboard: PropTypes.Requireable<string>;
|
|
51
|
+
copiedToClipboard: PropTypes.Requireable<string>;
|
|
52
|
+
copingToClipboardError: PropTypes.Requireable<string>;
|
|
53
53
|
unverified: PropTypes.Requireable<string>;
|
|
54
54
|
}>>;
|
|
55
55
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.105",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -108,15 +108,15 @@
|
|
|
108
108
|
"@types/react-dom": "^18.0.10",
|
|
109
109
|
"@types/sinon": "^10.0.13",
|
|
110
110
|
"@types/sinon-chai": "^3.2.9",
|
|
111
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
112
|
-
"@typescript-eslint/parser": "^5.
|
|
111
|
+
"@typescript-eslint/eslint-plugin": "^5.50.0",
|
|
112
|
+
"@typescript-eslint/parser": "^5.50.0",
|
|
113
113
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
|
|
114
114
|
"angular": "^1.8.3",
|
|
115
115
|
"angular-mocks": "^1.8.3",
|
|
116
116
|
"angular-route": "^1.8.3",
|
|
117
117
|
"babel-plugin-react-docgen": "^4.2.1",
|
|
118
118
|
"babel-plugin-require-context-hook": "^1.0.0",
|
|
119
|
-
"caniuse-lite": "^1.0.
|
|
119
|
+
"caniuse-lite": "^1.0.30001450",
|
|
120
120
|
"chai": "^4.3.7",
|
|
121
121
|
"chai-as-promised": "^7.1.1",
|
|
122
122
|
"chai-dom": "^1.10.0",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"react-test-renderer": "^18.2.0",
|
|
159
159
|
"regenerator-runtime": "^0.13.11",
|
|
160
160
|
"rimraf": "^4.1.2",
|
|
161
|
-
"rollup": "^3.12.
|
|
161
|
+
"rollup": "^3.12.1",
|
|
162
162
|
"rollup-plugin-clear": "^2.0.7",
|
|
163
163
|
"rollup-plugin-styles": "^4.0.0",
|
|
164
164
|
"sinon": "^15.0.1",
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"svg-inline-loader": "^0.8.2",
|
|
170
170
|
"teamcity-service-messages": "^0.1.14",
|
|
171
171
|
"terser-webpack-plugin": "^5.3.6",
|
|
172
|
-
"typescript": "~4.9.
|
|
172
|
+
"typescript": "~4.9.5",
|
|
173
173
|
"wallaby-webpack": "^3.9.16",
|
|
174
174
|
"webpack": "^5.75.0",
|
|
175
175
|
"webpack-cli": "^5.0.1",
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
"@ungap/url-search-params": "^0.2.2",
|
|
213
213
|
"babel-loader": "9.1.2",
|
|
214
214
|
"babel-plugin-transform-define": "^2.1.0",
|
|
215
|
-
"browserslist": "^4.21.
|
|
215
|
+
"browserslist": "^4.21.5",
|
|
216
216
|
"change-case": "^4.1.1",
|
|
217
217
|
"classnames": "^2.3.2",
|
|
218
218
|
"combokeys": "^3.0.1",
|