@micromag/element-grid 0.3.541 → 0.3.569
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -5
- package/lib/index.js +0 -110
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-grid",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.569",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -30,11 +30,10 @@
|
|
|
30
30
|
}
|
|
31
31
|
],
|
|
32
32
|
"license": "ISC",
|
|
33
|
-
"
|
|
33
|
+
"type": "module",
|
|
34
34
|
"module": "es/index.js",
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
|
-
"require": "./lib/index.js",
|
|
38
37
|
"import": "./es/index.js"
|
|
39
38
|
},
|
|
40
39
|
"./assets/css/styles": "./assets/css/styles.css",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
61
|
"@babel/runtime": "^7.13.10",
|
|
63
|
-
"@micromag/core": "^0.3.
|
|
62
|
+
"@micromag/core": "^0.3.569",
|
|
64
63
|
"classnames": "^2.2.6",
|
|
65
64
|
"lodash": "^4.17.21",
|
|
66
65
|
"prop-types": "^15.7.2",
|
|
@@ -71,5 +70,5 @@
|
|
|
71
70
|
"access": "public",
|
|
72
71
|
"registry": "https://registry.npmjs.org/"
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "ceb71f23a32ab8df4a1563a1e5cd5598e539de4d"
|
|
75
74
|
}
|
package/lib/index.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
var classNames = require('classnames');
|
|
5
|
-
var isArray = require('lodash/isArray');
|
|
6
|
-
var PropTypes = require('prop-types');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var core = require('@micromag/core');
|
|
9
|
-
|
|
10
|
-
var styles = {"container":"micromag-element-grid-container","items":"micromag-element-grid-items","cross":"micromag-element-grid-cross","axis":"micromag-element-grid-axis"};
|
|
11
|
-
|
|
12
|
-
var propTypes = {
|
|
13
|
-
layout: core.PropTypes.gridLayout,
|
|
14
|
-
items: PropTypes.arrayOf(PropTypes.node),
|
|
15
|
-
width: PropTypes.number,
|
|
16
|
-
height: PropTypes.number,
|
|
17
|
-
spacing: PropTypes.number,
|
|
18
|
-
vertical: PropTypes.bool,
|
|
19
|
-
className: PropTypes.string,
|
|
20
|
-
axisClassName: PropTypes.string,
|
|
21
|
-
crossClassName: PropTypes.string
|
|
22
|
-
};
|
|
23
|
-
var defaultProps = {
|
|
24
|
-
layout: null,
|
|
25
|
-
items: [],
|
|
26
|
-
width: null,
|
|
27
|
-
height: null,
|
|
28
|
-
spacing: 0,
|
|
29
|
-
vertical: false,
|
|
30
|
-
className: null,
|
|
31
|
-
axisClassName: null,
|
|
32
|
-
crossClassName: null
|
|
33
|
-
};
|
|
34
|
-
function Grid(_ref) {
|
|
35
|
-
var items = _ref.items,
|
|
36
|
-
layout = _ref.layout,
|
|
37
|
-
width = _ref.width,
|
|
38
|
-
height = _ref.height,
|
|
39
|
-
spacing = _ref.spacing,
|
|
40
|
-
vertical = _ref.vertical,
|
|
41
|
-
className = _ref.className,
|
|
42
|
-
axisClassName = _ref.axisClassName,
|
|
43
|
-
crossClassName = _ref.crossClassName;
|
|
44
|
-
var itemIndex = 0;
|
|
45
|
-
var finalLayout = isArray(layout) ? layout : [{
|
|
46
|
-
rows: vertical ? items.map(function () {
|
|
47
|
-
return 1;
|
|
48
|
-
}) : 1,
|
|
49
|
-
columns: vertical ? 1 : items.map(function () {
|
|
50
|
-
return 1;
|
|
51
|
-
})
|
|
52
|
-
}];
|
|
53
|
-
var crossTotal = finalLayout.reduce(function (total, _ref2) {
|
|
54
|
-
var _ref2$rows = _ref2.rows,
|
|
55
|
-
rows = _ref2$rows === void 0 ? 1 : _ref2$rows,
|
|
56
|
-
_ref2$columns = _ref2.columns,
|
|
57
|
-
columns = _ref2$columns === void 0 ? 1 : _ref2$columns;
|
|
58
|
-
return total + (vertical ? columns : rows);
|
|
59
|
-
}, 0);
|
|
60
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
61
|
-
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
62
|
-
style: {
|
|
63
|
-
width: width,
|
|
64
|
-
height: height,
|
|
65
|
-
padding: spacing !== null && spacing > 0 ? spacing / 2 : null
|
|
66
|
-
}
|
|
67
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
-
className: styles.items,
|
|
69
|
-
style: {
|
|
70
|
-
flexDirection: vertical ? 'row' : 'column'
|
|
71
|
-
}
|
|
72
|
-
}, finalLayout.map(function (_ref4, crossIndex) {
|
|
73
|
-
var rows = _ref4.rows,
|
|
74
|
-
columns = _ref4.columns;
|
|
75
|
-
var crossSizeRatio = (vertical ? columns : rows) / crossTotal;
|
|
76
|
-
var crossSize = "".concat(100 * crossSizeRatio, "%");
|
|
77
|
-
var axisItems = vertical ? rows : columns;
|
|
78
|
-
var finalAxisItems = isArray(axisItems) ? axisItems : [axisItems];
|
|
79
|
-
var axisTotal = finalAxisItems.reduce(function (total, it) {
|
|
80
|
-
return total + it;
|
|
81
|
-
}, 0);
|
|
82
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
key: "cross-".concat(crossIndex),
|
|
84
|
-
className: classNames([styles.cross, _defineProperty({}, crossClassName, crossClassName !== null)]),
|
|
85
|
-
style: {
|
|
86
|
-
flexDirection: vertical ? 'column' : 'row',
|
|
87
|
-
width: vertical ? crossSize : null,
|
|
88
|
-
height: vertical ? null : crossSize
|
|
89
|
-
}
|
|
90
|
-
}, finalAxisItems.map(function (axisItem, axisIndex) {
|
|
91
|
-
var axisSizeRatio = axisItem / axisTotal;
|
|
92
|
-
var axisSize = "".concat(100 * axisSizeRatio, "%");
|
|
93
|
-
var item = items[itemIndex];
|
|
94
|
-
itemIndex += 1;
|
|
95
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
96
|
-
key: "axis-".concat(axisIndex),
|
|
97
|
-
className: classNames([styles.axis, _defineProperty({}, axisClassName, axisClassName !== null)]),
|
|
98
|
-
style: {
|
|
99
|
-
width: vertical ? null : axisSize,
|
|
100
|
-
height: vertical ? axisSize : null,
|
|
101
|
-
padding: spacing > 0 ? spacing / 2 : 0
|
|
102
|
-
}
|
|
103
|
-
}, item);
|
|
104
|
-
}));
|
|
105
|
-
})));
|
|
106
|
-
}
|
|
107
|
-
Grid.propTypes = propTypes;
|
|
108
|
-
Grid.defaultProps = defaultProps;
|
|
109
|
-
|
|
110
|
-
module.exports = Grid;
|