@elliemae/ds-system 2.0.0-rc.1 → 2.0.0-rc.10

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.
@@ -8,18 +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 styledComponents = require('styled-components');
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 = styledComponents.createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n :root, body {\n overscroll-behavior-y: none;\n font-size: 16px;\n @media (min-width: ", ") { \n font-size: 13px;\n }\n }\n"])), _ref => {
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
19
  let {
20
20
  theme
21
21
  } = _ref;
22
22
  return theme.breakpoints.small;
23
- });
23
+ }, props => props.device === 'mobile' ? '16px' : '13px');
24
24
 
25
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 styledComponents = require('styled-components');
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 styledComponents.createGlobalStyle; }
63
+ get: function () { return styled_component.createGlobalStyle; }
60
64
  });
61
65
  Object.defineProperty(exports, 'css', {
62
66
  enumerable: true,
63
- get: function () { return styledComponents.css; }
67
+ get: function () { return styled_component.css; }
64
68
  });
65
69
  Object.defineProperty(exports, 'kfrm', {
66
70
  enumerable: true,
67
- get: function () { return styledComponents.keyframes; }
71
+ get: function () { return styled_component.keyframes; }
68
72
  });
69
73
  Object.defineProperty(exports, 'useTheme', {
70
74
  enumerable: true,
71
- get: function () { return styledComponents.useTheme; }
75
+ get: function () { return styled_component.useTheme; }
72
76
  });
73
77
  Object.defineProperty(exports, 'withTheme', {
74
78
  enumerable: true,
75
- get: function () { return styledComponents.withTheme; }
79
+ get: function () { return styled_component.withTheme; }
76
80
  });
77
81
  Object.defineProperty(exports, 'rgba', {
78
82
  enumerable: true,
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,123 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
+ require('core-js/modules/esnext.async-iterator.map.js');
8
+ require('core-js/modules/esnext.iterator.map.js');
9
+ require('core-js/modules/web.dom-collections.iterator.js');
10
+ require('core-js/modules/esnext.async-iterator.for-each.js');
11
+ require('core-js/modules/esnext.iterator.constructor.js');
12
+ require('core-js/modules/esnext.iterator.for-each.js');
13
+ require('core-js/modules/esnext.async-iterator.filter.js');
14
+ require('core-js/modules/esnext.iterator.filter.js');
15
+ var styled_component = require('styled-components');
16
+ var styleGetters = require('./styleGetters.js');
17
+ var utils = require('./utils.js');
18
+
19
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
+
21
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
22
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
23
+ var styled_component__default = /*#__PURE__*/_interopDefaultLegacy(styled_component);
24
+
25
+ const _excluded = ["theme"],
26
+ _excluded2 = ["theme"];
27
+
28
+ 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; }
29
+
30
+ 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; }
31
+ const styled = function (tag) {
32
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
33
+ name: null,
34
+ slot: null
35
+ };
36
+ const {
37
+ name: componentName,
38
+ slot: componentSlot
39
+ } = options;
40
+ return function (styleArg) {
41
+ for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
42
+ expressions[_key - 1] = arguments[_key];
43
+ }
44
+
45
+ /*
46
+ * These are the internal expression written in dimsum
47
+ * We just coerce with the default theme in case users
48
+ * forget to add the ThemeProvider
49
+ */
50
+ const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? _ref => {
51
+ let {
52
+ theme: themeInput
53
+ } = _ref,
54
+ other = _objectWithoutProperties__default["default"](_ref, _excluded);
55
+
56
+ return stylesArg(_objectSpread({
57
+ theme: utils.coerceWithDefaultTheme(themeInput)
58
+ }, other));
59
+ } : stylesArg) : [];
60
+ let transformedStyleArg = styleArg;
61
+ /*
62
+ * Here we get the style overrides from the user
63
+ */
64
+
65
+ if (componentName && componentSlot) {
66
+ expressionsWithDefaultTheme.push(props => {
67
+ const theme = utils.coerceWithDefaultTheme(props.theme);
68
+ const styleOverrides = styleGetters.getStyleOverrides(componentName, theme);
69
+
70
+ if (styleOverrides) {
71
+ return [styleOverrides[componentSlot]];
72
+ }
73
+
74
+ return null;
75
+ });
76
+ }
77
+ /*
78
+ * Here we get the variant overrides from the user (only for the root)
79
+ */
80
+
81
+
82
+ if (componentName && componentSlot === 'root') {
83
+ expressionsWithDefaultTheme.push(props => {
84
+ const theme = utils.coerceWithDefaultTheme(props.theme);
85
+ return styleGetters.variantsResolver(props, styleGetters.getVariantStyles(componentName, theme), theme, componentName);
86
+ });
87
+ }
88
+
89
+ const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
90
+
91
+ if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
92
+ // Here we are adding placeholders for all the new functions that we are gonna call
93
+ const placeholders = new Array(numOfCustomFnsApplied).fill('');
94
+ transformedStyleArg = [...styleArg, ...placeholders];
95
+ transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
96
+ } else if (typeof styleArg === 'function') {
97
+ // Here we just coerce with the default theme
98
+ transformedStyleArg = _ref2 => {
99
+ let {
100
+ theme: themeInput
101
+ } = _ref2,
102
+ other = _objectWithoutProperties__default["default"](_ref2, _excluded2);
103
+
104
+ return styleArg(_objectSpread({
105
+ theme: utils.coerceWithDefaultTheme(themeInput)
106
+ }, other));
107
+ };
108
+ }
109
+
110
+ const Component = /*#__PURE__*/styled_component__default["default"](tag).attrs({
111
+ className: "".concat(componentName, "-").concat(componentSlot)
112
+ }).withConfig({
113
+ componentId: "sc-rjg4in-0"
114
+ })(transformedStyleArg, ...expressionsWithDefaultTheme);
115
+ return Component;
116
+ };
117
+ }; // Here we setup the necessary keys so we can continue using styled.button, styled.span, etc.
118
+
119
+ Object.keys(styled_component__default["default"]).forEach(key => {
120
+ styled[key] = styled(key);
121
+ });
122
+
123
+ 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,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;
@@ -10,7 +10,7 @@ require('core-js/modules/esnext.iterator.for-each.js');
10
10
  var _jsx2 = require('@babel/runtime/helpers/jsx');
