@elliemae/ds-system 2.0.0-alpha.10 → 2.0.0-alpha.14

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/utils.js CHANGED
@@ -6,187 +6,134 @@ 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: ${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
- return `
17
- display: flex;
18
- justify-content: center;
19
- align-items: center;
20
- `;
16
+ return "\n display: flex;\n justify-content: center;\n align-items: center;\n ";
21
17
  }
22
18
  function disabled() {
23
- return `
24
- cursor: not-allowed;
25
- pointer-events: none;
26
- `;
19
+ return "\n cursor: not-allowed;\n pointer-events: none;\n ";
27
20
  }
28
21
  function keyframes(obj) {
29
- return styledComponents.keyframes(["", ""], lodash.reduce(obj, (result, value, key) => `
30
- ${result}
31
- ${key}% {
32
- ${value}
33
- }
34
- `, ''));
22
+ return styled_component.keyframes(["", ""], lodash.reduce(obj, (result, value, key) => "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n "), ''));
35
23
  } // eslint-disable-next-line max-params
36
24
 
37
- function boxShadow(top, left, blur, color, inset = false) {
38
- return `box-shadow: ${inset ? 'inset' : ''} ${top} ${left} ${blur} ${color};`;
25
+ function boxShadow(top, left, blur, color) {
26
+ let inset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
27
+ return "box-shadow: ".concat(inset ? 'inset' : '', " ").concat(top, " ").concat(left, " ").concat(blur, " ").concat(color, ";");
39
28
  }
40
- function color(variant = 'neutral', type = 400) {
41
- return styledComponents.css(["color:", ";"], props => props.theme.colors[variant][type]);
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]);
42
33
  }
43
- function border(color = theme.theme.colors.brand[600], size = '1px', type = 'solid') {
44
- return `${size} ${type} ${color}`;
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';
38
+ return "".concat(size, " ").concat(type, " ").concat(color);
45
39
  }
46
40
  function animation(animationKeyframes, animationLength, animationTimingFn) {
47
- 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);
48
42
  } // 0.0769
49
43
 
50
- function focus(color = theme.theme.colors.brand[600]) {
51
- return () => styledComponents.css(["outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], color, polished.lighten(0.3, color));
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));
52
47
  }
53
48
  function focusAfter(color) {
54
- 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));
55
50
  }
56
51
  function active() {
57
- 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]);
58
53
  }
59
54
  function hover() {
60
- 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]);
61
56
  }
62
- function textStyle(type, weight = 'regular') {
57
+ function textStyle(type) {
58
+ let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
63
59
  // eslint-disable-next-line complexity
64
60
  return props => {
65
- let cssVar = `font-weight: ${props.theme.fontWeights[weight]};`; // eslint-disable-next-line default-case
61
+ let cssVar = "font-weight: ".concat(props.theme.fontWeights[weight], ";"); // eslint-disable-next-line default-case
66
62
 
67
63
  switch (type) {
68
64
  case 'h1':
69
- cssVar += `
70
- font-size: ${mobileUtilities.toMobile('2.7692rem')};
71
- line-height: normal;
72
- `;
65
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile('2.7692rem'), ";\n line-height: normal;\n ");
73
66
  break;
74
67
 
75
68
  case 'h2':
76
- cssVar += `
77
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.title[800])};
78
- line-height: normal;
79
- `;
69
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.title[800]), ";\n line-height: normal;\n ");
80
70
  break;
81
71
 
82
72
  case 'h3':
83
- cssVar += `
84
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.title[700])};
85
- line-height: 1.2;
86
- `;
73
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.title[700]), ";\n line-height: 1.2;\n ");
87
74
  break;
88
75
 
89
76
  case 'h4':
90
- cssVar += `
91
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.title[600])};
92
- line-height: normal;
93
- `;
77
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.title[600]), ";\n line-height: normal;\n ");
94
78
  break;
95
79
 
96
80
  case 'h5':
