Rework value and list binder
- Rename FieldBinder to ValueBinder - Split ValueBinder interface into ValueGetter, ValueSetter and HTMLInputTyper - Add non pointer types to ValueBindAny.StringValue - Move encoding.TextMarshaler in type switch - Simplify ListBinder, and reuse ValueBinder logic - Add ListBindGenericValues type
This commit is contained in:
parent
a60a1f4af7
commit
a587fea398
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -7,6 +7,7 @@
|
||||
"ldflags",
|
||||
"Segoe",
|
||||
"simplehttp",
|
||||
"Typer",
|
||||
"vgrouter",
|
||||
"Vogel",
|
||||
"vugu",
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
type Dropdown struct {
|
||||
AttrMap vugu.AttrMap
|
||||
|
||||
Bind FieldBinder // Binds the current selected key to some variable.
|
||||
Bind ValueBinder // Binds the current selected key to some variable.
|
||||
BindList ListBinder // Binds the list content to some list provider.
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ func (c *Dropdown) currentKey() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return c.Bind.String()
|
||||
return c.Bind.StringValue()
|
||||
}
|
||||
|
||||
func (c *Dropdown) isKeySelected(key string) bool {
|
||||
@ -25,7 +25,7 @@ func (c *Dropdown) isKeySelected(key string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return key == c.Bind.String()
|
||||
return key == c.Bind.StringValue()
|
||||
}
|
||||
|
||||
func (c *Dropdown) keyValuePairs() []ListKeyValuePair {
|
||||
@ -42,5 +42,5 @@ func (c *Dropdown) handleChange(event vugu.DOMEvent) {
|
||||
}
|
||||
|
||||
val := event.PropString("target", "value")
|
||||
c.Bind.SetString(val)
|
||||
c.Bind.SetStringValue(val)
|
||||
}
|
||||
|
@ -10,7 +10,10 @@ type Field struct {
|
||||
AttrMap vugu.AttrMap
|
||||
ID string // The ID of the internal input component.
|
||||
|
||||
Bind FieldBinder
|
||||
Bind interface {
|
||||
ValueBinder
|
||||
HTMLInputTyper
|
||||
}
|
||||
|
||||
DefaultSlot vugu.Builder
|
||||
|
||||
@ -21,7 +24,7 @@ type Field struct {
|
||||
|
||||
func (c *Field) content() string {
|
||||
if c.Bind != nil {
|
||||
return c.Bind.String()
|
||||
return c.Bind.StringValue()
|
||||
}
|
||||
|
||||
return ""
|
||||
@ -43,6 +46,6 @@ func (c *Field) handleChange(event vugu.DOMEvent) {
|
||||
val := event.PropString("target", "value")
|
||||
|
||||
if c.Bind != nil {
|
||||
c.err = c.Bind.SetString(val)
|
||||
c.err = c.Bind.SetStringValue(val)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@ -21,7 +20,8 @@ type ListKeyValuePair struct {
|
||||
}
|
||||
|
||||
// ListBindGenericSlice implements ListBinder for slices that are of some arbitrary type.
|
||||
// For this to work, you need to supply a function that returns key value pairs for every slice entry.
|
||||
//
|
||||
// List keys will be bound to slice indices, and list values will be bound to a string representation of the slice elements.
|
||||
type ListBindGenericSlice[T any] struct {
|
||||
Slice *[]T
|
||||
}
|
||||
@ -33,43 +33,7 @@ func (l ListBindGenericSlice[T]) ListKeyValuePairs() []ListKeyValuePair {
|
||||
|
||||
result := make([]ListKeyValuePair, 0, len(*l.Slice))
|
||||
for i, entry := range *l.Slice {
|
||||
|
||||
var str string
|
||||
switch v := any(entry).(type) {
|
||||
case encoding.TextMarshaler:
|
||||
if text, err := v.MarshalText(); err != nil {
|
||||
str = fmt.Sprintf("%d: %s", i, err.Error())
|
||||
} else {
|
||||
str = string(text)
|
||||
}
|
||||
case string:
|
||||
str = v
|
||||
case int:
|
||||
str = strconv.FormatInt(int64(v), 10)
|
||||
case int8:
|
||||
str = strconv.FormatInt(int64(v), 10)
|
||||
case int16:
|
||||
str = strconv.FormatInt(int64(v), 10)
|
||||
case int32:
|
||||
str = strconv.FormatInt(int64(v), 10)
|
||||
case int64:
|
||||
str = strconv.FormatInt(int64(v), 10)
|
||||
case uint:
|
||||
str = strconv.FormatUint(uint64(v), 10)
|
||||
case uint8:
|
||||
str = strconv.FormatUint(uint64(v), 10)
|
||||
case uint16:
|
||||
str = strconv.FormatUint(uint64(v), 10)
|
||||
case uint32:
|
||||
str = strconv.FormatUint(uint64(v), 10)
|
||||
case uint64:
|
||||
str = strconv.FormatUint(uint64(v), 10)
|
||||
case float32:
|
||||
str = strconv.FormatFloat(float64(v), 'f', -1, 32) // TODO: Format number in current user's locale
|
||||
case float64:
|
||||
str = strconv.FormatFloat(float64(v), 'f', -1, 64)
|
||||
}
|
||||
|
||||
str := ValueBindAny{entry}.StringValue()
|
||||
result = append(result, ListKeyValuePair{Key: strconv.Itoa(i), Value: str})
|
||||
}
|
||||
return result
|
||||
@ -94,90 +58,6 @@ func (l ListBindGenericSlice[T]) ListDeleteKey(key string) bool {
|
||||
}
|
||||
|
||||
func (l ListBindGenericSlice[T]) ListAddKeyValuePair(key, value string) error {
|
||||
var val T
|
||||
switch v := any(&val).(type) {
|
||||
case encoding.TextUnmarshaler:
|
||||
if err := v.UnmarshalText([]byte(value)); err != nil {
|
||||
return err
|
||||
}
|
||||
case *string:
|
||||
*v = value
|
||||
case *int:
|
||||
val, err := strconv.ParseInt(value, 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = int(val)
|
||||
case *int8:
|
||||
val, err := strconv.ParseInt(value, 10, 8)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = int8(val)
|
||||
case *int16:
|
||||
val, err := strconv.ParseInt(value, 10, 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = int16(val)
|
||||
case *int32:
|
||||
val, err := strconv.ParseInt(value, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = int32(val)
|
||||
case *int64:
|
||||
val, err := strconv.ParseInt(value, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = int64(val)
|
||||
case *uint:
|
||||
val, err := strconv.ParseUint(value, 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = uint(val)
|
||||
case *uint8:
|
||||
val, err := strconv.ParseUint(value, 10, 8)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = uint8(val)
|
||||
case *uint16:
|
||||
val, err := strconv.ParseUint(value, 10, 16)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = uint16(val)
|
||||
case *uint32:
|
||||
val, err := strconv.ParseUint(value, 10, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = uint32(val)
|
||||
case *uint64:
|
||||
val, err := strconv.ParseUint(value, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = uint64(val)
|
||||
case *float32:
|
||||
val, err := strconv.ParseFloat(value, 32)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = float32(val)
|
||||
case *float64:
|
||||
val, err := strconv.ParseFloat(value, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = float64(val)
|
||||
default:
|
||||
return fmt.Errorf("bound type %T is not supported", v)
|
||||
}
|
||||
|
||||
index, err := strconv.Atoi(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse index: %w", err)
|
||||
@ -187,6 +67,11 @@ func (l ListBindGenericSlice[T]) ListAddKeyValuePair(key, value string) error {
|
||||
return fmt.Errorf("index %d out of bounds", index)
|
||||
}
|
||||
|
||||
var val T
|
||||
if err := (ValueBindAny{&val}).SetStringValue(value); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*l.Slice = slices.Insert(*l.Slice, index, val)
|
||||
|
||||
return nil
|
||||
@ -195,3 +80,33 @@ func (l ListBindGenericSlice[T]) ListAddKeyValuePair(key, value string) error {
|
||||
func (l ListBindGenericSlice[T]) ListLen() int {
|
||||
return len(*l.Slice)
|
||||
}
|
||||
|
||||
// ListBindGenericValues implements ListBinder for slices that are of some arbitrary type.
|
||||
//
|
||||
// List keys and values will be bound to the string representation of the slice elements.
|
||||
//
|
||||
// This is useful for dropdown components, as the key of the selected element will be set to the bound value.
|
||||
//
|
||||
// This can not modify the bound list.
|
||||
type ListBindGenericValues[T any] []T
|
||||
|
||||
func (l ListBindGenericValues[T]) ListKeyValuePairs() []ListKeyValuePair {
|
||||
result := make([]ListKeyValuePair, 0, len(l))
|
||||
for _, entry := range l {
|
||||
str := ValueBindAny{entry}.StringValue()
|
||||
result = append(result, ListKeyValuePair{Key: str, Value: str})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (l ListBindGenericValues[T]) ListDeleteKey(key string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (l ListBindGenericValues[T]) ListAddKeyValuePair(key, value string) error {
|
||||
return fmt.Errorf("the list binder doesn't support list modifications")
|
||||
}
|
||||
|
||||
func (l ListBindGenericValues[T]) ListLen() int {
|
||||
return len(l)
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import (
|
||||
type RadioButton struct {
|
||||
AttrMap vugu.AttrMap
|
||||
|
||||
Bind FieldBinder // Binds the current selected key to some variable.
|
||||
Bind ValueBinder // Binds the current selected key to some variable.
|
||||
Key string // The key that this RadioButton represents as a string.
|
||||
}
|
||||
|
||||
func (c *RadioButton) isChecked() bool {
|
||||
if c.Bind != nil {
|
||||
return c.Bind.String() == c.Key
|
||||
return c.Bind.StringValue() == c.Key
|
||||
}
|
||||
|
||||
return false
|
||||
@ -27,6 +27,6 @@ func (c *RadioButton) handleChange(event vugu.DOMEvent) {
|
||||
}
|
||||
|
||||
if event.PropBool("target", "checked") {
|
||||
c.Bind.SetString(c.Key)
|
||||
c.Bind.SetStringValue(c.Key)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div vg-attr='utils.AttributesAppend{AttrMap: c.AttrMap, Classes: "d3c-1685640525"}'>
|
||||
<input:Field :Bind="FieldBindAny{Value: &c.fieldValue}"><input:Button @Click="c.handleButtonAdd(event)"><icons:LPlus></icons:LPlus></input:Button></input:Field>
|
||||
<input:Field :Bind="ValueBindAny{Value: &c.fieldValue}"><input:Button @Click="c.handleButtonAdd(event)"><icons:LPlus></icons:LPlus></input:Button></input:Field>
|
||||
<div vg-for='i, entry := range c.keyValuePairs()' class="d3c-1685640525-tag d3c-color-layer-1 d3c-button-borderless"><span vg-content="entry.Value"></span><input:Button @Click="c.handleButtonDelete(event, i)"><icons:LDelete></icons:LDelete></input:Button></div>
|
||||
</div>
|
||||
|
||||
|
@ -38,7 +38,7 @@ func (c *Tags) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = FieldBindAny{Value: &c.fieldValue}
|
||||
vgcomp.Bind = ValueBindAny{Value: &c.fieldValue}
|
||||
vgcomp.DefaultSlot = vugu.NewBuilderFunc(func(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn := &vugu.VGNode{Type: vugu.VGNodeType(3)}
|
||||
vgout = &vugu.BuildOut{}
|
||||
|
@ -7,58 +7,116 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// FieldBinder is an interface that everything that every type that wants to bind to an input field must implement.
|
||||
type FieldBinder interface {
|
||||
String() string // String returns the bound variable formatted in the users/current locale.
|
||||
SetString(string) error // SetString parses the string value in the users/current locale and sets the value of the bound variable.
|
||||
// TODO: Locale dependent formatting
|
||||
|
||||
// ValueGetter can be implemented by types that need to be bound to UI components.
|
||||
type ValueGetter interface {
|
||||
StringValue() string // StringValue returns the value as a string formatted in the users/current locale.
|
||||
}
|
||||
|
||||
// ValueSetter can be implemented by types that need to be bound to UI components.
|
||||
type ValueSetter interface {
|
||||
SetStringValue(string) error // SetStringValue parses the string value in the users/current locale.
|
||||
}
|
||||
|
||||
// ValueBinder can be implemented by types that need to be bound to UI components.
|
||||
type ValueBinder interface {
|
||||
ValueGetter
|
||||
ValueSetter
|
||||
}
|
||||
|
||||
// HTMLInputTyper can be implemented by types that need to be bound to UI components.
|
||||
type HTMLInputTyper interface {
|
||||
HTMLInputType() string // HTMLInputType returns the to be used type parameter for the HTML input element.
|
||||
}
|
||||
|
||||
// FieldBindAny implements the FieldBinder interface for all basic types and the encoding.TextMarshaler, encoding.TextUnmarshaler interfaces.
|
||||
type FieldBindAny struct{ Value any }
|
||||
// ValueBindAny implements the ValueBinder interface for all basic types and the encoding.TextMarshaler, encoding.TextUnmarshaler interfaces.
|
||||
type ValueBindAny struct{ Value any }
|
||||
|
||||
func (f FieldBindAny) String() string {
|
||||
func (f ValueBindAny) StringValue() string {
|
||||
switch v := f.Value.(type) {
|
||||
case *bool:
|
||||
return strconv.FormatBool(*v)
|
||||
case *string:
|
||||
return *v
|
||||
case *int:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case *int8:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case *int16:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case *int32:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case *int64:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case *uint:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case *uint8:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case *uint16:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case *uint32:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case *uint64:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case *float32:
|
||||
return strconv.FormatFloat(float64(*v), 'f', -1, 32) // TODO: Format number in current user's locale
|
||||
case *float64:
|
||||
return strconv.FormatFloat(float64(*v), 'f', -1, 64)
|
||||
case *time.Time:
|
||||
case ValueGetter: // Support nested value getters.
|
||||
return v.StringValue()
|
||||
case *time.Time: // Put time.Time before TextMarshaler, so we can define a custom format that is compatible with input fields.
|
||||
return v.Local().Format("2006-01-02T15:04")
|
||||
case time.Time:
|
||||
return v.Local().Format("2006-01-02T15:04")
|
||||
case encoding.TextMarshaler:
|
||||
data, _ := v.MarshalText() // Ignore any errors, as we can't handle them here.
|
||||
return string(data)
|
||||
case *bool:
|
||||
return strconv.FormatBool(*v)
|
||||
case bool:
|
||||
return strconv.FormatBool(v)
|
||||
case *string:
|
||||
return *v
|
||||
case string:
|
||||
return v
|
||||
case *int:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case int:
|
||||
return strconv.FormatInt(int64(v), 10)
|
||||
case *int8:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case int8:
|
||||
return strconv.FormatInt(int64(v), 10)
|
||||
case *int16:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case int16:
|
||||
return strconv.FormatInt(int64(v), 10)
|
||||
case *int32:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case int32:
|
||||
return strconv.FormatInt(int64(v), 10)
|
||||
case *int64:
|
||||
return strconv.FormatInt(int64(*v), 10)
|
||||
case int64:
|
||||
return strconv.FormatInt(int64(v), 10)
|
||||
case *uint:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case uint:
|
||||
return strconv.FormatUint(uint64(v), 10)
|
||||
case *uint8:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case uint8:
|
||||
return strconv.FormatUint(uint64(v), 10)
|
||||
case *uint16:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case uint16:
|
||||
return strconv.FormatUint(uint64(v), 10)
|
||||
case *uint32:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case uint32:
|
||||
return strconv.FormatUint(uint64(v), 10)
|
||||
case *uint64:
|
||||
return strconv.FormatUint(uint64(*v), 10)
|
||||
case uint64:
|
||||
return strconv.FormatUint(uint64(v), 10)
|
||||
case *float32:
|
||||
return strconv.FormatFloat(float64(*v), 'f', -1, 32) // TODO: Format number in current user's locale
|
||||
case float32:
|
||||
return strconv.FormatFloat(float64(v), 'f', -1, 32) // TODO: Format number in current user's locale
|
||||
case *float64:
|
||||
return strconv.FormatFloat(float64(*v), 'f', -1, 64)
|
||||
case float64:
|
||||
return strconv.FormatFloat(float64(v), 'f', -1, 64)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (f FieldBindAny) SetString(value string) error {
|
||||
func (f ValueBindAny) SetStringValue(value string) error {
|
||||
switch v := f.Value.(type) {
|
||||
case ValueSetter: // Support nested value setters.
|
||||
return v.SetStringValue(value)
|
||||
case *time.Time: // Put time.Time before TextMarshaler, so we can define a custom format that is compatible with input fields.
|
||||
val, err := time.ParseInLocation("2006-01-02T15:04", value, time.Local)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = val
|
||||
case encoding.TextUnmarshaler:
|
||||
return v.UnmarshalText([]byte(value))
|
||||
case *bool:
|
||||
val, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
@ -139,14 +197,6 @@ func (f FieldBindAny) SetString(value string) error {
|
||||
return err
|
||||
}
|
||||
*v = float64(val)
|
||||
case *time.Time:
|
||||
val, err := time.ParseInLocation("2006-01-02T15:04", value, time.Local)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*v = val
|
||||
case encoding.TextUnmarshaler:
|
||||
return v.UnmarshalText([]byte(value))
|
||||
default:
|
||||
return fmt.Errorf("bound type %T is not supported", f.Value)
|
||||
}
|
||||
@ -154,8 +204,10 @@ func (f FieldBindAny) SetString(value string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f FieldBindAny) HTMLInputType() string {
|
||||
func (f ValueBindAny) HTMLInputType() string {
|
||||
switch f.Value.(type) {
|
||||
case *time.Time:
|
||||
return "datetime-local"
|
||||
case *bool:
|
||||
return "text" // We will render the boolean as text, as this is an input field, not a checkbox.
|
||||
case *string:
|
||||
@ -164,10 +216,6 @@ func (f FieldBindAny) HTMLInputType() string {
|
||||
return "number"
|
||||
case *float32, *float64:
|
||||
return "number"
|
||||
case *time.Time:
|
||||
return "datetime-local"
|
||||
case encoding.TextMarshaler, encoding.TextUnmarshaler:
|
||||
return "text"
|
||||
}
|
||||
|
||||
return "text"
|
@ -46,16 +46,16 @@
|
||||
|
||||
<h2>Radio buttons</h2>
|
||||
<view:Code>
|
||||
<pre vg-content='"<input:RadioButton id=\"page-radio-button-1-a\" :Bind=\"input.FieldBindAny{&c.radioButton1}\" Key=\"A\"></input:RadioButton>\n" +
|
||||
<pre vg-content='"<input:RadioButton id=\"page-radio-button-1-a\" :Bind=\"input.ValueBindAny{&c.radioButton1}\" Key=\"A\"></input:RadioButton>\n" +
|
||||
"<label for=\"page-radio-button-1-a\">Option A</label>"' style="margin: 0;"></pre>
|
||||
</view:Code>
|
||||
<input:RadioButton id="page-radio-button-1-a" :Bind="input.FieldBindAny{&c.radioButton1}" Key="A"></input:RadioButton>
|
||||
<input:RadioButton id="page-radio-button-1-a" :Bind="input.ValueBindAny{&c.radioButton1}" Key="A"></input:RadioButton>
|
||||
<label for="page-radio-button-1-a">Option A</label>
|
||||
<br>
|
||||
<input:RadioButton id="page-radio-button-1-b" :Bind="input.FieldBindAny{&c.radioButton1}" Key="B"></input:RadioButton>
|
||||
<input:RadioButton id="page-radio-button-1-b" :Bind="input.ValueBindAny{&c.radioButton1}" Key="B"></input:RadioButton>
|
||||
<label for="page-radio-button-1-b">Option B</label>
|
||||
<br>
|
||||
<input:RadioButton id="page-radio-button-1-c" :Bind="input.FieldBindAny{&c.radioButton1}" Key="C"></input:RadioButton>
|
||||
<input:RadioButton id="page-radio-button-1-c" :Bind="input.ValueBindAny{&c.radioButton1}" Key="C"></input:RadioButton>
|
||||
<label for="page-radio-button-1-c">Option C</label>
|
||||
<div vg-content="fmt.Sprintf(`Selected option is %q.`, c.radioButton1)"></div>
|
||||
|
||||
@ -75,30 +75,30 @@
|
||||
<p>To make labels work correctly, you have to use the <view:CodeInline>ID="some-id"</view:CodeInline> tag (uppercase ID), which will set the ID of the embedded input element!</p>
|
||||
<view:Code>
|
||||
<pre vg-content='"<label for=\"page-input-1\">Some input field</label>\n" +
|
||||
"<input:Field ID=\"page-input-1\" :Bind=\"input.FieldBindAny{&c.inputField1String}\"></input:Field>"' style="margin: 0;"></pre>
|
||||
"<input:Field ID=\"page-input-1\" :Bind=\"input.ValueBindAny{&c.inputField1String}\"></input:Field>"' style="margin: 0;"></pre>
|
||||
</view:Code>
|
||||
<label for="page-input-1">Some input field bound to string value</label>
|
||||
<input:Field ID="page-input-1" :Bind="input.FieldBindAny{&c.inputField1String}"></input:Field>
|
||||
<input:Field ID="page-input-1" :Bind="input.ValueBindAny{&c.inputField1String}"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Current value is %q.", c.inputField1String)'></span>
|
||||
<br>
|
||||
<label for="page-input-2">Some input field bound to integer value</label>
|
||||
<input:Field ID="page-input-2" :Bind="input.FieldBindAny{&c.inputField2Int}"></input:Field>
|
||||
<input:Field ID="page-input-2" :Bind="input.ValueBindAny{&c.inputField2Int}"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Current value is %v.", c.inputField2Int)'></span>
|
||||
<br>
|
||||
<label for="page-input-3">Some input field bound to float value</label>
|
||||
<input:Field ID="page-input-3" :Bind="input.FieldBindAny{&c.inputField3Float}"></input:Field>
|
||||
<input:Field ID="page-input-3" :Bind="input.ValueBindAny{&c.inputField3Float}"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Current value is %v.", c.inputField3Float)'></span>
|
||||
<br>
|
||||
<label for="page-input-6">Some input field bound to bool value</label>
|
||||
<input:Field ID="page-input-6" :Bind="input.FieldBindAny{&c.inputField6Bool}"></input:Field>
|
||||
<input:Field ID="page-input-6" :Bind="input.ValueBindAny{&c.inputField6Bool}"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Current state is %v.", c.inputField6Bool)'></span>
|
||||
<p>For passwords you have to set the <view:CodeInline>Type="password"</view:CodeInline> field of the component:</p>
|
||||
<label for="page-input-4">Some input field bound to password string</label>
|
||||
<input:Field ID="page-input-4" :Bind="input.FieldBindAny{&c.inputField4String}" Type="password"></input:Field>
|
||||
<input:Field ID="page-input-4" :Bind="input.ValueBindAny{&c.inputField4String}" Type="password"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Secret password is %q.", c.inputField4String)'></span>
|
||||
<p>You can add additional buttons to the input field:</p>
|
||||
<label for="page-input-5">Some input field with some extra button</label>
|
||||
<input:Field ID="page-input-5" :Bind="input.FieldBindAny{&c.inputField5String}">
|
||||
<input:Field ID="page-input-5" :Bind="input.ValueBindAny{&c.inputField5String}">
|
||||
<input:Button :Bind="&c.inputField5Bool">
|
||||
<icons:LLockOpened vg-if="!c.inputField5Bool" class="d3c-button-borderless"></icons:LLockOpened>
|
||||
<icons:LLockClosed vg-if="c.inputField5Bool" class="d3c-button-borderless"></icons:LLockClosed>
|
||||
@ -109,12 +109,12 @@
|
||||
</input:Field>
|
||||
<p>time.Time is also supported:</p>
|
||||
<label for="page-input-7">Some input field bound to a time.Time value</label>
|
||||
<input:Field ID="page-input-7" :Bind="input.FieldBindAny{&c.inputField7Time}"></input:Field>
|
||||
<input:Field ID="page-input-7" :Bind="input.ValueBindAny{&c.inputField7Time}"></input:Field>
|
||||
<span vg-content='fmt.Sprintf("Selected date and time is %v.", c.inputField7Time)'></span>
|
||||
|
||||
<h2>Drop-down</h2>
|
||||
<label for="page-dropdown-1">Select a slice entry</label>
|
||||
<input:Dropdown id="page-dropdown-1" :Bind="input.FieldBindAny{Value: &c.dropdown1Index}" :BindList="input.ListBindGenericSlice[string]{Slice: &c.dropdown1Slice}"></input:Dropdown>
|
||||
<input:Dropdown id="page-dropdown-1" :Bind="input.ValueBindAny{Value: &c.dropdown1Index}" :BindList="input.ListBindGenericSlice[string]{Slice: &c.dropdown1Slice}"></input:Dropdown>
|
||||
<span vg-content='fmt.Sprintf("The selected index is %d.", c.dropdown1Index)'></span>
|
||||
|
||||
<h2>Tags</h2>
|
||||
|
@ -31,7 +31,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x928E418A9F1AD716^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x947E59975927A2FA^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*layout.Container)
|
||||
if vgcomp == nil {
|
||||
@ -62,7 +62,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "Clickable components support the "}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xCF0DD6A7C79A983D^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x824C52E34196E77B^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.CodeInline)
|
||||
if vgcomp == nil {
|
||||
@ -89,7 +89,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: " event that handlers can be registered to with "}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xECF261CDF62F4799^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x1C2AEAAE2BF6AC5D^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.CodeInline)
|
||||
if vgcomp == nil {
|
||||
@ -117,7 +117,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x7C9A794E47C178A2^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x8DE76775758803E2^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -166,7 +166,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x8B2AC0254C511E18^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xD27F30849E3672E1^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -198,7 +198,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xE9F6BF7F6F2D97B9^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xA9A8932C9AC636EF^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -232,7 +232,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x304A5F2A364165CA^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xC36240073896AE95^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -267,7 +267,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x2DDC70A29611DBAF^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x326A82D46D6396B5^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -284,7 +284,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
_ = vgparent
|
||||
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x6A43A0E51C9A6C53^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x661B486FF158FF42^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LDocument)
|
||||
if vgcomp == nil {
|
||||
@ -330,7 +330,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "Use the "}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xAFFD7BC3E634D1E8^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x478FDC954C3EA46A^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.CodeInline)
|
||||
if vgcomp == nil {
|
||||
@ -360,7 +360,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x6385B83403AC7D96^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x2AAD47A3AC92D246^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -395,7 +395,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xA165259441557D96^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xCA3AD48273BB2C2^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -414,7 +414,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
_ = vgparent
|
||||
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x3B26A12A9A9AD428^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x9AB7DAADBB8288FB^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LGlobe)
|
||||
if vgcomp == nil {
|
||||
@ -454,7 +454,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xC7CE5967907608F3^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xD647D90A51CE1F3E^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -486,7 +486,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x1E87DA8BFC8EA20^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xCB770C0F1AE8C291^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -524,7 +524,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x23B1580846A400A4^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xEFB4944BDA615838^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -544,7 +544,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Namespace: "", Data: "pre", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "style", Val: "margin: 0;"}}}
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn.SetInnerHTML("<input:RadioButton id=\"page-radio-button-1-a\" :Bind=\"input.FieldBindAny{&c.radioButton1}\" Key=\"A\"></input:RadioButton>\n" +
|
||||
vgn.SetInnerHTML("<input:RadioButton id=\"page-radio-button-1-a\" :Bind=\"input.ValueBindAny{&c.radioButton1}\" Key=\"A\"></input:RadioButton>\n" +
|
||||
"<label for=\"page-radio-button-1-a\">Option A</label>")
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
@ -557,7 +557,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xDE9F0C080FCBE9B6^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x7BC2310B4750C527^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.RadioButton)
|
||||
if vgcomp == nil {
|
||||
@ -566,7 +566,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.radioButton1}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.radioButton1}
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["id"] = "page-radio-button-1-a"
|
||||
vgcomp.Key = "A"
|
||||
@ -587,7 +587,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xF51B902E976F71D0^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xE1EDD1866AE78AC6^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.RadioButton)
|
||||
if vgcomp == nil {
|
||||
@ -596,7 +596,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.radioButton1}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.radioButton1}
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["id"] = "page-radio-button-1-b"
|
||||
vgcomp.Key = "B"
|
||||
@ -617,7 +617,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x784BD71FE417B48C^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x756E5CE8DE4E165B^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.RadioButton)
|
||||
if vgcomp == nil {
|
||||
@ -626,7 +626,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.radioButton1}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.radioButton1}
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["id"] = "page-radio-button-1-c"
|
||||
vgcomp.Key = "C"
|
||||
@ -652,7 +652,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xA28B1B8C0429AF0^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x333BDCEE368C3E1A^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -685,7 +685,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xE9AAA18D5DF3C0DE^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x4F1AC3C7FF3C105^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.CheckBox)
|
||||
if vgcomp == nil {
|
||||
@ -714,7 +714,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x651C9288CF002954^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x500C0F57C116FDE6^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.CheckBox)
|
||||
if vgcomp == nil {
|
||||
@ -755,7 +755,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "To make labels work correctly, you have to use the "}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x68BB9D88FA3B351D^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xAC7E753F72CE5326^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.CodeInline)
|
||||
if vgcomp == nil {
|
||||
@ -785,7 +785,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xE2564FDE4DB68CE0^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x9A3BC016AC5CAC3E^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.Code)
|
||||
if vgcomp == nil {
|
||||
@ -806,7 +806,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(3), Namespace: "", Data: "pre", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "style", Val: "margin: 0;"}}}
|
||||
vgparent.AppendChild(vgn)
|
||||
vgn.SetInnerHTML("<label for=\"page-input-1\">Some input field</label>\n" +
|
||||
"<input:Field ID=\"page-input-1\" :Bind=\"input.FieldBindAny{&c.inputField1String}\"></input:Field>")
|
||||
"<input:Field ID=\"page-input-1\" :Bind=\"input.ValueBindAny{&c.inputField1String}\"></input:Field>")
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
return
|
||||
@ -823,7 +823,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x28EFFF3CE273EF44^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x2D043AD37AA3D919^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -832,7 +832,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField1String}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField1String}
|
||||
vgcomp.ID = "page-input-1"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
@ -856,7 +856,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x756CB00237D8810^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x48774E335A6DF07E^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -865,7 +865,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField2Int}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField2Int}
|
||||
vgcomp.ID = "page-input-2"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
@ -889,7 +889,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x7C3A36DA5DCF3ED3^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x389F24DDC5168BE1^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -898,7 +898,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField3Float}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField3Float}
|
||||
vgcomp.ID = "page-input-3"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
@ -922,7 +922,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xA262AF139BBC7695^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xB72B704D381BCEA4^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -931,7 +931,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField6Bool}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField6Bool}
|
||||
vgcomp.ID = "page-input-6"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
@ -952,7 +952,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "For passwords you have to set the "}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x5E54C508EAB2DA75^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xB95F701A0781923E^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*view.CodeInline)
|
||||
if vgcomp == nil {
|
||||
@ -987,7 +987,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xE6214B61489F970C^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x7AF4AD884531BF03^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -996,7 +996,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField4String}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField4String}
|
||||
vgcomp.ID = "page-input-4"
|
||||
vgcomp.Type = "password"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
@ -1021,7 +1021,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xADA936494B3AA8DD^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x9D7C1AD758CE42B7^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -1030,7 +1030,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField5String}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField5String}
|
||||
vgcomp.ID = "page-input-5"
|
||||
vgcomp.DefaultSlot = vugu.NewBuilderFunc(func(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn := &vugu.VGNode{Type: vugu.VGNodeType(3)}
|
||||
@ -1042,7 +1042,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xDAEC1AA0D2CE5DA9^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x555BD39E45783FEE^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -1063,7 +1063,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgparent.AppendChild(vgn)
|
||||
if !c.inputField5Bool {
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xCEC4D5F629C814D7^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x455A78C33C3AD4EA^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LLockOpened)
|
||||
if vgcomp == nil {
|
||||
@ -1083,7 +1083,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgparent.AppendChild(vgn)
|
||||
if c.inputField5Bool {
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xB0BD1FB25F12743D^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x9A1CDBA3EA679202^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LLockClosed)
|
||||
if vgcomp == nil {
|
||||
@ -1110,7 +1110,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xBAC9520EAD4AF0A4^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xC261560825261918^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Button)
|
||||
if vgcomp == nil {
|
||||
@ -1129,7 +1129,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x9E8F42676B734407^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xE28D137A80B46A63^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*icons.LGlobe)
|
||||
if vgcomp == nil {
|
||||
@ -1171,7 +1171,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x4B1753F5FE40444B^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x7D6DE54C774B51C4^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Field)
|
||||
if vgcomp == nil {
|
||||
@ -1180,7 +1180,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{&c.inputField7Time}
|
||||
vgcomp.Bind = input.ValueBindAny{&c.inputField7Time}
|
||||
vgcomp.ID = "page-input-7"
|
||||
vgout.Components = append(vgout.Components, vgcomp)
|
||||
vgn = &vugu.VGNode{Component: vgcomp}
|
||||
@ -1204,7 +1204,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xE08CB30A293A1BE1^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0xC3DF5DFFB763B333^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Dropdown)
|
||||
if vgcomp == nil {
|
||||
@ -1213,7 +1213,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgin.BuildEnv.WireComponent(vgcomp)
|
||||
}
|
||||
vgin.BuildEnv.UseComponent(vgcompKey, vgcomp) // ensure we can use this in the cache next time around
|
||||
vgcomp.Bind = input.FieldBindAny{Value: &c.dropdown1Index}
|
||||
vgcomp.Bind = input.ValueBindAny{Value: &c.dropdown1Index}
|
||||
vgcomp.BindList = input.ListBindGenericSlice[string]{Slice: &c.dropdown1Slice}
|
||||
vgcomp.AttrMap = make(map[string]interface{}, 8)
|
||||
vgcomp.AttrMap["id"] = "page-dropdown-1"
|
||||
@ -1239,7 +1239,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0x331AF2E50268D980^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x9B60AFD947AFFD5B^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.Tags)
|
||||
if vgcomp == nil {
|
||||
@ -1263,7 +1263,7 @@ func (c *PageInput) Build(vgin *vugu.BuildIn) (vgout *vugu.BuildOut) {
|
||||
vgn = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t"}
|
||||
vgparent.AppendChild(vgn)
|
||||
{
|
||||
vgcompKey := vugu.MakeCompKey(0xCF8CCA9BEBE76CBE^vgin.CurrentPositionHash(), vgiterkey)
|
||||
vgcompKey := vugu.MakeCompKey(0x5BD5B3B75FBAF631^vgin.CurrentPositionHash(), vgiterkey)
|
||||
// ask BuildEnv for prior instance of this specific component
|
||||
vgcomp, _ := vgin.BuildEnv.CachedComponent(vgcompKey).(*input.TextArea)
|
||||
if vgcomp == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user