@elliemae/ds-system 1.60.0 → 2.0.0-alpha.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.
Files changed (72) hide show
  1. package/cjs/arithmetic.js +12 -20
  2. package/cjs/constants.js +3 -4
  3. package/cjs/globalStyles.js +7 -9
  4. package/cjs/index.js +27 -17
  5. package/cjs/mobileUtilities.js +7 -17
  6. package/cjs/spaceUtilities.js +11 -20
  7. package/cjs/styled/index.d.js +2 -0
  8. package/cjs/styled/index.js +124 -0
  9. package/cjs/styled/styleGetters.js +44 -0
  10. package/cjs/styled/types.js +12 -0
  11. package/cjs/styled/utils.js +24 -0
  12. package/cjs/th.js +32 -0
  13. package/cjs/theme.js +1 -2
  14. package/cjs/themeProviderHOC.js +18 -12
  15. package/cjs/utils.js +52 -84
  16. package/esm/arithmetic.js +12 -16
  17. package/esm/constants.js +3 -4
  18. package/esm/globalStyles.js +7 -9
  19. package/esm/index.js +4 -9
  20. package/esm/mobileUtilities.js +6 -12
  21. package/esm/spaceUtilities.js +11 -20
  22. package/esm/styled/index.d.js +1 -0
  23. package/esm/styled/index.js +115 -0
  24. package/esm/styled/styleGetters.js +38 -0
  25. package/esm/styled/types.js +1 -0
  26. package/esm/styled/utils.js +18 -0
  27. package/esm/th.js +28 -0
  28. package/esm/theme.js +1 -2
  29. package/esm/themeProviderHOC.js +15 -10
  30. package/esm/utils.js +31 -71
  31. package/package.json +83 -12
  32. package/types/arithmetic.d.ts +5 -0
  33. package/types/constants.d.ts +11 -0
  34. package/types/globalStyles.d.ts +1 -0
  35. package/types/index.d.ts +9 -0
  36. package/types/mobileUtilities.d.ts +4 -0
  37. package/types/spaceUtilities.d.ts +13 -0
  38. package/types/styled/index.d.ts +2 -0
  39. package/types/styled/styleGetters.d.ts +4 -0
  40. package/types/styled/types.d.ts +28 -0
  41. package/types/styled/utils.d.ts +6 -0
  42. package/types/tests/arithmetic.test.d.ts +1 -0
  43. package/types/th.d.ts +14 -0
  44. package/types/theme.d.ts +2 -0
  45. package/types/themeProviderHOC.d.ts +2 -0
  46. package/types/utils.d.ts +27 -0
  47. package/arithmetic/package.json +0 -10
  48. package/cjs/arithmetic.js.map +0 -1
  49. package/cjs/constants.js.map +0 -1
  50. package/cjs/globalStyles.js.map +0 -1
  51. package/cjs/index.js.map +0 -1
  52. package/cjs/mobileUtilities.js.map +0 -1
  53. package/cjs/spaceUtilities.js.map +0 -1
  54. package/cjs/theme.js.map +0 -1
  55. package/cjs/themeProviderHOC.js.map +0 -1
  56. package/cjs/utils.js.map +0 -1
  57. package/constants/package.json +0 -10
  58. package/esm/arithmetic.js.map +0 -1
  59. package/esm/constants.js.map +0 -1
  60. package/esm/globalStyles.js.map +0 -1
  61. package/esm/index.js.map +0 -1
  62. package/esm/mobileUtilities.js.map +0 -1
  63. package/esm/spaceUtilities.js.map +0 -1
  64. package/esm/theme.js.map +0 -1
  65. package/esm/themeProviderHOC.js.map +0 -1
  66. package/esm/utils.js.map +0 -1
  67. package/globalStyles/package.json +0 -10
  68. package/mobileUtilities/package.json +0 -10
  69. package/spaceUtilities/package.json +0 -10
  70. package/theme/package.json +0 -10
  71. package/themeProviderHOC/package.json +0 -10
  72. package/utils/package.json +0 -10
package/cjs/utils.js CHANGED
@@ -2,33 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
6
5
  var polished = require('polished');
7
6
  var lodash = require('lodash');
8
7
  var theme = require('./theme.js');
9
8
  var mobileUtilities = require('./mobileUtilities.js');
