blob: 19aa83869c833e5fdd1b3249ffa994ab89a8fbec [file] [log] [blame]
// 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$NULLABLE get disabled;
set disabled(bool$NULLABLE value);
bool$NULLABLE get incremental;
set incremental(bool$NULLABLE value);
bool$NULLABLE get indeterminate;
set indeterminate(bool$NULLABLE value);
String$NULLABLE get name;
set name(String$NULLABLE value);
String$NULLABLE get value;
set value(String$NULLABLE value);
List<Node>$NULLABLE 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$NULLABLE get maxLength;
set maxLength(int$NULLABLE value);
String get pattern;
set pattern(String value);
String get placeholder;
set placeholder(String value);
bool$NULLABLE get readOnly;
set readOnly(bool$NULLABLE value);
bool get required;
set required(bool value);
int$NULLABLE get size;
set size(int$NULLABLE 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$NULLABLE get dirName;
set dirName(String$NULLABLE 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$NULLABLE get dirName;
set dirName(String$NULLABLE 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$NULLABLE get maxLength;
set maxLength(int$NULLABLE value);
bool$NULLABLE get multiple;
set multiple(bool$NULLABLE value);
String get pattern;
set pattern(String value);
String get placeholder;
set placeholder(String value);
bool$NULLABLE get readOnly;
set readOnly(bool$NULLABLE value);
bool get required;
set required(bool value);
int$NULLABLE get size;
set size(int$NULLABLE 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$NULLABLE get max;
set max(String$NULLABLE value);
String$NULLABLE get min;
set min(String$NULLABLE value);
String$NULLABLE get step;
set step(String$NULLABLE value);
num$NULLABLE get valueAsNumber;
set valueAsNumber(num$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get readOnly;
set readOnly(bool$NULLABLE 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$NULLABLE get checked;
set checked(bool$NULLABLE 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$NULLABLE get checked;
set checked(bool$NULLABLE 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$NULLABLE get accept;
set accept(String$NULLABLE value);
bool$NULLABLE get multiple;
set multiple(bool$NULLABLE 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$NULLABLE get alt;
set alt(String$NULLABLE 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$NULLABLE get height;
set height(int$NULLABLE value);
String$NULLABLE get src;
set src(String$NULLABLE value);
int$NULLABLE get width;
set width(int$NULLABLE 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');
}