@@ -17,6 +17,7 @@ import {
1717} from '@angular/core' ;
1818import classnames from 'classnames' ;
1919import toStyle from 'css-to-style' ;
20+ import stylenames , { StyleObject } from 'stylenames' ;
2021import { Many } from '../declarations/many' ;
2122import { ReactContentProps } from '../renderer/react-content' ;
2223import { isReactNode } from '../renderer/react-node' ;
@@ -44,10 +45,28 @@ export type InputRendererOptions<TContext extends object> =
4445
4546export type JsxRenderFunc < TContext > = ( context : TContext ) => JSX . Element ;
4647
48+ /**
49+ * Optional options to pass to `ReactWrapperComponent`.
50+ */
51+ /**
52+ * Whether the host's `display` should be set to the root child node's`display`.
53+ * @default `false`.
54+ */
55+
56+ /**
57+ * The zone to use to track changes to inner (Angular) templates & components.
58+ * @default `undefined`.
59+ */
60+ /* export type _ReactWrapperComponentInternalView<TProps extends {} = {}> = ReactWrapperComponent<TProps> & {
61+ readonly reactNodeRef: ElementRef<HTMLElement>;
62+ }; */
63+
4764export type ContentClassValue = string [ ] | Set < string > | { [ klass : string ] : any } ;
65+ export type ContentStyleValue = string | StyleObject ;
66+
4867/**
4968 * Base class for Angular @Components wrapping React Components.
50- * Simplifies some of the handling around passing down props and setting CSS on the host component.
69+ * Simplifies some of the handling around passing down props and CSS styling on the host component.
5170 */
5271// NOTE: TProps is not used at the moment, but a preparation for a potential future change.
5372export abstract class ReactWrapperComponent < TProps extends { } > implements AfterViewInit , OnChanges {
@@ -76,21 +95,23 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
7695 }
7796
7897 /**
79- * Alternative to `style` using the same syntax.
98+ * Alternative to `style` and `[ngStyle]` using (almost) the same syntax.
99+ * All syntax supports by `ngStyle` is supported, with the exception of specifying units in the key (`{ 'width.px': 12 }`).
80100 *
81101 * @description Since this is a wrapper component, sticking to the virtual DOM concept, this should have any styling of its own.
82102 * Any value passes to `contentStyle` will be passed to the root component's style.
83103 */
84104 @Input ( )
85- set contentStyle ( value : string ) {
105+ set contentStyle ( value : ContentStyleValue ) {
86106 this . _contentStyle = value ;
87107 if ( isReactNode ( this . reactNodeRef . nativeElement ) ) {
88- this . reactNodeRef . nativeElement . setProperty ( 'style' , toStyle ( value ) ) ;
108+ const stringValue = typeof value === 'string' ? value : stylenames ( value ) ;
109+ this . reactNodeRef . nativeElement . setProperty ( 'style' , toStyle ( stringValue ) ) ;
89110 this . changeDetectorRef . detectChanges ( ) ;
90111 }
91112 }
92113
93- get contentStyle ( ) : string {
114+ get contentStyle ( ) : ContentStyleValue {
94115 return this . _contentStyle ;
95116 }
96117
0 commit comments