import { type TokenSrcGroup, type TokenData, type TokenGroupData, type TokenKsExtensions, type TokenCollectionData } from '@knapsack/types'; /** * Tokens "data" shape used at runtime. This is what pure, tokens "source" is * converted to in order to make usage and lookups easier. */ export type TokenDataSummary = { tokensById: Record; tokens: TokenData[]; groupsById: Record; groups: TokenGroupData[]; /** * Extracted from `$extensions['cloud.knapsack'].global` */ globalConfig: TokenKsExtensions['global']; collections: TokenCollectionData[]; collectionsById: Record; }; /** * Removes last item of dot separated string. * `a.b.c` => `a.b` */ export declare const getParentId: (id: string) => string; /** * A token ID gives away how deeply nested it is by the number of dots in the ID. * e.g. color.brand.primary is 3 levels deep. */ export declare const getLevel: (id: string) => number; /** * Determine a token ID is within a group ID by splitting both on '.' and testing * if all of the group ID parts are in the token ID array. * @TODO: move to utils */ type GroupIdChildId = { groupId: string; childId: string; }; export declare const groupHasChild: ({ groupId, childId }: GroupIdChildId) => boolean; /** * Get immediate children of a group * ie `color.pink5` => `color.pink5.100`, `color.pink5.200` * * NOTE! This REMOVES items from allIds as they are found so subsequent searches * are faster. Do not use this if you need to find the same childrenIds more than * once. * * NOTE! This also fully depends on allIds being a Set sorted like so: * "color" * "color.primary" * "color.primary.light" * "color.secondary" * "color.secondary.light". * * The use of flatten() guarantees this order. */ type GroupIdAllIds = { groupId: string; allIds: Set; }; export declare const getChildrenIds: ({ groupId, allIds }: GroupIdAllIds) => string[]; /** * Simple alphabetical sort - numbers before strings, then alphabetically * We also want to keep sub groups right after their parent group */ export declare const sortAlphabetically: (a: string, b: string) => number; /** * The workhorse of generating the actual token data used within the app UI. The * memoized version - which is actually used in runtime - is created and exported below. */ export declare const convertTokenGroupToData: (obj: TokenSrcGroup) => TokenDataSummary; export {}; //# sourceMappingURL=convert-src-to-token-data.d.ts.map