@elliemae/ds-text-wrapper 1.57.1-rc.0 → 2.0.0-alpha.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/DSTextWrapper.js +42 -54
- package/cjs/defaultProps.js +1 -2
- package/cjs/index.js +1 -9
- package/cjs/props.js +1 -2
- package/esm/DSTextWrapper.js +41 -52
- package/esm/defaultProps.js +1 -2
- package/esm/index.js +0 -8
- package/esm/props.js +1 -2
- package/package.json +39 -10
- package/types/DSTextWrapper.d.ts +46 -0
- package/types/defaultProps.d.ts +11 -0
- package/types/index.d.ts +2 -0
- package/types/props.d.ts +11 -0
- package/DSTextWrapper/package.json +0 -10
- package/cjs/DSTextWrapper.js.map +0 -1
- package/cjs/defaultProps.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/props.js.map +0 -1
- package/defaultProps/package.json +0 -10
- package/esm/DSTextWrapper.js.map +0 -1
- package/esm/defaultProps.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/props.js.map +0 -1
- package/props/package.json +0 -10
package/cjs/DSTextWrapper.js
CHANGED
|
@@ -2,84 +2,72 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _extends = require('@babel/runtime/helpers/extends');
|
|
6
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
7
|
-
var
|
|
6
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
7
|
+
require('react');
|
|
8
8
|
var reactDesc = require('react-desc');
|
|
9
9
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
10
10
|
var props = require('./props.js');
|
|
11
11
|
var defaultProps = require('./defaultProps.js');
|
|
12
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
12
13
|
|
|
13
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
15
|
|
|
15
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
16
16
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
|
-
var
|
|
17
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
18
|
|
|
19
19
|
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; }
|
|
20
20
|
|
|
21
|
-
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[
|
|
22
|
-
/**
|
|
23
|
-
* if we don't care about word break
|
|
24
|
-
* const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')
|
|
25
|
-
* text.match(regx)
|
|
26
|
-
*
|
|
27
|
-
* @param {*} param0
|
|
28
|
-
*/
|
|
21
|
+
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; }
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
const DSTextWrapper = ({
|
|
24
|
+
containerProps,
|
|
25
|
+
className,
|
|
26
|
+
style,
|
|
27
|
+
text,
|
|
28
|
+
maxCharacters,
|
|
29
|
+
maxWidth,
|
|
30
|
+
textEllipsis,
|
|
31
|
+
textAlignment,
|
|
32
|
+
wordBreak
|
|
33
|
+
}) => {
|
|
34
|
+
const {
|
|
35
|
+
cssClassName,
|
|
36
|
+
classNameElement
|
|
37
|
+
} = dsClassnames.convertPropToCssClassName('text-wrapperRef', className, {
|
|
38
|
+
textEllipsis,
|
|
39
|
+
textAlignment,
|
|
40
|
+
wordBreak
|
|
41
|
+
});
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
classNameElement = _convertPropToCssClas.classNameElement;
|
|
43
|
+
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
44
|
+
let resultIndex = result.length - 1;
|
|
45
|
+
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
46
|
+
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
47
|
+
return result;
|
|
48
|
+
}, ['']);
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
return text.split(' ').reduce(function (result, word) {
|
|
51
|
-
var resultIndex = result.length - 1;
|
|
52
|
-
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
53
|
-
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
54
|
-
return result;
|
|
55
|
-
}, ['']);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
var displayText = text;
|
|
50
|
+
let displayText = text;
|
|
59
51
|
if (textEllipsis) displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;else if (maxCharacters > 0) {
|
|
60
|
-
displayText = limitPerCharacter().map(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
className: classNameElement('line')
|
|
64
|
-
}, textpart);
|
|
65
|
-
});
|
|
52
|
+
displayText = limitPerCharacter().map((textpart, index) => /*#__PURE__*/_jsx__default["default"]("span", {
|
|
53
|
+
className: classNameElement('line')
|
|
54
|
+
}, index, textpart));
|
|
66
55
|
}
|
|
67
|
-
return /*#__PURE__*/
|
|
56
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
68
57
|
className: cssClassName,
|
|
69
58
|
style: _objectSpread({
|
|
70
59
|
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
71
|
-
}, style)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
}, style),
|
|
61
|
+
children: textEllipsis ? /*#__PURE__*/_jsx__default["default"]("span", {
|
|
62
|
+
className: classNameElement('ellipsis-wrapperRef')
|
|
63
|
+
}, void 0, displayText) : displayText
|
|
64
|
+
}));
|
|
75
65
|
};
|
|
76
66
|
|
|
77
|
-
DSTextWrapper.propTypes = props.textProps;
|
|
78
67
|
DSTextWrapper.defaultProps = defaultProps.defaultProps;
|
|
79
|
-
|
|
68
|
+
const TextWrapperWithSchema = reactDesc.describe(DSTextWrapper);
|
|
80
69
|
TextWrapperWithSchema.propTypes = props.textProps;
|
|
81
70
|
|
|
82
71
|
exports.DSTextWrapper = DSTextWrapper;
|
|
83
72
|
exports.TextWrapperWithSchema = TextWrapperWithSchema;
|
|
84
|
-
exports[
|
|
85
|
-
//# sourceMappingURL=DSTextWrapper.js.map
|
|
73
|
+
exports["default"] = DSTextWrapper;
|
package/cjs/defaultProps.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const defaultProps = {
|
|
6
6
|
containerProps: {},
|
|
7
7
|
className: '',
|
|
8
8
|
style: {},
|
|
@@ -15,4 +15,3 @@ var defaultProps = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
exports.defaultProps = defaultProps;
|
|
18
|
-
//# sourceMappingURL=defaultProps.js.map
|
package/cjs/index.js
CHANGED
|
@@ -3,17 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var DSTextWrapper = require('./DSTextWrapper.js');
|
|
6
|
-
require('@babel/runtime/helpers/extends');
|
|
7
|
-
require('@babel/runtime/helpers/defineProperty');
|
|
8
|
-
require('react');
|
|
9
|
-
require('react-desc');
|
|
10
|
-
require('@elliemae/ds-classnames');
|
|
11
|
-
require('./props.js');
|
|
12
|
-
require('./defaultProps.js');
|
|
13
6
|
|
|
14
7
|
|
|
15
8
|
|
|
16
9
|
exports.DSTextWrapper = DSTextWrapper.DSTextWrapper;
|
|
17
10
|
exports.TextWrapperWithSchema = DSTextWrapper.TextWrapperWithSchema;
|
|
18
|
-
exports
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
11
|
+
exports["default"] = DSTextWrapper.DSTextWrapper;
|
package/cjs/props.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var reactDesc = require('react-desc');
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const textProps = {
|
|
8
8
|
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
9
9
|
className: reactDesc.PropTypes.string.description('css class'),
|
|
10
10
|
style: reactDesc.PropTypes.object.description('css style'),
|
|
@@ -17,4 +17,3 @@ var textProps = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
exports.textProps = textProps;
|
|
20
|
-
//# sourceMappingURL=props.js.map
|
package/esm/DSTextWrapper.js
CHANGED
|
@@ -1,73 +1,62 @@
|
|
|
1
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
2
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
-
import
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import 'react';
|
|
4
4
|
import { describe } from 'react-desc';
|
|
5
5
|
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
6
6
|
import { textProps } from './props.js';
|
|
7
7
|
import { defaultProps } from './defaultProps.js';
|
|
8
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
10
|
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; }
|
|
10
11
|
|
|
11
12
|
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; }
|
|
12
|
-
/**
|
|
13
|
-
* if we don't care about word break
|
|
14
|
-
* const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')
|
|
15
|
-
* text.match(regx)
|
|
16
|
-
*
|
|
17
|
-
* @param {*} param0
|
|
18
|
-
*/
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var displayText = text;
|
|
14
|
+
const DSTextWrapper = ({
|
|
15
|
+
containerProps,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
text,
|
|
19
|
+
maxCharacters,
|
|
20
|
+
maxWidth,
|
|
21
|
+
textEllipsis,
|
|
22
|
+
textAlignment,
|
|
23
|
+
wordBreak
|
|
24
|
+
}) => {
|
|
25
|
+
const {
|
|
26
|
+
cssClassName,
|
|
27
|
+
classNameElement
|
|
28
|
+
} = convertPropToCssClassName('text-wrapperRef', className, {
|
|
29
|
+
textEllipsis,
|
|
30
|
+
textAlignment,
|
|
31
|
+
wordBreak
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
35
|
+
let resultIndex = result.length - 1;
|
|
36
|
+
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
37
|
+
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
38
|
+
return result;
|
|
39
|
+
}, ['']);
|
|
40
|
+
|
|
41
|
+
let displayText = text;
|
|
49
42
|
if (textEllipsis) displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;else if (maxCharacters > 0) {
|
|
50
|
-
displayText = limitPerCharacter().map(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
className: classNameElement('line')
|
|
54
|
-
}, textpart);
|
|
55
|
-
});
|
|
43
|
+
displayText = limitPerCharacter().map((textpart, index) => /*#__PURE__*/_jsx("span", {
|
|
44
|
+
className: classNameElement('line')
|
|
45
|
+
}, index, textpart));
|
|
56
46
|
}
|
|
57
|
-
return /*#__PURE__*/
|
|
47
|
+
return /*#__PURE__*/jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
58
48
|
className: cssClassName,
|
|
59
49
|
style: _objectSpread({
|
|
60
50
|
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
61
|
-
}, style)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
}, style),
|
|
52
|
+
children: textEllipsis ? /*#__PURE__*/_jsx("span", {
|
|
53
|
+
className: classNameElement('ellipsis-wrapperRef')
|
|
54
|
+
}, void 0, displayText) : displayText
|
|
55
|
+
}));
|
|
65
56
|
};
|
|
66
57
|
|
|
67
|
-
DSTextWrapper.propTypes = textProps;
|
|
68
58
|
DSTextWrapper.defaultProps = defaultProps;
|
|
69
|
-
|
|
59
|
+
const TextWrapperWithSchema = describe(DSTextWrapper);
|
|
70
60
|
TextWrapperWithSchema.propTypes = textProps;
|
|
71
61
|
|
|
72
62
|
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default };
|
|
73
|
-
//# sourceMappingURL=DSTextWrapper.js.map
|
package/esm/defaultProps.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
1
|
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default } from './DSTextWrapper.js';
|
|
2
|
-
import '@babel/runtime/helpers/esm/extends';
|
|
3
|
-
import '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
-
import 'react';
|
|
5
|
-
import 'react-desc';
|
|
6
|
-
import '@elliemae/ds-classnames';
|
|
7
|
-
import './props.js';
|
|
8
|
-
import './defaultProps.js';
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
package/esm/props.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropTypes } from 'react-desc';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const textProps = {
|
|
4
4
|
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
5
5
|
className: PropTypes.string.description('css class'),
|
|
6
6
|
style: PropTypes.object.description('css style'),
|
|
@@ -13,4 +13,3 @@ var textProps = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { textProps };
|
|
16
|
-
//# sourceMappingURL=props.js.map
|
package/package.json
CHANGED
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-text-wrapper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"description": "
|
|
6
|
-
"module": "esm/index.js",
|
|
7
|
-
"main": "cjs/index.js",
|
|
5
|
+
"description": "ICE MT - Dimsum - Text Wrapper",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./cjs/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./props": {
|
|
15
|
+
"import": "./esm/props.js",
|
|
16
|
+
"require": "./cjs/props.js"
|
|
17
|
+
},
|
|
18
|
+
"./DSTextWrapper": {
|
|
19
|
+
"import": "./esm/DSTextWrapper.js",
|
|
20
|
+
"require": "./cjs/DSTextWrapper.js"
|
|
21
|
+
},
|
|
22
|
+
"./defaultProps": {
|
|
23
|
+
"import": "./esm/defaultProps.js",
|
|
24
|
+
"require": "./cjs/defaultProps.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
8
27
|
"sideEffects": [
|
|
9
28
|
"*.css",
|
|
10
29
|
"*.scss"
|
|
11
30
|
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"npm": ">=7",
|
|
37
|
+
"node": ">=14"
|
|
38
|
+
},
|
|
39
|
+
"author": "ICE MT",
|
|
12
40
|
"scripts": {
|
|
13
41
|
"dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
|
|
14
42
|
"prebuild": "exit 0",
|
|
@@ -16,16 +44,17 @@
|
|
|
16
44
|
"build": "node ../../scripts/build/build.js"
|
|
17
45
|
},
|
|
18
46
|
"dependencies": {
|
|
19
|
-
"@elliemae/ds-classnames": "
|
|
20
|
-
"
|
|
47
|
+
"@elliemae/ds-classnames": "2.0.0-alpha.11",
|
|
48
|
+
"@elliemae/ds-utilities": "2.0.0-alpha.11"
|
|
21
49
|
},
|
|
22
50
|
"peerDependencies": {
|
|
23
|
-
"lodash": "^4.17.
|
|
24
|
-
"react": "^17.0.
|
|
25
|
-
"react-dom": "^17.0.
|
|
51
|
+
"lodash": "^4.17.21",
|
|
52
|
+
"react": "^17.0.2",
|
|
53
|
+
"react-dom": "^17.0.2"
|
|
26
54
|
},
|
|
27
55
|
"publishConfig": {
|
|
28
56
|
"access": "public",
|
|
29
|
-
"directory": "dist"
|
|
57
|
+
"directory": "dist",
|
|
58
|
+
"generateSubmodules": true
|
|
30
59
|
}
|
|
31
60
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* if we don't care about word break
|
|
4
|
+
* const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')
|
|
5
|
+
* text.match(regx)
|
|
6
|
+
*
|
|
7
|
+
* @param {*} param0
|
|
8
|
+
*/
|
|
9
|
+
declare const DSTextWrapper: {
|
|
10
|
+
({ containerProps, className, style, text, maxCharacters, maxWidth, textEllipsis, textAlignment, wordBreak, }: {
|
|
11
|
+
containerProps: any;
|
|
12
|
+
className: any;
|
|
13
|
+
style: any;
|
|
14
|
+
text: any;
|
|
15
|
+
maxCharacters: any;
|
|
16
|
+
maxWidth: any;
|
|
17
|
+
textEllipsis: any;
|
|
18
|
+
textAlignment: any;
|
|
19
|
+
wordBreak: any;
|
|
20
|
+
}): JSX.Element;
|
|
21
|
+
propTypes: {
|
|
22
|
+
containerProps: any;
|
|
23
|
+
className: any;
|
|
24
|
+
style: any;
|
|
25
|
+
text: any;
|
|
26
|
+
maxCharacters: any;
|
|
27
|
+
maxWidth: any;
|
|
28
|
+
textEllipsis: any;
|
|
29
|
+
textAlignment: any;
|
|
30
|
+
wordBreak: any;
|
|
31
|
+
};
|
|
32
|
+
defaultProps: {
|
|
33
|
+
containerProps: {};
|
|
34
|
+
className: string;
|
|
35
|
+
style: {};
|
|
36
|
+
text: string;
|
|
37
|
+
maxCharacters: number;
|
|
38
|
+
maxWidth: string;
|
|
39
|
+
textEllipsis: boolean;
|
|
40
|
+
textAlignment: string;
|
|
41
|
+
wordBreak: boolean;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
declare const TextWrapperWithSchema: any;
|
|
45
|
+
export { DSTextWrapper, TextWrapperWithSchema };
|
|
46
|
+
export default DSTextWrapper;
|
package/types/index.d.ts
ADDED
package/types/props.d.ts
ADDED
package/cjs/DSTextWrapper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DSTextWrapper.js","sources":["../../src/DSTextWrapper.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport React from 'react';\nimport { describe } from 'react-desc';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { textProps } from './props';\nimport { defaultProps } from './defaultProps';\n\n/**\n * if we don't care about word break\n * const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')\n * text.match(regx)\n *\n * @param {*} param0\n */\nconst DSTextWrapper = ({\n containerProps,\n className,\n style,\n text,\n maxCharacters,\n maxWidth,\n textEllipsis,\n textAlignment,\n wordBreak,\n}) => {\n const { cssClassName, classNameElement } = convertPropToCssClassName(\n 'text-wrapperRef',\n className,\n {\n textEllipsis,\n textAlignment,\n wordBreak,\n },\n );\n const limitPerCharacter = () =>\n text.split(' ').reduce(\n (result, word) => {\n let resultIndex = result.length - 1;\n if (result[resultIndex].length + word.length > maxCharacters)\n resultIndex += 1;\n result[resultIndex] = `${result[resultIndex] || ''} ${word}`;\n return result;\n },\n [''],\n );\n\n let displayText = text;\n\n if (textEllipsis)\n displayText =\n maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;\n else if (maxCharacters > 0) {\n displayText = limitPerCharacter().map((textpart, index) => (\n <span key={index} className={classNameElement('line')}>\n {textpart}\n </span>\n ));\n }\n\n return (\n <span\n {...containerProps}\n className={cssClassName}\n style={{\n maxWidth: maxCharacters < 1 ? maxWidth : null,\n ...style,\n }}\n >\n {textEllipsis ? (\n <span className={classNameElement('ellipsis-wrapperRef')}>\n {displayText}\n </span>\n ) : (\n displayText\n )}\n </span>\n );\n};\n\nDSTextWrapper.propTypes = textProps;\nDSTextWrapper.defaultProps = defaultProps;\n\nconst TextWrapperWithSchema = describe(DSTextWrapper);\nTextWrapperWithSchema.propTypes = textProps;\n\nexport { DSTextWrapper, TextWrapperWithSchema };\nexport default DSTextWrapper;\n"],"names":["DSTextWrapper","containerProps","className","style","text","maxCharacters","maxWidth","textEllipsis","textAlignment","wordBreak","convertPropToCssClassName","cssClassName","classNameElement","limitPerCharacter","split","reduce","result","word","resultIndex","length","displayText","substring","map","textpart","index","React","propTypes","textProps","defaultProps","TextWrapperWithSchema","describe"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;IACMA,aAAa,GAAG,SAAhBA,aAAgB,OAUhB;AAAA,MATJC,cASI,QATJA,cASI;AAAA,MARJC,SAQI,QARJA,SAQI;AAAA,MAPJC,KAOI,QAPJA,KAOI;AAAA,MANJC,IAMI,QANJA,IAMI;AAAA,MALJC,aAKI,QALJA,aAKI;AAAA,MAJJC,QAII,QAJJA,QAII;AAAA,MAHJC,YAGI,QAHJA,YAGI;AAAA,MAFJC,aAEI,QAFJA,aAEI;AAAA,MADJC,SACI,QADJA,SACI;;AACJ,8BAA2CC,sCAAyB,CAClE,iBADkE,EAElER,SAFkE,EAGlE;AACEK,IAAAA,YAAY,EAAZA,YADF;AAEEC,IAAAA,aAAa,EAAbA,aAFF;AAGEC,IAAAA,SAAS,EAATA;AAHF,GAHkE,CAApE;AAAA,MAAQE,YAAR,yBAAQA,YAAR;AAAA,MAAsBC,gBAAtB,yBAAsBA,gBAAtB;;AASA,MAAMC,iBAAiB,GAAG,SAApBA,iBAAoB;AAAA,WACxBT,IAAI,CAACU,KAAL,CAAW,GAAX,EAAgBC,MAAhB,CACE,UAACC,MAAD,EAASC,IAAT,EAAkB;AAChB,UAAIC,WAAW,GAAGF,MAAM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}
|
package/cjs/defaultProps.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultProps.js","sources":["../../src/defaultProps.tsx"],"sourcesContent":["export const defaultProps = {\n containerProps: {},\n className: '',\n style: {},\n text: '',\n maxCharacters: 0,\n maxWidth: '100%',\n textEllipsis: false,\n textAlignment: 'left',\n wordBreak: true,\n};\n"],"names":["defaultProps","containerProps","className","style","text","maxCharacters","maxWidth","textEllipsis","textAlignment","wordBreak"],"mappings":";;;;IAAaA,YAAY,GAAG;AAC1BC,EAAAA,cAAc,EAAE,EADU;AAE1BC,EAAAA,SAAS,EAAE,EAFe;AAG1BC,EAAAA,KAAK,EAAE,EAHmB;AAI1BC,EAAAA,IAAI,EAAE,EAJoB;AAK1BC,EAAAA,aAAa,EAAE,CALW;AAM1BC,EAAAA,QAAQ,EAAE,MANgB;AAO1BC,EAAAA,YAAY,EAAE,KAPY;AAQ1BC,EAAAA,aAAa,EAAE,MARW;AAS1BC,EAAAA,SAAS,EAAE;AATe;;;;"}
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
|
package/cjs/props.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sources":["../../src/props.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const textProps = {\n containerProps: PropTypes.object.description(\n 'Set of Properties attached to the main container',\n ),\n className: PropTypes.string.description('css class'),\n style: PropTypes.object.description('css style'),\n text: PropTypes.string.description('Text to display').isRequired,\n maxCharacters: PropTypes.number.description(\n 'Maximum amount of charachters allowed',\n ),\n maxWidth: PropTypes.string.description('Maximum width allowed'),\n textEllipsis: PropTypes.bool.description('Whether to show ellipsis or not'),\n textAlignment: PropTypes.oneOf(['left', 'center', 'right']).description(\n 'Text alignement',\n ),\n wordBreak: PropTypes.bool.description('Whether to break the line or not'),\n};\n"],"names":["textProps","containerProps","PropTypes","object","description","className","string","style","text","isRequired","maxCharacters","number","maxWidth","textEllipsis","bool","textAlignment","oneOf","wordBreak"],"mappings":";;;;;;IAEaA,SAAS,GAAG;AACvBC,EAAAA,cAAc,EAAEC,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CACd,kDADc,CADO;AAIvBC,EAAAA,SAAS,EAAEH,mBAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,WAA7B,CAJY;AAKvBG,EAAAA,KAAK,EAAEL,mBAAS,CAACC,MAAV,CAAiBC,WAAjB,CAA6B,WAA7B,CALgB;AAMvBI,EAAAA,IAAI,EAAEN,mBAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,iBAA7B,EAAgDK,UAN/B;AAOvBC,EAAAA,aAAa,EAAER,mBAAS,CAACS,MAAV,CAAiBP,WAAjB,CACb,uCADa,CAPQ;AAUvBQ,EAAAA,QAAQ,EAAEV,mBAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,uBAA7B,CAVa;AAWvBS,EAAAA,YAAY,EAAEX,mBAAS,CAACY,IAAV,CAAeV,WAAf,CAA2B,iCAA3B,CAXS;AAYvBW,EAAAA,aAAa,EAAEb,mBAAS,CAACc,KAAV,CAAgB,CAAC,MAAD,EAAS,QAAT,EAAmB,OAAnB,CAAhB,EAA6CZ,WAA7C,CACb,iBADa,CAZQ;AAevBa,EAAAA,SAAS,EAAEf,mBAAS,CAACY,IAAV,CAAeV,WAAf,CAA2B,kCAA3B;AAfY;;;;"}
|
package/esm/DSTextWrapper.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DSTextWrapper.js","sources":["../../src/DSTextWrapper.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport React from 'react';\nimport { describe } from 'react-desc';\nimport { convertPropToCssClassName } from '@elliemae/ds-classnames';\nimport { textProps } from './props';\nimport { defaultProps } from './defaultProps';\n\n/**\n * if we don't care about word break\n * const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')\n * text.match(regx)\n *\n * @param {*} param0\n */\nconst DSTextWrapper = ({\n containerProps,\n className,\n style,\n text,\n maxCharacters,\n maxWidth,\n textEllipsis,\n textAlignment,\n wordBreak,\n}) => {\n const { cssClassName, classNameElement } = convertPropToCssClassName(\n 'text-wrapperRef',\n className,\n {\n textEllipsis,\n textAlignment,\n wordBreak,\n },\n );\n const limitPerCharacter = () =>\n text.split(' ').reduce(\n (result, word) => {\n let resultIndex = result.length - 1;\n if (result[resultIndex].length + word.length > maxCharacters)\n resultIndex += 1;\n result[resultIndex] = `${result[resultIndex] || ''} ${word}`;\n return result;\n },\n [''],\n );\n\n let displayText = text;\n\n if (textEllipsis)\n displayText =\n maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;\n else if (maxCharacters > 0) {\n displayText = limitPerCharacter().map((textpart, index) => (\n <span key={index} className={classNameElement('line')}>\n {textpart}\n </span>\n ));\n }\n\n return (\n <span\n {...containerProps}\n className={cssClassName}\n style={{\n maxWidth: maxCharacters < 1 ? maxWidth : null,\n ...style,\n }}\n >\n {textEllipsis ? (\n <span className={classNameElement('ellipsis-wrapperRef')}>\n {displayText}\n </span>\n ) : (\n displayText\n )}\n </span>\n );\n};\n\nDSTextWrapper.propTypes = textProps;\nDSTextWrapper.defaultProps = defaultProps;\n\nconst TextWrapperWithSchema = describe(DSTextWrapper);\nTextWrapperWithSchema.propTypes = textProps;\n\nexport { DSTextWrapper, TextWrapperWithSchema };\nexport default DSTextWrapper;\n"],"names":["DSTextWrapper","containerProps","className","style","text","maxCharacters","maxWidth","textEllipsis","textAlignment","wordBreak","convertPropToCssClassName","cssClassName","classNameElement","limitPerCharacter","split","reduce","result","word","resultIndex","length","displayText","substring","map","textpart","index","propTypes","textProps","defaultProps","TextWrapperWithSchema","describe"],"mappings":";;;;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;IACMA,aAAa,GAAG,SAAhBA,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;AAC1Be,IAAAA,WAAW,GAAGP,iBAAiB,GAAGS,GAApB,CAAwB,UAACC,QAAD,EAAWC,KAAX;AAAA,0BACpC;AAAM,QAAA,GAAG,EAAEA,KAAX;AAAkB,QAAA,SAAS,EAAEZ,gBAAgB,CAAC,MAAD;AAA7C,SACGW,QADH,CADoC;AAAA,KAAxB,CAAd;AAKD;AAED,sBACE,yCACMtB,cADN;AAEE,IAAA,SAAS,EAAEU,YAFb;AAGE,IAAA,KAAK;AACHL,MAAAA,QAAQ,EAAED,aAAa,GAAG,CAAhB,GAAoBC,QAApB,GAA+B;AADtC,OAEAH,KAFA;AAHP,MAQGI,YAAY,gBACX;AAAM,IAAA,SAAS,EAAEK,gBAAgB,CAAC,qBAAD;AAAjC,KACGQ,WADH,CADW,GAKXA,WAbJ,CADF;AAkBD;;AAEDpB,aAAa,CAACyB,SAAd,GAA0BC,SAA1B;AACA1B,aAAa,CAAC2B,YAAd,GAA6BA,YAA7B;IAEMC,qBAAqB,GAAGC,QAAQ,CAAC7B,aAAD;AACtC4B,qBAAqB,CAACH,SAAtB,GAAkCC,SAAlC;;;;"}
|
package/esm/defaultProps.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultProps.js","sources":["../../src/defaultProps.tsx"],"sourcesContent":["export const defaultProps = {\n containerProps: {},\n className: '',\n style: {},\n text: '',\n maxCharacters: 0,\n maxWidth: '100%',\n textEllipsis: false,\n textAlignment: 'left',\n wordBreak: true,\n};\n"],"names":["defaultProps","containerProps","className","style","text","maxCharacters","maxWidth","textEllipsis","textAlignment","wordBreak"],"mappings":"IAAaA,YAAY,GAAG;AAC1BC,EAAAA,cAAc,EAAE,EADU;AAE1BC,EAAAA,SAAS,EAAE,EAFe;AAG1BC,EAAAA,KAAK,EAAE,EAHmB;AAI1BC,EAAAA,IAAI,EAAE,EAJoB;AAK1BC,EAAAA,aAAa,EAAE,CALW;AAM1BC,EAAAA,QAAQ,EAAE,MANgB;AAO1BC,EAAAA,YAAY,EAAE,KAPY;AAQ1BC,EAAAA,aAAa,EAAE,MARW;AAS1BC,EAAAA,SAAS,EAAE;AATe;;;;"}
|
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/esm/props.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"props.js","sources":["../../src/props.tsx"],"sourcesContent":["import { PropTypes } from 'react-desc';\n\nexport const textProps = {\n containerProps: PropTypes.object.description(\n 'Set of Properties attached to the main container',\n ),\n className: PropTypes.string.description('css class'),\n style: PropTypes.object.description('css style'),\n text: PropTypes.string.description('Text to display').isRequired,\n maxCharacters: PropTypes.number.description(\n 'Maximum amount of charachters allowed',\n ),\n maxWidth: PropTypes.string.description('Maximum width allowed'),\n textEllipsis: PropTypes.bool.description('Whether to show ellipsis or not'),\n textAlignment: PropTypes.oneOf(['left', 'center', 'right']).description(\n 'Text alignement',\n ),\n wordBreak: PropTypes.bool.description('Whether to break the line or not'),\n};\n"],"names":["textProps","containerProps","PropTypes","object","description","className","string","style","text","isRequired","maxCharacters","number","maxWidth","textEllipsis","bool","textAlignment","oneOf","wordBreak"],"mappings":";;IAEaA,SAAS,GAAG;AACvBC,EAAAA,cAAc,EAAEC,SAAS,CAACC,MAAV,CAAiBC,WAAjB,CACd,kDADc,CADO;AAIvBC,EAAAA,SAAS,EAAEH,SAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,WAA7B,CAJY;AAKvBG,EAAAA,KAAK,EAAEL,SAAS,CAACC,MAAV,CAAiBC,WAAjB,CAA6B,WAA7B,CALgB;AAMvBI,EAAAA,IAAI,EAAEN,SAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,iBAA7B,EAAgDK,UAN/B;AAOvBC,EAAAA,aAAa,EAAER,SAAS,CAACS,MAAV,CAAiBP,WAAjB,CACb,uCADa,CAPQ;AAUvBQ,EAAAA,QAAQ,EAAEV,SAAS,CAACI,MAAV,CAAiBF,WAAjB,CAA6B,uBAA7B,CAVa;AAWvBS,EAAAA,YAAY,EAAEX,SAAS,CAACY,IAAV,CAAeV,WAAf,CAA2B,iCAA3B,CAXS;AAYvBW,EAAAA,aAAa,EAAEb,SAAS,CAACc,KAAV,CAAgB,CAAC,MAAD,EAAS,QAAT,EAAmB,OAAnB,CAAhB,EAA6CZ,WAA7C,CACb,iBADa,CAZQ;AAevBa,EAAAA,SAAS,EAAEf,SAAS,CAACY,IAAV,CAAeV,WAAf,CAA2B,kCAA3B;AAfY;;;;"}
|