data-table.go 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. package vuetify
  2. import (
  3. "context"
  4. "fmt"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VDataTableBuilder struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VDataTable(children ...h.HTMLComponent) (r *VDataTableBuilder) {
  11. r = &VDataTableBuilder{
  12. tag: h.Tag("v-data-table").Children(children...),
  13. }
  14. return
  15. }
  16. func (b *VDataTableBuilder) CalculateWidths(v bool) (r *VDataTableBuilder) {
  17. b.tag.Attr(":calculate-widths", fmt.Sprint(v))
  18. return b
  19. }
  20. func (b *VDataTableBuilder) Caption(v string) (r *VDataTableBuilder) {
  21. b.tag.Attr("caption", v)
  22. return b
  23. }
  24. func (b *VDataTableBuilder) CheckboxColor(v string) (r *VDataTableBuilder) {
  25. b.tag.Attr("checkbox-color", v)
  26. return b
  27. }
  28. func (b *VDataTableBuilder) CustomFilter(v interface{}) (r *VDataTableBuilder) {
  29. b.tag.Attr(":custom-filter", h.JSONString(v))
  30. return b
  31. }
  32. func (b *VDataTableBuilder) CustomGroup(v interface{}) (r *VDataTableBuilder) {
  33. b.tag.Attr(":custom-group", h.JSONString(v))
  34. return b
  35. }
  36. func (b *VDataTableBuilder) CustomSort(v interface{}) (r *VDataTableBuilder) {
  37. b.tag.Attr(":custom-sort", h.JSONString(v))
  38. return b
  39. }
  40. func (b *VDataTableBuilder) Dark(v bool) (r *VDataTableBuilder) {
  41. b.tag.Attr(":dark", fmt.Sprint(v))
  42. return b
  43. }
  44. func (b *VDataTableBuilder) Dense(v bool) (r *VDataTableBuilder) {
  45. b.tag.Attr(":dense", fmt.Sprint(v))
  46. return b
  47. }
  48. func (b *VDataTableBuilder) DisableFiltering(v bool) (r *VDataTableBuilder) {
  49. b.tag.Attr(":disable-filtering", fmt.Sprint(v))
  50. return b
  51. }
  52. func (b *VDataTableBuilder) DisablePagination(v bool) (r *VDataTableBuilder) {
  53. b.tag.Attr(":disable-pagination", fmt.Sprint(v))
  54. return b
  55. }
  56. func (b *VDataTableBuilder) DisableSort(v bool) (r *VDataTableBuilder) {
  57. b.tag.Attr(":disable-sort", fmt.Sprint(v))
  58. return b
  59. }
  60. func (b *VDataTableBuilder) ExpandIcon(v string) (r *VDataTableBuilder) {
  61. b.tag.Attr("expand-icon", v)
  62. return b
  63. }
  64. func (b *VDataTableBuilder) Expanded(v interface{}) (r *VDataTableBuilder) {
  65. b.tag.Attr(":expanded", h.JSONString(v))
  66. return b
  67. }
  68. func (b *VDataTableBuilder) FixedHeader(v bool) (r *VDataTableBuilder) {
  69. b.tag.Attr(":fixed-header", fmt.Sprint(v))
  70. return b
  71. }
  72. func (b *VDataTableBuilder) FooterProps(v interface{}) (r *VDataTableBuilder) {
  73. b.tag.Attr(":footer-props", h.JSONString(v))
  74. return b
  75. }
  76. func (b *VDataTableBuilder) GroupBy(v string) (r *VDataTableBuilder) {
  77. b.tag.Attr("group-by", v)
  78. return b
  79. }
  80. func (b *VDataTableBuilder) GroupDesc(v bool) (r *VDataTableBuilder) {
  81. b.tag.Attr(":group-desc", fmt.Sprint(v))
  82. return b
  83. }
  84. func (b *VDataTableBuilder) HeaderProps(v interface{}) (r *VDataTableBuilder) {
  85. b.tag.Attr(":header-props", h.JSONString(v))
  86. return b
  87. }
  88. func (b *VDataTableBuilder) Headers(v interface{}) (r *VDataTableBuilder) {
  89. b.tag.Attr(":headers", h.JSONString(v))
  90. return b
  91. }
  92. func (b *VDataTableBuilder) HeadersLength(v int) (r *VDataTableBuilder) {
  93. b.tag.Attr(":headers-length", fmt.Sprint(v))
  94. return b
  95. }
  96. func (b *VDataTableBuilder) Height(v int) (r *VDataTableBuilder) {
  97. b.tag.Attr(":height", fmt.Sprint(v))
  98. return b
  99. }
  100. func (b *VDataTableBuilder) HideDefaultFooter(v bool) (r *VDataTableBuilder) {
  101. b.tag.Attr(":hide-default-footer", fmt.Sprint(v))
  102. return b
  103. }
  104. func (b *VDataTableBuilder) HideDefaultHeader(v bool) (r *VDataTableBuilder) {
  105. b.tag.Attr(":hide-default-header", fmt.Sprint(v))
  106. return b
  107. }
  108. func (b *VDataTableBuilder) ItemClass(v string) (r *VDataTableBuilder) {
  109. b.tag.Attr("item-class", v)
  110. return b
  111. }
  112. func (b *VDataTableBuilder) ItemKey(v string) (r *VDataTableBuilder) {
  113. b.tag.Attr("item-key", v)
  114. return b
  115. }
  116. func (b *VDataTableBuilder) Items(v interface{}) (r *VDataTableBuilder) {
  117. b.tag.Attr(":items", h.JSONString(v))
  118. return b
  119. }
  120. func (b *VDataTableBuilder) ItemsPerPage(v int) (r *VDataTableBuilder) {
  121. b.tag.Attr(":items-per-page", fmt.Sprint(v))
  122. return b
  123. }
  124. func (b *VDataTableBuilder) Light(v bool) (r *VDataTableBuilder) {
  125. b.tag.Attr(":light", fmt.Sprint(v))
  126. return b
  127. }
  128. func (b *VDataTableBuilder) LoaderHeight(v int) (r *VDataTableBuilder) {
  129. b.tag.Attr(":loader-height", fmt.Sprint(v))
  130. return b
  131. }
  132. func (b *VDataTableBuilder) Loading(v bool) (r *VDataTableBuilder) {
  133. b.tag.Attr(":loading", fmt.Sprint(v))
  134. return b
  135. }
  136. func (b *VDataTableBuilder) LoadingText(v string) (r *VDataTableBuilder) {
  137. b.tag.Attr("loading-text", v)
  138. return b
  139. }
  140. func (b *VDataTableBuilder) Locale(v string) (r *VDataTableBuilder) {
  141. b.tag.Attr("locale", v)
  142. return b
  143. }
  144. func (b *VDataTableBuilder) MobileBreakpoint(v int) (r *VDataTableBuilder) {
  145. b.tag.Attr(":mobile-breakpoint", fmt.Sprint(v))
  146. return b
  147. }
  148. func (b *VDataTableBuilder) MultiSort(v bool) (r *VDataTableBuilder) {
  149. b.tag.Attr(":multi-sort", fmt.Sprint(v))
  150. return b
  151. }
  152. func (b *VDataTableBuilder) MustSort(v bool) (r *VDataTableBuilder) {
  153. b.tag.Attr(":must-sort", fmt.Sprint(v))
  154. return b
  155. }
  156. func (b *VDataTableBuilder) NoDataText(v string) (r *VDataTableBuilder) {
  157. b.tag.Attr("no-data-text", v)
  158. return b
  159. }
  160. func (b *VDataTableBuilder) NoResultsText(v string) (r *VDataTableBuilder) {
  161. b.tag.Attr("no-results-text", v)
  162. return b
  163. }
  164. func (b *VDataTableBuilder) Options(v interface{}) (r *VDataTableBuilder) {
  165. b.tag.Attr(":options", h.JSONString(v))
  166. return b
  167. }
  168. func (b *VDataTableBuilder) Page(v int) (r *VDataTableBuilder) {
  169. b.tag.Attr(":page", fmt.Sprint(v))
  170. return b
  171. }
  172. func (b *VDataTableBuilder) Search(v string) (r *VDataTableBuilder) {
  173. b.tag.Attr("search", v)
  174. return b
  175. }
  176. func (b *VDataTableBuilder) SelectableKey(v string) (r *VDataTableBuilder) {
  177. b.tag.Attr("selectable-key", v)
  178. return b
  179. }
  180. func (b *VDataTableBuilder) ServerItemsLength(v int) (r *VDataTableBuilder) {
  181. b.tag.Attr(":server-items-length", fmt.Sprint(v))
  182. return b
  183. }
  184. func (b *VDataTableBuilder) ShowExpand(v bool) (r *VDataTableBuilder) {
  185. b.tag.Attr(":show-expand", fmt.Sprint(v))
  186. return b
  187. }
  188. func (b *VDataTableBuilder) ShowGroupBy(v bool) (r *VDataTableBuilder) {
  189. b.tag.Attr(":show-group-by", fmt.Sprint(v))
  190. return b
  191. }
  192. func (b *VDataTableBuilder) ShowSelect(v bool) (r *VDataTableBuilder) {
  193. b.tag.Attr(":show-select", fmt.Sprint(v))
  194. return b
  195. }
  196. func (b *VDataTableBuilder) SingleExpand(v bool) (r *VDataTableBuilder) {
  197. b.tag.Attr(":single-expand", fmt.Sprint(v))
  198. return b
  199. }
  200. func (b *VDataTableBuilder) SingleSelect(v bool) (r *VDataTableBuilder) {
  201. b.tag.Attr(":single-select", fmt.Sprint(v))
  202. return b
  203. }
  204. func (b *VDataTableBuilder) SortBy(v string) (r *VDataTableBuilder) {
  205. b.tag.Attr("sort-by", v)
  206. return b
  207. }
  208. func (b *VDataTableBuilder) SortDesc(v bool) (r *VDataTableBuilder) {
  209. b.tag.Attr(":sort-desc", fmt.Sprint(v))
  210. return b
  211. }
  212. func (b *VDataTableBuilder) Value(v interface{}) (r *VDataTableBuilder) {
  213. b.tag.Attr(":value", h.JSONString(v))
  214. return b
  215. }
  216. func (b *VDataTableBuilder) SetAttr(k string, v interface{}) {
  217. b.tag.SetAttr(k, v)
  218. }
  219. func (b *VDataTableBuilder) Attr(vs ...interface{}) (r *VDataTableBuilder) {
  220. b.tag.Attr(vs...)
  221. return b
  222. }
  223. func (b *VDataTableBuilder) Children(children ...h.HTMLComponent) (r *VDataTableBuilder) {
  224. b.tag.Children(children...)
  225. return b
  226. }
  227. func (b *VDataTableBuilder) AppendChildren(children ...h.HTMLComponent) (r *VDataTableBuilder) {
  228. b.tag.AppendChildren(children...)
  229. return b
  230. }
  231. func (b *VDataTableBuilder) PrependChildren(children ...h.HTMLComponent) (r *VDataTableBuilder) {
  232. b.tag.PrependChildren(children...)
  233. return b
  234. }
  235. func (b *VDataTableBuilder) Class(names ...string) (r *VDataTableBuilder) {
  236. b.tag.Class(names...)
  237. return b
  238. }
  239. func (b *VDataTableBuilder) ClassIf(name string, add bool) (r *VDataTableBuilder) {
  240. b.tag.ClassIf(name, add)
  241. return b
  242. }
  243. func (b *VDataTableBuilder) On(name string, value string) (r *VDataTableBuilder) {
  244. b.tag.Attr(fmt.Sprintf("v-on:%s", name), value)
  245. return b
  246. }
  247. func (b *VDataTableBuilder) Bind(name string, value string) (r *VDataTableBuilder) {
  248. b.tag.Attr(fmt.Sprintf("v-bind:%s", name), value)
  249. return b
  250. }
  251. func (b *VDataTableBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  252. return b.tag.MarshalHTML(ctx)
  253. }