@JsOverlay @Nonnull static ReactElement createContextElement( @Nonnull final Object type ) { final ReactElement element = create( type ); element.props = JsPropertyMap.of(); element.key = null; element.ref = null; return element; }
/** * Init instance properties for the given VueComponent instance. The Constructor for VueComponent * is provided by Vue and doesn't extend the {@link IsVueComponent} constructor. This method get * an instance of the Java class for the VueComponent and copy properties to the * VueComponentInstance. This will initialise properties that are initialised inline in the class. * For example: List<String> myList = new LinkedList<String>(); * * @param vueComponentInstance An instance of VueComponent to initialize * @param javaComponentClassInstance An instance of the Component class */ public static void initComponentInstanceFields(IsVueComponent vueComponentInstance, IsVueComponent javaComponentClassInstance) { JsPropertyMap<Object> vueComponentInstancePropertyMap = Js.cast(vueComponentInstance); JsPropertyMap<Object> javaComponentClassInstancePropertyMap = Js .cast(javaComponentClassInstance); javaComponentClassInstancePropertyMap.forEach(key -> { try { if (!javaComponentClassInstancePropertyMap.has(key) || vueComponentInstancePropertyMap.get(key) != null) { return; } vueComponentInstancePropertyMap.set(key, javaComponentClassInstancePropertyMap.get(key)); } catch (Exception e) { } }); }
/** * Copy a Java class prototype to a VueComponent declaration. This allows VueComponent created by * Vue to pass as an instance of the {@link IsVueComponent} class they represent. * * @param extendedVueJsConstructor The Vue.js constructor function to extend * @param javaComponentPrototype The {@link IsVueComponent} class JS prototype to extend with * @param <T> The type of the VueComponent */ public static <T extends IsVueComponent> void extendVueConstructorWithJavaPrototype( VueJsConstructor<T> extendedVueJsConstructor, JsPropertyMap<Object> javaComponentPrototype) { JsPropertyMap vueProto = (JsPropertyMap) ((JsPropertyMap) extendedVueJsConstructor).get("prototype"); JsObject vueProtoJsObject = ((JsObject) vueProto); javaComponentPrototype.forEach(protoProp -> { if (!vueProtoJsObject.hasOwnProperty(protoProp)) { vueProto.set(protoProp, javaComponentPrototype.get(protoProp)); } }); }
final JsPropertyMap<Object> newState = JsPropertyMap.of(); newState.set( "Arez.id", getComponentId() ); if ( Arez.areNamesEnabled() ) newState.set( "Arez.name", getComponentName() ); if ( !newState.has( key ) ) newState.set( key, Js.undefined() ); for ( final String key : JsObject.keys( Js.uncheckedCast( newState ) ) ) final Any newValue = currentState.getAny( key ); final Any existingValue = newState.getAny( key ); if ( !Objects.equals( newValue, existingValue ) )
@Nonnull public final ProviderBuilder<ST> value( @Nullable final ST value ) { _element.props().set( "value", value ); return this; }
/** * Return the Vue Observer for the given object. The object must be reactive (visible in a Vue * Component) otherwise this method will return null. * * @param object The object we want to get the Vue Observer from * @return The Vue Observer for this Object */ public VueObserver getVueObserver(Object object) { return (VueObserver) ((JsPropertyMap) object).get("__ob__"); }
JsPropertyMap<Any> map = cast(instance); JsObject jsObject = cast(instance); map.forEach(key -> { if (!jsObject.hasOwnProperty(key)) { return; Any val = asAny(map.get(key)); if (isTripleEqual(val, null) || isTripleEqual(val, asAny(1)) || isTripleEqual(val, asAny(true))) { map.delete(key); map.forEach(key -> { if (!jsObject.hasOwnProperty(key)) { return; Any val = asAny(map.get(key)); if (isTripleEqual(val, null) || isTripleEqual(val, asAny(1)) ||
/** * Return true if data for the attribute identified by the key is null. * * @param key the attribute key. * @return true if the data is null. */ @JsOverlay default boolean isNull( @Nonnull final String key ) { return null == Js.asPropertyMap( this ).getAny( key ); }
/** * Return true if data for the attribute identified by the key is present in the change. * * @param key the attribute key. * @return true if the data is present. */ @JsOverlay default boolean containsKey( @Nonnull final String key ) { return Js.asPropertyMap( this ).has( key ); }
/** * Set the JS Prototype of the ExportedType Java Class represented by this {@link * VueComponentOptions}. This prototype will be used to retrieve the java methods of our {@link * IsVueComponent}. * * @param prototype The JS prototype of the ExportedType Java Class */ @JsOverlay public final void setComponentExportedTypePrototype(JsPropertyMap<Object> prototype) { this.componentExportedTypePrototype = prototype; // This must be set for Components extending Native JS Components this.componentExportedTypePrototype.set("options", this); }
@JsOverlay public final <T> JsArray<T> $refArray(String refName) { return ((JsPropertyMap<JsArray<T>>) $refs).get(refName); }
@Nonnull @JsOverlay default String getStringValue( @Nonnull final String key ) { return Js.asPropertyMap( this ).getAny( key ).asString(); }
@JsOverlay @Nonnull public static ReactElement createComponentElement( @Nonnull final ComponentConstructorFunction type ) { final ReactElement element = create( type ); element.props = JsPropertyMap.of(); element.key = null; element.ref = null; return element; }
private static ReactElement createElement( @Nonnull final String type, @Nullable final JsPropertyMap<Object> props, @Nullable final ReactNode... children ) final JsPropertyMap<Object> actual = JsPropertyMap.of(); String key = null; Object ref = null; if ( null != props ) key = props.has( "key" ) ? Js.asString( props.get( "key" ) ) : null; ref = props.has( "ref" ) ? props.get( "ref" ) : null; props.forEach( p -> { actual.set( p, props.get( p ) ); actual.set( "children", children[ 0 ] ); actual.set( "children", children );