form.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package vuetify
  2. import (
  3. "context"
  4. "fmt"
  5. h "github.com/theplant/htmlgo"
  6. )
  7. type VFormBuilder struct {
  8. tag *h.HTMLTagBuilder
  9. }
  10. func VForm(children ...h.HTMLComponent) (r *VFormBuilder) {
  11. r = &VFormBuilder{
  12. tag: h.Tag("v-form").Children(children...),
  13. }
  14. return
  15. }
  16. func (b *VFormBuilder) Disabled(v bool) (r *VFormBuilder) {
  17. b.tag.Attr(":disabled", fmt.Sprint(v))
  18. return b
  19. }
  20. func (b *VFormBuilder) LazyValidation(v bool) (r *VFormBuilder) {
  21. b.tag.Attr(":lazy-validation", fmt.Sprint(v))
  22. return b
  23. }
  24. func (b *VFormBuilder) Readonly(v bool) (r *VFormBuilder) {
  25. b.tag.Attr(":readonly", fmt.Sprint(v))
  26. return b
  27. }
  28. func (b *VFormBuilder) Value(v bool) (r *VFormBuilder) {
  29. b.tag.Attr(":value", fmt.Sprint(v))
  30. return b
  31. }
  32. func (b *VFormBuilder) SetAttr(k string, v interface{}) {
  33. b.tag.SetAttr(k, v)
  34. }
  35. func (b *VFormBuilder) Attr(vs ...interface{}) (r *VFormBuilder) {
  36. b.tag.Attr(vs...)
  37. return b
  38. }
  39. func (b *VFormBuilder) Children(children ...h.HTMLComponent) (r *VFormBuilder) {
  40. b.tag.Children(children...)
  41. return b
  42. }
  43. func (b *VFormBuilder) AppendChildren(children ...h.HTMLComponent) (r *VFormBuilder) {
  44. b.tag.AppendChildren(children...)
  45. return b
  46. }
  47. func (b *VFormBuilder) PrependChildren(children ...h.HTMLComponent) (r *VFormBuilder) {
  48. b.tag.PrependChildren(children...)
  49. return b
  50. }
  51. func (b *VFormBuilder) Class(names ...string) (r *VFormBuilder) {
  52. b.tag.Class(names...)
  53. return b
  54. }
  55. func (b *VFormBuilder) ClassIf(name string, add bool) (r *VFormBuilder) {
  56. b.tag.ClassIf(name, add)
  57. return b
  58. }
  59. func (b *VFormBuilder) On(name string, value string) (r *VFormBuilder) {
  60. b.tag.Attr(fmt.Sprintf("v-on:%s", name), value)
  61. return b
  62. }
  63. func (b *VFormBuilder) Bind(name string, value string) (r *VFormBuilder) {
  64. b.tag.Attr(fmt.Sprintf("v-bind:%s", name), value)
  65. return b
  66. }
  67. func (b *VFormBuilder) MarshalHTML(ctx context.Context) (r []byte, err error) {
  68. return b.tag.MarshalHTML(ctx)
  69. }