@douyinfe/semi-ui 2.41.0-beta.0 → 2.41.1
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/dist/umd/semi-ui.js +37 -27
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_utils/index.d.ts +1 -0
- package/lib/cjs/_utils/index.js +7 -0
- package/lib/cjs/datePicker/dateInput.js +2 -2
- package/lib/cjs/image/previewInner.d.ts +0 -1
- package/lib/cjs/image/previewInner.js +2 -7
- package/lib/cjs/input/index.d.ts +2 -3
- package/lib/cjs/input/index.js +5 -5
- package/lib/cjs/input/textarea.d.ts +1 -1
- package/lib/cjs/input/textarea.js +4 -2
- package/lib/cjs/modal/Modal.d.ts +0 -1
- package/lib/cjs/modal/Modal.js +2 -7
- package/lib/cjs/sideSheet/index.d.ts +3 -0
- package/lib/cjs/sideSheet/index.js +12 -3
- package/lib/cjs/slider/index.js +4 -1
- package/lib/es/_utils/index.d.ts +1 -0
- package/lib/es/_utils/index.js +6 -0
- package/lib/es/datePicker/dateInput.js +2 -2
- package/lib/es/image/previewInner.d.ts +0 -1
- package/lib/es/image/previewInner.js +2 -7
- package/lib/es/input/index.d.ts +2 -3
- package/lib/es/input/index.js +5 -5
- package/lib/es/input/textarea.d.ts +1 -1
- package/lib/es/input/textarea.js +4 -2
- package/lib/es/modal/Modal.d.ts +0 -1
- package/lib/es/modal/Modal.js +2 -7
- package/lib/es/sideSheet/index.d.ts +3 -0
- package/lib/es/sideSheet/index.js +12 -3
- package/lib/es/slider/index.js +4 -1
- package/package.json +2 -2
|
@@ -68,3 +68,4 @@ export declare const isSemiIcon: (icon: any) => boolean;
|
|
|
68
68
|
export declare function getActiveElement(): HTMLElement | null;
|
|
69
69
|
export declare function isNodeContainsFocus(node: HTMLElement): boolean;
|
|
70
70
|
export declare function getFocusableElements(node: HTMLElement): HTMLElement[];
|
|
71
|
+
export declare function getScrollbarWidth(): number;
|
package/lib/cjs/_utils/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.cloneDeep = cloneDeep;
|
|
|
7
7
|
exports.getActiveElement = getActiveElement;
|
|
8
8
|
exports.getFocusableElements = getFocusableElements;
|
|
9
9
|
exports.getHighLightTextHTML = void 0;
|
|
10
|
+
exports.getScrollbarWidth = getScrollbarWidth;
|
|
10
11
|
exports.isNodeContainsFocus = isNodeContainsFocus;
|
|
11
12
|
exports.registerMediaQuery = exports.isSemiIcon = void 0;
|
|
12
13
|
exports.stopPropagation = stopPropagation;
|
|
@@ -174,4 +175,10 @@ function getFocusableElements(node) {
|
|
|
174
175
|
// we are not filtered elements which are invisible
|
|
175
176
|
const focusableElements = Array.from(node.querySelectorAll(focusableSelectorsStr));
|
|
176
177
|
return focusableElements;
|
|
178
|
+
}
|
|
179
|
+
function getScrollbarWidth() {
|
|
180
|
+
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
181
|
+
return window.innerWidth - document.documentElement.clientWidth;
|
|
182
|
+
}
|
|
183
|
+
return 0;
|
|
177
184
|
}
|
|
@@ -222,7 +222,7 @@ class DateInput extends _baseComponent.default {
|
|
|
222
222
|
onChange: (rangeStartValue, e) => this.handleRangeInputChange(rangeStartValue, rangeEnd, e),
|
|
223
223
|
onEnterPress: e => this.handleRangeInputEnterPress(e, rangeStart, rangeEnd),
|
|
224
224
|
onFocus: e => this.handleRangeInputFocus(e, 'rangeStart'),
|
|
225
|
-
|
|
225
|
+
autoFocus: autofocus,
|
|
226
226
|
ref: rangeInputStartRef
|
|
227
227
|
})), this.renderRangeSeparator(rangeStart, rangeEnd), /*#__PURE__*/_react.default.createElement("div", {
|
|
228
228
|
className: `${inputCls} ${inputRightWrapperCls}`,
|
|
@@ -397,7 +397,7 @@ class DateInput extends _baseComponent.default {
|
|
|
397
397
|
value: text,
|
|
398
398
|
validateStatus: validateStatus,
|
|
399
399
|
prefix: prefix,
|
|
400
|
-
|
|
400
|
+
autoFocus: autofocus,
|
|
401
401
|
size: size,
|
|
402
402
|
onBlur: onBlur,
|
|
403
403
|
onFocus: onFocus
|
|
@@ -68,7 +68,6 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
68
68
|
foundation: PreviewInnerFoundation;
|
|
69
69
|
constructor(props: PreviewInnerProps);
|
|
70
70
|
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
71
|
-
static getScrollbarWidth(): number;
|
|
72
71
|
componentDidMount(): void;
|
|
73
72
|
componentDidUpdate(prevProps: PreviewInnerProps, prevState: PreviewInnerStates): void;
|
|
74
73
|
componentWillUnmount(): void;
|
|
@@ -18,6 +18,7 @@ var _previewFooter = _interopRequireDefault(require("./previewFooter"));
|
|
|
18
18
|
var _previewImage = _interopRequireDefault(require("./previewImage"));
|
|
19
19
|
var _previewInnerFoundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/image/previewInnerFoundation"));
|
|
20
20
|
var _previewContext = require("./previewContext");
|
|
21
|
+
var _utils = require("../_utils");
|
|
21
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
23
|
const prefixCls = _constants.cssClasses.PREFIX;
|
|
23
24
|
let startMouseDown = {
|
|
@@ -223,14 +224,8 @@ class PreviewInner extends _baseComponent.default {
|
|
|
223
224
|
}
|
|
224
225
|
return willUpdateStates;
|
|
225
226
|
}
|
|
226
|
-
static getScrollbarWidth() {
|
|
227
|
-
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
228
|
-
return window.innerWidth - document.documentElement.clientWidth;
|
|
229
|
-
}
|
|
230
|
-
return 0;
|
|
231
|
-
}
|
|
232
227
|
componentDidMount() {
|
|
233
|
-
this.scrollBarWidth =
|
|
228
|
+
this.scrollBarWidth = (0, _utils.getScrollbarWidth)();
|
|
234
229
|
this.originBodyWidth = document.body.style.width;
|
|
235
230
|
if (this.props.visible) {
|
|
236
231
|
this.foundation.beforeShow();
|
package/lib/cjs/input/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { TextAreaProps } from './textarea';
|
|
|
8
8
|
export type InputSize = 'small' | 'large' | 'default';
|
|
9
9
|
export type InputMode = 'password';
|
|
10
10
|
export type ValidateStatus = "default" | "error" | "warning" | "success";
|
|
11
|
-
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'prefix' | 'size' | '
|
|
11
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'prefix' | 'size' | 'placeholder' | 'onFocus' | 'onBlur'> {
|
|
12
12
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
13
13
|
'aria-describedby'?: React.AriaAttributes['aria-describedby'];
|
|
14
14
|
'aria-errormessage'?: React.AriaAttributes['aria-errormessage'];
|
|
@@ -25,7 +25,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
25
25
|
defaultValue?: React.ReactText;
|
|
26
26
|
disabled?: boolean;
|
|
27
27
|
readonly?: boolean;
|
|
28
|
-
autofocus?: boolean;
|
|
29
28
|
type?: string;
|
|
30
29
|
showClear?: boolean;
|
|
31
30
|
hideSuffix?: boolean;
|
|
@@ -81,7 +80,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
81
80
|
defaultValue: PropTypes.Requireable<any>;
|
|
82
81
|
disabled: PropTypes.Requireable<boolean>;
|
|
83
82
|
readonly: PropTypes.Requireable<boolean>;
|
|
84
|
-
|
|
83
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
85
84
|
type: PropTypes.Requireable<string>;
|
|
86
85
|
showClear: PropTypes.Requireable<boolean>;
|
|
87
86
|
hideSuffix: PropTypes.Requireable<boolean>;
|
package/lib/cjs/input/index.js
CHANGED
|
@@ -148,10 +148,10 @@ class Input extends _baseComponent.default {
|
|
|
148
148
|
this.foundation.init();
|
|
149
149
|
const {
|
|
150
150
|
disabled,
|
|
151
|
-
|
|
151
|
+
autoFocus,
|
|
152
152
|
preventScroll
|
|
153
153
|
} = this.props;
|
|
154
|
-
if (!disabled && autofocus) {
|
|
154
|
+
if (!disabled && (autoFocus || this.props['autofocus'])) {
|
|
155
155
|
this.inputRef.current.focus({
|
|
156
156
|
preventScroll
|
|
157
157
|
});
|
|
@@ -314,7 +314,7 @@ class Input extends _baseComponent.default {
|
|
|
314
314
|
{
|
|
315
315
|
addonAfter,
|
|
316
316
|
addonBefore,
|
|
317
|
-
|
|
317
|
+
autoFocus,
|
|
318
318
|
clearIcon,
|
|
319
319
|
className,
|
|
320
320
|
disabled,
|
|
@@ -342,7 +342,7 @@ class Input extends _baseComponent.default {
|
|
|
342
342
|
borderless,
|
|
343
343
|
showClearIgnoreDisabled
|
|
344
344
|
} = _a,
|
|
345
|
-
rest = __rest(_a, ["addonAfter", "addonBefore", "
|
|
345
|
+
rest = __rest(_a, ["addonAfter", "addonBefore", "autoFocus", "clearIcon", "className", "disabled", "defaultValue", "placeholder", "prefix", "mode", "insetLabel", "insetLabelId", "validateStatus", "type", "readonly", "size", "suffix", "style", "showClear", "onEnterPress", "onClear", "hideSuffix", "inputStyle", "forwardRef", "maxLength", "getValueLength", "preventScroll", "borderless", "showClearIgnoreDisabled"]);
|
|
346
346
|
const {
|
|
347
347
|
value,
|
|
348
348
|
isFocus,
|
|
@@ -437,7 +437,7 @@ Input.propTypes = {
|
|
|
437
437
|
defaultValue: _propTypes.default.any,
|
|
438
438
|
disabled: _propTypes.default.bool,
|
|
439
439
|
readonly: _propTypes.default.bool,
|
|
440
|
-
|
|
440
|
+
autoFocus: _propTypes.default.bool,
|
|
441
441
|
type: _propTypes.default.string,
|
|
442
442
|
showClear: _propTypes.default.bool,
|
|
443
443
|
hideSuffix: _propTypes.default.bool,
|
|
@@ -14,7 +14,7 @@ export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTex
|
|
|
14
14
|
defaultValue?: string;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
readonly?: boolean;
|
|
17
|
-
|
|
17
|
+
autoFocus?: boolean;
|
|
18
18
|
showCounter?: boolean;
|
|
19
19
|
showClear?: boolean;
|
|
20
20
|
onClear?: (e: React.MouseEvent<HTMLTextAreaElement>) => void;
|
|
@@ -198,9 +198,10 @@ class TextArea extends _baseComponent.default {
|
|
|
198
198
|
maxLength,
|
|
199
199
|
minLength,
|
|
200
200
|
showClear,
|
|
201
|
-
borderless
|
|
201
|
+
borderless,
|
|
202
|
+
autoFocus
|
|
202
203
|
} = _a,
|
|
203
|
-
rest = __rest(_a, ["autosize", "placeholder", "onEnterPress", "onResize", "disabled", "readonly", "className", "showCounter", "validateStatus", "maxCount", "defaultValue", "style", "forwardRef", "getValueLength", "maxLength", "minLength", "showClear", "borderless"]);
|
|
204
|
+
rest = __rest(_a, ["autosize", "placeholder", "onEnterPress", "onResize", "disabled", "readonly", "className", "showCounter", "validateStatus", "maxCount", "defaultValue", "style", "forwardRef", "getValueLength", "maxLength", "minLength", "showClear", "borderless", "autoFocus"]);
|
|
204
205
|
const {
|
|
205
206
|
isFocus,
|
|
206
207
|
value,
|
|
@@ -222,6 +223,7 @@ class TextArea extends _baseComponent.default {
|
|
|
222
223
|
[`${prefixCls}-textarea-showClear`]: showClear
|
|
223
224
|
});
|
|
224
225
|
const itemProps = Object.assign(Object.assign({}, (0, _omit2.default)(rest, 'insetLabel', 'insetLabelId', 'getValueLength', 'onClear', 'showClear')), {
|
|
226
|
+
autoFocus: autoFocus || this.props['autofocus'],
|
|
225
227
|
className: itemCls,
|
|
226
228
|
disabled,
|
|
227
229
|
readOnly: readonly,
|
package/lib/cjs/modal/Modal.d.ts
CHANGED
|
@@ -97,7 +97,6 @@ declare class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
97
97
|
constructor(props: ModalReactProps);
|
|
98
98
|
get adapter(): ModalAdapter;
|
|
99
99
|
static getDerivedStateFromProps(props: ModalReactProps, prevState: ModalState): Partial<ModalState>;
|
|
100
|
-
static getScrollbarWidth(): number;
|
|
101
100
|
static info: (props: ModalReactProps) => {
|
|
102
101
|
destroy: () => void;
|
|
103
102
|
update: (newConfig: ModalReactProps) => void;
|
package/lib/cjs/modal/Modal.js
CHANGED
|
@@ -19,6 +19,7 @@ var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
|
|
|
19
19
|
var _confirm = _interopRequireWildcard(require("./confirm"));
|
|
20
20
|
var _useModal = _interopRequireDefault(require("./useModal"));
|
|
21
21
|
var _cssAnimation = _interopRequireDefault(require("../_cssAnimation"));
|
|
22
|
+
var _utils = require("../_utils");
|
|
22
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -239,14 +240,8 @@ class Modal extends _baseComponent.default {
|
|
|
239
240
|
// }
|
|
240
241
|
return newState;
|
|
241
242
|
}
|
|
242
|
-
static getScrollbarWidth() {
|
|
243
|
-
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
244
|
-
return window.innerWidth - document.documentElement.clientWidth;
|
|
245
|
-
}
|
|
246
|
-
return 0;
|
|
247
|
-
}
|
|
248
243
|
componentDidMount() {
|
|
249
|
-
this.scrollBarWidth =
|
|
244
|
+
this.scrollBarWidth = (0, _utils.getScrollbarWidth)();
|
|
250
245
|
this.originBodyWidth = document.body.style.width;
|
|
251
246
|
if (this.props.visible) {
|
|
252
247
|
this.foundation.beforeShow();
|
|
@@ -49,6 +49,9 @@ export default class SideSheet extends BaseComponent<SideSheetReactProps, SideSh
|
|
|
49
49
|
private _active;
|
|
50
50
|
constructor(props: SideSheetReactProps);
|
|
51
51
|
context: ContextValue;
|
|
52
|
+
private bodyOverflow;
|
|
53
|
+
private scrollBarWidth;
|
|
54
|
+
private originBodyWidth;
|
|
52
55
|
get adapter(): SideSheetAdapter;
|
|
53
56
|
static getDerivedStateFromProps(props: SideSheetReactProps, prevState: SideSheetState): Partial<SideSheetState>;
|
|
54
57
|
componentDidMount(): void;
|
|
@@ -16,6 +16,7 @@ var _SideSheetContent = _interopRequireDefault(require("./SideSheetContent"));
|
|
|
16
16
|
var _sideSheetFoundation = _interopRequireDefault(require("@douyinfe/semi-foundation/lib/cjs/sideSheet/sideSheetFoundation"));
|
|
17
17
|
require("@douyinfe/semi-foundation/lib/cjs/sideSheet/sideSheet.css");
|
|
18
18
|
var _cssAnimation = _interopRequireDefault(require("../_cssAnimation"));
|
|
19
|
+
var _utils = require("../_utils");
|
|
19
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
21
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
21
22
|
var t = {};
|
|
@@ -44,6 +45,9 @@ class SideSheet extends _baseComponent.default {
|
|
|
44
45
|
displayNone: !this.props.visible
|
|
45
46
|
};
|
|
46
47
|
this.foundation = new _sideSheetFoundation.default(this.adapter);
|
|
48
|
+
this.bodyOverflow = '';
|
|
49
|
+
this.scrollBarWidth = 0;
|
|
50
|
+
this.originBodyWidth = '100%';
|
|
47
51
|
}
|
|
48
52
|
get adapter() {
|
|
49
53
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -51,16 +55,19 @@ class SideSheet extends _baseComponent.default {
|
|
|
51
55
|
const {
|
|
52
56
|
getPopupContainer
|
|
53
57
|
} = this.props;
|
|
54
|
-
|
|
58
|
+
this.bodyOverflow = document.body.style.overflow || '';
|
|
59
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
55
60
|
document.body.style.overflow = 'hidden';
|
|
61
|
+
document.body.style.width = `calc(${this.originBodyWidth || '100%'} - ${this.scrollBarWidth}px)`;
|
|
56
62
|
}
|
|
57
63
|
},
|
|
58
64
|
enabledBodyScroll: () => {
|
|
59
65
|
const {
|
|
60
66
|
getPopupContainer
|
|
61
67
|
} = this.props;
|
|
62
|
-
if (!getPopupContainer &&
|
|
63
|
-
document.body.style.overflow =
|
|
68
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
69
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
70
|
+
document.body.style.width = this.originBodyWidth;
|
|
64
71
|
}
|
|
65
72
|
},
|
|
66
73
|
notifyCancel: e => {
|
|
@@ -99,6 +106,8 @@ class SideSheet extends _baseComponent.default {
|
|
|
99
106
|
return newState;
|
|
100
107
|
}
|
|
101
108
|
componentDidMount() {
|
|
109
|
+
this.scrollBarWidth = (0, _utils.getScrollbarWidth)();
|
|
110
|
+
this.originBodyWidth = document.body.style.width;
|
|
102
111
|
if (this.props.visible) {
|
|
103
112
|
this.foundation.beforeShow();
|
|
104
113
|
}
|
package/lib/cjs/slider/index.js
CHANGED
|
@@ -442,7 +442,7 @@ class Slider extends _baseComponent.default {
|
|
|
442
442
|
getMaxHandleEl: () => this.maxHanleEl.current,
|
|
443
443
|
onHandleDown: e => {
|
|
444
444
|
this._addEventListener(document.body, 'mousemove', this.foundation.onHandleMove, false);
|
|
445
|
-
this._addEventListener(
|
|
445
|
+
this._addEventListener(window, 'mouseup', this.foundation.onHandleUp, false);
|
|
446
446
|
this._addEventListener(document.body, 'touchmove', this.foundation.onHandleTouchMove, false);
|
|
447
447
|
},
|
|
448
448
|
onHandleMove: function (mousePos, isMin) {
|
|
@@ -506,6 +506,8 @@ class Slider extends _baseComponent.default {
|
|
|
506
506
|
});
|
|
507
507
|
},
|
|
508
508
|
onHandleUpBefore: e => {
|
|
509
|
+
var _a, _b;
|
|
510
|
+
(_b = (_a = this.props).onMouseUp) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
509
511
|
e.stopPropagation();
|
|
510
512
|
e.preventDefault();
|
|
511
513
|
document.body.removeEventListener('mousemove', this.foundation.onHandleMove, false);
|
|
@@ -633,6 +635,7 @@ Slider.propTypes = {
|
|
|
633
635
|
vertical: _propTypes.default.bool,
|
|
634
636
|
onAfterChange: _propTypes.default.func,
|
|
635
637
|
onChange: _propTypes.default.func,
|
|
638
|
+
onMouseUp: _propTypes.default.func,
|
|
636
639
|
tooltipVisible: _propTypes.default.bool,
|
|
637
640
|
style: _propTypes.default.object,
|
|
638
641
|
className: _propTypes.default.string,
|
package/lib/es/_utils/index.d.ts
CHANGED
|
@@ -68,3 +68,4 @@ export declare const isSemiIcon: (icon: any) => boolean;
|
|
|
68
68
|
export declare function getActiveElement(): HTMLElement | null;
|
|
69
69
|
export declare function isNodeContainsFocus(node: HTMLElement): boolean;
|
|
70
70
|
export declare function getFocusableElements(node: HTMLElement): HTMLElement[];
|
|
71
|
+
export declare function getScrollbarWidth(): number;
|
package/lib/es/_utils/index.js
CHANGED
|
@@ -158,4 +158,10 @@ export function getFocusableElements(node) {
|
|
|
158
158
|
// we are not filtered elements which are invisible
|
|
159
159
|
const focusableElements = Array.from(node.querySelectorAll(focusableSelectorsStr));
|
|
160
160
|
return focusableElements;
|
|
161
|
+
}
|
|
162
|
+
export function getScrollbarWidth() {
|
|
163
|
+
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
164
|
+
return window.innerWidth - document.documentElement.clientWidth;
|
|
165
|
+
}
|
|
166
|
+
return 0;
|
|
161
167
|
}
|
|
@@ -215,7 +215,7 @@ export default class DateInput extends BaseComponent {
|
|
|
215
215
|
onChange: (rangeStartValue, e) => this.handleRangeInputChange(rangeStartValue, rangeEnd, e),
|
|
216
216
|
onEnterPress: e => this.handleRangeInputEnterPress(e, rangeStart, rangeEnd),
|
|
217
217
|
onFocus: e => this.handleRangeInputFocus(e, 'rangeStart'),
|
|
218
|
-
|
|
218
|
+
autoFocus: autofocus,
|
|
219
219
|
ref: rangeInputStartRef
|
|
220
220
|
})), this.renderRangeSeparator(rangeStart, rangeEnd), /*#__PURE__*/React.createElement("div", {
|
|
221
221
|
className: `${inputCls} ${inputRightWrapperCls}`,
|
|
@@ -390,7 +390,7 @@ export default class DateInput extends BaseComponent {
|
|
|
390
390
|
value: text,
|
|
391
391
|
validateStatus: validateStatus,
|
|
392
392
|
prefix: prefix,
|
|
393
|
-
|
|
393
|
+
autoFocus: autofocus,
|
|
394
394
|
size: size,
|
|
395
395
|
onBlur: onBlur,
|
|
396
396
|
onFocus: onFocus
|
|
@@ -68,7 +68,6 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
68
68
|
foundation: PreviewInnerFoundation;
|
|
69
69
|
constructor(props: PreviewInnerProps);
|
|
70
70
|
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
71
|
-
static getScrollbarWidth(): number;
|
|
72
71
|
componentDidMount(): void;
|
|
73
72
|
componentDidUpdate(prevProps: PreviewInnerProps, prevState: PreviewInnerStates): void;
|
|
74
73
|
componentWillUnmount(): void;
|
|
@@ -12,6 +12,7 @@ import Footer from "./previewFooter";
|
|
|
12
12
|
import PreviewImage from "./previewImage";
|
|
13
13
|
import PreviewInnerFoundation from '@douyinfe/semi-foundation/lib/es/image/previewInnerFoundation';
|
|
14
14
|
import { PreviewContext } from "./previewContext";
|
|
15
|
+
import { getScrollbarWidth } from "../_utils";
|
|
15
16
|
const prefixCls = cssClasses.PREFIX;
|
|
16
17
|
let startMouseDown = {
|
|
17
18
|
x: 0,
|
|
@@ -216,14 +217,8 @@ export default class PreviewInner extends BaseComponent {
|
|
|
216
217
|
}
|
|
217
218
|
return willUpdateStates;
|
|
218
219
|
}
|
|
219
|
-
static getScrollbarWidth() {
|
|
220
|
-
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
221
|
-
return window.innerWidth - document.documentElement.clientWidth;
|
|
222
|
-
}
|
|
223
|
-
return 0;
|
|
224
|
-
}
|
|
225
220
|
componentDidMount() {
|
|
226
|
-
this.scrollBarWidth =
|
|
221
|
+
this.scrollBarWidth = getScrollbarWidth();
|
|
227
222
|
this.originBodyWidth = document.body.style.width;
|
|
228
223
|
if (this.props.visible) {
|
|
229
224
|
this.foundation.beforeShow();
|
package/lib/es/input/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { TextAreaProps } from './textarea';
|
|
|
8
8
|
export type InputSize = 'small' | 'large' | 'default';
|
|
9
9
|
export type InputMode = 'password';
|
|
10
10
|
export type ValidateStatus = "default" | "error" | "warning" | "success";
|
|
11
|
-
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'prefix' | 'size' | '
|
|
11
|
+
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'prefix' | 'size' | 'placeholder' | 'onFocus' | 'onBlur'> {
|
|
12
12
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
13
13
|
'aria-describedby'?: React.AriaAttributes['aria-describedby'];
|
|
14
14
|
'aria-errormessage'?: React.AriaAttributes['aria-errormessage'];
|
|
@@ -25,7 +25,6 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem
|
|
|
25
25
|
defaultValue?: React.ReactText;
|
|
26
26
|
disabled?: boolean;
|
|
27
27
|
readonly?: boolean;
|
|
28
|
-
autofocus?: boolean;
|
|
29
28
|
type?: string;
|
|
30
29
|
showClear?: boolean;
|
|
31
30
|
hideSuffix?: boolean;
|
|
@@ -81,7 +80,7 @@ declare class Input extends BaseComponent<InputProps, InputState> {
|
|
|
81
80
|
defaultValue: PropTypes.Requireable<any>;
|
|
82
81
|
disabled: PropTypes.Requireable<boolean>;
|
|
83
82
|
readonly: PropTypes.Requireable<boolean>;
|
|
84
|
-
|
|
83
|
+
autoFocus: PropTypes.Requireable<boolean>;
|
|
85
84
|
type: PropTypes.Requireable<string>;
|
|
86
85
|
showClear: PropTypes.Requireable<boolean>;
|
|
87
86
|
hideSuffix: PropTypes.Requireable<boolean>;
|
package/lib/es/input/index.js
CHANGED
|
@@ -141,10 +141,10 @@ class Input extends BaseComponent {
|
|
|
141
141
|
this.foundation.init();
|
|
142
142
|
const {
|
|
143
143
|
disabled,
|
|
144
|
-
|
|
144
|
+
autoFocus,
|
|
145
145
|
preventScroll
|
|
146
146
|
} = this.props;
|
|
147
|
-
if (!disabled && autofocus) {
|
|
147
|
+
if (!disabled && (autoFocus || this.props['autofocus'])) {
|
|
148
148
|
this.inputRef.current.focus({
|
|
149
149
|
preventScroll
|
|
150
150
|
});
|
|
@@ -307,7 +307,7 @@ class Input extends BaseComponent {
|
|
|
307
307
|
{
|
|
308
308
|
addonAfter,
|
|
309
309
|
addonBefore,
|
|
310
|
-
|
|
310
|
+
autoFocus,
|
|
311
311
|
clearIcon,
|
|
312
312
|
className,
|
|
313
313
|
disabled,
|
|
@@ -335,7 +335,7 @@ class Input extends BaseComponent {
|
|
|
335
335
|
borderless,
|
|
336
336
|
showClearIgnoreDisabled
|
|
337
337
|
} = _a,
|
|
338
|
-
rest = __rest(_a, ["addonAfter", "addonBefore", "
|
|
338
|
+
rest = __rest(_a, ["addonAfter", "addonBefore", "autoFocus", "clearIcon", "className", "disabled", "defaultValue", "placeholder", "prefix", "mode", "insetLabel", "insetLabelId", "validateStatus", "type", "readonly", "size", "suffix", "style", "showClear", "onEnterPress", "onClear", "hideSuffix", "inputStyle", "forwardRef", "maxLength", "getValueLength", "preventScroll", "borderless", "showClearIgnoreDisabled"]);
|
|
339
339
|
const {
|
|
340
340
|
value,
|
|
341
341
|
isFocus,
|
|
@@ -429,7 +429,7 @@ Input.propTypes = {
|
|
|
429
429
|
defaultValue: PropTypes.any,
|
|
430
430
|
disabled: PropTypes.bool,
|
|
431
431
|
readonly: PropTypes.bool,
|
|
432
|
-
|
|
432
|
+
autoFocus: PropTypes.bool,
|
|
433
433
|
type: PropTypes.string,
|
|
434
434
|
showClear: PropTypes.bool,
|
|
435
435
|
hideSuffix: PropTypes.bool,
|
|
@@ -14,7 +14,7 @@ export interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTex
|
|
|
14
14
|
defaultValue?: string;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
readonly?: boolean;
|
|
17
|
-
|
|
17
|
+
autoFocus?: boolean;
|
|
18
18
|
showCounter?: boolean;
|
|
19
19
|
showClear?: boolean;
|
|
20
20
|
onClear?: (e: React.MouseEvent<HTMLTextAreaElement>) => void;
|
package/lib/es/input/textarea.js
CHANGED
|
@@ -191,9 +191,10 @@ class TextArea extends BaseComponent {
|
|
|
191
191
|
maxLength,
|
|
192
192
|
minLength,
|
|
193
193
|
showClear,
|
|
194
|
-
borderless
|
|
194
|
+
borderless,
|
|
195
|
+
autoFocus
|
|
195
196
|
} = _a,
|
|
196
|
-
rest = __rest(_a, ["autosize", "placeholder", "onEnterPress", "onResize", "disabled", "readonly", "className", "showCounter", "validateStatus", "maxCount", "defaultValue", "style", "forwardRef", "getValueLength", "maxLength", "minLength", "showClear", "borderless"]);
|
|
197
|
+
rest = __rest(_a, ["autosize", "placeholder", "onEnterPress", "onResize", "disabled", "readonly", "className", "showCounter", "validateStatus", "maxCount", "defaultValue", "style", "forwardRef", "getValueLength", "maxLength", "minLength", "showClear", "borderless", "autoFocus"]);
|
|
197
198
|
const {
|
|
198
199
|
isFocus,
|
|
199
200
|
value,
|
|
@@ -215,6 +216,7 @@ class TextArea extends BaseComponent {
|
|
|
215
216
|
[`${prefixCls}-textarea-showClear`]: showClear
|
|
216
217
|
});
|
|
217
218
|
const itemProps = Object.assign(Object.assign({}, _omit(rest, 'insetLabel', 'insetLabelId', 'getValueLength', 'onClear', 'showClear')), {
|
|
219
|
+
autoFocus: autoFocus || this.props['autofocus'],
|
|
218
220
|
className: itemCls,
|
|
219
221
|
disabled,
|
|
220
222
|
readOnly: readonly,
|
package/lib/es/modal/Modal.d.ts
CHANGED
|
@@ -97,7 +97,6 @@ declare class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
97
97
|
constructor(props: ModalReactProps);
|
|
98
98
|
get adapter(): ModalAdapter;
|
|
99
99
|
static getDerivedStateFromProps(props: ModalReactProps, prevState: ModalState): Partial<ModalState>;
|
|
100
|
-
static getScrollbarWidth(): number;
|
|
101
100
|
static info: (props: ModalReactProps) => {
|
|
102
101
|
destroy: () => void;
|
|
103
102
|
update: (newConfig: ModalReactProps) => void;
|
package/lib/es/modal/Modal.js
CHANGED
|
@@ -21,6 +21,7 @@ import BaseComponent from '../_base/baseComponent';
|
|
|
21
21
|
import confirm, { withConfirm, withError, withInfo, withSuccess, withWarning } from './confirm';
|
|
22
22
|
import useModal from './useModal';
|
|
23
23
|
import CSSAnimation from "../_cssAnimation";
|
|
24
|
+
import { getScrollbarWidth } from '../_utils';
|
|
24
25
|
export const destroyFns = [];
|
|
25
26
|
class Modal extends BaseComponent {
|
|
26
27
|
constructor(props) {
|
|
@@ -229,14 +230,8 @@ class Modal extends BaseComponent {
|
|
|
229
230
|
// }
|
|
230
231
|
return newState;
|
|
231
232
|
}
|
|
232
|
-
static getScrollbarWidth() {
|
|
233
|
-
if (globalThis && Object.prototype.toString.call(globalThis) === '[object Window]') {
|
|
234
|
-
return window.innerWidth - document.documentElement.clientWidth;
|
|
235
|
-
}
|
|
236
|
-
return 0;
|
|
237
|
-
}
|
|
238
233
|
componentDidMount() {
|
|
239
|
-
this.scrollBarWidth =
|
|
234
|
+
this.scrollBarWidth = getScrollbarWidth();
|
|
240
235
|
this.originBodyWidth = document.body.style.width;
|
|
241
236
|
if (this.props.visible) {
|
|
242
237
|
this.foundation.beforeShow();
|
|
@@ -49,6 +49,9 @@ export default class SideSheet extends BaseComponent<SideSheetReactProps, SideSh
|
|
|
49
49
|
private _active;
|
|
50
50
|
constructor(props: SideSheetReactProps);
|
|
51
51
|
context: ContextValue;
|
|
52
|
+
private bodyOverflow;
|
|
53
|
+
private scrollBarWidth;
|
|
54
|
+
private originBodyWidth;
|
|
52
55
|
get adapter(): SideSheetAdapter;
|
|
53
56
|
static getDerivedStateFromProps(props: SideSheetReactProps, prevState: SideSheetState): Partial<SideSheetState>;
|
|
54
57
|
componentDidMount(): void;
|
|
@@ -18,6 +18,7 @@ import SideSheetContent from './SideSheetContent';
|
|
|
18
18
|
import SideSheetFoundation from '@douyinfe/semi-foundation/lib/es/sideSheet/sideSheetFoundation';
|
|
19
19
|
import '@douyinfe/semi-foundation/lib/es/sideSheet/sideSheet.css';
|
|
20
20
|
import CSSAnimation from "../_cssAnimation";
|
|
21
|
+
import { getScrollbarWidth } from '../_utils';
|
|
21
22
|
const prefixCls = cssClasses.PREFIX;
|
|
22
23
|
const defaultWidthList = strings.WIDTH;
|
|
23
24
|
const defaultHeight = strings.HEIGHT;
|
|
@@ -37,6 +38,9 @@ export default class SideSheet extends BaseComponent {
|
|
|
37
38
|
displayNone: !this.props.visible
|
|
38
39
|
};
|
|
39
40
|
this.foundation = new SideSheetFoundation(this.adapter);
|
|
41
|
+
this.bodyOverflow = '';
|
|
42
|
+
this.scrollBarWidth = 0;
|
|
43
|
+
this.originBodyWidth = '100%';
|
|
40
44
|
}
|
|
41
45
|
get adapter() {
|
|
42
46
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -44,16 +48,19 @@ export default class SideSheet extends BaseComponent {
|
|
|
44
48
|
const {
|
|
45
49
|
getPopupContainer
|
|
46
50
|
} = this.props;
|
|
47
|
-
|
|
51
|
+
this.bodyOverflow = document.body.style.overflow || '';
|
|
52
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
48
53
|
document.body.style.overflow = 'hidden';
|
|
54
|
+
document.body.style.width = `calc(${this.originBodyWidth || '100%'} - ${this.scrollBarWidth}px)`;
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
enabledBodyScroll: () => {
|
|
52
58
|
const {
|
|
53
59
|
getPopupContainer
|
|
54
60
|
} = this.props;
|
|
55
|
-
if (!getPopupContainer &&
|
|
56
|
-
document.body.style.overflow =
|
|
61
|
+
if (!getPopupContainer && this.bodyOverflow !== 'hidden') {
|
|
62
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
63
|
+
document.body.style.width = this.originBodyWidth;
|
|
57
64
|
}
|
|
58
65
|
},
|
|
59
66
|
notifyCancel: e => {
|
|
@@ -92,6 +99,8 @@ export default class SideSheet extends BaseComponent {
|
|
|
92
99
|
return newState;
|
|
93
100
|
}
|
|
94
101
|
componentDidMount() {
|
|
102
|
+
this.scrollBarWidth = getScrollbarWidth();
|
|
103
|
+
this.originBodyWidth = document.body.style.width;
|
|
95
104
|
if (this.props.visible) {
|
|
96
105
|
this.foundation.beforeShow();
|
|
97
106
|
}
|
package/lib/es/slider/index.js
CHANGED
|
@@ -435,7 +435,7 @@ export default class Slider extends BaseComponent {
|
|
|
435
435
|
getMaxHandleEl: () => this.maxHanleEl.current,
|
|
436
436
|
onHandleDown: e => {
|
|
437
437
|
this._addEventListener(document.body, 'mousemove', this.foundation.onHandleMove, false);
|
|
438
|
-
this._addEventListener(
|
|
438
|
+
this._addEventListener(window, 'mouseup', this.foundation.onHandleUp, false);
|
|
439
439
|
this._addEventListener(document.body, 'touchmove', this.foundation.onHandleTouchMove, false);
|
|
440
440
|
},
|
|
441
441
|
onHandleMove: function (mousePos, isMin) {
|
|
@@ -499,6 +499,8 @@ export default class Slider extends BaseComponent {
|
|
|
499
499
|
});
|
|
500
500
|
},
|
|
501
501
|
onHandleUpBefore: e => {
|
|
502
|
+
var _a, _b;
|
|
503
|
+
(_b = (_a = this.props).onMouseUp) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
502
504
|
e.stopPropagation();
|
|
503
505
|
e.preventDefault();
|
|
504
506
|
document.body.removeEventListener('mousemove', this.foundation.onHandleMove, false);
|
|
@@ -625,6 +627,7 @@ Slider.propTypes = {
|
|
|
625
627
|
vertical: PropTypes.bool,
|
|
626
628
|
onAfterChange: PropTypes.func,
|
|
627
629
|
onChange: PropTypes.func,
|
|
630
|
+
onMouseUp: PropTypes.func,
|
|
628
631
|
tooltipVisible: PropTypes.bool,
|
|
629
632
|
style: PropTypes.object,
|
|
630
633
|
className: PropTypes.string,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.41.
|
|
3
|
+
"version": "2.41.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
],
|
|
72
72
|
"author": "",
|
|
73
73
|
"license": "MIT",
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "145acfe4a9dcca5eab26f40595f00eca521d0fc8",
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
77
77
|
"@babel/plugin-transform-runtime": "^7.15.8",
|