1+ import type { dxElementWrapper } from '@js/core/renderer' ;
12import $ from '@js/core/renderer' ;
23import { extend } from '@js/core/utils/extend' ;
34import { isDefined } from '@js/core/utils/type' ;
5+ import type { Properties } from '@js/ui/button' ;
6+ import type { HorizontalAlignment , VerticalAlignment } from '@js/ui/form' ;
7+ import type Button from '@ts/ui/button/wrapper' ;
8+ import type { TemplatesInfo } from '@ts/ui/form/m_form.layout_manager' ;
49
510const FIELD_BUTTON_ITEM_CLASS = 'dx-field-button-item' ;
611
12+ type ButtonItemRenderInfo = TemplatesInfo & {
13+ validationGroup ?: string ;
14+ createComponentCallback : (
15+ $element : dxElementWrapper ,
16+ options : Properties ,
17+ ) => Button ;
18+ } ;
19+
20+ function convertAlignmentToTextAlign (
21+ horizontalAlignment : HorizontalAlignment | undefined ,
22+ ) : HorizontalAlignment {
23+ return isDefined ( horizontalAlignment ) ? horizontalAlignment : 'right' ;
24+ }
25+
26+ function convertAlignmentToJustifyContent (
27+ verticalAlignment : VerticalAlignment | undefined ,
28+ ) : string {
29+ switch ( verticalAlignment ) {
30+ case 'center' :
31+ return 'center' ;
32+ case 'bottom' :
33+ return 'flex-end' ;
34+ default :
35+ return 'flex-start' ;
36+ }
37+ }
38+
739export function renderButtonItem ( {
840 item,
941 $parent,
1042 rootElementCssClassList,
1143 validationGroup,
1244 createComponentCallback,
13- } ) {
45+ } : ButtonItemRenderInfo ) : {
46+ $rootElement : dxElementWrapper ;
47+ buttonInstance : Button ;
48+ } {
1449 const $rootElement = $ ( '<div>' )
1550 . appendTo ( $parent )
1651 . addClass ( rootElementCssClassList . join ( ' ' ) )
@@ -27,23 +62,7 @@ export function renderButtonItem({
2762 $rootElement,
2863 buttonInstance : createComponentCallback (
2964 $button ,
30- 'dxButton' ,
3165 extend ( { validationGroup } , item . buttonOptions ) ,
3266 ) ,
3367 } ;
3468}
35-
36- function convertAlignmentToTextAlign ( horizontalAlignment ) {
37- return isDefined ( horizontalAlignment ) ? horizontalAlignment : 'right' ;
38- }
39-
40- function convertAlignmentToJustifyContent ( verticalAlignment ) {
41- switch ( verticalAlignment ) {
42- case 'center' :
43- return 'center' ;
44- case 'bottom' :
45- return 'flex-end' ;
46- default :
47- return 'flex-start' ;
48- }
49- }
0 commit comments