@@ -16,7 +16,7 @@ import {
1616 */
1717const levelPercentage : LevelPercentage = ( colors , level , direction ) => {
1818 let percentage = 100 ;
19- let percentageChange = colors . percentageChange ?? 0 ;
19+ let percentageChange = colors ? .percentageChange ?? 0 ;
2020
2121 if ( isNaN ( percentageChange ) ) {
2222 percentage = 100 ;
@@ -97,7 +97,7 @@ export const getSingleColor = (color: string, theme: ThemeInstance): string => {
9797const convertLevelColors : ConvertLevelColors = ( options ) => {
9898 const { colors, level, prop = 'default' , theme, type } = options ;
9999 const propOptionResponse = { ...colors [ prop ] as LevelColorResponse } ;
100- const direction = colors . percentageDirection as keyof ColorsObject ;
100+ const direction = colors ? .percentageDirection as keyof ColorsObject ;
101101
102102 // Color prop does not exist //
103103 if ( typeof propOptionResponse === 'undefined' ) {
@@ -112,9 +112,10 @@ const convertLevelColors: ConvertLevelColors = (options) => {
112112 const theTheme = theme . global . current . value . colors ;
113113 let color = theTheme [ value as string ] ?? value as string ;
114114
115- // If color is null set to transparent //
115+ // If color is null or undefined use defaults or set to transparent //
116116 if ( ! color ) {
117- color = 'transparent' ;
117+ color = colors . default [ key ] ?? 'transparent' ;
118+ color = getSingleColor ( color , theme ) ;
118119 }
119120
120121 // If color is a property that should not be converted, return the value //
@@ -424,9 +425,10 @@ function hexToRGB(hex: string): RGBColor {
424425export const useGetLevelColors : UseGetLevelColors = ( options ) => {
425426 const { colors, level, prop = 'default' , themeColors, type = null } = options ;
426427
427- if ( typeof colors !== 'object' || colors === null ) {
428- console . trace ( ) ;
429- throw new Error ( 'The "colors" prop is set to false. This function should not be called.' ) ;
428+ if ( typeof colors !== 'object' || colors === null || typeof colors === 'undefined' ) {
429+ // console.trace(); // For use when debugging //
430+ // throw new Error('Invalid prop: type check failed for prop "colors". Expected Object'); // For use when debugging //
431+ return { } ;
430432 }
431433
432434 const levelColorOptions = convertLevelColors ( {
0 commit comments