checkbox.go 5.3 KB

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