UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

61 lines (59 loc) • 2.36 kB
/** * DevExtreme (esm/__internal/filter_builder/between.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import $ from "../../core/renderer"; import { extend } from "../../core/utils/extend"; const FILTER_BUILDER_RANGE_CLASS = "dx-filterbuilder-range"; const FILTER_BUILDER_RANGE_START_CLASS = "dx-filterbuilder-range-start"; const FILTER_BUILDER_RANGE_END_CLASS = "dx-filterbuilder-range-end"; const FILTER_BUILDER_RANGE_SEPARATOR_CLASS = "dx-filterbuilder-range-separator"; const SEPARATOR = "\u2013"; function editorTemplate(conditionInfo, container) { const $editorStart = $("<div>").addClass("dx-filterbuilder-range-start"); const $editorEnd = $("<div>").addClass("dx-filterbuilder-range-end"); let values = conditionInfo.value || []; const getStartValue = function(rangeValues) { return rangeValues && rangeValues.length > 0 ? rangeValues[0] : null }; const getEndValue = function(rangeValues) { return rangeValues && 2 === rangeValues.length ? rangeValues[1] : null }; container.append($editorStart); container.append($("<span>").addClass("dx-filterbuilder-range-separator").text("\u2013")); container.append($editorEnd); container.addClass("dx-filterbuilder-range"); this._editorFactory.createEditor.call(this, $editorStart, extend({}, conditionInfo.field, conditionInfo, { value: getStartValue(values), parentType: "filterBuilder", setValue(value) { values = [value, getEndValue(values)]; conditionInfo.setValue(values) } })); this._editorFactory.createEditor.call(this, $editorEnd, extend({}, conditionInfo.field, conditionInfo, { value: getEndValue(values), parentType: "filterBuilder", setValue(value) { values = [getStartValue(values), value]; conditionInfo.setValue(values) } })) } export function getConfig(caption, context) { return { name: "between", caption: caption, icon: "range", valueSeparator: "\u2013", dataTypes: ["number", "date", "datetime"], editorTemplate: editorTemplate.bind(context), notForLookup: true } }