@elliemae/ds-system 2.2.0 → 2.3.0-alpha.3

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 (63) hide show
  1. package/cjs/arithmetic.js +42 -30
  2. package/cjs/arithmetic.js.map +7 -0
  3. package/cjs/constants.js +43 -15
  4. package/cjs/constants.js.map +7 -0
  5. package/cjs/globalStyles.js +44 -22
  6. package/cjs/globalStyles.js.map +7 -0
  7. package/cjs/index.js +42 -83
  8. package/cjs/index.js.map +7 -0
  9. package/cjs/mobileUtilities.js +57 -26
  10. package/cjs/mobileUtilities.js.map +7 -0
  11. package/cjs/spaceUtilities.js +72 -46
  12. package/cjs/spaceUtilities.js.map +7 -0
  13. package/cjs/styled/index.d.js +27 -2
  14. package/cjs/styled/index.d.js.map +7 -0
  15. package/cjs/styled/index.js +57 -92
  16. package/cjs/styled/index.js.map +7 -0
  17. package/cjs/styled/styleGetters.js +42 -30
  18. package/cjs/styled/styleGetters.js.map +7 -0
  19. package/cjs/styled/types.js +34 -11
  20. package/cjs/styled/types.js.map +7 -0
  21. package/cjs/styled/utils.js +46 -23
  22. package/cjs/styled/utils.js.map +7 -0
  23. package/cjs/th.js +57 -31
  24. package/cjs/th.js.map +7 -0
  25. package/cjs/theme.js +36 -9
  26. package/cjs/theme.js.map +7 -0
  27. package/cjs/themeProviderHOC.js +42 -29
  28. package/cjs/themeProviderHOC.js.map +7 -0
  29. package/cjs/utils.js +256 -146
  30. package/cjs/utils.js.map +7 -0
  31. package/esm/arithmetic.js +13 -25
  32. package/esm/arithmetic.js.map +7 -0
  33. package/esm/constants.js +14 -9
  34. package/esm/constants.js.map +7 -0
  35. package/esm/globalStyles.js +16 -15
  36. package/esm/globalStyles.js.map +7 -0
  37. package/esm/index.js +14 -11
  38. package/esm/index.js.map +7 -0
  39. package/esm/mobileUtilities.js +26 -17
  40. package/esm/mobileUtilities.js.map +7 -0
  41. package/esm/spaceUtilities.js +43 -35
  42. package/esm/spaceUtilities.js.map +7 -0
  43. package/esm/styled/index.d.js +2 -1
  44. package/esm/styled/index.d.js.map +7 -0
  45. package/esm/styled/index.js +23 -78
  46. package/esm/styled/index.js.map +7 -0
  47. package/esm/styled/styleGetters.js +12 -23
  48. package/esm/styled/styleGetters.js.map +7 -0
  49. package/esm/styled/types.js +6 -1
  50. package/esm/styled/types.js.map +7 -0
  51. package/esm/styled/utils.js +16 -16
  52. package/esm/styled/utils.js.map +7 -0
  53. package/esm/th.js +28 -27
  54. package/esm/th.js.map +7 -0
  55. package/esm/theme.js +6 -4
  56. package/esm/theme.js.map +7 -0
  57. package/esm/themeProviderHOC.js +13 -20
  58. package/esm/themeProviderHOC.js.map +7 -0
  59. package/esm/utils.js +227 -98
  60. package/esm/utils.js.map +7 -0
  61. package/package.json +2 -2
  62. package/types/th.d.ts +15 -12
  63. package/types/utils.d.ts +1 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/spaceUtilities.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { get } from 'lodash';\nimport { theme } from './theme';\n\nexport function mapGap(gutter: number | string): number | string {\n if (!gutter) return '0rem';\n if (String(gutter).includes('rem') || String(gutter).includes('px'))\n return gutter;\n return `${theme.space[gutter]}`;\n}\n\nexport function mapGutter(gutter: string | number): string {\n if (!gutter) return '0rem';\n return `${theme.space[gutter]} * 2`;\n}\n\nexport function mapSpace(width: string | number): string {\n if (typeof width === 'string')\n return get(theme, width) ? `${get(theme, width)}` : width;\n return `${width * 100}%`;\n}\n\nexport function fixSpaceGutter(\n width: string | number,\n gutter: string | number,\n): string | string[] {\n if (!width) return '';\n if (Array.isArray(width))\n return width.map((w) => `calc(${mapSpace(w)} - (${mapGutter(gutter)}))`);\n return `calc(${mapSpace(width)} - (${mapGutter(gutter)}))`;\n}\n\nexport function fixSpace(width: string | number): string | string[] {\n if (!width) return '';\n if (Array.isArray(width)) return width.map((w) => mapSpace(w));\n return mapSpace(width);\n}\n\n/**\n * Grid\n *\n * @param grid\n */\nexport function numbersToFr(grid: number[]): string[] {\n const den = grid.map((f) => (f < 1 ? Math.floor(1 / f) : f));\n return den.map((d) => `${d}fr`);\n}\nexport function mapGrid(width: string | number): string {\n if (get(theme, width)) return `${get(theme, width)}`;\n if (typeof width === 'string') return width;\n const den = width < 1 ? Math.floor(1 / width) : width;\n return `${den}fr`;\n}\n\nexport function mapTemplateGrid(grid: number[]): string | string[] {\n if (Array.isArray(grid)) {\n if (grid.some((w) => typeof w === 'string'))\n return grid.map((w) => mapGrid(w));\n return numbersToFr(grid);\n }\n return mapGrid(grid);\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,oBAAoB;AACpB,mBAAsB;AAEf,gBAAgB,QAA0C;AAC/D,MAAI,CAAC;AAAQ,WAAO;AACpB,MAAI,OAAO,QAAQ,SAAS,UAAU,OAAO,QAAQ,SAAS;AAC5D,WAAO;AACT,SAAO,GAAG,mBAAM,MAAM;AAAA;AAGjB,mBAAmB,QAAiC;AACzD,MAAI,CAAC;AAAQ,WAAO;AACpB,SAAO,GAAG,mBAAM,MAAM;AAAA;AAGjB,kBAAkB,OAAgC;AACvD,MAAI,OAAO,UAAU;AACnB,WAAO,uBAAI,oBAAO,SAAS,GAAG,uBAAI,oBAAO,WAAW;AACtD,SAAO,GAAG,QAAQ;AAAA;AAGb,wBACL,OACA,QACmB;AACnB,MAAI,CAAC;AAAO,WAAO;AACnB,MAAI,MAAM,QAAQ;AAChB,WAAO,MAAM,IAAI,CAAC,MAAM,QAAQ,SAAS,SAAS,UAAU;AAC9D,SAAO,QAAQ,SAAS,aAAa,UAAU;AAAA;AAG1C,kBAAkB,OAA2C;AAClE,MAAI,CAAC;AAAO,WAAO;AACnB,MAAI,MAAM,QAAQ;AAAQ,WAAO,MAAM,IAAI,CAAC,MAAM,SAAS;AAC3D,SAAO,SAAS;AAAA;AAQX,qBAAqB,MAA0B;AACpD,QAAM,MAAM,KAAK,IAAI,CAAC,MAAO,IAAI,IAAI,KAAK,MAAM,IAAI,KAAK;AACzD,SAAO,IAAI,IAAI,CAAC,MAAM,GAAG;AAAA;AAEpB,iBAAiB,OAAgC;AACtD,MAAI,uBAAI,oBAAO;AAAQ,WAAO,GAAG,uBAAI,oBAAO;AAC5C,MAAI,OAAO,UAAU;AAAU,WAAO;AACtC,QAAM,MAAM,QAAQ,IAAI,KAAK,MAAM,IAAI,SAAS;AAChD,SAAO,GAAG;AAAA;AAGL,yBAAyB,MAAmC;AACjE,MAAI,MAAM,QAAQ,OAAO;AACvB,QAAI,KAAK,KAAK,CAAC,MAAM,OAAO,MAAM;AAChC,aAAO,KAAK,IAAI,CAAC,MAAM,QAAQ;AACjC,WAAO,YAAY;AAAA;AAErB,SAAO,QAAQ;AAAA;",
6
+ "names": []
7
+ }
@@ -1,2 +1,27 @@
1
- 'use strict';
2
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __reExport = (target, module2, copyDefault, desc) => {
9
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
10
+ for (let key of __getOwnPropNames(module2))
11
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
12
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
13
+ }
14
+ return target;
15
+ };
16
+ var __toESM = (module2, isNodeMode) => {
17
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
18
+ };
19
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
20
+ return (module2, temp) => {
21
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
22
+ };
23
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
24
+ var index_d_exports = {};
25
+ var React = __toESM(require("react"));
26
+ module.exports = __toCommonJS(index_d_exports);
27
+ //# sourceMappingURL=index.d.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styled/index.d.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport type { Theme as PuiTheme } from '@elliemae/pui-theme';\nimport styled, { AnyStyledComponent } from 'styled-components';\n\ntype StyleObject = Record<string, string | Record<string, string>>;\n\nexport interface Theme extends PuiTheme {\n components?: {\n [componentName: string]: {\n styleOverrides?: StyleObject;\n variants?: { props: Record<string, unknown>; style: StyleObject }[];\n };\n };\n}\n\nexport type Styled<T extends object = Theme> = (\n tag: AnyStyledComponent,\n options?: { name: string; slot: string },\n) => any & {\n [el: AnyStyledComponent]: any;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;ACAA,YAAuB;",
6
+ "names": []
7
+ }
@@ -1,124 +1,89 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- require('core-js/modules/esnext.async-iterator.map.js');
7
- require('core-js/modules/esnext.iterator.map.js');
8
- require('core-js/modules/web.dom-collections.iterator.js');
9
- require('core-js/modules/esnext.async-iterator.reduce.js');
10
- require('core-js/modules/esnext.iterator.constructor.js');
11
- require('core-js/modules/esnext.iterator.reduce.js');
12
- require('core-js/modules/esnext.async-iterator.filter.js');
13
- require('core-js/modules/esnext.iterator.filter.js');
14
- require('core-js/modules/esnext.async-iterator.for-each.js');
15
- require('core-js/modules/esnext.iterator.for-each.js');
16
- var styled_component = require('styled-components');
17
- var styleGetters = require('./styleGetters.js');
18
- var utils = require('./utils.js');
19
-
20
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
-
22
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
23
- var styled_component__default = /*#__PURE__*/_interopDefaultLegacy(styled_component);
24
-
25
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
-
27
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
-
29
- const styledFunction = function (tag) {
30
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
31
- name: null,
32
- slot: null
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
33
26
  };
