Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximKudriavtsev committed Apr 29, 2020
2 parents ccfe3b3 + 0d789fe commit f049f17
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 33 deletions.
7 changes: 2 additions & 5 deletions js/core/utils/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import $ from '../../core/renderer';
const ICON_CLASS = 'dx-icon';
const SVG_ICON_CLASS = 'dx-svg-icon';

const getImageSourceType = (source) => {
export const getImageSourceType = (source) => {
if(!source || typeof source !== 'string') {
return false;
}
Expand All @@ -27,7 +27,7 @@ const getImageSourceType = (source) => {
return false;
};

const getImageContainer = (source) => {
export const getImageContainer = (source) => {
switch(getImageSourceType(source)) {
case 'image':
return $('<img>').attr('src', source).addClass(ICON_CLASS);
Expand All @@ -41,6 +41,3 @@ const getImageContainer = (source) => {
return null;
}
};

exports.getImageSourceType = getImageSourceType;
exports.getImageContainer = getImageContainer;
5 changes: 4 additions & 1 deletion js/renovation/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export class ButtonProps extends BaseWidgetProps {
@OneWay() hoverStateEnabled?: boolean = true;
@OneWay() icon?: string = '';
@OneWay() iconPosition?: string = 'left';
@Event() onClick?: (e: any) => any = noop;
@Event({
actionConfig: { excludeValidators: ['readOnly'] },
})
onClick?: (e: any) => any = noop;
@Event() onSubmit?: (e: any) => any = noop;
@OneWay() pressed?: boolean;
@OneWay() stylingMode?: 'outlined' | 'text' | 'contained';
Expand Down
30 changes: 8 additions & 22 deletions js/renovation/dist/button.j.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import registerComponent from '../../core/component_registrator';
import ValidationEngine from '../../ui/validation_engine';
import Component from '../preact-wrapper/component';
import ButtonComponent from '../button.p';
import { getInnerActionName } from '../preact-wrapper/utils';

const actions = {
onClick: { excludeValidators: ['readOnly'] },
onContentReady: { excludeValidators: ['disabled', 'readOnly'] },
};

export default class Button extends Component {
get _viewComponent() {
Expand All @@ -18,12 +12,6 @@ export default class Button extends Component {
props.render = this._createTemplateComponent(props, props.template, true);
props.onKeyDown = this._wrapKeyDownHandler(props.onKeyDown);

props.pressedChange = (pressed) => this.option('pressed', pressed);

Object.keys(actions).forEach((name) => {
props[name] = this.option(getInnerActionName(name));
});

props.validationGroup = ValidationEngine.getGroupConfig(this._findGroup());

return props;
Expand All @@ -47,28 +35,26 @@ export default class Button extends Component {
if(this.option('useSubmitBehavior')) {
this.option('onSubmit', this._getSubmitAction());
}
}

Object.keys(actions).forEach((name) => {
this._addAction(name, actions[name]);
});
_getActionsMap() {
return {
onClick: { excludeValidators: ['readOnly'] },
onContentReady: { excludeValidators: ['disabled', 'readOnly'] },
};
}

_optionChanged(option) {
const { name, value } = option;
if(actions[name]) {
this._addAction(name, actions[name]);
}

switch(name) {
case 'useSubmitBehavior':
value === true && this.option('onSubmit', this._getSubmitAction());
break;
case 'onOptionChanged':
super._optionChanged(option);
option = undefined;
break;
}

super._optionChanged();
super._optionChanged(option);
}

_getSubmitAction() {
Expand Down
36 changes: 36 additions & 0 deletions js/renovation/preact-wrapper/component.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import DOMComponent from '../../core/dom_component';

export default class PreactWrapper extends DOMComponent {
viewRef: any;

getInstance(): this;

_initMarkup(): void;

_render(): void;

getAllProps(isFirstRender: boolean): any;

_getActionsMap(): any;

_init(): any;

_createViewRef(): any;

_optionChanged(option: any): any;

_addAction(name: string, config:any): any;

_stateChange(name: string): (value: any) => void;

_createTemplateComponent(props: any, templateOption: any, canBeAnonymous: boolean): any;

_wrapKeyDownHandler(handler: (event: any, options: any) => any): any;

// Public API
repaint(): any;

registerKeyHandler(key: string, handler: (e: any) => any): void;

setAria(): any;
}
21 changes: 21 additions & 0 deletions js/renovation/preact-wrapper/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ export default class PreactWrapper extends DOMComponent {
options.ref = this.viewRef;
}

Object.keys(this._getActionsMap()).forEach((name) => {
options[name] = this.option(getInnerActionName(name));
});

return this.getProps && this.getProps(options) || options;
}

_getActionsMap() { return {}; }

_init() {
super._init();

Object.keys(this._getActionsMap()).forEach((name) => {
this._addAction(name, this._getActionsMap()[name]);
});

this._initWidget && this._initWidget();
this._supportedKeys = () => ({});
}
Expand All @@ -86,6 +97,16 @@ export default class PreactWrapper extends DOMComponent {
}

_optionChanged(option) {
const { name } = option || {};
if(name) {
if(this._getActionsMap()[name]) {
this._addAction(name, this._getActionsMap()[name]);
option = undefined;
} else if(Object.keys(this._getActionsMap()).some(event => getInnerActionName(event) === name)) {
option = undefined;
}
}

if(option) {
super._optionChanged(option);
}
Expand Down
6 changes: 4 additions & 2 deletions js/renovation/utils/base-props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export class BaseWidgetProps {
@OneWay() height?: string | number | null = null;
@OneWay() hint?: string;
@OneWay() hoverStateEnabled?: boolean = false;
@Event() onClick?: (e: any) => any;
@Event() onContentReady?: (e: any) => any = (() => {});
@Event() onClick?: (e: any) => void;
@Event({
actionConfig: { excludeValidators: ['disabled', 'readOnly'] },
}) onContentReady?: (e: any) => any = (() => {});
@Event() onKeyDown?: (e: any, options: any) => any;
@OneWay() rtlEnabled?: boolean = config().rtlEnabled;
@OneWay() tabIndex?: number = 0;
Expand Down
2 changes: 1 addition & 1 deletion js/ui/grid_core/ui.grid_core.editing.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Form from '../form';
import holdEvent from '../../events/hold';
import { when, Deferred, fromPromise } from '../../core/utils/deferred';
import commonUtils from '../../core/utils/common';
import iconUtils from '../../core/utils/icon';
import * as iconUtils from '../../core/utils/icon';
import Scrollable from '../scroll_view/ui.scrollable';
import deferredUtils from '../../core/utils/deferred';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { compileGetter, compileSetter } from '../../core/utils/data';
import { extend } from '../../core/utils/extend';
import { each } from '../../core/utils/iterator';
import devices from '../../core/devices';
import iconUtils from '../../core/utils/icon';
import { getImageContainer } from '../../core/utils/icon';
import HierarchicalDataAdapter from './ui.data_adapter';
import CollectionWidget from '../collection/ui.collection_widget.edit';
import { BindableTemplate } from '../../core/templates/bindable_template';
Expand Down Expand Up @@ -93,7 +93,7 @@ const HierarchicalCollectionWidget = CollectionWidget.inherit({
},

_getIconContainer: function(itemData) {
return itemData.icon ? iconUtils.getImageContainer(itemData.icon) : undefined;
return itemData.icon ? getImageContainer(itemData.icon) : undefined;
},

_getTextContainer: function(itemData) {
Expand Down

0 comments on commit f049f17

Please sign in to comment.