@flodesk/grain 10.17.4 → 10.18.0
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/arrange.js +74 -34
- package/es/components/autocomplete.js +132 -28
- package/es/components/autocomplete2.js +359 -0
- package/es/components/badge.js +7 -8
- package/es/components/box.js +85 -14
- package/es/components/box2.js +223 -0
- package/es/components/button.js +8 -26
- package/es/components/checkbox.js +12 -18
- package/es/components/dropdown.js +81 -28
- package/es/components/flex.js +72 -36
- package/es/components/index.js +5 -1
- package/es/components/link.js +27 -16
- package/es/components/modal.js +89 -68
- package/es/components/nav.js +9 -19
- package/es/components/pagination.js +4 -4
- package/es/components/popover.js +33 -12
- package/es/components/provider.js +14 -0
- package/es/components/select.js +12 -10
- package/es/components/slider.js +6 -17
- package/es/components/spinner.js +4 -14
- package/es/components/stack.js +5 -4
- package/es/components/switch.js +5 -17
- package/es/components/tab.js +1 -1
- package/es/components/text-button.js +13 -12
- package/es/components/text.js +84 -28
- package/es/components/text2/index.js +100 -0
- package/es/components/text2/styles.module.css +22 -0
- package/es/components/textarea.js +34 -20
- package/es/components/toast.js +16 -53
- package/es/components/tooltip.js +4 -4
- package/es/foundational/field.js +52 -28
- package/es/foundational/menu.js +138 -60
- package/es/foundational/styles.js +11 -11
- package/es/hooks/index.js +2 -1
- package/es/hooks/useOnClickOutside.js +7 -6
- package/es/hooks/usePrev.js +8 -0
- package/es/icons/icon-archive.js +21 -0
- package/es/icons/icon-at.js +21 -0
- package/es/icons/icon-bold.js +28 -0
- package/es/icons/icon-bullet-list.js +21 -0
- package/es/icons/icon-column-and-rows.js +21 -0
- package/es/icons/icon-columns-and-row.js +21 -0
- package/es/icons/icon-columns.js +21 -0
- package/es/icons/icon-folder-move.js +21 -0
- package/es/icons/icon-folder-remove.js +21 -0
- package/es/icons/icon-italic.js +28 -0
- package/es/icons/icon-number-list.js +21 -0
- package/es/icons/icon-row-and-columns.js +21 -0
- package/es/icons/icon-rows-and-column.js +21 -0
- package/es/icons/icon-rows.js +21 -0
- package/es/icons/icon-strike.js +28 -0
- package/es/icons/icon-text-justify.js +21 -0
- package/es/icons/icon-underline.js +28 -0
- package/es/icons/index.js +18 -1
- package/es/index.js +2 -1
- package/es/styles/base.js +2 -0
- package/es/styles/colors/core.js +2 -0
- package/es/styles/colors/experimental.js +2 -0
- package/es/styles/colors/index.js +4 -0
- package/es/styles/colors/theme.js +2 -0
- package/es/styles/index.js +6 -0
- package/es/styles/shadows.js +2 -0
- package/es/styles/utilities.js +108 -0
- package/es/styles/variables.js +2 -0
- package/es/types.js +18 -7
- package/es/utilities/attributes.js +66 -0
- package/es/utilities/helpers.js +13 -1
- package/es/utilities/index.js +3 -1
- package/es/utilities/responsive.js +3 -0
- package/es/utilities/style-config.js +442 -0
- package/es/utilities/styles.js +14 -2
- package/es/variables/breakpoints.js +9 -0
- package/es/variables/colors.js +2 -1
- package/es/variables/index.js +2 -1
- package/es/variables/vars.js +3 -0
- package/package.json +1 -1
- package/es/styles/base.css +0 -53
- package/es/styles/colors/core.css +0 -74
- package/es/styles/colors/experimental.css +0 -3
- package/es/styles/colors/theme.css +0 -92
- package/es/styles/shadows.css +0 -60
- package/es/styles/variables.css +0 -66
package/es/types.js
CHANGED
|
@@ -17,22 +17,32 @@ export var autoFlows = directions;
|
|
|
17
17
|
export var flexDirections = directions;
|
|
18
18
|
export var alignSelfs = [].concat(axisAlignments, ['baseline']);
|
|
19
19
|
export var flexWraps = ['nowrap', 'wrap', 'wrap-reverse'];
|
|
20
|
+
export var overflows = ['visible', 'hidden', 'scroll', 'auto'];
|
|
21
|
+
export var positions = ['static', 'relative', 'fixed', 'absolute', 'sticky'];
|
|
22
|
+
export var cursors = ['default', 'pointer'];
|
|
23
|
+
export var sides = ['all', 'left', 'right', 'top', 'bottom', 'x', 'y'];
|
|
24
|
+
export var borderWidths = ['1px', '2px', '3px', '4px'];
|
|
25
|
+
export var textTransforms = ['capitalize', 'uppercase', 'lowercase'];
|
|
26
|
+
export var textDisplays = ['block', 'inline-block', 'inline'];
|
|
27
|
+
export var textAlignments = ['left', 'center', 'right'];
|
|
28
|
+
export var spaces = Object.keys(vars.spaces);
|
|
20
29
|
export var types = {
|
|
30
|
+
spaces: PropTypes.oneOf(spaces),
|
|
21
31
|
color: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.colors)), PropTypes.string]),
|
|
22
|
-
responsiveSpace: PropTypes.oneOfType([PropTypes.oneOf(
|
|
32
|
+
responsiveSpace: PropTypes.oneOfType([PropTypes.oneOf(spaces), PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
23
33
|
dimension: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
24
34
|
responsiveDimension: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.object]),
|
|
25
|
-
side: PropTypes.oneOf(
|
|
35
|
+
side: PropTypes.oneOf(sides),
|
|
26
36
|
radius: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.radii)), PropTypes.string, PropTypes.number]),
|
|
27
37
|
shadow: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.shadows)), PropTypes.string]),
|
|
28
|
-
position: PropTypes.oneOf(
|
|
38
|
+
position: PropTypes.oneOf(positions),
|
|
29
39
|
responsiveTextSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.texts)), PropTypes.string, PropTypes.object]),
|
|
30
|
-
responsiveTextAlign: PropTypes.oneOfType([PropTypes.oneOf(
|
|
40
|
+
responsiveTextAlign: PropTypes.oneOfType([PropTypes.oneOf(textAlignments), PropTypes.string, PropTypes.object]),
|
|
31
41
|
iconSize: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.icons)), PropTypes.number, PropTypes.string]),
|
|
32
42
|
weight: PropTypes.oneOf(Object.keys(vars.weights)),
|
|
33
|
-
overflow: PropTypes.oneOf(
|
|
43
|
+
overflow: PropTypes.oneOf(overflows),
|
|
34
44
|
textTag: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span', 'label']),
|
|
35
|
-
textDisplay: PropTypes.oneOf(
|
|
45
|
+
textDisplay: PropTypes.oneOf(textDisplays),
|
|
36
46
|
responsiveColumns: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
37
47
|
responsiveRows: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
38
48
|
autoFlow: PropTypes.oneOfType([PropTypes.oneOf(autoFlows), PropTypes.string, PropTypes.object]),
|
|
@@ -57,7 +67,8 @@ export var types = {
|
|
|
57
67
|
buttonTag: PropTypes.oneOf(['button', 'a', 'span']),
|
|
58
68
|
hint: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
59
69
|
transition: PropTypes.oneOfType([PropTypes.oneOf(Object.keys(vars.transitions)), PropTypes.string]),
|
|
60
|
-
cursor: PropTypes.oneOf(
|
|
70
|
+
cursor: PropTypes.oneOf(cursors),
|
|
71
|
+
borderWidth: PropTypes.oneOf(borderWidths)
|
|
61
72
|
};
|
|
62
73
|
export var defaultProps = {
|
|
63
74
|
menuMaxHeight: '468px',
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "core-js/modules/es.object.values.js";
|
|
2
|
+
import "core-js/modules/es.object.to-string.js";
|
|
3
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
4
|
+
import "core-js/modules/es.array.concat.js";
|
|
5
|
+
import "core-js/modules/es.object.keys.js";
|
|
6
|
+
import { breakpoints, deviceShort } from '../variables';
|
|
7
|
+
import { isObject } from './helpers';
|
|
8
|
+
import { propNameToShort, styleConfig } from './style-config';
|
|
9
|
+
var mediaQueries = {
|
|
10
|
+
tablet: "@media (max-width: ".concat(breakpoints.tablet, "px)"),
|
|
11
|
+
mobile: "@media (max-width: ".concat(breakpoints.mobile, "px)")
|
|
12
|
+
};
|
|
13
|
+
export var generateStyleAttributes = function generateStyleAttributes(props) {
|
|
14
|
+
var styles = {};
|
|
15
|
+
var styleConfigValues = Object.values(styleConfig);
|
|
16
|
+
styleConfigValues.forEach(function (propsSet) {
|
|
17
|
+
propsSet.props.forEach(function (_ref) {
|
|
18
|
+
var propName = _ref.propName;
|
|
19
|
+
var value = props[propName];
|
|
20
|
+
var hasVariable = propsSet.variableChecker ? propsSet.variableChecker(value) : false;
|
|
21
|
+
var hasTransformer = propsSet.valueTransformer ? true : false;
|
|
22
|
+
if (hasVariable) return;
|
|
23
|
+
if (value === null || value === undefined || value === '') return;
|
|
24
|
+
var cssValue = hasTransformer ? propsSet.valueTransformer(value) : value;
|
|
25
|
+
var propNameShort = propNameToShort(propName);
|
|
26
|
+
|
|
27
|
+
if (!isObject(value)) {
|
|
28
|
+
styles["--".concat(propNameShort)] = cssValue;
|
|
29
|
+
} else {
|
|
30
|
+
var def = value.default,
|
|
31
|
+
mobile = value.mobile,
|
|
32
|
+
tablet = value.tablet; // accept fixed string media queries to help migration
|
|
33
|
+
|
|
34
|
+
var mobileMediaValue = value[mediaQueries.mobile];
|
|
35
|
+
var tabletMediaValue = value[mediaQueries.tablet];
|
|
36
|
+
var mob = mobileMediaValue || mobile;
|
|
37
|
+
var tab = tabletMediaValue || tablet;
|
|
38
|
+
styles["--".concat(propNameShort, "-").concat(deviceShort.default)] = hasTransformer ? propsSet.valueTransformer(def) : def;
|
|
39
|
+
styles["--".concat(propNameShort, "-").concat(deviceShort.mobile)] = hasTransformer ? propsSet.valueTransformer(mob) : mob;
|
|
40
|
+
styles["--".concat(propNameShort, "-").concat(deviceShort.tablet)] = hasTransformer ? propsSet.valueTransformer(tab) : tab;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return styles;
|
|
45
|
+
};
|
|
46
|
+
export var generateClassNameAttributes = function generateClassNameAttributes(props) {
|
|
47
|
+
var classNames = [];
|
|
48
|
+
var propKeys = Object.keys(props);
|
|
49
|
+
var styleConfigValues = Object.values(styleConfig);
|
|
50
|
+
propKeys.forEach(function (prop) {
|
|
51
|
+
styleConfigValues.forEach(function (styleConfigItem) {
|
|
52
|
+
styleConfigItem.props.forEach(function (propItem) {
|
|
53
|
+
if (propItem.propName === prop) {
|
|
54
|
+
var propName = propItem.propName;
|
|
55
|
+
var value = props[propName];
|
|
56
|
+
var hasVariable = styleConfigItem.variableChecker ? styleConfigItem.variableChecker(value) : false;
|
|
57
|
+
if (!hasVariable) return;
|
|
58
|
+
if (value === null || value === undefined || value === '') return;
|
|
59
|
+
var className = "".concat(propNameToShort(propName), "-").concat(value);
|
|
60
|
+
classNames.push(className);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
return classNames.join(' ');
|
|
66
|
+
};
|
package/es/utilities/helpers.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
2
|
|
|
3
3
|
import "core-js/modules/es.array.concat.js";
|
|
4
|
+
import "core-js/modules/es.object.to-string.js";
|
|
5
|
+
import "core-js/modules/web.dom-collections.for-each.js";
|
|
4
6
|
import "core-js/modules/es.symbol.js";
|
|
5
7
|
import "core-js/modules/es.symbol.description.js";
|
|
6
|
-
import "core-js/modules/es.object.to-string.js";
|
|
7
8
|
import "core-js/modules/es.symbol.iterator.js";
|
|
8
9
|
import "core-js/modules/es.array.iterator.js";
|
|
9
10
|
import "core-js/modules/es.string.iterator.js";
|
|
@@ -32,4 +33,15 @@ export var isArray = function isArray(value) {
|
|
|
32
33
|
};
|
|
33
34
|
export var isObject = function isObject(value) {
|
|
34
35
|
return _typeof(value) === 'object';
|
|
36
|
+
};
|
|
37
|
+
export var mergeRefs = function mergeRefs(refs) {
|
|
38
|
+
return function (value) {
|
|
39
|
+
refs.forEach(function (ref) {
|
|
40
|
+
if (typeof ref === 'function') {
|
|
41
|
+
ref(value);
|
|
42
|
+
} else if (ref != null) {
|
|
43
|
+
ref.current = value;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
35
47
|
};
|
package/es/utilities/index.js
CHANGED
|
@@ -61,6 +61,9 @@ export var getDimension = function getDimension(dimension) {
|
|
|
61
61
|
if (isString(dimension)) return dimension;
|
|
62
62
|
if (isNumber(dimension)) return u(dimension);
|
|
63
63
|
};
|
|
64
|
+
export var isSpaceVar = function isSpaceVar(space) {
|
|
65
|
+
return space in vars.spaces || space in vars.spaceUtils;
|
|
66
|
+
};
|
|
64
67
|
export var getSpace = function getSpace(space) {
|
|
65
68
|
if (space in vars.spaceUtils) {
|
|
66
69
|
return getCssVar(varInfo.spaceUtils.name, space);
|
|
@@ -0,0 +1,442 @@
|
|
|
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.map.js";
|
|
4
|
+
import "core-js/modules/es.array.includes.js";
|
|
5
|
+
import "core-js/modules/es.string.includes.js";
|
|
6
|
+
import "core-js/modules/es.array.find.js";
|
|
7
|
+
import "core-js/modules/es.object.to-string.js";
|
|
8
|
+
import "core-js/modules/es.object.values.js";
|
|
9
|
+
import "core-js/modules/es.symbol.js";
|
|
10
|
+
import "core-js/modules/es.symbol.description.js";
|
|
11
|
+
import "core-js/modules/es.symbol.iterator.js";
|
|
12
|
+
import "core-js/modules/es.array.iterator.js";
|
|
13
|
+
import "core-js/modules/es.string.iterator.js";
|
|
14
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
15
|
+
import "core-js/modules/es.array.from.js";
|
|
16
|
+
import "core-js/modules/es.array.slice.js";
|
|
17
|
+
import "core-js/modules/es.regexp.exec.js";
|
|
18
|
+
|
|
19
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
20
|
+
|
|
21
|
+
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."); }
|
|
22
|
+
|
|
23
|
+
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); }
|
|
24
|
+
|
|
25
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
26
|
+
|
|
27
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
import { alignSelfs, borderWidths, cursors, overflows, positions, sides, textAlignments, textDisplays, textTransforms } from '../types';
|
|
32
|
+
import { vars } from '../variables';
|
|
33
|
+
import { getDimension, getSpace, getTextSize, isSpaceVar } from './responsive';
|
|
34
|
+
import { getColor, getRadius, getShadow, getTransition, getWeight, isColorVar, isRadiusVar, isShadowVar, isTrasitionVar } from './styles';
|
|
35
|
+
var spaces = [].concat(_toConsumableArray(Object.keys(vars.spaces)), _toConsumableArray(Object.keys(vars.spaceUtils)));
|
|
36
|
+
var colors = [].concat(_toConsumableArray(Object.keys(vars.colors)), _toConsumableArray(Object.keys(vars.colorUtils)));
|
|
37
|
+
var shadows = Object.keys(vars.shadows);
|
|
38
|
+
var radii = Object.keys(vars.radii);
|
|
39
|
+
var transitions = [].concat(_toConsumableArray(Object.keys(vars.transitions)), _toConsumableArray(Object.keys(vars.transitionUtils)));
|
|
40
|
+
var sizes = Object.keys(vars.texts);
|
|
41
|
+
var weights = Object.keys(vars.weights);
|
|
42
|
+
|
|
43
|
+
var borderSideToStyle = function borderSideToStyle(side) {
|
|
44
|
+
if (side === 'all') return 'solid';
|
|
45
|
+
var borderConfig = {
|
|
46
|
+
top: ['top'],
|
|
47
|
+
right: ['right'],
|
|
48
|
+
bottom: ['bottom'],
|
|
49
|
+
left: ['left'],
|
|
50
|
+
y: ['top', 'bottom'],
|
|
51
|
+
x: ['right', 'left']
|
|
52
|
+
};
|
|
53
|
+
var borderStyles = ['top', 'right', 'bottom', 'left'].map(function (s) {
|
|
54
|
+
return borderConfig[side].includes(s) ? 'solid' : 'none';
|
|
55
|
+
});
|
|
56
|
+
return borderStyles.join(' ');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export var styleConfig = {
|
|
60
|
+
spaceProps: {
|
|
61
|
+
props: [{
|
|
62
|
+
propName: 'padding',
|
|
63
|
+
property: 'padding',
|
|
64
|
+
short: 'p'
|
|
65
|
+
}, {
|
|
66
|
+
propName: 'paddingTop',
|
|
67
|
+
property: 'padding-top',
|
|
68
|
+
short: 'pt'
|
|
69
|
+
}, {
|
|
70
|
+
propName: 'paddingBottom',
|
|
71
|
+
property: 'padding-bottom',
|
|
72
|
+
short: 'pb'
|
|
73
|
+
}, {
|
|
74
|
+
propName: 'paddingLeft',
|
|
75
|
+
property: 'padding-left',
|
|
76
|
+
short: 'pl'
|
|
77
|
+
}, {
|
|
78
|
+
propName: 'paddingRight',
|
|
79
|
+
property: 'padding-right',
|
|
80
|
+
short: 'pr'
|
|
81
|
+
}, {
|
|
82
|
+
propName: 'paddingX',
|
|
83
|
+
property: 'padding-inline',
|
|
84
|
+
short: 'px'
|
|
85
|
+
}, {
|
|
86
|
+
propName: 'paddingY',
|
|
87
|
+
property: 'padding-block',
|
|
88
|
+
short: 'py'
|
|
89
|
+
}, {
|
|
90
|
+
propName: 'margin',
|
|
91
|
+
property: 'margin',
|
|
92
|
+
short: 'm'
|
|
93
|
+
}, {
|
|
94
|
+
propName: 'marginTop',
|
|
95
|
+
property: 'margin-top',
|
|
96
|
+
short: 'mt'
|
|
97
|
+
}, {
|
|
98
|
+
propName: 'marginBottom',
|
|
99
|
+
property: 'margin-bottom',
|
|
100
|
+
short: 'mb'
|
|
101
|
+
}, {
|
|
102
|
+
propName: 'marginLeft',
|
|
103
|
+
property: 'margin-left',
|
|
104
|
+
short: 'ml'
|
|
105
|
+
}, {
|
|
106
|
+
propName: 'marginRight',
|
|
107
|
+
property: 'margin-right',
|
|
108
|
+
short: 'mr'
|
|
109
|
+
}, {
|
|
110
|
+
propName: 'marginX',
|
|
111
|
+
property: 'margin-inline',
|
|
112
|
+
short: 'mx'
|
|
113
|
+
}, {
|
|
114
|
+
propName: 'marginY',
|
|
115
|
+
property: 'margin-block',
|
|
116
|
+
short: 'my'
|
|
117
|
+
}, {
|
|
118
|
+
propName: 'top',
|
|
119
|
+
property: 'top',
|
|
120
|
+
short: 't'
|
|
121
|
+
}, {
|
|
122
|
+
propName: 'bottom',
|
|
123
|
+
property: 'bottom',
|
|
124
|
+
short: 'b'
|
|
125
|
+
}, {
|
|
126
|
+
propName: 'left',
|
|
127
|
+
property: 'left',
|
|
128
|
+
short: 'l'
|
|
129
|
+
}, {
|
|
130
|
+
propName: 'right',
|
|
131
|
+
property: 'right',
|
|
132
|
+
short: 'r'
|
|
133
|
+
}],
|
|
134
|
+
valueTransformer: getSpace,
|
|
135
|
+
variableChecker: isSpaceVar,
|
|
136
|
+
variables: spaces,
|
|
137
|
+
isResponsive: true
|
|
138
|
+
},
|
|
139
|
+
dimensionProps: {
|
|
140
|
+
props: [{
|
|
141
|
+
propName: 'width',
|
|
142
|
+
property: 'width',
|
|
143
|
+
short: 'w'
|
|
144
|
+
}, {
|
|
145
|
+
propName: 'minWidth',
|
|
146
|
+
property: 'min-width',
|
|
147
|
+
short: 'min-w'
|
|
148
|
+
}, {
|
|
149
|
+
propName: 'maxWidth',
|
|
150
|
+
property: 'max-width',
|
|
151
|
+
short: 'max-w'
|
|
152
|
+
}, {
|
|
153
|
+
propName: 'height',
|
|
154
|
+
property: 'height',
|
|
155
|
+
short: 'h'
|
|
156
|
+
}, {
|
|
157
|
+
propName: 'minHeight',
|
|
158
|
+
property: 'min-height',
|
|
159
|
+
short: 'min-h'
|
|
160
|
+
}, {
|
|
161
|
+
propName: 'maxHeight',
|
|
162
|
+
property: 'max-height',
|
|
163
|
+
short: 'max-h'
|
|
164
|
+
}],
|
|
165
|
+
valueTransformer: getDimension,
|
|
166
|
+
isResponsive: true
|
|
167
|
+
},
|
|
168
|
+
colorProps: {
|
|
169
|
+
props: [{
|
|
170
|
+
propName: 'color',
|
|
171
|
+
property: 'color',
|
|
172
|
+
short: 'c'
|
|
173
|
+
}, {
|
|
174
|
+
propName: 'colorHover',
|
|
175
|
+
property: 'color',
|
|
176
|
+
short: 'c-h'
|
|
177
|
+
}, {
|
|
178
|
+
propName: 'backgroundColor',
|
|
179
|
+
property: 'background-color',
|
|
180
|
+
short: 'bgc'
|
|
181
|
+
}, {
|
|
182
|
+
propName: 'backgroundColorHover',
|
|
183
|
+
property: 'background-color',
|
|
184
|
+
short: 'bgc-h'
|
|
185
|
+
}],
|
|
186
|
+
valueTransformer: getColor,
|
|
187
|
+
variableChecker: isColorVar,
|
|
188
|
+
variables: colors
|
|
189
|
+
},
|
|
190
|
+
shadowProps: {
|
|
191
|
+
props: [{
|
|
192
|
+
propName: 'shadow',
|
|
193
|
+
property: 'box-shadow',
|
|
194
|
+
short: 'sh'
|
|
195
|
+
}, {
|
|
196
|
+
propName: 'shadowHover',
|
|
197
|
+
property: 'box-shadow',
|
|
198
|
+
short: 'sh-h'
|
|
199
|
+
}],
|
|
200
|
+
valueTransformer: getShadow,
|
|
201
|
+
variableChecker: isShadowVar,
|
|
202
|
+
variables: shadows
|
|
203
|
+
},
|
|
204
|
+
radiusProps: {
|
|
205
|
+
props: [{
|
|
206
|
+
propName: 'radius',
|
|
207
|
+
property: 'border-radius',
|
|
208
|
+
short: 'rad'
|
|
209
|
+
}],
|
|
210
|
+
valueTransformer: getRadius,
|
|
211
|
+
variableChecker: isRadiusVar,
|
|
212
|
+
variables: radii
|
|
213
|
+
},
|
|
214
|
+
orderProps: {
|
|
215
|
+
props: [{
|
|
216
|
+
propName: 'order',
|
|
217
|
+
property: 'order',
|
|
218
|
+
short: 'ord'
|
|
219
|
+
}]
|
|
220
|
+
},
|
|
221
|
+
flexProps: {
|
|
222
|
+
props: [{
|
|
223
|
+
propName: 'flex',
|
|
224
|
+
property: 'flex',
|
|
225
|
+
short: 'flx'
|
|
226
|
+
}],
|
|
227
|
+
isResponsive: true
|
|
228
|
+
},
|
|
229
|
+
zIndexProps: {
|
|
230
|
+
props: [{
|
|
231
|
+
propName: 'zIndex',
|
|
232
|
+
property: 'z-index',
|
|
233
|
+
short: 'z'
|
|
234
|
+
}]
|
|
235
|
+
},
|
|
236
|
+
positionProps: {
|
|
237
|
+
props: [{
|
|
238
|
+
propName: 'position',
|
|
239
|
+
property: 'position',
|
|
240
|
+
short: 'pos'
|
|
241
|
+
}],
|
|
242
|
+
variableChecker: function variableChecker(value) {
|
|
243
|
+
return positions.includes(value);
|
|
244
|
+
},
|
|
245
|
+
variables: positions
|
|
246
|
+
},
|
|
247
|
+
overflowProps: {
|
|
248
|
+
props: [{
|
|
249
|
+
propName: 'overflow',
|
|
250
|
+
property: 'overflow',
|
|
251
|
+
short: 'of'
|
|
252
|
+
}, {
|
|
253
|
+
propName: 'overflowX',
|
|
254
|
+
property: 'overflow-x',
|
|
255
|
+
short: 'of-x'
|
|
256
|
+
}, {
|
|
257
|
+
propName: 'overflowY',
|
|
258
|
+
property: 'overflow-y',
|
|
259
|
+
short: 'of-y'
|
|
260
|
+
}],
|
|
261
|
+
variableChecker: function variableChecker(value) {
|
|
262
|
+
return overflows.includes(value);
|
|
263
|
+
},
|
|
264
|
+
variables: overflows
|
|
265
|
+
},
|
|
266
|
+
transitionProps: {
|
|
267
|
+
props: [{
|
|
268
|
+
propName: 'transition',
|
|
269
|
+
property: 'transition',
|
|
270
|
+
short: 'tr'
|
|
271
|
+
}, {
|
|
272
|
+
propName: 'transitionHover',
|
|
273
|
+
property: 'transition',
|
|
274
|
+
short: 'tr-h'
|
|
275
|
+
}],
|
|
276
|
+
valueTransformer: getTransition,
|
|
277
|
+
variableChecker: isTrasitionVar,
|
|
278
|
+
variables: transitions
|
|
279
|
+
},
|
|
280
|
+
cursorProps: {
|
|
281
|
+
props: [{
|
|
282
|
+
propName: 'cursor',
|
|
283
|
+
property: 'cursor',
|
|
284
|
+
short: 'cur'
|
|
285
|
+
}],
|
|
286
|
+
variableChecker: function variableChecker(value) {
|
|
287
|
+
return cursors.includes(value);
|
|
288
|
+
},
|
|
289
|
+
variables: cursors
|
|
290
|
+
},
|
|
291
|
+
aspectRatioProps: {
|
|
292
|
+
props: [{
|
|
293
|
+
propName: 'aspectRatio',
|
|
294
|
+
property: 'aspect-ratio',
|
|
295
|
+
short: 'ar'
|
|
296
|
+
}]
|
|
297
|
+
},
|
|
298
|
+
sizeProps: {
|
|
299
|
+
props: [{
|
|
300
|
+
propName: 'size',
|
|
301
|
+
property: 'font-size',
|
|
302
|
+
short: 'txt'
|
|
303
|
+
}],
|
|
304
|
+
isResponsive: true,
|
|
305
|
+
variables: sizes,
|
|
306
|
+
valueTransformer: getTextSize,
|
|
307
|
+
variableChecker: function variableChecker(value) {
|
|
308
|
+
return sizes.includes(value);
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
opacityProps: {
|
|
312
|
+
props: [{
|
|
313
|
+
propName: 'opacity',
|
|
314
|
+
property: 'opacity',
|
|
315
|
+
short: 'op'
|
|
316
|
+
}, {
|
|
317
|
+
propName: 'opacityHover',
|
|
318
|
+
property: 'opacity',
|
|
319
|
+
short: 'op-h'
|
|
320
|
+
}]
|
|
321
|
+
},
|
|
322
|
+
alignSelfProps: {
|
|
323
|
+
props: [{
|
|
324
|
+
propName: 'alignSelf',
|
|
325
|
+
property: 'align-self',
|
|
326
|
+
short: 'als'
|
|
327
|
+
}],
|
|
328
|
+
variables: alignSelfs,
|
|
329
|
+
variableChecker: function variableChecker(value) {
|
|
330
|
+
return alignSelfs.includes(value);
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
borderColorProps: {
|
|
334
|
+
props: [{
|
|
335
|
+
propName: 'borderColor',
|
|
336
|
+
property: 'border-color',
|
|
337
|
+
short: 'bdc'
|
|
338
|
+
}, {
|
|
339
|
+
propName: 'borderColorHover',
|
|
340
|
+
property: 'border-color',
|
|
341
|
+
short: 'bdc-h'
|
|
342
|
+
}],
|
|
343
|
+
valueTransformer: getColor,
|
|
344
|
+
variableChecker: isColorVar,
|
|
345
|
+
variables: colors
|
|
346
|
+
},
|
|
347
|
+
borderWidthProps: {
|
|
348
|
+
props: [{
|
|
349
|
+
propName: 'borderWidth',
|
|
350
|
+
property: 'border-width',
|
|
351
|
+
short: 'bdw'
|
|
352
|
+
}],
|
|
353
|
+
valueTransformer: function valueTransformer(borderWidth) {
|
|
354
|
+
return borderWidth;
|
|
355
|
+
},
|
|
356
|
+
variables: borderWidths,
|
|
357
|
+
variableChecker: function variableChecker(value) {
|
|
358
|
+
return borderWidths.includes(value);
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
borderSideProps: {
|
|
362
|
+
props: [{
|
|
363
|
+
propName: 'borderSide',
|
|
364
|
+
property: 'border-style',
|
|
365
|
+
short: 'bds'
|
|
366
|
+
}],
|
|
367
|
+
valueTransformer: borderSideToStyle,
|
|
368
|
+
variables: sides,
|
|
369
|
+
variableChecker: function variableChecker(value) {
|
|
370
|
+
return sides.includes(value);
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
alignProps: {
|
|
374
|
+
props: [{
|
|
375
|
+
propName: 'align',
|
|
376
|
+
property: 'text-align',
|
|
377
|
+
short: 'al'
|
|
378
|
+
}],
|
|
379
|
+
variables: textAlignments,
|
|
380
|
+
variableChecker: function variableChecker(value) {
|
|
381
|
+
return textAlignments.includes(value);
|
|
382
|
+
},
|
|
383
|
+
isResponsive: true
|
|
384
|
+
},
|
|
385
|
+
weightProps: {
|
|
386
|
+
props: [{
|
|
387
|
+
propName: 'weight',
|
|
388
|
+
property: 'font-weight',
|
|
389
|
+
short: 'w'
|
|
390
|
+
}],
|
|
391
|
+
variables: weights,
|
|
392
|
+
variableChecker: function variableChecker(value) {
|
|
393
|
+
return weights.includes(value);
|
|
394
|
+
},
|
|
395
|
+
valueTransformer: getWeight
|
|
396
|
+
},
|
|
397
|
+
textDisplayProps: {
|
|
398
|
+
props: [{
|
|
399
|
+
propName: 'display',
|
|
400
|
+
property: 'display',
|
|
401
|
+
short: 'ds' // instead of 'd' to avoid conflict with _display.scss in frontend
|
|
402
|
+
|
|
403
|
+
}],
|
|
404
|
+
variables: textDisplays,
|
|
405
|
+
variableChecker: function variableChecker(value) {
|
|
406
|
+
return textDisplays.includes(value);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
letterSpacingProps: {
|
|
410
|
+
props: [{
|
|
411
|
+
propName: 'letterSpacing',
|
|
412
|
+
property: 'letter-spacing',
|
|
413
|
+
short: 'ls'
|
|
414
|
+
}]
|
|
415
|
+
},
|
|
416
|
+
textTransformProps: {
|
|
417
|
+
props: [{
|
|
418
|
+
propName: 'textTransform',
|
|
419
|
+
property: 'text-transform',
|
|
420
|
+
short: 'tt'
|
|
421
|
+
}],
|
|
422
|
+
variables: textTransforms,
|
|
423
|
+
variableChecker: function variableChecker(value) {
|
|
424
|
+
return textTransforms.includes(value);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
export var propNameToShort = function propNameToShort(propName) {
|
|
429
|
+
var _prop$props$find;
|
|
430
|
+
|
|
431
|
+
var prop = Object.values(styleConfig).find(function (_ref) {
|
|
432
|
+
var props = _ref.props;
|
|
433
|
+
return props.find(function (_ref2) {
|
|
434
|
+
var prop = _ref2.propName;
|
|
435
|
+
return prop === propName;
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
return prop === null || prop === void 0 ? void 0 : (_prop$props$find = prop.props.find(function (_ref3) {
|
|
439
|
+
var prop = _ref3.propName;
|
|
440
|
+
return prop === propName;
|
|
441
|
+
})) === null || _prop$props$find === void 0 ? void 0 : _prop$props$find.short;
|
|
442
|
+
};
|
package/es/utilities/styles.js
CHANGED
|
@@ -3,6 +3,9 @@ import "core-js/modules/es.array.map.js";
|
|
|
3
3
|
import { getCssVar, isNumber, isString, u } from '.';
|
|
4
4
|
import { vars, varInfo } from '../variables';
|
|
5
5
|
import { getDimension } from './responsive';
|
|
6
|
+
export var isColorVar = function isColorVar(color) {
|
|
7
|
+
return color in vars.colorUtils || color in vars.colors;
|
|
8
|
+
};
|
|
6
9
|
export var getColor = function getColor(color) {
|
|
7
10
|
if (color in vars.colorUtils) {
|
|
8
11
|
return getCssVar(varInfo.colorUtils.name, color);
|
|
@@ -14,8 +17,11 @@ export var getColor = function getColor(color) {
|
|
|
14
17
|
|
|
15
18
|
return color;
|
|
16
19
|
};
|
|
20
|
+
export var isShadowVar = function isShadowVar(shadow) {
|
|
21
|
+
return shadow in vars.shadows;
|
|
22
|
+
};
|
|
17
23
|
export var getShadow = function getShadow(shadow) {
|
|
18
|
-
if (shadow
|
|
24
|
+
if (isShadowVar(shadow)) {
|
|
19
25
|
return getCssVar(varInfo.shadows.name, shadow);
|
|
20
26
|
}
|
|
21
27
|
|
|
@@ -26,8 +32,11 @@ export var getWeight = function getWeight(weight) {
|
|
|
26
32
|
return getCssVar(varInfo.weights.name, weight);
|
|
27
33
|
}
|
|
28
34
|
};
|
|
35
|
+
export var isRadiusVar = function isRadiusVar(radius) {
|
|
36
|
+
return radius in vars.radii;
|
|
37
|
+
};
|
|
29
38
|
export var getRadius = function getRadius(radius) {
|
|
30
|
-
if (radius
|
|
39
|
+
if (isRadiusVar(radius)) {
|
|
31
40
|
return getCssVar(varInfo.radii.name, radius);
|
|
32
41
|
}
|
|
33
42
|
|
|
@@ -35,6 +44,9 @@ export var getRadius = function getRadius(radius) {
|
|
|
35
44
|
if (isString(radius)) return radius;
|
|
36
45
|
if (isNumber(radius)) return u(radius);
|
|
37
46
|
};
|
|
47
|
+
export var isTrasitionVar = function isTrasitionVar(transition) {
|
|
48
|
+
return transition in vars.transitionUtils || transition in vars.transitions;
|
|
49
|
+
};
|
|
38
50
|
export var getTransition = function getTransition(transition) {
|
|
39
51
|
if (transition in vars.transitionUtils) {
|
|
40
52
|
return getCssVar(varInfo.transitionUtils.name, transition);
|
package/es/variables/colors.js
CHANGED
package/es/variables/index.js
CHANGED