@elliemae/ds-classnames 2.0.2 → 2.1.0-rc.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.
package/cjs/aggregatedClasses.js
CHANGED
|
@@ -13,8 +13,8 @@ require('core-js/modules/esnext.async-iterator.filter.js');
|
|
|
13
13
|
require('core-js/modules/esnext.iterator.filter.js');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('obj-str');
|
|
16
|
-
var classNameManager = require('./classNameManager.js');
|
|
17
16
|
var DimsumConfig = require('@elliemae/ds-shared/dimsum.config');
|
|
17
|
+
var classNameManager = require('./classNameManager.js');
|
|
18
18
|
var validateNativeProps = require('./validateNativeProps.js');
|
|
19
19
|
|
|
20
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -38,57 +38,54 @@ const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj
|
|
|
38
38
|
["".concat(generateClassNameWithModifier(block, element, key))]: obj[key]
|
|
39
39
|
}), {}) : [];
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
element
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
74
|
-
|
|
75
|
-
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
76
|
-
delete cleanedPropsPassedDown[propKey];
|
|
77
|
-
});
|
|
41
|
+
const aggregatedClasses = (type, props) => function (block, element, additionalModifiers) {
|
|
42
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
43
|
+
return /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
44
|
+
let {
|
|
45
|
+
innerRef,
|
|
46
|
+
children,
|
|
47
|
+
classProps,
|
|
48
|
+
useComponent,
|
|
49
|
+
className,
|
|
50
|
+
as
|
|
51
|
+
} = _ref,
|
|
52
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
53
|
+
|
|
54
|
+
// get the additional classNames either from a function or an object
|
|
55
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
56
|
+
if (typeof additionalModifiers === 'function') otherModifiers = appendBlockAndPrefixToObj(additionalModifiers(_objectSpread(_objectSpread(_objectSpread({}, rest), classProps), {}, {
|
|
57
|
+
className
|
|
58
|
+
})), block, element);
|
|
59
|
+
const otherModifiersStr = cx__default["default"](otherModifiers);
|
|
60
|
+
const {
|
|
61
|
+
prefix,
|
|
62
|
+
propsToRemoveFromFinalElement = []
|
|
63
|
+
} = options;
|
|
64
|
+
const {
|
|
65
|
+
cssClassName: classNames
|
|
66
|
+
} = classNameManager["default"](block, null, _objectSpread({}, classProps), {
|
|
67
|
+
prefix,
|
|
68
|
+
element
|
|
69
|
+
});
|
|
78
70
|
|
|
79
|
-
|
|
80
|
-
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
81
|
-
if (!validateNativeProps.isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
82
|
-
});
|
|
83
|
-
}
|
|
71
|
+
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
className: [classNames, otherModifiersStr, className].join(' ')
|
|
88
|
-
}, cleanedPropsPassedDown), children);
|
|
73
|
+
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
74
|
+
delete cleanedPropsPassedDown[propKey];
|
|
89
75
|
});
|
|
90
|
-
|
|
91
|
-
|
|
76
|
+
|
|
77
|
+
if (validateNativeProps.isNativeHTMLElement(block)) {
|
|
78
|
+
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
79
|
+
if (!validateNativeProps.isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return /*#__PURE__*/React__default["default"].createElement(as || type, _objectSpread({
|
|
84
|
+
ref: innerRef || ref,
|
|
85
|
+
className: [classNames, otherModifiersStr, className].join(' ')
|
|
86
|
+
}, cleanedPropsPassedDown), children);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
92
89
|
|
|
93
90
|
exports.cssPrefix = cssPrefix;
|
|
94
91
|
exports["default"] = aggregatedClasses;
|
package/esm/aggregatedClasses.js
CHANGED
|
@@ -9,8 +9,8 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
9
9
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import cx from 'obj-str';
|
|
12
|
-
import cssPipeline from './classNameManager.js';
|
|
13
12
|
import DimsumConfig from '@elliemae/ds-shared/dimsum.config';
|
|
13
|
+
import cssPipeline from './classNameManager.js';
|
|
14
14
|
import { isNativeHTMLElement, isValidNativeAttribute } from './validateNativeProps.js';
|
|
15
15
|
|
|
16
16
|
const _excluded = ["innerRef", "children", "classProps", "useComponent", "className", "as"];
|
|
@@ -26,56 +26,53 @@ const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj
|
|
|
26
26
|
["".concat(generateClassNameWithModifier(block, element, key))]: obj[key]
|
|
27
27
|
}), {}) : [];
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = _ref,
|
|
42
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
const aggregatedClasses = (type, props) => function (block, element, additionalModifiers) {
|
|
30
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
31
|
+
return /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
32
|
+
let {
|
|
33
|
+
innerRef,
|
|
34
|
+
children,
|
|
35
|
+
classProps,
|
|
36
|
+
useComponent,
|
|
37
|
+
className,
|
|
38
|
+
as
|
|
39
|
+
} = _ref,
|
|
40
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
// get the additional classNames either from a function or an object
|
|
43
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
44
|
+
if (typeof additionalModifiers === 'function') otherModifiers = appendBlockAndPrefixToObj(additionalModifiers(_objectSpread(_objectSpread(_objectSpread({}, rest), classProps), {}, {
|
|
45
|
+
className
|
|
46
|
+
})), block, element);
|
|
47
|
+
const otherModifiersStr = cx(otherModifiers);
|
|
48
|
+
const {
|
|
49
|
+
prefix,
|
|
50
|
+
propsToRemoveFromFinalElement = []
|
|
51
|
+
} = options;
|
|
52
|
+
const {
|
|
53
|
+
cssClassName: classNames
|
|
54
|
+
} = cssPipeline(block, null, _objectSpread({}, classProps), {
|
|
55
|
+
prefix,
|
|
56
|
+
element
|
|
57
|
+
});
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
62
|
+
delete cleanedPropsPassedDown[propKey];
|
|
63
|
+
});
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
if (isNativeHTMLElement(block)) {
|
|
66
|
+
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
67
|
+
if (!isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
68
|
+
});
|
|
69
|
+
}
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
71
|
+
return /*#__PURE__*/React.createElement(as || type, _objectSpread({
|
|
72
|
+
ref: innerRef || ref,
|
|
73
|
+
className: [classNames, otherModifiersStr, className].join(' ')
|
|
74
|
+
}, cleanedPropsPassedDown), children);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
80
77
|
|
|
81
78
|
export { cssPrefix, aggregatedClasses as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-classnames",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.1.0-rc.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum Library - Aggregated classNames to component",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@elliemae/ds-shared": "2.0.
|
|
72
|
-
"@elliemae/ds-utilities": "2.0.
|
|
71
|
+
"@elliemae/ds-shared": "2.1.0-rc.3",
|
|
72
|
+
"@elliemae/ds-utilities": "2.1.0-rc.3",
|
|
73
73
|
"obj-str": "~1.0.3"
|
|
74
74
|
},
|
|
75
75
|
"publishConfig": {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const cssPrefix: any;
|
|
3
|
-
declare
|
|
3
|
+
declare type AggregatedClassesT<T = unknown> = (type: any, props?: any) => (block: string, element?: string | null, additionalModifiers?: {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
} | ((arg: any) => {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}), options?: {
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}) => React.ForwardRefExoticComponent<React.RefAttributes<T>>;
|
|
10
|
+
declare const aggregatedClasses: AggregatedClassesT;
|
|
4
11
|
export default aggregatedClasses;
|
|
@@ -10,7 +10,11 @@ export declare const cssPrefix: string;
|
|
|
10
10
|
* @param props
|
|
11
11
|
* @param options
|
|
12
12
|
*/
|
|
13
|
-
declare const cssPipeline: (blockName?: string, cssClassNameModifier?: string, props?: {
|
|
13
|
+
declare const cssPipeline: (blockName?: string, cssClassNameModifier?: string, props?: {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}, options?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}) => {
|
|
14
18
|
blockName: string;
|
|
15
19
|
cssPrefix: string;
|
|
16
20
|
prefixBlockName: string;
|