Latest updates from IceHrmPro

This commit is contained in:
Thilina Pituwala
2020-05-20 18:47:29 +02:00
parent 60c92d7935
commit 7453a58aad
18012 changed files with 2089245 additions and 10173 deletions

30
web/node_modules/rc-select/lib/utils/commonUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import { RawValueType, GetLabeledValue, LabelValueType, DefaultValueType, FlattenOptionsType } from '../interface/generator';
export declare function toArray<T>(value: T | T[]): T[];
/**
* Convert outer props value into internal value
*/
export declare function toInnerValue(value: DefaultValueType, { labelInValue, combobox }: {
labelInValue: boolean;
combobox: boolean;
}): RawValueType[];
/**
* Convert internal value into out event value
*/
export declare function toOuterValues<FOT extends FlattenOptionsType>(valueList: RawValueType[], { optionLabelProp, labelInValue, prevValue, options, getLabeledValue, }: {
optionLabelProp: string;
labelInValue: boolean;
getLabeledValue: GetLabeledValue<FOT>;
options: FOT;
prevValue: DefaultValueType;
}): RawValueType[] | LabelValueType[];
export declare function removeLastEnabledValue<T extends {
disabled?: boolean;
}, P extends RawValueType | object>(measureValues: T[], values: P[]): {
values: P[];
removedValue: P;
};
export declare const isClient: HTMLElement;
/** Is client side and not jsdom */
export declare const isBrowserClient: HTMLElement;
/** Get unique id for accessibility usage */
export declare function getUUID(): number | string;

130
web/node_modules/rc-select/lib/utils/commonUtil.js generated vendored Normal file
View File

@@ -0,0 +1,130 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.toArray = toArray;
exports.toInnerValue = toInnerValue;
exports.toOuterValues = toOuterValues;
exports.removeLastEnabledValue = removeLastEnabledValue;
exports.getUUID = getUUID;
exports.isBrowserClient = exports.isClient = void 0;
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function toArray(value) {
if (Array.isArray(value)) {
return value;
}
return value !== undefined ? [value] : [];
}
/**
* Convert outer props value into internal value
*/
function toInnerValue(value, _ref) {
var labelInValue = _ref.labelInValue,
combobox = _ref.combobox;
if (value === undefined || value === '' && combobox) {
return [];
}
var values = Array.isArray(value) ? value : [value];
if (labelInValue) {
return values.map(function (_ref2) {
var key = _ref2.key,
val = _ref2.value;
return val !== undefined ? val : key;
});
}
return values;
}
/**
* Convert internal value into out event value
*/
function toOuterValues(valueList, _ref3) {
var optionLabelProp = _ref3.optionLabelProp,
labelInValue = _ref3.labelInValue,
prevValue = _ref3.prevValue,
options = _ref3.options,
getLabeledValue = _ref3.getLabeledValue;
var values = valueList;
if (labelInValue) {
values = values.map(function (val) {
return getLabeledValue(val, {
options: options,
prevValue: prevValue,
labelInValue: labelInValue,
optionLabelProp: optionLabelProp
});
});
}
return values;
}
function removeLastEnabledValue(measureValues, values) {
var newValues = _toConsumableArray(values);
var removeIndex;
for (removeIndex = measureValues.length - 1; removeIndex >= 0; removeIndex -= 1) {
if (!measureValues[removeIndex].disabled) {
break;
}
}
var removedValue = null;
if (removeIndex !== -1) {
removedValue = newValues[removeIndex];
newValues.splice(removeIndex, 1);
}
return {
values: newValues,
removedValue: removedValue
};
}
var isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
/** Is client side and not jsdom */
exports.isClient = isClient;
var isBrowserClient = process.env.NODE_ENV !== 'test' && isClient;
exports.isBrowserClient = isBrowserClient;
var uuid = 0;
/** Get unique id for accessibility usage */
function getUUID() {
var retId; // Test never reach
/* istanbul ignore if */
if (isBrowserClient) {
retId = uuid;
uuid += 1;
} else {
retId = 'TEST_OR_SSR';
}
return retId;
}

3
web/node_modules/rc-select/lib/utils/legacyUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
import * as React from 'react';
import { OptionsType } from '../interface';
export declare function convertChildrenToData(nodes: React.ReactNode, optionOnly?: boolean): OptionsType;

