UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

50 lines (47 loc) 1.78 kB
/** * DevExtreme (esm/__internal/ui/form/components/m_button_item.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 $ from "../../../../core/renderer"; import { extend } from "../../../../core/utils/extend"; import { isDefined } from "../../../../core/utils/type"; const FIELD_BUTTON_ITEM_CLASS = "dx-field-button-item"; export function renderButtonItem(_ref) { let { item: item, $parent: $parent, rootElementCssClassList: rootElementCssClassList, validationGroup: validationGroup, createComponentCallback: createComponentCallback } = _ref; const $rootElement = $("<div>").appendTo($parent).addClass(rootElementCssClassList.join(" ")).addClass("dx-field-button-item").css("textAlign", convertAlignmentToTextAlign(item.horizontalAlignment)); $parent.css("justifyContent", convertAlignmentToJustifyContent(item.verticalAlignment)); const $button = $("<div>").appendTo($rootElement); return { $rootElement: $rootElement, buttonInstance: createComponentCallback($button, "dxButton", extend({ validationGroup: validationGroup }, item.buttonOptions)) } } function convertAlignmentToTextAlign(horizontalAlignment) { return isDefined(horizontalAlignment) ? horizontalAlignment : "right" } function convertAlignmentToJustifyContent(verticalAlignment) { switch (verticalAlignment) { case "center": return "center"; case "bottom": return "flex-end"; default: return "flex-start" } }