| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| part of $LIBRARYNAME; |
| |
| $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS implements |
| HiddenInputElement, |
| SearchInputElement, |
| TextInputElement, |
| UrlInputElement, |
| TelephoneInputElement, |
| EmailInputElement, |
| PasswordInputElement, |
| DateInputElement, |
| MonthInputElement, |
| WeekInputElement, |
| TimeInputElement, |
| LocalDateTimeInputElement, |
| NumberInputElement, |
| RangeInputElement, |
| CheckboxInputElement, |
| RadioButtonInputElement, |
| FileUploadInputElement, |
| SubmitButtonInputElement, |
| ImageButtonInputElement, |
| ResetButtonInputElement, |
| ButtonInputElement { |
| |
| factory InputElement({String$NULLABLE type}) { |
| InputElement e = document.createElement("input") $#NULLSAFECAST(as InputElement); |
| if (type != null) { |
| try { |
| // IE throws an exception for unknown types. |
| e.type = type; |
| } catch(_) {} |
| } |
| return e; |
| } |
| |
| $!MEMBERS |
| } |
| |
| |
| // Interfaces representing the InputElement APIs which are supported |
| // for the various types of InputElement. From: |
| // https://w3c.github.io/html/sec-forms.html#the-input-element. |
| |
| /** |
| * Exposes the functionality common between all InputElement types. |
| */ |
| abstract class InputElementBase implements Element { |
| bool get autofocus; |
| set autofocus(bool value); |
| |
| bool get disabled; |
| set disabled(bool value); |
| |
| bool get incremental; |
| set incremental(bool value); |
| |
| bool get indeterminate; |
| set indeterminate(bool value); |
| |
| String get name; |
| set name(String value); |
| |
| String get value; |
| set value(String$NULLABLE value); |
| |
| List<Node> get labels; |
| |
| String get validationMessage; |
| |
| ValidityState get validity; |
| |
| bool get willValidate; |
| |
| bool checkValidity(); |
| |
| void setCustomValidity(String error); |
| } |
| |
| /** |
| * Hidden input which is not intended to be seen or edited by the user. |
| */ |
| abstract class HiddenInputElement implements InputElementBase { |
| factory HiddenInputElement() => new InputElement(type: 'hidden'); |
| } |
| |
| |
| /** |
| * Base interface for all inputs which involve text editing. |
| */ |
| abstract class TextInputElementBase implements InputElementBase { |
| String get autocomplete; |
| set autocomplete(String value); |
| |
| int get maxLength; |
| set maxLength(int value); |
| |
| String get pattern; |
| set pattern(String value); |
| |
| String get placeholder; |
| set placeholder(String value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| int get size; |
| set size(int value); |
| |
| void select(); |
| |
| String$NULLABLE get selectionDirection; |
| set selectionDirection(String$NULLABLE value); |
| |
| int$NULLABLE get selectionEnd; |
| set selectionEnd(int$NULLABLE value); |
| |
| int$NULLABLE get selectionStart; |
| set selectionStart(int$NULLABLE value); |
| |
| void setSelectionRange(int start, int end, [String$NULLABLE direction]); |
| } |
| |
| /** |
| * Similar to [TextInputElement], but on platforms where search is styled |
| * differently this will get the search style. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.FIREFOX) |
| @SupportedBrowser(SupportedBrowser.IE, '10') |
| @SupportedBrowser(SupportedBrowser.SAFARI) |
| abstract class SearchInputElement implements TextInputElementBase { |
| factory SearchInputElement() => new InputElement(type: 'search'); |
| |
| String get dirName; |
| set dirName(String value); |
| |
| Element$NULLABLE get list; |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'search')).type == 'search'; |
| } |
| } |
| |
| /** |
| * A basic text input editor control. |
| */ |
| abstract class TextInputElement implements TextInputElementBase { |
| factory TextInputElement() => new InputElement(type: 'text'); |
| |
| String get dirName; |
| set dirName(String value); |
| |
| Element$NULLABLE get list; |
| } |
| |
| /** |
| * A control for editing an absolute URL. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.FIREFOX) |
| @SupportedBrowser(SupportedBrowser.IE, '10') |
| @SupportedBrowser(SupportedBrowser.SAFARI) |
| abstract class UrlInputElement implements TextInputElementBase { |
| factory UrlInputElement() => new InputElement(type: 'url'); |
| |
| Element$NULLABLE get list; |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'url')).type == 'url'; |
| } |
| } |
| |
| /** |
| * Represents a control for editing a telephone number. |
| * |
| * This provides a single line of text with minimal formatting help since |
| * there is a wide variety of telephone numbers. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.FIREFOX) |
| @SupportedBrowser(SupportedBrowser.IE, '10') |
| @SupportedBrowser(SupportedBrowser.SAFARI) |
| abstract class TelephoneInputElement implements TextInputElementBase { |
| factory TelephoneInputElement() => new InputElement(type: 'tel'); |
| |
| Element$NULLABLE get list; |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'tel')).type == 'tel'; |
| } |
| } |
| |
| /** |
| * An e-mail address or list of e-mail addresses. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.FIREFOX) |
| @SupportedBrowser(SupportedBrowser.IE, '10') |
| @SupportedBrowser(SupportedBrowser.SAFARI) |
| abstract class EmailInputElement implements TextInputElementBase { |
| factory EmailInputElement() => new InputElement(type: 'email'); |
| |
| String get autocomplete; |
| set autocomplete(String value); |
| |
| bool get autofocus; |
| set autofocus(bool value); |
| |
| Element$NULLABLE get list; |
| |
| int get maxLength; |
| set maxLength(int value); |
| |
| bool get multiple; |
| set multiple(bool value); |
| |
| String get pattern; |
| set pattern(String value); |
| |
| String get placeholder; |
| set placeholder(String value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| int get size; |
| set size(int value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'email')).type == 'email'; |
| } |
| } |
| |
| /** |
| * Text with no line breaks (sensitive information). |
| */ |
| abstract class PasswordInputElement implements TextInputElementBase { |
| factory PasswordInputElement() => new InputElement(type: 'password'); |
| } |
| |
| /** |
| * Base interface for all input element types which involve ranges. |
| */ |
| abstract class RangeInputElementBase implements InputElementBase { |
| |
| Element$NULLABLE get list; |
| |
| String get max; |
| set max(String value); |
| |
| String get min; |
| set min(String value); |
| |
| String get step; |
| set step(String value); |
| |
| num get valueAsNumber; |
| set valueAsNumber(num value); |
| |
| void stepDown([int$NULLABLE n]); |
| |
| void stepUp([int$NULLABLE n]); |
| } |
| |
| /** |
| * A date (year, month, day) with no time zone. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME, '25') |
| abstract class DateInputElement implements RangeInputElementBase { |
| factory DateInputElement() => new InputElement(type: 'date'); |
| |
| DateTime get valueAsDate; |
| set valueAsDate(DateTime value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'date')).type == 'date'; |
| } |
| } |
| |
| /** |
| * A date consisting of a year and a month with no time zone. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME, '25') |
| abstract class MonthInputElement implements RangeInputElementBase { |
| factory MonthInputElement() => new InputElement(type: 'month'); |
| |
| DateTime get valueAsDate; |
| set valueAsDate(DateTime value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'month')).type == 'month'; |
| } |
| } |
| |
| /** |
| * A date consisting of a week-year number and a week number with no time zone. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME, '25') |
| abstract class WeekInputElement implements RangeInputElementBase { |
| factory WeekInputElement() => new InputElement(type: 'week'); |
| |
| DateTime get valueAsDate; |
| set valueAsDate(DateTime value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'week')).type == 'week'; |
| } |
| } |
| |
| /** |
| * A time (hour, minute, seconds, fractional seconds) with no time zone. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| abstract class TimeInputElement implements RangeInputElementBase { |
| factory TimeInputElement() => new InputElement(type: 'time'); |
| |
| DateTime get valueAsDate; |
| set valueAsDate(DateTime value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'time')).type == 'time'; |
| } |
| } |
| |
| /** |
| * A date and time (year, month, day, hour, minute, second, fraction of a |
| * second) with no time zone. |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME, '25') |
| abstract class LocalDateTimeInputElement implements RangeInputElementBase { |
| factory LocalDateTimeInputElement() => |
| new InputElement(type: 'datetime-local'); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'datetime-local')).type == 'datetime-local'; |
| } |
| } |
| |
| /** |
| * A numeric editor control. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.IE) |
| @SupportedBrowser(SupportedBrowser.SAFARI) |
| abstract class NumberInputElement implements RangeInputElementBase { |
| factory NumberInputElement() => new InputElement(type: 'number'); |
| |
| String get placeholder; |
| set placeholder(String value); |
| |
| bool get readOnly; |
| set readOnly(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'number')).type == 'number'; |
| } |
| } |
| |
| /** |
| * Similar to [NumberInputElement] but the browser may provide more optimal |
| * styling (such as a slider control). |
| * |
| * Use [supported] to check if this is supported on the current platform. |
| */ |
| @SupportedBrowser(SupportedBrowser.CHROME) |
| @SupportedBrowser(SupportedBrowser.IE, '10') |
| abstract class RangeInputElement implements RangeInputElementBase { |
| factory RangeInputElement() => new InputElement(type: 'range'); |
| |
| /// Returns true if this input type is supported on the current platform. |
| static bool get supported { |
| return (new InputElement(type: 'range')).type == 'range'; |
| } |
| } |
| |
| /** |
| * A boolean editor control. |
| * |
| * Note that if [indeterminate] is set then this control is in a third |
| * indeterminate state. |
| */ |
| abstract class CheckboxInputElement implements InputElementBase { |
| factory CheckboxInputElement() => new InputElement(type: 'checkbox'); |
| |
| bool get checked; |
| set checked(bool value); |
| |
| bool get required; |
| set required(bool value); |
| } |
| |
| |
| /** |
| * A control that when used with other [ReadioButtonInputElement] controls |
| * forms a radio button group in which only one control can be checked at a |
| * time. |
| * |
| * Radio buttons are considered to be in the same radio button group if: |
| * |
| * * They are all of type 'radio'. |
| * * They all have either the same [FormElement] owner, or no owner. |
| * * Their name attributes contain the same name. |
| */ |
| abstract class RadioButtonInputElement implements InputElementBase { |
| factory RadioButtonInputElement() => new InputElement(type: 'radio'); |
| |
| bool get checked; |
| set checked(bool value); |
| |
| bool get required; |
| set required(bool value); |
| } |
| |
| /** |
| * A control for picking files from the user's computer. |
| */ |
| abstract class FileUploadInputElement implements InputElementBase { |
| factory FileUploadInputElement() => new InputElement(type: 'file'); |
| |
| String get accept; |
| set accept(String value); |
| |
| bool get multiple; |
| set multiple(bool value); |
| |
| bool get required; |
| set required(bool value); |
| |
| List<File>$NULLABLE files; |
| } |
| |
| /** |
| * A button, which when clicked, submits the form. |
| */ |
| abstract class SubmitButtonInputElement implements InputElementBase { |
| factory SubmitButtonInputElement() => new InputElement(type: 'submit'); |
| |
| String get formAction; |
| set formAction(String value); |
| |
| String get formEnctype; |
| set formEnctype(String value); |
| |
| String get formMethod; |
| set formMethod(String value); |
| |
| bool get formNoValidate; |
| set formNoValidate(bool value); |
| |
| String get formTarget; |
| set formTarget(String value); |
| } |
| |
| /** |
| * Either an image which the user can select a coordinate to or a form |
| * submit button. |
| */ |
| abstract class ImageButtonInputElement implements InputElementBase { |
| factory ImageButtonInputElement() => new InputElement(type: 'image'); |
| |
| String get alt; |
| set alt(String value); |
| |
| String get formAction; |
| set formAction(String value); |
| |
| String get formEnctype; |
| set formEnctype(String value); |
| |
| String get formMethod; |
| set formMethod(String value); |
| |
| bool get formNoValidate; |
| set formNoValidate(bool value); |
| |
| String get formTarget; |
| set formTarget(String value); |
| |
| int get height; |
| set height(int value); |
| |
| String get src; |
| set src(String value); |
| |
| int get width; |
| set width(int value); |
| } |
| |
| /** |
| * A button, which when clicked, resets the form. |
| */ |
| abstract class ResetButtonInputElement implements InputElementBase { |
| factory ResetButtonInputElement() => new InputElement(type: 'reset'); |
| } |
| |
| /** |
| * A button, with no default behavior. |
| */ |
| abstract class ButtonInputElement implements InputElementBase { |
| factory ButtonInputElement() => new InputElement(type: 'button'); |
| } |