public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, TID> member ) => builder => { if (structure.JSRuntime == null) { throw new ArgumentException( "StructureInstance passed to ComboboxInput does not have a set JSRuntime.", nameof(structure.JSRuntime)); } int seq = -1; builder.OpenElement(++seq, "div"); // ClassSet classes = new ClassSet ( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(ComboboxInput <TStructure, TID>) ); InputBuilder.Required(value, member.Member, classes); InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); // InitCombobox(structure, value, member); _combobox !.OnSelect += o => OnInput?.Invoke(value, o != null ? o.Value : default !);
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, TMember> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); // var classes = new ClassSet( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(NumberInput <TStructure, TMember>) ); bool required = InputBuilder.Required(value, member.Member, classes); bool disabled = InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); // InputBuilder.OpenInnerInput ( builder, ref seq, value, member.Member, "input", "number", "value", member.Member.InputValue.Invoke(value, member.Member), required, disabled, args => OnChange(value, member.Member, args) ); if (_min != null) { builder.AddAttribute(++seq, "min", _min.Value); } if (_max != null) { builder.AddAttribute(++seq, "max", _max.Value); } if (_step != null) { builder.AddAttribute(++seq, "step", _step.Value); } InputBuilder.CloseInnerInput(builder); builder.CloseElement(); };
private void InitCombobox (StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, TID> member) { _combobox = new Combobox <TID> ( structure.JSRuntime !, () => _options.Invoke(value, member.Member), () => member.Member.InputIsDisabled?.Invoke(value, member.Member) == true, () => member.Member.InputIsRequired?.Invoke(value, member.Member) == true, member.Member.InputPlaceholder == null ? (Combobox <TID> .Placeholder?)null : () => member.Member.InputPlaceholder.Invoke(value, member.Member) ); }
protected override void OnInitialized() { _member = StructureInstance.GetMemberInstance <TM>(ID); if (_member.Member.Input == null) { throw new ArgumentNullException(nameof(_member.Member.Input), "MemberInput component was used on a Member with no Input."); } _initialValue = _member.Member.Value.Invoke(Value, _member.Member); _member.OnRefreshInputs += RefreshInput; _member.OnResetInputs += ResetInput; }
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, bool> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); // ClassSet classes = new ClassSet ( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(CheckboxInput <TStructure>) ); bool required = InputBuilder.Required(value, member.Member, classes); bool disabled = InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); // _checkbox ??= new Checkbox ( onToggle: c => OnInput?.Invoke(value, c), isChecked: () => member.Member.InputValue.Invoke(value, member.Member) is bool b && b, isDisabled: () => member.Member.InputIsDisabled?.Invoke(value, member.Member) == true ); builder.AddContent(++seq, _checkbox.Render()); // builder.CloseElement(); };
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, DateTime> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); // var classes = new ClassSet( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(DateInput <TStructure>) ); bool required = InputBuilder.Required(value, member.Member, classes); bool disabled = InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); // InputBuilder.OpenInnerInput ( builder, ref seq, value, member.Member, "input", "date", "value", TransformValue(structure.Structure, value, member.Member), required, disabled, args => OnChange(value, args) ); InputBuilder.CloseInnerInput(builder); builder.CloseElement(); };
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, DateTime> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); var classes = new ClassSet( "Integrant.Element.Override.Input", "Integrant.Element.Override.Input:Composite", "Integrant.Rudiment.Input." + nameof(DateTimeInput <TStructure>) ); builder.AddAttribute(++seq, "class", classes.ToString()); // builder.AddContent(++seq, _dateInput.Render(structure, value, member)); builder.AddContent(++seq, _timeInput.Render(structure, value, member)); builder.CloseElement(); };
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, string> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); // ClassSet classes = new ClassSet ( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(StringInput <TStructure>) ); if (TextArea) { classes.Add("Integrant.Rudiment.Input:TextArea"); } if (Monospace) { classes.Add("Integrant.Rudiment.Input:Monospace"); } bool required = InputBuilder.Required(value, member.Member, classes); bool disabled = InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); // if (!TextArea) { InputBuilder.OpenInnerInput ( builder, ref seq, value, member.Member, "input", "text", "value", member.Member.InputValue.Invoke(value, member.Member), required, disabled, args => OnChange(value, args) ); InputBuilder.CloseInnerInput(builder); } else { InputBuilder.OpenInnerInput ( builder, ref seq, value, member.Member, "textarea", null, "value", member.Member.InputValue.Invoke(value, member.Member), required, disabled, args => OnChange(value, args) ); if (TextAreaCols != null) { builder.AddAttribute(++seq, "cols", TextAreaCols.Invoke(value, member.Member, this)); } if (TextAreaRows != null) { builder.AddAttribute(++seq, "rows", TextAreaRows.Invoke(value, member.Member, this)); } InputBuilder.CloseInnerInput(builder); } builder.CloseElement(); };
public void Reset(StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, string> member) { }
public void Reset(StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, bool> member) { _checkbox !.Reset(); }
public void Reset (StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, TID> member) { InitCombobox(structure, value, member); }
public void Reset(StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, DateTime> member) { }
public RenderFragment Render ( StructureInstance <TStructure> structure, TStructure value, MemberInstance <TStructure, TID> member ) => builder => { int seq = -1; builder.OpenElement(++seq, "div"); // ClassSet classes = new ClassSet ( "Integrant.Element.Override.Input", "Integrant.Rudiment.Input." + nameof(SelectInput <TStructure, TID>) ); bool required = InputBuilder.Required(value, member.Member, classes); bool disabled = InputBuilder.Disabled(value, member.Member, classes); builder.AddAttribute(++seq, "class", classes.ToString()); if (member.Member.InputPlaceholder != null) { builder.AddAttribute(++seq, "placeholder", member.Member.InputPlaceholder.Invoke(value, member.Member)); } // List <IOption <TID> > options = _options.Invoke(value, member.Member).ToList(); object?v = member.Member.InputValue.Invoke(value, member.Member); int?selectedIndex = null; if (v != null) { selectedIndex = options.FindIndex(q => q.Value.Equals(v)); if (selectedIndex == -1) { selectedIndex = null; } // Console.WriteLine($"Selected index: {selectedIndex}"); } InputBuilder.OpenInnerInput ( builder, ref seq, value, member.Member, "select", null, "value", selectedIndex, required, disabled, args => OnChange(value, args) ); _keyMap = new Dictionary <int, TID>(); // builder.OpenRegion(++seq); int iSeq = -1; for (var i = 0; i < options.Count; i++) { IOption <TID> option = options[i]; _keyMap[i] = option.Value; builder.OpenElement(++iSeq, "option"); builder.AddAttribute(++iSeq, "value", i); ++iSeq; if (option.Disabled) { builder.AddAttribute(iSeq, "disabled", "disabled"); } ++iSeq; if (option.Value.Equals(v)) { builder.AddAttribute(iSeq, "selected", "selected"); } builder.AddContent(++iSeq, option.OptionText); builder.CloseElement(); } builder.CloseRegion(); // if (selectedIndex == null) { builder.OpenElement(++seq, "option"); builder.AddAttribute(++seq, "disabled", "disabled"); builder.AddAttribute(++seq, "hidden", "hidden"); builder.AddAttribute(++seq, "selected", "selected"); builder.CloseElement(); } InputBuilder.CloseInnerInput(builder); builder.CloseElement(); };