11
11
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
12
12
  require('react');
13
- var styledComponents = require('styled-components');
13
+ var styled_component = require('styled-components');
14
14
  var theme = require('./theme.js');
15
15
  var jsxRuntime = require('react/jsx-runtime');
16
16
 
@@ -22,7 +22,7 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
22
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; }
23
23
 
24
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; }
25
- const themeProviderHOC = Component => props => /*#__PURE__*/_jsx2__default["default"](styledComponents.ThemeProvider, {
25
+ const themeProviderHOC = Component => props => /*#__PURE__*/_jsx2__default["default"](styled_component.ThemeProvider, {
26
26
  theme: theme.theme
27
27
  }, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)));
28
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 styledComponents = require('styled-components');
9
+ var styled_component = require('styled-components');
10
10
 
11
11
  /* eslint-disable no-shadow */
12
12
  function truncate(width) {
13
- return props => styledComponents.css(["", " white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"], !!width || props.width ? "width: ".concat(props.width || width, ";") : '');
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,7 +19,7 @@ function disabled() {
19
19
  return "\n cursor: not-allowed;\n pointer-events: none;\n ";
20
20
  }
21
21
  function keyframes(obj) {
22
- return styledComponents.keyframes(["", ""], lodash.reduce(obj, (result, value, key) => "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n "), ''));
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
25
  function boxShadow(top, left, blur, color) {
@@ -29,7 +29,7 @@ function boxShadow(top, left, blur, color) {
29
29
  function color() {
30
30
  let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
31
31
  let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
32
- return styledComponents.css(["color:", ";"], props => props.theme.colors[variant][type]);
32
+ return styled_component.css(["color:", ";"], props => props.theme.colors[variant][type]);
33
33
  }
34
34
  function border() {
35
35
  let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
@@ -38,21 +38,21 @@ function border() {
38
38
  return "".concat(size, " ").concat(type, " ").concat(color);
39
39
  }
40
40
  function animation(animationKeyframes, animationLength, animationTimingFn) {
41
- return props => styledComponents.css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
41
+ return props => styled_component.css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
42
42
  } // 0.0769
43
43
 
44
44
  function focus() {
45
45
  let color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
46
- return () => styledComponents.css(["outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], color, polished.lighten(0.3, color));
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));
47
47
  }
48
48
  function focusAfter(color) {
49
- return styledComponents.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));
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));
50
50
  }
51
51
  function active() {
52
- return props => styledComponents.css(["outline:none;border:1px solid ", ";border-radius:2px;"], props.theme.colors.brand[700]);
52
+ return props => styled_component.css(["outline:none;border:1px solid ", ";border-radius:2px;"], props.theme.colors.brand[700]);
53
53
  }
54
54
  function hover() {
55
- return props => styledComponents.css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
55
+ return props => styled_component.css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
56
56
  }
