Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
canpolatoral committed May 8, 2019
2 parents ff95a7a + 2535c6b commit 56a0703
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 52 deletions.
2 changes: 1 addition & 1 deletion packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@kuveytturk/boa-base",
"private": true,
"author": "Kuveyt Turk BOA One Team",
"version": "0.1.6",
"version": "0.1.7",
"description": "Composer, BaseComponent, Theme, ErrorBoundary for BOA Components",
"keywords": [
"react",
Expand Down
3 changes: 2 additions & 1 deletion packages/base/src/ComponentComposer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default function ComponentComposer(WrappedComponent) {
}

render() {
const visible = this.props.visible !== undefined ? this.props.visible : this.props.isVisible;
const visible = this.props.isVisible !== undefined ?
this.props.isVisible : this.props.visible;
if (visible || visible === undefined) {
if (isWrappedWithStyles(WrappedComponent)) {
const innerComp = super.render();
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/DateTimePicker/DatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class DatePicker extends ComponentBase {
return (
<div
style={{
width: timeFormat ? '65%' : '100%',
width: (!timeFormat && this.props.fullWidth) ? '100%' : '65%',
}}
ref={r => (this.rootDate = r)}
>
Expand Down Expand Up @@ -416,7 +416,7 @@ class DatePicker extends ComponentBase {
return (
<div
style={{
width: '35%',
width: (!dateFormat && this.props.fullWidth) ? '100%' : '35%',
paddingLeft: 24,
}}
>
Expand Down
15 changes: 9 additions & 6 deletions packages/components/src/DateTimePicker/dateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,22 @@ export function getFormatDecomposition(format) {
timeFormat: undefined,
};
}
formats.dateFormatHint = Localization.stringLowerCase(
Localization.getDateTimeFormat(formats.dateFormat),
);
if (formats.dateFormat)
formats.dateFormatHint = Localization.stringLowerCase(
Localization.getDateTimeFormat(formats.dateFormat),
);
if (formats.timeFormat)
formats.timeFormatHint = Localization.stringLowerCase(
Localization.getDateTimeFormat(formats.timeFormat),
);

let dateMask = formats.dateFormatHint;
let timeMask = formats.timeFormatHint;
dateMask = dateMask.replaceAll('d', 'n');
dateMask = dateMask.replaceAll('m', 'n');
dateMask = dateMask.replaceAll('y', 'n');
if (dateMask) {
dateMask = dateMask.replaceAll('d', 'n');
dateMask = dateMask.replaceAll('m', 'n');
dateMask = dateMask.replaceAll('y', 'n');
}
if (timeMask) {
timeMask = timeMask.replaceAll('s', 'n');
timeMask = timeMask.replaceAll('h', 'n');
Expand Down
8 changes: 5 additions & 3 deletions packages/components/src/Input/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ class Input extends EditorBase {

if (showClearButton && hasValue(value) && !disabled) {
suffixText = (
<div>
<div style={{
display: 'inline-flex',
}}>
<IconButton
dynamicIcon="Close"
iconProperties={{
Expand Down Expand Up @@ -662,7 +664,7 @@ class Input extends EditorBase {
paddingTop: 10,
marginTop: 0,
};
const rootStyle = Object.assign(baseRootStyle, this.props.inputStyle);
const rootStyle = Object.assign(baseRootStyle, this.props.style);
let visibleLabel = true;

if (!focussed) {
Expand Down Expand Up @@ -765,7 +767,7 @@ class Input extends EditorBase {
inputRef={this.props.inputRef}
fullWidth={fullWidth}
type={type}
style={this.props.inputStyle}
// style={this.props.inputStyle}
value={this.state.value}
disabled={this.state.disabled}
disableUnderline={!underlineShow}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/InputAction/InputAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ class InputAction extends ComponentBase {
disabled={this.state.inputDisabled}
value={this.state.value}
onChange={this.onChange}
onFocus={this.onFocus}
onFocus={this.props.onFocus}
onBlur={this.onBlur}
onKeyDown={this.onKeyDown}
onKeyDown={this.props.onKeyDown}
prefixText={leftIcons.length ? leftIcons : null}
suffixText={rightIcons.length ? rightIcons : null}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/InputMask/InputMask.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class InputMask extends EditorBase {
let saltText = '';
let count = 0;

this.isCorrectFormat = text === undefined || text.length > 0;
this.isCorrectFormat = text === undefined || text == null || text.length > 0;

if (text !== undefined) {
if (text) {
for (let i = 0; i < mask.length; i++) {
const m = mask[i];
const isExist = PredefinedMask.Regex[m] !== undefined;
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/InputNumeric/InputNumeric.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class InputNumeric extends EditorBase {
}

checkNumberFormatIsValid(value) {
if (!value || value === '' || value === '-') {
if (!value || value === '' || value === '-' || value === '-0') {
return true;
}

Expand Down Expand Up @@ -377,14 +377,12 @@ class InputNumeric extends EditorBase {
return '';
}
}
const delimiters = Localization.getDelimiters();

if (typeof value === 'string') {
if (!value || value === '' || value === '-') {
if (!value || value === '' || value === '-' || value.indexOf('-0') !== -1) {
return value;
}

const delimiters = Localization.getDelimiters();

if (nextFormat !== 'D') {
let tempValue = value.replace(new RegExp(`[${delimiters.thousands}]`, 'g'), '');
if (tempValue.indexOf(delimiters.decimal) !== -1) {
Expand Down
67 changes: 40 additions & 27 deletions packages/components/src/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,22 @@ class Menu extends ComponentBase {
}

render() {
let menuItems = null;
let menuItems = [];
const fixedMenuItems = [];
const isRightToLeft = this.props.context.localization.isRightToLeft;

const fixedItems = this.props.items.filter(items => items.fixed === true);
/* istanbul ignore else */
if (!this.props.isMenuItemList) {
menuItems = this.props.items.map(item => {
const allItems = this.props.items;
for (let i = 0; i < allItems.length; i++) {
const item = allItems[i];

const allProperties = item.allProperties || {};
const typeId = allProperties.typeId;

if (typeId !== undefined && typeId !== 1 && typeId !== 2) {
return null;
// eslint-disable-next-line no-continue
continue;
}

const rightIcon =
Expand Down Expand Up @@ -176,30 +181,34 @@ class Menu extends ComponentBase {

innerDivStyle = merge(innerDivStyle, item.innerDivStyle || {});

if (item.value) {
return (
<MenuItem
classes={this.props.classes}
context={this.props.context}
key={item.value}
value={item.value}
primaryText={item.text}
items={item.items}
rightIcon={rightIcon}
leftIcon={leftIcon}
leftIconStyle={leftIconStyle}
style={itemStyle}
primaryTextPadding={this.props.primaryTextPadding}
innerDivStyle={innerDivStyle}
itemSelected={this.menuItemSelected}
width={this.props.width}
allProperties={item.allProperties}
/>
);
}
const menuItem = (item.value || item.text) ? (
<MenuItem
classes={this.props.classes}
context={this.props.context}
key={item.value}
value={item.value}
primaryText={item.text}
items={item.items}
rightIcon={rightIcon}
leftIcon={leftIcon}
leftIconStyle={leftIconStyle}
style={itemStyle}
primaryTextPadding={this.props.primaryTextPadding}
innerDivStyle={innerDivStyle}
itemSelected={this.menuItemSelected}
width={this.props.width}
allProperties={item.allProperties}
/>
) : <MuiDivider style={{ marginBottom: 12, marginTop: 12 }} key={Math.random()} />;

return <MuiDivider style={{ marginBottom: 12, marginTop: 12 }} key={Math.random()} />;
});
if (fixedItems &&
fixedItems.length > 0 &&
fixedItems.includes(item)) {
fixedMenuItems.push(menuItem);
} else {
menuItems.push(menuItem);
}
}
} else {
menuItems = this.props.items.map(item => {
if (item.props.menuItems && item.props.menuItems.length > 0) {
Expand Down Expand Up @@ -235,6 +244,10 @@ class Menu extends ComponentBase {
width={this.props.width}
style={this.props.style}
>
{fixedMenuItems}
{fixedItems && fixedItems.length > 0 ?
<MuiDivider style={{ marginBottom: 12, marginTop: 12 }} key={Math.random()} /> :
null}
{menuItems}
</MuiMenuList>
);
Expand Down
17 changes: 15 additions & 2 deletions packages/components/src/Menu/Menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ describe('<Menu />', () => {
assert.strictEqual(wrapper.childAt(1).props().value, 3);
});

it('should render fixed Items', () => {
const newItems = JSON.parse(JSON.stringify(items));
newItems[0].fixed = true;
newItems[3].fixed = true;

const wrapper = shallow(<Menu context={context} items={newItems} />);
assert.strictEqual(wrapper.type(), MuiMenuList);
assert.strictEqual(wrapper.childAt(0).type(), MenuItem);
assert.strictEqual(wrapper.childAt(0).props().value, 1);
assert.strictEqual(wrapper.childAt(1).type(), MenuItem);
assert.strictEqual(wrapper.childAt(1).props().value, 4);
assert.strictEqual(wrapper.childAt(2).type(), MuiDivider);
});
describe('rightIcon', () => {
it('should render icons', () => {
const wrapper = shallow(<Menu context={context} items={items} />);
Expand Down Expand Up @@ -166,7 +179,7 @@ describe('<Menu />', () => {
it('should handle selected', () => {
const wrapper = mount(<Menu items={items} context={context} />);
const menuItem = wrapper.find(MuiMenuItem).first();
menuItem.simulate('click', { persist: () => {}, value: 1 });
menuItem.simulate('click', { persist: () => { }, value: 1 });
assert.strictEqual(wrapper.instance().getInstance().state.value, 1);
});

Expand All @@ -176,7 +189,7 @@ describe('<Menu />', () => {
<Menu items={items} context={context} menuItemSelected={menuItemSelected} />,
);
const menuItem = wrapper.find(MuiMenuItem).first();
menuItem.simulate('click', { persist: () => {}, value: 1 });
menuItem.simulate('click', { persist: () => { }, value: 1 });
assert.strictEqual(wrapper.instance().getInstance().state.value, 1);
assert.strictEqual(menuItemSelected.callCount, 1);
});
Expand Down
2 changes: 1 addition & 1 deletion stories/DateTimePicker/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"name": "bool"
},
"required": false,
"description": "If `false`, width property of the field is assigned 100.",
"description": "If `true`, width property of the field is assigned 100.",
"defaultValue": {
"value": true,
"computed": false
Expand Down
15 changes: 15 additions & 0 deletions stories/Menu/Menu/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
{
text: 'Istanbul',
value: '34',
fixed: true,
leftIcon: {
dynamicIcon: 'EventNote',
iconProperties: {
Expand All @@ -17,5 +18,19 @@ export default {
text: 'Ankara',
value: '06',
},
{
text: 'Adana',
value: '01',
},
{
text: 'Erzurum',
fixed: true,
value: '25',
},
{
text: 'İzmir',
fixed: true,
value: '35',
},
],
};

0 comments on commit 56a0703

Please sign in to comment.