mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-02 20:18:22 +08:00
f0385d7c24
* feat: tree * refactor: select * refactor: select * refactor: select * refactor: vc-tree-select * refactor: tree-select * refactor: tree-select * feat: add showLeafIcon * refactor: remove lod vc-tree-select * feat: tree-select add tag-render * refactor: cascader * refactor: cascader * refactor: cascader * refactor: cascader * fix: maxTagmaxTagPlaceholder not work
31 lines
683 B
TypeScript
31 lines
683 B
TypeScript
import { ref } from 'vue';
|
|
import canUseDom from '../../_util/canUseDom';
|
|
|
|
let uuid = 0;
|
|
|
|
/** Is client side and not jsdom */
|
|
export const isBrowserClient = process.env.NODE_ENV !== 'test' && canUseDom();
|
|
|
|
/** Get unique id for accessibility usage */
|
|
export function getUUID(): number | string {
|
|
let retId: string | number;
|
|
|
|
// Test never reach
|
|
/* istanbul ignore if */
|
|
if (isBrowserClient) {
|
|
retId = uuid;
|
|
uuid += 1;
|
|
} else {
|
|
retId = 'TEST_OR_SSR';
|
|
}
|
|
|
|
return retId;
|
|
}
|
|
|
|
export default function useId(id = ref('')) {
|
|
// Inner id for accessibility usage. Only work in client side
|
|
const innerId = `rc_select_${getUUID()}`;
|
|
|
|
return id.value || innerId;
|
|
}
|