57
57
  function textStyle(type) {
58
58
  let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
@@ -112,13 +112,13 @@ function textStyle(type) {
112
112
  function iconColor() {
113
113
  let variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
114
114
  let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
115
- return styledComponents.css(["fill:", ";"], props => props.theme.colors[variant][type]);
115
+ return styled_component.css(["fill:", ";"], props => props.theme.colors[variant][type]);
116
116
  }
117
117
  function fakeBorder() {
118
- return styledComponents.css(["box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.neutral[200]);
118
+ return styled_component.css(["box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.neutral[200]);
119
119
  }
120
120
  function fakeActive() {
121
- return styledComponents.css(["outline:none;box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.brand[700]);
121
+ return styled_component.css(["outline:none;box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.brand[700]);
122
122
  }
123
123
  function clearFocus() {
124
124
  return "\n border: none;\n box-shadow: none;\n ";
@@ -131,16 +131,16 @@ function transition() {
131
131
  return "\n transition: ".concat(t, ";\n ");
132
132
  }
133
133
  function onlySafariAndFiredox(styles) {
134
- return styledComponents.css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
134
+ return styled_component.css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
135
135
  }
136
136
  function onlySafari(styles) {
137
- return styledComponents.css(["@media not all and (min-resolution:0.001dpcm){", "}"], styles);
137
+ return styled_component.css(["@media not all and (min-resolution:0.001dpcm){", "}"], styles);
138
138
  }
139
139
  function onlyFirefox(styles) {
140
- return styledComponents.css(["@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles);
140
+ return styled_component.css(["@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles);
141
141
  }
142
142
  function safariAndFirefoxBold(color) {
143
- return styledComponents.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);
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);
144
144
  }
145
145
 
146
146
  Object.defineProperty(exports, 'rgba', {
@@ -149,23 +149,23 @@ Object.defineProperty(exports, 'rgba', {
149
149
  });
150
150
  Object.defineProperty(exports, 'createGlobalStyle', {
151
151
  enumerable: true,
152
- get: function () { return styledComponents.createGlobalStyle; }
152
+ get: function () { return styled_component.createGlobalStyle; }
153
153
  });
154
154
  Object.defineProperty(exports, 'css', {
155
155
  enumerable: true,
156
- get: function () { return styledComponents.css; }
156
+ get: function () { return styled_component.css; }
157
157
  });
158
158
  Object.defineProperty(exports, 'kfrm', {
159
159
  enumerable: true,
160
- get: function () { return styledComponents.keyframes; }
160
+ get: function () { return styled_component.keyframes; }
161
161
  });
162
162
  Object.defineProperty(exports, 'useTheme', {
163
163
  enumerable: true,
164
- get: function () { return styledComponents.useTheme; }
164
+ get: function () { return styled_component.useTheme; }
165
165
  });
166
166
  Object.defineProperty(exports, 'withTheme', {
167
167
  enumerable: true,
168
- get: function () { return styledComponents.withTheme; }
168
+ get: function () { return styled_component.withTheme; }
169
169
  });
170
170
  exports.active = active;
171
171
  exports.animation = animation;
@@ -7,11 +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: 16px;\n @media (min-width: ", ") { \n font-size: 13px;\n }\n }\n"])), _ref => {
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
11
  let {
12
12
  theme
13
13
  } = _ref;
14
14
  return theme.breakpoints.small;
15
- });
15
+ }, props => props.device === 'mobile' ? '16px' : '13px');
16
16
 
17
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';
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,113 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
3
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
+ import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
5
+ import 'core-js/modules/esnext.async-iterator.map.js';
6
+ import 'core-js/modules/esnext.iterator.map.js';
7
+ import 'core-js/modules/web.dom-collections.iterator.js';
8
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
9
+ import 'core-js/modules/esnext.iterator.constructor.js';
10
+ import 'core-js/modules/esnext.iterator.for-each.js';
11
+ import styled_component from 'styled-components';
12
+ import { getStyleOverrides, variantsResolver, getVariantStyles } from './styleGetters.js';
13
+ import { coerceWithDefaultTheme } from './utils.js';
14
+
15
+ const _excluded = ["theme"],
16
+ _excluded2 = ["theme"];
17
+
18
+ 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; }
19
+
20
+ 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; }
21
+ const styled = function (tag) {
22
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
23
+ name: null,
24
+ slot: null
25
+ };
26
+ const {
27
+ name: componentName,
28
+ slot: componentSlot
29
+ } = options;
30
+ return 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' ? _ref => {
41
+ let {
42
+ theme: themeInput
43
+ } = _ref,
44
+ other = _objectWithoutProperties(_ref, _excluded);
45
+
46
+ return stylesArg(_objectSpread({
47
+ theme: coerceWithDefaultTheme(themeInput)
48
+ }, other));
49
+ } : stylesArg) : [];
50
+ let transformedStyleArg = styleArg;
51
+ /*
52
+ * Here we get the style overrides from the user
53
+ */
54
+
55
+ if (componentName && componentSlot) {
56
+ expressionsWithDefaultTheme.push(props => {
57
+ const theme = coerceWithDefaultTheme(props.theme);
58
+ const styleOverrides = getStyleOverrides(componentName, theme);
59
+
60
+ if (styleOverrides) {
61
+ return [styleOverrides[componentSlot]];
62
+ }
63
+
64
+ return null;
65
+ });
66
+ }
67
+ /*
68
+ * Here we get the variant overrides from the user (only for the root)
69
+ */
70
+
71
+
72
+ if (componentName && componentSlot === 'root') {
73
+ expressionsWithDefaultTheme.push(props => {
74
+ const theme = coerceWithDefaultTheme(props.theme);
75
+ return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);
76
+ });
77
+ }
78
+
79
+ const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
80
+
81
+ if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
82
+ // Here we are adding placeholders for all the new functions that we are gonna call
83
+ const placeholders = new Array(numOfCustomFnsApplied).fill('');
84
+ transformedStyleArg = [...styleArg, ...placeholders];
85
+ transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
86
+ } else if (typeof styleArg === 'function') {
87
+ // Here we just coerce with the default theme
88
+ transformedStyleArg = _ref2 => {
89
+ let {
90
+ theme: themeInput
91
+ } = _ref2,
92
+ other = _objectWithoutProperties(_ref2, _excluded2);
93
+
94
+ return styleArg(_objectSpread({
95
+ theme: coerceWithDefaultTheme(themeInput)
96
+ }, other));
97
+ };
98
+ }
99
+
100
+ const Component = /*#__PURE__*/styled_component(tag).attrs({
101
+ className: "".concat(componentName, "-").concat(componentSlot)
102
+ }).withConfig({
103
+ componentId: "sc-rjg4in-0"
104
+ })(transformedStyleArg, ...expressionsWithDefaultTheme);
105
+ return Component;
106
+ };
107
+ }; // Here we setup the necessary keys so we can continue using styled.button, styled.span, etc.
108
+
109
+ Object.keys(styled_component).forEach(key => {
110
+ styled[key] = styled(key);
111
+ });
112
+
113
+ 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,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-system",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.10",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - System",
6
6
  "module": "./esm/index.js",
@@ -23,6 +23,22 @@
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/styleGetters": {
35
+ "import": "./esm/styled/styleGetters.js",
36
+ "require": "./cjs/styled/styleGetters.js"
37
+ },
38
+ "./styled": {
39
+ "import": "./esm/styled/index.js",
40
+ "require": "./cjs/styled/index.js"
41
+ },
26
42
  "./spaceUtilities": {
27
43
  "import": "./esm/spaceUtilities.js",
28
44
  "require": "./cjs/spaceUtilities.js"
@@ -73,15 +89,14 @@
73
89
  },
74
90
  "devDependencies": {
75
91
  "@elliemae/pui-theme": "~2.2.5",
76
- "styled-components": "~5.3.3",
77
- "styled-system": "~5.1.5"
92
+ "@testing-library/jest-dom": "~5.15.0",
93
+ "styled-components": "~5.3.3"
78
94
  },
79
95
  "peerDependencies": {
80
96
  "@elliemae/pui-theme": "^2.2.5",
81
97
  "lodash": "^4.17.21",
82
98
  "react": "~17.0.2",
83
99
  "react-dom": "^17.0.2",
84
- "styled-components": "^5.3.3",
85
- "styled-system": "^5.1.5"
100
+ "styled-components": "^5.3.3"
86
101
  }
87
102
  }
