input.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. package vuetify
  2. import (
  3. "context"
  4. "fmt"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VInputBuilder struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VInput(children ...h.HTMLComponent) (r *VInputBuilder) {
  11. r = &VInputBuilder{
  12. tag: h.Tag("v-input").Children(children...),
  13. }
  14. return
  15. }
  16. func (b *VInputBuilder) AppendIcon(v string) (r *VInputBuilder) {
  17. b.tag.Attr("append-icon", v)
  18. return b
  19. }
  20. func (b *VInputBuilder) BackgroundColor(v string) (r *VInputBuilder) {
  21. b.tag.Attr("background-color", v)
  22. return b
  23. }
  24. func (b *VInputBuilder) Color(v string) (r *VInputBuilder) {
  25. b.tag.Attr("color", v)
  26. return b
  27. }
  28. func (b *VInputBuilder) Dark(v bool) (r *VInputBuilder) {
  29. b.tag.Attr(":dark", fmt.Sprint(v))
  30. return b
  31. }
  32. func (b *VInputBuilder) Dense(v bool) (r *VInputBuilder) {
  33. b.tag.Attr(":dense", fmt.Sprint(v))
  34. return b
  35. }
  36. func (b *VInputBuilder) Disabled(v bool) (r *VInputBuilder) {
  37. b.tag.Attr(":disabled", fmt.Sprint(v))
  38. return b
  39. }
  40. func (b *VInputBuilder) Error(v bool) (r *VInputBuilder) {
  41. b.tag.Attr(":error", fmt.Sprint(v))
  42. return b
  43. }
  44. func (b *VInputBuilder) ErrorCount(v int) (r *VInputBuilder) {
  45. b.tag.Attr(":error-count", fmt.Sprint(v))
  46. return b
  47. }
  48. func (b *VInputBuilder) ErrorMessages(v string) (r *VInputBuilder) {
  49. b.tag.Attr("error-messages", v)
  50. return b
  51. }
  52. func (b *VInputBuilder) Height(v int) (r *VInputBuilder) {
  53. b.tag.Attr(":height", fmt.Sprint(v))
  54. return b
  55. }
  56. func (b *VInputBuilder) HideDetails(v bool) (r *VInputBuilder) {
  57. b.tag.Attr(":hide-details", fmt.Sprint(v))
  58. return b
  59. }
  60. func (b *VInputBuilder) Hint(v string) (r *VInputBuilder) {
  61. b.tag.Attr("hint", v)
  62. return b
  63. }
  64. func (b *VInputBuilder) Id(v string) (r *VInputBuilder) {
  65. b.tag.Attr("id", v)
  66. return b
  67. }
  68. func (b *VInputBuilder) Label(v string) (r *VInputBuilder) {
  69. b.tag.Attr("label", v)
  70. return b
  71. }
  72. func (b *VInputBuilder) Light(v bool) (r *VInputBuilder) {
  73. b.tag.Attr(":light", fmt.Sprint(v))
  74. return b
  75. }
  76. func (b *VInputBuilder) Loading(v bool) (r *VInputBuilder) {
  77. b.tag.Attr(":loading", fmt.Sprint(v))
  78. return b
  79. }
  80. func (b *VInputBuilder) Messages(v string) (r *VInputBuilder) {
  81. b.tag.Attr("messages", v)
  82. return b
  83. }
  84. func (b *VInputBuilder) PersistentHint(v bool) (r *VInputBuilder) {
  85. b.tag.Attr(":persistent-hint", fmt.Sprint(v))
  86. return b
  87. }
  88. func (b *VInputBuilder) PrependIcon(v string) (r *VInputBuilder) {
  89. b.tag.Attr("prepend-icon", v)
  90. return b
  91. }
  92. func (b *VInputBuilder) Readonly(v bool) (r *VInputBuilder) {
  93. b.tag.Attr(":readonly", fmt.Sprint(v))
  94. return b
  95. }
  96. func (b *VInputBuilder) Rules(v interface{}) (r *VInputBuilder) {
  97. b.tag.Attr(":rules", h.JSONString(v))
  98. return b
  99. }
  100. func (b *VInputBuilder) Success(v bool) (r *VInputBuilder) {
  101. b.tag.Attr(":success", fmt.Sprint(v))
  102. return b
  103. }
  104. func (b *VInputBuilder) SuccessMessages(v string) (r *VInputBuilder) {
  105. b.tag.Attr("success-messages", v)
  106. return b
  107. }
  108. func (b *VInputBuilder) ValidateOnBlur(v bool) (r *VInputBuilder) {
  109. b.tag.Attr(":validate-on-blur", fmt.Sprint(v))
  110. return b
  111. }
  112. func (b *VInputBuilder) Value(v interface{}) (r *VInputBuilder) {
  113. b.tag.Attr(":value", h.JSONString(v))
  114. return b
  115. }
  116. func (b *VInputBuilder) SetAttr(k string, v interface{}) {
  117. b.tag.SetAttr(k, v)
  118. }
  119. func (b *VInputBuilder) Attr(vs ...interface{}) (r *VInputBuilder) {
  120. b.tag.Attr(vs...)
  121. return b
  122. }
  123. func (b *VInputBuilder) Children(children ...h.HTMLComponent) (r *VInputBuilder) {
  124. b.tag.Children(children...)
  125. return b
  126. }
  127. func (b *VInputBuilder) AppendChildren(children ...h.HTMLComponent) (r *VInputBuilder) {
  128. b.tag.AppendChildren(children...)
  129. return b
  130. }
  131. func (b *VInputBuilder) PrependChildren(children ...h.HTMLComponent) (r *VInputBuilder) {
  132. b.tag.PrependChildren(children...)
  133. return b
  134. }
  135. func (b *VInputBuilder) Class(names ...string) (r *VInputBuilder) {
  136. b.tag.Class(names...)
  137. return b
  138. }
  139. func (b *VInputBuilder) ClassIf(name string, add bool) (r *VInputBuilder) {
  140. b.tag.ClassIf(name, add)
  141. return b
  142. }
  143. func (b *VInputBuilder) On(name string, value string) (r *VInputBuilder) {
  144. b.tag.Attr(fmt.Sprintf("v-on:%s", name), value)
  145. return b
  146. }
  147. func (b *VInputBuilder) Bind(name string, value string) (r *VInputBuilder) {
  148. b.tag.Attr(fmt.Sprintf("v-bind:%s", name), value)
  149. return b
  150. }
  151. func (b *VInputBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  152. return b.tag.MarshalHTML(ctx)
  153. }