/// <summary> /// Creates a setup object for a standard text control. /// </summary> /// <param name="displaySetup"></param> /// <param name="widthOverride">The width of the control. This overrides any value that may be specified via CSS. If no width is specified via CSS and you /// pass null for this parameter, the width will be based on the maximum number of characters a user can input.</param> /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param> /// <param name="classes">The classes on the control.</param> /// <param name="disableTrimming">Pass true to disable white-space trimming.</param> /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="checksSpellingAndGrammar">Pass true to enable spelling and grammar checking, false to disable it, and null for default behavior.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action. Currently has no /// effect for multiline controls.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static TextControlSetup Create( DisplaySetup displaySetup = null, ContentBasedLength widthOverride = null, int numberOfRows = 1, ElementClassSet classes = null, bool disableTrimming = false, string placeholder = "", string autoFillTokens = "", bool?checksSpellingAndGrammar = null, SpecifiedValue <FormAction> action = null, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new TextControlSetup( displaySetup, numberOfRows == 1 ? "text" : "", widthOverride, numberOfRows, false, classes, disableTrimming, false, placeholder, autoFillTokens, null, checksSpellingAndGrammar, action, null, valueChangedAction, pageModificationValue, null, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a setup object for a read-only text control. /// </summary> /// <param name="displaySetup"></param> /// <param name="widthOverride">The width of the control. This overrides any value that may be specified via CSS. If no width is specified via CSS and you /// pass null for this parameter, the width will be based on the maximum number of characters a user can input.</param> /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param> /// <param name="classes">The classes on the control.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static TextControlSetup CreateReadOnly( DisplaySetup displaySetup = null, ContentBasedLength widthOverride = null, int numberOfRows = 1, ElementClassSet classes = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new TextControlSetup( displaySetup, numberOfRows == 1 ? "text" : "", widthOverride, numberOfRows, true, classes, false, false, "", "", null, null, null, null, null, null, null, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a setup object for an obscured (i.e. password) text control. /// </summary> /// <param name="displaySetup"></param> /// <param name="widthOverride">The width of the control. This overrides any value that may be specified via CSS. If no width is specified via CSS and you /// pass null for this parameter, the width will be based on the maximum number of characters a user can input.</param> /// <param name="classes">The classes on the control.</param> /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> /// <returns></returns> public static TextControlSetup CreateObscured( DisplaySetup displaySetup = null, ContentBasedLength widthOverride = null, ElementClassSet classes = null, string placeholder = "", string autoFillTokens = "", SpecifiedValue <FormAction> action = null, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new TextControlSetup( displaySetup, "password", widthOverride, null, false, classes, true, false, placeholder, autoFillTokens, null, null, action, null, valueChangedAction, pageModificationValue, null, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a setup object for a checkbox list. /// </summary> /// <param name="items">The items in the list.</param> /// <param name="displaySetup"></param> /// <param name="includeSelectAndDeselectAllButtons"></param> /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param> /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static CheckboxListSetup <ItemIdType> Create <ItemIdType>( IEnumerable <SelectListItem <ItemIdType> > items, DisplaySetup displaySetup = null, bool includeSelectAndDeselectAllButtons = false, ContentBasedLength minColumnWidth = null, SpecifiedValue <FormAction> action = null, FormAction selectionChangedAction = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new CheckboxListSetup <ItemIdType>( displaySetup, includeSelectAndDeselectAllButtons, items, minColumnWidth, action, selectionChangedAction, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a change-based checkbox list, which is a checkbox list that is based on changes to the selections rather than the absolute set of selected /// items. /// </summary> /// <param name="items">The items in the list.</param> /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> /// <param name="displaySetup"></param> /// <param name="includeSelectAndDeselectAllButtons"></param> /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param> /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static CheckboxList <ItemIdType> Create <ItemIdType>( IEnumerable <ChangeBasedListItemWithSelectionState <ItemIdType> > items, out Action modificationMethod, DisplaySetup displaySetup = null, bool includeSelectAndDeselectAllButtons = false, ContentBasedLength minColumnWidth = null, SpecifiedValue <FormAction> action = null, FormAction selectionChangedAction = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { items = items.Materialize(); return(Create( from i in items select i.Item, from i in items where i.IsSelected select i.Item.Item.Id, out modificationMethod, displaySetup: displaySetup, includeSelectAndDeselectAllButtons: includeSelectAndDeselectAllButtons, minColumnWidth: minColumnWidth, uiSelectedItemIds: from i in items where i.IsSelectedInUi select i.Item.Item.Id, action: action, selectionChangedAction: selectionChangedAction, validationPredicate: validationPredicate, validationErrorNotifier: validationErrorNotifier)); }
/// <summary> /// Creates a change-based checkbox list, which is a checkbox list that is based on changes to the selections rather than the absolute set of selected /// items. /// </summary> /// <param name="items">The items in the list.</param> /// <param name="selectedItemIds">The selected-item IDs.</param> /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param> /// <param name="displaySetup"></param> /// <param name="includeSelectAndDeselectAllButtons"></param> /// <param name="minColumnWidth">The minimum width of each column in the list. Pass null to force a single column.</param> /// <param name="uiSelectedItemIds"></param> /// <param name="action">The action that will occur when the user hits Enter on any of the checkboxes. Pass null to use the current default action.</param> /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static CheckboxList <ItemIdType> Create <ItemIdType>( IEnumerable <ChangeBasedListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, out Action modificationMethod, DisplaySetup displaySetup = null, bool includeSelectAndDeselectAllButtons = false, ContentBasedLength minColumnWidth = null, IEnumerable <ItemIdType> uiSelectedItemIds = null, SpecifiedValue <FormAction> action = null, FormAction selectionChangedAction = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { items = items.Materialize(); var selectedItemIdSet = selectedItemIds.ToImmutableHashSet(); ImmutableHashSet <ItemIdType> selectedItemIdsInPostBack = null; modificationMethod = () => { if (selectedItemIdsInPostBack == null) { return; } var changedItemIds = selectedItemIdsInPostBack.Except(selectedItemIdSet).Union(selectedItemIdSet.Except(selectedItemIdsInPostBack)).ToArray(); foreach (var i in items.Where(i => changedItemIds.Contains(i.Item.Id))) { i.ChangeHandler(selectedItemIdsInPostBack.Contains(i.Item.Id)); } }; return(new CheckboxList <ItemIdType>( CheckboxListSetup.Create( from i in items select i.Item, displaySetup: displaySetup, includeSelectAndDeselectAllButtons: includeSelectAndDeselectAllButtons, minColumnWidth: minColumnWidth, action: action, selectionChangedAction: selectionChangedAction, validationPredicate: validationPredicate, validationErrorNotifier: validationErrorNotifier), uiSelectedItemIds ?? selectedItemIdSet, validationMethod: (postBackValue, validator) => selectedItemIdsInPostBack = postBackValue.ToImmutableHashSet())); }
/// <summary> /// Creates a line-list item from this general list item. If you don't need to pass any arguments, don't use this method; general list items are implicitly /// converted to line-list items. /// </summary> /// <param name="item"></param> /// <param name="verticalAlignment">The vertical alignment of the item.</param> /// <param name="width">The width of the item.</param> public static LineListItem ToLineListItem( this ComponentListItem item, FlexboxVerticalAlignment verticalAlignment = FlexboxVerticalAlignment.NotSpecified, ContentBasedLength width = null) => new LineListItem(() => item.GetItemAndComponent(FlexboxVerticalAlignmentStatics.Class(verticalAlignment), width));
/// <summary> /// Creates a wrapping-list item from this general list item. If you don't need to pass any arguments, don't use this method; general list items are /// implicitly converted to wrapping-list items. /// </summary> /// <param name="item"></param> /// <param name="verticalAlignment">The vertical alignment of the item.</param> /// <param name="width">The width of the item.</param> public static WrappingListItem ToWrappingListItem( this ComponentListItem item, FlexboxVerticalAlignment verticalAlignment = FlexboxVerticalAlignment.NotSpecified, ContentBasedLength width = null) { return(new WrappingListItem(() => item.GetItemAndComponent(FlexboxVerticalAlignmentStatics.Class(verticalAlignment), width))); }
/// <summary> /// Creates a setup object for a read-only drop-down. /// </summary> /// <param name="items">The items in the list. There must be at least one.</param> /// <param name="displaySetup"></param> /// <param name="width">The width of the list. This overrides any value that may be specified via CSS. If no width is specified via CSS and you pass null /// for this parameter, the list will be just wide enough to show the selected item and will resize whenever the selected item is changed.</param> /// <param name="unlistedSelectedItemLabelGetter">A function that will be called if the selected item ID does not match any list item and is not the default /// value of the type. The function takes the selected item ID and returns the label of the unlisted selected item, which will appear before all other /// items in the list. The string " (invalid)" will be appended to the label.</param> /// <param name="placeholderText">The default-value placeholder's text. Do not pass null.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static DropDownSetup <ItemIdType> CreateReadOnly <ItemIdType>( IEnumerable <SelectListItem <ItemIdType> > items, DisplaySetup displaySetup = null, ContentBasedLength width = null, Func <ItemIdType, string> unlistedSelectedItemLabelGetter = null, string placeholderText = "Please select", Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) => new DropDownSetup <ItemIdType>( displaySetup, true, width, true, null, unlistedSelectedItemLabelGetter, placeholderText, items, "", null, null, null, null, validationPredicate, validationErrorNotifier);
/// <summary> /// Creates a setup object for a standard drop-down. /// </summary> /// <param name="items">The items in the list. There must be at least one.</param> /// <param name="displaySetup"></param> /// <param name="useNativeControl">Pass true to force the drop-down list to be a native control.</param> /// <param name="width">The width of the list. This overrides any value that may be specified via CSS. If no width is specified via CSS and you pass null /// for this parameter, the list will be just wide enough to show the selected item and will resize whenever the selected item is changed.</param> /// <param name="unlistedSelectedItemLabelGetter">A function that will be called if the selected item ID does not match any list item and is not the default /// value of the type. The function takes the selected item ID and returns the label of the unlisted selected item, which will appear before all other /// items in the list. The string " (invalid)" will be appended to the label.</param> /// <param name="placeholderText">The default-value placeholder's text. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="action">The action that will occur when the user hits Enter on the drop-down list. Pass null to use the current default action.</param> /// <param name="selectionChangedAction">The action that will occur when the selection is changed. Pass null for no action.</param> /// <param name="itemIdPageModificationValue"></param> /// <param name="itemMatchPageModificationSetups"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static DropDownSetup <ItemIdType> Create <ItemIdType>( IEnumerable <SelectListItem <ItemIdType> > items, DisplaySetup displaySetup = null, bool useNativeControl = false, ContentBasedLength width = null, Func <ItemIdType, string> unlistedSelectedItemLabelGetter = null, string placeholderText = "Please select", string autoFillTokens = "", SpecifiedValue <FormAction> action = null, FormAction selectionChangedAction = null, PageModificationValue <ItemIdType> itemIdPageModificationValue = null, IReadOnlyCollection <ListItemMatchPageModificationSetup <ItemIdType> > itemMatchPageModificationSetups = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) => new DropDownSetup <ItemIdType>( displaySetup, useNativeControl, width, false, null, unlistedSelectedItemLabelGetter, placeholderText, items, autoFillTokens, action, selectionChangedAction, itemIdPageModificationValue, itemMatchPageModificationSetups, validationPredicate, validationErrorNotifier);