protected override void OnAfterRender(bool firstRender) { if (firstRender) { StructureInstance.ValidateInitial(Value); } }
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(); };
protected override void OnInitialized() { var altUser = new User(); // _testUser = new User { Boolean = true, UserID = 12345, Name = "A.J.", PhoneNumber = "111.222.3344", Email = "[email protected]!99999999999999999999999999999999999999999999999999999999999999999! spaced out words n stuff", StartDate = DateTime.Now, StartTime = DateTime.Now, DepartmentID = 2, DepartmentType2 = 2, }; // _structure = Common.Structure.Instantiate(JSRuntime); // _structure.GetMemberInstance <string>("Name").OnValueUpdateUntyped += (v, m, mv) => Console.WriteLine($"Structure<User>." + m.ID + " -> " + v); _structure.GetMemberInstance <string>("Email").OnValueUpdateUntyped += (v, m, mv) => Console.WriteLine($"Structure<User>." + m.ID + " -> " + v); _structure.OnMemberValueUpdate += (s, v, m) => { Console.WriteLine($"Structure<User>." + v.ID + " -> " + m); InvokeAsync(StateHasChanged); }; // // _structure.OnMemberValueUpdate += (s, m, v) => InvokeAsync(StateHasChanged); _tagsSelector = new FlareSelector <string> (() => new List <IOption <string> > { new FlareSelect.Option <string> { ID = "A", OptionText = "A", }, new FlareSelect.Option <string> { ID = "B", OptionText = "B", }, new FlareSelect.Option <string> { ID = "C", OptionText = "C", }, }, true ); _tagsSelector.OnSelect += selected => _structure.GetMemberInstance <List <string> >(nameof(User.Tags)) .UpdateValue(_testUser, selected.Select(v => v.ID).ToList()); _structure.OnResetAllMemberInputs += () => _tagsSelector.Deselect(); _structure.ValidationState.OnFinishValidating += () => InvokeAsync(StateHasChanged); Task.Run(() => { Thread.Sleep(500); Console.WriteLine("Updating"); _testUser.Boolean = false; _structure.GetMemberInstance <bool>(nameof(User.Boolean)).ResetInputs(); _structure.Revalidate(_testUser); InvokeAsync(StateHasChanged); }); // _submitButton = new Button(() => "Submit", _ => Submit(), () => Button.Color.Green, isDisabled: () => !_structure.ValidationState.Valid()); _header2 = new Header ( new List <IBit> { new Title(() => "Header #1!"), new Filler(), new Link(() => "Link 1!", () => "/url1"), new Space(), new Link(() => "Link 2!", () => "/url2", isHighlighted: () => true), new Space(), new Link(() => "Link 3!", () => "/url3"), }, Header.HeaderType.Secondary ); // Task.Run(async () => // { // while (true) // { // await InvokeAsync(StateHasChanged); // Thread.Sleep(200); // } // }); }