@serenity-is/corelib / DateEditor
Class: DateEditor<P>
Defined in: src/ui/editors/dateeditor.tsx:25
An editor that renders a date input with a date picker.
Extends
EditorWidget<P>
Type Parameters
P
P extends DateEditorOptions = DateEditorOptions
Widget props type.
Implements
Constructors
Constructor
new DateEditor<
P>(props):DateEditor<P>
Defined in: src/ui/editors/dateeditor.tsx:38
Creates a date editor.
Parameters
props
EditorProps<P>
Widget props.
Returns
DateEditor<P>
Overrides
Properties
domNode
readonlydomNode:HTMLInputElement
Defined in: src/ui/editors/dateeditor.tsx:32
The text input element that backs the editor.
Overrides
idPrefix
readonlyidPrefix:string
Defined in: src/ui/widgets/widget.ts:96
The id prefix used for this widget's child element ids.
Inherited from
options
protectedreadonlyoptions:WidgetProps<EditorProps<P>>
Defined in: src/ui/widgets/widget.ts:92
The widget's options/props.
Inherited from
uniqueName
readonlyuniqueName:string
Defined in: src/ui/widgets/widget.ts:94
A unique name for this widget instance, used for event namespacing.
Inherited from
[typeInfo]
static[typeInfo]:EditorTypeInfo<"Serenity.">
Defined in: src/ui/editors/dateeditor.tsx:26
Implementation of
Overrides
dateInputChange()
staticdateInputChange: (e) =>void
Defined in: src/ui/editors/dateeditor.tsx:316
Handles date input change events.
Parameters
e
Event
Returns
void
defaultDeferInit
staticdefaultDeferInit:boolean=false
Defined in: src/ui/widgets/widget.ts:106
Whether the classes that neither have a DeferInitAttribute (see Attributes.deferInit) nor override
deferredInit, nor have a base class that says true or false, defer their initialization; false by
default. An application whose widgets are written for deferred
initialization turns it on in its script init, before any widget is created.
Inherited from
isComponent
readonlystaticisComponent:true=true
Defined in: src/ui/widgets/widget.ts:530
Inherited from
useFlatpickr
staticuseFlatpickr:boolean
Defined in: src/ui/editors/dateeditor.tsx:328
Whether to prefer flatpickr over jQuery UI datepicker.
Accessors
element
Get Signature
get element():
Fluent
Defined in: src/ui/widgets/widget.ts:216
Returns a Fluent(this.domNode) object
Returns
Inherited from
initialized
Get Signature
get
protectedinitialized():boolean
Defined in: src/ui/widgets/widget.ts:137
Whether the widget is initialized: always for one that initializes in its constructor, and for one that defers its initialization (see isDeferredInit), once its deferredInit is done.
Returns
boolean
Inherited from
props
Get Signature
get props():
WidgetProps<P>
Defined in: src/ui/widgets/widget.ts:503
Returns the widget's props/options.
Returns
WidgetProps<P>
Inherited from
readOnly
Get Signature
get readOnly():
boolean
Defined in: src/ui/editors/editorwidget.ts:42
Returns whether the editor is read-only.
Returns
boolean
True when read-only.
Set Signature
set readOnly(
value):void
Defined in: src/ui/editors/editorwidget.ts:48
Sets whether the editor is read-only.
Parameters
value
boolean
Returns
void
Inherited from
usesDeferredInit
Get Signature
get
protectedusesDeferredInit():boolean
Defined in: src/ui/widgets/widget.ts:129
Whether this widget defers its initialization, see isDeferredInit.
Returns
boolean
Inherited from
value
Get Signature
get value():
string
Defined in: src/ui/editors/dateeditor.tsx:151
Returns the current date value.
Returns
string
The date value.
Set Signature
set value(
v):void
Defined in: src/ui/editors/dateeditor.tsx:173
Sets the date value.
Parameters
v
string
The date value to set.
Returns
void
valueAsDate
Get Signature
get valueAsDate():
Date
Defined in: src/ui/editors/dateeditor.tsx:188
Returns the current date value as a Date.
Returns
Date
The date value.
Set Signature
set valueAsDate(
v):void
Defined in: src/ui/editors/dateeditor.tsx:203
Sets the date value as a Date.
Parameters
v
Date
The date value to set.
Returns
void
Methods
addCssClass()
protectedaddCssClass():void
Defined in: src/ui/widgets/widget.ts:223
Adds the widget's CSS class to its DOM node.
Returns
void
Inherited from
addValidationRule()
Call Signature
addValidationRule(
rule,uniqueName?):void
Defined in: src/ui/widgets/widget.ts:267
Adds a validation rule to the widget's DOM node.
Parameters
rule
(input) => string
The validation rule function, or a unique name when the two-argument overload is used.
uniqueName?
string
A unique name for the rule, or the rule function when the two-argument overload is used.
Returns
void
Inherited from
EditorWidget.addValidationRule
Call Signature
addValidationRule(
uniqueName,rule):void
Defined in: src/ui/widgets/widget.ts:268
Adds a validation rule to the widget's DOM node.
Parameters
uniqueName
string
A unique name for the rule, or the rule function when the two-argument overload is used.
rule
(input) => string
The validation rule function, or a unique name when the two-argument overload is used.
Returns
void
Inherited from
EditorWidget.addValidationRule
afterRender()
protectedafterRender(callback):void
Defined in: src/ui/widgets/widget.ts:359
Queues a callback to run after the widget's contents are rendered.
Parameters
callback
() => void
The callback to run after rendering.
Returns
void
Inherited from
byId()
protectedbyId<TElement>(id):Fluent<TElement>
Defined in: src/ui/widgets/widget.ts:279
Finds a child element by its prefix-relative id.
Type Parameters
TElement
TElement extends HTMLElement = HTMLElement
Parameters
id
string
The id relative to the widget's id prefix.
Returns
Fluent<TElement>
A Fluent wrapper for the matching element.
Inherited from
change()
change(
handler):void
Defined in: src/ui/widgets/widget.ts:310
Registers a change handler on the widget's DOM node.
Parameters
handler
(e) => void
The change event handler.
Returns
void
Inherited from
changeSelect2()
changeSelect2(
handler):void
Defined in: src/ui/widgets/widget.ts:319
Registers a change handler that ignores changes originating from
combobox setting values.
Parameters
handler
(e) => void
The change event handler.
Returns
void
Inherited from
createFlatPickrTrigger()
createFlatPickrTrigger():
HTMLElement
Defined in: src/ui/editors/dateeditor.tsx:368
Creates the flatpickr trigger button next to the input.
Returns
HTMLElement
The trigger element.
deferredInit()
protecteddeferredInit():void|PromiseLike<void>
Defined in: src/ui/widgets/widget.ts:440
Does the initialization of a widget that defers it (see isDeferredInit), once, when init or
initAsync is called after all its constructors are done. The base classes initialize what their
constructors would, e.g. the contents, the form or the columns, and a subclass does the work its constructor
would do after await super.deferredInit(), which may wait too. The part before its first await runs at once,
so a widget that is made and inited has its contents.
Returns
void | PromiseLike<void>
Inherited from
destroy()
destroy():
void
Defined in: src/ui/editors/dateeditor.tsx:126
Cleans up the date picker instance.
Returns
void
Overrides
findById()
protectedfindById<TElement>(id):TElement
Defined in: src/ui/widgets/widget.ts:291
Finds a child element by its prefix-relative id.
Type Parameters
TElement
TElement extends HTMLElement = HTMLElement
Parameters
id
string
The id relative to the widget's id prefix.
Returns
TElement
The matching element, or null if not found.
Inherited from
get_maxDate()
get_maxDate():
Date
Defined in: src/ui/editors/dateeditor.tsx:280
Returns the maximum allowed date as a Date.
Returns
Date
The maximum date.
get_maxValue()
get_maxValue():
string
Defined in: src/ui/editors/dateeditor.tsx:248
Returns the maximum allowed date value.
Returns
string
The maximum value.
get_minDate()
get_minDate():
Date
Defined in: src/ui/editors/dateeditor.tsx:264
Returns the minimum allowed date as a Date.
Returns
Date
The minimum date.
get_minValue()
get_minValue():
string
Defined in: src/ui/editors/dateeditor.tsx:232
Returns the minimum allowed date value.
Returns
string
The minimum value.
get_readOnly()
get_readOnly():
boolean
Defined in: src/ui/editors/dateeditor.tsx:211
Returns whether the editor is read-only.
Returns
boolean
True when read-only.
Implementation of
get_sqlMinMax()
get_sqlMinMax():
boolean
Defined in: src/ui/editors/dateeditor.tsx:296
Whether SQL min/max date bounds are applied.
Returns
boolean
True when SQL bounds are set.
get_value()
get_value():
string
Defined in: src/ui/editors/dateeditor.tsx:138
Returns the current date value in "yyyy-MM-dd" format.
Returns
string
The date value, or null when empty.
Implementation of
getCssClass()
protectedgetCssClass():string
Defined in: src/ui/widgets/widget.ts:231
Returns the CSS class(es) applied to the widget's DOM node.
Returns
string
The space-separated CSS class string.
Inherited from
getCustomAttribute()
protectedgetCustomAttribute<TAttr>(attrType,inherit):TAttr
Defined in: src/ui/widgets/widget.ts:351
Returns a custom attribute applied to the widget's type.
Type Parameters
TAttr
TAttr extends CustomAttribute
Parameters
attrType
(...args) => TAttr
The attribute type to look up.
inherit
boolean = true
Whether to search inherited types; defaults to true.
Returns
TAttr
The matching attribute, or null.
Inherited from
EditorWidget.getCustomAttribute
getFlatpickrOptions()
getFlatpickrOptions(
input):any
Defined in: src/ui/editors/dateeditor.tsx:335
Returns the flatpickr options for the given input.
Parameters
input
HTMLElement
The input element.
Returns
any
Flatpickr options.
getGridField()
getGridField():
Fluent
Defined in: src/ui/widgets/widget.ts:302
Returns the closest .field element containing the widget's DOM node.
Returns
A Fluent wrapper for the grid field.
Inherited from
init()
init():
this
Defined in: src/ui/widgets/widget.ts:375
Initializes the widget: one that defers its initialization (see isDeferredInit) starts it, and it may end later, see initAsync; others are initialized by their constructors already.
Returns
this
This widget instance.
Inherited from
initAsync()
initAsync():
Promise<DateEditor<P>>
Defined in: src/ui/widgets/widget.ts:388
Initializes the widget once and waits until it is initialized: one that defers its initialization (see isDeferredInit) runs its deferredInit, the first time it is called; others are initialized by their constructors.
Returns
Promise<DateEditor<P>>
A promise of this widget, which is rejected when its initialization fails.
Inherited from
initNow()
protectedinitNow():boolean
Defined in: src/ui/widgets/widget.ts:146
Starts the initialization of a widget that defers it, if it hasn't started, and tells whether it is
initialized now, e.g. as it had nothing to wait for. A method that needs the widget initialized waits for
initAsync when it is not, e.g. if (!this.initNow()) return void this.initAsync().then(...).
Returns
boolean
Inherited from
internalRenderContents()
internalRenderContents():
void
Defined in: src/ui/widgets/widget.ts:462
Renders the widget's contents and runs any queued after-render callbacks.
Returns
void
Inherited from
EditorWidget.internalRenderContents
legacyTemplateRender()
protectedlegacyTemplateRender():boolean
Defined in: src/ui/widgets/widget.ts:487
Renders the widget from a legacy getTemplate string, if defined.
Returns
boolean
True if a legacy template was rendered.
Inherited from
EditorWidget.legacyTemplateRender
render()
render():
any
Defined in: src/ui/widgets/widget.ts:449
Returns the main element for this widget or the document fragment. As widgets may get their elements from props unlike regular JSX widgets, this method should not be overridden. Override renderContents() instead.
Returns
any
Inherited from
renderContents()
protectedrenderContents():any
Defined in: src/ui/widgets/widget.ts:477
Renders the widget's contents. Override this to provide custom content.
Returns
any
The rendered contents.
Inherited from
set_maxDate()
set_maxDate(
value):void
Defined in: src/ui/editors/dateeditor.tsx:288
Sets the maximum allowed date as a Date.
Parameters
value
Date
The maximum date.
Returns
void
set_maxValue()
set_maxValue(
value):void
Defined in: src/ui/editors/dateeditor.tsx:256
Sets the maximum allowed date value.
Parameters
value
string
The maximum value.
Returns
void
set_minDate()
set_minDate(
value):void
Defined in: src/ui/editors/dateeditor.tsx:272
Sets the minimum allowed date as a Date.
Parameters
value
Date
The minimum date.
Returns
void
set_minValue()
set_minValue(
value):void
Defined in: src/ui/editors/dateeditor.tsx:240
Sets the minimum allowed date value.
Parameters
value
string
The minimum value.
Returns
void
set_readOnly()
set_readOnly(
value):void
Defined in: src/ui/editors/dateeditor.tsx:219
Sets whether the editor is read-only.
Parameters
value
boolean
True to enable read-only mode.
Returns
void
Implementation of
set_sqlMinMax()
set_sqlMinMax(
value):void
Defined in: src/ui/editors/dateeditor.tsx:304
Sets whether SQL min/max date bounds are applied.
Parameters
value
boolean
True to apply SQL bounds.
Returns
void
set_value()
set_value(
value):void
Defined in: src/ui/editors/dateeditor.tsx:159
Sets the date value.
Parameters
value
string
The date value to set.
Returns
void
Implementation of
setToToday()
setToToday(
triggerChange?):void
Defined in: src/ui/editors/dateeditor.tsx:118
Sets the value to today's date.
Parameters
triggerChange?
boolean
When true, triggers a change event.
Returns
void
syncOrAsyncThen()
protectedsyncOrAsyncThen<T>(syncMethod,asyncMethod,then):void
Defined in: src/ui/widgets/widget.ts:514
Runs a method synchronously or asynchronously depending on the widget's
useAsync flag, then invokes a continuation.
Type Parameters
T
T
Parameters
syncMethod
() => T
The synchronous method to run.
asyncMethod
() => PromiseLike<T>
The asynchronous method to run.
then
(v) => void
The continuation invoked with the result.
Returns
void
Inherited from
useIdPrefix()
protecteduseIdPrefix():IdPrefixType
Defined in: src/ui/widgets/widget.ts:525
Returns an id prefix helper for resolving child element ids.
Returns
An IdPrefixType proxy for this widget's id prefix.
Inherited from
create()
staticcreate<TWidget,P>(params):TWidget
Defined in: src/ui/widgets/widget.ts:333
Creates a widget instance from the given params, appending its element to the container and invoking the init/init callbacks.
Type Parameters
TWidget
TWidget extends Widget<P>
P
P
Parameters
params
CreateWidgetParams<TWidget, P>
The widget creation params.
Returns
TWidget
The created widget instance.
Inherited from
createDefaultElement()
staticcreateDefaultElement():HTMLInputElement
Defined in: src/ui/editors/dateeditor.tsx:30
Creates the default text input element for the date editor.
Returns
HTMLInputElement
The input element.
Overrides
EditorWidget.createDefaultElement
dateInputKeyup()
staticdateInputKeyup(e):void
Defined in: src/ui/editors/dateeditor.tsx:323
Handles keyup on date inputs to normalize typed dates.
Parameters
e
KeyboardEvent
Keyboard event.
Returns
void
getWidgetName()
staticgetWidgetName(type):string
Defined in: src/ui/widgets/widget.ts:256
Returns the widget name for a type, used for association and unique names.
Parameters
type
Function
The widget type.
Returns
string
The widget name.
Inherited from
isDeferredInit()
staticisDeferredInit(type,requested?):boolean
Defined in: src/ui/widgets/widget.ts:118
Gets whether a widget of a type defers its initialization to deferredInit, which init or
initAsync runs once all the constructors are done, and which may wait. It is as the DeferInitAttribute
(see Attributes.deferInit) of the type or a base class says, true for a class that overrides
deferredInit, else as defaultDeferInit says. It throws when the type and its base classes say
conflicting things, e.g. a class has false but overrides deferredInit.
Parameters
type
Function
The widget type.
requested?
boolean
Whether the creator of the widget asks for it, see WidgetProps.deferInit, which counts
only for a class whose own attribute says "optional".
Returns
boolean
Inherited from
registerClass()
protectedstaticregisterClass<TypeName>(typeName,intfAndAttr?):ClassTypeInfo<TypeName>
Defined in: src/ui/widgets/widget.ts:538
Registers this type as a class with the given type name.
Type Parameters
TypeName
TypeName
Parameters
typeName
StringLiteral<TypeName>
The type name to register.
intfAndAttr?
(InterfaceType | AttributeSpecifier)[]
Optional interfaces and attributes.
Returns
ClassTypeInfo<TypeName>
The class type info.
Inherited from
registerEditor()
protectedstaticregisterEditor<TypeName>(typeName,intfAndAttr?):EditorTypeInfo<TypeName>
Defined in: src/ui/widgets/widget.ts:553
Registers this type as an editor with the given type name.
Type Parameters
TypeName
TypeName
Parameters
typeName
StringLiteral<TypeName>
The type name to register.
intfAndAttr?
(InterfaceType | AttributeSpecifier)[]
Optional interfaces and attributes.
Returns
EditorTypeInfo<TypeName>
The editor type info.
Inherited from
uiPickerZIndexWorkaround()
staticuiPickerZIndexWorkaround(el):void
Defined in: src/ui/editors/dateeditor.tsx:377
Applies a z-index workaround for the jQuery UI datepicker popup.
Parameters
el
The input element or array-like collection.
HTMLElement | ArrayLike<HTMLElement>
Returns
void