70
web/node_modules/rc-select/lib/utils/legacyUtil.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; 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); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertChildrenToData = convertChildrenToData;
var React = _interopRequireWildcard(require("react"));
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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; }
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 convertNodeToOption(node) {
var key = node.key,
_node$props = node.props,
children = _node$props.children,
value = _node$props.value,
restProps = _objectWithoutProperties(_node$props, ["children", "value"]);
return _objectSpread({
key: key,
value: value !== undefined ? value : key,
children: children
}, restProps);
}
function convertChildrenToData(nodes) {
var optionOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return (0, _toArray.default)(nodes).map(function (node, index) {
if (!React.isValidElement(node) || !node.type) {
return null;
}
var isSelectOptGroup = node.type.isSelectOptGroup,
key = node.key,
_node$props2 = node.props,
children = _node$props2.children,
restProps = _objectWithoutProperties(_node$props2, ["children"]);
if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node);
}
return _objectSpread({
key: "__RC_SELECT_GRP__".concat(key === null ? index : key, "__"),
label: key
}, restProps, {
options: convertChildrenToData(children)
});
}).filter(function (data) {
return data;
});
}

21
web/node_modules/rc-select/lib/utils/valueUtil.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { OptionsType as SelectOptionsType, OptionData, FlattenOptionData } from '../interface';
import { FilterFunc, RawValueType, GetLabeledValue, DefaultValueType } from '../interface/generator';
/**
* Flat options into flatten list.
* We use `optionOnly` here is aim to avoid user use nested option group.
* Here is simply set `key` to the index if not provided.
*/
export declare function flattenOptions(options: SelectOptionsType): FlattenOptionData[];
export declare function findValueOption(values: RawValueType[], options: FlattenOptionData[]): OptionData[];
export declare const getLabeledValue: GetLabeledValue<FlattenOptionData[]>;
/** Filter options and return a new options by the search text */
export declare function filterOptions(searchValue: string, options: SelectOptionsType, { optionFilterProp, filterOption, }: {
optionFilterProp: string;
filterOption: boolean | FilterFunc<SelectOptionsType[number]>;
}): SelectOptionsType;
export declare function getSeparatedContent(text: string, tokens: string[]): string[];
export declare function isValueDisabled(value: RawValueType, options: FlattenOptionData[]): boolean;
/**
* `tags` mode should fill un-list item into the option list
*/
export declare function fillOptionsWithMissingValue(options: SelectOptionsType, value: DefaultValueType, optionLabelProp: string, labelInValue: boolean): SelectOptionsType;

311
web/node_modules/rc-select/lib/utils/valueUtil.js generated vendored Normal file
View File