10
- require('@elliemae/pui-theme');
11
- require('@babel/runtime/helpers/slicedToArray');
12
- require('react');
13
- require('./constants.js');
9
+ var styled_component = require('styled-components');
14
10
 
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefaultLegacy(_taggedTemplateLiteral);
18
-
19
- var _templateObject;
20
-
21
- var styled = require('styled-components');
22
-
23
- var css = styled.css;
24
- var kfrm = styled.keyframes;
25
- var withTheme = styled.withTheme;
26
- var useTheme = styled.useTheme;
27
- var createGlobalStyle = styled.createGlobalStyle;
11
+ /* eslint-disable no-shadow */
28
12
  function truncate(width) {
29
- return function (props) {
30
- return css(["", " white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"], !!width || props.width ? "width: ".concat(props.width || width, ";") : '');
31
- };
13
+ return props => styled_component.css(["", " white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"], !!width || props.width ? "width: ".concat(props.width || width, ";") : '');
32
14
  }
33
15
  function flexCenter() {
34
16
  return "\n display: flex;\n justify-content: center;\n align-items: center;\n ";
@@ -37,58 +19,46 @@ function disabled() {
37
19
  return "\n cursor: not-allowed;\n pointer-events: none;\n ";
38
20
  }
39
21
  function keyframes(obj) {
40
- return kfrm(_templateObject || (_templateObject = _taggedTemplateLiteral__default['default'](["", "\n "])), lodash.reduce(obj, function (result, value, key) {
41
- return "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n ");
42
- }, ''));
22
+ return styled_component.keyframes(["", ""], lodash.reduce(obj, (result, value, key) => "\n ".concat(result, "\n ").concat(key, "% {\n ").concat(value, "\n }\n "), ''));
43
23
  } // eslint-disable-next-line max-params
44
24
 
45
25
  function boxShadow(top, left, blur, color) {
46
- var inset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
26
+ let inset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
47
27
  return "box-shadow: ".concat(inset ? 'inset' : '', " ").concat(top, " ").concat(left, " ").concat(blur, " ").concat(color, ";");
48
28
  }
49
29
  function color() {
50
- var variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
51
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
52
- return css(["color:", ";"], function (props) {
53
- return props.theme.colors[variant][type];
54
- });
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]);
55
33
  }
56
34
  function border() {
57
- var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
58
- var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1px';
59
- var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'solid';
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';
60
38
  return "".concat(size, " ").concat(type, " ").concat(color);
61
39
  }
62
40
  function animation(animationKeyframes, animationLength, animationTimingFn) {
63
- return function (props) {
64
- return css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
65
- };
41
+ return props => styled_component.css(["animation:", " ", " ", ";"], props.animationKeyframes || animationKeyframes, props.animationLength || animationLength, props.animationTimingFn || animationTimingFn);
66
42
  } // 0.0769
67
43
 
68
44
  function focus() {
69
- var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : theme.theme.colors.brand[600];
70
- return function () {
71
- return css(["outline:none;border:1px solid ", ";box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], color, polished.lighten(0.3, color));
72
- };
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));
73
47
  }
74
48
  function focusAfter(color) {
75
- return 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));
76
50
  }
77
51
  function active() {
78
- return function (props) {
79
- return css(["outline:none;border:1px solid ", ";border-radius:2px;"], props.theme.colors.brand[700]);
80
- };
52
+ return props => styled_component.css(["outline:none;border:1px solid ", ";border-radius:2px;"], props.theme.colors.brand[700]);
81
53
  }
82
54
  function hover() {
83
- return function (props) {
84
- return css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
85
- };
55
+ return props => styled_component.css(["outline:1px solid ", ";outline-offset:-1px;"], props.theme.colors.brand[600]);
86
56
  }
