Skip to content

Commit

Permalink
Update to material-ui v4
Browse files Browse the repository at this point in the history
  • Loading branch information
psamim committed Jun 25, 2019
1 parent a7644c7 commit 283d914
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 23 deletions.
8 changes: 4 additions & 4 deletions lib/Array.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ var styles = function styles(theme) {
return {
arrayItem: {
position: "relative",
padding: theme.spacing.unit,
marginTop: theme.spacing.unit,
padding: theme.spacing(),
marginTop: theme.spacing(),
display: "flex"
},
deleteItemButton: {
margin: [[-theme.spacing.unit, -theme.spacing.unit, "auto", "auto"]]
margin: [[theme.spacing(-1), theme.spacing(-1), "auto", "auto"]]
},
addButton: {
marginLeft: theme.spacing.unit
marginLeft: theme.spacing()
},
elementsContainer: {
display: "flex",
Expand Down
4 changes: 2 additions & 2 deletions lib/FieldSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var styles = function styles(theme) {
return {
root: {
marginTop: theme.spacing.unit
marginTop: theme.spacing(1)
},
fields: {
marginLeft: theme.spacing.unit
marginLeft: theme.spacing(1)
}
};
};
Expand Down
2 changes: 1 addition & 1 deletion lib/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var styles = function styles(theme) {
flexWrap: "wrap"
},
chip: {
margin: theme.spacing.unit / 4
margin: theme.spacing(0.25)
},
menuItem: {
fontWeight: theme.typography.fontWeightRegular
Expand Down
4 changes: 2 additions & 2 deletions lib/Radios.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
var styles = function styles(theme) {
return {
formControl: {
marginTop: theme.spacing.unit
marginTop: theme.spacing(1)
},
group: {
margin: theme.spacing.unit + "px 0"
margin: theme.spacing(1, 0)
}
};
};
Expand Down
18 changes: 17 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ var _notevil = require("notevil");

var _notevil2 = _interopRequireDefault(_notevil);

var _set2 = require("lodash/fp/set");

var _set3 = _interopRequireDefault(_set2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Evaluates an expression in a safe way
Expand Down Expand Up @@ -617,6 +621,17 @@ function selectOrSet(projection, obj, valueToSet, type) {
return value;
}

function set(projection, obj, valueToSet, type) {
if (!obj) {
obj = this;
}

// Support [] array syntax
var parts = typeof projection === "string" ? _objectpath2.default.parse(projection) : projection;

return (0, _set3.default)(parts, valueToSet)(obj);
}

var validateBySchema = function validateBySchema(schema, value) {
return _tv2.default.validateResult(value, schema);
};
Expand Down Expand Up @@ -721,5 +736,6 @@ exports.default = {
selectOrSet: selectOrSet,
getValueFromModel: getValueFromModel,
getTitleByValue: getTitleByValue,
removeEmpty: removeEmpty
removeEmpty: removeEmpty,
set: set
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
},
"devDependencies": {
"@babel/preset-flow": "^7.0.0",
"@material-ui/core": "^3.7.1",
"@material-ui/icons": "3.0.1",
"@material-ui/core": "^4.0.0",
"@material-ui/icons": "^4.0.0",
"babel-cli": "6.26.0",
"babel-core": "6.26.3",
"babel-eslint": "^10.0.1",
Expand Down Expand Up @@ -75,8 +75,8 @@
"peerDependencies": {
"react": "*",
"react-dom": "*",
"@material-ui/core": ">=3.2.0",
"@material-ui/icons": ">=3.0.0"
"@material-ui/core": ">=4.0.0",
"@material-ui/icons": ">=4.0.0"
},
"scripts": {
"preversion": "webpack -p",
Expand Down
8 changes: 4 additions & 4 deletions src/Array.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import type { Localization } from "./types";
const styles = theme => ({
arrayItem: {
position: "relative",
padding: theme.spacing.unit,
marginTop: theme.spacing.unit,
padding: theme.spacing(),
marginTop: theme.spacing(),
display: "flex"
},
deleteItemButton: {
margin: [[-theme.spacing.unit, -theme.spacing.unit, "auto", "auto"]]
margin: [[theme.spacing(-1), theme.spacing(-1), "auto", "auto"]]
},
addButton: {
marginLeft: theme.spacing.unit
marginLeft: theme.spacing()
},
elementsContainer: {
display: "flex",
Expand Down
4 changes: 2 additions & 2 deletions src/FieldSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type { Localization } from "./types";

const styles = theme => ({
root: {
marginTop: theme.spacing.unit
marginTop: theme.spacing(1)
},
fields: {
marginLeft: theme.spacing.unit
marginLeft: theme.spacing(1)
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const styles = theme => ({
flexWrap: "wrap"
},
chip: {
margin: theme.spacing.unit / 4
margin: theme.spacing(0.25)
},
menuItem: {
fontWeight: theme.typography.fontWeightRegular
Expand Down
4 changes: 2 additions & 2 deletions src/Radios.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type { Localization } from "./types";

const styles = theme => ({
formControl: {
marginTop: theme.spacing.unit
marginTop: theme.spacing(1)
},
group: {
margin: `${theme.spacing.unit}px 0`
margin: theme.spacing(1, 0)
}
});

Expand Down

0 comments on commit 283d914

Please sign in to comment.