import { hidePropertiesIn , hidePropertyIn , Properties , StructurePreviewProps , transformGroupsIntoTabs } from "@mendix/piw-utils-internal" ; import { MaxValueTypeEnum , MinValueTypeEnum , RangeSliderPreviewProps , StepSizeTypeEnum } from "../typings/RangeSliderProps" ; import StructurePreviewSvg from "./assets/structure-preview.svg" ; import StructurePreviewSvgDark from "./assets/structure-preview-dark.svg" ; const keysToHideByMinValueType = { static : [ "minAttribute" , "expressionMinimumValue" ] , dynamic : [ "staticMinimumValue" , "expressionMinimumValue" ] , expression : [ "staticMinimumValue" , "minAttribute" ] } ; const keysToHideByMaxValueType = { static : [ "maxAttribute" , "expressionMaximumValue" ] , dynamic : [ "staticMaximumValue" , "expressionMaximumValue" ] , expression : [ "staticMaximumValue" , "maxAttribute" ] } ; const keysToHideBySizeType = { static : [ "stepAttribute" , "expressionStepSize" ] , dynamic : [ "stepValue" , "expressionStepSize" ] , expression : [ "stepValue" , "stepAttribute" ] } ; export function getProperties ( values , defaultProperties , platform ) { hidePropertiesIn ( defaultProperties , values , [ ... keysToHideByMinValueType [ values . minValueType ] , ... keysToHideByMaxValueType [ values . maxValueType ] , ... keysToHideBySizeType [ values . stepSizeType ] ] ) ; if ( ! values . showTooltip ) { hidePropertiesIn ( defaultProperties , values , [ "tooltipLower" , "tooltipTypeLower" , "tooltipUpper" , "tooltipTypeUpper" ] ) ; } if ( values . tooltipTypeLower === "value" ) { hidePropertyIn ( defaultProperties , values , "tooltipLower" ) ; } if ( values . tooltipTypeUpper === "value" ) { hidePropertyIn ( defaultProperties , values , "tooltipUpper" ) ; } if ( values . orientation === "horizontal" ) { hidePropertiesIn ( defaultProperties , values , [ "heightUnit" , "height" ] ) ; } if ( platform === "web" ) { transformGroupsIntoTabs ( defaultProperties ) ; } return defaultProperties ; } export function getPreview ( _ , isDarkMode ) { return { type : "Image" , document : decodeURIComponent ( ( isDarkMode ? StructurePreviewSvgDark : StructurePreviewSvg ) . replace ( "data:image/svg+xml," , "" ) ) , height : 28 , width : 300 } ; }