package de.eddyson.tapestry.react.select;

import java.io.IOException;

import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.annotations.Path;
import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.Resource;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.FactoryDefaults;
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.services.javascript.JavaScriptModuleConfiguration;
import org.apache.tapestry5.services.javascript.ModuleManager;

//https://github.com/JedWatson/react-select/issues/270
public class ReactSelectModule {

  @Contribute(ModuleManager.class)
  public static void setupJSModules(final MappedConfiguration<String, JavaScriptModuleConfiguration> configuration,
      @Path("classpath:de/eddyson/tapestry/react/select/react-select.js") final Resource reactSelect,
      @Path("classpath:de/eddyson/tapestry/react/select/react-select.js") final Resource reactSelectMin,
      @Path("classpath:de/eddyson/tapestry/react/select/react-input-autosize.js") final Resource reactInputautoSize,
      @Path("classpath:de/eddyson/tapestry/react/select/react-input-autosize.js") final Resource reactInputautoSizeMin,
      @Path("classpath:de/eddyson/tapestry/react/select/classnames.js") final Resource classnames,
      @Symbol(ReactSelectSymbols.CONTRIBUTE_CLASSNAMES_MODULE) final boolean contributeClassnamesModule,
      @Symbol(ReactSelectSymbols.CONTRIBUTE_REACT_INPUT_AUTOSIZE_MODULE) final boolean contributeInputAutosizeModule,
      @Symbol(SymbolConstants.PRODUCTION_MODE) final boolean productionMode) throws IOException {
    if (contributeClassnamesModule) {
      configuration.add("classnames", new JavaScriptModuleConfiguration(classnames));
    }
    if (contributeInputAutosizeModule) {
      configuration.add("react-input-autosize",
          new JavaScriptModuleConfiguration(productionMode ? reactInputautoSizeMin : reactInputautoSize));
    }
    configuration.add("react-select", new JavaScriptModuleConfiguration(productionMode ? reactSelectMin : reactSelect));
  }

  @Contribute(SymbolProvider.class)
  @FactoryDefaults
  public static void configureSymbolDefaults(final MappedConfiguration<String, Object> configuration) {
    configuration.add(ReactSelectSymbols.CONTRIBUTE_CLASSNAMES_MODULE, true);
    configuration.add(ReactSelectSymbols.CONTRIBUTE_REACT_INPUT_AUTOSIZE_MODULE, true);

  }

}

@@ -1020,32 +1020,36 @@
 ct/react-select.
+min.
 js%22) final Resou
@@ -1254,32 +1254,36 @@
 -input-autosize.
+min.
 js%22) final Resou

fix minified module paths