87
57
  function textStyle(type) {
88
- var weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
58
+ let weight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'regular';
89
59
  // eslint-disable-next-line complexity
90
- return function (props) {
91
- var cssVar = "font-weight: ".concat(props.theme.fontWeights[weight], ";"); // eslint-disable-next-line default-case
60
+ return props => {
61
+ let cssVar = "font-weight: ".concat(props.theme.fontWeights[weight], ";"); // eslint-disable-next-line default-case
92
62
 
93
63
  switch (type) {
94
64
  case 'h1':
@@ -140,21 +110,15 @@ function textStyle(type) {
140
110
  };
141
111
  }
142
112
  function iconColor() {
143
- var variant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'neutral';
144
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 400;
145
- return css(["fill:", ";"], function (props) {
146
- return props.theme.colors[variant][type];
147
- });
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]);
148
116
  }
149
117
  function fakeBorder() {
150
- return css(["box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], function (props) {
151
- return props.theme.colors.neutral[200];
152
- });
118
+ return styled_component.css(["box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.neutral[200]);
153
119
  }
154
120
  function fakeActive() {
155
- return css(["outline:none;box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], function (props) {
156
- return props.theme.colors.brand[700];
157
- });
121
+ return styled_component.css(["outline:none;box-shadow:inset 0 0 0 1px ", ";border-radius:2px;"], props => props.theme.colors.brand[700]);
158
122
  }
159
123
  function clearFocus() {
160
124
  return "\n border: none;\n box-shadow: none;\n ";
@@ -163,27 +127,37 @@ function buttonLink() {
163
127
  return "\n background-color: transparent;\n border: 1px solid transparent;\n cursor: pointer;\n ";
164
128
  }
165
129
  function transition() {
166
- var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all 1s ease';
130
+ let t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'all 1s ease';
167
131
  return "\n transition: ".concat(t, ";\n ");
168
132
  }
169
- function onlySafariAndFiredox(styles) {
170
- return css(["@media not all and (min-resolution:0.001dpcm){", "}@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles, styles);
171
- }
172
- function onlySafari(styles) {
173
- return css(["@media not all and (min-resolution:0.001dpcm){", "}"], styles);
174
- }
175
- function onlyFirefox(styles) {
176
- return css(["@media screen and (min--moz-device-pixel-ratio:0){", "}"], styles);
177
- }
178
- function safariAndFirefoxBold(color) {
179
- return 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);
180
- }
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");
181
137
 
182
138
  Object.defineProperty(exports, 'rgba', {
183
139
  enumerable: true,
184
- get: function () {
185
- return polished.rgba;
186
- }
140
+ get: function () { return polished.rgba; }
141
+ });
142
+ Object.defineProperty(exports, 'createGlobalStyle', {
143
+ enumerable: true,
144
+ get: function () { return styled_component.createGlobalStyle; }
145
+ });
146
+ Object.defineProperty(exports, 'css', {
147
+ enumerable: true,
148
+ get: function () { return styled_component.css; }
149
+ });
150
+ Object.defineProperty(exports, 'kfrm', {
151
+ enumerable: true,
152
+ get: function () { return styled_component.keyframes; }
153
+ });
154
+ Object.defineProperty(exports, 'useTheme', {
155
+ enumerable: true,
156
+ get: function () { return styled_component.useTheme; }
157
+ });
158
+ Object.defineProperty(exports, 'withTheme', {
159
+ enumerable: true,
160
+ get: function () { return styled_component.withTheme; }
187
161
  });
188
162
  exports.active = active;
189
163
  exports.animation = animation;
@@ -192,8 +166,6 @@ exports.boxShadow = boxShadow;
192
166
  exports.buttonLink = buttonLink;
193
167
  exports.clearFocus = clearFocus;
194
168
  exports.color = color;
195
- exports.createGlobalStyle = createGlobalStyle;
196
- exports.css = css;
197
169
  exports.disabled = disabled;
198
170
  exports.fakeActive = fakeActive;
199
171
  exports.fakeBorder = fakeBorder;
@@ -203,14 +175,10 @@ exports.focusAfter = focusAfter;
203
175
  exports.hover = hover;
204
176
  exports.iconColor = iconColor;
205
177
  exports.keyframes = keyframes;
206
- exports.kfrm = kfrm;
207
178
  exports.onlyFirefox = onlyFirefox;
208
179
  exports.onlySafari = onlySafari;
209
- exports.onlySafariAndFiredox = onlySafariAndFiredox;
180
+ exports.onlySafariAndFirefox = onlySafariAndFirefox;
210
181
  exports.safariAndFirefoxBold = safariAndFirefoxBold;
211
182
  exports.textStyle = textStyle;
212
183
  exports.transition = transition;
213
184
  exports.truncate = truncate;
214
- exports.useTheme = useTheme;
215
- exports.withTheme = withTheme;
216
- //# sourceMappingURL=utils.js.map
package/esm/arithmetic.js CHANGED
@@ -1,24 +1,21 @@
1
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
2
 
3
3
  function getNumberAndUnit(numberStrWithUnit) {
4
- var _String$match = String(numberStrWithUnit).match(/[a-z]+|[(/^\-?\d*.\d+|\d+),?]+/gi),
5
- _String$match2 = _slicedToArray(_String$match, 2),
6
- number = _String$match2[0],
7
- unit = _String$match2[1];
8
-
4
+ const [number, unit] = String(numberStrWithUnit).match(/[a-z]+|[(/^\-?\d*.\d+|\d+),?]+/gi);
9
5
  return {
10
- number: number,
11
- unit: unit
6
+ number,
7
+ unit
12
8
  };
13
9
  }
14
10
  function op(operator, n1, n2) {
15
- var _getNumberAndUnit = getNumberAndUnit(n1),
16
- number = _getNumberAndUnit.number,
17
- unit = _getNumberAndUnit.unit;
18
-
19
- var _getNumberAndUnit2 = getNumberAndUnit(n2),
20
- number2 = _getNumberAndUnit2.number,
21
- unit2 = _getNumberAndUnit2.unit;
11
+ const {
12
+ number,
13
+ unit
14
+ } = getNumberAndUnit(n1);
15
+ const {
16
+ number: number2,
17
+ unit: unit2
18
+ } = getNumberAndUnit(n2);
22
19
 
23
20
  switch (operator) {
24
21
  case '*':
@@ -39,4 +36,3 @@ function op(operator, n1, n2) {
39
36
  }
40
37
 
41
38
  export { getNumberAndUnit, op };
42
- //# sourceMappingURL=arithmetic.js.map
package/esm/constants.js CHANGED
@@ -1,6 +1,6 @@
1
- var desktopBaseFont = 13;
2
- var mobileBaseFont = 16;
3
- var translateUnits = {
1
+ const desktopBaseFont = 13;
2
+ const mobileBaseFont = 16;
3
+ const translateUnits = {
4
4
  '8px': '4px',
5
5
  '16px': '8px',
6
6
  '32px': '16px',
@@ -11,4 +11,3 @@ var translateUnits = {
11
11
  };
12
12
 
13
13
  export { desktopBaseFont, mobileBaseFont, translateUnits };
14
- //# sourceMappingURL=constants.js.map
@@ -1,19 +1,17 @@
1
1
  import _taggedTemplateLiteral from '@babel/runtime/helpers/esm/taggedTemplateLiteral';
2
- import { createGlobalStyle } from './utils.js';
3
2
  import 'polished';
4
3
  import 'lodash';
5
4
  import './theme.js';
6
- import '@elliemae/pui-theme';
7
- import './mobileUtilities.js';
8
- import '@babel/runtime/helpers/esm/slicedToArray';
5
+ import 'core-js/modules/web.dom-collections.iterator.js';
9
6
  import 'react';
10
- import './constants.js';
7
+ import { createGlobalStyle } from 'styled-components';
11
8
 
12
9
  var _templateObject;
13
- var 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"])), function (_ref) {
14
- var theme = _ref.theme;
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;
15
14
  return theme.breakpoints.small;
16
- });
15
+ }, props => props.device === 'mobile' ? '16px' : '13px');
17
16
 
18
17
  export { GlobalStyles };
19
- //# sourceMappingURL=globalStyles.js.map
package/esm/index.js CHANGED
@@ -1,16 +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, createGlobalStyle, css, disabled, fakeActive, fakeBorder, flexCenter, focus, focusAfter, hover, iconColor, keyframes, kfrm, onlyFirefox, onlySafari, onlySafariAndFiredox, safariAndFirefoxBold, textStyle, transition, truncate, useTheme, withTheme } 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';
10
+ export { createGlobalStyle, css, keyframes as kfrm, useTheme, withTheme } from 'styled-components';
8
11
  export { rgba } from 'polished';
9
- import '@babel/runtime/helpers/esm/taggedTemplateLiteral';
10
- import 'lodash';
11
- import '@elliemae/pui-theme';
12
- import '@babel/runtime/helpers/esm/slicedToArray';
13
- import 'react';
14
- import './constants.js';
15
- import 'styled-components';
16
- //# sourceMappingURL=index.js.map
@@ -1,8 +1,7 @@
1
- import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
2
  import { useState, useEffect } from 'react';
3
3
  import { theme } from './theme.js';
4
4
  import { translateUnits, mobileBaseFont, desktopBaseFont } from './constants.js';
5
- import '@elliemae/pui-theme';
6
5
 
7
6
  function __UNSAFE_SPACE_TO_DIMSUM(unit) {
8
7
  if (translateUnits[unit]) return translateUnits[unit];
@@ -12,29 +11,24 @@ function toMobile(unit) {
12
11
  if (!isMobile()) return unit;
13
12
  return "".concat(parseFloat(unit) * (desktopBaseFont / mobileBaseFont), "rem");
14
13
  }
15
- var useIsMobile = function useIsMobile() {
16
- var _useState = useState(isMobile()),
17
- _useState2 = _slicedToArray(_useState, 2),
18
- mobile = _useState2[0],
19
- setMobile = _useState2[1];
20
-
21
- useEffect(function () {
14
+ const useIsMobile = () => {
15
+ const [mobile, setMobile] = useState(isMobile());
16
+ useEffect(() => {
22
17
  function handleResize() {
23
18
  setMobile(isMobile());
24
19
  }
25
20
 
26
21
  if (window) window.addEventListener('resize', handleResize);
27
- return function () {
22
+ return () => {
28
23
  if (window) window.removeEventListener('resize', handleResize);
29
24
  };
30
25
  }, []);
31
26
  if (!window) return false;
32
27
  return mobile;
33
28
  };
34
- var isMobile = function isMobile() {
29
+ const isMobile = () => {
35
30
  if (!window) return false;
36
31
  return Number(theme.breakpoints.medium.split('px')[0]) - window.innerWidth >= 0;
37
32
  };
38
33
 
39
34
  export { __UNSAFE_SPACE_TO_DIMSUM, isMobile, toMobile, useIsMobile };
40
- //# sourceMappingURL=mobileUtilities.js.map
@@ -1,6 +1,10 @@
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
- import '@elliemae/pui-theme';
4
8
 
5
9
  function mapGap(gutter) {
6
10
  if (!gutter) return '0rem';
@@ -17,16 +21,12 @@ function mapSpace(width) {
17
21
  }
18
22
  function fixSpaceGutter(width, gutter) {
19
23
  if (!width) return '';
20
- if (Array.isArray(width)) return width.map(function (w) {
21
- return "calc(".concat(mapSpace(w), " - (").concat(mapGutter(gutter), "))");
22
- });
24
+ if (Array.isArray(width)) return width.map(w => "calc(".concat(mapSpace(w), " - (").concat(mapGutter(gutter), "))"));
23
25
  return "calc(".concat(mapSpace(width), " - (").concat(mapGutter(gutter), "))");
24
26
  }
25
27
  function fixSpace(width) {
26
28
  if (!width) return '';
27
- if (Array.isArray(width)) return width.map(function (w) {
28
- return mapSpace(w);
29
- });
29
+ if (Array.isArray(width)) return width.map(w => mapSpace(w));
30
30
  return mapSpace(width);
31
31
  }
32
32
  /**
@@ -36,26 +36,18 @@ function fixSpace(width) {
36
36
  */
37
37
 
38
38
  function numbersToFr(grid) {
39
- var den = grid.map(function (f) {
40
- return f < 1 ? Math.floor(1 / f) : f;
41
- });
42
- return den.map(function (d) {
43
- return "".concat(d, "fr");
44
- });
39
+ const den = grid.map(f => f < 1 ? Math.floor(1 / f) : f);
40
+ return den.map(d => "".concat(d, "fr"));
45
41
  }
46
42
  function mapGrid(width) {
47
43
  if (get(theme, width)) return "".concat(get(theme, width));
48
44
  if (typeof width === 'string') return width;
49
- var den = width < 1 ? Math.floor(1 / width) : width;
45
+ const den = width < 1 ? Math.floor(1 / width) : width;
50
46
  return "".concat(den, "fr");
51
47
  }
52
48
  function mapTemplateGrid(grid) {
53
49
  if (Array.isArray(grid)) {
54
- if (grid.some(function (w) {
55
- return typeof w === 'string';
56
- })) return grid.map(function (w) {
57
- return mapGrid(w);
58
- });
50
+ if (grid.some(w => typeof w === 'string')) return grid.map(w => mapGrid(w));
59
51
  return numbersToFr(grid);
60
52
  }
61
53
 
@@ -63,4 +55,3 @@ function mapTemplateGrid(grid) {
63
55
  }
64
56
 
65
57
  export { fixSpace, fixSpaceGutter, mapGap, mapGrid, mapGutter, mapSpace, mapTemplateGrid, numbersToFr };
66
- //# sourceMappingURL=spaceUtilities.js.map
@@ -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 };