UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

126 lines (124 loc) 4.1 kB
/** * DevExtreme (cjs/__internal/ui/date_box/m_date_box.strategy.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/ */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _events_engine = _interopRequireDefault(require("../../../common/core/events/core/events_engine")); var _date = _interopRequireDefault(require("../../../common/core/localization/date")); var _class = _interopRequireDefault(require("../../../core/class")); var _renderer = _interopRequireDefault(require("../../../core/renderer")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e } } class DateBoxStrategy extends(_class.default.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 || (0, _renderer.default)("<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.default.abstract() } _getWidgetName() { _class.default.abstract() } getDefaultOptions() { return { mode: "text" } } getDisplayFormat(displayFormat) { _class.default.abstract() } supportedKeys() {} getKeyboardListener() {} customizeButtons() {} getParsedText(text, format) { const value = _date.default.parse(text, format); return value || _date.default.parse(text) } renderInputMinMax() {} renderOpenedState() { this._updateValue() } popupConfig(popupConfig) { _class.default.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(); _events_engine.default.off($popupContent, "mousedown"); _events_engine.default.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"]) } } var _default = exports.default = DateBoxStrategy;