|
| 1 | +package react.semanticui.addons.textarea |
| 2 | + |
| 3 | +import scala.scalajs.js |
| 4 | +import js.annotation._ |
| 5 | +import js.| |
| 6 | +import japgolly.scalajs.react._ |
| 7 | +import japgolly.scalajs.react.raw.JsNumber |
| 8 | +import react.common._ |
| 9 | +import react.semanticui._ |
| 10 | +import japgolly.scalajs.react.vdom.TagMod |
| 11 | +import react.semanticui.collections.form.Form |
| 12 | + |
| 13 | +final case class TextArea( |
| 14 | + as: js.UndefOr[AsC] = js.undefined, |
| 15 | + onChangeE: js.UndefOr[TextArea.Event] = js.undefined, |
| 16 | + onChange: js.UndefOr[Callback] = js.undefined, |
| 17 | + onInputE: js.UndefOr[TextArea.Event] = js.undefined, |
| 18 | + onInput: js.UndefOr[Callback] = js.undefined, |
| 19 | + rows: js.UndefOr[Int | String] = js.undefined, |
| 20 | + value: js.UndefOr[String | JsNumber] = js.undefined, |
| 21 | + override val modifiers: Seq[TagMod] = Seq.empty |
| 22 | +) extends GenericComponentPA[TextArea.TextAreaProps, TextArea] { |
| 23 | + override protected def cprops = TextArea.props(this) |
| 24 | + override protected val component = TextArea.component |
| 25 | + override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers) |
| 26 | +} |
| 27 | + |
| 28 | +object TextArea { |
| 29 | + type Event = (Form.ReactFormEvent, TextAreaProps) => Callback |
| 30 | + type RawEvent = js.Function2[Form.ReactFormEvent, TextAreaProps, Unit] |
| 31 | + |
| 32 | + @js.native |
| 33 | + @JSImport("semantic-ui-react", "TextArea") |
| 34 | + object RawComponent extends js.Object |
| 35 | + |
| 36 | + @js.native |
| 37 | + trait TextAreaProps extends js.Object { |
| 38 | + @JSBracketAccess |
| 39 | + def apply(key: String): js.Any = js.native |
| 40 | + |
| 41 | + @JSBracketAccess |
| 42 | + def update(key: String, v: js.Any): Unit = js.native |
| 43 | + |
| 44 | + /** An element type to render as (string or function). */ |
| 45 | + var as: js.UndefOr[AsT] = js.native |
| 46 | + |
| 47 | + /** |
| 48 | + * Called on change. |
| 49 | + * |
| 50 | + * @param {SyntheticEvent} event - The React SyntheticEvent object |
| 51 | + * @param {object} data - All props and the event value. |
| 52 | + */ |
| 53 | + var onChange: js.UndefOr[RawEvent] = js.undefined |
| 54 | + |
| 55 | + /** |
| 56 | + * Called on input. |
| 57 | + * |
| 58 | + * @param {SyntheticEvent} event - The React SyntheticEvent object |
| 59 | + * @param {object} data - All props and the event value. |
| 60 | + */ |
| 61 | + var onInput: js.UndefOr[RawEvent] = js.undefined |
| 62 | + |
| 63 | + /** Indicates row count for a TextArea. */ |
| 64 | + var rows: js.UndefOr[JsNumber | String] = js.undefined |
| 65 | + |
| 66 | + /** The value of the textarea. */ |
| 67 | + var value: js.UndefOr[JsNumber | String] = js.undefined |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | + def props(q: TextArea): TextAreaProps = |
| 72 | + rawprops( |
| 73 | + q.as, |
| 74 | + q.onChangeE, |
| 75 | + q.onChange, |
| 76 | + q.onInputE, |
| 77 | + q.onInput, |
| 78 | + q.rows, |
| 79 | + q.value |
| 80 | + ) |
| 81 | + |
| 82 | + def rawprops( |
| 83 | + as: js.UndefOr[AsC] = js.undefined, |
| 84 | + onChangeE: js.UndefOr[TextArea.Event] = js.undefined, |
| 85 | + onChange: js.UndefOr[Callback] = js.undefined, |
| 86 | + onInputE: js.UndefOr[TextArea.Event] = js.undefined, |
| 87 | + onInput: js.UndefOr[Callback] = js.undefined, |
| 88 | + rows: js.UndefOr[Int | String] = js.undefined, |
| 89 | + value: js.UndefOr[String | JsNumber] = js.undefined |
| 90 | + ): TextAreaProps = { |
| 91 | + val p = as.toJsObject[TextAreaProps] |
| 92 | + as.toJs.foreach(v => p.as = v) |
| 93 | + (onChangeE, onChange).toJs.foreach(v => p.onChange = v) |
| 94 | + (onInputE, onInput).toJs.foreach(v => p.onInput = v) |
| 95 | + rows.foreach(v => p.rows = v) |
| 96 | + value.foreach(v => p.value = v) |
| 97 | + p |
| 98 | + } |
| 99 | + |
| 100 | + private val component = |
| 101 | + JsComponent[TextAreaProps, Children.None, Null](RawComponent) |
| 102 | + |
| 103 | + val Default: TextArea = TextArea() |
| 104 | + |
| 105 | + val defaultProps: TextAreaProps = props(Default) |
| 106 | + |
| 107 | + def apply(modifiers: TagMod*): TextArea = |
| 108 | + new TextArea(modifiers = modifiers) |
| 109 | +} |
0 commit comments