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

224 lines
5.1 KiB
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
import {
getPropsData,
getSlotOptions,
getKey,
getAttrs,
getComponentFromProp,
} from '../_util/props-util';
import { cloneVNodes } from '../_util/vnode';
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 21:28:54 +08:00
if (typeof title === 'string') {
2019-03-16 09:14:55 +08: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 21:28:54 +08:00
}
2019-01-12 11:33:27 +08: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 21:28:54 +08:00
}
2019-01-12 11:33:27 +08: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 21:28:54 +08:00
if (!child) {
2019-01-12 11:33:27 +08: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 21:28:54 +08:00
}
2019-01-12 11:33:27 +08:00
const props = getPropsData(child);
2018-02-06 19:00:34 +08:00
if ('value' in props) {
2019-01-12 11:33:27 +08:00
return props.value;
2018-02-06 19:00:34 +08:00
}
2018-02-22 12:07:37 +08:00
if (getKey(child) !== undefined) {
2019-01-12 11:33:27 +08:00
return getKey(child);
2018-02-06 19:00:34 +08:00
}
2018-02-24 18:12:24 +08:00
if (getSlotOptions(child).isSelectOptGroup) {
2019-01-12 11:33:27 +08:00
const label = getComponentFromProp(child, 'label');
2018-02-24 18:12:24 +08:00
if (label) {
2019-01-12 11:33:27 +08:00
return label;
2018-02-24 18:12:24 +08:00
}
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
throw new Error(`Need at least a key or a value or a label (only for OptGroup) for ${child}`);
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function getPropValue(child, prop) {
2018-02-06 19:00:34 +08:00
if (prop === 'value') {
2019-01-12 11:33:27 +08:00
return getValuePropValue(child);
2018-02-06 19:00:34 +08:00
}
2018-02-11 18:04:31 +08:00
if (prop === 'children') {
2019-01-12 11:33:27 +08:00
const newChild = child.$slots
? cloneVNodes(child.$slots.default, true)
: cloneVNodes(child.componentOptions.children, true);
2018-02-28 19:07:04 +08:00
if (newChild.length === 1 && !newChild[0].tag) {
2019-01-12 11:33:27 +08:00
return newChild[0].text;
2018-02-11 18:04:31 +08:00
}
2019-01-12 11:33:27 +08:00
return newChild;
2018-02-11 18:04:31 +08:00
}
2019-01-12 11:33:27 +08:00
const data = getPropsData(child);
2018-02-12 18:10:51 +08:00
if (prop in data) {
2019-01-12 11:33:27 +08:00
return data[prop];
2018-02-12 18:10:51 +08:00
} else {
2019-01-12 11:33:27 +08:00
return getAttrs(child)[prop];
2018-02-12 18:10:51 +08:00
}
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function isMultiple(props) {
return props.multiple;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function isCombobox(props) {
return props.combobox;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function isMultipleOrTags(props) {
return props.multiple || props.tags;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function isMultipleOrTagsOrCombobox(props) {
return isMultipleOrTags(props) || isCombobox(props);
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function isSingleMode(props) {
return !isMultipleOrTagsOrCombobox(props);
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function toArray(value) {
let ret = value;
2018-02-06 19:00:34 +08:00
if (value === undefined) {
2019-01-12 11:33:27 +08:00
ret = [];
2018-02-06 19:00:34 +08:00
} else if (!Array.isArray(value)) {
2019-01-12 11:33:27 +08:00
ret = [value];
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
return ret;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08: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 21:28:54 +08:00
}
2019-01-12 11:33:27 +08:00
export function preventDefaultEvent(e) {
e.preventDefault();
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function findIndexInValueBySingleValue(value, singleValue) {
let index = -1;
2019-01-04 23:00:09 +08:00
if (value) {
for (let i = 0; i < value.length; i++) {
if (value[i] === singleValue) {
2019-01-12 11:33:27 +08:00
index = i;
break;
2019-01-04 23:00:09 +08:00
}
2018-02-06 19:00:34 +08:00
}
}
2019-01-12 11:33:27 +08:00
return index;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function getLabelFromPropsValue(value, key) {
let label;
value = toArray(value);
2019-01-04 23:00:09 +08:00
if (value) {
for (let i = 0; i < value.length; i++) {
if (value[i].key === key) {
2019-01-12 11:33:27 +08:00
label = value[i].label;
break;
2019-01-04 23:00:09 +08:00
}
2018-02-06 19:00:34 +08:00
}
}
2019-01-12 11:33:27 +08:00
return label;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function getSelectKeys(menuItems, value) {
2018-02-06 19:00:34 +08:00
if (value === null || value === undefined) {
2019-01-12 11:33:27 +08:00
return [];
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
let selectedKeys = [];
2018-02-06 19:00:34 +08:00
menuItems.forEach(item => {
2018-02-07 23:03:47 +08:00
if (getSlotOptions(item).isMenuItemGroup) {
2019-01-12 11:33:27 +08:00
selectedKeys = selectedKeys.concat(getSelectKeys(item.componentOptions.children, value));
2018-02-06 19:00:34 +08:00
} else {
2019-01-12 11:33:27 +08:00
const itemValue = getValuePropValue(item);
const itemKey = item.key;
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey !== undefined) {
2019-01-12 11:33:27 +08:00
selectedKeys.push(itemKey);
2018-02-06 19:00:34 +08:00
}
}
2019-01-12 11:33:27 +08:00
});
return selectedKeys;
2018-02-06 19:00:34 +08:00
}
export const UNSELECTABLE_STYLE = {
userSelect: 'none',
WebkitUserSelect: 'none',
2019-01-12 11:33:27 +08:00
};
2018-02-06 19:00:34 +08: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 21:28:54 +08:00
unselectable: 'on',
2019-01-12 11:33:27 +08:00
};
2018-02-06 19:00:34 +08:00
2019-01-12 11:33:27 +08:00
export function findFirstMenuItem(children) {
2018-02-06 19:00:34 +08:00
for (let i = 0; i < children.length; i++) {
2019-01-12 11:33:27 +08:00
const child = children[i];
const props = getPropsData(child);
2018-02-12 11:47:57 +08:00
if (getSlotOptions(child).isMenuItemGroup) {
2019-01-12 11:33:27 +08:00
const found = findFirstMenuItem(child.componentOptions.children);
2018-02-06 19:00:34 +08:00
if (found) {
2019-01-12 11:33:27 +08:00
return found;
2018-02-06 19:00:34 +08:00
}
2018-02-07 23:03:47 +08:00
} else if (!props.disabled) {
2019-01-12 11:33:27 +08:00
return child;
2018-02-06 19:00:34 +08:00
}
}
2019-01-12 11:33:27 +08:00
return null;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function includesSeparators(str, separators) {
2018-02-06 19:00:34 +08:00
for (let i = 0; i < separators.length; ++i) {
2019-01-04 23:00:09 +08:00
if (str.lastIndexOf(separators[i]) > 0) {
2019-01-12 11:33:27 +08:00
return true;
2018-02-06 19:00:34 +08:00
}
}
2019-01-12 11:33:27 +08:00
return false;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function splitBySeparators(str, separators) {
const reg = new RegExp(`[${separators.join()}]`);
return str.split(reg).filter(token => token);
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function defaultFilterFn(input, child) {
const props = getPropsData(child);
2018-02-07 23:03:47 +08:00
if (props.disabled) {
2019-01-12 11:33:27 +08:00
return false;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
let value = getPropValue(child, this.optionFilterProp);
2018-02-12 18:10:51 +08:00
if (value.length && value[0].text) {
2019-01-12 11:33:27 +08:00
value = value[0].text;
2018-02-12 18:10:51 +08:00
} else {
2019-01-12 11:33:27 +08:00
value = String(value);
2018-02-12 18:10:51 +08:00
}
2019-01-12 11:33:27 +08:00
return value.toLowerCase().indexOf(input.toLowerCase()) > -1;
2018-02-06 19:00:34 +08:00
}
2019-01-12 11:33:27 +08:00
export function validateOptionValue(value, props) {
2018-02-06 19:00:34 +08:00
if (isSingleMode(props) || isMultiple(props)) {
2019-01-12 11:33:27 +08:00
return;
2018-02-06 19:00:34 +08:00
}
if (typeof value !== 'string') {
throw new Error(
`Invalid \`value\` of type \`${typeof value}\` supplied to Option, ` +
2019-01-04 23:00:09 +08:00
`expected \`string\` when \`tags/combobox\` is \`true\`.`,
2019-01-12 11:33:27 +08:00
);
2018-02-06 19:00:34 +08: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 21:28:54 +08:00
2019-01-12 11:33:27 +08: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 21:28:54 +08:00
}
2019-01-04 23:00:09 +08:00
2019-01-12 11:33:27 +08:00
export function generateUUID() {
2019-01-04 23:00:09 +08:00
if (process.env.NODE_ENV === 'test') {
2019-01-12 11:33:27 +08:00
return 'test-uuid';
2019-01-04 23:00:09 +08:00
}
2019-01-12 11:33:27 +08:00
let d = new Date().getTime();
2019-01-04 23:00:09 +08:00
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
2019-01-12 11:33:27 +08: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 23:00:09 +08:00
}