34
- const {
35
- name: componentName = null,
36
- slot: componentSlot = null
37
- } = options;
38
-
39
- const func = function (styleArg) {
40
- for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
41
- expressions[_key - 1] = arguments[_key];
42
- }
43
-
44
- /*
45
- * These are the internal expression written in dimsum
46
- * We just coerce with the default theme in case users
47
- * forget to add the ThemeProvider
48
- */
49
- const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? props => stylesArg(_objectSpread(_objectSpread({}, props), {}, {
50
- theme: utils.coerceWithDefaultTheme(props.theme)
51
- })) : stylesArg) : [];
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var styled_exports = {};
29
+ __export(styled_exports, {
30
+ styled: () => styled
31
+ });
32
+ var React = __toESM(require("react"));
33
+ var import_styled_components = __toESM(require("styled-components"));
34
+ var import_styleGetters = require("./styleGetters");
35
+ var import_utils = require("./utils");
36
+ const styledFunction = (tag, options = { name: null, slot: null }) => {
37
+ const { name: componentName = null, slot: componentSlot = null } = options;
38
+ const func = (styleArg, ...expressions) => {
39
+ const expressionsWithDefaultTheme = expressions ? expressions.map((stylesArg) => typeof stylesArg === "function" ? (props) => stylesArg({
40
+ ...props,
41
+ theme: (0, import_utils.coerceWithDefaultTheme)(props.theme)
42
+ }) : stylesArg) : [];
52
43
  let transformedStyleArg = styleArg;
53
- /*
54
- * Here we get the style overrides from the user
55
- */
56
-
57
44
  if (componentName && componentSlot) {
58
- expressionsWithDefaultTheme.push(props => {
59
- const theme = utils.coerceWithDefaultTheme(props.theme);
60
- const styleOverrides = styleGetters.getStyleOverrides(componentName, theme);
61
-
45
+ expressionsWithDefaultTheme.push((props) => {
46
+ const theme = (0, import_utils.coerceWithDefaultTheme)(props.theme);
47
+ const styleOverrides = (0, import_styleGetters.getStyleOverrides)(componentName, theme);
62
48
  if (styleOverrides) {
63
49
  return [styleOverrides[componentSlot]];
64
50
  }
65
-
66
51
  return null;
67
52
  });
68
53
  }
69
- /*
70
- * Here we get the variant overrides from the user (only for the root)
71
- */
72
-
73
-
74
- if (componentName && componentSlot === 'root') {
75
- expressionsWithDefaultTheme.push(props => {
76
- const theme = utils.coerceWithDefaultTheme(props.theme);
77
- return styleGetters.variantsResolver(props, styleGetters.getVariantStyles(componentName, theme), theme, componentName);
54
+ if (componentName && componentSlot === "root") {
55
+ expressionsWithDefaultTheme.push((props) => {
56
+ const theme = (0, import_utils.coerceWithDefaultTheme)(props.theme);
57
+ return (0, import_styleGetters.variantsResolver)(props, (0, import_styleGetters.getVariantStyles)(componentName, theme), theme, componentName);
78
58
  });
79
59
  }
80
-
81
60
  const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;
82
-
83
61
  if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
84
- // Here we are adding placeholders for all the new functions that we are gonna call
85
- const placeholders = new Array(numOfCustomFnsApplied).fill('');
62
+ const placeholders = new Array(numOfCustomFnsApplied).fill("");
86
63
  transformedStyleArg = Object.assign([...styleArg, ...placeholders], {
87
64
  raw: [...styleArg.raw, ...placeholders]
88
65
  });
89
- } else if (typeof styleArg === 'function') {
90
- // Here we just coerce with the default theme
91
- transformedStyleArg = props => styleArg(_objectSpread(_objectSpread({}, props), {}, {
92
- theme: utils.coerceWithDefaultTheme(props.theme)
93
- }));
66
+ } else if (typeof styleArg === "function") {
67
+ transformedStyleArg = (props) => styleArg({ ...props, theme: (0, import_utils.coerceWithDefaultTheme)(props.theme) });
94
68
  }
95
-
96
- let Component = /*#__PURE__*/styled_component__default["default"](tag);
97
- const displayName = componentName !== null && componentSlot !== null ? "".concat(componentName, "-").concat(componentSlot) : null;
98
-
69
+ let Component = (0, import_styled_components.default)(tag);
70
+ const displayName = componentName !== null && componentSlot !== null ? `${componentName}-${componentSlot}` : null;
99
71
  if (displayName !== null) {
100
- Component = Component.attrs({
101
- className: "".concat(componentName, "-").concat(componentSlot)
102
- });
72
+ Component = Component.attrs({ className: `${componentName}${componentSlot}` });
103
73
  }
104
-
105
74
  Component = Component(transformedStyleArg, ...expressionsWithDefaultTheme);
106
-
107
75
  if (displayName !== null) {
108
76
  Component.displayName = displayName;
109
77
  }
110
-
111
78
  return Component;
112
79
  };
113
-
114
80
  return func;
115
81
  };
116
-
117
- const styledObject = Object.keys(styled_component__default["default"]).reduce((obj, key) => {
82
+ const styledObject = Object.keys(import_styled_components.default).reduce((obj, key) => {
118
83
  const castedKey = key;
119
84
  obj[castedKey] = styledFunction(castedKey);
120
85
  return obj;
121
86
  }, {});
122
87
  const styled = Object.assign(styledFunction, styledObject);
123
-
124
- exports.styled = styled;
88
+ module.exports = __toCommonJS(styled_exports);
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styled/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import styled_component, { StyledComponentPropsWithRef } from 'styled-components';\nimport { Styled, StyledFunction, StyledObject } from './types';\nimport { getStyleOverrides, getVariantStyles, variantsResolver } from './styleGetters';\nimport { coerceWithDefaultTheme } from './utils';\n\nconst styledFunction: StyledFunction = (tag, options = { name: null, slot: null }) => {\n const { name: componentName = null, slot: componentSlot = null } = options;\n const func: ReturnType<StyledFunction> = (styleArg, ...expressions) => {\n /*\n * These are the internal expression written in dimsum\n * We just coerce with the default theme in case users\n * forget to add the ThemeProvider\n */\n const expressionsWithDefaultTheme = expressions\n ? expressions.map<typeof expressions[number]>((stylesArg) =>\n typeof stylesArg === 'function'\n ? (props) =>\n stylesArg({\n ...props,\n theme: coerceWithDefaultTheme(props.theme),\n })\n : stylesArg,\n )\n : [];\n\n let transformedStyleArg = styleArg;\n\n /*\n * Here we get the style overrides from the user\n */\n if (componentName && componentSlot) {\n expressionsWithDefaultTheme.push((props) => {\n const theme = coerceWithDefaultTheme(props.theme);\n const styleOverrides = getStyleOverrides(componentName, theme);\n if (styleOverrides) {\n return [styleOverrides[componentSlot]];\n }\n return null;\n });\n }\n\n /*\n * Here we get the variant overrides from the user (only for the root)\n */\n if (componentName && componentSlot === 'root') {\n expressionsWithDefaultTheme.push((props) => {\n const theme = coerceWithDefaultTheme(props.theme);\n return variantsResolver(props, getVariantStyles(componentName, theme), theme, componentName);\n });\n }\n\n const numOfCustomFnsApplied = expressionsWithDefaultTheme.length - expressions.length;\n\n if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {\n // Here we are adding placeholders for all the new functions that we are gonna call\n const placeholders: string[] = new Array(numOfCustomFnsApplied).fill('');\n transformedStyleArg = Object.assign([...styleArg, ...placeholders], {\n raw: [...(styleArg as TemplateStringsArray).raw, ...placeholders],\n });\n } else if (typeof styleArg === 'function') {\n // Here we just coerce with the default theme\n transformedStyleArg = (props) => styleArg({ ...props, theme: coerceWithDefaultTheme(props.theme) });\n }\n let Component = styled_component(tag);\n\n const displayName =\n componentName !== null && componentSlot !== null ? `${componentName}-${componentSlot}` : null;\n\n if (displayName !== null) {\n Component = Component.attrs({ className: `${componentName}${componentSlot}` } as unknown as Partial<\n StyledComponentPropsWithRef<typeof tag>\n >);\n }\n\n Component = Component(transformedStyleArg, ...expressionsWithDefaultTheme);\n\n if (displayName !== null) {\n Component.displayName = displayName;\n }\n\n return Component;\n };\n return func;\n};\n\nconst styledObject = Object.keys(styled_component).reduce((obj, key) => {\n const castedKey = key as keyof JSX.IntrinsicElements;\n obj[castedKey] = styledFunction(castedKey);\n return obj;\n}, {} as StyledObject);\n\nexport const styled: Styled = Object.assign(styledFunction, styledObject);\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,+BAA8D;AAE9D,0BAAsE;AACtE,mBAAuC;AAEvC,MAAM,iBAAiC,CAAC,KAAK,UAAU,EAAE,MAAM,MAAM,MAAM,WAAW;AACpF,QAAM,EAAE,MAAM,gBAAgB,MAAM,MAAM,gBAAgB,SAAS;AACnE,QAAM,OAAmC,CAAC,aAAa,gBAAgB;AAMrE,UAAM,8BAA8B,cAChC,YAAY,IAAgC,CAAC,cAC7C,OAAO,cAAc,aACjB,CAAC,UACD,UAAU;AAAA,SACL;AAAA,MACH,OAAO,yCAAuB,MAAM;AAAA,SAEtC,aAEJ;AAEJ,QAAI,sBAAsB;AAK1B,QAAI,iBAAiB,eAAe;AAClC,kCAA4B,KAAK,CAAC,UAAU;AAC1C,cAAM,QAAQ,yCAAuB,MAAM;AAC3C,cAAM,iBAAiB,2CAAkB,eAAe;AACxD,YAAI,gBAAgB;AAClB,iBAAO,CAAC,eAAe;AAAA;AAEzB,eAAO;AAAA;AAAA;AAOX,QAAI,iBAAiB,kBAAkB,QAAQ;AAC7C,kCAA4B,KAAK,CAAC,UAAU;AAC1C,cAAM,QAAQ,yCAAuB,MAAM;AAC3C,eAAO,0CAAiB,OAAO,0CAAiB,eAAe,QAAQ,OAAO;AAAA;AAAA;AAIlF,UAAM,wBAAwB,4BAA4B,SAAS,YAAY;AAE/E,QAAI,MAAM,QAAQ,aAAa,wBAAwB,GAAG;AAExD,YAAM,eAAyB,IAAI,MAAM,uBAAuB,KAAK;AACrE,4BAAsB,OAAO,OAAO,CAAC,GAAG,UAAU,GAAG,eAAe;AAAA,QAClE,KAAK,CAAC,GAAI,SAAkC,KAAK,GAAG;AAAA;AAAA,eAE7C,OAAO,aAAa,YAAY;AAEzC,4BAAsB,CAAC,UAAU,SAAS,KAAK,OAAO,OAAO,yCAAuB,MAAM;AAAA;AAE5F,QAAI,YAAY,sCAAiB;AAEjC,UAAM,cACJ,kBAAkB,QAAQ,kBAAkB,OAAO,GAAG,iBAAiB,kBAAkB;AAE3F,QAAI,gBAAgB,MAAM;AACxB,kBAAY,UAAU,MAAM,EAAE,WAAW,GAAG,gBAAgB;AAAA;AAK9D,gBAAY,UAAU,qBAAqB,GAAG;AAE9C,QAAI,gBAAgB,MAAM;AACxB,gBAAU,cAAc;AAAA;AAG1B,WAAO;AAAA;AAET,SAAO;AAAA;AAGT,MAAM,eAAe,OAAO,KAAK,kCAAkB,OAAO,CAAC,KAAK,QAAQ;AACtE,QAAM,YAAY;AAClB,MAAI,aAAa,eAAe;AAChC,SAAO;AAAA,GACN;AAEI,MAAM,SAAiB,OAAO,OAAO,gBAAgB;",
6
+ "names": []
7
+ }
@@ -1,44 +1,56 @@
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;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
16
11
  };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var styleGetters_exports = {};
29
+ __export(styleGetters_exports, {
30
+ getStyleOverrides: () => getStyleOverrides,
31
+ getVariantStyles: () => getVariantStyles,
32
+ variantsResolver: () => variantsResolver
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_utils = require("./utils");
36
+ const getStyleOverrides = (name, theme) => theme.components?.[name]?.styleOverrides || null;
17
37
  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) || [];
38
+ const variants = theme.components?.[name]?.variants || [];
21
39
  return variants.reduce((styles, definition) => {
22
- const key = utils.propsToClassKey(definition.props);
40
+ const key = (0, import_utils.propsToClassKey)(definition.props);
23
41
  styles[key] = definition.style;
24
42
  return styles;
25
43
  }, {});
26
44
  };
27
45
  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) || [];
46
+ const themeVariants = theme?.components?.[name]?.variants || [];
31
47
  return themeVariants.reduce((variantsStyles, themeVariant) => {
32
- const isMatch = Object.keys(themeVariant.props).every(key => props[key] === themeVariant.props[key]);
33
-
48
+ const isMatch = Object.keys(themeVariant.props).every((key) => props[key] === themeVariant.props[key]);
34
49
  if (isMatch) {
35
- variantsStyles.push(styles[utils.propsToClassKey(themeVariant.props)]);
50
+ variantsStyles.push(styles[(0, import_utils.propsToClassKey)(themeVariant.props)]);
36
51
  }
37
-
38
52
  return variantsStyles;
39
53
  }, []);
40
54
  };
41
-
42
- exports.getStyleOverrides = getStyleOverrides;
43
- exports.getVariantStyles = getVariantStyles;
44
- exports.variantsResolver = variantsResolver;
55
+ module.exports = __toCommonJS(styleGetters_exports);
56
+ //# sourceMappingURL=styleGetters.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styled/styleGetters.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/* eslint-disable max-params */\nimport type { Theme, CSSObject } from './types';\nimport { propsToClassKey } from './utils';\n\nexport const getStyleOverrides = (name: string, theme: Theme): CSSObject | null =>\n theme.components?.[name]?.styleOverrides || null;\n\nexport const getVariantStyles = (name: string, theme: Theme): Record<string, CSSObject> => {\n const variants = theme.components?.[name]?.variants || [];\n\n return variants.reduce((styles, definition) => {\n const key = propsToClassKey(definition.props);\n styles[key] = definition.style;\n return styles;\n }, {} as Record<string, CSSObject>);\n};\n\nexport const variantsResolver = (\n props: Record<string, unknown>,\n styles: CSSObject,\n theme: Theme,\n name: string,\n): CSSObject[keyof CSSObject][] => {\n const themeVariants = theme?.components?.[name]?.variants || [];\n\n return themeVariants.reduce((variantsStyles, themeVariant) => {\n const isMatch = Object.keys(themeVariant.props).every((key) => props[key] === themeVariant.props[key]);\n if (isMatch) {\n variantsStyles.push(styles[propsToClassKey(themeVariant.props)]);\n }\n return variantsStyles;\n }, [] as CSSObject[keyof CSSObject][]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAgC;AAEzB,MAAM,oBAAoB,CAAC,MAAc,UAC9C,MAAM,aAAa,OAAO,kBAAkB;AAEvC,MAAM,mBAAmB,CAAC,MAAc,UAA4C;AACzF,QAAM,WAAW,MAAM,aAAa,OAAO,YAAY;AAEvD,SAAO,SAAS,OAAO,CAAC,QAAQ,eAAe;AAC7C,UAAM,MAAM,kCAAgB,WAAW;AACvC,WAAO,OAAO,WAAW;AACzB,WAAO;AAAA,KACN;AAAA;AAGE,MAAM,mBAAmB,CAC9B,OACA,QACA,OACA,SACiC;AACjC,QAAM,gBAAgB,OAAO,aAAa,OAAO,YAAY;AAE7D,SAAO,cAAc,OAAO,CAAC,gBAAgB,iBAAiB;AAC5D,UAAM,UAAU,OAAO,KAAK,aAAa,OAAO,MAAM,CAAC,QAAQ,MAAM,SAAS,aAAa,MAAM;AACjG,QAAI,SAAS;AACX,qBAAe,KAAK,OAAO,kCAAgB,aAAa;AAAA;AAE1D,WAAO;AAAA,KACN;AAAA;",
6
+ "names": []
7
+ }
@@ -1,12 +1,35 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var styled_component = require('styled-components');
6
-
7
-
8
-
9
- Object.defineProperty(exports, 'CSSObject', {
10
- enumerable: true,
11
- get: function () { return styled_component.CSSObject; }
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var types_exports = {};
29
+ __export(types_exports, {
30
+ CSSObject: () => import_styled_components2.CSSObject
12
31
  });
32
+ var React = __toESM(require("react"));
33
+ var import_styled_components2 = require("styled-components");
34
+ module.exports = __toCommonJS(types_exports);
35
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styled/types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport type { Theme as PuiTheme } from '@elliemae/pui-theme';\nimport {\n AnyStyledComponent,\n CSSObject,\n Interpolation,\n InterpolationFunction,\n StyledComponent,\n StyledComponentInnerAttrs,\n StyledComponentInnerComponent,\n StyledComponentInnerOtherProps,\n StyledComponentPropsWithRef,\n ThemedStyledProps,\n} from 'styled-components';\n\nexport { CSSObject } from 'styled-components';\n\nexport interface Theme extends PuiTheme {\n components?: {\n [componentName: string]: {\n styleOverrides?: CSSObject;\n variants?: { props: Record<string, { toString: () => string }>; style: CSSObject }[];\n };\n };\n}\n\nexport type ThemedStyledFunctionBase<\n C extends keyof JSX.IntrinsicElements | React.ComponentType<any>,\n T extends object,\n O extends object = {},\n A extends keyof any = never,\n> = <U extends object = {}>(\n first:\n | TemplateStringsArray\n | CSSObject\n | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>,\n ...rest: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>\n) => StyledComponent<C, T, O & U, A>;\n\ntype ThemedStyledComponentFactories<T extends object> = {\n [TTag in keyof JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;\n};\n\nexport type StyledFunction = <C extends AnyStyledComponent | keyof JSX.IntrinsicElements | React.ComponentType<any>>(\n tag: C,\n options?: { name: string | null; slot: string | null; },\n) => ThemedStyledFunctionBase<\n C extends AnyStyledComponent ? StyledComponentInnerComponent<C> : C,\n Theme,\n C extends AnyStyledComponent ? StyledComponentInnerOtherProps<C> : {},\n C extends AnyStyledComponent ? StyledComponentInnerAttrs<C> : never\n>;\n\nexport type StyledObject = ThemedStyledComponentFactories<Theme>;\n\nexport type Styled = StyledFunction & StyledObject;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADevB,gCAA0B;",
6
+ "names": []
7
+ }
@@ -1,24 +1,47 @@
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]));
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
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;
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var utils_exports = {};
29
+ __export(utils_exports, {
30
+ coerceWithDefaultTheme: () => coerceWithDefaultTheme,
31
+ isEmpty: () => isEmpty,
32
+ propsToClassKey: () => propsToClassKey
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_ds_utilities = require("@elliemae/ds-utilities");
36
+ var import_theme = require("../theme");
37
+ const systemTheme = import_theme.theme;
38
+ const isEmpty = (string) => string.length === 0;
39
+ const coerceWithDefaultTheme = (themeInput) => themeInput ?? systemTheme;
40
+ const propsToClassKey = (props) => Object.keys(props).sort().reduce((classKey, key) => {
41
+ if (key === "color") {
42
+ return classKey + isEmpty(String(classKey)) ? String(props[key]) : (0, import_ds_utilities.capitalize)(String(props[key]));
43
+ }
44
+ return `${classKey}${isEmpty(String(classKey)) ? key : (0, import_ds_utilities.capitalize)(key)}${(0, import_ds_utilities.capitalize)(props[key].toString())}`;
45
+ }, "");
46
+ module.exports = __toCommonJS(utils_exports);
47
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/styled/utils.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { capitalize } from '@elliemae/ds-utilities';\nimport type { Theme } from './types';\nimport { theme as defaultTheme } from '../theme';\n\nconst systemTheme = defaultTheme;\n\nexport const isEmpty = (string: string): boolean => string.length === 0;\n\nexport const coerceWithDefaultTheme = (themeInput: Theme): Theme => themeInput ?? systemTheme;\n\nexport const propsToClassKey = (props: Record<string, { toString: () => string }>): string =>\n Object.keys(props)\n .sort()\n .reduce((classKey, key) => {\n if (key === 'color') {\n return classKey + isEmpty(String(classKey)) ? String(props[key]) : capitalize(String(props[key]));\n }\n return `${classKey}${isEmpty(String(classKey)) ? key : capitalize(key)}${capitalize(props[key].toString())}`;\n }, '');\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAA2B;AAE3B,mBAAsC;AAEtC,MAAM,cAAc;AAEb,MAAM,UAAU,CAAC,WAA4B,OAAO,WAAW;AAE/D,MAAM,yBAAyB,CAAC,eAA6B,cAAc;AAE3E,MAAM,kBAAkB,CAAC,UAC9B,OAAO,KAAK,OACT,OACA,OAAO,CAAC,UAAU,QAAQ;AACzB,MAAI,QAAQ,SAAS;AACnB,WAAO,WAAW,QAAQ,OAAO,aAAa,OAAO,MAAM,QAAQ,oCAAW,OAAO,MAAM;AAAA;AAE7F,SAAO,GAAG,WAAW,QAAQ,OAAO,aAAa,MAAM,oCAAW,OAAO,oCAAW,MAAM,KAAK;AAAA,GAC9F;",
6
+ "names": []
7
+ }
package/cjs/th.js CHANGED
@@ -1,32 +1,58 @@
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;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
21
11
  };
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;
12
+ var __reExport = (target, module2, copyDefault, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
16
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
17
+ }
18
+ return target;
19
+ };
20
+ var __toESM = (module2, isNodeMode) => {
21
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
22
+ };
23
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
24
+ return (module2, temp) => {
25
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
26
+ };
27
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
28
+ var th_exports = {};
29
+ __export(th_exports, {
30
+ th: () => th
31
+ });
32
+ var React = __toESM(require("react"));
33
+ const th = (property) => {
34
+ const thGetter = (value, dfault = "") => {
35
+ const func = ({ theme }) => {
36
+ const parts = value.split("-");
37
+ let result = theme[property];
38
+ parts.forEach((part) => {
39
+ if (result)
40
+ result = result[part];
41
+ });
42
+ return result ?? dfault;
43
+ };
44
+ return func;
45
+ };
46
+ return thGetter;
47
+ };
48
+ th.space = th("space");
49
+ th.fontSize = th("fontSizes");
50
+ th.fontWeight = th("fontWeights");
51
+ th.lineHeight = th("lineHeights");
52
+ th.letterSpacing = th("letterSpacings");
53
+ th.font = th("fonts");
54
+ th.color = th("colors");
55
+ th.breakpoint = th("breakpoints");
56
+ th.media = th("media");
57
+ module.exports = __toCommonJS(th_exports);
58
+ //# sourceMappingURL=th.js.map
package/cjs/th.js.map ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/th.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { Theme } from '@elliemae/pui-theme';\ntype ThGetter = (value: string, dfault?: string) => ({ theme }: { theme: Theme }) => string;\ntype ThConstructor = ((property: keyof Theme) => ThGetter) & {\n space: ThGetter;\n fontSize: ThGetter;\n fontWeight: ThGetter;\n lineHeight: ThGetter;\n letterSpacing: ThGetter;\n font: ThGetter;\n color: ThGetter;\n breakpoint: ThGetter;\n media: ThGetter;\n};\n\nexport const th: ThConstructor = (property): ThGetter => {\n const thGetter: ThGetter = (value, dfault = '') => {\n const func: ReturnType<ThGetter> = ({ theme }) => {\n const parts = value.split('-');\n let result = theme[property];\n parts.forEach((part) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n if (result) result = result[part as keyof typeof result];\n });\n return (result as unknown as string) ?? dfault;\n };\n return func;\n };\n return thGetter;\n};\nth.space = th('space');\nth.fontSize = th('fontSizes');\nth.fontWeight = th('fontWeights');\nth.lineHeight = th('lineHeights');\nth.letterSpacing = th('letterSpacings');\nth.font = th('fonts');\nth.color = th('colors');\nth.breakpoint = th('breakpoints');\nth.media = th('media');\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADchB,MAAM,KAAoB,CAAC,aAAuB;AACvD,QAAM,WAAqB,CAAC,OAAO,SAAS,OAAO;AACjD,UAAM,OAA6B,CAAC,EAAE,YAAY;AAChD,YAAM,QAAQ,MAAM,MAAM;AAC1B,UAAI,SAAS,MAAM;AACnB,YAAM,QAAQ,CAAC,SAAS;AAEtB,YAAI;AAAQ,mBAAS,OAAO;AAAA;AAE9B,aAAQ,UAAgC;AAAA;AAE1C,WAAO;AAAA;AAET,SAAO;AAAA;AAET,GAAG,QAAQ,GAAG;AACd,GAAG,WAAW,GAAG;AACjB,GAAG,aAAa,GAAG;AACnB,GAAG,aAAa,GAAG;AACnB,GAAG,gBAAgB,GAAG;AACtB,GAAG,OAAO,GAAG;AACb,GAAG,QAAQ,GAAG;AACd,GAAG,aAAa,GAAG;AACnB,GAAG,QAAQ,GAAG;",
6
+ "names": []
7
+ }