@codecademy/variance 0.20.0 → 0.20.1-alpha.32ef98.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/CHANGELOG.md +8 -0
- package/dist/core.js +183 -245
- package/dist/createTheme/createTheme.js +58 -132
- package/dist/createTheme/createTheme.test.js +159 -184
- package/dist/createTheme/index.js +2 -1
- package/dist/createTheme/types.js +2 -0
- package/dist/index.js +2 -1
- package/dist/scales/createScale.js +2 -3
- package/dist/scales/createScaleLookup.js +13 -23
- package/dist/src/core.d.ts +10 -0
- package/dist/src/core.js +189 -0
- package/dist/src/core.js.map +1 -0
- package/dist/src/createTheme/createTheme.test.d.ts +1 -0
- package/dist/src/createTheme/createTheme.test.js +167 -0
- package/dist/src/createTheme/createTheme.test.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/utils/__fixtures__/testConfig.d.ts +153 -0
- package/dist/src/utils/__fixtures__/testConfig.js +94 -0
- package/dist/src/utils/__fixtures__/testConfig.js.map +1 -0
- package/dist/transforms/index.js +2 -1
- package/dist/transforms/transformSize.js +24 -45
- package/dist/types/config.js +2 -0
- package/dist/types/properties.js +2 -0
- package/dist/types/props.js +2 -0
- package/dist/types/theme.js +2 -0
- package/dist/types/utils.js +2 -0
- package/dist/utils/__fixtures__/testConfig.js +94 -153
- package/dist/utils/flattenScale.js +16 -22
- package/dist/utils/getStaticProperties.js +2 -5
- package/dist/utils/propNames.js +57 -43
- package/dist/utils/responsive.js +57 -86
- package/dist/utils/serializeTokens.js +30 -39
- package/package.json +3 -3
|
@@ -1,47 +1,26 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
1
|
import { isNumber } from 'lodash';
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return "".concat(coordinate, "px");
|
|
2
|
+
export const percentageOrAbsolute = (coordinate) => {
|
|
3
|
+
if (coordinate === 0) {
|
|
4
|
+
return coordinate;
|
|
5
|
+
}
|
|
6
|
+
if (coordinate <= 1 && coordinate >= -1) {
|
|
7
|
+
return `${coordinate * 100}%`;
|
|
8
|
+
}
|
|
9
|
+
return `${coordinate}px`;
|
|
24
10
|
};
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (match === undefined) {
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var numericValue = parseFloat(number);
|
|
46
|
-
return !unit ? percentageOrAbsolute(numericValue) : "".concat(numericValue).concat(unit);
|
|
47
|
-
};
|
|
11
|
+
const valueWithUnit = /(-?\d*\.?\d+)(%|\w*)/;
|
|
12
|
+
export const transformSize = (value) => {
|
|
13
|
+
if (isNumber(value)) {
|
|
14
|
+
return percentageOrAbsolute(value);
|
|
15
|
+
}
|
|
16
|
+
if (value.includes('calc')) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
const [match, number, unit] = valueWithUnit.exec(value) || [];
|
|
20
|
+
if (match === undefined) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
const numericValue = parseFloat(number);
|
|
24
|
+
return !unit ? percentageOrAbsolute(numericValue) : `${numericValue}${unit}`;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=transformSize.js.map
|
package/dist/types/config.js
CHANGED
package/dist/types/properties.js
CHANGED
package/dist/types/props.js
CHANGED
package/dist/types/theme.js
CHANGED
package/dist/types/utils.js
CHANGED
|
@@ -1,153 +1,94 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
property: '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
property: '
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
property: '
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
property: '
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
property: '
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
property: '
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
properties: ['borderTopStyle', 'borderBottomStyle']
|
|
96
|
-
},
|
|
97
|
-
flex: {
|
|
98
|
-
property: 'flex'
|
|
99
|
-
},
|
|
100
|
-
flexBasis: {
|
|
101
|
-
property: 'flexBasis'
|
|
102
|
-
},
|
|
103
|
-
p: {
|
|
104
|
-
property: 'padding'
|
|
105
|
-
},
|
|
106
|
-
px: {
|
|
107
|
-
property: 'padding',
|
|
108
|
-
properties: ['paddingLeft', 'paddingRight'],
|
|
109
|
-
scale: 'spacing'
|
|
110
|
-
},
|
|
111
|
-
py: {
|
|
112
|
-
property: 'padding',
|
|
113
|
-
properties: ['paddingTop', 'paddingBottom'],
|
|
114
|
-
scale: 'spacing'
|
|
115
|
-
},
|
|
116
|
-
pt: {
|
|
117
|
-
property: 'paddingTop'
|
|
118
|
-
},
|
|
119
|
-
pb: {
|
|
120
|
-
property: 'paddingBottom'
|
|
121
|
-
},
|
|
122
|
-
pr: {
|
|
123
|
-
property: 'paddingRight'
|
|
124
|
-
},
|
|
125
|
-
pl: {
|
|
126
|
-
property: 'paddingLeft'
|
|
127
|
-
},
|
|
128
|
-
m: {
|
|
129
|
-
property: 'margin'
|
|
130
|
-
},
|
|
131
|
-
mx: {
|
|
132
|
-
property: 'margin',
|
|
133
|
-
properties: ['marginLeft', 'marginRight'],
|
|
134
|
-
scale: 'spacing'
|
|
135
|
-
},
|
|
136
|
-
my: {
|
|
137
|
-
property: 'margin',
|
|
138
|
-
properties: ['marginTop', 'marginBottom'],
|
|
139
|
-
scale: 'spacing'
|
|
140
|
-
},
|
|
141
|
-
mt: {
|
|
142
|
-
property: 'marginTop'
|
|
143
|
-
},
|
|
144
|
-
mb: {
|
|
145
|
-
property: 'marginBottom'
|
|
146
|
-
},
|
|
147
|
-
mr: {
|
|
148
|
-
property: 'marginRight'
|
|
149
|
-
},
|
|
150
|
-
ml: {
|
|
151
|
-
property: 'marginLeft'
|
|
152
|
-
}
|
|
153
|
-
};
|
|
1
|
+
export const testConfig = {
|
|
2
|
+
textColor: { property: 'color' },
|
|
3
|
+
bg: { property: 'backgroundColor' },
|
|
4
|
+
borderColor: { property: 'borderColor' },
|
|
5
|
+
borderColorX: {
|
|
6
|
+
property: 'borderColor',
|
|
7
|
+
properties: ['borderLeftColor', 'borderRightColor'],
|
|
8
|
+
scale: 'colors',
|
|
9
|
+
},
|
|
10
|
+
borderColorY: {
|
|
11
|
+
property: 'borderColor',
|
|
12
|
+
properties: ['borderTopColor', 'borderBottomColor'],
|
|
13
|
+
scale: 'colors',
|
|
14
|
+
},
|
|
15
|
+
borderColorLeft: { property: 'borderLeftColor' },
|
|
16
|
+
borderColorRight: { property: 'borderRightColor' },
|
|
17
|
+
borderColorTop: { property: 'borderTopColor' },
|
|
18
|
+
borderColorBottom: { property: 'borderBottomColor' },
|
|
19
|
+
border: { property: 'border' },
|
|
20
|
+
borderX: { property: 'border', properties: ['borderLeft', 'borderRight'] },
|
|
21
|
+
borderY: { property: 'border', properties: ['borderTop', 'borderBottom'] },
|
|
22
|
+
borderTop: { property: 'borderTop' },
|
|
23
|
+
borderRight: { property: 'borderRight' },
|
|
24
|
+
borderBottom: { property: 'borderBottom' },
|
|
25
|
+
borderLeft: { property: 'borderLeft' },
|
|
26
|
+
borderWidth: { property: 'borderWidth' },
|
|
27
|
+
borderWidthX: {
|
|
28
|
+
property: 'borderWidth',
|
|
29
|
+
properties: ['borderLeftWidth', 'borderRightWidth'],
|
|
30
|
+
},
|
|
31
|
+
borderWidthY: {
|
|
32
|
+
property: 'borderWidth',
|
|
33
|
+
properties: ['borderTopWidth', 'borderBottomWidth'],
|
|
34
|
+
},
|
|
35
|
+
borderRadius: { property: 'borderRadius' },
|
|
36
|
+
borderRadiusLeft: {
|
|
37
|
+
property: 'borderRadius',
|
|
38
|
+
properties: ['borderTopLeftRadius', 'borderBottomLeftRadius'],
|
|
39
|
+
},
|
|
40
|
+
borderRadiusTop: {
|
|
41
|
+
property: 'borderRadius',
|
|
42
|
+
properties: ['borderTopLeftRadius', 'borderTopRightRadius'],
|
|
43
|
+
},
|
|
44
|
+
borderRadiusBottom: {
|
|
45
|
+
property: 'borderRadius',
|
|
46
|
+
properties: ['borderBottomLeftRadius', 'borderBottomRightRadius'],
|
|
47
|
+
},
|
|
48
|
+
borderRadiusRight: {
|
|
49
|
+
property: 'borderRadius',
|
|
50
|
+
properties: ['borderTopRightRadius', 'borderBottomRightRadius'],
|
|
51
|
+
},
|
|
52
|
+
borderStyle: { property: 'borderStyle' },
|
|
53
|
+
borderStyleX: {
|
|
54
|
+
property: 'borderStyle',
|
|
55
|
+
properties: ['borderLeftStyle', 'borderRightStyle'],
|
|
56
|
+
},
|
|
57
|
+
borderStyleY: {
|
|
58
|
+
property: 'borderStyle',
|
|
59
|
+
properties: ['borderTopStyle', 'borderBottomStyle'],
|
|
60
|
+
},
|
|
61
|
+
flex: { property: 'flex' },
|
|
62
|
+
flexBasis: { property: 'flexBasis' },
|
|
63
|
+
p: { property: 'padding' },
|
|
64
|
+
px: {
|
|
65
|
+
property: 'padding',
|
|
66
|
+
properties: ['paddingLeft', 'paddingRight'],
|
|
67
|
+
scale: 'spacing',
|
|
68
|
+
},
|
|
69
|
+
py: {
|
|
70
|
+
property: 'padding',
|
|
71
|
+
properties: ['paddingTop', 'paddingBottom'],
|
|
72
|
+
scale: 'spacing',
|
|
73
|
+
},
|
|
74
|
+
pt: { property: 'paddingTop' },
|
|
75
|
+
pb: { property: 'paddingBottom' },
|
|
76
|
+
pr: { property: 'paddingRight' },
|
|
77
|
+
pl: { property: 'paddingLeft' },
|
|
78
|
+
m: { property: 'margin' },
|
|
79
|
+
mx: {
|
|
80
|
+
property: 'margin',
|
|
81
|
+
properties: ['marginLeft', 'marginRight'],
|
|
82
|
+
scale: 'spacing',
|
|
83
|
+
},
|
|
84
|
+
my: {
|
|
85
|
+
property: 'margin',
|
|
86
|
+
properties: ['marginTop', 'marginBottom'],
|
|
87
|
+
scale: 'spacing',
|
|
88
|
+
},
|
|
89
|
+
mt: { property: 'marginTop' },
|
|
90
|
+
mb: { property: 'marginBottom' },
|
|
91
|
+
mr: { property: 'marginRight' },
|
|
92
|
+
ml: { property: 'marginLeft' },
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=testConfig.js.map
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
-
|
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
1
|
import { isObject } from 'lodash';
|
|
8
|
-
/**
|
|
9
|
-
* Returns an exhaustive list of all possible paths of an object T for keys K.
|
|
10
|
-
* Possibilities are returned as `k1.k2.k3`.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
2
|
export function flattenScale(object, path) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
return Object.keys(object).reduce((carry, key) => {
|
|
4
|
+
const nextKey = path ? `${path}${key === '_' ? '' : `-${key}`}` : key;
|
|
5
|
+
const current = object[key];
|
|
6
|
+
if (isObject(current)) {
|
|
7
|
+
return {
|
|
8
|
+
...carry,
|
|
9
|
+
...flattenScale(current, nextKey),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
...carry,
|
|
14
|
+
[nextKey]: object[key],
|
|
15
|
+
};
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=flattenScale.js.map
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { keys, pick } from 'lodash';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
return !filteredKeys.includes(key);
|
|
5
|
-
}));
|
|
6
|
-
};
|
|
2
|
+
export const getStaticCss = (props, filteredKeys) => pick(props, keys(props).filter((key) => !filteredKeys.includes(key)));
|
|
3
|
+
//# sourceMappingURL=getStaticProperties.js.map
|
package/dist/utils/propNames.js
CHANGED
|
@@ -1,52 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const SHORTHAND_PROPERTIES = [
|
|
2
|
+
'border',
|
|
3
|
+
'borderTop',
|
|
4
|
+
'borderBottom',
|
|
5
|
+
'borderLeft',
|
|
6
|
+
'borderRight',
|
|
7
|
+
'borderWidth',
|
|
8
|
+
'borderStyle',
|
|
9
|
+
'borderColor',
|
|
10
|
+
'background',
|
|
11
|
+
'flex',
|
|
12
|
+
'margin',
|
|
13
|
+
'padding',
|
|
14
|
+
'transition',
|
|
15
|
+
'gap',
|
|
16
|
+
'grid',
|
|
17
|
+
'gridArea',
|
|
18
|
+
'gridColumn',
|
|
19
|
+
'gridRow',
|
|
20
|
+
'gridTemplate',
|
|
21
|
+
'overflow',
|
|
22
|
+
'transition',
|
|
23
|
+
];
|
|
24
|
+
const SORT = {
|
|
25
|
+
A_BEFORE_B: -1,
|
|
26
|
+
B_BEFORE_A: 1,
|
|
27
|
+
EQUAL: 1,
|
|
6
28
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
const compare = (a, b) => {
|
|
30
|
+
if (a < b)
|
|
31
|
+
return SORT.A_BEFORE_B;
|
|
32
|
+
if (b < a)
|
|
33
|
+
return SORT.B_BEFORE_A;
|
|
34
|
+
return SORT.EQUAL;
|
|
12
35
|
};
|
|
13
36
|
/**
|
|
14
37
|
* Orders all properties by the most dependent props
|
|
15
38
|
* @param config
|
|
16
39
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var aProp = aConf.property,
|
|
24
|
-
_aConf$properties = aConf.properties,
|
|
25
|
-
aProperties = _aConf$properties === void 0 ? [] : _aConf$properties;
|
|
26
|
-
var bProp = bConf.property,
|
|
27
|
-
_bConf$properties = bConf.properties,
|
|
28
|
-
bProperties = _bConf$properties === void 0 ? [] : _bConf$properties;
|
|
29
|
-
var aIsShorthand = SHORTHAND_PROPERTIES.includes(aProp);
|
|
30
|
-
var bIsShorthand = SHORTHAND_PROPERTIES.includes(bProp);
|
|
31
|
-
|
|
40
|
+
export const orderPropNames = (config) => Object.keys(config).sort((a, b) => {
|
|
41
|
+
const { [a]: aConf, [b]: bConf } = config;
|
|
42
|
+
const { property: aProp, properties: aProperties = [] } = aConf;
|
|
43
|
+
const { property: bProp, properties: bProperties = [] } = bConf;
|
|
44
|
+
const aIsShorthand = SHORTHAND_PROPERTIES.includes(aProp);
|
|
45
|
+
const bIsShorthand = SHORTHAND_PROPERTIES.includes(bProp);
|
|
32
46
|
if (aIsShorthand && bIsShorthand) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return compare(bNum, aNum);
|
|
47
|
+
const aNum = aProperties.length;
|
|
48
|
+
const bNum = bProperties.length;
|
|
49
|
+
if (aProp !== bProp) {
|
|
50
|
+
return compare(SHORTHAND_PROPERTIES.indexOf(aProp), SHORTHAND_PROPERTIES.indexOf(bProp));
|
|
51
|
+
}
|
|
52
|
+
if (aProp === bProp) {
|
|
53
|
+
if (aNum === 0)
|
|
54
|
+
return SORT.A_BEFORE_B;
|
|
55
|
+
if (bNum === 0)
|
|
56
|
+
return SORT.B_BEFORE_A;
|
|
57
|
+
}
|
|
58
|
+
return compare(bNum, aNum);
|
|
46
59
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (bIsShorthand)
|
|
60
|
+
if (aIsShorthand)
|
|
61
|
+
return SORT.A_BEFORE_B;
|
|
62
|
+
if (bIsShorthand)
|
|
63
|
+
return SORT.B_BEFORE_A;
|
|
50
64
|
return SORT.EQUAL;
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=propNames.js.map
|
package/dist/utils/responsive.js
CHANGED
|
@@ -1,94 +1,65 @@
|
|
|
1
|
-
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
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); }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
-
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
|
|
13
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
|
|
15
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
1
|
import { intersection, omit } from 'lodash';
|
|
20
|
-
|
|
2
|
+
const BREAKPOINT_KEYS = ['_', 'xs', 'sm', 'md', 'lg', 'xl'];
|
|
21
3
|
/**
|
|
22
4
|
* Destructures the themes breakpoints into an ordered structure to traverse
|
|
23
5
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
xl = _ref.xl; // Ensure order for mapping
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
map: breakpoints,
|
|
38
|
-
array: [xs, sm, md, lg, xl]
|
|
39
|
-
};
|
|
6
|
+
export const parseBreakpoints = (breakpoints) => {
|
|
7
|
+
if (breakpoints === undefined)
|
|
8
|
+
return null;
|
|
9
|
+
const { xs, sm, md, lg, xl } = breakpoints ?? {};
|
|
10
|
+
// Ensure order for mapping
|
|
11
|
+
return {
|
|
12
|
+
map: breakpoints,
|
|
13
|
+
array: [xs, sm, md, lg, xl],
|
|
14
|
+
};
|
|
40
15
|
};
|
|
41
|
-
export
|
|
42
|
-
|
|
16
|
+
export const isMediaArray = (val) => Array.isArray(val);
|
|
17
|
+
export const isMediaMap = (val) => intersection(Object.keys(val), BREAKPOINT_KEYS).length > 0;
|
|
18
|
+
export const objectParser = (value, props, config, breakpoints) => {
|
|
19
|
+
const styles = {};
|
|
20
|
+
const { styleFn, prop } = config;
|
|
21
|
+
const { _, ...rest } = value;
|
|
22
|
+
// the keyof 'base' is base styles
|
|
23
|
+
if (_)
|
|
24
|
+
Object.assign(styles, styleFn(_, prop, props));
|
|
25
|
+
// Map over remaining keys and merge the corresponding breakpoint styles
|
|
26
|
+
// for that property.
|
|
27
|
+
Object.keys(breakpoints).forEach((breakpointKey) => {
|
|
28
|
+
const bpStyles = rest[breakpointKey];
|
|
29
|
+
if (typeof bpStyles === 'undefined')
|
|
30
|
+
return;
|
|
31
|
+
Object.assign(styles, {
|
|
32
|
+
[breakpoints[breakpointKey]]: styleFn(bpStyles, prop, props),
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return styles;
|
|
43
36
|
};
|
|
44
|
-
export
|
|
45
|
-
|
|
37
|
+
export const arrayParser = (value, props, config, breakpoints) => {
|
|
38
|
+
const styles = {};
|
|
39
|
+
const { styleFn, prop } = config;
|
|
40
|
+
const [_, ...rest] = value;
|
|
41
|
+
// the first index is base styles
|
|
42
|
+
if (_)
|
|
43
|
+
Object.assign(styles, styleFn(_, prop, props));
|
|
44
|
+
// Map over each value in the array and merge the corresponding breakpoint styles
|
|
45
|
+
// for that property.
|
|
46
|
+
rest.forEach((val, i) => {
|
|
47
|
+
const breakpointKey = breakpoints[i];
|
|
48
|
+
if (!breakpointKey || typeof val === 'undefined')
|
|
49
|
+
return;
|
|
50
|
+
Object.assign(styles, {
|
|
51
|
+
[breakpointKey]: styleFn(val, prop, props),
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return styles;
|
|
46
55
|
};
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (_) Object.assign(styles, styleFn(_, prop, props)); // Map over remaining keys and merge the corresponding breakpoint styles
|
|
57
|
-
// for that property.
|
|
58
|
-
|
|
59
|
-
Object.keys(breakpoints).forEach(function (breakpointKey) {
|
|
60
|
-
var bpStyles = rest[breakpointKey];
|
|
61
|
-
if (typeof bpStyles === 'undefined') return;
|
|
62
|
-
Object.assign(styles, _defineProperty({}, breakpoints[breakpointKey], styleFn(bpStyles, prop, props)));
|
|
63
|
-
});
|
|
64
|
-
return styles;
|
|
56
|
+
export const orderBreakpoints = (styles, breakpoints) => {
|
|
57
|
+
const orderedStyles = omit(styles, breakpoints);
|
|
58
|
+
breakpoints.forEach((bp) => {
|
|
59
|
+
if (styles[bp]) {
|
|
60
|
+
orderedStyles[bp] = styles[bp];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return orderedStyles;
|
|
65
64
|
};
|
|
66
|
-
|
|
67
|
-
var styles = {};
|
|
68
|
-
var styleFn = config.styleFn,
|
|
69
|
-
prop = config.prop;
|
|
70
|
-
|
|
71
|
-
var _value = _toArray(value),
|
|
72
|
-
_ = _value[0],
|
|
73
|
-
rest = _value.slice(1); // the first index is base styles
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (_) Object.assign(styles, styleFn(_, prop, props)); // Map over each value in the array and merge the corresponding breakpoint styles
|
|
77
|
-
// for that property.
|
|
78
|
-
|
|
79
|
-
rest.forEach(function (val, i) {
|
|
80
|
-
var breakpointKey = breakpoints[i];
|
|
81
|
-
if (!breakpointKey || typeof val === 'undefined') return;
|
|
82
|
-
Object.assign(styles, _defineProperty({}, breakpointKey, styleFn(val, prop, props)));
|
|
83
|
-
});
|
|
84
|
-
return styles;
|
|
85
|
-
};
|
|
86
|
-
export var orderBreakpoints = function orderBreakpoints(styles, breakpoints) {
|
|
87
|
-
var orderedStyles = omit(styles, breakpoints);
|
|
88
|
-
breakpoints.forEach(function (bp) {
|
|
89
|
-
if (styles[bp]) {
|
|
90
|
-
orderedStyles[bp] = styles[bp];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
return orderedStyles;
|
|
94
|
-
};
|
|
65
|
+
//# sourceMappingURL=responsive.js.map
|