@micromag/element-stack 0.3.531 → 0.3.547
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 -179
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-stack",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.547",
|
|
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.547",
|
|
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": "3c2f5904ce61fcfa61f673c38c2a5ec56e9e2b07"
|
|
75
74
|
}
|
package/lib/index.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
7
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
8
|
-
var classNames = require('classnames');
|
|
9
|
-
var isNumber = require('lodash/isNumber');
|
|
10
|
-
var isString = require('lodash/isString');
|
|
11
|
-
var PropTypes = require('prop-types');
|
|
12
|
-
var core = require('@micromag/core');
|
|
13
|
-
|
|
14
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
15
|
-
var StackContext = /*#__PURE__*/React.createContext({
|
|
16
|
-
direction: 'horizontal'
|
|
17
|
-
});
|
|
18
|
-
var useStack = function useStack() {
|
|
19
|
-
return React.useContext(StackContext);
|
|
20
|
-
};
|
|
21
|
-
var useStackDirection = function useStackDirection() {
|
|
22
|
-
var _useContext = React.useContext(StackContext),
|
|
23
|
-
direction = _useContext.direction;
|
|
24
|
-
return direction;
|
|
25
|
-
};
|
|
26
|
-
var propTypes$4 = {
|
|
27
|
-
children: PropTypes.node.isRequired,
|
|
28
|
-
direction: PropTypes.oneOf(['vertical', 'horizontal'])
|
|
29
|
-
};
|
|
30
|
-
var defaultProps$4 = {
|
|
31
|
-
direction: 'vertical'
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Note: this is done to avoid excessive renders on the screens that use the context
|
|
35
|
-
|
|
36
|
-
function StackProvider(_ref) {
|
|
37
|
-
var direction = _ref.direction,
|
|
38
|
-
children = _ref.children;
|
|
39
|
-
var value = React.useMemo(function () {
|
|
40
|
-
return {
|
|
41
|
-
direction: direction
|
|
42
|
-
};
|
|
43
|
-
}, [direction]);
|
|
44
|
-
return /*#__PURE__*/React.createElement(StackContext.Provider, {
|
|
45
|
-
value: value
|
|
46
|
-
}, children);
|
|
47
|
-
}
|
|
48
|
-
StackProvider.propTypes = propTypes$4;
|
|
49
|
-
StackProvider.defaultProps = defaultProps$4;
|
|
50
|
-
|
|
51
|
-
var styles$1 = {"container":"micromag-element-stack-spacer-container","hasSize":"micromag-element-stack-spacer-hasSize"};
|
|
52
|
-
|
|
53
|
-
var propTypes$3 = {
|
|
54
|
-
size: PropTypes.number,
|
|
55
|
-
minSize: PropTypes.number,
|
|
56
|
-
maxSize: PropTypes.number,
|
|
57
|
-
className: PropTypes.string
|
|
58
|
-
};
|
|
59
|
-
var defaultProps$3 = {
|
|
60
|
-
size: null,
|
|
61
|
-
minSize: null,
|
|
62
|
-
maxSize: null,
|
|
63
|
-
className: null
|
|
64
|
-
};
|
|
65
|
-
function Spacer(_ref) {
|
|
66
|
-
var size = _ref.size,
|
|
67
|
-
minSize = _ref.minSize,
|
|
68
|
-
maxSize = _ref.maxSize,
|
|
69
|
-
className = _ref.className;
|
|
70
|
-
var direction = useStackDirection();
|
|
71
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
-
className: classNames([styles$1.container, _defineProperty(_defineProperty({}, styles$1.hasSize, size !== null), className, className !== null)]),
|
|
73
|
-
style: {
|
|
74
|
-
width: direction === 'horizontal' ? size : null,
|
|
75
|
-
minWidth: direction === 'horizontal' ? minSize : null,
|
|
76
|
-
maxWidth: direction === 'horizontal' ? maxSize : null,
|
|
77
|
-
height: direction === 'vertical' ? size : null,
|
|
78
|
-
minHeight: direction === 'vertical' ? minSize : null,
|
|
79
|
-
maxHeight: direction === 'vertical' ? maxSize : null
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
Spacer.propTypes = propTypes$3;
|
|
84
|
-
Spacer.defaultProps = defaultProps$3;
|
|
85
|
-
Spacer.withoutTransitionsWrapper = true;
|
|
86
|
-
|
|
87
|
-
var styles = {"container":"micromag-element-stack-container"};
|
|
88
|
-
|
|
89
|
-
var propTypes$2 = {
|
|
90
|
-
direction: core.PropTypes.stackDirection,
|
|
91
|
-
align: core.PropTypes.stackAlign,
|
|
92
|
-
spacing: core.PropTypes.stackSpacing,
|
|
93
|
-
reverse: PropTypes.bool,
|
|
94
|
-
size: PropTypes.number,
|
|
95
|
-
minSize: PropTypes.number,
|
|
96
|
-
maxSize: PropTypes.number,
|
|
97
|
-
className: PropTypes.string,
|
|
98
|
-
children: PropTypes.node
|
|
99
|
-
};
|
|
100
|
-
var defaultProps$2 = {
|
|
101
|
-
direction: 'horizontal',
|
|
102
|
-
align: 'center',
|
|
103
|
-
spacing: null,
|
|
104
|
-
reverse: false,
|
|
105
|
-
size: null,
|
|
106
|
-
minSize: null,
|
|
107
|
-
maxSize: null,
|
|
108
|
-
className: null,
|
|
109
|
-
children: null
|
|
110
|
-
};
|
|
111
|
-
function Stack(_ref) {
|
|
112
|
-
var direction = _ref.direction,
|
|
113
|
-
align = _ref.align,
|
|
114
|
-
spacing = _ref.spacing,
|
|
115
|
-
reverse = _ref.reverse,
|
|
116
|
-
size = _ref.size,
|
|
117
|
-
minSize = _ref.minSize,
|
|
118
|
-
maxSize = _ref.maxSize,
|
|
119
|
-
className = _ref.className,
|
|
120
|
-
children = _ref.children;
|
|
121
|
-
var flexDirection = (direction === 'vertical' ? 'column' : 'row') + (reverse ? '-reverse' : '');
|
|
122
|
-
var alignItems = align === 'center' ? align : "flex-".concat(align);
|
|
123
|
-
var justifyContent = isString(spacing) ? "space-".concat(spacing) : null;
|
|
124
|
-
var space = isNumber(spacing) ? spacing : null;
|
|
125
|
-
var lastIndex = children !== null && children.length ? children.length - 1 : null;
|
|
126
|
-
return /*#__PURE__*/React.createElement(StackProvider, {
|
|
127
|
-
direction: direction
|
|
128
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
129
|
-
className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
|
|
130
|
-
style: {
|
|
131
|
-
flexDirection: flexDirection,
|
|
132
|
-
alignItems: alignItems,
|
|
133
|
-
justifyContent: justifyContent,
|
|
134
|
-
width: direction === 'horizontal' ? size : null,
|
|
135
|
-
minWidth: direction === 'horizontal' ? minSize : null,
|
|
136
|
-
maxWidth: direction === 'horizontal' ? maxSize : null,
|
|
137
|
-
height: direction === 'vertical' ? size : null,
|
|
138
|
-
minHeight: direction === 'vertical' ? minSize : null,
|
|
139
|
-
maxHeight: direction === 'vertical' ? maxSize : null
|
|
140
|
-
}
|
|
141
|
-
}, React.Children.toArray(children).reduce(function (allChildren, child, index) {
|
|
142
|
-
return child.type !== Spacer && space !== null && index < lastIndex ? [].concat(_toConsumableArray(allChildren), [child, /*#__PURE__*/React.createElement(Spacer, {
|
|
143
|
-
key: "spacer-".concat(index),
|
|
144
|
-
size: space
|
|
145
|
-
})]) : [].concat(_toConsumableArray(allChildren), [child]);
|
|
146
|
-
}, [])));
|
|
147
|
-
}
|
|
148
|
-
Stack.propTypes = propTypes$2;
|
|
149
|
-
Stack.defaultProps = defaultProps$2;
|
|
150
|
-
|
|
151
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
152
|
-
var propTypes$1 = {};
|
|
153
|
-
var defaultProps$1 = {};
|
|
154
|
-
function HStack(props) {
|
|
155
|
-
return /*#__PURE__*/React.createElement(Stack, Object.assign({}, props, {
|
|
156
|
-
direction: "horizontal"
|
|
157
|
-
}));
|
|
158
|
-
}
|
|
159
|
-
HStack.propTypes = propTypes$1;
|
|
160
|
-
HStack.defaultProps = defaultProps$1;
|
|
161
|
-
|
|
162
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
163
|
-
var propTypes = {};
|
|
164
|
-
var defaultProps = {};
|
|
165
|
-
function VStack(props) {
|
|
166
|
-
return /*#__PURE__*/React.createElement(Stack, Object.assign({}, props, {
|
|
167
|
-
direction: "vertical"
|
|
168
|
-
}));
|
|
169
|
-
}
|
|
170
|
-
VStack.propTypes = propTypes;
|
|
171
|
-
VStack.defaultProps = defaultProps;
|
|
172
|
-
|
|
173
|
-
exports.HStack = HStack;
|
|
174
|
-
exports.Spacer = Spacer;
|
|
175
|
-
exports.StackProvider = StackProvider;
|
|
176
|
-
exports.VStack = VStack;
|
|
177
|
-
exports.default = Stack;
|
|
178
|
-
exports.useStack = useStack;
|
|
179
|
-
exports.useStackDirection = useStackDirection;
|