@zohodesk/components
Version:
Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development
57 lines (50 loc) • 1.14 kB
JavaScript
import { useNumberGenerator, getNumberGenerators } from "./NumberGenerator/NumberGenerator";
import { getLibraryConfig } from "./Config";
let globalId = getLibraryConfig('zindexCounter'),
deletedIndexes = [],
globalPrefix;
export function removeGlobalZIndexPrefix() {
globalPrefix = undefined;
}
function getGlobalZIndexPrefix() {
return globalPrefix;
}
export function setInitialZIndex(id) {
globalId = id;
}
function getGlobalId() {
return globalId;
}
function setDeletedIndexes(array) {
deletedIndexes = array;
}
function getDeletedIndexes() {
return deletedIndexes;
}
function callback(_ref) {
let {
globalId,
deletedIndexes
} = _ref;
setInitialZIndex(globalId);
setDeletedIndexes(deletedIndexes);
}
export function useZIndex(prefix) {
return useNumberGenerator({
getGlobalId,
prefix,
getGlobalPrefix: getGlobalZIndexPrefix,
getDeletedIndexes,
callback
});
}
export function getZIndex(Component, prefix) {
return getNumberGenerators({
Component,
prefix,
getGlobalPrefix: getGlobalZIndexPrefix,
getGlobalId,
getDeletedIndexes,
callback
});
}