@flodesk/grain 10.9.3 → 10.9.5
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/es/components/box2.js +132 -367
- package/es/styles/utilities.js +47 -88
- package/es/types.js +2 -1
- package/es/utilities/attributes.js +52 -0
- package/es/utilities/helpers.js +0 -162
- package/es/utilities/index.js +3 -1
- package/es/utilities/style-config.js +297 -0
- package/es/utilities/styles.js +11 -2
- package/package.json +1 -1
package/es/components/box2.js
CHANGED
|
@@ -3,7 +3,9 @@ import "core-js/modules/es.array.index-of.js";
|
|
|
3
3
|
import "core-js/modules/es.symbol.js";
|
|
4
4
|
import "core-js/modules/es.object.define-property.js";
|
|
5
5
|
import "core-js/modules/es.array.filter.js";
|
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
|
6
7
|
import "core-js/modules/es.object.get-own-property-descriptor.js";
|
|
8
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
7
9
|
import "core-js/modules/es.object.get-own-property-descriptors.js";
|
|
8
10
|
import "core-js/modules/es.object.define-properties.js";
|
|
9
11
|
import "core-js/modules/es.object.assign.js";
|
|
@@ -11,6 +13,10 @@ var _excluded = ["all", "color", "colorHover", "backgroundColor", "backgroundCol
|
|
|
11
13
|
|
|
12
14
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
13
15
|
|
|
16
|
+
import "core-js/modules/es.string.trim.js";
|
|
17
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
18
|
+
import "core-js/modules/es.string.replace.js";
|
|
19
|
+
|
|
14
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
21
|
|
|
16
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -21,380 +27,139 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
21
27
|
|
|
22
28
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
23
29
|
|
|
24
|
-
import "core-js/modules/es.object.to-string.js";
|
|
25
|
-
import "core-js/modules/web.dom-collections.for-each.js";
|
|
26
|
-
import "core-js/modules/es.array.concat.js";
|
|
27
|
-
import "core-js/modules/es.array.includes.js";
|
|
28
|
-
import "core-js/modules/es.string.includes.js";
|
|
29
|
-
import "core-js/modules/es.string.trim.js";
|
|
30
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
31
|
-
import "core-js/modules/es.string.replace.js";
|
|
32
|
-
import { getColor, getShadow, getSpace, isObject, isSpaceVar, propNameToShorthand, getDimension, isColorVar, getRadius, isNumber } from '../utilities';
|
|
33
30
|
import React, { forwardRef } from 'react';
|
|
34
|
-
import {
|
|
31
|
+
import { types } from '../types';
|
|
35
32
|
import PropTypes from 'prop-types';
|
|
36
|
-
import {
|
|
33
|
+
import { styleConfig, generateStyleAttributes, generateClassNameAttributes } from '../utilities';
|
|
37
34
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
35
|
+
var dimensionProps = styleConfig.dimensionProps,
|
|
36
|
+
colorProps = styleConfig.colorProps,
|
|
37
|
+
zIndexProps = styleConfig.zIndexProps,
|
|
38
|
+
aspectRatioProps = styleConfig.aspectRatioProps,
|
|
39
|
+
flexProps = styleConfig.flexProps,
|
|
40
|
+
spaceProps = styleConfig.spaceProps,
|
|
41
|
+
shadowProps = styleConfig.shadowProps,
|
|
42
|
+
radiusProps = styleConfig.radiusProps,
|
|
43
|
+
orderProps = styleConfig.orderProps,
|
|
44
|
+
positionProps = styleConfig.positionProps,
|
|
45
|
+
overflowProps = styleConfig.overflowProps,
|
|
46
|
+
transitionProps = styleConfig.transitionProps,
|
|
47
|
+
cursorProps = styleConfig.cursorProps;
|
|
48
|
+
export var Box2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
49
|
+
var all = _ref.all,
|
|
50
|
+
color = _ref.color,
|
|
51
|
+
colorHover = _ref.colorHover,
|
|
52
|
+
backgroundColor = _ref.backgroundColor,
|
|
53
|
+
backgroundColorHover = _ref.backgroundColorHover,
|
|
54
|
+
borderColorHover = _ref.borderColorHover,
|
|
55
|
+
borderSide = _ref.borderSide,
|
|
56
|
+
width = _ref.width,
|
|
57
|
+
minWidth = _ref.minWidth,
|
|
58
|
+
maxWidth = _ref.maxWidth,
|
|
59
|
+
height = _ref.height,
|
|
60
|
+
minHeight = _ref.minHeight,
|
|
61
|
+
maxHeight = _ref.maxHeight,
|
|
62
|
+
radius = _ref.radius,
|
|
63
|
+
padding = _ref.padding,
|
|
64
|
+
paddingTop = _ref.paddingTop,
|
|
65
|
+
paddingBottom = _ref.paddingBottom,
|
|
66
|
+
paddingLeft = _ref.paddingLeft,
|
|
67
|
+
paddingRight = _ref.paddingRight,
|
|
68
|
+
paddingX = _ref.paddingX,
|
|
69
|
+
paddingY = _ref.paddingY,
|
|
70
|
+
margin = _ref.margin,
|
|
71
|
+
marginTop = _ref.marginTop,
|
|
72
|
+
marginBottom = _ref.marginBottom,
|
|
73
|
+
marginLeft = _ref.marginLeft,
|
|
74
|
+
marginRight = _ref.marginRight,
|
|
75
|
+
marginX = _ref.marginX,
|
|
76
|
+
marginY = _ref.marginY,
|
|
77
|
+
position = _ref.position,
|
|
78
|
+
top = _ref.top,
|
|
79
|
+
bottom = _ref.bottom,
|
|
80
|
+
left = _ref.left,
|
|
81
|
+
right = _ref.right,
|
|
82
|
+
shadow = _ref.shadow,
|
|
83
|
+
shadowHover = _ref.shadowHover,
|
|
84
|
+
overflow = _ref.overflow,
|
|
85
|
+
overflowX = _ref.overflowX,
|
|
86
|
+
overflowY = _ref.overflowY,
|
|
87
|
+
aspectRatio = _ref.aspectRatio,
|
|
88
|
+
zIndex = _ref.zIndex,
|
|
89
|
+
_ref$tag = _ref.tag,
|
|
90
|
+
tag = _ref$tag === void 0 ? 'div' : _ref$tag,
|
|
91
|
+
opacity = _ref.opacity,
|
|
92
|
+
opacityHover = _ref.opacityHover,
|
|
93
|
+
order = _ref.order,
|
|
94
|
+
alignSelf = _ref.alignSelf,
|
|
95
|
+
flex = _ref.flex,
|
|
96
|
+
transition = _ref.transition,
|
|
97
|
+
transitionHover = _ref.transitionHover,
|
|
98
|
+
cursor = _ref.cursor,
|
|
99
|
+
children = _ref.children,
|
|
100
|
+
className = _ref.className,
|
|
101
|
+
style = _ref.style,
|
|
102
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
103
|
+
|
|
104
|
+
var allProps = {
|
|
105
|
+
all: all,
|
|
106
|
+
color: color,
|
|
107
|
+
colorHover: colorHover,
|
|
108
|
+
backgroundColor: backgroundColor,
|
|
109
|
+
backgroundColorHover: backgroundColorHover,
|
|
110
|
+
borderColorHover: borderColorHover,
|
|
111
|
+
borderSide: borderSide,
|
|
112
|
+
width: width,
|
|
113
|
+
minWidth: minWidth,
|
|
114
|
+
maxWidth: maxWidth,
|
|
115
|
+
height: height,
|
|
116
|
+
minHeight: minHeight,
|
|
117
|
+
maxHeight: maxHeight,
|
|
118
|
+
radius: radius,
|
|
119
|
+
padding: padding,
|
|
120
|
+
paddingTop: paddingTop,
|
|
121
|
+
paddingBottom: paddingBottom,
|
|
122
|
+
paddingLeft: paddingLeft,
|
|
123
|
+
paddingRight: paddingRight,
|
|
124
|
+
paddingX: paddingX,
|
|
125
|
+
paddingY: paddingY,
|
|
126
|
+
margin: margin,
|
|
127
|
+
marginTop: marginTop,
|
|
128
|
+
marginBottom: marginBottom,
|
|
129
|
+
marginLeft: marginLeft,
|
|
130
|
+
marginRight: marginRight,
|
|
131
|
+
marginX: marginX,
|
|
132
|
+
marginY: marginY,
|
|
133
|
+
position: position,
|
|
134
|
+
top: top,
|
|
135
|
+
bottom: bottom,
|
|
136
|
+
left: left,
|
|
137
|
+
right: right,
|
|
138
|
+
shadow: shadow,
|
|
139
|
+
shadowHover: shadowHover,
|
|
140
|
+
overflow: overflow,
|
|
141
|
+
overflowX: overflowX,
|
|
142
|
+
overflowY: overflowY,
|
|
143
|
+
aspectRatio: aspectRatio,
|
|
144
|
+
zIndex: zIndex,
|
|
145
|
+
tag: tag,
|
|
146
|
+
opacity: opacity,
|
|
147
|
+
opacityHover: opacityHover,
|
|
148
|
+
order: order,
|
|
149
|
+
alignSelf: alignSelf,
|
|
150
|
+
flex: flex,
|
|
151
|
+
transition: transition,
|
|
152
|
+
transitionHover: transitionHover,
|
|
153
|
+
cursor: cursor
|
|
65
154
|
};
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var generateOrderStyles = function generateOrderStyles(_ref3) {
|
|
69
|
-
var order = _ref3.order;
|
|
70
|
-
var styles = {};
|
|
71
|
-
var property = 'order';
|
|
72
|
-
|
|
73
|
-
if (isObject(order)) {
|
|
74
|
-
var defaultValue = order.default,
|
|
75
|
-
mobile = order.mobile,
|
|
76
|
-
tablet = order.tablet;
|
|
77
|
-
styles["--".concat(propNameToShorthand(property), "-dft")] = defaultValue;
|
|
78
|
-
styles["--".concat(propNameToShorthand(property), "-mbl")] = mobile;
|
|
79
|
-
styles["--".concat(propNameToShorthand(property), "-tbl")] = tablet;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isNumber(order)) {
|
|
83
|
-
styles[property] = order;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return styles;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
var generateDimentionStyles = function generateDimentionStyles(_ref4) {
|
|
90
|
-
var dimentionsProps = _ref4.dimentionsProps;
|
|
91
|
-
var styles = {};
|
|
92
|
-
dimentionsProps.forEach(function (_ref5) {
|
|
93
|
-
var property = _ref5.property,
|
|
94
|
-
value = _ref5.value;
|
|
95
|
-
|
|
96
|
-
if (isObject(value)) {
|
|
97
|
-
var defaultValue = value.default,
|
|
98
|
-
mobile = value.mobile,
|
|
99
|
-
tablet = value.tablet;
|
|
100
|
-
styles["--".concat(propNameToShorthand(property), "-dft")] = getDimension(defaultValue);
|
|
101
|
-
styles["--".concat(propNameToShorthand(property), "-mbl")] = getDimension(mobile);
|
|
102
|
-
styles["--".concat(propNameToShorthand(property), "-tbl")] = getDimension(tablet);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
styles["--".concat(propNameToShorthand(property))] = getDimension(value);
|
|
107
|
-
});
|
|
108
|
-
return styles;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
var generateColorStyles = function generateColorStyles(_ref6) {
|
|
112
|
-
var colorProps = _ref6.colorProps;
|
|
113
|
-
var styles = {};
|
|
114
|
-
var classNames = [];
|
|
115
|
-
colorProps.forEach(function (_ref7) {
|
|
116
|
-
var property = _ref7.property,
|
|
117
|
-
value = _ref7.value;
|
|
118
|
-
|
|
119
|
-
if (isColorVar(value)) {
|
|
120
|
-
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
121
|
-
} else {
|
|
122
|
-
styles["--".concat(propNameToShorthand(property))] = getColor(value);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
return {
|
|
126
|
-
className: classNames.join(' '),
|
|
127
|
-
style: styles
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
var genereateShadowStyles = function genereateShadowStyles(_ref8) {
|
|
132
|
-
var shadowProps = _ref8.shadowProps;
|
|
133
|
-
var styles = {};
|
|
134
|
-
var classNames = [];
|
|
135
|
-
shadowProps.forEach(function (_ref9) {
|
|
136
|
-
var property = _ref9.property,
|
|
137
|
-
value = _ref9.value;
|
|
138
|
-
|
|
139
|
-
if (value in vars.shadows) {
|
|
140
|
-
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
141
|
-
} else {
|
|
142
|
-
styles["--".concat(propNameToShorthand(property))] = getShadow(value);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return {
|
|
146
|
-
className: classNames.join(' '),
|
|
147
|
-
style: styles
|
|
148
|
-
};
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
var generateRadiusStyles = function generateRadiusStyles(_ref10) {
|
|
152
|
-
var radiusProps = _ref10.radiusProps;
|
|
153
|
-
var styles = {};
|
|
154
|
-
var classNames = [];
|
|
155
|
-
radiusProps.forEach(function (_ref11) {
|
|
156
|
-
var property = _ref11.property,
|
|
157
|
-
value = _ref11.value;
|
|
158
|
-
|
|
159
|
-
if (value in vars.radii) {
|
|
160
|
-
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
161
|
-
} else {
|
|
162
|
-
styles["--".concat(propNameToShorthand(property))] = getRadius(value);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
className: classNames.join(' '),
|
|
167
|
-
style: styles
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
var generateZIndexStyles = function generateZIndexStyles(_ref12) {
|
|
172
|
-
var zIndex = _ref12.zIndex;
|
|
173
|
-
var styles = {};
|
|
174
|
-
styles["zIndex"] = zIndex;
|
|
175
|
-
return styles;
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
var generatePositionStyles = function generatePositionStyles(_ref13) {
|
|
179
|
-
var position = _ref13.position;
|
|
180
|
-
|
|
181
|
-
if (position) {
|
|
182
|
-
return "".concat(propNameToShorthand('position'), "-").concat(position);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
var generateOverflowStyles = function generateOverflowStyles(_ref14) {
|
|
187
|
-
var overflowProps = _ref14.overflowProps;
|
|
188
|
-
var classNames = [];
|
|
189
|
-
overflowProps.forEach(function (_ref15) {
|
|
190
|
-
var property = _ref15.property,
|
|
191
|
-
value = _ref15.value;
|
|
192
|
-
|
|
193
|
-
if (overflows.includes(value)) {
|
|
194
|
-
classNames.push("".concat(propNameToShorthand(property), "-").concat(value));
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return classNames.join(' ');
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export var Box2 = /*#__PURE__*/forwardRef(function (_ref16, ref) {
|
|
201
|
-
var all = _ref16.all,
|
|
202
|
-
color = _ref16.color,
|
|
203
|
-
colorHover = _ref16.colorHover,
|
|
204
|
-
backgroundColor = _ref16.backgroundColor,
|
|
205
|
-
backgroundColorHover = _ref16.backgroundColorHover,
|
|
206
|
-
borderColorHover = _ref16.borderColorHover,
|
|
207
|
-
borderSide = _ref16.borderSide,
|
|
208
|
-
width = _ref16.width,
|
|
209
|
-
minWidth = _ref16.minWidth,
|
|
210
|
-
maxWidth = _ref16.maxWidth,
|
|
211
|
-
height = _ref16.height,
|
|
212
|
-
minHeight = _ref16.minHeight,
|
|
213
|
-
maxHeight = _ref16.maxHeight,
|
|
214
|
-
radius = _ref16.radius,
|
|
215
|
-
padding = _ref16.padding,
|
|
216
|
-
paddingTop = _ref16.paddingTop,
|
|
217
|
-
paddingBottom = _ref16.paddingBottom,
|
|
218
|
-
paddingLeft = _ref16.paddingLeft,
|
|
219
|
-
paddingRight = _ref16.paddingRight,
|
|
220
|
-
paddingX = _ref16.paddingX,
|
|
221
|
-
paddingY = _ref16.paddingY,
|
|
222
|
-
margin = _ref16.margin,
|
|
223
|
-
marginTop = _ref16.marginTop,
|
|
224
|
-
marginBottom = _ref16.marginBottom,
|
|
225
|
-
marginLeft = _ref16.marginLeft,
|
|
226
|
-
marginRight = _ref16.marginRight,
|
|
227
|
-
marginX = _ref16.marginX,
|
|
228
|
-
marginY = _ref16.marginY,
|
|
229
|
-
position = _ref16.position,
|
|
230
|
-
top = _ref16.top,
|
|
231
|
-
bottom = _ref16.bottom,
|
|
232
|
-
left = _ref16.left,
|
|
233
|
-
right = _ref16.right,
|
|
234
|
-
shadow = _ref16.shadow,
|
|
235
|
-
shadowHover = _ref16.shadowHover,
|
|
236
|
-
overflow = _ref16.overflow,
|
|
237
|
-
overflowX = _ref16.overflowX,
|
|
238
|
-
overflowY = _ref16.overflowY,
|
|
239
|
-
aspectRatio = _ref16.aspectRatio,
|
|
240
|
-
zIndex = _ref16.zIndex,
|
|
241
|
-
_ref16$tag = _ref16.tag,
|
|
242
|
-
tag = _ref16$tag === void 0 ? 'div' : _ref16$tag,
|
|
243
|
-
opacity = _ref16.opacity,
|
|
244
|
-
opacityHover = _ref16.opacityHover,
|
|
245
|
-
order = _ref16.order,
|
|
246
|
-
alignSelf = _ref16.alignSelf,
|
|
247
|
-
flex = _ref16.flex,
|
|
248
|
-
transition = _ref16.transition,
|
|
249
|
-
transitionHover = _ref16.transitionHover,
|
|
250
|
-
cursor = _ref16.cursor,
|
|
251
|
-
children = _ref16.children,
|
|
252
|
-
className = _ref16.className,
|
|
253
|
-
style = _ref16.style,
|
|
254
|
-
otherProps = _objectWithoutProperties(_ref16, _excluded);
|
|
255
|
-
|
|
256
|
-
var spaceProps = [{
|
|
257
|
-
property: 'padding',
|
|
258
|
-
value: padding
|
|
259
|
-
}, {
|
|
260
|
-
property: 'paddingTop',
|
|
261
|
-
value: paddingTop
|
|
262
|
-
}, {
|
|
263
|
-
property: 'paddingBottom',
|
|
264
|
-
value: paddingBottom
|
|
265
|
-
}, {
|
|
266
|
-
property: 'paddingLeft',
|
|
267
|
-
value: paddingLeft
|
|
268
|
-
}, {
|
|
269
|
-
property: 'paddingRight',
|
|
270
|
-
value: paddingRight
|
|
271
|
-
}, {
|
|
272
|
-
property: 'paddingX',
|
|
273
|
-
value: paddingX
|
|
274
|
-
}, {
|
|
275
|
-
property: 'paddingY',
|
|
276
|
-
value: paddingY
|
|
277
|
-
}, {
|
|
278
|
-
property: 'margin',
|
|
279
|
-
value: margin
|
|
280
|
-
}, {
|
|
281
|
-
property: 'marginTop',
|
|
282
|
-
value: marginTop
|
|
283
|
-
}, {
|
|
284
|
-
property: 'marginBottom',
|
|
285
|
-
value: marginBottom
|
|
286
|
-
}, {
|
|
287
|
-
property: 'marginLeft',
|
|
288
|
-
value: marginLeft
|
|
289
|
-
}, {
|
|
290
|
-
property: 'marginRight',
|
|
291
|
-
value: marginRight
|
|
292
|
-
}, {
|
|
293
|
-
property: 'marginX',
|
|
294
|
-
value: marginX
|
|
295
|
-
}, {
|
|
296
|
-
property: 'marginY',
|
|
297
|
-
value: marginY
|
|
298
|
-
}, {
|
|
299
|
-
property: 'top',
|
|
300
|
-
value: top
|
|
301
|
-
}, {
|
|
302
|
-
property: 'bottom',
|
|
303
|
-
value: bottom
|
|
304
|
-
}, {
|
|
305
|
-
property: 'left',
|
|
306
|
-
value: left
|
|
307
|
-
}, {
|
|
308
|
-
property: 'right',
|
|
309
|
-
value: right
|
|
310
|
-
}];
|
|
311
|
-
var dimentionsProps = [{
|
|
312
|
-
property: 'width',
|
|
313
|
-
value: width
|
|
314
|
-
}, {
|
|
315
|
-
property: 'minWidth',
|
|
316
|
-
value: minWidth
|
|
317
|
-
}, {
|
|
318
|
-
property: 'maxWidth',
|
|
319
|
-
value: maxWidth
|
|
320
|
-
}, {
|
|
321
|
-
property: 'height',
|
|
322
|
-
value: height
|
|
323
|
-
}, {
|
|
324
|
-
property: 'minHeight',
|
|
325
|
-
value: minHeight
|
|
326
|
-
}, {
|
|
327
|
-
property: 'maxHeight',
|
|
328
|
-
value: maxHeight
|
|
329
|
-
}];
|
|
330
|
-
var colorProps = [{
|
|
331
|
-
property: 'color',
|
|
332
|
-
value: color
|
|
333
|
-
}, {
|
|
334
|
-
property: 'colorHover',
|
|
335
|
-
value: colorHover
|
|
336
|
-
}, {
|
|
337
|
-
property: 'backgroundColor',
|
|
338
|
-
value: backgroundColor
|
|
339
|
-
}, {
|
|
340
|
-
property: 'backgroundColorHover',
|
|
341
|
-
value: backgroundColorHover
|
|
342
|
-
}];
|
|
343
|
-
var shadowProps = [{
|
|
344
|
-
property: 'shadow',
|
|
345
|
-
value: shadow
|
|
346
|
-
}, {
|
|
347
|
-
property: 'shadowHover',
|
|
348
|
-
value: shadowHover
|
|
349
|
-
}];
|
|
350
|
-
var radiusProps = [{
|
|
351
|
-
property: 'radius',
|
|
352
|
-
value: radius
|
|
353
|
-
}];
|
|
354
|
-
var overflowProps = [{
|
|
355
|
-
property: 'overflow',
|
|
356
|
-
value: overflow
|
|
357
|
-
}, {
|
|
358
|
-
property: 'overflowX',
|
|
359
|
-
value: overflowX
|
|
360
|
-
}, {
|
|
361
|
-
property: 'overflowY',
|
|
362
|
-
value: overflowY
|
|
363
|
-
}];
|
|
364
155
|
|
|
365
|
-
var styles = _objectSpread(
|
|
366
|
-
dimentionsProps: dimentionsProps
|
|
367
|
-
})), generateSpaceStyles({
|
|
368
|
-
spaceProps: spaceProps
|
|
369
|
-
}).style), generateColorStyles({
|
|
370
|
-
colorProps: colorProps
|
|
371
|
-
}).style), genereateShadowStyles({
|
|
372
|
-
shadowProps: shadowProps
|
|
373
|
-
}).style), generateRadiusStyles({
|
|
374
|
-
radiusProps: radiusProps
|
|
375
|
-
}).style), generateOrderStyles({
|
|
376
|
-
order: order
|
|
377
|
-
})), generateZIndexStyles({
|
|
378
|
-
zIndex: zIndex
|
|
379
|
-
}));
|
|
156
|
+
var styles = _objectSpread({}, generateStyleAttributes([dimensionProps, colorProps, spaceProps, shadowProps, radiusProps, orderProps, zIndexProps, transitionProps, aspectRatioProps, flexProps], allProps));
|
|
380
157
|
|
|
381
|
-
var
|
|
382
|
-
var classNames = [
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
colorProps: colorProps
|
|
386
|
-
}).className, genereateShadowStyles({
|
|
387
|
-
shadowProps: shadowProps
|
|
388
|
-
}).className, generateRadiusStyles({
|
|
389
|
-
radiusProps: radiusProps
|
|
390
|
-
}).className, generatePositionStyles({
|
|
391
|
-
position: position
|
|
392
|
-
}), generateOverflowStyles({
|
|
393
|
-
overflowProps: overflowProps
|
|
394
|
-
}), propClassname].join(' ').replace(/\s+/g, ' ').trim();
|
|
395
|
-
return ___EmotionJSX("div", _extends({
|
|
158
|
+
var propClassName = className ? className : '';
|
|
159
|
+
var classNames = [generateClassNameAttributes([spaceProps, colorProps, shadowProps, radiusProps, positionProps, overflowProps, transitionProps, cursorProps], allProps), propClassName].join(' ').replace(/\s+/g, ' ').trim();
|
|
160
|
+
var Tag = tag;
|
|
161
|
+
return ___EmotionJSX(Tag, _extends({
|
|
396
162
|
ref: ref,
|
|
397
|
-
as: tag,
|
|
398
163
|
style: styles,
|
|
399
164
|
className: classNames
|
|
400
165
|
}, otherProps), children);
|
package/es/styles/utilities.js
CHANGED
|
@@ -1,108 +1,67 @@
|
|
|
1
|
-
import "core-js/modules/es.object.keys.js";
|
|
2
1
|
import "core-js/modules/es.object.to-string.js";
|
|
3
2
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
4
3
|
import "core-js/modules/es.array.concat.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { vars } from '../variables';
|
|
8
|
-
var spaces = Object.keys(vars.spaces);
|
|
9
|
-
var colors = Object.keys(vars.colors);
|
|
10
|
-
var shadows = Object.keys(vars.shadows);
|
|
11
|
-
var radii = Object.keys(vars.radii);
|
|
12
|
-
var spaceProperties = ['padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', 'padding-inline', 'padding-block', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'margin-inline', 'margin-block', 'top', 'bottom', 'left', 'right', 'width', 'height', 'min-width', 'max-width', 'min-height', 'max-height'];
|
|
13
|
-
var colorProperties = ['color', 'background-color'];
|
|
4
|
+
import { styleConfig } from '../utilities';
|
|
5
|
+
import { propNameToShort } from '../utilities/style-config';
|
|
14
6
|
|
|
15
|
-
function
|
|
7
|
+
var generateUtilityClasses = function generateUtilityClasses(propertySets) {
|
|
16
8
|
var css = '';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
colorProperties.forEach(function (property) {
|
|
24
|
-
css += "\n .".concat(propertyToShorthand(property), "-").concat(color, " {\n ").concat(property, ": ").concat(getColor(color), "\n }");
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
[].concat(spaceProperties, colorProperties).forEach(function (property) {
|
|
28
|
-
css += "\n [style*=\"--".concat(propertyToShorthand(property), ":\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), ")\n }");
|
|
29
|
-
});
|
|
30
|
-
return css;
|
|
31
|
-
}
|
|
9
|
+
propertySets.forEach(function (set) {
|
|
10
|
+
set.variables.forEach(function (variable) {
|
|
11
|
+
set.props.forEach(function (prop) {
|
|
12
|
+
var property = prop.property;
|
|
13
|
+
var cssValue = set.valueTransformer ? set.valueTransformer(variable) : variable;
|
|
14
|
+
var hasHover = prop.modifier === 'hover';
|
|
32
15
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
colorProperties.forEach(function (property) {
|
|
37
|
-
css += "\n .".concat(propertyToShorthand(property), "-hover-").concat(color, ":hover {\n ").concat(property, ": ").concat(getColor(color), "\n }\n ");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
colorProperties.forEach(function (property) {
|
|
41
|
-
css += "\n [style*=\"--".concat(propertyToShorthand(property), "-hover\"]:hover {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-hover)\n }\n ");
|
|
42
|
-
});
|
|
43
|
-
return css;
|
|
44
|
-
};
|
|
16
|
+
if (!hasHover) {
|
|
17
|
+
css += "\n .".concat(propNameToShort(prop.propName), "-").concat(variable, " {\n ").concat(property, ": ").concat(cssValue, "\n }");
|
|
18
|
+
}
|
|
45
19
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return css;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var generateShadowCSS = function generateShadowCSS() {
|
|
55
|
-
var css = '';
|
|
56
|
-
var property = 'box-shadow';
|
|
57
|
-
shadows.forEach(function (shadow) {
|
|
58
|
-
css += "\n .".concat(propertyToShorthand(property), "-").concat(shadow, " {\n ").concat(property, ": ").concat(getShadow(shadow), "\n }\n .").concat(propertyToShorthand(property), "-hover-").concat(shadow, ":hover {\n ").concat(property, ": ").concat(getShadow(shadow), "\n }\n ");
|
|
59
|
-
css += "\n [style*=\"--".concat(propertyToShorthand(property), "\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), ")\n }\n [style*=\"--").concat(propertyToShorthand(property), "-hover\"]:hover {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-hover)\n }\n ");
|
|
20
|
+
if (hasHover) {
|
|
21
|
+
css += "\n .".concat(propNameToShort(prop.propName), "-").concat(variable, ":hover {\n ").concat(property, ": ").concat(cssValue, "\n }");
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
60
25
|
});
|
|
61
26
|
return css;
|
|
62
27
|
};
|
|
63
28
|
|
|
64
|
-
var
|
|
29
|
+
var generateStyleClasses = function generateStyleClasses(propertySets) {
|
|
65
30
|
var css = '';
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
31
|
+
propertySets.forEach(function (set) {
|
|
32
|
+
set.props.forEach(function (prop) {
|
|
33
|
+
var property = prop.property;
|
|
34
|
+
var propName = prop.propName;
|
|
35
|
+
var cssVar = "--".concat(propNameToShort(propName));
|
|
36
|
+
var hasHover = prop.modifier === 'hover';
|
|
73
37
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
css += "\n [style*=\"--".concat(propertyToShorthand(property), "-dft\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-dft)\n }\n @media (max-width: 1169px) {\n [style*=\"--").concat(propertyToShorthand(property), "-tbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-tbl);\n }\n }\n @media (max-width: 767px) {\n [style*=\"--").concat(propertyToShorthand(property), "-mbl\"] {\n ").concat(property, ": var(--").concat(propertyToShorthand(property), "-mbl);\n }\n }\n ");
|
|
78
|
-
return css;
|
|
79
|
-
};
|
|
38
|
+
if (!hasHover) {
|
|
39
|
+
css += "\n [style*=\"".concat(cssVar, ":\"] {\n ").concat(property, ": var(").concat(cssVar, ")\n }");
|
|
40
|
+
}
|
|
80
41
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
positions.forEach(function (value) {
|
|
85
|
-
css += "\n .".concat(propertyToShorthand(property), "-").concat(value, " {\n ").concat(property, ": ").concat(value, "\n }\n ");
|
|
86
|
-
});
|
|
87
|
-
return css;
|
|
88
|
-
};
|
|
42
|
+
if (hasHover) {
|
|
43
|
+
css += "\n [style*=\"".concat(cssVar, "\"]:hover {\n ").concat(property, ": var(").concat(cssVar, ")\n }");
|
|
44
|
+
}
|
|
89
45
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
css += "\n .".concat(propertyToShorthand(property), "-").concat(value, " {\n ").concat(property, ": ").concat(value, "\n }\n ");
|
|
46
|
+
if (set.isResponsive) {
|
|
47
|
+
css += "\n [style*=\"".concat(cssVar, "-def\"] {\n ").concat(property, ": var(").concat(cssVar, "-def)\n }\n\n @media (max-width: 1169px) {\n [style*=\"").concat(cssVar, "-tab\"] {\n ").concat(property, ": var(").concat(cssVar, "-tab);\n }\n }\n\n @media (max-width: 767px) {\n [style*=\"").concat(cssVar, "-mob\"] {\n ").concat(property, ": var(").concat(cssVar, "-mob);\n }\n }\n ");
|
|
48
|
+
}
|
|
49
|
+
});
|
|
95
50
|
});
|
|
96
51
|
return css;
|
|
97
52
|
};
|
|
98
53
|
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
54
|
+
var spaceProps = styleConfig.spaceProps,
|
|
55
|
+
colorProps = styleConfig.colorProps,
|
|
56
|
+
shadowProps = styleConfig.shadowProps,
|
|
57
|
+
radiusProps = styleConfig.radiusProps,
|
|
58
|
+
positionProps = styleConfig.positionProps,
|
|
59
|
+
overflowProps = styleConfig.overflowProps,
|
|
60
|
+
transitionProps = styleConfig.transitionProps,
|
|
61
|
+
cursorProps = styleConfig.cursorProps,
|
|
62
|
+
dimensionProps = styleConfig.dimensionProps,
|
|
63
|
+
aspectRatioProps = styleConfig.aspectRatioProps,
|
|
64
|
+
orderProps = styleConfig.orderProps,
|
|
65
|
+
flexProps = styleConfig.flexProps;
|
|
66
|
+
var utilities = "\n ".concat(generateUtilityClasses([spaceProps, colorProps, shadowProps, radiusProps, positionProps, overflowProps, transitionProps, cursorProps]), ";\n\n ").concat(generateStyleClasses([dimensionProps, spaceProps, colorProps, shadowProps, radiusProps, transitionProps, aspectRatioProps, orderProps, flexProps]), ";\n");
|
|
108
67
|
export default utilities;
|
package/es/types.js
CHANGED
|
@@ -19,6 +19,7 @@ export var alignSelfs = [].concat(axisAlignments, ['baseline']);
|
|
|
19
19
|
export var flexWraps = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
20
20
|
export var overflows = ['visible', 'hidden', 'scroll', 'auto'];
|
|
21
21
|
export var positions = ['static', 'relative', 'fixed', 'absolute', 'sticky'];
|
|
22
|
+
export var cursors = ['default', 'pointer'];
|
|
22
23
|
export var types = {
|
|
23
24
|
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
24
25
|
responsiveSpace: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.spaces)), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
@@ -59,7 +60,7 @@ export var types = {
|
|
|
59
60
|
buttonTag: PropTypes.oneOf(['button', 'a', 'span']),
|
|
60
61
|
hint: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
61
62
|
transition: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.transitions)), PropTypes.string]),
|
|
62
|
-
cursor: PropTypes.oneOf(
|
|
63
|
+
cursor: PropTypes.oneOf(cursors)
|
|
63
64
|
};
|
|
64
65
|
export var defaultProps = {
|
|
65
66
|
menuMaxHeight: '468px',
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
|
2
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
3
|
+
import "core-js/modules/es.array.concat.js";
|
|
4
|
+
import { isObject } from './helpers';
|
|
5
|
+
import { propNameToShort } from './style-config';
|
|
6
|
+
export var generateStyleAttributes = function generateStyleAttributes(propsSets, allProps) {
|
|
7
|
+
var styles = {};
|
|
8
|
+
propsSets.forEach(function (propsSet) {
|
|
9
|
+
propsSet.props.forEach(function (_ref) {
|
|
10
|
+
var propName = _ref.propName;
|
|
11
|
+
var value = allProps[propName];
|
|
12
|
+
var hasVariable = propsSet.variableChecker ? propsSet.variableChecker(value) : false;
|
|
13
|
+
var hasTransformer = propsSet.valueTransformer ? true : false;
|
|
14
|
+
if (hasVariable) return;
|
|
15
|
+
if (!value) return;
|
|
16
|
+
var cssValue = hasTransformer ? propsSet.valueTransformer(value) : value;
|
|
17
|
+
var propNameShort = propNameToShort(propName);
|
|
18
|
+
|
|
19
|
+
if (!isObject(value)) {
|
|
20
|
+
styles["--".concat(propNameShort)] = cssValue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isObject(value)) {
|
|
24
|
+
var def = value.default,
|
|
25
|
+
mobile = value.mobile,
|
|
26
|
+
tablet = value.tablet;
|
|
27
|
+
var defaultValueCss = hasTransformer ? propsSet.valueTransformer(def) : def;
|
|
28
|
+
var mobileValueCss = hasTransformer ? propsSet.valueTransformer(mobile) : mobile;
|
|
29
|
+
var tabletValueCss = hasTransformer ? propsSet.valueTransformer(tablet) : tablet;
|
|
30
|
+
styles["--".concat(propNameShort, "-def")] = defaultValueCss;
|
|
31
|
+
styles["--".concat(propNameShort, "-mob")] = mobileValueCss;
|
|
32
|
+
styles["--".concat(propNameShort, "-tab")] = tabletValueCss;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return styles;
|
|
37
|
+
};
|
|
38
|
+
export var generateClassNameAttributes = function generateClassNameAttributes(propsSets, allProps) {
|
|
39
|
+
var classNames = [];
|
|
40
|
+
propsSets.forEach(function (propsSet) {
|
|
41
|
+
propsSet.props.forEach(function (_ref2) {
|
|
42
|
+
var propName = _ref2.propName;
|
|
43
|
+
var value = allProps[propName];
|
|
44
|
+
var hasVariable = propsSet.variableChecker ? propsSet.variableChecker(value) : false;
|
|
45
|
+
if (!hasVariable) return;
|
|
46
|
+
if (!value) return;
|
|
47
|
+
var className = "".concat(propNameToShort(propName), "-").concat(value);
|
|
48
|
+
classNames.push(className);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return classNames.join(' ');
|
|
52
|
+
};
|
package/es/utilities/helpers.js
CHANGED
|
@@ -3,7 +3,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
3
3
|
import "core-js/modules/es.array.concat.js";
|
|
4
4
|
import "core-js/modules/es.object.to-string.js";
|
|
5
5
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
6
|
-
import "core-js/modules/es.array.find.js";
|
|
7
6
|
import "core-js/modules/es.symbol.js";
|
|
8
7
|
import "core-js/modules/es.symbol.description.js";
|
|
9
8
|
import "core-js/modules/es.symbol.iterator.js";
|
|
@@ -45,165 +44,4 @@ export var mergeRefs = function mergeRefs(refs) {
|
|
|
45
44
|
}
|
|
46
45
|
});
|
|
47
46
|
};
|
|
48
|
-
};
|
|
49
|
-
var shortHandProps = [{
|
|
50
|
-
propName: 'padding',
|
|
51
|
-
property: 'padding',
|
|
52
|
-
value: 'p'
|
|
53
|
-
}, {
|
|
54
|
-
propName: 'paddingTop',
|
|
55
|
-
property: 'padding-top',
|
|
56
|
-
value: 'pt'
|
|
57
|
-
}, {
|
|
58
|
-
propName: 'paddingBottom',
|
|
59
|
-
property: 'padding-bottom',
|
|
60
|
-
value: 'pb'
|
|
61
|
-
}, {
|
|
62
|
-
propName: 'paddingLeft',
|
|
63
|
-
property: 'padding-left',
|
|
64
|
-
value: 'pl'
|
|
65
|
-
}, {
|
|
66
|
-
propName: 'paddingRight',
|
|
67
|
-
property: 'padding-right',
|
|
68
|
-
value: 'pr'
|
|
69
|
-
}, {
|
|
70
|
-
propName: 'paddingX',
|
|
71
|
-
property: 'padding-inline',
|
|
72
|
-
value: 'px'
|
|
73
|
-
}, {
|
|
74
|
-
propName: 'paddingY',
|
|
75
|
-
property: 'padding-block',
|
|
76
|
-
value: 'py'
|
|
77
|
-
}, {
|
|
78
|
-
propName: 'margin',
|
|
79
|
-
property: 'margin',
|
|
80
|
-
value: 'm'
|
|
81
|
-
}, {
|
|
82
|
-
propName: 'marginTop',
|
|
83
|
-
property: 'margin-top',
|
|
84
|
-
value: 'mt'
|
|
85
|
-
}, {
|
|
86
|
-
propName: 'marginBottom',
|
|
87
|
-
property: 'margin-bottom',
|
|
88
|
-
value: 'mb'
|
|
89
|
-
}, {
|
|
90
|
-
propName: 'marginLeft',
|
|
91
|
-
property: 'margin-left',
|
|
92
|
-
value: 'ml'
|
|
93
|
-
}, {
|
|
94
|
-
propName: 'marginRight',
|
|
95
|
-
property: 'margin-right',
|
|
96
|
-
value: 'mr'
|
|
97
|
-
}, {
|
|
98
|
-
propName: 'marginX',
|
|
99
|
-
property: 'margin-inline',
|
|
100
|
-
value: 'mx'
|
|
101
|
-
}, {
|
|
102
|
-
propName: 'marginY',
|
|
103
|
-
property: 'margin-block',
|
|
104
|
-
value: 'my'
|
|
105
|
-
}, {
|
|
106
|
-
propName: 'top',
|
|
107
|
-
property: 'top',
|
|
108
|
-
value: 't'
|
|
109
|
-
}, {
|
|
110
|
-
propName: 'bottom',
|
|
111
|
-
property: 'bottom',
|
|
112
|
-
value: 'b'
|
|
113
|
-
}, {
|
|
114
|
-
propName: 'left',
|
|
115
|
-
property: 'left',
|
|
116
|
-
value: 'l'
|
|
117
|
-
}, {
|
|
118
|
-
propName: 'right',
|
|
119
|
-
property: 'right',
|
|
120
|
-
value: 'r'
|
|
121
|
-
}, {
|
|
122
|
-
propName: 'width',
|
|
123
|
-
property: 'width',
|
|
124
|
-
value: 'w'
|
|
125
|
-
}, {
|
|
126
|
-
propName: 'height',
|
|
127
|
-
property: 'height',
|
|
128
|
-
value: 'h'
|
|
129
|
-
}, {
|
|
130
|
-
propName: 'minWidth',
|
|
131
|
-
property: 'min-width',
|
|
132
|
-
value: 'min-w'
|
|
133
|
-
}, {
|
|
134
|
-
propName: 'maxWidth',
|
|
135
|
-
property: 'max-width',
|
|
136
|
-
value: 'max-w'
|
|
137
|
-
}, {
|
|
138
|
-
propName: 'minHeight',
|
|
139
|
-
property: 'min-height',
|
|
140
|
-
value: 'min-h'
|
|
141
|
-
}, {
|
|
142
|
-
propName: 'maxHeight',
|
|
143
|
-
property: 'max-height',
|
|
144
|
-
value: 'max-h'
|
|
145
|
-
}, {
|
|
146
|
-
propName: 'color',
|
|
147
|
-
property: 'color',
|
|
148
|
-
value: 'c'
|
|
149
|
-
}, {
|
|
150
|
-
propName: 'colorHover',
|
|
151
|
-
property: 'color',
|
|
152
|
-
value: 'c-hover'
|
|
153
|
-
}, {
|
|
154
|
-
propName: 'backgroundColor',
|
|
155
|
-
property: 'background-color',
|
|
156
|
-
value: 'bgc'
|
|
157
|
-
}, {
|
|
158
|
-
propName: 'backgroundColorHover',
|
|
159
|
-
property: 'background-color',
|
|
160
|
-
value: 'bgc-hover'
|
|
161
|
-
}, {
|
|
162
|
-
propName: 'shadow',
|
|
163
|
-
property: 'box-shadow',
|
|
164
|
-
value: 'sh'
|
|
165
|
-
}, {
|
|
166
|
-
propName: 'shadowHover',
|
|
167
|
-
property: 'box-shadow',
|
|
168
|
-
value: 'sh-hover'
|
|
169
|
-
}, {
|
|
170
|
-
propName: 'radius',
|
|
171
|
-
property: 'border-radius',
|
|
172
|
-
value: 'rad'
|
|
173
|
-
}, {
|
|
174
|
-
propName: 'order',
|
|
175
|
-
property: 'order',
|
|
176
|
-
value: 'order'
|
|
177
|
-
}, {
|
|
178
|
-
propName: 'position',
|
|
179
|
-
property: 'position',
|
|
180
|
-
value: 'pos'
|
|
181
|
-
}, {
|
|
182
|
-
propName: 'overflow',
|
|
183
|
-
property: 'overflow',
|
|
184
|
-
value: 'ovf'
|
|
185
|
-
}, {
|
|
186
|
-
propName: 'overflowX',
|
|
187
|
-
property: 'overflow-x',
|
|
188
|
-
value: 'ovf-x'
|
|
189
|
-
}, {
|
|
190
|
-
propName: 'overflowY',
|
|
191
|
-
property: 'overflow-y',
|
|
192
|
-
value: 'ovf-y'
|
|
193
|
-
}];
|
|
194
|
-
export var propertyToShorthand = function propertyToShorthand(property) {
|
|
195
|
-
var _shortHandProps$find;
|
|
196
|
-
|
|
197
|
-
return (_shortHandProps$find = shortHandProps.find(function (_ref) {
|
|
198
|
-
var prop = _ref.property;
|
|
199
|
-
return prop === property;
|
|
200
|
-
})) === null || _shortHandProps$find === void 0 ? void 0 : _shortHandProps$find.value;
|
|
201
|
-
};
|
|
202
|
-
export var propNameToShorthand = function propNameToShorthand(propName) {
|
|
203
|
-
var _shortHandProps$find2;
|
|
204
|
-
|
|
205
|
-
return (_shortHandProps$find2 = shortHandProps.find(function (_ref2) {
|
|
206
|
-
var prop = _ref2.propName;
|
|
207
|
-
return prop === propName;
|
|
208
|
-
})) === null || _shortHandProps$find2 === void 0 ? void 0 : _shortHandProps$find2.value;
|
|
209
47
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import "core-js/modules/es.array.concat.js";
|
|
2
|
+
import "core-js/modules/es.object.keys.js";
|
|
3
|
+
import "core-js/modules/es.array.includes.js";
|
|
4
|
+
import "core-js/modules/es.string.includes.js";
|
|
5
|
+
import "core-js/modules/es.array.find.js";
|
|
6
|
+
import "core-js/modules/es.object.to-string.js";
|
|
7
|
+
import "core-js/modules/es.object.values.js";
|
|
8
|
+
import "core-js/modules/es.symbol.js";
|
|
9
|
+
import "core-js/modules/es.symbol.description.js";
|
|
10
|
+
import "core-js/modules/es.symbol.iterator.js";
|
|
11
|
+
import "core-js/modules/es.array.iterator.js";
|
|
12
|
+
import "core-js/modules/es.string.iterator.js";
|
|
13
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
14
|
+
import "core-js/modules/es.array.from.js";
|
|
15
|
+
import "core-js/modules/es.array.slice.js";
|
|
16
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
17
|
+
|
|
18
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
19
|
+
|
|
20
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
|
|
22
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
+
|
|
24
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
25
|
+
|
|
26
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
+
|
|
28
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
+
|
|
30
|
+
import { cursors, overflows, positions } from '../types';
|
|
31
|
+
import { vars } from '../variables';
|
|
32
|
+
import { getDimension, getSpace, isSpaceVar } from './responsive';
|
|
33
|
+
import { getColor, getRadius, getShadow, getTransition, isColorVar, isRadiusVar, isShadowVar, isTrasitionVar } from './styles';
|
|
34
|
+
var spaces = [].concat(_toConsumableArray(Object.keys(vars.spaces)), _toConsumableArray(Object.keys(vars.spaceUtils)));
|
|
35
|
+
var colors = [].concat(_toConsumableArray(Object.keys(vars.colors)), _toConsumableArray(Object.keys(vars.colorUtils)));
|
|
36
|
+
var shadows = Object.keys(vars.shadows);
|
|
37
|
+
var radii = Object.keys(vars.radii);
|
|
38
|
+
var transitions = [].concat(_toConsumableArray(Object.keys(vars.transitions)), _toConsumableArray(Object.keys(vars.transitionUtils)));
|
|
39
|
+
export var styleConfig = {
|
|
40
|
+
spaceProps: {
|
|
41
|
+
props: [{
|
|
42
|
+
propName: 'padding',
|
|
43
|
+
property: 'padding',
|
|
44
|
+
short: 'p'
|
|
45
|
+
}, {
|
|
46
|
+
propName: 'paddingTop',
|
|
47
|
+
property: 'padding-top',
|
|
48
|
+
short: 'pt'
|
|
49
|
+
}, {
|
|
50
|
+
propName: 'paddingBottom',
|
|
51
|
+
property: 'padding-bottom',
|
|
52
|
+
short: 'pb'
|
|
53
|
+
}, {
|
|
54
|
+
propName: 'paddingLeft',
|
|
55
|
+
property: 'padding-left',
|
|
56
|
+
short: 'pl'
|
|
57
|
+
}, {
|
|
58
|
+
propName: 'paddingRight',
|
|
59
|
+
property: 'padding-right',
|
|
60
|
+
short: 'pr'
|
|
61
|
+
}, {
|
|
62
|
+
propName: 'paddingX',
|
|
63
|
+
property: 'padding-inline',
|
|
64
|
+
short: 'px'
|
|
65
|
+
}, {
|
|
66
|
+
propName: 'paddingY',
|
|
67
|
+
property: 'padding-block',
|
|
68
|
+
short: 'py'
|
|
69
|
+
}, {
|
|
70
|
+
propName: 'margin',
|
|
71
|
+
property: 'margin',
|
|
72
|
+
short: 'm'
|
|
73
|
+
}, {
|
|
74
|
+
propName: 'marginTop',
|
|
75
|
+
property: 'margin-top',
|
|
76
|
+
short: 'mt'
|
|
77
|
+
}, {
|
|
78
|
+
propName: 'marginBottom',
|
|
79
|
+
property: 'margin-bottom',
|
|
80
|
+
short: 'mb'
|
|
81
|
+
}, {
|
|
82
|
+
propName: 'marginLeft',
|
|
83
|
+
property: 'margin-left',
|
|
84
|
+
short: 'ml'
|
|
85
|
+
}, {
|
|
86
|
+
propName: 'marginRight',
|
|
87
|
+
property: 'margin-right',
|
|
88
|
+
short: 'mr'
|
|
89
|
+
}, {
|
|
90
|
+
propName: 'marginX',
|
|
91
|
+
property: 'margin-inline',
|
|
92
|
+
short: 'mx'
|
|
93
|
+
}, {
|
|
94
|
+
propName: 'marginY',
|
|
95
|
+
property: 'margin-block',
|
|
96
|
+
short: 'my'
|
|
97
|
+
}, {
|
|
98
|
+
propName: 'top',
|
|
99
|
+
property: 'top',
|
|
100
|
+
short: 't'
|
|
101
|
+
}, {
|
|
102
|
+
propName: 'bottom',
|
|
103
|
+
property: 'bottom',
|
|
104
|
+
short: 'b'
|
|
105
|
+
}, {
|
|
106
|
+
propName: 'left',
|
|
107
|
+
property: 'left',
|
|
108
|
+
short: 'l'
|
|
109
|
+
}, {
|
|
110
|
+
propName: 'right',
|
|
111
|
+
property: 'right',
|
|
112
|
+
short: 'r'
|
|
113
|
+
}],
|
|
114
|
+
valueTransformer: getSpace,
|
|
115
|
+
variableChecker: isSpaceVar,
|
|
116
|
+
variables: spaces,
|
|
117
|
+
isResponsive: true
|
|
118
|
+
},
|
|
119
|
+
dimensionProps: {
|
|
120
|
+
props: [{
|
|
121
|
+
propName: 'width',
|
|
122
|
+
property: 'width',
|
|
123
|
+
short: 'w'
|
|
124
|
+
}, {
|
|
125
|
+
propName: 'minWidth',
|
|
126
|
+
property: 'height',
|
|
127
|
+
short: 'min-w'
|
|
128
|
+
}, {
|
|
129
|
+
propName: 'maxWidth',
|
|
130
|
+
property: 'min-width',
|
|
131
|
+
short: 'max-w'
|
|
132
|
+
}, {
|
|
133
|
+
propName: 'height',
|
|
134
|
+
property: 'max-width',
|
|
135
|
+
short: 'h'
|
|
136
|
+
}, {
|
|
137
|
+
propName: 'minHeight',
|
|
138
|
+
property: 'min-height',
|
|
139
|
+
short: 'min-h'
|
|
140
|
+
}, {
|
|
141
|
+
propName: 'maxHeight',
|
|
142
|
+
property: 'max-height',
|
|
143
|
+
short: 'max-h'
|
|
144
|
+
}],
|
|
145
|
+
valueTransformer: getDimension,
|
|
146
|
+
isResponsive: true
|
|
147
|
+
},
|
|
148
|
+
colorProps: {
|
|
149
|
+
props: [{
|
|
150
|
+
propName: 'color',
|
|
151
|
+
property: 'color',
|
|
152
|
+
short: 'c'
|
|
153
|
+
}, {
|
|
154
|
+
propName: 'colorHover',
|
|
155
|
+
property: 'color',
|
|
156
|
+
modifier: 'hover',
|
|
157
|
+
short: 'c-hover'
|
|
158
|
+
}, {
|
|
159
|
+
propName: 'backgroundColor',
|
|
160
|
+
property: 'background-color',
|
|
161
|
+
short: 'bgc'
|
|
162
|
+
}, {
|
|
163
|
+
propName: 'backgroundColorHover',
|
|
164
|
+
property: 'background-color',
|
|
165
|
+
modifier: 'hover',
|
|
166
|
+
short: 'bgc-hover'
|
|
167
|
+
}],
|
|
168
|
+
valueTransformer: getColor,
|
|
169
|
+
variableChecker: isColorVar,
|
|
170
|
+
variables: colors
|
|
171
|
+
},
|
|
172
|
+
shadowProps: {
|
|
173
|
+
props: [{
|
|
174
|
+
propName: 'shadow',
|
|
175
|
+
property: 'box-shadow',
|
|
176
|
+
short: 'sh'
|
|
177
|
+
}, {
|
|
178
|
+
propName: 'shadowHover',
|
|
179
|
+
property: 'box-shadow',
|
|
180
|
+
modifier: 'hover',
|
|
181
|
+
short: 'sh-hover'
|
|
182
|
+
}],
|
|
183
|
+
valueTransformer: getShadow,
|
|
184
|
+
variableChecker: isShadowVar,
|
|
185
|
+
variables: shadows
|
|
186
|
+
},
|
|
187
|
+
radiusProps: {
|
|
188
|
+
props: [{
|
|
189
|
+
propName: 'radius',
|
|
190
|
+
property: 'border-radius',
|
|
191
|
+
short: 'rad'
|
|
192
|
+
}],
|
|
193
|
+
valueTransformer: getRadius,
|
|
194
|
+
variableChecker: isRadiusVar,
|
|
195
|
+
variables: radii
|
|
196
|
+
},
|
|
197
|
+
orderProps: {
|
|
198
|
+
props: [{
|
|
199
|
+
propName: 'order',
|
|
200
|
+
property: 'order',
|
|
201
|
+
short: 'ord'
|
|
202
|
+
}]
|
|
203
|
+
},
|
|
204
|
+
flexProps: {
|
|
205
|
+
props: [{
|
|
206
|
+
propName: 'flex',
|
|
207
|
+
property: 'flex',
|
|
208
|
+
short: 'flex'
|
|
209
|
+
}],
|
|
210
|
+
isResponsive: true
|
|
211
|
+
},
|
|
212
|
+
zIndexProps: {
|
|
213
|
+
props: [{
|
|
214
|
+
propName: 'zIndex',
|
|
215
|
+
property: 'z-index',
|
|
216
|
+
short: 'z'
|
|
217
|
+
}]
|
|
218
|
+
},
|
|
219
|
+
positionProps: {
|
|
220
|
+
props: [{
|
|
221
|
+
propName: 'position',
|
|
222
|
+
property: 'position',
|
|
223
|
+
short: 'pos'
|
|
224
|
+
}],
|
|
225
|
+
variableChecker: function variableChecker(value) {
|
|
226
|
+
return positions.includes(value);
|
|
227
|
+
},
|
|
228
|
+
variables: positions
|
|
229
|
+
},
|
|
230
|
+
overflowProps: {
|
|
231
|
+
props: [{
|
|
232
|
+
propName: 'overflow',
|
|
233
|
+
property: 'overflow',
|
|
234
|
+
short: 'ovf'
|
|
235
|
+
}, {
|
|
236
|
+
propName: 'overflowX',
|
|
237
|
+
property: 'overflow-x',
|
|
238
|
+
short: 'ovf-x'
|
|
239
|
+
}, {
|
|
240
|
+
propName: 'overflowY',
|
|
241
|
+
property: 'overflow-y',
|
|
242
|
+
short: 'ovf-y'
|
|
243
|
+
}],
|
|
244
|
+
variableChecker: function variableChecker(value) {
|
|
245
|
+
return overflows.includes(value);
|
|
246
|
+
},
|
|
247
|
+
variables: overflows
|
|
248
|
+
},
|
|
249
|
+
transitionProps: {
|
|
250
|
+
props: [{
|
|
251
|
+
propName: 'transition',
|
|
252
|
+
property: 'transition',
|
|
253
|
+
short: 'tr'
|
|
254
|
+
}, {
|
|
255
|
+
propName: 'transitionHover',
|
|
256
|
+
property: 'transition',
|
|
257
|
+
modifier: 'hover',
|
|
258
|
+
short: 'tr-hover'
|
|
259
|
+
}],
|
|
260
|
+
valueTransformer: getTransition,
|
|
261
|
+
variableChecker: isTrasitionVar,
|
|
262
|
+
variables: transitions
|
|
263
|
+
},
|
|
264
|
+
cursorProps: {
|
|
265
|
+
props: [{
|
|
266
|
+
propName: 'cursor',
|
|
267
|
+
property: 'cursor',
|
|
268
|
+
short: 'cur'
|
|
269
|
+
}],
|
|
270
|
+
variableChecker: function variableChecker(value) {
|
|
271
|
+
return cursors.includes(value);
|
|
272
|
+
},
|
|
273
|
+
variables: cursors
|
|
274
|
+
},
|
|
275
|
+
aspectRatioProps: {
|
|
276
|
+
props: [{
|
|
277
|
+
propName: 'aspectRatio',
|
|
278
|
+
property: 'aspect-ratio',
|
|
279
|
+
short: 'ar'
|
|
280
|
+
}]
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
export var propNameToShort = function propNameToShort(propName) {
|
|
284
|
+
var _prop$props$find;
|
|
285
|
+
|
|
286
|
+
var prop = Object.values(styleConfig).find(function (_ref) {
|
|
287
|
+
var props = _ref.props;
|
|
288
|
+
return props.find(function (_ref2) {
|
|
289
|
+
var prop = _ref2.propName;
|
|
290
|
+
return prop === propName;
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
return prop === null || prop === void 0 ? void 0 : (_prop$props$find = prop.props.find(function (_ref3) {
|
|
294
|
+
var prop = _ref3.propName;
|
|
295
|
+
return prop === propName;
|
|
296
|
+
})) === null || _prop$props$find === void 0 ? void 0 : _prop$props$find.short;
|
|
297
|
+
};
|
package/es/utilities/styles.js
CHANGED
|
@@ -17,8 +17,11 @@ export var getColor = function getColor(color) {
|
|
|
17
17
|
|
|
18
18
|
return color;
|
|
19
19
|
};
|
|
20
|
+
export var isShadowVar = function isShadowVar(shadow) {
|
|
21
|
+
return shadow in vars.shadows;
|
|
22
|
+
};
|
|
20
23
|
export var getShadow = function getShadow(shadow) {
|
|
21
|
-
if (shadow
|
|
24
|
+
if (isShadowVar(shadow)) {
|
|
22
25
|
return getCssVar(varInfo.shadows.name, shadow);
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -29,8 +32,11 @@ export var getWeight = function getWeight(weight) {
|
|
|
29
32
|
return getCssVar(varInfo.weights.name, weight);
|
|
30
33
|
}
|
|
31
34
|
};
|
|
35
|
+
export var isRadiusVar = function isRadiusVar(radius) {
|
|
36
|
+
return radius in vars.radii;
|
|
37
|
+
};
|
|
32
38
|
export var getRadius = function getRadius(radius) {
|
|
33
|
-
if (radius
|
|
39
|
+
if (isRadiusVar(radius)) {
|
|
34
40
|
return getCssVar(varInfo.radii.name, radius);
|
|
35
41
|
}
|
|
36
42
|
|
|
@@ -38,6 +44,9 @@ export var getRadius = function getRadius(radius) {
|
|
|
38
44
|
if (isString(radius)) return radius;
|
|
39
45
|
if (isNumber(radius)) return u(radius);
|
|
40
46
|
};
|
|
47
|
+
export var isTrasitionVar = function isTrasitionVar(transition) {
|
|
48
|
+
return transition in vars.transitionUtils || transition in vars.transitions;
|
|
49
|
+
};
|
|
41
50
|
export var getTransition = function getTransition(transition) {
|
|
42
51
|
if (transition in vars.transitionUtils) {
|
|
43
52
|
return getCssVar(varInfo.transitionUtils.name, transition);
|