DateTimeComponent
A component that displays and edits a date and time.
You can add this component using SettingEx.addDateTime.
In order to add the styles for the component, use initPluginContext in your plugin’s onload() function.
Alternatively, you can copy styles from https://unpkg.com/@mnaoumov/obsidian-lib/dist/styles.css.
Import:
import { DateTimeComponent } from '@mnaoumov/obsidian-lib/setting-components/date-time-component';Signature:
export class DateTimeComponent extends TypedRangeTextComponent<Date>Extends: TypedRangeTextComponent<Date>
Constructor
new DateTimeComponent(containerEl: HTMLElement)Creates a new date and time component.
Properties
| Property | Type | Description |
|---|---|---|
| inputEl | HTMLInputElement | An input element of the component. (Inherited from TypedRangeTextComponent) |
| onChange | (callback: (newValue: Date) => void) => this | Sets a callback function to be called when the value of the component changes. (Inherited from TypedRangeTextComponent) |
| textComponent | TextComponent | The inner text component. (Inherited from TypedRangeTextComponent) |
| validatorEl | ValidatorElement | A validator element of the component. (Inherited from TypedRangeTextComponent) |
Methods
| Method | Returns | Description |
|---|---|---|
| getValue() | Date | Gets the value of the component. (Inherited from TypedRangeTextComponent) |
| onChange(callback) | this | Sets the callback function to be called when the component is changed. (Inherited from TypedRangeTextComponent) |
| onChanged() | void | Called when the component is changed. (Inherited from TypedRangeTextComponent) |
| setDisabled(isDisabled) | this | Sets the disabled state of the component. (Inherited from TypedRangeTextComponent) |
| setMax(max) | this | Sets the maximum value of the component. (Inherited from TypedRangeTextComponent) |
| setMin(min) | this | Sets the minimum value of the component. (Inherited from TypedRangeTextComponent) |
| setStep(step) | this | Sets the step value of the component. (Inherited from TypedRangeTextComponent) |
| setValue(value) | this | Sets the value of the component. (Inherited from TypedRangeTextComponent) |
| valueFromString($string) | Date | Converts a string to a date. |
| valueToString(value) | string | Converts a date to a string. |
Links to this page: