diff --git a/importer-portable/src/main/scala/org/scalablytyped/converter/internal/importer/AdaptiveNamingImport.scala b/importer-portable/src/main/scala/org/scalablytyped/converter/internal/importer/AdaptiveNamingImport.scala index c512956f0f..bdc1045b92 100644 --- a/importer-portable/src/main/scala/org/scalablytyped/converter/internal/importer/AdaptiveNamingImport.scala +++ b/importer-portable/src/main/scala/org/scalablytyped/converter/internal/importer/AdaptiveNamingImport.scala @@ -130,7 +130,7 @@ object AdaptiveNamingImport { } private def addMod(str: String) = str match { - case "" => "mod" + case "" => Name.mod.unescaped case nonEmpty => nonEmpty + "Mod" } diff --git a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/Name.scala b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/Name.scala index 9afa720b9d..5830cb0dcb 100644 --- a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/Name.scala +++ b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/Name.scala @@ -13,6 +13,7 @@ final case class Name(unescaped: String) { } object Name { + val mod: Name = Name("mod") val std: Name = Name("std") val typings: Name = Name("typings") val global: Name = Name("global") diff --git a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/IdentifyReactComponents.scala b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/IdentifyReactComponents.scala index 076e764631..0f8035d2e3 100644 --- a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/IdentifyReactComponents.scala +++ b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/IdentifyReactComponents.scala @@ -195,8 +195,9 @@ class IdentifyReactComponents( case _: ClassTree => false case _ => true } - val propsRef = PropsRef(flattenedParams.headOption.map(_.tpe).getOrElse(TypeRef.Object)) - def validName = isUpper(method.name) || (Unnamed(method.name) && (isUpper(owner.name) || Unnamed(owner.name))) + val propsRef = PropsRef(flattenedParams.headOption.map(_.tpe).getOrElse(TypeRef.Object)) + def validName = + isUpper(method.name) || (Unnamed(method.name) && (isUpper(owner.name) || Unnamed(owner.name) || owner.name === Name.mod)) if (!validName || !isTopLevel || !method.isNative) None else @@ -385,7 +386,7 @@ class IdentifyReactComponents( val fromCodePath = codePath.parts .filterNot(Unnamed) .reverse - .takeWhile(n => !n.unescaped.endsWith("Mod") && n.unescaped != "mod") + .takeWhile(n => !n.unescaped.endsWith("Mod") && n != Name.mod) .headOption val name = fromCodePath.orElse(fromAnnotations(anns)) diff --git a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/ReactNames.scala b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/ReactNames.scala index 48d3b65505..a43fa9342a 100644 --- a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/ReactNames.scala +++ b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/ReactNames.scala @@ -4,7 +4,7 @@ package flavours class ReactNames(val outputPkg: Name) { val libName = Name("react") - val mod = QualifiedName(IArray(outputPkg, libName, Name("mod"))) + val mod = QualifiedName(IArray(outputPkg, libName, Name.mod)) val Ref = mod + Name("Ref") val LegacyRef = mod + Name("LegacyRef") val RefObject = mod + Name("RefObject") diff --git a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/SlinkyGenStBuildingComponent.scala b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/SlinkyGenStBuildingComponent.scala index 7e660e4883..0deac9e79b 100644 --- a/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/SlinkyGenStBuildingComponent.scala +++ b/scalajs/src/main/scala/org/scalablytyped/converter/internal/scalajs/flavours/SlinkyGenStBuildingComponent.scala @@ -194,7 +194,7 @@ class SlinkyGenStBuildingComponent(val outputPkg: Name, val scalaVersion: Versio comments = NoComments, ) val impl = { - val modParam = ParamTree(Name("mod"), isImplicit = false, isVal = false, TagModE, NotImplemented, NoComments) + val modParam = ParamTree(Name.mod, isImplicit = false, isVal = false, TagModE, NotImplemented, NoComments) val modRef = Ref(modParam.name) val AttrPair = TypeRef(SlinkyGenComponents.names.AttrPair, IArray(TypeRef.Wildcard), NoComments) diff --git a/tests/react-integration-test/check-japgolly/r/react-dropzone/build.sbt b/tests/react-integration-test/check-japgolly/r/react-dropzone/build.sbt index 21a74fa901..aa37746d9f 100644 --- a/tests/react-integration-test/check-japgolly/r/react-dropzone/build.sbt +++ b/tests/react-integration-test/check-japgolly/r/react-dropzone/build.sbt @@ -1,6 +1,6 @@ organization := "org.scalablytyped" name := "react-dropzone" -version := "10.1.10-d9f6ec" +version := "10.1.10-f9d26c" scalaVersion := "2.13.3" enablePlugins(ScalaJSPlugin) libraryDependencies ++= Seq( diff --git a/tests/react-integration-test/check-japgolly/r/react-dropzone/src/main/scala/typingsJapgolly/reactDropzone/components/ReactDropzone.scala b/tests/react-integration-test/check-japgolly/r/react-dropzone/src/main/scala/typingsJapgolly/reactDropzone/components/ReactDropzone.scala new file mode 100644 index 0000000000..f93e53e6a9 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-dropzone/src/main/scala/typingsJapgolly/reactDropzone/components/ReactDropzone.scala @@ -0,0 +1,97 @@ +package typingsJapgolly.reactDropzone.components + +import japgolly.scalajs.react.Callback +import japgolly.scalajs.react.ReactDragEventFrom +import japgolly.scalajs.react.raw.React.Element +import org.scalajs.dom.raw.HTMLElement +import typingsJapgolly.StBuildingComponent +import typingsJapgolly.react.mod.RefAttributes +import typingsJapgolly.reactDropzone.mod.DropEvent +import typingsJapgolly.reactDropzone.mod.DropzoneProps +import typingsJapgolly.reactDropzone.mod.DropzoneRef +import typingsJapgolly.reactDropzone.mod.DropzoneState +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object ReactDropzone { + + @JSImport("react-dropzone", JSImport.Default) + @js.native + val component: js.Object = js.native + + @scala.inline + class Builder (val args: js.Array[js.Any]) + extends AnyVal + with StBuildingComponent[DropzoneRef] { + + @scala.inline + def accept(value: String | js.Array[String]): this.type = set("accept", value.asInstanceOf[js.Any]) + + @scala.inline + def acceptVarargs(value: String*): this.type = set("accept", js.Array(value :_*)) + + @scala.inline + def children(value: /* state */ DropzoneState => Element): this.type = set("children", js.Any.fromFunction1(value)) + + @scala.inline + def disabled(value: Boolean): this.type = set("disabled", value.asInstanceOf[js.Any]) + + @scala.inline + def getFilesFromEvent( + value: /* event */ DropEvent => /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify Promise> */ _ + ): this.type = set("getFilesFromEvent", js.Any.fromFunction1(value)) + + @scala.inline + def maxSize(value: Double): this.type = set("maxSize", value.asInstanceOf[js.Any]) + + @scala.inline + def minSize(value: Double): this.type = set("minSize", value.asInstanceOf[js.Any]) + + @scala.inline + def multiple(value: Boolean): this.type = set("multiple", value.asInstanceOf[js.Any]) + + @scala.inline + def noClick(value: Boolean): this.type = set("noClick", value.asInstanceOf[js.Any]) + + @scala.inline + def noDrag(value: Boolean): this.type = set("noDrag", value.asInstanceOf[js.Any]) + + @scala.inline + def noDragEventsBubbling(value: Boolean): this.type = set("noDragEventsBubbling", value.asInstanceOf[js.Any]) + + @scala.inline + def noKeyboard(value: Boolean): this.type = set("noKeyboard", value.asInstanceOf[js.Any]) + + @scala.inline + def onDragEnter(value: ReactDragEventFrom[HTMLElement] => Callback): this.type = set("onDragEnter", js.Any.fromFunction1((t0: ReactDragEventFrom[HTMLElement]) => value(t0).runNow())) + + @scala.inline + def onDragLeave(value: ReactDragEventFrom[HTMLElement] => Callback): this.type = set("onDragLeave", js.Any.fromFunction1((t0: ReactDragEventFrom[HTMLElement]) => value(t0).runNow())) + + @scala.inline + def onDragOver(value: ReactDragEventFrom[HTMLElement] => Callback): this.type = set("onDragOver", js.Any.fromFunction1((t0: ReactDragEventFrom[HTMLElement]) => value(t0).runNow())) + + @scala.inline + def onDrop( + value: (/* acceptedFiles */ js.Array[js.Any], /* rejectedFiles */ js.Array[js.Any], /* event */ DropEvent) => Callback + ): this.type = set("onDrop", js.Any.fromFunction3((t0: /* acceptedFiles */ js.Array[js.Any], t1: /* rejectedFiles */ js.Array[js.Any], t2: /* event */ DropEvent) => (value(t0, t1, t2)).runNow())) + + @scala.inline + def onDropAccepted(value: (/* files */ js.Array[js.Any], /* event */ DropEvent) => Callback): this.type = set("onDropAccepted", js.Any.fromFunction2((t0: /* files */ js.Array[js.Any], t1: /* event */ DropEvent) => (value(t0, t1)).runNow())) + + @scala.inline + def onDropRejected(value: (/* files */ js.Array[js.Any], /* event */ DropEvent) => Callback): this.type = set("onDropRejected", js.Any.fromFunction2((t0: /* files */ js.Array[js.Any], t1: /* event */ DropEvent) => (value(t0, t1)).runNow())) + + @scala.inline + def onFileDialogCancel(value: Callback): this.type = set("onFileDialogCancel", value.toJsFn) + + @scala.inline + def preventDropOnDocument(value: Boolean): this.type = set("preventDropOnDocument", value.asInstanceOf[js.Any]) + } + + implicit def make(companion: ReactDropzone.type): Builder = new Builder(js.Array(this.component, js.Dictionary.empty))() + + def withProps(p: DropzoneProps with RefAttributes[DropzoneRef]): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any])) +} diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/build.sbt b/tests/react-integration-test/check-japgolly/r/react-markdown/build.sbt new file mode 100644 index 0000000000..b8ff00985a --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/build.sbt @@ -0,0 +1,15 @@ +organization := "org.scalablytyped" +name := "react-markdown" +version := "0.0-unknown-7278fc" +scalaVersion := "2.13.3" +enablePlugins(ScalaJSPlugin) +libraryDependencies ++= Seq( + "com.github.japgolly.scalajs-react" %%% "core" % "1.7.5", + "com.olvind" %%% "scalablytyped-runtime" % "2.4.0", + "org.scalablytyped" %%% "react" % "16.9.2-0e03be", + "org.scalablytyped" %%% "std" % "0.0-unknown-43ed0a") +publishArtifact in packageDoc := false +scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials") +licenses += ("MIT", url("http://opensource.org/licenses/MIT")) +bintrayRepository := "ScalablyTyped" +resolvers += Resolver.bintrayRepo("oyvindberg", "ScalablyTyped") diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/project/build.properties b/tests/react-integration-test/check-japgolly/r/react-markdown/project/build.properties new file mode 100644 index 0000000000..b80399a6ad --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.4.2 \ No newline at end of file diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/project/plugins.sbt b/tests/react-integration-test/check-japgolly/r/react-markdown/project/plugins.sbt new file mode 100644 index 0000000000..fe7cc09e18 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.3.0") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/readme.md b/tests/react-integration-test/check-japgolly/r/react-markdown/readme.md new file mode 100644 index 0000000000..07a10b6741 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/readme.md @@ -0,0 +1,15 @@ + +# Scala.js typings for react-markdown + + + + +## Note +This library has been generated from typescript code from first party type definitions. + +Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped) + +## Usage +See [the main readme](../../readme.md) for instructions. + + diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/components/ReactMarkdown.scala b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/components/ReactMarkdown.scala new file mode 100644 index 0000000000..d6f30cac35 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/components/ReactMarkdown.scala @@ -0,0 +1,20 @@ +package typingsJapgolly.reactMarkdown.components + +import typingsJapgolly.StBuildingComponent.Default +import typingsJapgolly.reactMarkdown.mod.ReactMarkdownProps +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +/* The props of this component has an unsupported shape. You can use `set` manually to use it, but with no compiler support :/ . Couldn't find props for typingsJapgolly.reactMarkdown.mod.ReactMarkdownProps because: IArray(Couldn't find props for typingsJapgolly.reactMarkdown.mod.ChildrenProp with typingsJapgolly.reactMarkdown.reactMarkdownStrings.Not with js.Any because: IArray(Could't extract props from js.Any because couldn't resolve ClassTree.), Couldn't find props for typingsJapgolly.reactMarkdown.mod.SourceProp with typingsJapgolly.reactMarkdown.reactMarkdownStrings.Not with js.Any because: IArray(Could't extract props from js.Any because couldn't resolve ClassTree.)) */ +object ReactMarkdown { + + def apply(p: ReactMarkdownProps): Default[js.Object] = new Default[js.Object](js.Array(this.component, p.asInstanceOf[js.Any])) + + @JSImport("react-markdown", JSImport.Namespace) + @js.native + val component: js.Object = js.native + + implicit def make(companion: ReactMarkdown.type): Default[js.Object] = new Default[js.Object](js.Array(this.component, js.Dictionary.empty))() +} diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/mod.scala b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/mod.scala new file mode 100644 index 0000000000..f30e3799cc --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/mod.scala @@ -0,0 +1,148 @@ +package typingsJapgolly.reactMarkdown + +import japgolly.scalajs.react.raw.React.Element +import japgolly.scalajs.react.raw.React.ElementType +import japgolly.scalajs.react.raw.React.Node +import org.scalablytyped.runtime.StringDictionary +import org.scalablytyped.runtime.TopLevel +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object mod { + + @scala.inline + def apply(props: ReactMarkdownProps): Element = ^.asInstanceOf[js.Dynamic].apply(props.asInstanceOf[js.Any]).asInstanceOf[Element] + + @JSImport("react-markdown", JSImport.Namespace) + @js.native + val ^ : js.Any = js.native + + @JSImport("react-markdown", "renderers") + @js.native + val renderers: Renderers_ = js.native + + @scala.inline + def uriTransformer(uri: String): String = ^.asInstanceOf[js.Dynamic].applyDynamic("uriTransformer")(uri.asInstanceOf[js.Any]).asInstanceOf[String] + + @js.native + trait ChildrenProp extends StObject { + + val children: String = js.native + } + object ChildrenProp { + + @scala.inline + def apply(children: String): ChildrenProp = { + val __obj = js.Dynamic.literal(children = children.asInstanceOf[js.Any]) + __obj.asInstanceOf[ChildrenProp] + } + + @scala.inline + implicit class ChildrenPropMutableBuilder[Self <: ChildrenProp] (val x: Self) extends AnyVal { + + @scala.inline + def setChildren(value: String): Self = StObject.set(x, "children", value.asInstanceOf[js.Any]) + } + } + + type LinkTargetResolver = js.Function3[/* uri */ String, /* text */ String, /* title */ js.UndefOr[String], String] + + type MutuallyExclusive[T, U] = (T with Not[U]) | (U with Not[T]) + + type Not[T] = /* import warning: importer.ImportType#apply c Unsupported type mapping: + {[ key in keyof T ]:? never} + */ typingsJapgolly.reactMarkdown.reactMarkdownStrings.Not with TopLevel[js.Any] + + type ReactMarkdownProps = ReactMarkdownPropsBase with (MutuallyExclusive[ChildrenProp, SourceProp]) + + @js.native + trait ReactMarkdownPropsBase extends StObject { + + val allowNode: js.UndefOr[js.Function1[/* index */ Double, Boolean]] = js.native + + val className: js.UndefOr[String] = js.native + + val linkTarget: js.UndefOr[String | LinkTargetResolver] = js.native + + val transformLinkUri: js.UndefOr[ + (js.Function3[ + /* uri */ String, + /* children */ js.UndefOr[Node], + /* title */ js.UndefOr[String], + String + ]) | Null + ] = js.native + } + object ReactMarkdownPropsBase { + + @scala.inline + def apply(): ReactMarkdownPropsBase = { + val __obj = js.Dynamic.literal() + __obj.asInstanceOf[ReactMarkdownPropsBase] + } + + @scala.inline + implicit class ReactMarkdownPropsBaseMutableBuilder[Self <: ReactMarkdownPropsBase] (val x: Self) extends AnyVal { + + @scala.inline + def setAllowNode(value: /* index */ Double => Boolean): Self = StObject.set(x, "allowNode", js.Any.fromFunction1(value)) + + @scala.inline + def setAllowNodeUndefined: Self = StObject.set(x, "allowNode", js.undefined) + + @scala.inline + def setClassName(value: String): Self = StObject.set(x, "className", value.asInstanceOf[js.Any]) + + @scala.inline + def setClassNameUndefined: Self = StObject.set(x, "className", js.undefined) + + @scala.inline + def setLinkTarget(value: String | LinkTargetResolver): Self = StObject.set(x, "linkTarget", value.asInstanceOf[js.Any]) + + @scala.inline + def setLinkTargetFunction3(value: (/* uri */ String, /* text */ String, /* title */ js.UndefOr[String]) => String): Self = StObject.set(x, "linkTarget", js.Any.fromFunction3(value)) + + @scala.inline + def setLinkTargetUndefined: Self = StObject.set(x, "linkTarget", js.undefined) + + @scala.inline + def setTransformLinkUri( + value: (/* uri */ String, /* children */ js.UndefOr[Node], /* title */ js.UndefOr[String]) => String + ): Self = StObject.set(x, "transformLinkUri", js.Any.fromFunction3(value)) + + @scala.inline + def setTransformLinkUriNull: Self = StObject.set(x, "transformLinkUri", null) + + @scala.inline + def setTransformLinkUriUndefined: Self = StObject.set(x, "transformLinkUri", js.undefined) + } + } + + type Renderer[T] = js.Function1[/* props */ T, ElementType] + + type Renderers_ = StringDictionary[String | Renderer[js.Any]] + + @js.native + trait SourceProp extends StObject { + + /** @deprecated use children */ + val source: String = js.native + } + object SourceProp { + + @scala.inline + def apply(source: String): SourceProp = { + val __obj = js.Dynamic.literal(source = source.asInstanceOf[js.Any]) + __obj.asInstanceOf[SourceProp] + } + + @scala.inline + implicit class SourcePropMutableBuilder[Self <: SourceProp] (val x: Self) extends AnyVal { + + @scala.inline + def setSource(value: String): Self = StObject.set(x, "source", value.asInstanceOf[js.Any]) + } + } +} diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownRequire.scala b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownRequire.scala new file mode 100644 index 0000000000..80658ffe02 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownRequire.scala @@ -0,0 +1,12 @@ +package typingsJapgolly.reactMarkdown + +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +/* This can be used to `require` the library as a side effect. + If it is a global library this will make scalajs-bundler include it */ +@JSImport("react-markdown", JSImport.Namespace) +@js.native +object reactMarkdownRequire extends StObject diff --git a/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownStrings.scala b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownStrings.scala new file mode 100644 index 0000000000..928ec3d556 --- /dev/null +++ b/tests/react-integration-test/check-japgolly/r/react-markdown/src/main/scala/typingsJapgolly/reactMarkdown/reactMarkdownStrings.scala @@ -0,0 +1,14 @@ +package typingsJapgolly.reactMarkdown + +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object reactMarkdownStrings { + + @js.native + sealed trait Not extends StObject + @scala.inline + def Not: Not = "Not".asInstanceOf[Not] +} diff --git a/tests/react-integration-test/check-slinky/r/react-dropzone/build.sbt b/tests/react-integration-test/check-slinky/r/react-dropzone/build.sbt index b6bbb8e8d6..3caa83da13 100644 --- a/tests/react-integration-test/check-slinky/r/react-dropzone/build.sbt +++ b/tests/react-integration-test/check-slinky/r/react-dropzone/build.sbt @@ -1,6 +1,6 @@ organization := "org.scalablytyped" name := "react-dropzone" -version := "10.1.10-d409e9" +version := "10.1.10-98fbfc" scalaVersion := "2.13.3" enablePlugins(ScalaJSPlugin) libraryDependencies ++= Seq( diff --git a/tests/react-integration-test/check-slinky/r/react-dropzone/src/main/scala/typingsSlinky/reactDropzone/components/ReactDropzone.scala b/tests/react-integration-test/check-slinky/r/react-dropzone/src/main/scala/typingsSlinky/reactDropzone/components/ReactDropzone.scala new file mode 100644 index 0000000000..65d732487f --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-dropzone/src/main/scala/typingsSlinky/reactDropzone/components/ReactDropzone.scala @@ -0,0 +1,109 @@ +package typingsSlinky.reactDropzone.components + +import org.scalajs.dom.raw.HTMLElement +import slinky.core.facade.ReactElement +import slinky.web.html.`*`.tag +import typingsSlinky.StBuildingComponent +import typingsSlinky.react.mod.DragEvent +import typingsSlinky.react.mod.RefAttributes +import typingsSlinky.reactDropzone.mod.DropEvent +import typingsSlinky.reactDropzone.mod.DropzoneProps +import typingsSlinky.reactDropzone.mod.DropzoneRef +import typingsSlinky.reactDropzone.mod.DropzoneState +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object ReactDropzone { + + @JSImport("react-dropzone", JSImport.Default) + @js.native + val component: js.Object = js.native + + @scala.inline + class Builder (val args: js.Array[js.Any]) + extends AnyVal + with StBuildingComponent[tag.type, DropzoneRef] { + + @scala.inline + def accept(value: String | js.Array[String]): this.type = set("accept", value.asInstanceOf[js.Any]) + + @scala.inline + def acceptVarargs(value: String*): this.type = set("accept", js.Array(value :_*)) + + @scala.inline + def children(value: /* state */ DropzoneState => ReactElement): this.type = set("children", js.Any.fromFunction1(value)) + + @scala.inline + def disabled(value: Boolean): this.type = set("disabled", value.asInstanceOf[js.Any]) + + @scala.inline + def getFilesFromEvent( + value: /* event */ DropEvent => /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify Promise> */ _ + ): this.type = set("getFilesFromEvent", js.Any.fromFunction1(value)) + + @scala.inline + def maxSize(value: Double): this.type = set("maxSize", value.asInstanceOf[js.Any]) + + @scala.inline + def minSize(value: Double): this.type = set("minSize", value.asInstanceOf[js.Any]) + + @scala.inline + def multiple(value: Boolean): this.type = set("multiple", value.asInstanceOf[js.Any]) + + @scala.inline + def noClick(value: Boolean): this.type = set("noClick", value.asInstanceOf[js.Any]) + + @scala.inline + def noDrag(value: Boolean): this.type = set("noDrag", value.asInstanceOf[js.Any]) + + @scala.inline + def noDragEventsBubbling(value: Boolean): this.type = set("noDragEventsBubbling", value.asInstanceOf[js.Any]) + + @scala.inline + def noKeyboard(value: Boolean): this.type = set("noKeyboard", value.asInstanceOf[js.Any]) + + @scala.inline + def onDragEnter(value: DragEvent[HTMLElement] => Unit): this.type = set("onDragEnter", js.Any.fromFunction1(value)) + + @scala.inline + def onDragLeave(value: DragEvent[HTMLElement] => Unit): this.type = set("onDragLeave", js.Any.fromFunction1(value)) + + @scala.inline + def onDragOver(value: DragEvent[HTMLElement] => Unit): this.type = set("onDragOver", js.Any.fromFunction1(value)) + + @scala.inline + def onDrop( + value: (/* acceptedFiles */ js.Array[ + /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify File */ _ + ], /* rejectedFiles */ js.Array[ + /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify File */ _ + ], /* event */ DropEvent) => Unit + ): this.type = set("onDrop", js.Any.fromFunction3(value)) + + @scala.inline + def onDropAccepted( + value: (/* files */ js.Array[ + /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify File */ _ + ], /* event */ DropEvent) => Unit + ): this.type = set("onDropAccepted", js.Any.fromFunction2(value)) + + @scala.inline + def onDropRejected( + value: (/* files */ js.Array[ + /* import warning: transforms.QualifyReferences#resolveTypeRef many Couldn't qualify File */ _ + ], /* event */ DropEvent) => Unit + ): this.type = set("onDropRejected", js.Any.fromFunction2(value)) + + @scala.inline + def onFileDialogCancel(value: () => Unit): this.type = set("onFileDialogCancel", js.Any.fromFunction0(value)) + + @scala.inline + def preventDropOnDocument(value: Boolean): this.type = set("preventDropOnDocument", value.asInstanceOf[js.Any]) + } + + implicit def make(companion: ReactDropzone.type): Builder = new Builder(js.Array(this.component, js.Dictionary.empty))() + + def withProps(p: DropzoneProps with RefAttributes[DropzoneRef]): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any])) +} diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/build.sbt b/tests/react-integration-test/check-slinky/r/react-markdown/build.sbt new file mode 100644 index 0000000000..39de86b765 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/build.sbt @@ -0,0 +1,15 @@ +organization := "org.scalablytyped" +name := "react-markdown" +version := "0.0-unknown-193ec3" +scalaVersion := "2.13.3" +enablePlugins(ScalaJSPlugin) +libraryDependencies ++= Seq( + "com.olvind" %%% "scalablytyped-runtime" % "2.4.0", + "me.shadaj" %%% "slinky-web" % "0.6.6", + "org.scalablytyped" %%% "react" % "16.9.2-46b1eb", + "org.scalablytyped" %%% "std" % "0.0-unknown-615776") +publishArtifact in packageDoc := false +scalacOptions ++= List("-encoding", "utf-8", "-feature", "-g:notailcalls", "-language:implicitConversions", "-language:higherKinds", "-language:existentials") +licenses += ("MIT", url("http://opensource.org/licenses/MIT")) +bintrayRepository := "ScalablyTyped" +resolvers += Resolver.bintrayRepo("oyvindberg", "ScalablyTyped") diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/project/build.properties b/tests/react-integration-test/check-slinky/r/react-markdown/project/build.properties new file mode 100644 index 0000000000..b80399a6ad --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.4.2 \ No newline at end of file diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/project/plugins.sbt b/tests/react-integration-test/check-slinky/r/react-markdown/project/plugins.sbt new file mode 100644 index 0000000000..fe7cc09e18 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/project/plugins.sbt @@ -0,0 +1,2 @@ +addSbtPlugin("org.scala-js" %% "sbt-scalajs" % "1.3.0") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/readme.md b/tests/react-integration-test/check-slinky/r/react-markdown/readme.md new file mode 100644 index 0000000000..07a10b6741 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/readme.md @@ -0,0 +1,15 @@ + +# Scala.js typings for react-markdown + + + + +## Note +This library has been generated from typescript code from first party type definitions. + +Provided with :purple_heart: from [ScalablyTyped](https://github.com/oyvindberg/ScalablyTyped) + +## Usage +See [the main readme](../../readme.md) for instructions. + + diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/components/ReactMarkdown.scala b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/components/ReactMarkdown.scala new file mode 100644 index 0000000000..2e19e11772 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/components/ReactMarkdown.scala @@ -0,0 +1,21 @@ +package typingsSlinky.reactMarkdown.components + +import slinky.web.html.`*`.tag +import typingsSlinky.StBuildingComponent.Default +import typingsSlinky.reactMarkdown.mod.ReactMarkdownProps +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +/* The props of this component has an unsupported shape. You can use `set` manually to use it, but with no compiler support :/ . Couldn't find props for typingsSlinky.reactMarkdown.mod.ReactMarkdownProps because: IArray(Couldn't find props for typingsSlinky.reactMarkdown.mod.ChildrenProp with typingsSlinky.reactMarkdown.reactMarkdownStrings.Not with js.Any because: IArray(Could't extract props from js.Any because couldn't resolve ClassTree.), Couldn't find props for typingsSlinky.reactMarkdown.mod.SourceProp with typingsSlinky.reactMarkdown.reactMarkdownStrings.Not with js.Any because: IArray(Could't extract props from js.Any because couldn't resolve ClassTree.)) */ +object ReactMarkdown { + + def apply(p: ReactMarkdownProps): Default[tag.type, js.Object] = new Default[tag.type, js.Object](js.Array(this.component, p.asInstanceOf[js.Any])) + + @JSImport("react-markdown", JSImport.Namespace) + @js.native + val component: js.Object = js.native + + implicit def make(companion: ReactMarkdown.type): Default[tag.type, js.Object] = new Default[tag.type, js.Object](js.Array(this.component, js.Dictionary.empty))() +} diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/mod.scala b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/mod.scala new file mode 100644 index 0000000000..15b05a508a --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/mod.scala @@ -0,0 +1,146 @@ +package typingsSlinky.reactMarkdown + +import org.scalablytyped.runtime.StringDictionary +import org.scalablytyped.runtime.TopLevel +import slinky.core.facade.ReactElement +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object mod { + + @scala.inline + def apply(props: ReactMarkdownProps): ReactElement = ^.asInstanceOf[js.Dynamic].apply(props.asInstanceOf[js.Any]).asInstanceOf[ReactElement] + + @JSImport("react-markdown", JSImport.Namespace) + @js.native + val ^ : js.Any = js.native + + @JSImport("react-markdown", "renderers") + @js.native + val renderers: Renderers_ = js.native + + @scala.inline + def uriTransformer(uri: String): String = ^.asInstanceOf[js.Dynamic].applyDynamic("uriTransformer")(uri.asInstanceOf[js.Any]).asInstanceOf[String] + + @js.native + trait ChildrenProp extends StObject { + + val children: String = js.native + } + object ChildrenProp { + + @scala.inline + def apply(children: String): ChildrenProp = { + val __obj = js.Dynamic.literal(children = children.asInstanceOf[js.Any]) + __obj.asInstanceOf[ChildrenProp] + } + + @scala.inline + implicit class ChildrenPropMutableBuilder[Self <: ChildrenProp] (val x: Self) extends AnyVal { + + @scala.inline + def setChildren(value: String): Self = StObject.set(x, "children", value.asInstanceOf[js.Any]) + } + } + + type LinkTargetResolver = js.Function3[/* uri */ String, /* text */ String, /* title */ js.UndefOr[String], String] + + type MutuallyExclusive[T, U] = (T with Not[U]) | (U with Not[T]) + + type Not[T] = /* import warning: importer.ImportType#apply c Unsupported type mapping: + {[ key in keyof T ]:? never} + */ typingsSlinky.reactMarkdown.reactMarkdownStrings.Not with TopLevel[js.Any] + + type ReactMarkdownProps = ReactMarkdownPropsBase with (MutuallyExclusive[ChildrenProp, SourceProp]) + + @js.native + trait ReactMarkdownPropsBase extends StObject { + + val allowNode: js.UndefOr[js.Function1[/* index */ Double, Boolean]] = js.native + + val className: js.UndefOr[String] = js.native + + val linkTarget: js.UndefOr[String | LinkTargetResolver] = js.native + + val transformLinkUri: js.UndefOr[ + (js.Function3[ + /* uri */ String, + /* children */ js.UndefOr[ReactElement], + /* title */ js.UndefOr[String], + String + ]) | Null + ] = js.native + } + object ReactMarkdownPropsBase { + + @scala.inline + def apply(): ReactMarkdownPropsBase = { + val __obj = js.Dynamic.literal() + __obj.asInstanceOf[ReactMarkdownPropsBase] + } + + @scala.inline + implicit class ReactMarkdownPropsBaseMutableBuilder[Self <: ReactMarkdownPropsBase] (val x: Self) extends AnyVal { + + @scala.inline + def setAllowNode(value: /* index */ Double => Boolean): Self = StObject.set(x, "allowNode", js.Any.fromFunction1(value)) + + @scala.inline + def setAllowNodeUndefined: Self = StObject.set(x, "allowNode", js.undefined) + + @scala.inline + def setClassName(value: String): Self = StObject.set(x, "className", value.asInstanceOf[js.Any]) + + @scala.inline + def setClassNameUndefined: Self = StObject.set(x, "className", js.undefined) + + @scala.inline + def setLinkTarget(value: String | LinkTargetResolver): Self = StObject.set(x, "linkTarget", value.asInstanceOf[js.Any]) + + @scala.inline + def setLinkTargetFunction3(value: (/* uri */ String, /* text */ String, /* title */ js.UndefOr[String]) => String): Self = StObject.set(x, "linkTarget", js.Any.fromFunction3(value)) + + @scala.inline + def setLinkTargetUndefined: Self = StObject.set(x, "linkTarget", js.undefined) + + @scala.inline + def setTransformLinkUri( + value: (/* uri */ String, /* children */ js.UndefOr[ReactElement], /* title */ js.UndefOr[String]) => String + ): Self = StObject.set(x, "transformLinkUri", js.Any.fromFunction3(value)) + + @scala.inline + def setTransformLinkUriNull: Self = StObject.set(x, "transformLinkUri", null) + + @scala.inline + def setTransformLinkUriUndefined: Self = StObject.set(x, "transformLinkUri", js.undefined) + } + } + + type Renderer[T] = js.Function1[/* props */ T, ReactElement] + + type Renderers_ = StringDictionary[String | Renderer[js.Any]] + + @js.native + trait SourceProp extends StObject { + + /** @deprecated use children */ + val source: String = js.native + } + object SourceProp { + + @scala.inline + def apply(source: String): SourceProp = { + val __obj = js.Dynamic.literal(source = source.asInstanceOf[js.Any]) + __obj.asInstanceOf[SourceProp] + } + + @scala.inline + implicit class SourcePropMutableBuilder[Self <: SourceProp] (val x: Self) extends AnyVal { + + @scala.inline + def setSource(value: String): Self = StObject.set(x, "source", value.asInstanceOf[js.Any]) + } + } +} diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownRequire.scala b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownRequire.scala new file mode 100644 index 0000000000..cc1baf91a1 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownRequire.scala @@ -0,0 +1,12 @@ +package typingsSlinky.reactMarkdown + +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +/* This can be used to `require` the library as a side effect. + If it is a global library this will make scalajs-bundler include it */ +@JSImport("react-markdown", JSImport.Namespace) +@js.native +object reactMarkdownRequire extends StObject diff --git a/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownStrings.scala b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownStrings.scala new file mode 100644 index 0000000000..4c12981241 --- /dev/null +++ b/tests/react-integration-test/check-slinky/r/react-markdown/src/main/scala/typingsSlinky/reactMarkdown/reactMarkdownStrings.scala @@ -0,0 +1,14 @@ +package typingsSlinky.reactMarkdown + +import org.scalablytyped.runtime.StObject +import scala.scalajs.js +import scala.scalajs.js.`|` +import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, JSBracketAccess} + +object reactMarkdownStrings { + + @js.native + sealed trait Not extends StObject + @scala.inline + def Not: Not = "Not".asInstanceOf[Not] +} diff --git a/tests/react-integration-test/in/react-markdown/index.d.ts b/tests/react-integration-test/in/react-markdown/index.d.ts new file mode 100644 index 0000000000..27a5cbdfed --- /dev/null +++ b/tests/react-integration-test/in/react-markdown/index.d.ts @@ -0,0 +1,45 @@ +import {ElementType, ReactNode, ReactElement} from 'react' + +type Not = { + [key in keyof T]?: never +} + +type MutuallyExclusive = (T & Not) | (U & Not) + +declare namespace ReactMarkdown { + type LinkTargetResolver = (uri: string, text: string, title?: string) => string + + type Renderer = (props: T) => ElementType + interface Renderers { + [key: string]: string | Renderer + } + + interface ReactMarkdownPropsBase { + readonly className?: string + readonly allowNode?: (index: number) => boolean + readonly linkTarget?: string | LinkTargetResolver + readonly transformLinkUri?: + | ((uri: string, children?: ReactNode, title?: string) => string) + | null + } + + interface SourceProp { + /** @deprecated use children */ + readonly source: string + } + + interface ChildrenProp { + readonly children: string + } + + + type ReactMarkdownProps = ReactMarkdownPropsBase & + MutuallyExclusive + + const renderers: Renderers + function uriTransformer(uri: string): string +} + +declare function ReactMarkdown(props: ReactMarkdown.ReactMarkdownProps): ReactElement + +export = ReactMarkdown