package/types/index.d.ts CHANGED
@@ -3,5 +3,7 @@ export * from './spaceUtilities';
3
3
  export * from './mobileUtilities';
4
4
  export * from './utils';
5
5
  export * from './arithmetic';
6
+ export * from './th';
6
7
  export * from './theme';
8
+ export * from './styled';
7
9
  export { themeProviderHOC } from './themeProviderHOC';
@@ -0,0 +1,2 @@
1
+ import { Styled } from './index.d';
2
+ export declare const styled: Styled;
@@ -0,0 +1,4 @@
1
+ import type { StyleObject, Theme } from './index.d';
2
+ export declare const getStyleOverrides: (name: string, theme: Theme) => StyleObject;
3
+ export declare const getVariantStyles: (name: string, theme: Theme) => Record<string, string>;
4
+ export declare const variantsResolver: (props: Record<string, unknown>, styles: StyleObject, theme: Theme, name: string) => StyleObject[keyof StyleObject][];
@@ -0,0 +1,4 @@
1
+ import type { Theme } from '@elliemae/pui-theme';
2
+ export declare const isEmpty: (string: string) => boolean;
3
+ export declare const coerceWithDefaultTheme: (themeInput: Theme) => Theme;
4
+ export declare const propsToClassKey: (props: Record<string, unknown>) => 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<any>>;
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<any>>;
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<any>>;
19
- export declare function fakeBorder(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
20
- export declare function fakeActive(): import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
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;