import * as R from "ramda"; import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils"; import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers"; export const getButtonsCount = ( configuration: Record, prefix: string ): number => { const button1Key = `${prefix}_button_1_button_enabled`; const button2Key = `${prefix}_button_2_button_enabled`; const button3Key = `${prefix}_button_3_button_enabled`; return R.toPairs(configuration).filter( ([key, value]) => [button1Key, button2Key, button3Key].includes(key) && value ).length; }; export const getPluginIdentifier = ( configuration: Record, prefix: string, index: number ): string => { const match = `${prefix}_button_\\d_assign_action`; const re = new RegExp(match); const rejectNils = R.compose(R.path([index]), R.filter(isNotNil)); return rejectNils( R.toPairs(configuration) .filter(([key]) => R.startsWith(`${prefix}_button`, key)) .map(([key, value]) => { const matched = key.match(re); return matched ? value : undefined; }) ); }; type Label = { name: string; }; type LabelContainer = { elements: Array