97
- cssVar += `
98
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.title[500])};
99
- line-height: normal;
100
- `;
81
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.title[500]), ";\n line-height: normal;\n ");
101
82
  break;
102
83
 
103
84
  case 'section-header':
104
- cssVar += `
105
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.title[500])};
106
- line-height: normal;
107
- text-transform: uppercase;
108
- `;
85
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.title[500]), ";\n line-height: normal;\n text-transform: uppercase;\n ");
109
86
  break;
110
87
 
111
88
  case 'body':
112
- cssVar += `
113
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.value[400])};
114
- line-height: normal;
115
- `;
89
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.value[400]), ";\n line-height: normal;\n ");
116
90
  break;
117
91
 
118
92
  case 'body-small':
119
- cssVar += `
120
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.value[300])};
121
- line-height: normal;
122
- `;
93
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.value[300]), ";\n line-height: normal;\n ");
123
94
  break;
124
95
 
125
96
  case 'body-micro':
126
- cssVar += `
127
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.microText[200])};
128
- line-height: normal;
129
- `;
97
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.microText[200]), ";\n line-height: normal;\n ");
130
98
  break;
131
99
 
132
100
  case 'list':
133
- cssVar += `
134
- font-size: ${mobileUtilities.toMobile(props.theme.fontSizes.value[400])};
135
- line-height: normal;
136
- `;
101
+ cssVar += "\n font-size: ".concat(mobileUtilities.toMobile(props.theme.fontSizes.value[400]), ";\n line-height: normal;\n ");
137
102
  break;
138
103
 
139
104
  case 'link':
140
- cssVar += `
141
- line-height: ${props.theme.xl};
142
- color: ${props.theme.colors.brand[600]};
143
- cursor: pointer;
144
- `;
105
+ cssVar += "\n line-height: ".concat(props.theme.xl, ";\n color: ").concat(props.theme.colors.brand[600], ";\n cursor: pointer;\n ");
145
106
  break;
146
107
  }
147
108
 
148
109
  return cssVar;
149
110
  };
150
111
  }
151
- function iconColor(variant = 'neutral', type = 400) {
152
- return styledComponents.css(["fill:", ";"], props => props.theme.colors[variant][type]);
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]);
153
116
  }
154
117
  function fakeBorder() {
155
- 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]);
156
119
  }
157
120
  function fakeActive() {
158
- 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]);
159
122
  }
160
123
  function clearFocus() {
161
- return `
162
- border: none;
163
- box-shadow: none;
164
- `;
124
+ return "\n border: none;\n box-shadow: none;\n ";
165
125
  }
