UNPKG

igniteui-webcomponents

Version:

Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.

96 lines 3.36 kB
import { isString } from '../util.js'; export const calendarResourcesMap = new Map([ ['selectMonth', 'calendar_select_month'], ['selectYear', 'calendar_select_year'], ['selectDate', 'calendar_select_date'], ['selectRange', 'calendar_range_placeholder'], ['selectedDate', undefined], ['startDate', 'calendar_range_label_start'], ['endDate', 'calendar_range_label_end'], ['previousMonth', 'calendar_previous_month'], ['nextMonth', 'calendar_next_month'], ['previousYear', 'calendar_previous_year'], ['nextYear', 'calendar_next_year'], ['previousYears', 'calendar_previous_years'], ['nextYears', 'calendar_next_years'], ['weekLabel', 'i18n/getWeekLabel'], ]); export const chatResourcesMap = new Map([ ['suggestionsHeader', 'chat_suggestions_header'], ['reactionCopy', 'chat_reaction_copy'], ['reactionLike', 'chat_reaction_like'], ['reactionDislike', 'chat_reaction_dislike'], ['reactionRegenerate', 'chat_reaction_regenerate'], ['attachmentLabel', 'chat_attachment_label'], ['attachmentsListLabel', 'chat_attachments_list_label'], ['messageCopied', 'chat_message_copied'], ]); export const dateRangePickerResourcesMap = new Map([ ['separator', 'date_range_picker_date_separator'], ['done', 'date_range_picker_done_button'], ['cancel', 'date_range_picker_cancel_button'], ['last7Days', 'date_range_picker_last7Days'], ['last30Days', 'date_range_picker_last30Days'], ['currentMonth', 'date_range_picker_currentMonth'], ['yearToDate', 'date_range_picker_yearToDate'], ...calendarResourcesMap.entries(), ]); export const datePickerResourcesMap = new Map([ ['changeDate', 'date_picker_change_date'], ['chooseDate', 'date_picker_choose_date'], ...calendarResourcesMap.entries(), ]); function getResourceMap(name) { switch (name) { case 'calendar': return calendarResourcesMap; case 'chat': return chatResourcesMap; case 'date-picker': return datePickerResourcesMap; case 'date-range-picker': return dateRangePickerResourcesMap; default: break; } return new Map(); } export function convertToIgcResource(resource, resourceMapName) { const result = {}; const resourceMap = getResourceMap(resourceMapName); if (!resourceMap) { return resource; } for (const [igcKey, coreKey] of resourceMap) { if (igcKey in resource) { result[igcKey] = resource[igcKey]; } else if (coreKey && coreKey in resource) { const value = resource[coreKey]; if (isString(value)) { result[igcKey] = value; } } } return result; } export function convertToCoreResource(resource, resourceMapName) { const result = {}; const resourceMap = getResourceMap(resourceMapName); if (!resourceMap) { return resource; } for (const [igcKey, coreKey] of resourceMap) { if (coreKey && coreKey in resource) { result[coreKey] = resource[coreKey]; } else if (coreKey) { const value = resource[igcKey]; if (isString(value)) { result[coreKey] = value; } } } return result; } //# sourceMappingURL=utils.js.map