1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

added tag autocomplete

This commit is contained in:
Fedor Katurov 2020-10-31 20:49:28 +07:00
parent 1414245a1a
commit 359cfaee7a
18 changed files with 375 additions and 80 deletions

13
src/utils/tag.ts Normal file
View file

@ -0,0 +1,13 @@
import { ITag } from '~/redux/types';
export const separateTags = (tags: Partial<ITag>[]): Partial<ITag>[][] =>
(tags || []).reduce(
(obj, tag) =>
tag.title.substr(0, 1) === '/' ? [[...obj[0], tag], obj[1]] : [obj[0], [...obj[1], tag]],
[[], []]
);
export const separateTagOptions = (options: string[]): string[][] =>
separateTags(options.map((title): Partial<ITag> => ({ title }))).map(item =>
item.map(({ title }) => title)
);