/// <summary>
 /// Creates an identified-component-data object.
 /// </summary>
 /// <param name="id">The component ID. Pass a nonempty string to specify an ID and make the component an ID container. Pass the empty string for an
 /// ID container only. Pass null for no ID and no container. A component with a specified ID cannot be used more than once in the same ID container.</param>
 /// <param name="updateRegionLinkers"></param>
 /// <param name="errorSources"></param>
 /// <param name="childGetter"></param>
 internal IdentifiedComponentData(
     string id, IEnumerable <UpdateRegionLinker> updateRegionLinkers, ErrorSourceSet errorSources,
     Func <ModificationErrorDictionary, IEnumerable <ChildType> > childGetter)
 {
     Id = id;
     UpdateRegionLinkers = updateRegionLinkers;
     ErrorSources        = errorSources;
     ChildGetter         = childGetter;
 }
Пример #2
0
 internal FormItem(
     FormItemSetup setup, IReadOnlyCollection <PhrasingComponent> label, IReadOnlyCollection <FlowComponent> content, EwfValidation validation)
 {
     Setup          = setup ?? new FormItemSetup();
     this.label     = label;
     this.content   = content;
     Validation     = validation;
     ErrorSourceSet = validation != null ? new ErrorSourceSet(validations: validation.ToCollection()) : null;
 }
Пример #3
0
 internal FormItem(
     FormItemSetup setup, IReadOnlyCollection <PhrasingComponent> label, IReadOnlyCollection <FlowComponent> content,
     IReadOnlyCollection <EwfValidation> validations)
 {
     Setup            = setup ?? new FormItemSetup();
     this.label       = label;
     this.content     = content;
     this.validations = validations;
     ErrorSourceSet   = validations.Any() ? new ErrorSourceSet(validations: validations) : null;
 }
 /// <summary>
 /// Creates a modification-error container with the specified sources.
 /// </summary>
 public FlowErrorContainer(ErrorSourceSet errorSources, ErrorDisplayStyle <FlowComponent> displayStyle, bool disableFocusabilityOnError = false)
 {
     children = new IdentifiedFlowComponent(
         () => new IdentifiedComponentData <FlowComponentOrNode>(
             "",
             Enumerable.Empty <UpdateRegionLinker>(),
             errorSources,
             errorsBySource => displayStyle.GetComponents(
                 errorSources,
                 errorSources.Validations.SelectMany(errorsBySource.GetValidationErrors)
                 .Select(i => new TrustedHtmlString(HttpUtility.HtmlEncode(i)))
                 .Concat(errorsBySource.GetGeneralErrors()),
                 !disableFocusabilityOnError))).ToCollection();
 }
Пример #5
0
 internal static DisplayableElementLocalData GetErrorFocusableElementLocalData(
     ElementContext context, string elementName, ErrorSourceSet errorSources, IReadOnlyCollection <ElementAttribute> attributes) =>
 new DisplayableElementLocalData(
     elementName,
     new FocusabilityCondition(false, errorFocusabilitySources: errorSources),
     isFocused => {
     if (isFocused)
     {
         attributes = (attributes ?? Enumerable.Empty <ElementAttribute>()).Append(new ElementAttribute("tabindex", "-1")).Materialize();
     }
     return(new DisplayableElementFocusDependentData(
                attributes: attributes,
                includeIdAttribute: isFocused,
                jsInitStatements: isFocused
                                                                   ? "document.getElementById( '{0}' ).focus(); document.getElementById( '{0}' ).scrollIntoView( {{ behavior: 'smooth', block: 'start' }} );"
                .FormatWith(context.Id)
                                                                   : ""));
 });
Пример #6
0
 IReadOnlyCollection <FlowComponent> ErrorDisplayStyle <FlowComponent> .GetComponents(
     ErrorSourceSet errorSources, IEnumerable <TrustedHtmlString> errors, bool componentsFocusableOnError) =>
 componentGetter(errorSources, errors, componentsFocusableOnError);