@elliemae/ds-classnames 2.0.1 → 2.1.0-rc.2
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 }; }
|
|
@@ -27,9 +27,9 @@ var DimsumConfig__default = /*#__PURE__*/_interopDefaultLegacy(DimsumConfig);
|
|
|
27
27
|
|
|
28
28
|
const _excluded = ["innerRef", "children", "classProps", "useComponent", "className", "as"];
|
|
29
29
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
30
|
+
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; }
|
|
31
31
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
32
|
+
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; }
|
|
33
33
|
const cssPrefix = DimsumConfig__default["default"].classNamePrefix;
|
|
34
34
|
|
|
35
35
|
const generateClassNameWithModifier = (block, element, modifier) => "".concat(cssPrefix, "-").concat(block).concat(element ? "__".concat(element) : '', "--").concat(modifier);
|
|
@@ -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;
|
|
@@ -13,9 +13,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
13
13
|
|
|
14
14
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
15
15
|
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
16
|
+
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; }
|
|
17
17
|
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
20
|
/* eslint-disable max-lines */
|
|
21
21
|
const attributeWhiteList = {
|
package/esm/aggregatedClasses.js
CHANGED
|
@@ -9,15 +9,15 @@ 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"];
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
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; }
|
|
19
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
20
|
+
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(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; }
|
|
21
21
|
const cssPrefix = DimsumConfig.classNamePrefix;
|
|
22
22
|
|
|
23
23
|
const generateClassNameWithModifier = (block, element, modifier) => "".concat(cssPrefix, "-").concat(block).concat(element ? "__".concat(element) : '', "--").concat(modifier);
|
|
@@ -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 };
|
|
@@ -5,9 +5,9 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
7
|
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
8
|
+
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; }
|
|
9
9
|
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
10
|
+
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(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; }
|
|
11
11
|
|
|
12
12
|
/* eslint-disable max-lines */
|
|
13
13
|
const attributeWhiteList = {
|
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.2",
|
|
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.2",
|
|
72
|
+
"@elliemae/ds-utilities": "2.1.0-rc.2",
|
|
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;
|