@@ -0,0 +1,311 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.flattenOptions = flattenOptions;
exports.findValueOption = findValueOption;
exports.filterOptions = filterOptions;
exports.getSeparatedContent = getSeparatedContent;
exports.isValueDisabled = isValueDisabled;
exports.fillOptionsWithMissingValue = fillOptionsWithMissingValue;
exports.getLabeledValue = void 0;
var _warning = _interopRequireDefault(require("rc-util/lib/warning"));
var _commonUtil = require("./commonUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _typeof(obj) { "@babel/helpers - typeof"; 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 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(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(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; }
function getKey(data, index) {
var key = data.key;
var value;
if ('value' in data) {
value = data.value;
}
if (key !== null && key !== undefined) {
return key;
}
if (value !== undefined) {
return value;
}
return "rc-index-key-".concat(index);
}
/**
* Flat options into flatten list.
* We use `optionOnly` here is aim to avoid user use nested option group.
* Here is simply set `key` to the index if not provided.
*/
function flattenOptions(options) {
var flattenList = [];
function dig(list, isGroupOption) {
list.forEach(function (data) {
if (isGroupOption || !('options' in data)) {
// Option
flattenList.push({
key: getKey(data, flattenList.length),
groupOption: isGroupOption,
data: data
});
} else {
// Option Group
flattenList.push({
key: getKey(data, flattenList.length),
group: true,
data: data
});
dig(data.options, true);
}
});
}
dig(options, false);
return flattenList;
}
/**
* Inject `props` into `option` for legacy usage
*/
function injectPropsWithOption(option) {
var newOption = _objectSpread({}, option);
if (!('props' in newOption)) {
Object.defineProperty(newOption, 'props', {
get: function get() {
(0, _warning.default)(false, 'Return type is option instead of Option instance. Please read value directly instead of reading from `props`.');
return newOption;
}
});
}
return newOption;
}
function findValueOption(values, options) {
var optionMap = new Map();
options.forEach(function (flattenItem) {
if (!flattenItem.group) {
var data = flattenItem.data; // Check if match
optionMap.set(data.value, data);
}
});
return values.map(function (val) {
return injectPropsWithOption(optionMap.get(val));
});
}
var getLabeledValue = function getLabeledValue(value, _ref) {
var options = _ref.options,
prevValue = _ref.prevValue,
labelInValue = _ref.labelInValue,
optionLabelProp = _ref.optionLabelProp;
var item = findValueOption([value], options)[0];
var result = {
value: value
};
var prevValItem;
var prevValues = (0, _commonUtil.toArray)(prevValue);
if (labelInValue) {
prevValItem = prevValues.find(function (prevItem) {
if (_typeof(prevItem) === 'object' && 'value' in prevItem) {
return prevItem.value === value;
} // [Legacy] Support `key` as `value`
return prevItem.key === value;
});
}
if (prevValItem && _typeof(prevValItem) === 'object' && 'label' in prevValItem) {
result.label = prevValItem.label;
if (item && typeof prevValItem.label === 'string' && typeof item[optionLabelProp] === 'string' && prevValItem.label.trim() !== item[optionLabelProp].trim()) {
(0, _warning.default)(false, '`label` of `value` is not same as `label` in Select options.');
}
} else if (item && optionLabelProp in item) {
result.label = item[optionLabelProp];
} else {
result.label = value;
} // [Legacy] We need fill `key` as `value` to compatible old code usage
result.key = result.value;
return result;
};
exports.getLabeledValue = getLabeledValue;
function toRawString(content) {
return (0, _commonUtil.toArray)(content).join('');
}
/** Filter single option if match the search text */
function getFilterFunction(optionFilterProp) {
return function (searchValue, option) {
var lowerSearchText = searchValue.toLowerCase(); // Group label search
if ('options' in option) {
return toRawString(option.label).toLowerCase().includes(lowerSearchText);
} // Option value search
var rawValue = option[optionFilterProp];
var value = toRawString(rawValue).toLowerCase();
return value.includes(lowerSearchText) && !option.disabled;
};
}
/** Filter options and return a new options by the search text */
function filterOptions(searchValue, options, _ref2) {
var optionFilterProp = _ref2.optionFilterProp,
filterOption = _ref2.filterOption;
var filteredOptions = [];
var filterFunc;
if (filterOption === false) {
return options;
}
if (typeof filterOption === 'function') {
filterFunc = filterOption;
} else {
filterFunc = getFilterFunction(optionFilterProp);
}
options.forEach(function (item) {
// Group should check child options
if ('options' in item) {
// Check group first
var matchGroup = filterFunc(searchValue, item);
if (matchGroup) {
filteredOptions.push(item);
} else {
// Check option
var subOptions = item.options.filter(function (subItem) {
return filterFunc(searchValue, subItem);
});
if (subOptions.length) {
filteredOptions.push(_objectSpread({}, item, {
options: subOptions
}));
}
}
return;
}
if (filterFunc(searchValue, injectPropsWithOption(item))) {
filteredOptions.push(item);
}
});
return filteredOptions;
}
function getSeparatedContent(text, tokens) {
if (!tokens || !tokens.length) {
return null;
}
var match = false;
function separate(str, _ref3) {
var _ref4 = _toArray(_ref3),
token = _ref4[0],
restTokens = _ref4.slice(1);
if (!token) {
return [str];
}
var list = str.split(token);
match = match || list.length > 1;
return list.reduce(function (prevList, unitStr) {
return [].concat(_toConsumableArray(prevList), _toConsumableArray(separate(unitStr, restTokens)));
}, []).filter(function (unit) {
return unit;
});
}
var list = separate(text, tokens);
return match ? list : null;
}
function isValueDisabled(value, options) {
var option = findValueOption([value], options)[0];
return option.disabled;
}
/**
* `tags` mode should fill un-list item into the option list
*/
function fillOptionsWithMissingValue(options, value, optionLabelProp, labelInValue) {
var values = (0, _commonUtil.toArray)(value).slice().sort();
var cloneOptions = _toConsumableArray(options); // Convert options value to set
var optionValues = new Set();
options.forEach(function (opt) {
if (opt.options) {
opt.options.forEach(function (subOpt) {
optionValues.add(subOpt.value);
});
} else {
optionValues.add(opt.value);
}
}); // Fill missing value
values.forEach(function (item) {
var val = labelInValue ? item.value : item;
if (!optionValues.has(val)) {
var _ref5;
cloneOptions.push(labelInValue ? (_ref5 = {}, _defineProperty(_ref5, optionLabelProp, item.label), _defineProperty(_ref5, "value", val), _ref5) : {
value: val
});
}
});
return cloneOptions;
}

View File

@@ -0,0 +1,3 @@
import { SelectProps } from '..';
declare function warningProps(props: SelectProps): void;
export default warningProps;

View File

@@ -0,0 +1,130 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _warning = _interopRequireWildcard(require("rc-util/lib/warning"));
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
var _legacyUtil = require("./legacyUtil");
var _commonUtil = require("./commonUtil");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _typeof(obj) { "@babel/helpers - typeof"; 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 warningProps(props) {
var mode = props.mode,
options = props.options,
children = props.children,
backfill = props.backfill,
allowClear = props.allowClear,
placeholder = props.placeholder,
getInputElement = props.getInputElement,
showSearch = props.showSearch,
onSearch = props.onSearch,
defaultOpen = props.defaultOpen,
autoFocus = props.autoFocus,
labelInValue = props.labelInValue,
value = props.value,
inputValue = props.inputValue,
optionLabelProp = props.optionLabelProp;
var multiple = mode === 'multiple' || mode === 'tags';
var mergedShowSearch = showSearch !== undefined ? showSearch : multiple || mode === 'combobox';
var mergedOptions = options || (0, _legacyUtil.convertChildrenToData)(children); // `tags` should not set option as disabled
(0, _warning.default)(mode !== 'tags' || mergedOptions.every(function (opt) {
return !opt.disabled;
}), 'Please avoid setting option to disabled in tags mode since user can always type text as tag.'); // `combobox` & `tags` should option be `string` type
if (mode === 'tags' || mode === 'combobox') {
var hasNumberValue = mergedOptions.some(function (item) {
if (item.options) {
return item.options.some(function (opt) {
return typeof ('value' in opt ? opt.value : opt.key) === 'number';
});
}
return typeof ('value' in item ? item.value : item.key) === 'number';
});
(0, _warning.default)(!hasNumberValue, '`value` of Option should not use number type when `mode` is `tags` or `combobox`.');
} // `combobox` should not use `optionLabelProp`
(0, _warning.default)(mode !== 'combobox' || !optionLabelProp, '`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly.'); // Only `combobox` support `backfill`
(0, _warning.default)(mode === 'combobox' || !backfill, '`backfill` only works with `combobox` mode.'); // Only `combobox` support `getInputElement`
(0, _warning.default)(mode === 'combobox' || !getInputElement, '`getInputElement` only work with `combobox` mode.'); // Customize `getInputElement` should not use `allowClear` & `placeholder`
(0, _warning.noteOnce)(mode !== 'combobox' || !getInputElement || !allowClear || !placeholder, 'Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`.'); // `onSearch` should use in `combobox` or `showSearch`
if (onSearch && !mergedShowSearch && mode !== 'combobox' && mode !== 'tags') {
(0, _warning.default)(false, '`onSearch` should work with `showSearch` instead of use alone.');
}
(0, _warning.noteOnce)(!defaultOpen || autoFocus, '`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed.');
if (value !== undefined && value !== null) {
var values = (0, _commonUtil.toArray)(value);
(0, _warning.default)(!labelInValue || values.every(function (val) {
return _typeof(val) === 'object' && ('key' in val || 'value' in val);
}), '`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`');
(0, _warning.default)(!multiple || Array.isArray(value), '`value` should be array when `mode` is `multiple` or `tags`');
} // Syntactic sugar should use correct children type
if (children) {
var invalidateChildType = null;
(0, _toArray.default)(children).some(function (node) {
if (!_react.default.isValidElement(node) || !node.type) {
return false;
}
var type = node.type;
if (type.isSelectOption) {
return false;
}
if (type.isSelectOptGroup) {
var allChildrenValid = (0, _toArray.default)(node.props.children).every(function (subNode) {
if (!_react.default.isValidElement(subNode) || !node.type || subNode.type.isSelectOption) {
return true;
}
invalidateChildType = subNode.type;
return false;
});
if (allChildrenValid) {
return false;
}
return true;
}
invalidateChildType = type;
return true;
});
if (invalidateChildType) {
(0, _warning.default)(false, "`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(invalidateChildType.displayName || invalidateChildType.name || invalidateChildType, "`."));
}
(0, _warning.default)(inputValue === undefined, '`inputValue` is deprecated, please use `searchValue` instead.');
}
}
var _default = warningProps;
exports.default = _default;