ant-design-vue/components/vc-select/util.js

214 lines
4.9 KiB
JavaScript
Raw Normal View History

2020-06-30 10:31:58 +00:00
import { getPropsData, getComponent, getSlot } from '../_util/props-util';
import { cloneElement } from '../_util/vnode';
2020-06-29 10:43:43 +00:00
import { isVNode, Text } from 'vue';
2019-01-12 03:33:27 +00:00
export function toTitle(title) {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if (typeof title === 'string') {
2019-03-16 01:14:55 +00:00
return title.trim();
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-12 03:33:27 +00:00
return '';
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-12 03:33:27 +00:00
export function getValuePropValue(child) {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
if (!child) {
2019-01-12 03:33:27 +00:00
return null;
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-12 03:33:27 +00:00
const props = getPropsData(child);
2018-02-06 11:00:34 +00:00
if ('value' in props) {
2019-01-12 03:33:27 +00:00
return props.value;
2018-02-06 11:00:34 +00:00
}
2020-06-29 10:43:43 +00:00
if (child.key !== undefined) {
return child.key;
2018-02-06 11:00:34 +00:00
}
if (typeof child.type === 'object' && child.type.isSelectOptGroup) {
const label = getComponent(child, 'label');
2018-02-24 10:12:24 +00:00
if (label) {
2019-01-12 03:33:27 +00:00
return label;
2018-02-24 10:12:24 +00:00
}
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
throw new Error(`Need at least a key or a value or a label (only for OptGroup) for ${child}`);
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function getPropValue(child, prop) {
2018-02-06 11:00:34 +00:00
if (prop === 'value') {
2019-01-12 03:33:27 +00:00
return getValuePropValue(child);
2018-02-06 11:00:34 +00:00
}
2018-02-11 10:04:31 +00:00
if (prop === 'children') {
2020-07-01 16:24:44 +00:00
const temp = getComponent(child);
const newChild = isVNode(temp) ? cloneElement(temp) : temp;
2020-06-29 10:43:43 +00:00
if (isVNode(newChild) && newChild.type === Text) {
return newChild.children;
2018-02-11 10:04:31 +00:00
}
2019-01-12 03:33:27 +00:00
return newChild;
2018-02-11 10:04:31 +00:00
}
2020-06-29 10:43:43 +00:00
const props = getPropsData(child);
return props[prop];
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function isMultiple(props) {
return props.multiple;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function isCombobox(props) {
return props.combobox;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function isMultipleOrTags(props) {
return props.multiple || props.tags;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function isMultipleOrTagsOrCombobox(props) {
return isMultipleOrTags(props) || isCombobox(props);
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function isSingleMode(props) {
return !isMultipleOrTagsOrCombobox(props);
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function toArray(value) {
let ret = value;
2018-02-06 11:00:34 +00:00
if (value === undefined) {
2019-01-12 03:33:27 +00:00
ret = [];
2018-02-06 11:00:34 +00:00
} else if (!Array.isArray(value)) {
2019-01-12 03:33:27 +00:00
ret = [value];
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
return ret;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function getMapKey(value) {
return `${typeof value}-${value}`;
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-12 03:33:27 +00:00
export function preventDefaultEvent(e) {
e.preventDefault();
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function findIndexInValueBySingleValue(value, singleValue) {
let index = -1;
2019-01-04 15:00:09 +00:00
if (value) {
for (let i = 0; i < value.length; i++) {
if (value[i] === singleValue) {
2019-01-12 03:33:27 +00:00
index = i;
break;
2019-01-04 15:00:09 +00:00
}
2018-02-06 11:00:34 +00:00
}
}
2019-01-12 03:33:27 +00:00
return index;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function getLabelFromPropsValue(value, key) {
let label;
value = toArray(value);
2019-01-04 15:00:09 +00:00
if (value) {
for (let i = 0; i < value.length; i++) {
if (value[i].key === key) {
2019-01-12 03:33:27 +00:00
label = value[i].label;
break;
2019-01-04 15:00:09 +00:00
}
2018-02-06 11:00:34 +00:00
}
}
2019-01-12 03:33:27 +00:00
return label;
2018-02-06 11:00:34 +00:00
}
2020-06-29 10:43:43 +00:00
export function getSelectKeys(menuItems = [], value) {
2018-02-06 11:00:34 +00:00
if (value === null || value === undefined) {
2019-01-12 03:33:27 +00:00
return [];
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
let selectedKeys = [];
2018-02-06 11:00:34 +00:00
menuItems.forEach(item => {
2020-06-29 10:43:43 +00:00
if (item.type?.isMenuItemGroup) {
2020-06-30 10:31:58 +00:00
selectedKeys = selectedKeys.concat(getSelectKeys(getSlot(item), value));
2018-02-06 11:00:34 +00:00
} else {
2019-01-12 03:33:27 +00:00
const itemValue = getValuePropValue(item);
const itemKey = item.key;
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey !== undefined) {
2019-01-12 03:33:27 +00:00
selectedKeys.push(itemKey);
2018-02-06 11:00:34 +00:00
}
}
2019-01-12 03:33:27 +00:00
});
return selectedKeys;
2018-02-06 11:00:34 +00:00
}
export const UNSELECTABLE_STYLE = {
userSelect: 'none',
WebkitUserSelect: 'none',
2019-01-12 03:33:27 +00:00
};
2018-02-06 11:00:34 +00:00
export const UNSELECTABLE_ATTRIBUTE = {
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
unselectable: 'on',
2019-01-12 03:33:27 +00:00
};
2018-02-06 11:00:34 +00:00
2019-01-12 03:33:27 +00:00
export function findFirstMenuItem(children) {
2018-02-06 11:00:34 +00:00
for (let i = 0; i < children.length; i++) {
2019-01-12 03:33:27 +00:00
const child = children[i];
const props = getPropsData(child);
2020-06-29 10:43:43 +00:00
if (child.type?.isMenuItemGroup) {
2020-06-30 10:31:58 +00:00
const found = findFirstMenuItem(getSlot(child));
2018-02-06 11:00:34 +00:00
if (found) {
2019-01-12 03:33:27 +00:00
return found;
2018-02-06 11:00:34 +00:00
}
2018-02-07 15:03:47 +00:00
} else if (!props.disabled) {
2019-01-12 03:33:27 +00:00
return child;
2018-02-06 11:00:34 +00:00
}
}
2019-01-12 03:33:27 +00:00
return null;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function includesSeparators(str, separators) {
2018-02-06 11:00:34 +00:00
for (let i = 0; i < separators.length; ++i) {
2019-01-04 15:00:09 +00:00
if (str.lastIndexOf(separators[i]) > 0) {
2019-01-12 03:33:27 +00:00
return true;
2018-02-06 11:00:34 +00:00
}
}
2019-01-12 03:33:27 +00:00
return false;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function splitBySeparators(str, separators) {
const reg = new RegExp(`[${separators.join()}]`);
return str.split(reg).filter(token => token);
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function defaultFilterFn(input, child) {
const props = getPropsData(child);
2018-02-07 15:03:47 +00:00
if (props.disabled) {
2019-01-12 03:33:27 +00:00
return false;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
let value = getPropValue(child, this.optionFilterProp);
2018-02-12 10:10:51 +00:00
if (value.length && value[0].text) {
2019-01-12 03:33:27 +00:00
value = value[0].text;
2018-02-12 10:10:51 +00:00
} else {
2019-01-12 03:33:27 +00:00
value = String(value);
2018-02-12 10:10:51 +00:00
}
2019-01-12 03:33:27 +00:00
return value.toLowerCase().indexOf(input.toLowerCase()) > -1;
2018-02-06 11:00:34 +00:00
}
2019-01-12 03:33:27 +00:00
export function validateOptionValue(value, props) {
2018-02-06 11:00:34 +00:00
if (isSingleMode(props) || isMultiple(props)) {
2019-01-12 03:33:27 +00:00
return;
2018-02-06 11:00:34 +00:00
}
if (typeof value !== 'string') {
throw new Error(
`Invalid \`value\` of type \`${typeof value}\` supplied to Option, ` +
2019-01-04 15:00:09 +00:00
`expected \`string\` when \`tags/combobox\` is \`true\`.`,
2019-01-12 03:33:27 +00:00
);
2018-02-06 11:00:34 +00:00
}
}
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
2019-01-12 03:33:27 +00:00
export function saveRef(instance, name) {
return node => {
instance[name] = node;
};
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
}
2019-01-04 15:00:09 +00:00
2019-01-12 03:33:27 +00:00
export function generateUUID() {
2019-01-04 15:00:09 +00:00
if (process.env.NODE_ENV === 'test') {
2019-01-12 03:33:27 +00:00
return 'test-uuid';
2019-01-04 15:00:09 +00:00
}
2019-01-12 03:33:27 +00:00
let d = new Date().getTime();
2019-01-04 15:00:09 +00:00
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
2019-01-12 03:33:27 +00:00
const r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x7) | 0x8).toString(16);
});
return uuid;
2019-01-04 15:00:09 +00:00
}