UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

115 lines (114 loc) 3.67 kB
/** * DevExtreme (esm/__internal/ui/date_box/m_date_box.strategy.js) * Version: 24.2.7 * Build date: Mon Apr 28 2025 * * Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import eventsEngine from "../../../common/core/events/core/events_engine"; import dateLocalization from "../../../common/core/localization/date"; import Class from "../../../core/class"; import $ from "../../../core/renderer"; class DateBoxStrategy extends(Class.inherit({})) { ctor(dateBox) { this.dateBox = dateBox } widgetOption(option) { var _this$_widget; return null === (_this$_widget = this._widget) || void 0 === _this$_widget ? void 0 : _this$_widget.option.apply(this._widget, arguments) } _renderWidget(element) { element = element || $("<div>"); this._widget = this._createWidget(element); this._widget.$element().appendTo(this._getWidgetContainer()) } _createWidget(element) { const widgetName = this._getWidgetName(); const widgetOptions = this._getWidgetOptions(); return this.dateBox._createComponent(element, widgetName, widgetOptions) } _getWidgetOptions() { Class.abstract() } _getWidgetName() { Class.abstract() } getDefaultOptions() { return { mode: "text" } } getDisplayFormat(displayFormat) { Class.abstract() } supportedKeys() {} getKeyboardListener() {} customizeButtons() {} getParsedText(text, format) { const value = dateLocalization.parse(text, format); return value || dateLocalization.parse(text) } renderInputMinMax() {} renderOpenedState() { this._updateValue() } popupConfig(popupConfig) { Class.abstract() } _dimensionChanged() { var _this$_getPopup; null === (_this$_getPopup = this._getPopup()) || void 0 === _this$_getPopup || _this$_getPopup.repaint() } renderPopupContent() { const popup = this._getPopup(); this._renderWidget(); const $popupContent = popup.$content().parent(); eventsEngine.off($popupContent, "mousedown"); eventsEngine.on($popupContent, "mousedown", this._preventFocusOnPopup.bind(this)) } _preventFocusOnPopup(e) { e.preventDefault() } _getWidgetContainer() { return this._getPopup().$content() } _getPopup() { return this.dateBox._popup } popupShowingHandler() {} popupHiddenHandler() {} _updateValue(preventDefaultValue) { var _this$_widget2; null === (_this$_widget2 = this._widget) || void 0 === _this$_widget2 || _this$_widget2.option("value", this.dateBoxValue()) } useCurrentDateByDefault() {} getDefaultDate() { return new Date } textChangedHandler() {} renderValue() { if (this.dateBox.option("opened")) { this._updateValue() } } getValue() { return this._widget.option("value") } isAdaptivityChanged() { return false } dispose() { const popup = this._getPopup(); if (popup) { popup.$content().empty() } } dateBoxValue(value, event) { if (arguments.length) { return this.dateBox.dateValue.apply(this.dateBox, arguments) } return this.dateBox.dateOption.apply(this.dateBox, ["value"]) } } export default DateBoxStrategy;