/** * 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__"); }
static boolean isVueLibInjected() { return ((JsPropertyMap) DomGlobal.window).get("Vue") != null; } }
/** * Return a "deep" value in a given object by following an expression in the form: * "parent.child.property". This only works if all the chain is exposed using JsInterop. * * @param object The root object to get on * @param path The path to follow * @param <T> The type of object we get in return * @return The object at the end of the chain */ public static <T> T getDeepValue(Object object, String path) { JsPropertyMap objectMap = (JsPropertyMap) object; String[] pathSplit = path.split("\\."); for (String s : pathSplit) { objectMap = (JsPropertyMap) objectMap.get(s); } return (T) objectMap; }
@JsOverlay public final <T> JsArray<T> $refArray(String refName) { return ((JsPropertyMap<JsArray<T>>) $refs).get(refName); }
private String convertStyle(JsPropertyMap<String> rippleStyle) { StringBuilder style = new StringBuilder(); rippleStyle.forEach(key -> { style.append(key + ":" + rippleStyle.get(key) + ";"); }); return style.toString(); }
private String convertStyle(JsPropertyMap<String> rippleStyle) { StringBuilder style = new StringBuilder(); rippleStyle.forEach(key -> { style.append(key + ":" + rippleStyle.get(key) + ";"); }); return style.toString(); }
@JsOverlay public final boolean $isRefArray(String refName) { return ((JsPropertyMap<Object>) $refs).get(refName) instanceof JsArray; }
@JsOverlay public final boolean $isListenerArray(String key) { return ((JsPropertyMap<Object>) $listeners).get(key) instanceof JsArray; }
@JsOverlay default VueComponentOptions<T> getOptions() { return (VueComponentOptions<T>) ((JsPropertyMap) this).get("options"); }
@JsOverlay public final <T> T $ref(String refName) { return ((JsPropertyMap<T>) $refs).get(refName); }
@JsOverlay public final Function $listener(String key) { return ((JsPropertyMap<Function>) $listeners).get(key); }
@JsOverlay public final JsArray<Function> $listenerArray(String key) { return ((JsPropertyMap<JsArray<Function>>) $listeners).get(key); }
private Map<String, Object> initClassPropertiesCache(JsObject object, String className) { final Map<String, Object> tmpCache = new HashMap<>(); classesPropertyCaches.put(className, tmpCache); JsPropertyMap prototype = (JsPropertyMap) object.__proto__; prototype.forEach(property -> { Object value = prototype.get(property); if (isDefaultValue(value)) { tmpCache.put(property, value); } }); return tmpCache; }
/** * Add a custom prop validator to validate a property * * @param javaMethod Function pointer to the method in the {@link IsVueComponent} * @param propertyName The name of the property to validate */ @JsOverlay public final void addJavaPropValidator(Function javaMethod, String propertyName) { PropOptions propDefinition = getProps().get(propertyName); propDefinition.validator = javaMethod; }
@JsOverlay public final T getComponent() { return this.__vue_custom_element__.get("$children").getAt(0); } }
/** * Copy the given hook function from the Java instance to the options we pass to Vue * * @param hookFunctionName The name of the hook function to copy */ private void copyHook(String hookFunctionName) { Function hookFunction = (Function) ((JsPropertyMap) vuegwt$javaDirectiveInstance).get(hookFunctionName); if (hookFunction == null) { return; } // Filter empty function inherited from VueDirective String body = getFunctionBody(hookFunction); if ("".equals(body)) { return; } set(hookFunctionName, hookFunction); }
/** * Add a custom prop validator to validate a property * * @param javaMethod Function pointer to the method in the {@link IsVueComponent} * @param propertyName The name of the property to validate */ @JsOverlay public final void addJavaPropDefaultValue(Function javaMethod, String propertyName) { PropOptions propDefinition = getProps().get(propertyName); propDefinition.defaultValue = javaMethod; }
@JsOverlay public final <T> T $computed(String propertyName) { JsPropertyMap<T> map = Js.cast(this); return map.get(propertyName); } }
public static TimeZoneInfo buildTimeZoneData(String json) { TimeZoneInfo timeZoneInfo=new TimeZoneInfo(); JsPropertyMap<?> parsed = Js.cast(Global.JSON.parse(json)); timeZoneInfo.id=Js.cast(parsed.get("id")); timeZoneInfo.std_offset=Js.cast(parsed.get("std_offset")); timeZoneInfo.names=Js.cast(parsed.get("names")); JsArray<Any> jsTransitions=Js.cast(parsed.get("transitions")); for(int i=0;i<jsTransitions.length;i++){ timeZoneInfo.transitions.push(jsTransitions.getAt(i).asInt()); } return timeZoneInfo; }
@JsOverlay public final ComputedOptions getComputedOptions(String name) { if (getComputed() == null) { setComputed(cast(JsPropertyMap.of())); } return getComputed().get(name); }