devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
81 lines (80 loc) • 2.66 kB
JavaScript
/**
* DevExtreme (esm/__internal/ui/date_box/m_date_box.strategy.native.js)
* Version: 24.2.6
* Build date: Mon Mar 17 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import _extends from "@babel/runtime/helpers/esm/extends";
import devices from "../../../core/devices";
import dateSerialization from "../../../core/utils/date_serialization";
import {
inputType
} from "../../../core/utils/support";
import DateBoxStrategy from "./m_date_box.strategy";
import dateUtils from "./m_date_utils";
class NativeStrategy extends DateBoxStrategy {
ctor(dateBox) {
super.ctor(dateBox);
this.NAME = "Native"
}
popupConfig(popupConfig) {
return _extends({}, popupConfig, {
width: "auto"
})
}
getParsedText(text) {
if (!text) {
return null
}
if ("datetime" === this.dateBox.option("type")) {
return new Date(text.replace(/-/g, "/").replace("T", " ").split(".")[0])
}
return dateUtils.fromStandardDateFormat(text)
}
renderPopupContent() {}
_getWidgetName() {}
_getWidgetOptions() {}
_getDateBoxType() {
let {
type: type
} = this.dateBox.option();
if (!dateUtils.SUPPORTED_FORMATS.includes(type)) {
type = "date"
} else if ("datetime" === type && !inputType(type)) {
type = "datetime-local"
}
return type
}
customizeButtons() {
const dropDownButton = this.dateBox.getButton("dropDown");
if (devices.real().android && dropDownButton) {
dropDownButton.on("click", (() => {
this.dateBox._input().get(0).click()
}))
}
}
getDefaultOptions() {
return {
mode: this._getDateBoxType()
}
}
getDisplayFormat(displayFormat) {
const type = this._getDateBoxType();
return displayFormat || dateUtils.FORMATS_MAP[type]
}
renderInputMinMax($input) {
const type = this.dateBox.option("type");
const format = {
datetime: "yyyy-MM-ddTHH:mm:ss",
date: "yyyy-MM-dd",
time: "HH:mm:ss"
} [type] ?? "yyyy-MM-dd";
$input.attr({
min: dateSerialization.serializeDate(this.dateBox.dateOption("min"), format),
max: dateSerialization.serializeDate(this.dateBox.dateOption("max"), format)
})
}
}
export default NativeStrategy;