+export const getPreferredTagValues = (tagKeyID: string, vocabulary: Vocabulary, withMatch?: string): PropFieldSuggestion[] => {
+ const tag = vocabulary.tags[tagKeyID];
+ const regex = !!withMatch ? new RegExp(escapeRegExp(withMatch), 'i') : undefined;
+ return tag && tag.values
+ ? Object.keys(tag.values).map(
+ tagValueID => tag.values![tagValueID].labels && tag.values![tagValueID].labels.length > 0
+ ? {
+ "id": tagValueID,
+ "label": tag.values![tagValueID].labels[0].label,
+ "synonyms": !!withMatch && tag.values![tagValueID].labels.length > 1
+ ? tag.values![tagValueID].labels.slice(1)
+ .filter(l => !!regex ? regex.test(l.label) : true)
+ .map(l => l.label)
+ : []
+ }
+ : {"id": tagValueID, "label": tagValueID, "synonyms": []})
+ .sort(compare)
+ : [];
+};
+
+export const getTags = ({ tags }: Vocabulary): PropFieldSuggestion[] => {
+ return tags && Object.keys(tags)