@elliemae/ds-system 2.0.0-next.9 → 2.0.0-rc.12
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/globalStyles.js +7 -4
- package/cjs/index.js +10 -6
- package/cjs/spaceUtilities.js +5 -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 +32 -0
- package/cjs/themeProviderHOC.js +7 -2
- package/cjs/utils.js +39 -28
- package/esm/globalStyles.js +6 -3
- package/esm/index.js +2 -0
- package/esm/spaceUtilities.js +5 -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 +28 -0
- package/esm/themeProviderHOC.js +5 -0
- package/esm/utils.js +18 -7
- package/package.json +26 -7
- package/types/index.d.ts +2 -0
- package/types/styled/index.d.ts +2 -0
- package/types/styled/styleGetters.d.ts +4 -0
- package/types/styled/types.d.ts +28 -0
- package/types/styled/utils.d.ts +6 -0
- package/types/th.d.ts +14 -0
- package/types/utils.d.ts +5 -5
package/cjs/globalStyles.js
CHANGED
|
@@ -8,15 +8,18 @@ require('lodash');
|
|
|
8
8
|
require('./theme.js');
|
|
9
9
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
10
|
require('react');
|
|
11
|
-
var
|
|
11
|
+
var styled_component = require('styled-components');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
15
15
|
var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
|
|
16
16
|
|
|
17
17
|
var _templateObject;
|
|
18
|
-
const GlobalStyles =
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const GlobalStyles = styled_component.createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n :root, body {\n overscroll-behavior-y: none;\n\n ", "\n\n font-size: ", ";\n\n @media(min-width: ", ") {\n font-size: ", ";\n }\n\n }\n"])), props => void 0, 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');
|
|
21
24
|
|
|
22
25
|
exports.GlobalStyles = GlobalStyles;
|
package/cjs/index.js
CHANGED
|
@@ -7,9 +7,11 @@ var spaceUtilities = require('./spaceUtilities.js');
|
|
|
7
7
|
var mobileUtilities = require('./mobileUtilities.js');
|
|
8
8
|
var utils = require('./utils.js');
|
|
9
9
|
var arithmetic = require('./arithmetic.js');
|
|
10
|
+
var th = require('./th.js');
|
|
10
11
|
var theme = require('./theme.js');
|
|
12
|
+
var index = require('./styled/index.js');
|
|
11
13
|
var themeProviderHOC = require('./themeProviderHOC.js');
|
|
12
|
-
var
|
|
14
|
+
var styled_component = require('styled-components');
|
|
13
15
|
var polished = require('polished');
|
|
14
16
|
|
|
15
17
|
|
|
@@ -52,27 +54,29 @@ exports.transition = utils.transition;
|
|
|
52
54
|
exports.truncate = utils.truncate;
|
|
53
55
|
exports.getNumberAndUnit = arithmetic.getNumberAndUnit;
|
|
54
56
|
exports.op = arithmetic.op;
|
|
57
|
+
exports.th = th.th;
|
|
55
58
|
exports.theme = theme.theme;
|
|
59
|
+
exports.styled = index.styled;
|
|
56
60
|
exports.themeProviderHOC = themeProviderHOC.themeProviderHOC;
|
|
57
61
|
Object.defineProperty(exports, 'createGlobalStyle', {
|
|
58
62
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
63
|
+
get: function () { return styled_component.createGlobalStyle; }
|
|
60
64
|
});
|
|
61
65
|
Object.defineProperty(exports, 'css', {
|
|
62
66
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
67
|
+
get: function () { return styled_component.css; }
|
|
64
68
|
});
|
|
65
69
|
Object.defineProperty(exports, 'kfrm', {
|
|
66
70
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
71
|
+
get: function () { return styled_component.keyframes; }
|
|
68
72
|
});
|
|
69
73
|
Object.defineProperty(exports, 'useTheme', {
|
|
70
74
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
75
|
+
get: function () { return styled_component.useTheme; }
|
|
72
76
|
});
|
|
73
77
|
Object.defineProperty(exports, 'withTheme', {
|
|
74
78
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
79
|
+
get: function () { return styled_component.withTheme; }
|
|
76
80
|
});
|
|
77
81
|
Object.defineProperty(exports, 'rgba', {
|
|
78
82
|
enumerable: true,
|
package/cjs/spaceUtilities.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
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');
|
|
5
10
|
var lodash = require('lodash');
|
|
6
11
|
var theme = require('./theme.js');
|
|
7
12
|
|
|
@@ -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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](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; }
|
|
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,
|
|
36
|
+
slot: componentSlot
|
|
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,32 @@
|
|
|
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 => (value, dfault) => _ref => {
|
|
10
|
+
var _result;
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
theme
|
|
14
|
+
} = _ref;
|
|
15
|
+
const parts = value.split('-');
|
|
16
|
+
let result = theme[property];
|
|
17
|
+
parts.forEach(part => {
|
|
18
|
+
if (result) result = result[part];
|
|
19
|
+
});
|
|
20
|
+
return (_result = result) !== null && _result !== void 0 ? _result : dfault;
|
|
21
|
+
};
|
|
22
|
+
th.space = th('space');
|
|
23
|
+
th.fontSize = th('fontSizes');
|
|
24
|
+
th.fontWeight = th('fontWeights');
|
|
25
|
+
th.lineHeight = th('lineHeights');
|
|
26
|
+
th.letterSpacing = th('letterSpacings');
|
|
27
|
+
th.font = th('fonts');
|
|
28
|
+
th.color = th('colors');
|
|
29
|
+
th.breakpoint = th('breakpoints');
|
|
30
|
+
th.media = th('media');
|
|
31
|
+
|
|
32
|
+
exports.th = th;
|
package/cjs/themeProviderHOC.js
CHANGED
|
@@ -2,10 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
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');
|
|
5
10
|
var _jsx2 = require('@babel/runtime/helpers/jsx');
|
|
6
11
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
12
|
require('react');
|
|
8
|
-
var
|
|
13
|
+
var styled_component = require('styled-components');
|
|
9
14
|
var theme = require('./theme.js');
|
|
10
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
16
|
|
|
@@ -17,7 +22,7 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
17
22
|
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; }
|
|
18
23
|
|
|
19
24
|
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__default["default"](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; }
|
|
20
|
-
const themeProviderHOC = Component => props => /*#__PURE__*/_jsx2__default["default"](
|
|
25
|
+
const themeProviderHOC = Component => props => /*#__PURE__*/_jsx2__default["default"](styled_component.ThemeProvider, {
|
|
21
26
|
theme: theme.theme
|
|
22
27
|
}, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)));
|
|
23
28
|
|
package/cjs/utils.js
CHANGED
|
@@ -6,11 +6,11 @@ var polished = require('polished');
|
|
|
6
6
|
var lodash = require('lodash');
|
|
7
7
|
var theme = require('./theme.js');
|
|
8
8
|
var mobileUtilities = require('./mobileUtilities.js');
|
|
9
|
-
var
|
|
9
|
+
var styled_component = require('styled-components');
|
|
10
10
|
|
|
11
11
|
/* eslint-disable no-shadow */
|
|
12
12
|
function truncate(width) {
|
|
13
|
-
return props =>
|
|
13
|
+
return props => styled_component.css(["", " white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"], !!width || props.width ? "width: ".concat(props.width || width, ";") : '');
|
|
14
14
|
}
|
|
15
15
|
function flexCenter() {
|
|
16
16
|
return "\n display: flex;\n justify-content: center;\n align-items: center;\n ";
|
|
@@ -19,35 +19,43 @@ function disabled() {
|
|
|
19
19
|
return "\n cursor: not-allowed;\n pointer-events: none;\n ";
|
|
20
20
|
}
|
|
21
21
|
function keyframes(obj) {
|
|
22
|
-
return
|
|
22
|
+
return styled_component.keyframes(["", ""], lodash.reduce(obj, (result, value, key) => "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n "), ''));
|
|
23
23
|
} // eslint-disable-next-line max-params
|
|
24
24
|
|
|
25
|
-
function boxShadow(top, left, blur, color
|
|
25
|
+
function boxShadow(top, left, blur, color) {
|
|
26
|
+
let inset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
26
27
|
return "box-shadow: ".concat(inset ? 'inset' : '', " ").concat(top, " ").concat(left, " ").concat(blur, " ").concat(color, ";");
|
|
27
28
|
}
|
|
28
|
-
function color(
|
|
29
|
-
|
|
29
|
+
function color() {
|
|
30
|
+
let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
|
|
31
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
32
|
+
return styled_component.css(["color:", ";"], props => props.theme.colors[variant][type]);
|
|
30
33
|
}
|
|
31
|
-
function border(
|
|
34
|
+
function border() {
|
|
35
|
+
let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
|
|
36
|
+
let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1px';
|
|
37
|
+
let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'solid';
|
|
32
38
|
return "".concat(size, " ").concat(type, " ").concat(color);
|
|
33
39
|
}
|
|
34
40
|
function animation(animationKeyframes, animationLength, animationTimingFn) {
|
|
35
|
-
return props =>
|
|
41
|
+
return props => styled_component.css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
|
|
36
42
|
} // 0.0769
|
|
37
43
|
|
|
38
|
-
function focus(
|
|
39
|
-
|
|
44
|
+
function focus() {
|
|
45
|
+
let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
|
|
46
|
+
return () => styled_component.css(["outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], color, polished.lighten(0.3, color));
|
|
40
47
|
}
|
|
41
48
|
function focusAfter(color) {
|
|
42
|
-
return
|
|
49
|
+
return styled_component.css(["outline:none;position:relative;&:after{content:'';z-index:10;position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;", "}"], focus(color));
|
|
43
50
|
}
|
|
44
51
|
function active() {
|
|
45
|
-
return props =>
|
|
52
|
+
return props => styled_component.css(["outline:none;border:1px solid ", ";border-radius:2px;"], props.theme.colors.brand[700]);
|
|
46
53
|
}
|
|
47
54
|
function hover() {
|
|
48
|
-
return props =>
|
|
55
|
+
return props => styled_component.css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
|
|
49
56
|
}
|
|
50
|
-
function textStyle(type
|
|
57
|
+
function textStyle(type) {
|
|
58
|
+
let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
|
|
51
59
|
// eslint-disable-next-line complexity
|
|
52
60
|
return props => {
|
|
53
61
|
let cssVar = "font-weight: ".concat(props.theme.fontWeights[weight], ";"); // eslint-disable-next-line default-case
|
|
@@ -101,14 +109,16 @@ function textStyle(type, weight = 'regular') {
|
|
|
101
109
|
return cssVar;
|
|
102
110
|
};
|
|
103
111
|
}
|
|
104
|
-
function iconColor(
|
|
105
|
-
|
|
112
|
+
function iconColor() {
|
|
113
|
+
let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
|
|
114
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
115
|
+
return styled_component.css(["fill:", ";"], props => props.theme.colors[variant][type]);
|
|
106
116
|
}
|
|
107
117
|
function fakeBorder() {
|
|
108
|
-
return
|
|
118
|
+
return styled_component.css(["box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.neutral[200]);
|
|
109
119
|
}
|
|
110
120
|
function fakeActive() {
|
|
111
|
-
return
|
|
121
|
+
return styled_component.css(["outline:none;box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.brand[700]);
|
|
112
122
|
}
|
|
113
123
|
function clearFocus() {
|
|
114
124
|
return "\n border: none;\n box-shadow: none;\n ";
|
|
@@ -116,20 +126,21 @@ function clearFocus() {
|
|
|
116
126
|
function buttonLink() {
|
|
117
127
|
return "\n background-color: transparent;\n border: 1px solid transparent;\n cursor: pointer;\n ";
|
|
118
128
|
}
|
|
119
|
-
function transition(
|
|
129
|
+
function transition() {
|
|
130
|
+
let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all 1s ease';
|
|
120
131
|
return "\n transition: ".concat(t, ";\n ");
|
|
121
132
|
}
|
|
122
133
|
function onlySafariAndFiredox(styles) {
|
|
123
|
-
return
|
|
134
|
+
return styled_component.css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
|
|
124
135
|
}
|
|
125
136
|
function onlySafari(styles) {
|
|
126
|
-
return
|
|
137
|
+
return styled_component.css(["@media not all and (min-resolution:0.001dpcm){", "}"], styles);
|
|
127
138
|
}
|
|
128
139
|
function onlyFirefox(styles) {
|
|
129
|
-
return
|
|
140
|
+
return styled_component.css(["@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles);
|
|
130
141
|
}
|
|
131
142
|
function safariAndFirefoxBold(color) {
|
|
132
|
-
return
|
|
143
|
+
return styled_component.css(["@media not all and (min-resolution:0.001dpcm){font-weight:400;-webkit-font-smoothing:subpixel-antialiased;-webkit-text-stroke:0.4px ", ";}@media screen and (min--moz-device-pixel-ratio:0){font-weight:400;-webkit-font-smoothing:subpixel-antialiased;-webkit-text-stroke:0.4px ", ";}"], color, color);
|
|
133
144
|
}
|
|
134
145
|
|
|
135
146
|
Object.defineProperty(exports, 'rgba', {
|
|
@@ -138,23 +149,23 @@ Object.defineProperty(exports, 'rgba', {
|
|
|
138
149
|
});
|
|
139
150
|
Object.defineProperty(exports, 'createGlobalStyle', {
|
|
140
151
|
enumerable: true,
|
|
141
|
-
get: function () { return
|
|
152
|
+
get: function () { return styled_component.createGlobalStyle; }
|
|
142
153
|
});
|
|
143
154
|
Object.defineProperty(exports, 'css', {
|
|
144
155
|
enumerable: true,
|
|
145
|
-
get: function () { return
|
|
156
|
+
get: function () { return styled_component.css; }
|
|
146
157
|
});
|
|
147
158
|
Object.defineProperty(exports, 'kfrm', {
|
|
148
159
|
enumerable: true,
|
|
149
|
-
get: function () { return
|
|
160
|
+
get: function () { return styled_component.keyframes; }
|
|
150
161
|
});
|
|
151
162
|
Object.defineProperty(exports, 'useTheme', {
|
|
152
163
|
enumerable: true,
|
|
153
|
-
get: function () { return
|
|
164
|
+
get: function () { return styled_component.useTheme; }
|
|
154
165
|
});
|
|
155
166
|
Object.defineProperty(exports, 'withTheme', {
|
|
156
167
|
enumerable: true,
|
|
157
|
-
get: function () { return
|
|
168
|
+
get: function () { return styled_component.withTheme; }
|
|
158
169
|
});
|
|
159
170
|
exports.active = active;
|
|
160
171
|
exports.animation = animation;
|
package/esm/globalStyles.js
CHANGED
|
@@ -7,8 +7,11 @@ import 'react';
|
|
|
7
7
|
import { createGlobalStyle } from 'styled-components';
|
|
8
8
|
|
|
9
9
|
var _templateObject;
|
|
10
|
-
const GlobalStyles = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root, body {\n overscroll-behavior-y: none;\n font-size:
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const GlobalStyles = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root, body {\n overscroll-behavior-y: none;\n\n ", "\n\n font-size: ", ";\n\n @media(min-width: ", ") {\n font-size: ", ";\n }\n\n }\n"])), props => void 0, props => props.device === 'desktop' ? '13px' : '16px', _ref => {
|
|
11
|
+
let {
|
|
12
|
+
theme
|
|
13
|
+
} = _ref;
|
|
14
|
+
return theme.breakpoints.small;
|
|
15
|
+
}, props => props.device === 'mobile' ? '16px' : '13px');
|
|
13
16
|
|
|
14
17
|
export { GlobalStyles };
|
package/esm/index.js
CHANGED
|
@@ -3,7 +3,9 @@ export { fixSpace, fixSpaceGutter, mapGap, mapGrid, mapGutter, mapSpace, mapTemp
|
|
|
3
3
|
export { __UNSAFE_SPACE_TO_DIMSUM, isMobile, toMobile, useIsMobile } from './mobileUtilities.js';
|
|
4
4
|
export { active, animation, border, boxShadow, buttonLink, clearFocus, color, disabled, fakeActive, fakeBorder, flexCenter, focus, focusAfter, hover, iconColor, keyframes, onlyFirefox, onlySafari, onlySafariAndFiredox, safariAndFirefoxBold, textStyle, transition, truncate } from './utils.js';
|
|
5
5
|
export { getNumberAndUnit, op } from './arithmetic.js';
|
|
6
|
+
export { th } from './th.js';
|
|
6
7
|
export { theme } from './theme.js';
|
|
8
|
+
export { styled } from './styled/index.js';
|
|
7
9
|
export { themeProviderHOC } from './themeProviderHOC.js';
|
|
8
10
|
export { createGlobalStyle, css, keyframes as kfrm, useTheme, withTheme } from 'styled-components';
|
|
9
11
|
export { rgba } from 'polished';
|
package/esm/spaceUtilities.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
1
6
|
import { get } from 'lodash';
|
|
2
7
|
import { theme } from './theme.js';
|
|
3
8
|
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
12
|
+
import styled_component from 'styled-components';
|
|
13
|
+
import { getStyleOverrides, variantsResolver, getVariantStyles } from './styleGetters.js';
|
|
14
|
+
import { coerceWithDefaultTheme } from './utils.js';
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
const styledFunction = function (tag) {
|
|
21
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
22
|
+
name: null,
|
|
23
|
+
slot: null
|
|
24
|
+
};
|
|
25
|
+
const {
|
|
26
|
+
name: componentName,
|
|
27
|
+
slot: componentSlot
|
|
28
|
+
} = options;
|
|
29
|
+
|
|
30
|
+
const func = function (styleArg) {
|
|
31
|
+
for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
32
|
+
expressions[_key - 1] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* These are the internal expression written in dimsum
|
|
37
|
+
* We just coerce with the default theme in case users
|
|
38
|
+
* forget to add the ThemeProvider
|
|
39
|
+
*/
|
|
40
|
+
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? props => stylesArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
41
|
+
theme: coerceWithDefaultTheme(props.theme)
|
|
42
|
+
})) : stylesArg) : [];
|
|
43
|
+
let transformedStyleArg = styleArg;
|
|
44
|
+
/*
|
|
45
|
+
* Here we get the style overrides from the user
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
if (componentName && componentSlot) {
|
|
49
|
+
expressionsWithDefaultTheme.push(props => {
|
|
50
|
+
const theme = coerceWithDefaultTheme(props.theme);
|
|
51
|
+
const styleOverrides = getStyleOverrides(componentName, theme);
|
|
52
|
+
|
|
53
|
+
if (styleOverrides) {
|
|
54
|
+
return [styleOverrides[componentSlot]];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/*
|
|
61
|
+
* Here we get the variant overrides from the user (only for the root)
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if (componentName && componentSlot === 'root') {
|
|
66
|
+
expressionsWithDefaultTheme.push(props => {
|
|
67
|
+
const theme = coerceWithDefaultTheme(props.theme);
|
|
68
|
+
return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
|
|
73
|
+
|
|
74
|
+
if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
|
|
75
|
+
// Here we are adding placeholders for all the new functions that we are gonna call
|
|
76
|
+
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
77
|
+
transformedStyleArg = Object.assign([...styleArg, ...placeholders], {
|
|
78
|
+
raw: [...styleArg.raw, ...placeholders]
|
|
79
|
+
});
|
|
80
|
+
} else if (typeof styleArg === 'function') {
|
|
81
|
+
// Here we just coerce with the default theme
|
|
82
|
+
transformedStyleArg = props => styleArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
83
|
+
theme: coerceWithDefaultTheme(props.theme)
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let Component = /*#__PURE__*/styled_component(tag);
|
|
88
|
+
const displayName = componentName !== null && componentSlot !== null ? "".concat(componentName).concat(componentSlot) : null;
|
|
89
|
+
|
|
90
|
+
if (displayName !== null) {
|
|
91
|
+
Component = Component.attrs({
|
|
92
|
+
className: "".concat(componentName).concat(componentSlot)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Component = Component(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
97
|
+
|
|
98
|
+
if (displayName !== null) {
|
|
99
|
+
Component.displayName = displayName;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return Component;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return func;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const styledObject = Object.keys(styled_component).reduce((obj, key) => {
|
|
109
|
+
const castedKey = key;
|
|
110
|
+
obj[castedKey] = styledFunction(castedKey);
|
|
111
|
+
return obj;
|
|
112
|
+
}, {});
|
|
113
|
+
const styled = Object.assign(styledFunction, styledObject);
|
|
114
|
+
|
|
115
|
+
export { styled };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.every.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.every.js';
|
|
6
|
+
import { propsToClassKey } from './utils.js';
|
|
7
|
+
|
|
8
|
+
const getStyleOverrides = (name, theme) => {
|
|
9
|
+
var _theme$components, _theme$components$nam;
|
|
10
|
+
|
|
11
|
+
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;
|
|
12
|
+
};
|
|
13
|
+
const getVariantStyles = (name, theme) => {
|
|
14
|
+
var _theme$components2, _theme$components2$na;
|
|
15
|
+
|
|
16
|
+
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) || [];
|
|
17
|
+
return variants.reduce((styles, definition) => {
|
|
18
|
+
const key = propsToClassKey(definition.props);
|
|
19
|
+
styles[key] = definition.style;
|
|
20
|
+
return styles;
|
|
21
|
+
}, {});
|
|
22
|
+
};
|
|
23
|
+
const variantsResolver = (props, styles, theme, name) => {
|
|
24
|
+
var _theme$components3, _theme$components3$na;
|
|
25
|
+
|
|
26
|
+
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) || [];
|
|
27
|
+
return themeVariants.reduce((variantsStyles, themeVariant) => {
|
|
28
|
+
const isMatch = Object.keys(themeVariant.props).every(key => props[key] === themeVariant.props[key]);
|
|
29
|
+
|
|
30
|
+
if (isMatch) {
|
|
31
|
+
variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return variantsStyles;
|
|
35
|
+
}, []);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { getStyleOverrides, getVariantStyles, variantsResolver };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CSSObject } from 'styled-components';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
4
|
+
import { capitalize } from '@elliemae/ds-utilities';
|
|
5
|
+
import { theme } from '../theme.js';
|
|
6
|
+
|
|
7
|
+
const systemTheme = theme;
|
|
8
|
+
const isEmpty = string => string.length === 0;
|
|
9
|
+
const coerceWithDefaultTheme = themeInput => themeInput !== null && themeInput !== void 0 ? themeInput : systemTheme;
|
|
10
|
+
const propsToClassKey = props => Object.keys(props).sort().reduce((classKey, key) => {
|
|
11
|
+
if (key === 'color') {
|
|
12
|
+
return classKey + isEmpty(String(classKey)) ? String(props[key]) : capitalize(String(props[key]));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return "".concat(classKey).concat(isEmpty(String(classKey)) ? key : capitalize(key)).concat(capitalize(props[key].toString()));
|
|
16
|
+
}, '');
|
|
17
|
+
|
|
18
|
+
export { coerceWithDefaultTheme, isEmpty, propsToClassKey };
|
package/esm/th.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
+
|
|
5
|
+
const th = property => (value, dfault) => _ref => {
|
|
6
|
+
var _result;
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
theme
|
|
10
|
+
} = _ref;
|
|
11
|
+
const parts = value.split('-');
|
|
12
|
+
let result = theme[property];
|
|
13
|
+
parts.forEach(part => {
|
|
14
|
+
if (result) result = result[part];
|
|
15
|
+
});
|
|
16
|
+
return (_result = result) !== null && _result !== void 0 ? _result : dfault;
|
|
17
|
+
};
|
|
18
|
+
th.space = th('space');
|
|
19
|
+
th.fontSize = th('fontSizes');
|
|
20
|
+
th.fontWeight = th('fontWeights');
|
|
21
|
+
th.lineHeight = th('lineHeights');
|
|
22
|
+
th.letterSpacing = th('letterSpacings');
|
|
23
|
+
th.font = th('fonts');
|
|
24
|
+
th.color = th('colors');
|
|
25
|
+
th.breakpoint = th('breakpoints');
|
|
26
|
+
th.media = th('media');
|
|
27
|
+
|
|
28
|
+
export { th };
|
package/esm/themeProviderHOC.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _jsx2 from '@babel/runtime/helpers/esm/jsx';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
8
|
import 'react';
|
package/esm/utils.js
CHANGED
|
@@ -20,20 +20,27 @@ function keyframes(obj) {
|
|
|
20
20
|
return keyframes$1(["", ""], reduce(obj, (result, value, key) => "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n "), ''));
|
|
21
21
|
} // eslint-disable-next-line max-params
|
|
22
22
|
|
|
23
|
-
function boxShadow(top, left, blur, color
|
|
23
|
+
function boxShadow(top, left, blur, color) {
|
|
24
|
+
let inset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
24
25
|
return "box-shadow: ".concat(inset ? 'inset' : '', " ").concat(top, " ").concat(left, " ").concat(blur, " ").concat(color, ";");
|
|
25
26
|
}
|
|
26
|
-
function color(
|
|
27
|
+
function color() {
|
|
28
|
+
let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
|
|
29
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
27
30
|
return css(["color:", ";"], props => props.theme.colors[variant][type]);
|
|
28
31
|
}
|
|
29
|
-
function border(
|
|
32
|
+
function border() {
|
|
33
|
+
let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.colors.brand[600];
|
|
34
|
+
let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1px';
|
|
35
|
+
let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'solid';
|
|
30
36
|
return "".concat(size, " ").concat(type, " ").concat(color);
|
|
31
37
|
}
|
|
32
38
|
function animation(animationKeyframes, animationLength, animationTimingFn) {
|
|
33
39
|
return props => css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
|
|
34
40
|
} // 0.0769
|
|
35
41
|
|
|
36
|
-
function focus(
|
|
42
|
+
function focus() {
|
|
43
|
+
let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.colors.brand[600];
|
|
37
44
|
return () => css(["outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], color, lighten(0.3, color));
|
|
38
45
|
}
|
|
39
46
|
function focusAfter(color) {
|
|
@@ -45,7 +52,8 @@ function active() {
|
|
|
45
52
|
function hover() {
|
|
46
53
|
return props => css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
|
|
47
54
|
}
|
|
48
|
-
function textStyle(type
|
|
55
|
+
function textStyle(type) {
|
|
56
|
+
let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
|
|
49
57
|
// eslint-disable-next-line complexity
|
|
50
58
|
return props => {
|
|
51
59
|
let cssVar = "font-weight: ".concat(props.theme.fontWeights[weight], ";"); // eslint-disable-next-line default-case
|
|
@@ -99,7 +107,9 @@ function textStyle(type, weight = 'regular') {
|
|
|
99
107
|
return cssVar;
|
|
100
108
|
};
|
|
101
109
|
}
|
|
102
|
-
function iconColor(
|
|
110
|
+
function iconColor() {
|
|
111
|
+
let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
|
|
112
|
+
let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
|
|
103
113
|
return css(["fill:", ";"], props => props.theme.colors[variant][type]);
|
|
104
114
|
}
|
|
105
115
|
function fakeBorder() {
|
|
@@ -114,7 +124,8 @@ function clearFocus() {
|
|
|
114
124
|
function buttonLink() {
|
|
115
125
|
return "\n background-color: transparent;\n border: 1px solid transparent;\n cursor: pointer;\n ";
|
|
116
126
|
}
|
|
117
|
-
function transition(
|
|
127
|
+
function transition() {
|
|
128
|
+
let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all 1s ease';
|
|
118
129
|
return "\n transition: ".concat(t, ";\n ");
|
|
119
130
|
}
|
|
120
131
|
function onlySafariAndFiredox(styles) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-system",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - System",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -23,6 +23,26 @@
|
|
|
23
23
|
"import": "./esm/theme.js",
|
|
24
24
|
"require": "./cjs/theme.js"
|
|
25
25
|
},
|
|
26
|
+
"./th": {
|
|
27
|
+
"import": "./esm/th.js",
|
|
28
|
+
"require": "./cjs/th.js"
|
|
29
|
+
},
|
|
30
|
+
"./styled/utils": {
|
|
31
|
+
"import": "./esm/styled/utils.js",
|
|
32
|
+
"require": "./cjs/styled/utils.js"
|
|
33
|
+
},
|
|
34
|
+
"./styled/types": {
|
|
35
|
+
"import": "./esm/styled/types.js",
|
|
36
|
+
"require": "./cjs/styled/types.js"
|
|
37
|
+
},
|
|
38
|
+
"./styled/styleGetters": {
|
|
39
|
+
"import": "./esm/styled/styleGetters.js",
|
|
40
|
+
"require": "./cjs/styled/styleGetters.js"
|
|
41
|
+
},
|
|
42
|
+
"./styled": {
|
|
43
|
+
"import": "./esm/styled/index.js",
|
|
44
|
+
"require": "./cjs/styled/index.js"
|
|
45
|
+
},
|
|
26
46
|
"./spaceUtilities": {
|
|
27
47
|
"import": "./esm/spaceUtilities.js",
|
|
28
48
|
"require": "./cjs/spaceUtilities.js"
|
|
@@ -72,16 +92,15 @@
|
|
|
72
92
|
"polished": "~3.6.7"
|
|
73
93
|
},
|
|
74
94
|
"devDependencies": {
|
|
75
|
-
"@elliemae/pui-theme": "~2.2.
|
|
76
|
-
"
|
|
77
|
-
"styled-
|
|
95
|
+
"@elliemae/pui-theme": "~2.2.5",
|
|
96
|
+
"@testing-library/jest-dom": "~5.15.0",
|
|
97
|
+
"styled-components": "~5.3.3"
|
|
78
98
|
},
|
|
79
99
|
"peerDependencies": {
|
|
80
|
-
"@elliemae/pui-theme": "^2.2.
|
|
100
|
+
"@elliemae/pui-theme": "^2.2.5",
|
|
81
101
|
"lodash": "^4.17.21",
|
|
82
102
|
"react": "~17.0.2",
|
|
83
103
|
"react-dom": "^17.0.2",
|
|
84
|
-
"styled-components": "^5.3.
|
|
85
|
-
"styled-system": "^5.1.5"
|
|
104
|
+
"styled-components": "^5.3.3"
|
|
86
105
|
}
|
|
87
106
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Theme, CSSObject } from './types';
|
|
2
|
+
export declare const getStyleOverrides: (name: string, theme: Theme) => CSSObject | null;
|
|
3
|
+
export declare const getVariantStyles: (name: string, theme: Theme) => Record<string, CSSObject>;
|
|
4
|
+
export declare const variantsResolver: (props: Record<string, unknown>, styles: CSSObject, theme: Theme, name: string) => CSSObject[keyof CSSObject][];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme as PuiTheme } from '@elliemae/pui-theme';
|
|
3
|
+
import { AnyStyledComponent, CSSObject, Interpolation, InterpolationFunction, StyledComponent, StyledComponentInnerAttrs, StyledComponentInnerComponent, StyledComponentInnerOtherProps, StyledComponentPropsWithRef, ThemedStyledProps } from 'styled-components';
|
|
4
|
+
export { CSSObject } from 'styled-components';
|
|
5
|
+
export interface Theme extends PuiTheme {
|
|
6
|
+
components?: {
|
|
7
|
+
[componentName: string]: {
|
|
8
|
+
styleOverrides?: CSSObject;
|
|
9
|
+
variants?: {
|
|
10
|
+
props: Record<string, {
|
|
11
|
+
toString: () => string;
|
|
12
|
+
}>;
|
|
13
|
+
style: CSSObject;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare type ThemedStyledFunctionBase<C extends keyof JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> = <U extends object = {}>(first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>, ...rest: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>) => StyledComponent<C, T, O & U, A>;
|
|
19
|
+
declare type ThemedStyledComponentFactories<T extends object> = {
|
|
20
|
+
[TTag in keyof JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;
|
|
21
|
+
};
|
|
22
|
+
export declare type StyledFunction = <C extends AnyStyledComponent | keyof JSX.IntrinsicElements | React.ComponentType<any>>(tag: C, options?: {
|
|
23
|
+
name: string | null;
|
|
24
|
+
slot: string | null;
|
|
25
|
+
}) => ThemedStyledFunctionBase<C extends AnyStyledComponent ? StyledComponentInnerComponent<C> : C, Theme, C extends AnyStyledComponent ? StyledComponentInnerOtherProps<C> : {}, C extends AnyStyledComponent ? StyledComponentInnerAttrs<C> : never>;
|
|
26
|
+
export interface StyledObject extends ThemedStyledComponentFactories<Theme> {
|
|
27
|
+
}
|
|
28
|
+
export declare type Styled = StyledFunction & StyledObject;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Theme } from './types';
|
|
2
|
+
export declare const isEmpty: (string: string) => boolean;
|
|
3
|
+
export declare const coerceWithDefaultTheme: (themeInput: Theme) => Theme;
|
|
4
|
+
export declare const propsToClassKey: (props: Record<string, {
|
|
5
|
+
toString: () => string;
|
|
6
|
+
}>) => string;
|
package/types/th.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare type thGetter = (value: string, dfault: string) => (theme: any) => string;
|
|
2
|
+
declare type thConstructor = ((property: string) => thGetter) & {
|
|
3
|
+
space: thGetter;
|
|
4
|
+
fontSize: thGetter;
|
|
5
|
+
fontWeight: thGetter;
|
|
6
|
+
lineHeight: thGetter;
|
|
7
|
+
letterSpacing: thGetter;
|
|
8
|
+
font: thGetter;
|
|
9
|
+
color: thGetter;
|
|
10
|
+
breakpoint: thGetter;
|
|
11
|
+
media: thGetter;
|
|
12
|
+
};
|
|
13
|
+
export declare const th: thConstructor;
|
|
14
|
+
export {};
|
package/types/utils.d.ts
CHANGED
|
@@ -7,17 +7,17 @@ export declare function flexCenter(): string;
|
|
|
7
7
|
export declare function disabled(): string;
|
|
8
8
|
export declare function keyframes(obj: Record<string, unknown>): Keyframes;
|
|
9
9
|
export declare function boxShadow(top: string, left: string, blur: string, color: string, inset?: boolean): string;
|
|
10
|
-
export declare function color(variant?: string, type?: number): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<
|
|
10
|
+
export declare function color(variant?: string, type?: number): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
11
11
|
export declare function border(color?: string, size?: string, type?: string): string;
|
|
12
12
|
export declare function animation(animationKeyframes: string, animationLength: string, animationTimingFn: string): (props: any) => import("styled-components").FlattenSimpleInterpolation;
|
|
13
13
|
export declare function focus(color?: string): () => import("styled-components").FlattenSimpleInterpolation;
|
|
14
|
-
export declare function focusAfter(color: string): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<
|
|
14
|
+
export declare function focusAfter(color: string): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
15
15
|
export declare function active(): (props: any) => import("styled-components").FlattenSimpleInterpolation;
|
|
16
16
|
export declare function hover(): (props: any) => import("styled-components").FlattenSimpleInterpolation;
|
|
17
17
|
export declare function textStyle(type: string, weight?: string): (props: any) => string;
|
|
18
|
-
export declare function iconColor(variant?: string, type?: number): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<
|
|
19
|
-
export declare function fakeBorder(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<
|
|
20
|
-
export declare function fakeActive(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<
|
|
18
|
+
export declare function iconColor(variant?: string, type?: number): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
19
|
+
export declare function fakeBorder(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
20
|
+
export declare function fakeActive(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
21
21
|
export declare function clearFocus(): string;
|
|
22
22
|
export declare function buttonLink(): string;
|
|
23
23
|
export declare function transition(t?: string): string;
|