Ejemplo n.º 1
0
 /// <summary>
 /// Handles the component click event.
 /// </summary>
 /// <returns></returns>
 protected async Task OnClickHandler()
 {
     if (CopyToClipboard)
     {
         await JSUtilitiesModule.CopyToClipboard(ElementRef, ElementId);
     }
 }
Ejemplo n.º 2
0
        private async Task Expand()
        {
            // An element location must be known every time we need to show the dropdown. The reason is mainly
            // because sometimes input can have different offset based on the changes on the page. For example
            // when validation is triggered the input can be pushed down by the error messages.
            elementInfo = await JSUtilitiesModule.GetElementInfo(ElementRef, ElementId);

            await JSClosableModule.Register(dotNetObjectRef, ElementRef);

            Expanded = true;

            // automatically set focus to the dropdown so that we can make it auto-close on blur event
            ExecuteAfterRender(async() => await DropdownElementRef.FocusAsync());
        }
Ejemplo n.º 3
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            var listRect = await JSUtilitiesModule.GetElementInfo(slickListElementRef, null);

            if (slickWidth != (int)listRect.BoundingClientRect.Width)
            {
                slickWidth = (int)listRect.BoundingClientRect.Width;
                totalWidth = slickWidth * (carouselSlides.Count * 2 + 1);

                await InvokeAsync(StateHasChanged);
            }

            await base.OnAfterRenderAsync(firstRender);
        }
Ejemplo n.º 4
0
        internal protected override void OnVisibleChanged(bool e)
        {
            ExecuteAfterRender(async() =>
            {
                if (ParentDropdown != null && ParentDropdown is AntDesign.Dropdown dropdown)
                {
                    var dropdownMenuElementInfo = await JSUtilitiesModule.GetElementInfo(ElementRef, ElementId);

                    MenuStyleNames = GetMenuStyleNames(dropdown.ElementInfo, dropdownMenuElementInfo, dropdown.Direction);

                    await InvokeAsync(StateHasChanged);
                }
            });

            base.OnVisibleChanged(e);
        }
Ejemplo n.º 5
0
        /// <inheritdoc/>
        protected async Task OnInputHandler(ChangeEventArgs e)
        {
            if (IsChangeTextOnKeyPress)
            {
                if (IsDelayTextOnKeyPress)
                {
                    inputValueDebouncer?.Update(e?.Value?.ToString());
                }
                else
                {
                    var caret = await JSUtilitiesModule.GetCaret(ElementRef);

                    await CurrentValueHandler(e?.Value?.ToString());

                    await JSUtilitiesModule.SetCaret(ElementRef, caret);
                }
            }
        }
Ejemplo n.º 6
0
        protected async Task OnSliderMouseDown(MouseEventArgs e)
        {
            // only the left button can trigger the change
            if (e.Button != 0)
            {
                return;
            }

            mouseDown = true;

            sliderElementInfo = await JSUtilitiesModule.GetElementInfo(ElementRef, ElementId);

            sliderStart = sliderElementInfo.BoundingClientRect.Left;
            sliderWidth = sliderElementInfo.BoundingClientRect.Width;

            startedAt = e.ClientX;

            Percentage = CalculatePercentage(e.ClientX);

            await CurrentValueHandler(CalculateValue( Percentage ));
        }
Ejemplo n.º 7
0
        /// <inheritdoc/>
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            await base.SetParametersAsync(parameters);

            if (ParentValidation != null)
            {
                if (parameters.TryGetValue <Expression <Func <TValue> > >(nameof(CheckedExpression), out var expression))
                {
                    await ParentValidation.InitializeInputExpression(expression);
                }

                await InitializeValidation();
            }

            if (parameters.TryGetValue <bool?>(nameof(Indeterminate), out var indeterminate) && this.indeterminate != indeterminate)
            {
                this.indeterminate = indeterminate;

                ExecuteAfterRender(async() =>
                {
                    await JSUtilitiesModule.SetProperty(ElementRef, "indeterminate", indeterminate);
                });
            }
        }
Ejemplo n.º 8
0
 /// <inheritdoc/>
 public virtual async Task Select(bool focus = true)
 {
     await JSUtilitiesModule.Select(ElementRef, ElementId, focus);
 }
Ejemplo n.º 9
0
 /// <inheritdoc/>
 public virtual Task Select(bool focus = true)
 {
     return(JSUtilitiesModule.Select(ElementRef, ElementId, focus).AsTask());
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Sets focus on the button element, if it can be focused.
 /// </summary>
 /// <param name="scrollToElement">If true the browser should scroll the document to bring the newly-focused element into view.</param>
 /// <returns>A task that represents the asynchronous operation.</returns>
 public Task Focus(bool scrollToElement = true)
 {
     return(JSUtilitiesModule.Focus(ElementRef, ElementId, scrollToElement).AsTask());
 }
Ejemplo n.º 11
0
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            elementInfo = await JSUtilitiesModule.GetElementInfo(ElementRef, ElementId);

            await base.OnAfterRenderAsync(firstRender);
        }