@jetbrains/ring-ui-built 6.0.56 → 6.0.58
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/date-picker/date-picker.d.ts +3 -1
- package/components/date-picker/date-picker.js +6 -4
- package/components/dialog/dialog.d.ts +2 -0
- package/components/dialog/dialog.js +9 -3
- package/components/select/select.d.ts +3 -0
- package/components/select/select.js +12 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { PureComponent } from 'react';
|
1
|
+
import { PureComponent, ButtonHTMLAttributes } from 'react';
|
2
2
|
import * as React from 'react';
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
import type { Locale } from 'date-fns';
|
@@ -29,6 +29,7 @@ export type DatePickerProps = Omit<DatePopupProps, 'translations' | 'parseDateIn
|
|
29
29
|
disabled?: boolean | null | undefined;
|
30
30
|
parseDateInput: (input: string | null | undefined) => Date | null;
|
31
31
|
size?: Size;
|
32
|
+
buttonAttributes?: Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-label'>;
|
32
33
|
};
|
33
34
|
/**
|
34
35
|
* @name Date Picker
|
@@ -61,6 +62,7 @@ export default class DatePicker extends PureComponent<DatePickerProps> {
|
|
61
62
|
translations: PropTypes.Requireable<object>;
|
62
63
|
locale: PropTypes.Requireable<object>;
|
63
64
|
size: PropTypes.Requireable<Size>;
|
65
|
+
buttonAttributes: PropTypes.Requireable<object>;
|
64
66
|
};
|
65
67
|
static defaultProps: DatePickerProps;
|
66
68
|
static contextType: React.Context<import("../i18n/i18n-context").I18nContextProps>;
|
@@ -290,13 +290,14 @@ var DatePicker = /*#__PURE__*/function (_PureComponent) {
|
|
290
290
|
disabled: (_this$props$disabled = this.props.disabled) !== null && _this$props$disabled !== void 0 ? _this$props$disabled : false,
|
291
291
|
pseudo: true,
|
292
292
|
children: this.getAnchorText()
|
293
|
-
}) : /*#__PURE__*/jsx(Button, {
|
293
|
+
}) : /*#__PURE__*/jsx(Button, _objectSpread2(_objectSpread2({
|
294
294
|
"data-test-ring-dropdown-anchor": true,
|
295
295
|
className: modules_0c7b7d96.anchor,
|
296
296
|
text: false,
|
297
|
-
disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
|
297
|
+
disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
|
298
|
+
}, this.props.buttonAttributes), {}, {
|
298
299
|
children: anchorContent
|
299
|
-
})
|
300
|
+
}))
|
300
301
|
}, dropdownProps), {}, {
|
301
302
|
children: /*#__PURE__*/jsx(PopupComponent, {
|
302
303
|
className: popupClassName,
|
@@ -340,7 +341,8 @@ _defineProperty(DatePicker, "propTypes", {
|
|
340
341
|
maxDate: dateType,
|
341
342
|
translations: PropTypes.object,
|
342
343
|
locale: PropTypes.object,
|
343
|
-
size: PropTypes.oneOf(Object.values(Size))
|
344
|
+
size: PropTypes.oneOf(Object.values(Size)),
|
345
|
+
buttonAttributes: PropTypes.object
|
344
346
|
});
|
345
347
|
_defineProperty(DatePicker, "defaultProps", {
|
346
348
|
className: '',
|
@@ -21,6 +21,7 @@ export interface DialogProps extends Partial<TabTrapProps> {
|
|
21
21
|
dense?: boolean | null | undefined;
|
22
22
|
native?: boolean;
|
23
23
|
modal?: boolean;
|
24
|
+
preventBodyScroll?: boolean;
|
24
25
|
}
|
25
26
|
export default class Dialog extends PureComponent<DialogProps> {
|
26
27
|
static propTypes: {
|
@@ -41,6 +42,7 @@ export default class Dialog extends PureComponent<DialogProps> {
|
|
41
42
|
portalTarget: PropTypes.Requireable<HTMLElement>;
|
42
43
|
autoFocusFirst: PropTypes.Requireable<boolean>;
|
43
44
|
'data-test': PropTypes.Requireable<string>;
|
45
|
+
preventBodyScroll: PropTypes.Requireable<boolean>;
|
44
46
|
};
|
45
47
|
static defaultProps: Partial<DialogProps>;
|
46
48
|
state: {
|
@@ -60,7 +60,7 @@ import '../global/controls-height.js';
|
|
60
60
|
import '../_helpers/button__classes.js';
|
61
61
|
import 'scrollbar-width';
|
62
62
|
|
63
|
-
var _excluded = ["show", "showCloseButton", "onOverlayClick", "onCloseAttempt", "onEscPress", "onCloseClick", "children", "className", "contentClassName", "trapFocus", "data-test", "closeButtonInside", "portalTarget", "label", "closeButtonTitle", "dense", "shortcutOptions", "native", "modal"];
|
63
|
+
var _excluded = ["show", "showCloseButton", "onOverlayClick", "onCloseAttempt", "onEscPress", "onCloseClick", "children", "className", "contentClassName", "trapFocus", "data-test", "closeButtonInside", "portalTarget", "label", "closeButtonTitle", "dense", "shortcutOptions", "native", "modal", "preventBodyScroll"];
|
64
64
|
function noop() {}
|
65
65
|
var Dialog = /*#__PURE__*/function (_PureComponent) {
|
66
66
|
function Dialog() {
|
@@ -149,6 +149,9 @@ var Dialog = /*#__PURE__*/function (_PureComponent) {
|
|
149
149
|
}, {
|
150
150
|
key: "toggleScrollPreventer",
|
151
151
|
value: function toggleScrollPreventer() {
|
152
|
+
if (!this.props.preventBodyScroll) {
|
153
|
+
return;
|
154
|
+
}
|
152
155
|
if (this.props.show) {
|
153
156
|
this.scrollPreventer.prevent();
|
154
157
|
} else {
|
@@ -179,6 +182,7 @@ var Dialog = /*#__PURE__*/function (_PureComponent) {
|
|
179
182
|
_this$props4.shortcutOptions;
|
180
183
|
var native = _this$props4.native;
|
181
184
|
_this$props4.modal;
|
185
|
+
_this$props4.preventBodyScroll;
|
182
186
|
var restProps = _objectWithoutProperties(_this$props4, _excluded);
|
183
187
|
var classes = classNames(modules_5e9b8c03.container, className);
|
184
188
|
var shortcutsMap = this.getShortcutsMap();
|
@@ -269,7 +273,8 @@ _defineProperty(Dialog, "propTypes", {
|
|
269
273
|
trapFocus: PropTypes.bool,
|
270
274
|
portalTarget: PropTypes.instanceOf(HTMLElement),
|
271
275
|
autoFocusFirst: PropTypes.bool,
|
272
|
-
'data-test': PropTypes.string
|
276
|
+
'data-test': PropTypes.string,
|
277
|
+
preventBodyScroll: PropTypes.bool
|
273
278
|
});
|
274
279
|
_defineProperty(Dialog, "defaultProps", {
|
275
280
|
label: 'Dialog',
|
@@ -284,7 +289,8 @@ _defineProperty(Dialog, "defaultProps", {
|
|
284
289
|
},
|
285
290
|
trapFocus: false,
|
286
291
|
autoFocusFirst: true,
|
287
|
-
modal: true
|
292
|
+
modal: true,
|
293
|
+
preventBodyScroll: true
|
288
294
|
});
|
289
295
|
|
290
296
|
export { Dialog as default };
|
@@ -213,6 +213,9 @@ export default class Select<T = unknown> extends Component<SelectProps<T>, Selec
|
|
213
213
|
shortcutsScope: string;
|
214
214
|
listId: string;
|
215
215
|
private _focusHandler;
|
216
|
+
isClickingSelect: boolean;
|
217
|
+
mouseDownHandler: () => void;
|
218
|
+
mouseUpHandler: () => void;
|
216
219
|
private _blurHandler;
|
217
220
|
node?: HTMLElement | null;
|
218
221
|
nodeRef: (el: HTMLElement | null) => void;
|
@@ -307,10 +307,17 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
307
307
|
focused: true
|
308
308
|
});
|
309
309
|
});
|
310
|
+
_defineProperty(_this, "isClickingSelect", false);
|
311
|
+
_defineProperty(_this, "mouseDownHandler", function () {
|
312
|
+
_this.isClickingSelect = true;
|
313
|
+
});
|
314
|
+
_defineProperty(_this, "mouseUpHandler", function () {
|
315
|
+
_this.isClickingSelect = false;
|
316
|
+
});
|
310
317
|
_defineProperty(_this, "_blurHandler", function () {
|
311
318
|
var _this$_popup;
|
312
319
|
_this.props.onBlur();
|
313
|
-
if (_this._popup && _this._popup.isVisible() && !_this._popup.isClickingPopup) {
|
320
|
+
if (_this._popup && _this._popup.isVisible() && !_this._popup.isClickingPopup && !_this.isClickingSelect) {
|
314
321
|
window.setTimeout(function () {
|
315
322
|
_this.setState({
|
316
323
|
showPopup: false
|
@@ -1012,6 +1019,10 @@ var Select = /*#__PURE__*/function (_Component) {
|
|
1012
1019
|
ref: this.nodeRef,
|
1013
1020
|
className: classNames(classes, modules_9d0de074.inputMode),
|
1014
1021
|
"data-test": joinDataTestAttributes('ring-select', dataTest),
|
1022
|
+
role: "presentation" // has interactive elements inside
|
1023
|
+
,
|
1024
|
+
onMouseDown: this.mouseDownHandler,
|
1025
|
+
onMouseUp: this.mouseUpHandler,
|
1015
1026
|
children: [shortcutsEnabled && /*#__PURE__*/jsx(Shortcuts, {
|
1016
1027
|
map: this.getShortcutsMap(),
|
1017
1028
|
scope: this.shortcutsScope
|