@elliemae/ds-system 2.0.0-rc.10 → 2.0.0-rc.11
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/styled/index.js +26 -35
- package/cjs/styled/types.js +12 -0
- package/esm/styled/index.js +26 -34
- package/esm/styled/types.js +1 -0
- package/package.json +5 -1
- package/types/styled/index.d.ts +1 -1
- package/types/styled/styleGetters.d.ts +4 -4
- package/types/styled/types.d.ts +28 -0
- package/types/styled/utils.d.ts +4 -2
- package/cjs/styled/index.d.js +0 -2
- package/esm/styled/index.d.js +0 -1
package/cjs/styled/index.js
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
7
6
|
require('core-js/modules/esnext.async-iterator.map.js');
|
|
8
7
|
require('core-js/modules/esnext.iterator.map.js');
|
|
9
8
|
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
11
10
|
require('core-js/modules/esnext.iterator.constructor.js');
|
|
12
|
-
require('core-js/modules/esnext.iterator.
|
|
11
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
13
12
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
14
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');
|
|
15
16
|
var styled_component = require('styled-components');
|
|
16
17
|
var styleGetters = require('./styleGetters.js');
|
|
17
18
|
var utils = require('./utils.js');
|
|
@@ -19,16 +20,13 @@ var utils = require('./utils.js');
|
|
|
19
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
21
|
|
|
21
22
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
22
|
-
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
23
23
|
var styled_component__default = /*#__PURE__*/_interopDefaultLegacy(styled_component);
|
|
24
24
|
|
|
25
|
-
const _excluded = ["theme"],
|
|
26
|
-
_excluded2 = ["theme"];
|
|
27
|
-
|
|
28
25
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
29
26
|
|
|
30
27
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
|
-
|
|
28
|
+
|
|
29
|
+
const styledFunction = function (tag) {
|
|
32
30
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
33
31
|
name: null,
|
|
34
32
|
slot: null
|
|
@@ -37,7 +35,8 @@ const styled = function (tag) {
|
|
|
37
35
|
name: componentName,
|
|
38
36
|
slot: componentSlot
|
|
39
37
|
} = options;
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
const func = function (styleArg) {
|
|
41
40
|
for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
42
41
|
expressions[_key - 1] = arguments[_key];
|
|
43
42
|
}
|
|
@@ -47,16 +46,9 @@ const styled = function (tag) {
|
|
|
47
46
|
* We just coerce with the default theme in case users
|
|
48
47
|
* forget to add the ThemeProvider
|
|
49
48
|
*/
|
|
50
|
-
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ?
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
} = _ref,
|
|
54
|
-
other = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
55
|
-
|
|
56
|
-
return stylesArg(_objectSpread({
|
|
57
|
-
theme: utils.coerceWithDefaultTheme(themeInput)
|
|
58
|
-
}, other));
|
|
59
|
-
} : stylesArg) : [];
|
|
49
|
+
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? props => stylesArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
50
|
+
theme: utils.coerceWithDefaultTheme(props.theme)
|
|
51
|
+
})) : stylesArg) : [];
|
|
60
52
|
let transformedStyleArg = styleArg;
|
|
61
53
|
/*
|
|
62
54
|
* Here we get the style overrides from the user
|
|
@@ -91,20 +83,14 @@ const styled = function (tag) {
|
|
|
91
83
|
if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
|
|
92
84
|
// Here we are adding placeholders for all the new functions that we are gonna call
|
|
93
85
|
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
94
|
-
transformedStyleArg = [...styleArg, ...placeholders]
|
|
95
|
-
|
|
86
|
+
transformedStyleArg = Object.assign([...styleArg, ...placeholders], {
|
|
87
|
+
raw: [...styleArg.raw, ...placeholders]
|
|
88
|
+
});
|
|
96
89
|
} else if (typeof styleArg === 'function') {
|
|
97
90
|
// Here we just coerce with the default theme
|
|
98
|
-
transformedStyleArg =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} = _ref2,
|
|
102
|
-
other = _objectWithoutProperties__default["default"](_ref2, _excluded2);
|
|
103
|
-
|
|
104
|
-
return styleArg(_objectSpread({
|
|
105
|
-
theme: utils.coerceWithDefaultTheme(themeInput)
|
|
106
|
-
}, other));
|
|
107
|
-
};
|
|
91
|
+
transformedStyleArg = props => styleArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
92
|
+
theme: utils.coerceWithDefaultTheme(props.theme)
|
|
93
|
+
}));
|
|
108
94
|
}
|
|
109
95
|
|
|
110
96
|
const Component = /*#__PURE__*/styled_component__default["default"](tag).attrs({
|
|
@@ -114,10 +100,15 @@ const styled = function (tag) {
|
|
|
114
100
|
})(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
115
101
|
return Component;
|
|
116
102
|
};
|
|
117
|
-
}; // Here we setup the necessary keys so we can continue using styled.button, styled.span, etc.
|
|
118
103
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
return func;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const styledObject = Object.keys(styled_component__default["default"]).reduce((obj, key) => {
|
|
108
|
+
const castedKey = key;
|
|
109
|
+
obj[castedKey] = styledFunction(castedKey);
|
|
110
|
+
return obj;
|
|
111
|
+
}, {});
|
|
112
|
+
const styled = Object.assign(styledFunction, styledObject);
|
|
122
113
|
|
|
123
114
|
exports.styled = styled;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styled_component = require('styled-components');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'CSSObject', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return styled_component.CSSObject; }
|
|
12
|
+
});
|
package/esm/styled/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
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';
|
|
3
5
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
5
6
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
6
7
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
7
8
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
8
|
-
import 'core-js/modules/esnext.async-iterator.
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
9
10
|
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
10
|
-
import 'core-js/modules/esnext.iterator.
|
|
11
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
12
|
import styled_component from 'styled-components';
|
|
12
13
|
import { getStyleOverrides, variantsResolver, getVariantStyles } from './styleGetters.js';
|
|
13
14
|
import { coerceWithDefaultTheme } from './utils.js';
|
|
14
15
|
|
|
15
|
-
const _excluded = ["theme"],
|
|
16
|
-
_excluded2 = ["theme"];
|
|
17
|
-
|
|
18
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; }
|
|
19
17
|
|
|
20
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; }
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
const styledFunction = function (tag) {
|
|
22
21
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
23
22
|
name: null,
|
|
24
23
|
slot: null
|
|
@@ -27,7 +26,8 @@ const styled = function (tag) {
|
|
|
27
26
|
name: componentName,
|
|
28
27
|
slot: componentSlot
|
|
29
28
|
} = options;
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
const func = function (styleArg) {
|
|
31
31
|
for (var _len = arguments.length, expressions = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
32
32
|
expressions[_key - 1] = arguments[_key];
|
|
33
33
|
}
|
|
@@ -37,16 +37,9 @@ const styled = function (tag) {
|
|
|
37
37
|
* We just coerce with the default theme in case users
|
|
38
38
|
* forget to add the ThemeProvider
|
|
39
39
|
*/
|
|
40
|
-
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ?
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = _ref,
|
|
44
|
-
other = _objectWithoutProperties(_ref, _excluded);
|
|
45
|
-
|
|
46
|
-
return stylesArg(_objectSpread({
|
|
47
|
-
theme: coerceWithDefaultTheme(themeInput)
|
|
48
|
-
}, other));
|
|
49
|
-
} : stylesArg) : [];
|
|
40
|
+
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => typeof stylesArg === 'function' ? props => stylesArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
41
|
+
theme: coerceWithDefaultTheme(props.theme)
|
|
42
|
+
})) : stylesArg) : [];
|
|
50
43
|
let transformedStyleArg = styleArg;
|
|
51
44
|
/*
|
|
52
45
|
* Here we get the style overrides from the user
|
|
@@ -81,20 +74,14 @@ const styled = function (tag) {
|
|
|
81
74
|
if (Array.isArray(styleArg) && numOfCustomFnsApplied > 0) {
|
|
82
75
|
// Here we are adding placeholders for all the new functions that we are gonna call
|
|
83
76
|
const placeholders = new Array(numOfCustomFnsApplied).fill('');
|
|
84
|
-
transformedStyleArg = [...styleArg, ...placeholders]
|
|
85
|
-
|
|
77
|
+
transformedStyleArg = Object.assign([...styleArg, ...placeholders], {
|
|
78
|
+
raw: [...styleArg.raw, ...placeholders]
|
|
79
|
+
});
|
|
86
80
|
} else if (typeof styleArg === 'function') {
|
|
87
81
|
// Here we just coerce with the default theme
|
|
88
|
-
transformedStyleArg =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} = _ref2,
|
|
92
|
-
other = _objectWithoutProperties(_ref2, _excluded2);
|
|
93
|
-
|
|
94
|
-
return styleArg(_objectSpread({
|
|
95
|
-
theme: coerceWithDefaultTheme(themeInput)
|
|
96
|
-
}, other));
|
|
97
|
-
};
|
|
82
|
+
transformedStyleArg = props => styleArg(_objectSpread(_objectSpread({}, props), {}, {
|
|
83
|
+
theme: coerceWithDefaultTheme(props.theme)
|
|
84
|
+
}));
|
|
98
85
|
}
|
|
99
86
|
|
|
100
87
|
const Component = /*#__PURE__*/styled_component(tag).attrs({
|
|
@@ -104,10 +91,15 @@ const styled = function (tag) {
|
|
|
104
91
|
})(transformedStyleArg, ...expressionsWithDefaultTheme);
|
|
105
92
|
return Component;
|
|
106
93
|
};
|
|
107
|
-
}; // Here we setup the necessary keys so we can continue using styled.button, styled.span, etc.
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
95
|
+
return func;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const styledObject = Object.keys(styled_component).reduce((obj, key) => {
|
|
99
|
+
const castedKey = key;
|
|
100
|
+
obj[castedKey] = styledFunction(castedKey);
|
|
101
|
+
return obj;
|
|
102
|
+
}, {});
|
|
103
|
+
const styled = Object.assign(styledFunction, styledObject);
|
|
112
104
|
|
|
113
105
|
export { styled };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CSSObject } from 'styled-components';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-system",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - System",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"import": "./esm/styled/utils.js",
|
|
32
32
|
"require": "./cjs/styled/utils.js"
|
|
33
33
|
},
|
|
34
|
+
"./styled/types": {
|
|
35
|
+
"import": "./esm/styled/types.js",
|
|
36
|
+
"require": "./cjs/styled/types.js"
|
|
37
|
+
},
|
|
34
38
|
"./styled/styleGetters": {
|
|
35
39
|
"import": "./esm/styled/styleGetters.js",
|
|
36
40
|
"require": "./cjs/styled/styleGetters.js"
|
package/types/styled/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Styled } from './
|
|
1
|
+
import { Styled } from './types';
|
|
2
2
|
export declare const styled: Styled;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const getStyleOverrides: (name: string, theme: Theme) =>
|
|
3
|
-
export declare const getVariantStyles: (name: string, theme: Theme) => Record<string,
|
|
4
|
-
export declare const variantsResolver: (props: Record<string, unknown>, styles:
|
|
1
|
+
import type { Theme, CSSObject } from './types';
|
|
2
|
+
export declare const getStyleOverrides: (name: string, theme: Theme) => CSSObject | null;
|
|
3
|
+
export declare const getVariantStyles: (name: string, theme: Theme) => Record<string, CSSObject>;
|
|
4
|
+
export declare const variantsResolver: (props: Record<string, unknown>, styles: CSSObject, theme: Theme, name: string) => CSSObject[keyof CSSObject][];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Theme as PuiTheme } from '@elliemae/pui-theme';
|
|
3
|
+
import { AnyStyledComponent, CSSObject, Interpolation, InterpolationFunction, StyledComponent, StyledComponentInnerAttrs, StyledComponentInnerComponent, StyledComponentInnerOtherProps, StyledComponentPropsWithRef, ThemedStyledProps } from 'styled-components';
|
|
4
|
+
export { CSSObject } from 'styled-components';
|
|
5
|
+
export interface Theme extends PuiTheme {
|
|
6
|
+
components?: {
|
|
7
|
+
[componentName: string]: {
|
|
8
|
+
styleOverrides?: CSSObject;
|
|
9
|
+
variants?: {
|
|
10
|
+
props: Record<string, {
|
|
11
|
+
toString: () => string;
|
|
12
|
+
}>;
|
|
13
|
+
style: CSSObject;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare type ThemedStyledFunctionBase<C extends keyof JSX.IntrinsicElements | React.ComponentType<any>, T extends object, O extends object = {}, A extends keyof any = never> = <U extends object = {}>(first: TemplateStringsArray | CSSObject | InterpolationFunction<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>, ...rest: Array<Interpolation<ThemedStyledProps<StyledComponentPropsWithRef<C> & O & U, T>>>) => StyledComponent<C, T, O & U, A>;
|
|
19
|
+
declare type ThemedStyledComponentFactories<T extends object> = {
|
|
20
|
+
[TTag in keyof JSX.IntrinsicElements]: ThemedStyledFunctionBase<TTag, T>;
|
|
21
|
+
};
|
|
22
|
+
export declare type StyledFunction = <C extends AnyStyledComponent | keyof JSX.IntrinsicElements | React.ComponentType<any>>(tag: C, options?: {
|
|
23
|
+
name: string | null;
|
|
24
|
+
slot: string | null;
|
|
25
|
+
}) => ThemedStyledFunctionBase<C extends AnyStyledComponent ? StyledComponentInnerComponent<C> : C, Theme, C extends AnyStyledComponent ? StyledComponentInnerOtherProps<C> : {}, C extends AnyStyledComponent ? StyledComponentInnerAttrs<C> : never>;
|
|
26
|
+
export interface StyledObject extends ThemedStyledComponentFactories<Theme> {
|
|
27
|
+
}
|
|
28
|
+
export declare type Styled = StyledFunction & StyledObject;
|
package/types/styled/utils.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Theme } from '
|
|
1
|
+
import type { Theme } from './types';
|
|
2
2
|
export declare const isEmpty: (string: string) => boolean;
|
|
3
3
|
export declare const coerceWithDefaultTheme: (themeInput: Theme) => Theme;
|
|
4
|
-
export declare const propsToClassKey: (props: Record<string,
|
|
4
|
+
export declare const propsToClassKey: (props: Record<string, {
|
|
5
|
+
toString: () => string;
|
|
6
|
+
}>) => string;
|
package/cjs/styled/index.d.js
DELETED
package/esm/styled/index.d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|