166
126
  function buttonLink() {
167
- return `
168
- background-color: transparent;
169
- border: 1px solid transparent;
170
- cursor: pointer;
171
- `;
172
- }
173
- function transition(t = 'all 1s ease') {
174
- return `
175
- transition: ${t};
176
- `;
177
- }
178
- function onlySafariAndFiredox(styles) {
179
- return styledComponents.css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
180
- }
181
- function onlySafari(styles) {
182
- return styledComponents.css(["@media not all and (min-resolution:0.001dpcm){", "}"], styles);
183
- }
184
- function onlyFirefox(styles) {
185
- return styledComponents.css(["@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles);
127
+ return "\n background-color: transparent;\n border: 1px solid transparent;\n cursor: pointer;\n ";
186
128
  }
187
- function safariAndFirefoxBold(color) {
188
- 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);
129
+ function transition() {
130
+ let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all 1s ease';
131
+ return "\n transition: ".concat(t, ";\n ");
189
132
  }
133
+ const onlySafariAndFirefox = styles => styled_component.css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
134
+ const onlySafari = styles => "\n @media not all and (min-resolution: 0.001dpcm) {\n ".concat(styles, "\n }\n ");
135
+ const onlyFirefox = styles => "\n @media screen and (min--moz-device-pixel-ratio: 0) {\n ".concat(styles, "\n }\n ");
136
+ const safariAndFirefoxBold = color => "\n @media not all and (min-resolution: 0.001dpcm) {\n font-weight: 400;\n -webkit-font-smoothing: subpixel-antialiased;\n -webkit-text-stroke: 0.4px ".concat(color, ";\n }\n @media screen and (min--moz-device-pixel-ratio: 0) {\n font-weight: 400;\n -webkit-font-smoothing: subpixel-antialiased;\n -webkit-text-stroke: 0.4px ").concat(color, ";\n }\n");
190
137
 
191
138
  Object.defineProperty(exports, 'rgba', {
192
139
  enumerable: true,
@@ -194,23 +141,23 @@ Object.defineProperty(exports, 'rgba', {
194
141
  });
195
142
  Object.defineProperty(exports, 'createGlobalStyle', {
196
143
  enumerable: true,
197
- get: function () { return styledComponents.createGlobalStyle; }
144
+ get: function () { return styled_component.createGlobalStyle; }
198
145
  });
199
146
  Object.defineProperty(exports, 'css', {
200
147
  enumerable: true,
201
- get: function () { return styledComponents.css; }
148
+ get: function () { return styled_component.css; }
202
149
  });
203
150
  Object.defineProperty(exports, 'kfrm', {
204
151
  enumerable: true,
205
- get: function () { return styledComponents.keyframes; }
152
+ get: function () { return styled_component.keyframes; }
206
153
  });
207
154
  Object.defineProperty(exports, 'useTheme', {
208
155
  enumerable: true,
209
- get: function () { return styledComponents.useTheme; }
156
+ get: function () { return styled_component.useTheme; }
210
157
  });
211
158
  Object.defineProperty(exports, 'withTheme', {
212
159
  enumerable: true,
213
- get: function () { return styledComponents.withTheme; }
160
+ get: function () { return styled_component.withTheme; }
214
161
  });
215
162
  exports.active = active;
216
163
  exports.animation = animation;
@@ -230,7 +177,7 @@ exports.iconColor = iconColor;
230
177
  exports.keyframes = keyframes;
231
178
  exports.onlyFirefox = onlyFirefox;
232
179
  exports.onlySafari = onlySafari;
233
- exports.onlySafariAndFiredox = onlySafariAndFiredox;
180
+ exports.onlySafariAndFirefox = onlySafariAndFirefox;
234
181
  exports.safariAndFirefoxBold = safariAndFirefoxBold;
235
182
  exports.textStyle = textStyle;
236
183
  exports.transition = transition;
package/esm/arithmetic.js CHANGED
@@ -1,3 +1,5 @@
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+
1
3
  function getNumberAndUnit(numberStrWithUnit) {
2
4
  const [number, unit] = String(numberStrWithUnit).match(/[a-z]+|[(/^\-?\d*.\d+|\d+),?]+/gi);
3
5
  return {
@@ -1,19 +1,17 @@
1
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
1
2
  import 'polished';
2
3
  import 'lodash';
3
4
  import './theme.js';
5
+ import 'core-js/modules/web.dom-collections.iterator.js';
4
6
  import 'react';
5
7
  import { createGlobalStyle } from 'styled-components';
6
8
 
7
- const GlobalStyles = createGlobalStyle`
8
- :root, body {
9
- overscroll-behavior-y: none;
10
- font-size: 16px;
11
- @media (min-width: ${({
12
- theme
13
- }) => theme.breakpoints.small}) {
14
- font-size: 13px;
15
- }
16
- }
17
- `;
9
+ var _templateObject;
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');
18
16
 
19
17
  export { GlobalStyles };
package/esm/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  export { GlobalStyles } from './globalStyles.js';
2
2
  export { fixSpace, fixSpaceGutter, mapGap, mapGrid, mapGutter, mapSpace, mapTemplateGrid, numbersToFr } from './spaceUtilities.js';
3
3
  export { __UNSAFE_SPACE_TO_DIMSUM, isMobile, toMobile, useIsMobile } from './mobileUtilities.js';
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';
4
+ export { active, animation, border, boxShadow, buttonLink, clearFocus, color, disabled, fakeActive, fakeBorder, flexCenter, focus, focusAfter, hover, iconColor, keyframes, onlyFirefox, onlySafari, onlySafariAndFirefox, 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';
@@ -1,14 +1,15 @@
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
1
2
  import { useState, useEffect } from 'react';
2
3
  import { theme } from './theme.js';
3
4
  import { translateUnits, mobileBaseFont, desktopBaseFont } from './constants.js';
4
5
 
5
6
  function __UNSAFE_SPACE_TO_DIMSUM(unit) {
6
7
  if (translateUnits[unit]) return translateUnits[unit];
7
- return `${parseFloat(unit) * (mobileBaseFont / desktopBaseFont) / 2}px`;
8
+ return "".concat(parseFloat(unit) * (mobileBaseFont / desktopBaseFont) / 2, "px");
8
9
  }
9
10
  function toMobile(unit) {
10
11
  if (!isMobile()) return unit;
11
- return `${parseFloat(unit) * (desktopBaseFont / mobileBaseFont)}rem`;
12
+ return "".concat(parseFloat(unit) * (desktopBaseFont / mobileBaseFont), "rem");
12
13
  }
13
14
  const useIsMobile = () => {
14
15
  const [mobile, setMobile] = useState(isMobile());
@@ -1,23 +1,28 @@
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
 
4
9
  function mapGap(gutter) {
5
10
  if (!gutter) return '0rem';
6
11
  if (String(gutter).includes('rem') || String(gutter).includes('px')) return gutter;
7
- return `${theme.space[gutter]}`;
12
+ return "".concat(theme.space[gutter]);
8
13
  }
9
14
  function mapGutter(gutter) {
10
15
  if (!gutter) return '0rem';
11
- return `${theme.space[gutter]} * 2`;
16
+ return "".concat(theme.space[gutter], " * 2");
12
17
  }
13
18
  function mapSpace(width) {
14
- if (typeof width === 'string') return get(theme, width) ? `${get(theme, width)}` : width;
15
- return `${width * 100}%`;
19
+ if (typeof width === 'string') return get(theme, width) ? "".concat(get(theme, width)) : width;
20
+ return "".concat(width * 100, "%");
16
21
  }
17
22
  function fixSpaceGutter(width, gutter) {
18
23
  if (!width) return '';
19
- if (Array.isArray(width)) return width.map(w => `calc(${mapSpace(w)} - (${mapGutter(gutter)}))`);
20
- return `calc(${mapSpace(width)} - (${mapGutter(gutter)}))`;
24
+ if (Array.isArray(width)) return width.map(w => "calc(".concat(mapSpace(w), " - (").concat(mapGutter(gutter), "))"));
25
+ return "calc(".concat(mapSpace(width), " - (").concat(mapGutter(gutter), "))");
21
26
  }
22
27
  function fixSpace(width) {
23
28
  if (!width) return '';
@@ -32,13 +37,13 @@ function fixSpace(width) {
32
37
 
33
38
  function numbersToFr(grid) {
34
39
  const den = grid.map(f => f < 1 ? Math.floor(1 / f) : f);
35
- return den.map(d => `${d}fr`);
40
+ return den.map(d => "".concat(d, "fr"));
36
41
  }
37
42
  function mapGrid(width) {
38
- if (get(theme, width)) return `${get(theme, width)}`;
43
+ if (get(theme, width)) return "".concat(get(theme, width));
39
44
  if (typeof width === 'string') return width;
40
45
  const den = width < 1 ? Math.floor(1 / width) : width;
41
- return `${den}fr`;
46
+ return "".concat(den, "fr");
42
47
  }
43
48
  function mapTemplateGrid(grid) {
44
49
  if (Array.isArray(grid)) {
@@ -0,0 +1 @@
1
+
@@ -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 };
@@ -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';