11import type { Generic } from 'adopted-style-sheets' ;
22
3- import type { AnyIconFontClass , KoliBriCustomIcon , KoliBriHorizontalIconsProp , KoliBriIconsProp , KoliBriIconsState } from '../types' ;
3+ import type { AnyIconFontClass , KoliBriAllIcons , KoliBriCustomIcon , KoliBriHorizontalIconsProp , KoliBriIconsProp , KoliBriIconsState } from '../types' ;
44import type { Stringified } from '../types/common' ;
55import type { WatchOptions } from '../utils' ;
66import { objectObjectHandler , parseJson , watchValidator } from '../utils' ;
@@ -26,7 +26,7 @@ export type PropHorizontalIcons = {
2626
2727const mapCustomIcon = ( state : KoliBriIconsState , alignment : AlignPropType , icon ?: AnyIconFontClass | KoliBriCustomIcon ) => {
2828 if ( isObject ( icon ) ) {
29- state [ alignment ] = icon as KoliBriCustomIcon ;
29+ state [ alignment ] = icon ;
3030 } else if ( isString ( icon , 1 ) ) {
3131 state [ alignment ] = {
3232 icon : icon as AnyIconFontClass ,
@@ -42,11 +42,12 @@ export const mapIconProp2State = (icon: KoliBriIconsProp): KoliBriIconsState =>
4242 icon : icon as AnyIconFontClass ,
4343 } ,
4444 } ;
45- } else if ( typeof icon === 'object' && icon !== null ) {
46- mapCustomIcon ( state , 'top' , icon . top ) ;
47- mapCustomIcon ( state , 'right' , icon . right ) ;
48- mapCustomIcon ( state , 'bottom' , icon . bottom ) ;
49- mapCustomIcon ( state , 'left' , icon . left ) ;
45+ } else if ( isObject ( icon ) ) {
46+ const icons : KoliBriAllIcons = icon ;
47+ mapCustomIcon ( state , 'top' , icons . top ) ;
48+ mapCustomIcon ( state , 'right' , icons . right ) ;
49+ mapCustomIcon ( state , 'bottom' , icons . bottom ) ;
50+ mapCustomIcon ( state , 'left' , icons . left ) ;
5051 }
5152 return state ;
5253} ;
@@ -59,8 +60,7 @@ const beforePatchIcon = (component: Generic.Element.Component): void => {
5960} ;
6061
6162export const isIcon = ( value ?: unknown ) : boolean =>
62- typeof value === 'object' &&
63- value !== null &&
63+ isObject ( value ) &&
6464 ( typeof ( value as KoliBriCustomIcon ) . style === 'undefined' || isStyle ( ( value as KoliBriCustomIcon ) . style ) ) &&
6565 ( typeof ( value as KoliBriCustomIcon ) . label === 'undefined' || isString ( ( value as KoliBriCustomIcon ) . label ) ) &&
6666 isString ( ( value as KoliBriCustomIcon ) . icon , 1 ) ;
@@ -76,13 +76,12 @@ export const validateIcons = (component: Generic.Element.Component, value?: Icon
7676 component ,
7777 '_icons' ,
7878 ( value ) : boolean => {
79- const valueIsEmptyObject = typeof value === 'object' && value !== null && Object . keys ( value ) . length === 0 ;
79+ const valueIsEmptyObject = isObject ( value ) && Object . keys ( value ) . length === 0 ;
8080 return (
8181 value === null ||
8282 valueIsEmptyObject ||
8383 isString ( value , 1 ) ||
84- ( typeof value === 'object' &&
85- value !== null &&
84+ ( isObject ( value ) &&
8685 ( isString ( value . left , 1 ) ||
8786 isIcon ( value . left ) ||
8887 isString ( value . right , 1 ) ||
0 commit comments