first commit
This commit is contained in:
9
frontend/node_modules/rc-input/es/utils/commonUtils.d.ts
generated
vendored
Normal file
9
frontend/node_modules/rc-input/es/utils/commonUtils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type React from 'react';
|
||||
import type { BaseInputProps, InputProps } from '../interface';
|
||||
export declare function hasAddon(props: BaseInputProps | InputProps): boolean;
|
||||
export declare function hasPrefixSuffix(props: BaseInputProps | InputProps): boolean;
|
||||
export declare function resolveOnChange<E extends HTMLInputElement | HTMLTextAreaElement>(target: E, e: React.ChangeEvent<E> | React.MouseEvent<HTMLElement, MouseEvent> | React.CompositionEvent<HTMLElement>, onChange: undefined | ((event: React.ChangeEvent<E>) => void), targetValue?: string): void;
|
||||
export interface InputFocusOptions extends FocusOptions {
|
||||
cursor?: 'start' | 'end' | 'all';
|
||||
}
|
||||
export declare function triggerFocus(element?: HTMLInputElement | HTMLTextAreaElement, option?: InputFocusOptions): void;
|
||||
92
frontend/node_modules/rc-input/es/utils/commonUtils.js
generated
vendored
Normal file
92
frontend/node_modules/rc-input/es/utils/commonUtils.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
export function hasAddon(props) {
|
||||
return !!(props.addonBefore || props.addonAfter);
|
||||
}
|
||||
export function hasPrefixSuffix(props) {
|
||||
return !!(props.prefix || props.suffix || props.allowClear);
|
||||
}
|
||||
|
||||
// TODO: It's better to use `Proxy` replace the `element.value`. But we still need support IE11.
|
||||
function cloneEvent(event, target, value) {
|
||||
// A bug report filed on WebKit's Bugzilla tracker, dating back to 2009, specifically addresses the issue of cloneNode() not copying files of <input type="file"> elements.
|
||||
// As of the last update, this bug was still marked as "NEW," indicating that it might not have been resolved yet.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=28123
|
||||
var currentTarget = target.cloneNode(true);
|
||||
|
||||
// click clear icon
|
||||
var newEvent = Object.create(event, {
|
||||
target: {
|
||||
value: currentTarget
|
||||
},
|
||||
currentTarget: {
|
||||
value: currentTarget
|
||||
}
|
||||
});
|
||||
|
||||
// Fill data
|
||||
currentTarget.value = value;
|
||||
|
||||
// Fill selection. Some type like `email` not support selection
|
||||
// https://github.com/ant-design/ant-design/issues/47833
|
||||
if (typeof target.selectionStart === 'number' && typeof target.selectionEnd === 'number') {
|
||||
currentTarget.selectionStart = target.selectionStart;
|
||||
currentTarget.selectionEnd = target.selectionEnd;
|
||||
}
|
||||
currentTarget.setSelectionRange = function () {
|
||||
target.setSelectionRange.apply(target, arguments);
|
||||
};
|
||||
return newEvent;
|
||||
}
|
||||
export function resolveOnChange(target, e, onChange, targetValue) {
|
||||
if (!onChange) {
|
||||
return;
|
||||
}
|
||||
var event = e;
|
||||
if (e.type === 'click') {
|
||||
// Clone a new target for event.
|
||||
// Avoid the following usage, the setQuery method gets the original value.
|
||||
//
|
||||
// const [query, setQuery] = React.useState('');
|
||||
// <Input
|
||||
// allowClear
|
||||
// value={query}
|
||||
// onChange={(e)=> {
|
||||
// setQuery((prevStatus) => e.target.value);
|
||||
// }}
|
||||
// />
|
||||
|
||||
event = cloneEvent(e, target, '');
|
||||
onChange(event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Trigger by composition event, this means we need force change the input value
|
||||
// https://github.com/ant-design/ant-design/issues/45737
|
||||
// https://github.com/ant-design/ant-design/issues/46598
|
||||
if (target.type !== 'file' && targetValue !== undefined) {
|
||||
event = cloneEvent(e, target, targetValue);
|
||||
onChange(event);
|
||||
return;
|
||||
}
|
||||
onChange(event);
|
||||
}
|
||||
export function triggerFocus(element, option) {
|
||||
if (!element) return;
|
||||
element.focus(option);
|
||||
|
||||
// Selection content
|
||||
var _ref = option || {},
|
||||
cursor = _ref.cursor;
|
||||
if (cursor) {
|
||||
var len = element.value.length;
|
||||
switch (cursor) {
|
||||
case 'start':
|
||||
element.setSelectionRange(0, 0);
|
||||
break;
|
||||
case 'end':
|
||||
element.setSelectionRange(len, len);
|
||||
break;
|
||||
default:
|
||||
element.setSelectionRange(0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
frontend/node_modules/rc-input/es/utils/types.d.ts
generated
vendored
Normal file
2
frontend/node_modules/rc-input/es/utils/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/** https://github.com/Microsoft/TypeScript/issues/29729 */
|
||||
export type LiteralUnion<T extends U, U> = T | (U & {});
|
||||
1
frontend/node_modules/rc-input/es/utils/types.js
generated
vendored
Normal file
1
frontend/node_modules/rc-input/es/utils/types.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user