@elliemae/ds-classnames 2.0.0-alpha.9 → 2.0.0-next.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/aggregatedClasses.js +53 -43
- package/cjs/classNameManager.js +22 -13
- package/cjs/converPropsToFormModifiers.js +11 -5
- package/cjs/convertPropToFeedBackModifiers.js +13 -7
- package/cjs/convertPropsToColorModifiers.js +10 -4
- package/cjs/convertPropsToLayoutModifiers.js +13 -7
- package/cjs/convertPropsToSizeModifiers.js +17 -11
- package/cjs/convertPropsToTextModifiers.js +12 -6
- package/cjs/index.js +1 -0
- package/cjs/validateNativeProps.js +5 -0
- package/esm/aggregatedClasses.js +52 -42
- package/esm/classNameManager.js +22 -13
- package/esm/converPropsToFormModifiers.js +11 -5
- package/esm/convertPropToFeedBackModifiers.js +13 -7
- package/esm/convertPropsToColorModifiers.js +10 -4
- package/esm/convertPropsToLayoutModifiers.js +13 -7
- package/esm/convertPropsToSizeModifiers.js +17 -11
- package/esm/convertPropsToTextModifiers.js +12 -6
- package/esm/index.js +1 -1
- package/esm/validateNativeProps.js +5 -0
- package/package.json +3 -3
- package/types/index.d.ts +1 -1
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
package/cjs/aggregatedClasses.js
CHANGED
|
@@ -4,6 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
6
6
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
7
14
|
var React = require('react');
|
|
8
15
|
var cx = require('obj-str');
|
|
9
16
|
var classNameManager = require('./classNameManager.js');
|
|
@@ -25,59 +32,62 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
25
32
|
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; }
|
|
26
33
|
const cssPrefix = DimsumConfig__default["default"].classNamePrefix;
|
|
27
34
|
|
|
28
|
-
const generateClassNameWithModifier = (block, element, modifier) =>
|
|
35
|
+
const generateClassNameWithModifier = (block, element, modifier) => "".concat(cssPrefix, "-").concat(block).concat(element ? "__".concat(element) : '', "--").concat(modifier);
|
|
29
36
|
|
|
30
37
|
const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj).reduce((acc, key) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
31
|
-
[
|
|
38
|
+
["".concat(generateClassNameWithModifier(block, element, key))]: obj[key]
|
|
32
39
|
}), {}) : [];
|
|
33
40
|
|
|
34
41
|
function aggregatedClasses(type, props) {
|
|
35
42
|
// aggregatedClasses options parameters
|
|
36
|
-
return (block, element, additionalModifiers
|
|
37
|
-
let {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
return function (block, element, additionalModifiers) {
|
|
44
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
45
|
+
return /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
|
|
46
|
+
let {
|
|
47
|
+
innerRef,
|
|
48
|
+
children,
|
|
49
|
+
classProps,
|
|
50
|
+
useComponent,
|
|
51
|
+
className,
|
|
52
|
+
as
|
|
53
|
+
} = _ref,
|
|
54
|
+
rest = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
55
|
+
|
|
56
|
+
// get the additional classNames either from a function or an object
|
|
57
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
58
|
+
if (typeof additionalModifiers === 'function') otherModifiers = appendBlockAndPrefixToObj(additionalModifiers(_objectSpread(_objectSpread(_objectSpread({}, rest), classProps), {}, {
|
|
59
|
+
className
|
|
60
|
+
})), block, element);
|
|
61
|
+
const otherModifiersStr = cx__default["default"](otherModifiers);
|
|
62
|
+
const {
|
|
63
|
+
prefix,
|
|
64
|
+
propsToRemoveFromFinalElement = []
|
|
65
|
+
} = options;
|
|
66
|
+
const {
|
|
67
|
+
cssClassName: classNames
|
|
68
|
+
} = classNameManager["default"](block, null, _objectSpread({}, classProps), {
|
|
69
|
+
prefix,
|
|
70
|
+
element
|
|
71
|
+
});
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
delete cleanedPropsPassedDown[propKey];
|
|
68
|
-
});
|
|
73
|
+
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!validateNativeProps.isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
75
|
+
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
76
|
+
delete cleanedPropsPassedDown[propKey];
|
|
73
77
|
});
|
|
74
|
-
}
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
if (validateNativeProps.isNativeHTMLElement(block)) {
|
|
80
|
+
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
81
|
+
if (!validateNativeProps.isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return /*#__PURE__*/React__default["default"].createElement(as || type, _objectSpread({
|
|
86
|
+
ref: innerRef || ref,
|
|
87
|
+
className: [classNames, otherModifiersStr, className].join(' ')
|
|
88
|
+
}, cleanedPropsPassedDown), children);
|
|
89
|
+
});
|
|
90
|
+
};
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
exports.cssPrefix = cssPrefix;
|
package/cjs/classNameManager.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
5
6
|
var utils = require('@elliemae/ds-utilities/utils');
|
|
6
7
|
var DimsumConfig = require('@elliemae/ds-shared/dimsum.config');
|
|
7
8
|
var converPropsToFormModifiers = require('./converPropsToFormModifiers.js');
|
|
@@ -15,7 +16,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
15
16
|
|
|
16
17
|
var DimsumConfig__default = /*#__PURE__*/_interopDefaultLegacy(DimsumConfig);
|
|
17
18
|
|
|
18
|
-
const cssPrefix =
|
|
19
|
+
const cssPrefix = "".concat(DimsumConfig__default["default"].classNamePrefix, "-");
|
|
19
20
|
|
|
20
21
|
const executePipelines = props => {
|
|
21
22
|
const form = converPropsToFormModifiers().execute(props);
|
|
@@ -39,17 +40,21 @@ const executePipelines = props => {
|
|
|
39
40
|
*/
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
const cssPipeline = (
|
|
43
|
+
const cssPipeline = function () {
|
|
44
|
+
let blockName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'block';
|
|
45
|
+
let cssClassNameModifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
46
|
+
let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
47
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
43
48
|
const {
|
|
44
49
|
prefix,
|
|
45
50
|
element
|
|
46
51
|
} = options;
|
|
47
|
-
const prefixBlockName =
|
|
52
|
+
const prefixBlockName = "".concat(prefix || cssPrefix).concat(blockName).concat(element ? "__".concat(element) : ''); // PipeLine
|
|
48
53
|
|
|
49
54
|
const pipes = !utils.isEmpty(props) ? executePipelines(props) : [];
|
|
50
55
|
const basePipeline = [prefixBlockName, ...pipes]; // specific classname
|
|
51
56
|
|
|
52
|
-
const className = cssClassNameModifier ? [...basePipeline].join(
|
|
57
|
+
const className = cssClassNameModifier ? [...basePipeline].join(" ".concat(prefixBlockName, "--")).concat(" ".concat(cssClassNameModifier)) : [...basePipeline].join(" ".concat(prefixBlockName, "--"));
|
|
53
58
|
return {
|
|
54
59
|
blockName,
|
|
55
60
|
cssPrefix,
|
|
@@ -57,23 +62,27 @@ const cssPipeline = (blockName = 'block', cssClassNameModifier = '', props = {},
|
|
|
57
62
|
cssClassName: className,
|
|
58
63
|
|
|
59
64
|
mainModifier(modifier) {
|
|
60
|
-
return
|
|
65
|
+
return "".concat(className, "--").concat(modifier);
|
|
61
66
|
},
|
|
62
67
|
|
|
63
|
-
classNameBlock(elementName
|
|
64
|
-
|
|
68
|
+
classNameBlock(elementName) {
|
|
69
|
+
let usePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
70
|
+
return "".concat(!usePrefix ? blockName : prefixBlockName, "-").concat(elementName);
|
|
65
71
|
},
|
|
66
72
|
|
|
67
|
-
classNameBlockModifier(modifierName
|
|
68
|
-
|
|
73
|
+
classNameBlockModifier(modifierName) {
|
|
74
|
+
let elementBlockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
75
|
+
return "".concat(prefixBlockName, "-").concat(elementBlockName, "--").concat(modifierName);
|
|
69
76
|
},
|
|
70
77
|
|
|
71
|
-
classNameElement(elementName
|
|
72
|
-
|
|
78
|
+
classNameElement(elementName) {
|
|
79
|
+
let elementBlockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
80
|
+
return "".concat(prefixBlockName).concat(elementBlockName ? "-".concat(elementBlockName) : '', "__").concat(elementName);
|
|
73
81
|
},
|
|
74
82
|
|
|
75
|
-
classNameModifier(modifierName
|
|
76
|
-
|
|
83
|
+
classNameModifier(modifierName) {
|
|
84
|
+
let elementName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
85
|
+
return "".concat(prefixBlockName).concat(elementName ? "__".concat(elementName) : '', "--").concat(modifierName);
|
|
77
86
|
}
|
|
78
87
|
|
|
79
88
|
};
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
readOnly = false,
|
|
11
|
+
disabled = false,
|
|
12
|
+
checked = false
|
|
13
|
+
} = _ref;
|
|
8
14
|
const cssModifier = []; // input state modifiers
|
|
9
15
|
|
|
10
16
|
if (checked) cssModifier.push('checked');
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
hasError = false,
|
|
11
|
+
hasWarning = false,
|
|
12
|
+
hasSuccess = false,
|
|
13
|
+
modalType
|
|
14
|
+
} = _ref;
|
|
9
15
|
const cssModifier = []; // valid state modifier
|
|
10
16
|
|
|
11
17
|
if (hasError) cssModifier.push('error');else if (hasWarning) cssModifier.push('warning');else if (hasSuccess) cssModifier.push('success');
|
|
12
|
-
if (modalType) cssModifier.push(
|
|
18
|
+
if (modalType) cssModifier.push("modal-type-".concat(modalType));
|
|
13
19
|
return cssModifier;
|
|
14
20
|
};
|
|
15
21
|
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
color = null
|
|
11
|
+
} = _ref;
|
|
6
12
|
const cssModifier = [];
|
|
7
13
|
|
|
8
14
|
if (color && color[0]) {
|
|
9
|
-
if (color[1] !== null) cssModifier.push(
|
|
15
|
+
if (color[1] !== null) cssModifier.push("color-".concat(color[0], "-").concat(color[1]));else cssModifier.push("color-".concat(color[0]));
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
return cssModifier;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
id,
|
|
11
|
+
buttonType = 'default',
|
|
12
|
+
fluidWidth = false,
|
|
13
|
+
fluidHeight = false
|
|
14
|
+
} = _ref;
|
|
9
15
|
const cssModifier = []; // buttons types
|
|
10
16
|
|
|
11
|
-
if (id) cssModifier.push(
|
|
17
|
+
if (id) cssModifier.push("id-".concat(id));
|
|
12
18
|
if (buttonType) cssModifier.push(buttonType);
|
|
13
19
|
if (fluidWidth) cssModifier.push('fluid-width');
|
|
14
20
|
if (fluidHeight) cssModifier.push('fluid-height');
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
size = null,
|
|
11
|
+
extraTight = false,
|
|
12
|
+
tight = false,
|
|
13
|
+
base = false,
|
|
14
|
+
bitLoose = false,
|
|
15
|
+
loose = false,
|
|
16
|
+
extraLoose = false,
|
|
17
|
+
superLoose = false
|
|
18
|
+
} = _ref;
|
|
13
19
|
const cssModifier = [];
|
|
14
|
-
if (size) cssModifier.push(
|
|
20
|
+
if (size) cssModifier.push("".concat(size)); // Size as Flag
|
|
15
21
|
|
|
16
22
|
if (extraTight) cssModifier.push('size-extra-tight');else if (tight) cssModifier.push('size-tight');else if (base) cssModifier.push('size-base');else if (bitLoose) cssModifier.push('size-bit-loose');else if (loose) cssModifier.push('size-loose');else if (extraLoose) cssModifier.push('size-extra-loose');else if (superLoose) cssModifier.push('size-super-loose');
|
|
17
23
|
return cssModifier;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
6
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
+
|
|
8
|
+
const basicAction = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
textEllipsis,
|
|
11
|
+
textAlignment,
|
|
12
|
+
wordBreak
|
|
13
|
+
} = _ref;
|
|
8
14
|
const cssModifier = [];
|
|
9
15
|
if (textEllipsis) cssModifier.push('text-overflow-ellipsis');
|
|
10
16
|
if (wordBreak) cssModifier.push('text-overflow-word-break');
|
|
11
|
-
if (['left', 'right', 'center', 'justify'].indexOf(textAlignment) > -1) cssModifier.push(
|
|
17
|
+
if (['left', 'right', 'center', 'justify'].indexOf(textAlignment) > -1) cssModifier.push("text-align-".concat(textAlignment));
|
|
12
18
|
return cssModifier;
|
|
13
19
|
};
|
|
14
20
|
|
package/cjs/index.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
|
|
7
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
package/esm/aggregatedClasses.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
1
3
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
2
4
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
3
10
|
import React from 'react';
|
|
4
11
|
import cx from 'obj-str';
|
|
5
12
|
import cssPipeline from './classNameManager.js';
|
|
@@ -13,59 +20,62 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
20
|
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; }
|
|
14
21
|
const cssPrefix = DimsumConfig.classNamePrefix;
|
|
15
22
|
|
|
16
|
-
const generateClassNameWithModifier = (block, element, modifier) =>
|
|
23
|
+
const generateClassNameWithModifier = (block, element, modifier) => "".concat(cssPrefix, "-").concat(block).concat(element ? "__".concat(element) : '', "--").concat(modifier);
|
|
17
24
|
|
|
18
25
|
const appendBlockAndPrefixToObj = (obj, block, element) => obj ? Object.keys(obj).reduce((acc, key) => _objectSpread(_objectSpread({}, acc), {}, {
|
|
19
|
-
[
|
|
26
|
+
["".concat(generateClassNameWithModifier(block, element, key))]: obj[key]
|
|
20
27
|
}), {}) : [];
|
|
21
28
|
|
|
22
29
|
function aggregatedClasses(type, props) {
|
|
23
30
|
// aggregatedClasses options parameters
|
|
24
|
-
return (block, element, additionalModifiers
|
|
25
|
-
let {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return function (block, element, additionalModifiers) {
|
|
32
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
33
|
+
return /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
34
|
+
let {
|
|
35
|
+
innerRef,
|
|
36
|
+
children,
|
|
37
|
+
classProps,
|
|
38
|
+
useComponent,
|
|
39
|
+
className,
|
|
40
|
+
as
|
|
41
|
+
} = _ref,
|
|
42
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
44
|
+
// get the additional classNames either from a function or an object
|
|
45
|
+
let otherModifiers = appendBlockAndPrefixToObj(additionalModifiers, block, element);
|
|
46
|
+
if (typeof additionalModifiers === 'function') otherModifiers = appendBlockAndPrefixToObj(additionalModifiers(_objectSpread(_objectSpread(_objectSpread({}, rest), classProps), {}, {
|
|
47
|
+
className
|
|
48
|
+
})), block, element);
|
|
49
|
+
const otherModifiersStr = cx(otherModifiers);
|
|
50
|
+
const {
|
|
51
|
+
prefix,
|
|
52
|
+
propsToRemoveFromFinalElement = []
|
|
53
|
+
} = options;
|
|
54
|
+
const {
|
|
55
|
+
cssClassName: classNames
|
|
56
|
+
} = cssPipeline(block, null, _objectSpread({}, classProps), {
|
|
57
|
+
prefix,
|
|
58
|
+
element
|
|
59
|
+
});
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
delete cleanedPropsPassedDown[propKey];
|
|
56
|
-
});
|
|
61
|
+
const cleanedPropsPassedDown = _objectSpread(_objectSpread({}, props), rest);
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
63
|
+
propsToRemoveFromFinalElement.forEach(propKey => {
|
|
64
|
+
delete cleanedPropsPassedDown[propKey];
|
|
61
65
|
});
|
|
62
|
-
}
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (isNativeHTMLElement(block)) {
|
|
68
|
+
Object.keys(cleanedPropsPassedDown).forEach(key => {
|
|
69
|
+
if (!isValidNativeAttribute(key)) delete cleanedPropsPassedDown[key];
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return /*#__PURE__*/React.createElement(as || type, _objectSpread({
|
|
74
|
+
ref: innerRef || ref,
|
|
75
|
+
className: [classNames, otherModifiersStr, className].join(' ')
|
|
76
|
+
}, cleanedPropsPassedDown), children);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
export { cssPrefix, aggregatedClasses as default };
|
package/esm/classNameManager.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
1
2
|
import { isEmpty } from '@elliemae/ds-utilities/utils';
|
|
2
3
|
import DimsumConfig from '@elliemae/ds-shared/dimsum.config';
|
|
3
4
|
import pipe from './converPropsToFormModifiers.js';
|
|
@@ -7,7 +8,7 @@ import pipe$3 from './convertPropsToSizeModifiers.js';
|
|
|
7
8
|
import pipe$4 from './convertPropsToTextModifiers.js';
|
|
8
9
|
import pipe$5 from './convertPropsToColorModifiers.js';
|
|
9
10
|
|
|
10
|
-
const cssPrefix =
|
|
11
|
+
const cssPrefix = "".concat(DimsumConfig.classNamePrefix, "-");
|
|
11
12
|
|
|
12
13
|
const executePipelines = props => {
|
|
13
14
|
const form = pipe().execute(props);
|
|
@@ -31,17 +32,21 @@ const executePipelines = props => {
|
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
|
|
34
|
-
const cssPipeline = (
|
|
35
|
+
const cssPipeline = function () {
|
|
36
|
+
let blockName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'block';
|
|
37
|
+
let cssClassNameModifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
38
|
+
let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
39
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
35
40
|
const {
|
|
36
41
|
prefix,
|
|
37
42
|
element
|
|
38
43
|
} = options;
|
|
39
|
-
const prefixBlockName =
|
|
44
|
+
const prefixBlockName = "".concat(prefix || cssPrefix).concat(blockName).concat(element ? "__".concat(element) : ''); // PipeLine
|
|
40
45
|
|
|
41
46
|
const pipes = !isEmpty(props) ? executePipelines(props) : [];
|
|
42
47
|
const basePipeline = [prefixBlockName, ...pipes]; // specific classname
|
|
43
48
|
|
|
44
|
-
const className = cssClassNameModifier ? [...basePipeline].join(
|
|
49
|
+
const className = cssClassNameModifier ? [...basePipeline].join(" ".concat(prefixBlockName, "--")).concat(" ".concat(cssClassNameModifier)) : [...basePipeline].join(" ".concat(prefixBlockName, "--"));
|
|
45
50
|
return {
|
|
46
51
|
blockName,
|
|
47
52
|
cssPrefix,
|
|
@@ -49,23 +54,27 @@ const cssPipeline = (blockName = 'block', cssClassNameModifier = '', props = {},
|
|
|
49
54
|
cssClassName: className,
|
|
50
55
|
|
|
51
56
|
mainModifier(modifier) {
|
|
52
|
-
return
|
|
57
|
+
return "".concat(className, "--").concat(modifier);
|
|
53
58
|
},
|
|
54
59
|
|
|
55
|
-
classNameBlock(elementName
|
|
56
|
-
|
|
60
|
+
classNameBlock(elementName) {
|
|
61
|
+
let usePrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
62
|
+
return "".concat(!usePrefix ? blockName : prefixBlockName, "-").concat(elementName);
|
|
57
63
|
},
|
|
58
64
|
|
|
59
|
-
classNameBlockModifier(modifierName
|
|
60
|
-
|
|
65
|
+
classNameBlockModifier(modifierName) {
|
|
66
|
+
let elementBlockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
67
|
+
return "".concat(prefixBlockName, "-").concat(elementBlockName, "--").concat(modifierName);
|
|
61
68
|
},
|
|
62
69
|
|
|
63
|
-
classNameElement(elementName
|
|
64
|
-
|
|
70
|
+
classNameElement(elementName) {
|
|
71
|
+
let elementBlockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
72
|
+
return "".concat(prefixBlockName).concat(elementBlockName ? "-".concat(elementBlockName) : '', "__").concat(elementName);
|
|
65
73
|
},
|
|
66
74
|
|
|
67
|
-
classNameModifier(modifierName
|
|
68
|
-
|
|
75
|
+
classNameModifier(modifierName) {
|
|
76
|
+
let elementName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
77
|
+
return "".concat(prefixBlockName).concat(elementName ? "__".concat(elementName) : '', "--").concat(modifierName);
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
readOnly = false,
|
|
9
|
+
disabled = false,
|
|
10
|
+
checked = false
|
|
11
|
+
} = _ref;
|
|
6
12
|
const cssModifier = []; // input state modifiers
|
|
7
13
|
|
|
8
14
|
if (checked) cssModifier.push('checked');
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
hasError = false,
|
|
9
|
+
hasWarning = false,
|
|
10
|
+
hasSuccess = false,
|
|
11
|
+
modalType
|
|
12
|
+
} = _ref;
|
|
7
13
|
const cssModifier = []; // valid state modifier
|
|
8
14
|
|
|
9
15
|
if (hasError) cssModifier.push('error');else if (hasWarning) cssModifier.push('warning');else if (hasSuccess) cssModifier.push('success');
|
|
10
|
-
if (modalType) cssModifier.push(
|
|
16
|
+
if (modalType) cssModifier.push("modal-type-".concat(modalType));
|
|
11
17
|
return cssModifier;
|
|
12
18
|
};
|
|
13
19
|
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
color = null
|
|
9
|
+
} = _ref;
|
|
4
10
|
const cssModifier = [];
|
|
5
11
|
|
|
6
12
|
if (color && color[0]) {
|
|
7
|
-
if (color[1] !== null) cssModifier.push(
|
|
13
|
+
if (color[1] !== null) cssModifier.push("color-".concat(color[0], "-").concat(color[1]));else cssModifier.push("color-".concat(color[0]));
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
return cssModifier;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
id,
|
|
9
|
+
buttonType = 'default',
|
|
10
|
+
fluidWidth = false,
|
|
11
|
+
fluidHeight = false
|
|
12
|
+
} = _ref;
|
|
7
13
|
const cssModifier = []; // buttons types
|
|
8
14
|
|
|
9
|
-
if (id) cssModifier.push(
|
|
15
|
+
if (id) cssModifier.push("id-".concat(id));
|
|
10
16
|
if (buttonType) cssModifier.push(buttonType);
|
|
11
17
|
if (fluidWidth) cssModifier.push('fluid-width');
|
|
12
18
|
if (fluidHeight) cssModifier.push('fluid-height');
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
size = null,
|
|
9
|
+
extraTight = false,
|
|
10
|
+
tight = false,
|
|
11
|
+
base = false,
|
|
12
|
+
bitLoose = false,
|
|
13
|
+
loose = false,
|
|
14
|
+
extraLoose = false,
|
|
15
|
+
superLoose = false
|
|
16
|
+
} = _ref;
|
|
11
17
|
const cssModifier = [];
|
|
12
|
-
if (size) cssModifier.push(
|
|
18
|
+
if (size) cssModifier.push("".concat(size)); // Size as Flag
|
|
13
19
|
|
|
14
20
|
if (extraTight) cssModifier.push('size-extra-tight');else if (tight) cssModifier.push('size-tight');else if (base) cssModifier.push('size-base');else if (bitLoose) cssModifier.push('size-bit-loose');else if (loose) cssModifier.push('size-loose');else if (extraLoose) cssModifier.push('size-extra-loose');else if (superLoose) cssModifier.push('size-super-loose');
|
|
15
21
|
return cssModifier;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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/web.dom-collections.iterator.js';
|
|
5
|
+
|
|
6
|
+
const basicAction = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
textEllipsis,
|
|
9
|
+
textAlignment,
|
|
10
|
+
wordBreak
|
|
11
|
+
} = _ref;
|
|
6
12
|
const cssModifier = [];
|
|
7
13
|
if (textEllipsis) cssModifier.push('text-overflow-ellipsis');
|
|
8
14
|
if (wordBreak) cssModifier.push('text-overflow-word-break');
|
|
9
|
-
if (['left', 'right', 'center', 'justify'].indexOf(textAlignment) > -1) cssModifier.push(
|
|
15
|
+
if (['left', 'right', 'center', 'justify'].indexOf(textAlignment) > -1) cssModifier.push("text-align-".concat(textAlignment));
|
|
10
16
|
return cssModifier;
|
|
11
17
|
};
|
|
12
18
|
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as convertPropToCssClassName } from './classNameManager.js';
|
|
1
|
+
export { default as convertPropToCssClassName, cssPrefix } from './classNameManager.js';
|
|
2
2
|
export { default as aggregatedClasses } from './aggregatedClasses.js';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
|
|
3
8
|
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; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-classnames",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-next.11",
|
|
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-utilities": "2.0.0-
|
|
72
|
-
"obj-str": "1.0.3"
|
|
71
|
+
"@elliemae/ds-utilities": "2.0.0-next.11",
|
|
72
|
+
"obj-str": "~1.0.3"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public",
|
package/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as convertPropToCssClassName } from './classNameManager';
|
|
1
|
+
export { default as convertPropToCssClassName, cssPrefix } from './classNameManager';
|
|
2
2
|
export { default as aggregatedClasses } from './aggregatedClasses';
|
package/cjs/package.json
DELETED