@elliemae/ds-system 2.3.0-alpha.9 → 2.3.0-next.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/cjs/arithmetic.js +43 -0
- package/cjs/constants.js +19 -0
- package/cjs/globalStyles.js +25 -0
- package/cjs/index.js +84 -0
- package/cjs/mobileUtilities.js +41 -0
- package/cjs/spaceUtilities.js +68 -0
- package/cjs/styled/index.d.js +2 -0
- package/cjs/styled/index.js +124 -0
- package/cjs/styled/styleGetters.js +44 -0
- package/cjs/styled/types.js +12 -0
- package/cjs/styled/utils.js +24 -0
- package/cjs/th.js +43 -0
- package/cjs/theme.js +9 -0
- package/cjs/themeProviderHOC.js +29 -0
- package/cjs/utils.js +184 -0
- package/{dist/esm → esm}/arithmetic.js +25 -13
- package/esm/constants.js +13 -0
- package/esm/globalStyles.js +17 -0
- package/esm/index.js +11 -0
- package/esm/mobileUtilities.js +34 -0
- package/esm/spaceUtilities.js +57 -0
- package/esm/styled/index.d.js +1 -0
- package/esm/styled/index.js +115 -0
- package/esm/styled/styleGetters.js +38 -0
- package/esm/styled/types.js +1 -0
- package/esm/styled/utils.js +18 -0
- package/esm/th.js +39 -0
- package/esm/theme.js +5 -0
- package/esm/themeProviderHOC.js +20 -0
- package/esm/utils.js +136 -0
- package/package.json +45 -47
- package/{dist/types → types}/arithmetic.d.ts +0 -0
- package/{dist/types → types}/constants.d.ts +0 -0
- package/{dist/types → types}/globalStyles.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/{dist/types → types}/mobileUtilities.d.ts +0 -0
- package/{dist/types → types}/spaceUtilities.d.ts +0 -0
- package/{dist/types → types}/styled/index.d.ts +0 -0
- package/{dist/types → types}/styled/styleGetters.d.ts +0 -0
- package/{dist/types → types}/styled/types.d.ts +0 -0
- package/{dist/types → types}/styled/utils.d.ts +0 -0
- package/{dist/types → types}/tests/arithmetic.test.d.ts +0 -0
- package/{dist/types → types}/th.d.ts +0 -0
- package/{dist/types → types}/theme.d.ts +0 -0
- package/{dist/types → types}/themeProviderHOC.d.ts +0 -0
- package/{dist/types → types}/utils.d.ts +2 -1
- package/dist/cjs/arithmetic.js +0 -55
- package/dist/cjs/arithmetic.js.map +0 -7
- package/dist/cjs/constants.js +0 -47
- package/dist/cjs/constants.js.map +0 -7
- package/dist/cjs/globalStyles.js +0 -47
- package/dist/cjs/globalStyles.js.map +0 -7
- package/dist/cjs/index.js +0 -43
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/mobileUtilities.js +0 -72
- package/dist/cjs/mobileUtilities.js.map +0 -7
- package/dist/cjs/spaceUtilities.js +0 -94
- package/dist/cjs/spaceUtilities.js.map +0 -7
- package/dist/cjs/styled/index.d.js +0 -27
- package/dist/cjs/styled/index.d.js.map +0 -7
- package/dist/cjs/styled/index.js +0 -89
- package/dist/cjs/styled/index.js.map +0 -7
- package/dist/cjs/styled/styleGetters.js +0 -56
- package/dist/cjs/styled/styleGetters.js.map +0 -7
- package/dist/cjs/styled/types.js +0 -35
- package/dist/cjs/styled/types.js.map +0 -7
- package/dist/cjs/styled/utils.js +0 -47
- package/dist/cjs/styled/utils.js.map +0 -7
- package/dist/cjs/th.js +0 -58
- package/dist/cjs/th.js.map +0 -7
- package/dist/cjs/theme.js +0 -36
- package/dist/cjs/theme.js.map +0 -7
- package/dist/cjs/themeProviderHOC.js +0 -42
- package/dist/cjs/themeProviderHOC.js.map +0 -7
- package/dist/cjs/utils.js +0 -294
- package/dist/cjs/utils.js.map +0 -7
- package/dist/esm/arithmetic.js.map +0 -7
- package/dist/esm/constants.js +0 -18
- package/dist/esm/constants.js.map +0 -7
- package/dist/esm/globalStyles.js +0 -18
- package/dist/esm/globalStyles.js.map +0 -7
- package/dist/esm/index.js +0 -14
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/mobileUtilities.js +0 -43
- package/dist/esm/mobileUtilities.js.map +0 -7
- package/dist/esm/spaceUtilities.js +0 -65
- package/dist/esm/spaceUtilities.js.map +0 -7
- package/dist/esm/styled/index.d.js +0 -2
- package/dist/esm/styled/index.d.js.map +0 -7
- package/dist/esm/styled/index.js +0 -60
- package/dist/esm/styled/index.js.map +0 -7
- package/dist/esm/styled/styleGetters.js +0 -27
- package/dist/esm/styled/styleGetters.js.map +0 -7
- package/dist/esm/styled/types.js +0 -6
- package/dist/esm/styled/types.js.map +0 -7
- package/dist/esm/styled/utils.js +0 -18
- package/dist/esm/styled/utils.js.map +0 -7
- package/dist/esm/th.js +0 -29
- package/dist/esm/th.js.map +0 -7
- package/dist/esm/theme.js +0 -7
- package/dist/esm/theme.js.map +0 -7
- package/dist/esm/themeProviderHOC.js +0 -13
- package/dist/esm/themeProviderHOC.js.map +0 -7
- package/dist/esm/utils.js +0 -265
- package/dist/esm/utils.js.map +0 -7
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
|
|
7
|
+
function getNumberAndUnit(numberStrWithUnit) {
|
|
8
|
+
const [number, unit] = String(numberStrWithUnit).match(/[a-z]+|[(/^\-?\d*.\d+|\d+),?]+/gi);
|
|
9
|
+
return {
|
|
10
|
+
number,
|
|
11
|
+
unit
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function op(operator, n1, n2) {
|
|
15
|
+
const {
|
|
16
|
+
number,
|
|
17
|
+
unit
|
|
18
|
+
} = getNumberAndUnit(n1);
|
|
19
|
+
const {
|
|
20
|
+
number: number2,
|
|
21
|
+
unit: unit2
|
|
22
|
+
} = getNumberAndUnit(n2);
|
|
23
|
+
|
|
24
|
+
switch (operator) {
|
|
25
|
+
case '*':
|
|
26
|
+
return Number(number) * Number(number2) + (unit || unit2);
|
|
27
|
+
|
|
28
|
+
case '+':
|
|
29
|
+
return Number(number) + Number(number2) + (unit || unit2);
|
|
30
|
+
|
|
31
|
+
case '-':
|
|
32
|
+
return Number(number) - Number(number2) + (unit || unit2);
|
|
33
|
+
|
|
34
|
+
case '/':
|
|
35
|
+
return Number(number) / Number(number2) + (unit || unit2);
|
|
36
|
+
|
|
37
|
+
default:
|
|
38
|
+
return Number(number) + Number(number2) + (unit || unit2);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.getNumberAndUnit = getNumberAndUnit;
|
|
43
|
+
exports.op = op;
|
package/cjs/constants.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const desktopBaseFont = 13;
|
|
6
|
+
const mobileBaseFont = 16;
|
|
7
|
+
const translateUnits = {
|
|
8
|
+
'8px': '4px',
|
|
9
|
+
'16px': '8px',
|
|
10
|
+
'32px': '16px',
|
|
11
|
+
'48px': '24px',
|
|
12
|
+
'56px': '32px',
|
|
13
|
+
'64px': '48px',
|
|
14
|
+
'72px': '64px'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.desktopBaseFont = desktopBaseFont;
|
|
18
|
+
exports.mobileBaseFont = mobileBaseFont;
|
|
19
|
+
exports.translateUnits = translateUnits;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
|
|
6
|
+
require('polished');
|
|
7
|
+
require('lodash');
|
|
8
|
+
require('./theme.js');
|
|
9
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
|
+
require('react');
|
|
11
|
+
var styled_component = require('styled-components');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
16
|
+
|
|
17
|
+
var _templateObject;
|
|
18
|
+
const GlobalStyles = styled_component.createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n :root, body {\n overscroll-behavior-y: none;\n\n font-size: ", ";\n\n @media(min-width: ", ") {\n font-size: ", ";\n }\n\n }\n"])), props => props.device === 'desktop' ? '13px' : '16px', _ref => {
|
|
19
|
+
let {
|
|
20
|
+
theme
|
|
21
|
+
} = _ref;
|
|
22
|
+
return theme.breakpoints.small;
|
|
23
|
+
}, props => props.device === 'mobile' ? '16px' : '13px');
|
|
24
|
+
|
|
25
|
+
exports.GlobalStyles = GlobalStyles;
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var globalStyles = require('./globalStyles.js');
|
|
6
|
+
var spaceUtilities = require('./spaceUtilities.js');
|
|
7
|
+
var mobileUtilities = require('./mobileUtilities.js');
|
|
8
|
+
var utils = require('./utils.js');
|
|
9
|
+
var arithmetic = require('./arithmetic.js');
|
|
10
|
+
var th = require('./th.js');
|
|
11
|
+
var theme = require('./theme.js');
|
|
12
|
+
var index = require('./styled/index.js');
|
|
13
|
+
var themeProviderHOC = require('./themeProviderHOC.js');
|
|
14
|
+
var styled_component = require('styled-components');
|
|
15
|
+
var polished = require('polished');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.GlobalStyles = globalStyles.GlobalStyles;
|
|
20
|
+
exports.fixSpace = spaceUtilities.fixSpace;
|
|
21
|
+
exports.fixSpaceGutter = spaceUtilities.fixSpaceGutter;
|
|
22
|
+
exports.mapGap = spaceUtilities.mapGap;
|
|
23
|
+
exports.mapGrid = spaceUtilities.mapGrid;
|
|
24
|
+
exports.mapGutter = spaceUtilities.mapGutter;
|
|
25
|
+
exports.mapSpace = spaceUtilities.mapSpace;
|
|
26
|
+
exports.mapTemplateGrid = spaceUtilities.mapTemplateGrid;
|
|
27
|
+
exports.numbersToFr = spaceUtilities.numbersToFr;
|
|
28
|
+
exports.__UNSAFE_SPACE_TO_DIMSUM = mobileUtilities.__UNSAFE_SPACE_TO_DIMSUM;
|
|
29
|
+
exports.isMobile = mobileUtilities.isMobile;
|
|
30
|
+
exports.toMobile = mobileUtilities.toMobile;
|
|
31
|
+
exports.useIsMobile = mobileUtilities.useIsMobile;
|
|
32
|
+
exports.active = utils.active;
|
|
33
|
+
exports.animation = utils.animation;
|
|
34
|
+
exports.border = utils.border;
|
|
35
|
+
exports.boxShadow = utils.boxShadow;
|
|
36
|
+
exports.buttonLink = utils.buttonLink;
|
|
37
|
+
exports.clearFocus = utils.clearFocus;
|
|
38
|
+
exports.color = utils.color;
|
|
39
|
+
exports.disabled = utils.disabled;
|
|
40
|
+
exports.fakeActive = utils.fakeActive;
|
|
41
|
+
exports.fakeBorder = utils.fakeBorder;
|
|
42
|
+
exports.flexCenter = utils.flexCenter;
|
|
43
|
+
exports.focus = utils.focus;
|
|
44
|
+
exports.focusAfter = utils.focusAfter;
|
|
45
|
+
exports.hover = utils.hover;
|
|
46
|
+
exports.iconColor = utils.iconColor;
|
|
47
|
+
exports.keyframes = utils.keyframes;
|
|
48
|
+
exports.onlyFirefox = utils.onlyFirefox;
|
|
49
|
+
exports.onlySafari = utils.onlySafari;
|
|
50
|
+
exports.onlySafariAndFirefox = utils.onlySafariAndFirefox;
|
|
51
|
+
exports.safariAndFirefoxBold = utils.safariAndFirefoxBold;
|
|
52
|
+
exports.textStyle = utils.textStyle;
|
|
53
|
+
exports.transition = utils.transition;
|
|
54
|
+
exports.truncate = utils.truncate;
|
|
55
|
+
exports.getNumberAndUnit = arithmetic.getNumberAndUnit;
|
|
56
|
+
exports.op = arithmetic.op;
|
|
57
|
+
exports.th = th.th;
|
|
58
|
+
exports.theme = theme.theme;
|
|
59
|
+
exports.styled = index.styled;
|
|
60
|
+
exports.themeProviderHOC = themeProviderHOC.themeProviderHOC;
|
|
61
|
+
Object.defineProperty(exports, 'createGlobalStyle', {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return styled_component.createGlobalStyle; }
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, 'css', {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return styled_component.css; }
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, 'kfrm', {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return styled_component.keyframes; }
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, 'useTheme', {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () { return styled_component.useTheme; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, 'withTheme', {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return styled_component.withTheme; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, 'rgba', {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return polished.rgba; }
|
|
84
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var theme = require('./theme.js');
|
|
8
|
+
var constants = require('./constants.js');
|
|
9
|
+
|
|
10
|
+
function __UNSAFE_SPACE_TO_DIMSUM(unit) {
|
|
11
|
+
if (constants.translateUnits[unit]) return constants.translateUnits[unit];
|
|
12
|
+
return "".concat(parseFloat(unit) * (constants.mobileBaseFont / constants.desktopBaseFont) / 2, "px");
|
|
13
|
+
}
|
|
14
|
+
function toMobile(unit) {
|
|
15
|
+
if (!isMobile()) return unit;
|
|
16
|
+
return "".concat(parseFloat(unit) * (constants.desktopBaseFont / constants.mobileBaseFont), "rem");
|
|
17
|
+
}
|
|
18
|
+
const useIsMobile = () => {
|
|
19
|
+
const [mobile, setMobile] = react.useState(isMobile());
|
|
20
|
+
react.useEffect(() => {
|
|
21
|
+
function handleResize() {
|
|
22
|
+
setMobile(isMobile());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (window) window.addEventListener('resize', handleResize);
|
|
26
|
+
return () => {
|
|
27
|
+
if (window) window.removeEventListener('resize', handleResize);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
if (!window) return false;
|
|
31
|
+
return mobile;
|
|
32
|
+
};
|
|
33
|
+
const isMobile = () => {
|
|
34
|
+
if (!window) return false;
|
|
35
|
+
return Number(theme.theme.breakpoints.medium.split('px')[0]) - window.innerWidth >= 0;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.__UNSAFE_SPACE_TO_DIMSUM = __UNSAFE_SPACE_TO_DIMSUM;
|
|
39
|
+
exports.isMobile = isMobile;
|
|
40
|
+
exports.toMobile = toMobile;
|
|
41
|
+
exports.useIsMobile = useIsMobile;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.some.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.some.js');
|
|
10
|
+
var lodash = require('lodash');
|
|
11
|
+
var theme = require('./theme.js');
|
|
12
|
+
|
|
13
|
+
function mapGap(gutter) {
|
|
14
|
+
if (!gutter) return '0rem';
|
|
15
|
+
if (String(gutter).includes('rem') || String(gutter).includes('px')) return gutter;
|
|
16
|
+
return "".concat(theme.theme.space[gutter]);
|
|
17
|
+
}
|
|
18
|
+
function mapGutter(gutter) {
|
|
19
|
+
if (!gutter) return '0rem';
|
|
20
|
+
return "".concat(theme.theme.space[gutter], " * 2");
|
|
21
|
+
}
|
|
22
|
+
function mapSpace(width) {
|
|
23
|
+
if (typeof width === 'string') return lodash.get(theme.theme, width) ? "".concat(lodash.get(theme.theme, width)) : width;
|
|
24
|
+
return "".concat(width * 100, "%");
|
|
25
|
+
}
|
|
26
|
+
function fixSpaceGutter(width, gutter) {
|
|
27
|
+
if (!width) return '';
|
|
28
|
+
if (Array.isArray(width)) return width.map(w => "calc(".concat(mapSpace(w), " - (").concat(mapGutter(gutter), "))"));
|
|
29
|
+
return "calc(".concat(mapSpace(width), " - (").concat(mapGutter(gutter), "))");
|
|
30
|
+
}
|
|
31
|
+
function fixSpace(width) {
|
|
32
|
+
if (!width) return '';
|
|
33
|
+
if (Array.isArray(width)) return width.map(w => mapSpace(w));
|
|
34
|
+
return mapSpace(width);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Grid
|
|
38
|
+
*
|
|
39
|
+
* @param grid
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
function numbersToFr(grid) {
|
|
43
|
+
const den = grid.map(f => f < 1 ? Math.floor(1 / f) : f);
|
|
44
|
+
return den.map(d => "".concat(d, "fr"));
|
|
45
|
+
}
|
|
46
|
+
function mapGrid(width) {
|
|
47
|
+
if (lodash.get(theme.theme, width)) return "".concat(lodash.get(theme.theme, width));
|
|
48
|
+
if (typeof width === 'string') return width;
|
|
49
|
+
const den = width < 1 ? Math.floor(1 / width) : width;
|
|
50
|
+
return "".concat(den, "fr");
|
|
51
|
+
}
|
|
52
|
+
function mapTemplateGrid(grid) {
|
|
53
|
+
if (Array.isArray(grid)) {
|
|
54
|
+
if (grid.some(w => typeof w === 'string')) return grid.map(w => mapGrid(w));
|
|
55
|
+
return numbersToFr(grid);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return mapGrid(grid);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
exports.fixSpace = fixSpace;
|
|
62
|
+
exports.fixSpaceGutter = fixSpaceGutter;
|
|
63
|
+
exports.mapGap = mapGap;
|
|
64
|
+
exports.mapGrid = mapGrid;
|
|
65
|
+
exports.mapGutter = mapGutter;
|
|
66
|
+
exports.mapSpace = mapSpace;
|
|
67
|
+
exports.mapTemplateGrid = mapTemplateGrid;
|
|
68
|
+
exports.numbersToFr = numbersToFr;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
14
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
15
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
16
|
+
var styled_component = require('styled-components');
|
|
17
|
+
var styleGetters = require('./styleGetters.js');
|
|
18
|
+
var utils = require('./utils.js');
|
|
19
|
+
|
|
20
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
+
|
|
22
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
23
|
+
var styled_component__default = /*#__PURE__*/_interopDefaultLegacy(styled_component);
|
|
24
|
+
|
|
25
|
+
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; }
|
|
26
|
+
|
|
27
|
+
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__default["default"](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; }
|
|
28
|
+
|
|
29
|
+
const styledFunction = function (tag) {
|
|
30
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
31
|
+
name: null,
|
|
32
|
+
slot: null
|
|
33
|
+
};
|
|
34
|
+
const {
|
|
35
|
+
name: componentName = null,
|
|
36
|
+
slot: componentSlot = null
|
|
37
|
+
} = options;
|
|
38
|
+
|
|
39
|
+
const func = function (styleArg) {
|
|
40
|
+
for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
41
|
+
expressions[_key - 1] = arguments[_key];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* These are the internal expression written in dimsum
|
|
46
|
+
* We just coerce with the default theme in case users
|
|
47
|
+
* forget to add the ThemeProvider
|
|
48
|
+
*/
|
|
49
|
+
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? props => stylesArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
50
|
+
theme: utils.coerceWithDefaultTheme(props.theme)
|
|
51
|
+
})) : stylesArg) : [];
|
|
52
|
+
let transformedStyleArg = styleArg;
|
|
53
|
+
/*
|
|
54
|
+
* Here we get the style overrides from the user
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
if (componentName && componentSlot) {
|
|
58
|
+
expressionsWithDefaultTheme.push(props => {
|
|
59
|
+
const theme = utils.coerceWithDefaultTheme(props.theme);
|
|
60
|
+
const styleOverrides = styleGetters.getStyleOverrides(componentName, theme);
|
|
61
|
+
|
|
62
|
+
if (styleOverrides) {
|
|
63
|
+
return [styleOverrides[componentSlot]];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return null;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/*
|
|
70
|
+
* Here we get the variant overrides from the user (only for the root)
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if (componentName && componentSlot === 'root') {
|
|
75
|
+
expressionsWithDefaultTheme.push(props => {
|
|
76
|
+
const theme = utils.coerceWithDefaultTheme(props.theme);
|
|
77
|
+
return styleGetters.variantsResolver(props, styleGetters.getVariantStyles(componentName, theme), theme, componentName);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
82
|
+
|
|
83
|
+
if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
|
|
84
|
+
// Here we are adding placeholders for all the new functions that we are gonna call
|
|
85
|
+
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
86
|
+
transformedStyleArg = Object.assign([...styleArg, ...placeholders], {
|
|
87
|
+
raw: [...styleArg.raw, ...placeholders]
|
|
88
|
+
});
|
|
89
|
+
} else if (typeof styleArg === 'function') {
|
|
90
|
+
// Here we just coerce with the default theme
|
|
91
|
+
transformedStyleArg = props => styleArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
92
|
+
theme: utils.coerceWithDefaultTheme(props.theme)
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let Component = /*#__PURE__*/styled_component__default["default"](tag);
|
|
97
|
+
const displayName = componentName !== null && componentSlot !== null ? "".concat(componentName, "-").concat(componentSlot) : null;
|
|
98
|
+
|
|
99
|
+
if (displayName !== null) {
|
|
100
|
+
Component = Component.attrs({
|
|
101
|
+
className: "".concat(componentName, "-").concat(componentSlot)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Component = Component(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
106
|
+
|
|
107
|
+
if (displayName !== null) {
|
|
108
|
+
Component.displayName = displayName;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return Component;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return func;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const styledObject = Object.keys(styled_component__default["default"]).reduce((obj, key) => {
|
|
118
|
+
const castedKey = key;
|
|
119
|
+
obj[castedKey] = styledFunction(castedKey);
|
|
120
|
+
return obj;
|
|
121
|
+
}, {});
|
|
122
|
+
const styled = Object.assign(styledFunction, styledObject);
|
|
123
|
+
|
|
124
|
+
exports.styled = styled;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.every.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.every.js');
|
|
10
|
+
var utils = require('./utils.js');
|
|
11
|
+
|
|
12
|
+
const getStyleOverrides = (name, theme) => {
|
|
13
|
+
var _theme$components, _theme$components$nam;
|
|
14
|
+
|
|
15
|
+
return ((_theme$components = theme.components) === null || _theme$components === void 0 ? void 0 : (_theme$components$nam = _theme$components[name]) === null || _theme$components$nam === void 0 ? void 0 : _theme$components$nam.styleOverrides) || null;
|
|
16
|
+
};
|
|
17
|
+
const getVariantStyles = (name, theme) => {
|
|
18
|
+
var _theme$components2, _theme$components2$na;
|
|
19
|
+
|
|
20
|
+
const variants = ((_theme$components2 = theme.components) === null || _theme$components2 === void 0 ? void 0 : (_theme$components2$na = _theme$components2[name]) === null || _theme$components2$na === void 0 ? void 0 : _theme$components2$na.variants) || [];
|
|
21
|
+
return variants.reduce((styles, definition) => {
|
|
22
|
+
const key = utils.propsToClassKey(definition.props);
|
|
23
|
+
styles[key] = definition.style;
|
|
24
|
+
return styles;
|
|
25
|
+
}, {});
|
|
26
|
+
};
|
|
27
|
+
const variantsResolver = (props, styles, theme, name) => {
|
|
28
|
+
var _theme$components3, _theme$components3$na;
|
|
29
|
+
|
|
30
|
+
const themeVariants = (theme === null || theme === void 0 ? void 0 : (_theme$components3 = theme.components) === null || _theme$components3 === void 0 ? void 0 : (_theme$components3$na = _theme$components3[name]) === null || _theme$components3$na === void 0 ? void 0 : _theme$components3$na.variants) || [];
|
|
31
|
+
return themeVariants.reduce((variantsStyles, themeVariant) => {
|
|
32
|
+
const isMatch = Object.keys(themeVariant.props).every(key => props[key] === themeVariant.props[key]);
|
|
33
|
+
|
|
34
|
+
if (isMatch) {
|
|
35
|
+
variantsStyles.push(styles[utils.propsToClassKey(themeVariant.props)]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return variantsStyles;
|
|
39
|
+
}, []);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.getStyleOverrides = getStyleOverrides;
|
|
43
|
+
exports.getVariantStyles = getVariantStyles;
|
|
44
|
+
exports.variantsResolver = variantsResolver;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled_component = require('styled-components');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'CSSObject', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return styled_component.CSSObject; }
|
|
12
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
8
|
+
var dsUtilities = require('@elliemae/ds-utilities');
|
|
9
|
+
var theme = require('../theme.js');
|
|
10
|
+
|
|
11
|
+
const systemTheme = theme.theme;
|
|
12
|
+
const isEmpty = string => string.length === 0;
|
|
13
|
+
const coerceWithDefaultTheme = themeInput => themeInput !== null && themeInput !== void 0 ? themeInput : systemTheme;
|
|
14
|
+
const propsToClassKey = props => Object.keys(props).sort().reduce((classKey, key) => {
|
|
15
|
+
if (key === 'color') {
|
|
16
|
+
return classKey + isEmpty(String(classKey)) ? String(props[key]) : dsUtilities.capitalize(String(props[key]));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return "".concat(classKey).concat(isEmpty(String(classKey)) ? key : dsUtilities.capitalize(key)).concat(dsUtilities.capitalize(props[key].toString()));
|
|
20
|
+
}, '');
|
|
21
|
+
|
|
22
|
+
exports.coerceWithDefaultTheme = coerceWithDefaultTheme;
|
|
23
|
+
exports.isEmpty = isEmpty;
|
|
24
|
+
exports.propsToClassKey = propsToClassKey;
|
package/cjs/th.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
+
|
|
9
|
+
const th = property => {
|
|
10
|
+
const thGetter = function (value) {
|
|
11
|
+
let dfault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
12
|
+
|
|
13
|
+
const func = _ref => {
|
|
14
|
+
var _ref2;
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
theme
|
|
18
|
+
} = _ref;
|
|
19
|
+
const parts = value.split('-');
|
|
20
|
+
let result = theme[property];
|
|
21
|
+
parts.forEach(part => {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
23
|
+
if (result) result = result[part];
|
|
24
|
+
});
|
|
25
|
+
return (_ref2 = result) !== null && _ref2 !== void 0 ? _ref2 : dfault;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return func;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return thGetter;
|
|
32
|
+
};
|
|
33
|
+
th.space = th('space');
|
|
34
|
+
th.fontSize = th('fontSizes');
|
|
35
|
+
th.fontWeight = th('fontWeights');
|
|
36
|
+
th.lineHeight = th('lineHeights');
|
|
37
|
+
th.letterSpacing = th('letterSpacings');
|
|
38
|
+
th.font = th('fonts');
|
|
39
|
+
th.color = th('colors');
|
|
40
|
+
th.breakpoint = th('breakpoints');
|
|
41
|
+
th.media = th('media');
|
|
42
|
+
|
|
43
|
+
exports.th = th;
|
package/cjs/theme.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
+
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
11
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
12
|
+
require('react');
|
|
13
|
+
var styled_component = require('styled-components');
|
|
14
|
+
var theme = require('./theme.js');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var _jsx2__default = /*#__PURE__*/_interopDefaultLegacy(_jsx2);
|
|
20
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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__default["default"](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; }
|
|
25
|
+
const themeProviderHOC = Component => props => /*#__PURE__*/_jsx2__default["default"](styled_component.ThemeProvider, {
|
|
26
|
+
theme: theme.theme
|
|
27
|
+
}, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)));
|
|
28
|
+
|
|
29
|
+
exports.themeProviderHOC = themeProviderHOC;
|