Latest updates from IceHrmPro
This commit is contained in:
18
web/node_modules/rc-mentions/HISTORY.md
generated
vendored
Normal file
18
web/node_modules/rc-mentions/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# History
|
||||
----
|
||||
|
||||
## 0.4.0 / 2019-08-06
|
||||
|
||||
- Support `getPopupContainer` prop.
|
||||
|
||||
## 0.3.0 / 2019-05-14
|
||||
|
||||
- Support `placement` prop.
|
||||
|
||||
## 0.2.0 / 2019-05-08
|
||||
|
||||
- Support `rows` prop.
|
||||
|
||||
## 0.1.0 / 2019-05-08
|
||||
|
||||
- Initial release.
|
||||
9
web/node_modules/rc-mentions/LICENSE.md
generated
vendored
Normal file
9
web/node_modules/rc-mentions/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019-present alipay.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
121
web/node_modules/rc-mentions/README.md
generated
vendored
Normal file
121
web/node_modules/rc-mentions/README.md
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
# rc-mentions
|
||||
---
|
||||
|
||||
React Mentions
|
||||
|
||||
[![NPM version][npm-image]][npm-url]
|
||||
[![build status][travis-image]][travis-url]
|
||||
[![Test coverage][codecov-image]][codecov-url]
|
||||
[](https://david-dm.org/react-component/mentions)
|
||||
[](https://david-dm.org/react-component/mentions?type=dev)
|
||||
[![npm download][download-image]][download-url]
|
||||
[](https://github.com/react-component/mentions)
|
||||
|
||||
[Storybook]: https://github.com/storybooks/press/blob/master/badges/storybook.svg
|
||||
[npm-image]: http://img.shields.io/npm/v/rc-mentions.svg?style=flat-square
|
||||
[npm-url]: http://npmjs.org/package/rc-mentions
|
||||
[travis-image]: https://img.shields.io/travis/react-component/mentions.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/react-component/mentions
|
||||
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/mentions.svg?style=flat-square
|
||||
[codecov-url]: https://codecov.io/gh/react-component/mentions/branch/master
|
||||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[download-image]: https://img.shields.io/npm/dm/rc-mentions.svg?style=flat-square
|
||||
[download-url]: https://npmjs.org/package/rc-mentions
|
||||
|
||||
## Screenshots
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/5378891/57270992-2fd48780-70c0-11e9-91ae-c614d0b49a45.png" />
|
||||
|
||||
## Feature
|
||||
|
||||
* support ie9,ie9+,chrome,firefox,safari
|
||||
|
||||
### Keyboard
|
||||
|
||||
* Open mentions (focus input || focus and click)
|
||||
* KeyDown/KeyUp/Enter to navigate menu
|
||||
|
||||
## install
|
||||
|
||||
[](https://npmjs.org/package/rc-mentions)
|
||||
|
||||
## Usage
|
||||
|
||||
### basic use
|
||||
|
||||
```js
|
||||
import Mentions from 'rc-mentions';
|
||||
|
||||
const { Option } = Mentions;
|
||||
|
||||
var Demo = (
|
||||
<Mentions>
|
||||
<Option value="light">Light</Option>
|
||||
<Option value="bamboo">Bamboo</Option>
|
||||
<Option value="cat">Cat</Option>
|
||||
</Mentions>
|
||||
);
|
||||
React.render(<Demo />, container);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### Mentions props
|
||||
|
||||
| name | description | type | default |
|
||||
|----------|----------------|----------|--------------|
|
||||
| autoFocus | Auto get focus when component mounted | boolean | `false` |
|
||||
| defaultValue | Default value | string | - |
|
||||
| filterOption | Customize filter option logic | false \| (input: string, option: OptionProps) => boolean | - |
|
||||
| notFoundContent | Set mentions content when not match | ReactNode | 'Not Found' |
|
||||
| placement | Set popup placement | 'top' \| 'bottom' | 'bottom' |
|
||||
| direction | Set popup direction | 'ltr' \| 'rtl' | 'ltr' |
|
||||
| prefix | Set trigger prefix keyword | string \| string[] | '@' |
|
||||
| rows | Set row count | number | 1 |
|
||||
| split | Set split string before and after selected mention | string | ' ' |
|
||||
| validateSearch | Customize trigger search logic | (text: string, props: MentionsProps) => void | - |
|
||||
| value | Set value of mentions | string | - |
|
||||
| onChange | Trigger when value changed |(text: string) => void | - |
|
||||
| onSelect | Trigger when user select the option | (option: OptionProps, prefix: string) => void | - |
|
||||
| onSearch | Trigger when prefix hit | (text: string, prefix: string) => void | - |
|
||||
| onFocus | Trigger when mentions get focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
|
||||
| onBlur | Trigger when mentions lose focus | React.FocusEventHandler<HTMLTextAreaElement> | - |
|
||||
| getPopupContainer | DOM Container for suggestions | () => HTMLElement | - |
|
||||
|
||||
### Methods
|
||||
|
||||
| name | description |
|
||||
|----------|----------------|
|
||||
| focus() | Component get focus |
|
||||
| blur() | Component lose focus |
|
||||
|
||||
## Development
|
||||
|
||||
```
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
http://localhost:9001/
|
||||
|
||||
online example: http://react-component.github.io/mentions/
|
||||
|
||||
## Test Case
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
## Coverage
|
||||
|
||||
```
|
||||
npm run coverage
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
rc-mentions is released under the MIT license.
|
||||
16
web/node_modules/rc-mentions/es/DropdownMenu.d.ts
generated
vendored
Normal file
16
web/node_modules/rc-mentions/es/DropdownMenu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { MentionsContextProps } from './MentionsContext';
|
||||
import { OptionProps } from './Option';
|
||||
interface DropdownMenuProps {
|
||||
prefixCls?: string;
|
||||
options: OptionProps[];
|
||||
}
|
||||
/**
|
||||
* We only use Menu to display the candidate.
|
||||
* The focus is controlled by textarea to make accessibility easy.
|
||||
*/
|
||||
declare class DropdownMenu extends React.Component<DropdownMenuProps, {}> {
|
||||
renderDropdown: ({ notFoundContent, activeIndex, setActiveIndex, selectOption, onFocus, onBlur, }: MentionsContextProps) => JSX.Element;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default DropdownMenu;
|
||||
96
web/node_modules/rc-mentions/es/DropdownMenu.js
generated
vendored
Normal file
96
web/node_modules/rc-mentions/es/DropdownMenu.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
import Menu, { MenuItem } from 'rc-menu';
|
||||
import * as React from 'react';
|
||||
import { MentionsContextConsumer } from './MentionsContext';
|
||||
/**
|
||||
* We only use Menu to display the candidate.
|
||||
* The focus is controlled by textarea to make accessibility easy.
|
||||
*/
|
||||
|
||||
var DropdownMenu =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(DropdownMenu, _React$Component);
|
||||
|
||||
function DropdownMenu() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, DropdownMenu);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(DropdownMenu).apply(this, arguments));
|
||||
|
||||
_this.renderDropdown = function (_ref) {
|
||||
var notFoundContent = _ref.notFoundContent,
|
||||
activeIndex = _ref.activeIndex,
|
||||
setActiveIndex = _ref.setActiveIndex,
|
||||
selectOption = _ref.selectOption,
|
||||
onFocus = _ref.onFocus,
|
||||
onBlur = _ref.onBlur;
|
||||
var _this$props = _this.props,
|
||||
prefixCls = _this$props.prefixCls,
|
||||
options = _this$props.options;
|
||||
var activeOption = options[activeIndex] || {};
|
||||
return React.createElement(Menu, {
|
||||
prefixCls: "".concat(prefixCls, "-menu"),
|
||||
activeKey: activeOption.value,
|
||||
onSelect: function onSelect(_ref2) {
|
||||
var key = _ref2.key;
|
||||
var option = options.find(function (_ref3) {
|
||||
var value = _ref3.value;
|
||||
return value === key;
|
||||
});
|
||||
selectOption(option);
|
||||
},
|
||||
onFocus: onFocus,
|
||||
onBlur: onBlur
|
||||
}, options.map(function (option, index) {
|
||||
var value = option.value,
|
||||
disabled = option.disabled,
|
||||
children = option.children,
|
||||
className = option.className,
|
||||
style = option.style;
|
||||
return React.createElement(MenuItem, {
|
||||
key: value,
|
||||
disabled: disabled,
|
||||
className: className,
|
||||
style: style,
|
||||
onMouseEnter: function onMouseEnter() {
|
||||
setActiveIndex(index);
|
||||
}
|
||||
}, children);
|
||||
}), !options.length && React.createElement(MenuItem, {
|
||||
disabled: true
|
||||
}, notFoundContent));
|
||||
};
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(DropdownMenu, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return React.createElement(MentionsContextConsumer, null, this.renderDropdown);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DropdownMenu;
|
||||
}(React.Component);
|
||||
|
||||
export default DropdownMenu;
|
||||
21
web/node_modules/rc-mentions/es/KeywordTrigger.d.ts
generated
vendored
Normal file
21
web/node_modules/rc-mentions/es/KeywordTrigger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
import { Placement, Direction } from './Mentions';
|
||||
interface KeywordTriggerProps {
|
||||
loading?: boolean;
|
||||
options: OptionProps[];
|
||||
prefixCls?: string;
|
||||
placement?: Placement;
|
||||
direction?: Direction;
|
||||
visible?: boolean;
|
||||
transitionName?: string;
|
||||
children?: React.ReactElement;
|
||||
getPopupContainer?: () => HTMLElement;
|
||||
}
|
||||
declare class KeywordTrigger extends React.Component<KeywordTriggerProps, {}> {
|
||||
getDropdownPrefix: () => string;
|
||||
getDropdownElement: () => JSX.Element;
|
||||
getDropDownPlacement: () => string;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default KeywordTrigger;
|
||||
123
web/node_modules/rc-mentions/es/KeywordTrigger.js
generated
vendored
Normal file
123
web/node_modules/rc-mentions/es/KeywordTrigger.js
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
import Trigger from 'rc-trigger';
|
||||
import * as React from 'react';
|
||||
import DropdownMenu from './DropdownMenu';
|
||||
var BUILT_IN_PLACEMENTS = {
|
||||
bottomRight: {
|
||||
points: ['tl', 'br'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
bottomLeft: {
|
||||
points: ['tr', 'bl'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
topRight: {
|
||||
points: ['bl', 'tr'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
topLeft: {
|
||||
points: ['br', 'tl'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var KeywordTrigger =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(KeywordTrigger, _React$Component);
|
||||
|
||||
function KeywordTrigger() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, KeywordTrigger);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(KeywordTrigger).apply(this, arguments));
|
||||
|
||||
_this.getDropdownPrefix = function () {
|
||||
return "".concat(_this.props.prefixCls, "-dropdown");
|
||||
};
|
||||
|
||||
_this.getDropdownElement = function () {
|
||||
var options = _this.props.options;
|
||||
return React.createElement(DropdownMenu, {
|
||||
prefixCls: _this.getDropdownPrefix(),
|
||||
options: options
|
||||
});
|
||||
};
|
||||
|
||||
_this.getDropDownPlacement = function () {
|
||||
var _this$props = _this.props,
|
||||
placement = _this$props.placement,
|
||||
direction = _this$props.direction;
|
||||
var popupPlacement = 'topRight';
|
||||
|
||||
if (direction === 'rtl') {
|
||||
popupPlacement = placement === 'top' ? 'topLeft' : 'bottomLeft';
|
||||
} else {
|
||||
popupPlacement = placement === 'top' ? 'topRight' : 'bottomRight';
|
||||
}
|
||||
|
||||
return popupPlacement;
|
||||
};
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(KeywordTrigger, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props2 = this.props,
|
||||
children = _this$props2.children,
|
||||
visible = _this$props2.visible,
|
||||
transitionName = _this$props2.transitionName,
|
||||
getPopupContainer = _this$props2.getPopupContainer;
|
||||
var popupElement = this.getDropdownElement();
|
||||
return React.createElement(Trigger, {
|
||||
prefixCls: this.getDropdownPrefix(),
|
||||
popupVisible: visible,
|
||||
popup: popupElement,
|
||||
popupPlacement: this.getDropDownPlacement(),
|
||||
popupTransitionName: transitionName,
|
||||
builtinPlacements: BUILT_IN_PLACEMENTS,
|
||||
getPopupContainer: getPopupContainer
|
||||
}, children);
|
||||
}
|
||||
}]);
|
||||
|
||||
return KeywordTrigger;
|
||||
}(React.Component);
|
||||
|
||||
export default KeywordTrigger;
|
||||
88
web/node_modules/rc-mentions/es/Mentions.d.ts
generated
vendored
Normal file
88
web/node_modules/rc-mentions/es/Mentions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
import { filterOption as defaultFilterOption, Omit, validateSearch as defaultValidateSearch } from './util';
|
||||
declare type BaseTextareaAttrs = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'prefix' | 'onChange' | 'onSelect'>;
|
||||
export declare type Placement = 'top' | 'bottom';
|
||||
export declare type Direction = 'ltr' | 'rtl';
|
||||
export interface MentionsProps extends BaseTextareaAttrs {
|
||||
autoFocus?: boolean;
|
||||
className?: string;
|
||||
defaultValue?: string;
|
||||
notFoundContent?: React.ReactNode;
|
||||
split?: string;
|
||||
style?: React.CSSProperties;
|
||||
transitionName?: string;
|
||||
placement?: Placement;
|
||||
direction?: Direction;
|
||||
prefix?: string | string[];
|
||||
prefixCls?: string;
|
||||
value?: string;
|
||||
filterOption?: false | typeof defaultFilterOption;
|
||||
validateSearch?: typeof defaultValidateSearch;
|
||||
onChange?: (text: string) => void;
|
||||
onSelect?: (option: OptionProps, prefix: string) => void;
|
||||
onSearch?: (text: string, prefix: string) => void;
|
||||
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
getPopupContainer?: () => HTMLElement;
|
||||
}
|
||||
interface MentionsState {
|
||||
value: string;
|
||||
measuring: boolean;
|
||||
measureText: string | null;
|
||||
measurePrefix: string;
|
||||
measureLocation: number;
|
||||
activeIndex: number;
|
||||
isFocus: boolean;
|
||||
}
|
||||
declare class Mentions extends React.Component<MentionsProps, MentionsState> {
|
||||
static Option: React.FunctionComponent<OptionProps>;
|
||||
textarea?: HTMLTextAreaElement;
|
||||
measure?: HTMLDivElement;
|
||||
focusId: number | undefined;
|
||||
static defaultProps: {
|
||||
prefixCls: string;
|
||||
prefix: string;
|
||||
split: string;
|
||||
validateSearch: typeof defaultValidateSearch;
|
||||
filterOption: typeof defaultFilterOption;
|
||||
notFoundContent: string;
|
||||
rows: number;
|
||||
};
|
||||
static getDerivedStateFromProps(props: MentionsProps, prevState: MentionsState): Partial<MentionsState>;
|
||||
constructor(props: MentionsProps);
|
||||
componentDidUpdate(): void;
|
||||
triggerChange: (value: string) => void;
|
||||
onChange: React.ChangeEventHandler<HTMLTextAreaElement>;
|
||||
onKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
||||
/**
|
||||
* When to start measure:
|
||||
* 1. When user press `prefix`
|
||||
* 2. When measureText !== prevMeasureText
|
||||
* - If measure hit
|
||||
* - If measuring
|
||||
*
|
||||
* When to stop measure:
|
||||
* 1. Selection is out of range
|
||||
* 2. Contains `space`
|
||||
* 3. ESC or select one
|
||||
*/
|
||||
onKeyUp: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
||||
onInputFocus: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onInputBlur: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onDropdownFocus: () => void;
|
||||
onDropdownBlur: () => void;
|
||||
onFocus: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||
onBlur: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||
selectOption: (option: OptionProps) => void;
|
||||
setActiveIndex: (activeIndex: number) => void;
|
||||
setTextAreaRef: (element: HTMLTextAreaElement) => void;
|
||||
setMeasureRef: (element: HTMLDivElement) => void;
|
||||
getOptions: (measureText?: string) => OptionProps[];
|
||||
startMeasure(measureText: string, measurePrefix: string, measureLocation: number): void;
|
||||
stopMeasure(callback?: () => void): void;
|
||||
focus(): void;
|
||||
blur(): void;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default Mentions;
|
||||
411
web/node_modules/rc-mentions/es/Mentions.js
generated
vendored
Normal file
411
web/node_modules/rc-mentions/es/Mentions.js
generated
vendored
Normal file
@@ -0,0 +1,411 @@
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
import classNames from 'classnames';
|
||||
import toArray from "rc-util/es/Children/toArray";
|
||||
import KeyCode from "rc-util/es/KeyCode";
|
||||
import * as React from 'react';
|
||||
import KeywordTrigger from './KeywordTrigger';
|
||||
import { MentionsContextProvider } from './MentionsContext';
|
||||
import Option from './Option';
|
||||
import { filterOption as defaultFilterOption, getBeforeSelectionText, getLastMeasureIndex, omit, replaceWithMeasure, setInputSelection, validateSearch as defaultValidateSearch } from './util';
|
||||
|
||||
var Mentions =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(Mentions, _React$Component);
|
||||
|
||||
function Mentions(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Mentions);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Mentions).call(this, props));
|
||||
_this.focusId = undefined;
|
||||
|
||||
_this.triggerChange = function (value) {
|
||||
var onChange = _this.props.onChange;
|
||||
|
||||
if (!('value' in _this.props)) {
|
||||
_this.setState({
|
||||
value: value
|
||||
});
|
||||
}
|
||||
|
||||
if (onChange) {
|
||||
onChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
_this.onChange = function (_ref) {
|
||||
var value = _ref.target.value;
|
||||
|
||||
_this.triggerChange(value);
|
||||
}; // Check if hit the measure keyword
|
||||
|
||||
|
||||
_this.onKeyDown = function (event) {
|
||||
var which = event.which;
|
||||
var _this$state = _this.state,
|
||||
activeIndex = _this$state.activeIndex,
|
||||
measuring = _this$state.measuring; // Skip if not measuring
|
||||
|
||||
if (!measuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (which === KeyCode.UP || which === KeyCode.DOWN) {
|
||||
// Control arrow function
|
||||
var optionLen = _this.getOptions().length;
|
||||
|
||||
var offset = which === KeyCode.UP ? -1 : 1;
|
||||
var newActiveIndex = (activeIndex + offset + optionLen) % optionLen;
|
||||
|
||||
_this.setState({
|
||||
activeIndex: newActiveIndex
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
} else if (which === KeyCode.ESC) {
|
||||
_this.stopMeasure();
|
||||
} else if (which === KeyCode.ENTER) {
|
||||
// Measure hit
|
||||
var option = _this.getOptions()[activeIndex];
|
||||
|
||||
_this.selectOption(option);
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* When to start measure:
|
||||
* 1. When user press `prefix`
|
||||
* 2. When measureText !== prevMeasureText
|
||||
* - If measure hit
|
||||
* - If measuring
|
||||
*
|
||||
* When to stop measure:
|
||||
* 1. Selection is out of range
|
||||
* 2. Contains `space`
|
||||
* 3. ESC or select one
|
||||
*/
|
||||
|
||||
|
||||
_this.onKeyUp = function (event) {
|
||||
var key = event.key,
|
||||
which = event.which;
|
||||
var _this$state2 = _this.state,
|
||||
prevMeasureText = _this$state2.measureText,
|
||||
measuring = _this$state2.measuring;
|
||||
var _this$props = _this.props,
|
||||
_this$props$prefix = _this$props.prefix,
|
||||
prefix = _this$props$prefix === void 0 ? '' : _this$props$prefix,
|
||||
onSearch = _this$props.onSearch,
|
||||
validateSearch = _this$props.validateSearch;
|
||||
var target = event.target;
|
||||
var selectionStartText = getBeforeSelectionText(target);
|
||||
|
||||
var _getLastMeasureIndex = getLastMeasureIndex(selectionStartText, prefix),
|
||||
measureIndex = _getLastMeasureIndex.location,
|
||||
measurePrefix = _getLastMeasureIndex.prefix; // Skip if match the white key list
|
||||
|
||||
|
||||
if ([KeyCode.ESC, KeyCode.UP, KeyCode.DOWN, KeyCode.ENTER].indexOf(which) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (measureIndex !== -1) {
|
||||
var measureText = selectionStartText.slice(measureIndex + measurePrefix.length);
|
||||
var validateMeasure = validateSearch(measureText, _this.props);
|
||||
var matchOption = !!_this.getOptions(measureText).length;
|
||||
|
||||
if (validateMeasure) {
|
||||
if (key === measurePrefix || measuring || measureText !== prevMeasureText && matchOption) {
|
||||
_this.startMeasure(measureText, measurePrefix, measureIndex);
|
||||
}
|
||||
} else if (measuring) {
|
||||
// Stop if measureText is invalidate
|
||||
_this.stopMeasure();
|
||||
}
|
||||
/**
|
||||
* We will trigger `onSearch` to developer since they may use for async update.
|
||||
* If met `space` means user finished searching.
|
||||
*/
|
||||
|
||||
|
||||
if (onSearch && validateMeasure) {
|
||||
onSearch(measureText, measurePrefix);
|
||||
}
|
||||
} else if (measuring) {
|
||||
_this.stopMeasure();
|
||||
}
|
||||
};
|
||||
|
||||
_this.onInputFocus = function (event) {
|
||||
_this.onFocus(event);
|
||||
};
|
||||
|
||||
_this.onInputBlur = function (event) {
|
||||
_this.onBlur(event);
|
||||
};
|
||||
|
||||
_this.onDropdownFocus = function () {
|
||||
_this.onFocus();
|
||||
};
|
||||
|
||||
_this.onDropdownBlur = function () {
|
||||
_this.onBlur();
|
||||
};
|
||||
|
||||
_this.onFocus = function (event) {
|
||||
window.clearTimeout(_this.focusId);
|
||||
var isFocus = _this.state.isFocus;
|
||||
var onFocus = _this.props.onFocus;
|
||||
|
||||
if (!isFocus && event && onFocus) {
|
||||
onFocus(event);
|
||||
}
|
||||
|
||||
_this.setState({
|
||||
isFocus: true
|
||||
});
|
||||
};
|
||||
|
||||
_this.onBlur = function (event) {
|
||||
_this.focusId = window.setTimeout(function () {
|
||||
var onBlur = _this.props.onBlur;
|
||||
|
||||
_this.setState({
|
||||
isFocus: false
|
||||
});
|
||||
|
||||
_this.stopMeasure();
|
||||
|
||||
if (onBlur) {
|
||||
onBlur(event);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
_this.selectOption = function (option) {
|
||||
var _this$state3 = _this.state,
|
||||
value = _this$state3.value,
|
||||
measureLocation = _this$state3.measureLocation,
|
||||
measurePrefix = _this$state3.measurePrefix;
|
||||
var _this$props2 = _this.props,
|
||||
split = _this$props2.split,
|
||||
onSelect = _this$props2.onSelect;
|
||||
var _option$value = option.value,
|
||||
mentionValue = _option$value === void 0 ? '' : _option$value;
|
||||
|
||||
var _replaceWithMeasure = replaceWithMeasure(value, {
|
||||
measureLocation: measureLocation,
|
||||
targetText: mentionValue,
|
||||
prefix: measurePrefix,
|
||||
selectionStart: _this.textarea.selectionStart,
|
||||
split: split
|
||||
}),
|
||||
text = _replaceWithMeasure.text,
|
||||
selectionLocation = _replaceWithMeasure.selectionLocation;
|
||||
|
||||
_this.triggerChange(text);
|
||||
|
||||
_this.stopMeasure(function () {
|
||||
// We need restore the selection position
|
||||
setInputSelection(_this.textarea, selectionLocation);
|
||||
});
|
||||
|
||||
if (onSelect) {
|
||||
onSelect(option, measurePrefix);
|
||||
}
|
||||
};
|
||||
|
||||
_this.setActiveIndex = function (activeIndex) {
|
||||
_this.setState({
|
||||
activeIndex: activeIndex
|
||||
});
|
||||
};
|
||||
|
||||
_this.setTextAreaRef = function (element) {
|
||||
_this.textarea = element;
|
||||
};
|
||||
|
||||
_this.setMeasureRef = function (element) {
|
||||
_this.measure = element;
|
||||
};
|
||||
|
||||
_this.getOptions = function (measureText) {
|
||||
var targetMeasureText = measureText || _this.state.measureText || '';
|
||||
var _this$props3 = _this.props,
|
||||
children = _this$props3.children,
|
||||
filterOption = _this$props3.filterOption;
|
||||
var list = toArray(children).map(function (_ref2) {
|
||||
var props = _ref2.props;
|
||||
return props;
|
||||
}).filter(function (option) {
|
||||
/** Return all result if `filterOption` is false. */
|
||||
if (filterOption === false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return filterOption(targetMeasureText, option);
|
||||
});
|
||||
return list;
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
value: props.defaultValue || props.value || '',
|
||||
measuring: false,
|
||||
measureLocation: 0,
|
||||
measureText: null,
|
||||
measurePrefix: '',
|
||||
activeIndex: 0,
|
||||
isFocus: false
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Mentions, [{
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
var measuring = this.state.measuring; // Sync measure div top with textarea for rc-trigger usage
|
||||
|
||||
if (measuring) {
|
||||
this.measure.scrollTop = this.textarea.scrollTop;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "startMeasure",
|
||||
value: function startMeasure(measureText, measurePrefix, measureLocation) {
|
||||
this.setState({
|
||||
measuring: true,
|
||||
measureText: measureText,
|
||||
measurePrefix: measurePrefix,
|
||||
measureLocation: measureLocation,
|
||||
activeIndex: 0
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "stopMeasure",
|
||||
value: function stopMeasure(callback) {
|
||||
this.setState({
|
||||
measuring: false,
|
||||
measureLocation: 0,
|
||||
measureText: null
|
||||
}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "focus",
|
||||
value: function focus() {
|
||||
this.textarea.focus();
|
||||
}
|
||||
}, {
|
||||
key: "blur",
|
||||
value: function blur() {
|
||||
this.textarea.blur();
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$state4 = this.state,
|
||||
value = _this$state4.value,
|
||||
measureLocation = _this$state4.measureLocation,
|
||||
measurePrefix = _this$state4.measurePrefix,
|
||||
measuring = _this$state4.measuring,
|
||||
activeIndex = _this$state4.activeIndex;
|
||||
|
||||
var _this$props4 = this.props,
|
||||
prefixCls = _this$props4.prefixCls,
|
||||
placement = _this$props4.placement,
|
||||
direction = _this$props4.direction,
|
||||
transitionName = _this$props4.transitionName,
|
||||
className = _this$props4.className,
|
||||
style = _this$props4.style,
|
||||
autoFocus = _this$props4.autoFocus,
|
||||
notFoundContent = _this$props4.notFoundContent,
|
||||
getPopupContainer = _this$props4.getPopupContainer,
|
||||
restProps = _objectWithoutProperties(_this$props4, ["prefixCls", "placement", "direction", "transitionName", "className", "style", "autoFocus", "notFoundContent", "getPopupContainer"]);
|
||||
|
||||
var inputProps = omit(restProps, 'value', 'defaultValue', 'prefix', 'split', 'children', 'validateSearch', 'filterOption', 'onSelect', 'onSearch');
|
||||
var options = measuring ? this.getOptions() : [];
|
||||
return React.createElement("div", {
|
||||
className: classNames(prefixCls, className),
|
||||
style: style
|
||||
}, React.createElement("textarea", Object.assign({
|
||||
autoFocus: autoFocus,
|
||||
ref: this.setTextAreaRef,
|
||||
value: value
|
||||
}, inputProps, {
|
||||
onChange: this.onChange,
|
||||
onKeyDown: this.onKeyDown,
|
||||
onKeyUp: this.onKeyUp,
|
||||
onFocus: this.onInputFocus,
|
||||
onBlur: this.onInputBlur
|
||||
})), measuring && React.createElement("div", {
|
||||
ref: this.setMeasureRef,
|
||||
className: "".concat(prefixCls, "-measure")
|
||||
}, value.slice(0, measureLocation), React.createElement(MentionsContextProvider, {
|
||||
value: {
|
||||
notFoundContent: notFoundContent,
|
||||
activeIndex: activeIndex,
|
||||
setActiveIndex: this.setActiveIndex,
|
||||
selectOption: this.selectOption,
|
||||
onFocus: this.onDropdownFocus,
|
||||
onBlur: this.onDropdownBlur
|
||||
}
|
||||
}, React.createElement(KeywordTrigger, {
|
||||
prefixCls: prefixCls,
|
||||
transitionName: transitionName,
|
||||
placement: placement,
|
||||
direction: direction,
|
||||
options: options,
|
||||
visible: true,
|
||||
getPopupContainer: getPopupContainer
|
||||
}, React.createElement("span", null, measurePrefix))), value.slice(measureLocation + measurePrefix.length)));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(props, prevState) {
|
||||
var newState = {};
|
||||
|
||||
if ('value' in props && props.value !== prevState.value) {
|
||||
newState.value = props.value || '';
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Mentions;
|
||||
}(React.Component);
|
||||
|
||||
Mentions.Option = Option;
|
||||
Mentions.defaultProps = {
|
||||
prefixCls: 'rc-mentions',
|
||||
prefix: '@',
|
||||
split: ' ',
|
||||
validateSearch: defaultValidateSearch,
|
||||
filterOption: defaultFilterOption,
|
||||
notFoundContent: 'Not Found',
|
||||
rows: 1
|
||||
};
|
||||
export default Mentions;
|
||||
12
web/node_modules/rc-mentions/es/MentionsContext.d.ts
generated
vendored
Normal file
12
web/node_modules/rc-mentions/es/MentionsContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
export interface MentionsContextProps {
|
||||
notFoundContent: React.ReactNode;
|
||||
activeIndex: number;
|
||||
setActiveIndex: (index: number) => void;
|
||||
selectOption: (option: OptionProps) => void;
|
||||
onFocus: React.FocusEventHandler<HTMLElement>;
|
||||
onBlur: React.FocusEventHandler<HTMLElement>;
|
||||
}
|
||||
export declare const MentionsContextProvider: React.ProviderExoticComponent<React.ProviderProps<MentionsContextProps>>;
|
||||
export declare const MentionsContextConsumer: React.ExoticComponent<React.ConsumerProps<MentionsContextProps>>;
|
||||
6
web/node_modules/rc-mentions/es/MentionsContext.js
generated
vendored
Normal file
6
web/node_modules/rc-mentions/es/MentionsContext.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/* tslint:disable: no-object-literal-type-assertion */
|
||||
import * as React from 'react'; // We will never use default, here only to fix TypeScript warning
|
||||
|
||||
var MentionsContext = React.createContext(null);
|
||||
export var MentionsContextProvider = MentionsContext.Provider;
|
||||
export var MentionsContextConsumer = MentionsContext.Consumer;
|
||||
10
web/node_modules/rc-mentions/es/Option.d.ts
generated
vendored
Normal file
10
web/node_modules/rc-mentions/es/Option.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
export interface OptionProps {
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
declare const Option: React.SFC<OptionProps>;
|
||||
export default Option;
|
||||
5
web/node_modules/rc-mentions/es/Option.js
generated
vendored
Normal file
5
web/node_modules/rc-mentions/es/Option.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var Option = function Option() {
|
||||
return null;
|
||||
};
|
||||
|
||||
export default Option;
|
||||
2
web/node_modules/rc-mentions/es/index.d.ts
generated
vendored
Normal file
2
web/node_modules/rc-mentions/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import Mentions from './Mentions';
|
||||
export default Mentions;
|
||||
2
web/node_modules/rc-mentions/es/index.js
generated
vendored
Normal file
2
web/node_modules/rc-mentions/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import Mentions from './Mentions';
|
||||
export default Mentions;
|
||||
40
web/node_modules/rc-mentions/es/util.d.ts
generated
vendored
Normal file
40
web/node_modules/rc-mentions/es/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { MentionsProps } from './Mentions';
|
||||
import { OptionProps } from './Option';
|
||||
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
declare type OmitFunc = <T extends object, K extends [...(keyof T)[]]>(obj: T, ...keys: K) => {
|
||||
[K2 in Exclude<keyof T, K[number]>]: T[K2];
|
||||
};
|
||||
export declare const omit: OmitFunc;
|
||||
/**
|
||||
* Cut input selection into 2 part and return text before selection start
|
||||
*/
|
||||
export declare function getBeforeSelectionText(input: HTMLTextAreaElement): string;
|
||||
interface MeasureIndex {
|
||||
location: number;
|
||||
prefix: string;
|
||||
}
|
||||
/**
|
||||
* Find the last match prefix index
|
||||
*/
|
||||
export declare function getLastMeasureIndex(text: string, prefix?: string | string[]): MeasureIndex;
|
||||
interface MeasureConfig {
|
||||
measureLocation: number;
|
||||
prefix: string;
|
||||
targetText: string;
|
||||
selectionStart: number;
|
||||
split: string;
|
||||
}
|
||||
/**
|
||||
* Paint targetText into current text:
|
||||
* text: little@litest
|
||||
* targetText: light
|
||||
* => little @light test
|
||||
*/
|
||||
export declare function replaceWithMeasure(text: string, measureConfig: MeasureConfig): {
|
||||
text: string;
|
||||
selectionLocation: number;
|
||||
};
|
||||
export declare function setInputSelection(input: HTMLTextAreaElement, location: number): void;
|
||||
export declare function validateSearch(text: string, props: MentionsProps): boolean;
|
||||
export declare function filterOption(input: string, { value }: OptionProps): boolean;
|
||||
export {};
|
||||
134
web/node_modules/rc-mentions/es/util.js
generated
vendored
Normal file
134
web/node_modules/rc-mentions/es/util.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
export var omit = function omit(obj) {
|
||||
var clone = _objectSpread({}, obj);
|
||||
|
||||
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
keys[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
delete clone[key];
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
/**
|
||||
* Cut input selection into 2 part and return text before selection start
|
||||
*/
|
||||
|
||||
export function getBeforeSelectionText(input) {
|
||||
var selectionStart = input.selectionStart;
|
||||
return input.value.slice(0, selectionStart);
|
||||
}
|
||||
/**
|
||||
* Find the last match prefix index
|
||||
*/
|
||||
|
||||
export function getLastMeasureIndex(text) {
|
||||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
var prefixList = Array.isArray(prefix) ? prefix : [prefix];
|
||||
return prefixList.reduce(function (lastMatch, prefixStr) {
|
||||
var lastIndex = text.lastIndexOf(prefixStr);
|
||||
|
||||
if (lastIndex > lastMatch.location) {
|
||||
return {
|
||||
location: lastIndex,
|
||||
prefix: prefixStr
|
||||
};
|
||||
}
|
||||
|
||||
return lastMatch;
|
||||
}, {
|
||||
location: -1,
|
||||
prefix: ''
|
||||
});
|
||||
}
|
||||
|
||||
function lower(char) {
|
||||
return (char || '').toLowerCase();
|
||||
}
|
||||
|
||||
function reduceText(text, targetText, split) {
|
||||
var firstChar = text[0];
|
||||
|
||||
if (!firstChar || firstChar === split) {
|
||||
return text;
|
||||
} // Reuse rest text as it can
|
||||
|
||||
|
||||
var restText = text;
|
||||
var targetTextLen = targetText.length;
|
||||
|
||||
for (var i = 0; i < targetTextLen; i += 1) {
|
||||
if (lower(restText[i]) !== lower(targetText[i])) {
|
||||
restText = restText.slice(i);
|
||||
break;
|
||||
} else if (i === targetTextLen - 1) {
|
||||
restText = restText.slice(targetTextLen);
|
||||
}
|
||||
}
|
||||
|
||||
return restText;
|
||||
}
|
||||
/**
|
||||
* Paint targetText into current text:
|
||||
* text: little@litest
|
||||
* targetText: light
|
||||
* => little @light test
|
||||
*/
|
||||
|
||||
|
||||
export function replaceWithMeasure(text, measureConfig) {
|
||||
var measureLocation = measureConfig.measureLocation,
|
||||
prefix = measureConfig.prefix,
|
||||
targetText = measureConfig.targetText,
|
||||
selectionStart = measureConfig.selectionStart,
|
||||
split = measureConfig.split; // Before text will append one space if have other text
|
||||
|
||||
var beforeMeasureText = text.slice(0, measureLocation);
|
||||
|
||||
if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {
|
||||
beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);
|
||||
}
|
||||
|
||||
if (beforeMeasureText) {
|
||||
beforeMeasureText = "".concat(beforeMeasureText).concat(split);
|
||||
} // Cut duplicate string with current targetText
|
||||
|
||||
|
||||
var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);
|
||||
|
||||
if (restText.slice(0, split.length) === split) {
|
||||
restText = restText.slice(split.length);
|
||||
}
|
||||
|
||||
var connectedStartText = "".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);
|
||||
return {
|
||||
text: "".concat(connectedStartText).concat(restText),
|
||||
selectionLocation: connectedStartText.length
|
||||
};
|
||||
}
|
||||
export function setInputSelection(input, location) {
|
||||
input.setSelectionRange(location, location);
|
||||
/**
|
||||
* Reset caret into view.
|
||||
* Since this function always called by user control, it's safe to focus element.
|
||||
*/
|
||||
|
||||
input.blur();
|
||||
input.focus();
|
||||
}
|
||||
export function validateSearch(text, props) {
|
||||
var split = props.split;
|
||||
return !split || text.indexOf(split) === -1;
|
||||
}
|
||||
export function filterOption(input, _ref) {
|
||||
var _ref$value = _ref.value,
|
||||
value = _ref$value === void 0 ? '' : _ref$value;
|
||||
var lowerCase = input.toLowerCase();
|
||||
return value.toLowerCase().indexOf(lowerCase) !== -1;
|
||||
}
|
||||
16
web/node_modules/rc-mentions/lib/DropdownMenu.d.ts
generated
vendored
Normal file
16
web/node_modules/rc-mentions/lib/DropdownMenu.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as React from 'react';
|
||||
import { MentionsContextProps } from './MentionsContext';
|
||||
import { OptionProps } from './Option';
|
||||
interface DropdownMenuProps {
|
||||
prefixCls?: string;
|
||||
options: OptionProps[];
|
||||
}
|
||||
/**
|
||||
* We only use Menu to display the candidate.
|
||||
* The focus is controlled by textarea to make accessibility easy.
|
||||
*/
|
||||
declare class DropdownMenu extends React.Component<DropdownMenuProps, {}> {
|
||||
renderDropdown: ({ notFoundContent, activeIndex, setActiveIndex, selectOption, onFocus, onBlur, }: MentionsContextProps) => JSX.Element;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default DropdownMenu;
|
||||
108
web/node_modules/rc-mentions/lib/DropdownMenu.js
generated
vendored
Normal file
108
web/node_modules/rc-mentions/lib/DropdownMenu.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _rcMenu = _interopRequireWildcard(require("rc-menu"));
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
var _MentionsContext = require("./MentionsContext");
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
/**
|
||||
* We only use Menu to display the candidate.
|
||||
* The focus is controlled by textarea to make accessibility easy.
|
||||
*/
|
||||
var DropdownMenu =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(DropdownMenu, _React$Component);
|
||||
|
||||
function DropdownMenu() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, DropdownMenu);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(DropdownMenu).apply(this, arguments));
|
||||
|
||||
_this.renderDropdown = function (_ref) {
|
||||
var notFoundContent = _ref.notFoundContent,
|
||||
activeIndex = _ref.activeIndex,
|
||||
setActiveIndex = _ref.setActiveIndex,
|
||||
selectOption = _ref.selectOption,
|
||||
onFocus = _ref.onFocus,
|
||||
onBlur = _ref.onBlur;
|
||||
var _this$props = _this.props,
|
||||
prefixCls = _this$props.prefixCls,
|
||||
options = _this$props.options;
|
||||
var activeOption = options[activeIndex] || {};
|
||||
return React.createElement(_rcMenu.default, {
|
||||
prefixCls: "".concat(prefixCls, "-menu"),
|
||||
activeKey: activeOption.value,
|
||||
onSelect: function onSelect(_ref2) {
|
||||
var key = _ref2.key;
|
||||
var option = options.find(function (_ref3) {
|
||||
var value = _ref3.value;
|
||||
return value === key;
|
||||
});
|
||||
selectOption(option);
|
||||
},
|
||||
onFocus: onFocus,
|
||||
onBlur: onBlur
|
||||
}, options.map(function (option, index) {
|
||||
var value = option.value,
|
||||
disabled = option.disabled,
|
||||
children = option.children,
|
||||
className = option.className,
|
||||
style = option.style;
|
||||
return React.createElement(_rcMenu.MenuItem, {
|
||||
key: value,
|
||||
disabled: disabled,
|
||||
className: className,
|
||||
style: style,
|
||||
onMouseEnter: function onMouseEnter() {
|
||||
setActiveIndex(index);
|
||||
}
|
||||
}, children);
|
||||
}), !options.length && React.createElement(_rcMenu.MenuItem, {
|
||||
disabled: true
|
||||
}, notFoundContent));
|
||||
};
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(DropdownMenu, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
return React.createElement(_MentionsContext.MentionsContextConsumer, null, this.renderDropdown);
|
||||
}
|
||||
}]);
|
||||
|
||||
return DropdownMenu;
|
||||
}(React.Component);
|
||||
|
||||
var _default = DropdownMenu;
|
||||
exports.default = _default;
|
||||
21
web/node_modules/rc-mentions/lib/KeywordTrigger.d.ts
generated
vendored
Normal file
21
web/node_modules/rc-mentions/lib/KeywordTrigger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
import { Placement, Direction } from './Mentions';
|
||||
interface KeywordTriggerProps {
|
||||
loading?: boolean;
|
||||
options: OptionProps[];
|
||||
prefixCls?: string;
|
||||
placement?: Placement;
|
||||
direction?: Direction;
|
||||
visible?: boolean;
|
||||
transitionName?: string;
|
||||
children?: React.ReactElement;
|
||||
getPopupContainer?: () => HTMLElement;
|
||||
}
|
||||
declare class KeywordTrigger extends React.Component<KeywordTriggerProps, {}> {
|
||||
getDropdownPrefix: () => string;
|
||||
getDropdownElement: () => JSX.Element;
|
||||
getDropDownPlacement: () => string;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default KeywordTrigger;
|
||||
138
web/node_modules/rc-mentions/lib/KeywordTrigger.js
generated
vendored
Normal file
138
web/node_modules/rc-mentions/lib/KeywordTrigger.js
generated
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _rcTrigger = _interopRequireDefault(require("rc-trigger"));
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
var BUILT_IN_PLACEMENTS = {
|
||||
bottomRight: {
|
||||
points: ['tl', 'br'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
bottomLeft: {
|
||||
points: ['tr', 'bl'],
|
||||
offset: [0, 4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
topRight: {
|
||||
points: ['bl', 'tr'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
},
|
||||
topLeft: {
|
||||
points: ['br', 'tl'],
|
||||
offset: [0, -4],
|
||||
overflow: {
|
||||
adjustX: 0,
|
||||
adjustY: 1
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var KeywordTrigger =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(KeywordTrigger, _React$Component);
|
||||
|
||||
function KeywordTrigger() {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, KeywordTrigger);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(KeywordTrigger).apply(this, arguments));
|
||||
|
||||
_this.getDropdownPrefix = function () {
|
||||
return "".concat(_this.props.prefixCls, "-dropdown");
|
||||
};
|
||||
|
||||
_this.getDropdownElement = function () {
|
||||
var options = _this.props.options;
|
||||
return React.createElement(_DropdownMenu.default, {
|
||||
prefixCls: _this.getDropdownPrefix(),
|
||||
options: options
|
||||
});
|
||||
};
|
||||
|
||||
_this.getDropDownPlacement = function () {
|
||||
var _this$props = _this.props,
|
||||
placement = _this$props.placement,
|
||||
direction = _this$props.direction;
|
||||
var popupPlacement = 'topRight';
|
||||
|
||||
if (direction === 'rtl') {
|
||||
popupPlacement = placement === 'top' ? 'topLeft' : 'bottomLeft';
|
||||
} else {
|
||||
popupPlacement = placement === 'top' ? 'topRight' : 'bottomRight';
|
||||
}
|
||||
|
||||
return popupPlacement;
|
||||
};
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(KeywordTrigger, [{
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$props2 = this.props,
|
||||
children = _this$props2.children,
|
||||
visible = _this$props2.visible,
|
||||
transitionName = _this$props2.transitionName,
|
||||
getPopupContainer = _this$props2.getPopupContainer;
|
||||
var popupElement = this.getDropdownElement();
|
||||
return React.createElement(_rcTrigger.default, {
|
||||
prefixCls: this.getDropdownPrefix(),
|
||||
popupVisible: visible,
|
||||
popup: popupElement,
|
||||
popupPlacement: this.getDropDownPlacement(),
|
||||
popupTransitionName: transitionName,
|
||||
builtinPlacements: BUILT_IN_PLACEMENTS,
|
||||
getPopupContainer: getPopupContainer
|
||||
}, children);
|
||||
}
|
||||
}]);
|
||||
|
||||
return KeywordTrigger;
|
||||
}(React.Component);
|
||||
|
||||
var _default = KeywordTrigger;
|
||||
exports.default = _default;
|
||||
88
web/node_modules/rc-mentions/lib/Mentions.d.ts
generated
vendored
Normal file
88
web/node_modules/rc-mentions/lib/Mentions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
import { filterOption as defaultFilterOption, Omit, validateSearch as defaultValidateSearch } from './util';
|
||||
declare type BaseTextareaAttrs = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'prefix' | 'onChange' | 'onSelect'>;
|
||||
export declare type Placement = 'top' | 'bottom';
|
||||
export declare type Direction = 'ltr' | 'rtl';
|
||||
export interface MentionsProps extends BaseTextareaAttrs {
|
||||
autoFocus?: boolean;
|
||||
className?: string;
|
||||
defaultValue?: string;
|
||||
notFoundContent?: React.ReactNode;
|
||||
split?: string;
|
||||
style?: React.CSSProperties;
|
||||
transitionName?: string;
|
||||
placement?: Placement;
|
||||
direction?: Direction;
|
||||
prefix?: string | string[];
|
||||
prefixCls?: string;
|
||||
value?: string;
|
||||
filterOption?: false | typeof defaultFilterOption;
|
||||
validateSearch?: typeof defaultValidateSearch;
|
||||
onChange?: (text: string) => void;
|
||||
onSelect?: (option: OptionProps, prefix: string) => void;
|
||||
onSearch?: (text: string, prefix: string) => void;
|
||||
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
getPopupContainer?: () => HTMLElement;
|
||||
}
|
||||
interface MentionsState {
|
||||
value: string;
|
||||
measuring: boolean;
|
||||
measureText: string | null;
|
||||
measurePrefix: string;
|
||||
measureLocation: number;
|
||||
activeIndex: number;
|
||||
isFocus: boolean;
|
||||
}
|
||||
declare class Mentions extends React.Component<MentionsProps, MentionsState> {
|
||||
static Option: React.FunctionComponent<OptionProps>;
|
||||
textarea?: HTMLTextAreaElement;
|
||||
measure?: HTMLDivElement;
|
||||
focusId: number | undefined;
|
||||
static defaultProps: {
|
||||
prefixCls: string;
|
||||
prefix: string;
|
||||
split: string;
|
||||
validateSearch: typeof defaultValidateSearch;
|
||||
filterOption: typeof defaultFilterOption;
|
||||
notFoundContent: string;
|
||||
rows: number;
|
||||
};
|
||||
static getDerivedStateFromProps(props: MentionsProps, prevState: MentionsState): Partial<MentionsState>;
|
||||
constructor(props: MentionsProps);
|
||||
componentDidUpdate(): void;
|
||||
triggerChange: (value: string) => void;
|
||||
onChange: React.ChangeEventHandler<HTMLTextAreaElement>;
|
||||
onKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
||||
/**
|
||||
* When to start measure:
|
||||
* 1. When user press `prefix`
|
||||
* 2. When measureText !== prevMeasureText
|
||||
* - If measure hit
|
||||
* - If measuring
|
||||
*
|
||||
* When to stop measure:
|
||||
* 1. Selection is out of range
|
||||
* 2. Contains `space`
|
||||
* 3. ESC or select one
|
||||
*/
|
||||
onKeyUp: React.KeyboardEventHandler<HTMLTextAreaElement>;
|
||||
onInputFocus: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onInputBlur: React.FocusEventHandler<HTMLTextAreaElement>;
|
||||
onDropdownFocus: () => void;
|
||||
onDropdownBlur: () => void;
|
||||
onFocus: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||
onBlur: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
|
||||
selectOption: (option: OptionProps) => void;
|
||||
setActiveIndex: (activeIndex: number) => void;
|
||||
setTextAreaRef: (element: HTMLTextAreaElement) => void;
|
||||
setMeasureRef: (element: HTMLDivElement) => void;
|
||||
getOptions: (measureText?: string) => OptionProps[];
|
||||
startMeasure(measureText: string, measurePrefix: string, measureLocation: number): void;
|
||||
stopMeasure(callback?: () => void): void;
|
||||
focus(): void;
|
||||
blur(): void;
|
||||
render(): JSX.Element;
|
||||
}
|
||||
export default Mentions;
|
||||
430
web/node_modules/rc-mentions/lib/Mentions.js
generated
vendored
Normal file
430
web/node_modules/rc-mentions/lib/Mentions.js
generated
vendored
Normal file
@@ -0,0 +1,430 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _classnames = _interopRequireDefault(require("classnames"));
|
||||
|
||||
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
|
||||
|
||||
var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
var _KeywordTrigger = _interopRequireDefault(require("./KeywordTrigger"));
|
||||
|
||||
var _MentionsContext = require("./MentionsContext");
|
||||
|
||||
var _Option = _interopRequireDefault(require("./Option"));
|
||||
|
||||
var _util = require("./util");
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
||||
|
||||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
||||
|
||||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
||||
|
||||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
||||
|
||||
var Mentions =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inherits(Mentions, _React$Component);
|
||||
|
||||
function Mentions(props) {
|
||||
var _this;
|
||||
|
||||
_classCallCheck(this, Mentions);
|
||||
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(Mentions).call(this, props));
|
||||
_this.focusId = undefined;
|
||||
|
||||
_this.triggerChange = function (value) {
|
||||
var onChange = _this.props.onChange;
|
||||
|
||||
if (!('value' in _this.props)) {
|
||||
_this.setState({
|
||||
value: value
|
||||
});
|
||||
}
|
||||
|
||||
if (onChange) {
|
||||
onChange(value);
|
||||
}
|
||||
};
|
||||
|
||||
_this.onChange = function (_ref) {
|
||||
var value = _ref.target.value;
|
||||
|
||||
_this.triggerChange(value);
|
||||
}; // Check if hit the measure keyword
|
||||
|
||||
|
||||
_this.onKeyDown = function (event) {
|
||||
var which = event.which;
|
||||
var _this$state = _this.state,
|
||||
activeIndex = _this$state.activeIndex,
|
||||
measuring = _this$state.measuring; // Skip if not measuring
|
||||
|
||||
if (!measuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (which === _KeyCode.default.UP || which === _KeyCode.default.DOWN) {
|
||||
// Control arrow function
|
||||
var optionLen = _this.getOptions().length;
|
||||
|
||||
var offset = which === _KeyCode.default.UP ? -1 : 1;
|
||||
var newActiveIndex = (activeIndex + offset + optionLen) % optionLen;
|
||||
|
||||
_this.setState({
|
||||
activeIndex: newActiveIndex
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
} else if (which === _KeyCode.default.ESC) {
|
||||
_this.stopMeasure();
|
||||
} else if (which === _KeyCode.default.ENTER) {
|
||||
// Measure hit
|
||||
var option = _this.getOptions()[activeIndex];
|
||||
|
||||
_this.selectOption(option);
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* When to start measure:
|
||||
* 1. When user press `prefix`
|
||||
* 2. When measureText !== prevMeasureText
|
||||
* - If measure hit
|
||||
* - If measuring
|
||||
*
|
||||
* When to stop measure:
|
||||
* 1. Selection is out of range
|
||||
* 2. Contains `space`
|
||||
* 3. ESC or select one
|
||||
*/
|
||||
|
||||
|
||||
_this.onKeyUp = function (event) {
|
||||
var key = event.key,
|
||||
which = event.which;
|
||||
var _this$state2 = _this.state,
|
||||
prevMeasureText = _this$state2.measureText,
|
||||
measuring = _this$state2.measuring;
|
||||
var _this$props = _this.props,
|
||||
_this$props$prefix = _this$props.prefix,
|
||||
prefix = _this$props$prefix === void 0 ? '' : _this$props$prefix,
|
||||
onSearch = _this$props.onSearch,
|
||||
validateSearch = _this$props.validateSearch;
|
||||
var target = event.target;
|
||||
var selectionStartText = (0, _util.getBeforeSelectionText)(target);
|
||||
|
||||
var _getLastMeasureIndex = (0, _util.getLastMeasureIndex)(selectionStartText, prefix),
|
||||
measureIndex = _getLastMeasureIndex.location,
|
||||
measurePrefix = _getLastMeasureIndex.prefix; // Skip if match the white key list
|
||||
|
||||
|
||||
if ([_KeyCode.default.ESC, _KeyCode.default.UP, _KeyCode.default.DOWN, _KeyCode.default.ENTER].indexOf(which) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (measureIndex !== -1) {
|
||||
var measureText = selectionStartText.slice(measureIndex + measurePrefix.length);
|
||||
var validateMeasure = validateSearch(measureText, _this.props);
|
||||
var matchOption = !!_this.getOptions(measureText).length;
|
||||
|
||||
if (validateMeasure) {
|
||||
if (key === measurePrefix || measuring || measureText !== prevMeasureText && matchOption) {
|
||||
_this.startMeasure(measureText, measurePrefix, measureIndex);
|
||||
}
|
||||
} else if (measuring) {
|
||||
// Stop if measureText is invalidate
|
||||
_this.stopMeasure();
|
||||
}
|
||||
/**
|
||||
* We will trigger `onSearch` to developer since they may use for async update.
|
||||
* If met `space` means user finished searching.
|
||||
*/
|
||||
|
||||
|
||||
if (onSearch && validateMeasure) {
|
||||
onSearch(measureText, measurePrefix);
|
||||
}
|
||||
} else if (measuring) {
|
||||
_this.stopMeasure();
|
||||
}
|
||||
};
|
||||
|
||||
_this.onInputFocus = function (event) {
|
||||
_this.onFocus(event);
|
||||
};
|
||||
|
||||
_this.onInputBlur = function (event) {
|
||||
_this.onBlur(event);
|
||||
};
|
||||
|
||||
_this.onDropdownFocus = function () {
|
||||
_this.onFocus();
|
||||
};
|
||||
|
||||
_this.onDropdownBlur = function () {
|
||||
_this.onBlur();
|
||||
};
|
||||
|
||||
_this.onFocus = function (event) {
|
||||
window.clearTimeout(_this.focusId);
|
||||
var isFocus = _this.state.isFocus;
|
||||
var onFocus = _this.props.onFocus;
|
||||
|
||||
if (!isFocus && event && onFocus) {
|
||||
onFocus(event);
|
||||
}
|
||||
|
||||
_this.setState({
|
||||
isFocus: true
|
||||
});
|
||||
};
|
||||
|
||||
_this.onBlur = function (event) {
|
||||
_this.focusId = window.setTimeout(function () {
|
||||
var onBlur = _this.props.onBlur;
|
||||
|
||||
_this.setState({
|
||||
isFocus: false
|
||||
});
|
||||
|
||||
_this.stopMeasure();
|
||||
|
||||
if (onBlur) {
|
||||
onBlur(event);
|
||||
}
|
||||
}, 0);
|
||||
};
|
||||
|
||||
_this.selectOption = function (option) {
|
||||
var _this$state3 = _this.state,
|
||||
value = _this$state3.value,
|
||||
measureLocation = _this$state3.measureLocation,
|
||||
measurePrefix = _this$state3.measurePrefix;
|
||||
var _this$props2 = _this.props,
|
||||
split = _this$props2.split,
|
||||
onSelect = _this$props2.onSelect;
|
||||
var _option$value = option.value,
|
||||
mentionValue = _option$value === void 0 ? '' : _option$value;
|
||||
|
||||
var _replaceWithMeasure = (0, _util.replaceWithMeasure)(value, {
|
||||
measureLocation: measureLocation,
|
||||
targetText: mentionValue,
|
||||
prefix: measurePrefix,
|
||||
selectionStart: _this.textarea.selectionStart,
|
||||
split: split
|
||||
}),
|
||||
text = _replaceWithMeasure.text,
|
||||
selectionLocation = _replaceWithMeasure.selectionLocation;
|
||||
|
||||
_this.triggerChange(text);
|
||||
|
||||
_this.stopMeasure(function () {
|
||||
// We need restore the selection position
|
||||
(0, _util.setInputSelection)(_this.textarea, selectionLocation);
|
||||
});
|
||||
|
||||
if (onSelect) {
|
||||
onSelect(option, measurePrefix);
|
||||
}
|
||||
};
|
||||
|
||||
_this.setActiveIndex = function (activeIndex) {
|
||||
_this.setState({
|
||||
activeIndex: activeIndex
|
||||
});
|
||||
};
|
||||
|
||||
_this.setTextAreaRef = function (element) {
|
||||
_this.textarea = element;
|
||||
};
|
||||
|
||||
_this.setMeasureRef = function (element) {
|
||||
_this.measure = element;
|
||||
};
|
||||
|
||||
_this.getOptions = function (measureText) {
|
||||
var targetMeasureText = measureText || _this.state.measureText || '';
|
||||
var _this$props3 = _this.props,
|
||||
children = _this$props3.children,
|
||||
filterOption = _this$props3.filterOption;
|
||||
var list = (0, _toArray.default)(children).map(function (_ref2) {
|
||||
var props = _ref2.props;
|
||||
return props;
|
||||
}).filter(function (option) {
|
||||
/** Return all result if `filterOption` is false. */
|
||||
if (filterOption === false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return filterOption(targetMeasureText, option);
|
||||
});
|
||||
return list;
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
value: props.defaultValue || props.value || '',
|
||||
measuring: false,
|
||||
measureLocation: 0,
|
||||
measureText: null,
|
||||
measurePrefix: '',
|
||||
activeIndex: 0,
|
||||
isFocus: false
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Mentions, [{
|
||||
key: "componentDidUpdate",
|
||||
value: function componentDidUpdate() {
|
||||
var measuring = this.state.measuring; // Sync measure div top with textarea for rc-trigger usage
|
||||
|
||||
if (measuring) {
|
||||
this.measure.scrollTop = this.textarea.scrollTop;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "startMeasure",
|
||||
value: function startMeasure(measureText, measurePrefix, measureLocation) {
|
||||
this.setState({
|
||||
measuring: true,
|
||||
measureText: measureText,
|
||||
measurePrefix: measurePrefix,
|
||||
measureLocation: measureLocation,
|
||||
activeIndex: 0
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "stopMeasure",
|
||||
value: function stopMeasure(callback) {
|
||||
this.setState({
|
||||
measuring: false,
|
||||
measureLocation: 0,
|
||||
measureText: null
|
||||
}, callback);
|
||||
}
|
||||
}, {
|
||||
key: "focus",
|
||||
value: function focus() {
|
||||
this.textarea.focus();
|
||||
}
|
||||
}, {
|
||||
key: "blur",
|
||||
value: function blur() {
|
||||
this.textarea.blur();
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
value: function render() {
|
||||
var _this$state4 = this.state,
|
||||
value = _this$state4.value,
|
||||
measureLocation = _this$state4.measureLocation,
|
||||
measurePrefix = _this$state4.measurePrefix,
|
||||
measuring = _this$state4.measuring,
|
||||
activeIndex = _this$state4.activeIndex;
|
||||
|
||||
var _this$props4 = this.props,
|
||||
prefixCls = _this$props4.prefixCls,
|
||||
placement = _this$props4.placement,
|
||||
direction = _this$props4.direction,
|
||||
transitionName = _this$props4.transitionName,
|
||||
className = _this$props4.className,
|
||||
style = _this$props4.style,
|
||||
autoFocus = _this$props4.autoFocus,
|
||||
notFoundContent = _this$props4.notFoundContent,
|
||||
getPopupContainer = _this$props4.getPopupContainer,
|
||||
restProps = _objectWithoutProperties(_this$props4, ["prefixCls", "placement", "direction", "transitionName", "className", "style", "autoFocus", "notFoundContent", "getPopupContainer"]);
|
||||
|
||||
var inputProps = (0, _util.omit)(restProps, 'value', 'defaultValue', 'prefix', 'split', 'children', 'validateSearch', 'filterOption', 'onSelect', 'onSearch');
|
||||
var options = measuring ? this.getOptions() : [];
|
||||
return React.createElement("div", {
|
||||
className: (0, _classnames.default)(prefixCls, className),
|
||||
style: style
|
||||
}, React.createElement("textarea", Object.assign({
|
||||
autoFocus: autoFocus,
|
||||
ref: this.setTextAreaRef,
|
||||
value: value
|
||||
}, inputProps, {
|
||||
onChange: this.onChange,
|
||||
onKeyDown: this.onKeyDown,
|
||||
onKeyUp: this.onKeyUp,
|
||||
onFocus: this.onInputFocus,
|
||||
onBlur: this.onInputBlur
|
||||
})), measuring && React.createElement("div", {
|
||||
ref: this.setMeasureRef,
|
||||
className: "".concat(prefixCls, "-measure")
|
||||
}, value.slice(0, measureLocation), React.createElement(_MentionsContext.MentionsContextProvider, {
|
||||
value: {
|
||||
notFoundContent: notFoundContent,
|
||||
activeIndex: activeIndex,
|
||||
setActiveIndex: this.setActiveIndex,
|
||||
selectOption: this.selectOption,
|
||||
onFocus: this.onDropdownFocus,
|
||||
onBlur: this.onDropdownBlur
|
||||
}
|
||||
}, React.createElement(_KeywordTrigger.default, {
|
||||
prefixCls: prefixCls,
|
||||
transitionName: transitionName,
|
||||
placement: placement,
|
||||
direction: direction,
|
||||
options: options,
|
||||
visible: true,
|
||||
getPopupContainer: getPopupContainer
|
||||
}, React.createElement("span", null, measurePrefix))), value.slice(measureLocation + measurePrefix.length)));
|
||||
}
|
||||
}], [{
|
||||
key: "getDerivedStateFromProps",
|
||||
value: function getDerivedStateFromProps(props, prevState) {
|
||||
var newState = {};
|
||||
|
||||
if ('value' in props && props.value !== prevState.value) {
|
||||
newState.value = props.value || '';
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Mentions;
|
||||
}(React.Component);
|
||||
|
||||
Mentions.Option = _Option.default;
|
||||
Mentions.defaultProps = {
|
||||
prefixCls: 'rc-mentions',
|
||||
prefix: '@',
|
||||
split: ' ',
|
||||
validateSearch: _util.validateSearch,
|
||||
filterOption: _util.filterOption,
|
||||
notFoundContent: 'Not Found',
|
||||
rows: 1
|
||||
};
|
||||
var _default = Mentions;
|
||||
exports.default = _default;
|
||||
12
web/node_modules/rc-mentions/lib/MentionsContext.d.ts
generated
vendored
Normal file
12
web/node_modules/rc-mentions/lib/MentionsContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { OptionProps } from './Option';
|
||||
export interface MentionsContextProps {
|
||||
notFoundContent: React.ReactNode;
|
||||
activeIndex: number;
|
||||
setActiveIndex: (index: number) => void;
|
||||
selectOption: (option: OptionProps) => void;
|
||||
onFocus: React.FocusEventHandler<HTMLElement>;
|
||||
onBlur: React.FocusEventHandler<HTMLElement>;
|
||||
}
|
||||
export declare const MentionsContextProvider: React.ProviderExoticComponent<React.ProviderProps<MentionsContextProps>>;
|
||||
export declare const MentionsContextConsumer: React.ExoticComponent<React.ConsumerProps<MentionsContextProps>>;
|
||||
18
web/node_modules/rc-mentions/lib/MentionsContext.js
generated
vendored
Normal file
18
web/node_modules/rc-mentions/lib/MentionsContext.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.MentionsContextConsumer = exports.MentionsContextProvider = void 0;
|
||||
|
||||
var React = _interopRequireWildcard(require("react"));
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
/* tslint:disable: no-object-literal-type-assertion */
|
||||
// We will never use default, here only to fix TypeScript warning
|
||||
var MentionsContext = React.createContext(null);
|
||||
var MentionsContextProvider = MentionsContext.Provider;
|
||||
exports.MentionsContextProvider = MentionsContextProvider;
|
||||
var MentionsContextConsumer = MentionsContext.Consumer;
|
||||
exports.MentionsContextConsumer = MentionsContextConsumer;
|
||||
10
web/node_modules/rc-mentions/lib/Option.d.ts
generated
vendored
Normal file
10
web/node_modules/rc-mentions/lib/Option.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as React from 'react';
|
||||
export interface OptionProps {
|
||||
value?: string;
|
||||
disabled?: boolean;
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
declare const Option: React.SFC<OptionProps>;
|
||||
export default Option;
|
||||
13
web/node_modules/rc-mentions/lib/Option.js
generated
vendored
Normal file
13
web/node_modules/rc-mentions/lib/Option.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var Option = function Option() {
|
||||
return null;
|
||||
};
|
||||
|
||||
var _default = Option;
|
||||
exports.default = _default;
|
||||
2
web/node_modules/rc-mentions/lib/index.d.ts
generated
vendored
Normal file
2
web/node_modules/rc-mentions/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import Mentions from './Mentions';
|
||||
export default Mentions;
|
||||
13
web/node_modules/rc-mentions/lib/index.js
generated
vendored
Normal file
13
web/node_modules/rc-mentions/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _Mentions = _interopRequireDefault(require("./Mentions"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _default = _Mentions.default;
|
||||
exports.default = _default;
|
||||
40
web/node_modules/rc-mentions/lib/util.d.ts
generated
vendored
Normal file
40
web/node_modules/rc-mentions/lib/util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { MentionsProps } from './Mentions';
|
||||
import { OptionProps } from './Option';
|
||||
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
declare type OmitFunc = <T extends object, K extends [...(keyof T)[]]>(obj: T, ...keys: K) => {
|
||||
[K2 in Exclude<keyof T, K[number]>]: T[K2];
|
||||
};
|
||||
export declare const omit: OmitFunc;
|
||||
/**
|
||||
* Cut input selection into 2 part and return text before selection start
|
||||
*/
|
||||
export declare function getBeforeSelectionText(input: HTMLTextAreaElement): string;
|
||||
interface MeasureIndex {
|
||||
location: number;
|
||||
prefix: string;
|
||||
}
|
||||
/**
|
||||
* Find the last match prefix index
|
||||
*/
|
||||
export declare function getLastMeasureIndex(text: string, prefix?: string | string[]): MeasureIndex;
|
||||
interface MeasureConfig {
|
||||
measureLocation: number;
|
||||
prefix: string;
|
||||
targetText: string;
|
||||
selectionStart: number;
|
||||
split: string;
|
||||
}
|
||||
/**
|
||||
* Paint targetText into current text:
|
||||
* text: little@litest
|
||||
* targetText: light
|
||||
* => little @light test
|
||||
*/
|
||||
export declare function replaceWithMeasure(text: string, measureConfig: MeasureConfig): {
|
||||
text: string;
|
||||
selectionLocation: number;
|
||||
};
|
||||
export declare function setInputSelection(input: HTMLTextAreaElement, location: number): void;
|
||||
export declare function validateSearch(text: string, props: MentionsProps): boolean;
|
||||
export declare function filterOption(input: string, { value }: OptionProps): boolean;
|
||||
export {};
|
||||
154
web/node_modules/rc-mentions/lib/util.js
generated
vendored
Normal file
154
web/node_modules/rc-mentions/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getBeforeSelectionText = getBeforeSelectionText;
|
||||
exports.getLastMeasureIndex = getLastMeasureIndex;
|
||||
exports.replaceWithMeasure = replaceWithMeasure;
|
||||
exports.setInputSelection = setInputSelection;
|
||||
exports.validateSearch = validateSearch;
|
||||
exports.filterOption = filterOption;
|
||||
exports.omit = void 0;
|
||||
|
||||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
var omit = function omit(obj) {
|
||||
var clone = _objectSpread({}, obj);
|
||||
|
||||
for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
keys[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
keys.forEach(function (key) {
|
||||
delete clone[key];
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
/**
|
||||
* Cut input selection into 2 part and return text before selection start
|
||||
*/
|
||||
|
||||
|
||||
exports.omit = omit;
|
||||
|
||||
function getBeforeSelectionText(input) {
|
||||
var selectionStart = input.selectionStart;
|
||||
return input.value.slice(0, selectionStart);
|
||||
}
|
||||
/**
|
||||
* Find the last match prefix index
|
||||
*/
|
||||
|
||||
|
||||
function getLastMeasureIndex(text) {
|
||||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
var prefixList = Array.isArray(prefix) ? prefix : [prefix];
|
||||
return prefixList.reduce(function (lastMatch, prefixStr) {
|
||||
var lastIndex = text.lastIndexOf(prefixStr);
|
||||
|
||||
if (lastIndex > lastMatch.location) {
|
||||
return {
|
||||
location: lastIndex,
|
||||
prefix: prefixStr
|
||||
};
|
||||
}
|
||||
|
||||
return lastMatch;
|
||||
}, {
|
||||
location: -1,
|
||||
prefix: ''
|
||||
});
|
||||
}
|
||||
|
||||
function lower(char) {
|
||||
return (char || '').toLowerCase();
|
||||
}
|
||||
|
||||
function reduceText(text, targetText, split) {
|
||||
var firstChar = text[0];
|
||||
|
||||
if (!firstChar || firstChar === split) {
|
||||
return text;
|
||||
} // Reuse rest text as it can
|
||||
|
||||
|
||||
var restText = text;
|
||||
var targetTextLen = targetText.length;
|
||||
|
||||
for (var i = 0; i < targetTextLen; i += 1) {
|
||||
if (lower(restText[i]) !== lower(targetText[i])) {
|
||||
restText = restText.slice(i);
|
||||
break;
|
||||
} else if (i === targetTextLen - 1) {
|
||||
restText = restText.slice(targetTextLen);
|
||||
}
|
||||
}
|
||||
|
||||
return restText;
|
||||
}
|
||||
/**
|
||||
* Paint targetText into current text:
|
||||
* text: little@litest
|
||||
* targetText: light
|
||||
* => little @light test
|
||||
*/
|
||||
|
||||
|
||||
function replaceWithMeasure(text, measureConfig) {
|
||||
var measureLocation = measureConfig.measureLocation,
|
||||
prefix = measureConfig.prefix,
|
||||
targetText = measureConfig.targetText,
|
||||
selectionStart = measureConfig.selectionStart,
|
||||
split = measureConfig.split; // Before text will append one space if have other text
|
||||
|
||||
var beforeMeasureText = text.slice(0, measureLocation);
|
||||
|
||||
if (beforeMeasureText[beforeMeasureText.length - split.length] === split) {
|
||||
beforeMeasureText = beforeMeasureText.slice(0, beforeMeasureText.length - split.length);
|
||||
}
|
||||
|
||||
if (beforeMeasureText) {
|
||||
beforeMeasureText = "".concat(beforeMeasureText).concat(split);
|
||||
} // Cut duplicate string with current targetText
|
||||
|
||||
|
||||
var restText = reduceText(text.slice(selectionStart), targetText.slice(selectionStart - measureLocation - prefix.length), split);
|
||||
|
||||
if (restText.slice(0, split.length) === split) {
|
||||
restText = restText.slice(split.length);
|
||||
}
|
||||
|
||||
var connectedStartText = "".concat(beforeMeasureText).concat(prefix).concat(targetText).concat(split);
|
||||
return {
|
||||
text: "".concat(connectedStartText).concat(restText),
|
||||
selectionLocation: connectedStartText.length
|
||||
};
|
||||
}
|
||||
|
||||
function setInputSelection(input, location) {
|
||||
input.setSelectionRange(location, location);
|
||||
/**
|
||||
* Reset caret into view.
|
||||
* Since this function always called by user control, it's safe to focus element.
|
||||
*/
|
||||
|
||||
input.blur();
|
||||
input.focus();
|
||||
}
|
||||
|
||||
function validateSearch(text, props) {
|
||||
var split = props.split;
|
||||
return !split || text.indexOf(split) === -1;
|
||||
}
|
||||
|
||||
function filterOption(input, _ref) {
|
||||
var _ref$value = _ref.value,
|
||||
value = _ref$value === void 0 ? '' : _ref$value;
|
||||
var lowerCase = input.toLowerCase();
|
||||
return value.toLowerCase().indexOf(lowerCase) !== -1;
|
||||
}
|
||||
87
web/node_modules/rc-mentions/package.json
generated
vendored
Normal file
87
web/node_modules/rc-mentions/package.json
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"_from": "rc-mentions@~1.1.0",
|
||||
"_id": "rc-mentions@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-uOVMiQ5Jxfo3mbpOZsZt20Alid0268lX9eBR2I/chly0qhNbmSB71iLOHGkbL7zuHd50GF/eSr9fXJJQKUYG1Q==",
|
||||
"_location": "/rc-mentions",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "rc-mentions@~1.1.0",
|
||||
"name": "rc-mentions",
|
||||
"escapedName": "rc-mentions",
|
||||
"rawSpec": "~1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/antd"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/rc-mentions/-/rc-mentions-1.1.0.tgz",
|
||||
"_shasum": "fa4994b94eee03e5254a0a600839ed19e1f9f0e9",
|
||||
"_spec": "rc-mentions@~1.1.0",
|
||||
"_where": "/Users/thilina/TestProjects/icehrm-pro/web/node_modules/antd",
|
||||
"bugs": {
|
||||
"url": "http://github.com/react-component/mentions/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.6",
|
||||
"rc-menu": "^8.0.1",
|
||||
"rc-trigger": "^4.0.0",
|
||||
"rc-util": "^4.6.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "React Mentions",
|
||||
"devDependencies": {
|
||||
"@types/classnames": "^2.2.6",
|
||||
"@types/enzyme": "^3.1.15",
|
||||
"@types/react": "^16.7.17",
|
||||
"@types/react-dom": "^16.0.11",
|
||||
"@types/warning": "^3.0.0",
|
||||
"@umijs/fabric": "^1.1.9",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-to-json": "^3.1.4",
|
||||
"father": "^2.13.6",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"np": "^5.0.3",
|
||||
"react": "^16.0.0",
|
||||
"react-dom": "^16.0.0",
|
||||
"typescript": "^3.2.2"
|
||||
},
|
||||
"files": [
|
||||
"assets/*.css",
|
||||
"es",
|
||||
"dist",
|
||||
"lib"
|
||||
],
|
||||
"homepage": "http://github.com/react-component/mentions",
|
||||
"keywords": [
|
||||
"react",
|
||||
"react-component",
|
||||
"react-mentions",
|
||||
"mentions"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/index",
|
||||
"module": "./es/index",
|
||||
"name": "rc-mentions",
|
||||
"peerDependencies": {
|
||||
"react": "*"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/react-component/mentions.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "father doc build --storybook",
|
||||
"compile": "father build",
|
||||
"lint": "eslint src/ --ext .tsx,.ts",
|
||||
"now-build": "npm run build",
|
||||
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish --any-branch",
|
||||
"start": "father doc dev --storybook",
|
||||
"test": "father test"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user