@elliemae/ds-text-wrapper 2.2.0-alpha.4 → 3.0.0-next.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/DSTextWrapper.js +73 -79
- package/cjs/defaultProps.js +10 -38
- package/cjs/index.js +11 -36
- package/cjs/props.js +17 -44
- package/esm/DSTextWrapper.js +59 -47
- package/esm/defaultProps.js +6 -9
- package/esm/index.js +1 -7
- package/esm/props.js +13 -15
- package/package.json +2 -2
- package/cjs/DSTextWrapper.js.map +0 -7
- package/cjs/defaultProps.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/props.js.map +0 -7
- package/esm/DSTextWrapper.js.map +0 -7
- package/esm/defaultProps.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/props.js.map +0 -7
package/cjs/DSTextWrapper.js
CHANGED
|
@@ -1,89 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
textAlignment,
|
|
49
|
-
wordBreak
|
|
50
|
-
}) => {
|
|
51
|
-
const { cssClassName, classNameElement } = (0, import_ds_classnames.convertPropToCssClassName)("text-wrapperRef", className, {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
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.map.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
12
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
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');
|
|
16
|
+
require('react');
|
|
17
|
+
var reactDesc = require('react-desc');
|
|
18
|
+
var dsClassnames = require('@elliemae/ds-classnames');
|
|
19
|
+
var props = require('./props.js');
|
|
20
|
+
var defaultProps = require('./defaultProps.js');
|
|
21
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
22
|
+
|
|
23
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
|
+
|
|
25
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
26
|
+
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
const DSTextWrapper = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
containerProps,
|
|
35
|
+
className,
|
|
36
|
+
style,
|
|
37
|
+
text,
|
|
38
|
+
maxCharacters,
|
|
39
|
+
maxWidth,
|
|
40
|
+
textEllipsis,
|
|
41
|
+
textAlignment,
|
|
42
|
+
wordBreak
|
|
43
|
+
} = _ref;
|
|
44
|
+
const {
|
|
45
|
+
cssClassName,
|
|
46
|
+
classNameElement
|
|
47
|
+
} = dsClassnames.convertPropToCssClassName('text-wrapperRef', className, {
|
|
52
48
|
textEllipsis,
|
|
53
49
|
textAlignment,
|
|
54
50
|
wordBreak
|
|
55
51
|
});
|
|
56
|
-
|
|
52
|
+
|
|
53
|
+
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
57
54
|
let resultIndex = result.length - 1;
|
|
58
|
-
if (result[resultIndex].length + word.length > maxCharacters)
|
|
59
|
-
|
|
60
|
-
result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
|
|
55
|
+
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
56
|
+
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
61
57
|
return result;
|
|
62
|
-
}, [
|
|
58
|
+
}, ['']);
|
|
59
|
+
|
|
63
60
|
let displayText = text;
|
|
64
|
-
if (textEllipsis)
|
|
65
|
-
displayText =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
key: index,
|
|
69
|
-
className: classNameElement("line")
|
|
70
|
-
}, textpart));
|
|
61
|
+
if (textEllipsis) displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;else if (maxCharacters > 0) {
|
|
62
|
+
displayText = limitPerCharacter().map((textpart, index) => /*#__PURE__*/_jsx__default["default"]("span", {
|
|
63
|
+
className: classNameElement('line')
|
|
64
|
+
}, index, textpart));
|
|
71
65
|
}
|
|
72
|
-
return
|
|
73
|
-
...containerProps,
|
|
66
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
74
67
|
className: cssClassName,
|
|
75
|
-
style: {
|
|
76
|
-
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
68
|
+
style: _objectSpread({
|
|
69
|
+
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
70
|
+
}, style),
|
|
71
|
+
children: textEllipsis ? /*#__PURE__*/_jsx__default["default"]("span", {
|
|
72
|
+
className: classNameElement('ellipsis-wrapperRef')
|
|
73
|
+
}, void 0, displayText) : displayText
|
|
74
|
+
}));
|
|
82
75
|
};
|
|
83
|
-
|
|
84
|
-
DSTextWrapper.defaultProps =
|
|
85
|
-
const TextWrapperWithSchema =
|
|
86
|
-
TextWrapperWithSchema.propTypes =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
|
|
77
|
+
DSTextWrapper.defaultProps = defaultProps.defaultProps;
|
|
78
|
+
const TextWrapperWithSchema = reactDesc.describe(DSTextWrapper);
|
|
79
|
+
TextWrapperWithSchema.propTypes = props.textProps;
|
|
80
|
+
|
|
81
|
+
exports.DSTextWrapper = DSTextWrapper;
|
|
82
|
+
exports.TextWrapperWithSchema = TextWrapperWithSchema;
|
|
83
|
+
exports["default"] = DSTextWrapper;
|
package/cjs/defaultProps.js
CHANGED
|
@@ -1,45 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var defaultProps_exports = {};
|
|
29
|
-
__export(defaultProps_exports, {
|
|
30
|
-
defaultProps: () => defaultProps
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
33
5
|
const defaultProps = {
|
|
34
6
|
containerProps: {},
|
|
35
|
-
className:
|
|
7
|
+
className: '',
|
|
36
8
|
style: {},
|
|
37
|
-
text:
|
|
9
|
+
text: '',
|
|
38
10
|
maxCharacters: 0,
|
|
39
|
-
maxWidth:
|
|
11
|
+
maxWidth: '100%',
|
|
40
12
|
textEllipsis: false,
|
|
41
|
-
textAlignment:
|
|
13
|
+
textAlignment: 'left',
|
|
42
14
|
wordBreak: true
|
|
43
15
|
};
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
|
|
17
|
+
exports.defaultProps = defaultProps;
|
package/cjs/index.js
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var src_exports = {};
|
|
29
|
-
__export(src_exports, {
|
|
30
|
-
default: () => import_DSTextWrapper.default
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
__reExport(src_exports, require("./DSTextWrapper"));
|
|
34
|
-
var import_DSTextWrapper = require("./DSTextWrapper");
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DSTextWrapper = require('./DSTextWrapper.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.DSTextWrapper = DSTextWrapper.DSTextWrapper;
|
|
10
|
+
exports.TextWrapperWithSchema = DSTextWrapper.TextWrapperWithSchema;
|
|
11
|
+
exports["default"] = DSTextWrapper.DSTextWrapper;
|
package/cjs/props.js
CHANGED
|
@@ -1,46 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
-
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(module2))
|
|
15
|
-
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
-
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (module2, isNodeMode) => {
|
|
21
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
-
var props_exports = {};
|
|
29
|
-
__export(props_exports, {
|
|
30
|
-
textProps: () => textProps
|
|
31
|
-
});
|
|
32
|
-
var React = __toESM(require("react"));
|
|
33
|
-
var import_react_desc = require("react-desc");
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var reactDesc = require('react-desc');
|
|
6
|
+
|
|
34
7
|
const textProps = {
|
|
35
|
-
containerProps:
|
|
36
|
-
className:
|
|
37
|
-
style:
|
|
38
|
-
text:
|
|
39
|
-
maxCharacters:
|
|
40
|
-
maxWidth:
|
|
41
|
-
textEllipsis:
|
|
42
|
-
textAlignment:
|
|
43
|
-
wordBreak:
|
|
8
|
+
containerProps: reactDesc.PropTypes.object.description('Set of Properties attached to the main container'),
|
|
9
|
+
className: reactDesc.PropTypes.string.description('css class'),
|
|
10
|
+
style: reactDesc.PropTypes.object.description('css style'),
|
|
11
|
+
text: reactDesc.PropTypes.string.description('Text to display').isRequired,
|
|
12
|
+
maxCharacters: reactDesc.PropTypes.number.description('Maximum amount of charachters allowed'),
|
|
13
|
+
maxWidth: reactDesc.PropTypes.string.description('Maximum width allowed'),
|
|
14
|
+
textEllipsis: reactDesc.PropTypes.bool.description('Whether to show ellipsis or not'),
|
|
15
|
+
textAlignment: reactDesc.PropTypes.oneOf(['left', 'center', 'right']).description('Text alignement'),
|
|
16
|
+
wordBreak: reactDesc.PropTypes.bool.description('Whether to break the line or not')
|
|
44
17
|
};
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
|
|
19
|
+
exports.textProps = textProps;
|
package/esm/DSTextWrapper.js
CHANGED
|
@@ -1,60 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
8
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
12
|
+
import 'react';
|
|
13
|
+
import { describe } from 'react-desc';
|
|
14
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
15
|
+
import { textProps } from './props.js';
|
|
16
|
+
import { defaultProps } from './defaultProps.js';
|
|
17
|
+
import { jsx } from 'react/jsx-runtime';
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
|
+
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; }
|
|
22
|
+
|
|
23
|
+
const DSTextWrapper = _ref => {
|
|
24
|
+
let {
|
|
25
|
+
containerProps,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
text,
|
|
29
|
+
maxCharacters,
|
|
30
|
+
maxWidth,
|
|
31
|
+
textEllipsis,
|
|
32
|
+
textAlignment,
|
|
33
|
+
wordBreak
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
cssClassName,
|
|
37
|
+
classNameElement
|
|
38
|
+
} = convertPropToCssClassName('text-wrapperRef', className, {
|
|
19
39
|
textEllipsis,
|
|
20
40
|
textAlignment,
|
|
21
41
|
wordBreak
|
|
22
42
|
});
|
|
23
|
-
|
|
43
|
+
|
|
44
|
+
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
24
45
|
let resultIndex = result.length - 1;
|
|
25
|
-
if (result[resultIndex].length + word.length > maxCharacters)
|
|
26
|
-
|
|
27
|
-
result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
|
|
46
|
+
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
47
|
+
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
28
48
|
return result;
|
|
29
|
-
}, [
|
|
49
|
+
}, ['']);
|
|
50
|
+
|
|
30
51
|
let displayText = text;
|
|
31
|
-
if (textEllipsis)
|
|
32
|
-
displayText =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
key: index,
|
|
36
|
-
className: classNameElement("line")
|
|
37
|
-
}, textpart));
|
|
52
|
+
if (textEllipsis) displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;else if (maxCharacters > 0) {
|
|
53
|
+
displayText = limitPerCharacter().map((textpart, index) => /*#__PURE__*/_jsx("span", {
|
|
54
|
+
className: classNameElement('line')
|
|
55
|
+
}, index, textpart));
|
|
38
56
|
}
|
|
39
|
-
return
|
|
40
|
-
...containerProps,
|
|
57
|
+
return /*#__PURE__*/jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
41
58
|
className: cssClassName,
|
|
42
|
-
style: {
|
|
43
|
-
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
59
|
+
style: _objectSpread({
|
|
60
|
+
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
61
|
+
}, style),
|
|
62
|
+
children: textEllipsis ? /*#__PURE__*/_jsx("span", {
|
|
63
|
+
className: classNameElement('ellipsis-wrapperRef')
|
|
64
|
+
}, void 0, displayText) : displayText
|
|
65
|
+
}));
|
|
49
66
|
};
|
|
50
|
-
|
|
67
|
+
|
|
51
68
|
DSTextWrapper.defaultProps = defaultProps;
|
|
52
69
|
const TextWrapperWithSchema = describe(DSTextWrapper);
|
|
53
70
|
TextWrapperWithSchema.propTypes = textProps;
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
DSTextWrapper,
|
|
57
|
-
TextWrapperWithSchema,
|
|
58
|
-
DSTextWrapper_default as default
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=DSTextWrapper.js.map
|
|
71
|
+
|
|
72
|
+
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default };
|
package/esm/defaultProps.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
const defaultProps = {
|
|
3
2
|
containerProps: {},
|
|
4
|
-
className:
|
|
3
|
+
className: '',
|
|
5
4
|
style: {},
|
|
6
|
-
text:
|
|
5
|
+
text: '',
|
|
7
6
|
maxCharacters: 0,
|
|
8
|
-
maxWidth:
|
|
7
|
+
maxWidth: '100%',
|
|
9
8
|
textEllipsis: false,
|
|
10
|
-
textAlignment:
|
|
9
|
+
textAlignment: 'left',
|
|
11
10
|
wordBreak: true
|
|
12
11
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=defaultProps.js.map
|
|
12
|
+
|
|
13
|
+
export { defaultProps };
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export * from "./DSTextWrapper";
|
|
3
|
-
import { default as default2 } from "./DSTextWrapper";
|
|
4
|
-
export {
|
|
5
|
-
default2 as default
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default } from './DSTextWrapper.js';
|
package/esm/props.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
3
|
const textProps = {
|
|
4
|
-
containerProps: PropTypes.object.description(
|
|
5
|
-
className: PropTypes.string.description(
|
|
6
|
-
style: PropTypes.object.description(
|
|
7
|
-
text: PropTypes.string.description(
|
|
8
|
-
maxCharacters: PropTypes.number.description(
|
|
9
|
-
maxWidth: PropTypes.string.description(
|
|
10
|
-
textEllipsis: PropTypes.bool.description(
|
|
11
|
-
textAlignment: PropTypes.oneOf([
|
|
12
|
-
wordBreak: PropTypes.bool.description(
|
|
4
|
+
containerProps: PropTypes.object.description('Set of Properties attached to the main container'),
|
|
5
|
+
className: PropTypes.string.description('css class'),
|
|
6
|
+
style: PropTypes.object.description('css style'),
|
|
7
|
+
text: PropTypes.string.description('Text to display').isRequired,
|
|
8
|
+
maxCharacters: PropTypes.number.description('Maximum amount of charachters allowed'),
|
|
9
|
+
maxWidth: PropTypes.string.description('Maximum width allowed'),
|
|
10
|
+
textEllipsis: PropTypes.bool.description('Whether to show ellipsis or not'),
|
|
11
|
+
textAlignment: PropTypes.oneOf(['left', 'center', 'right']).description('Text alignement'),
|
|
12
|
+
wordBreak: PropTypes.bool.description('Whether to break the line or not')
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=props.js.map
|
|
14
|
+
|
|
15
|
+
export { textProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-text-wrapper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Text Wrapper",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"build": "node ../../scripts/build/build.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@elliemae/ds-classnames": "
|
|
47
|
+
"@elliemae/ds-classnames": "3.0.0-next.2",
|
|
48
48
|
"react-desc": "~4.1.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
package/cjs/DSTextWrapper.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/DSTextWrapper.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkB;AAClB,wBAAyB;AACzB,2BAA0C;AAC1C,mBAA0B;AAC1B,0BAA6B;AAS7B,MAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,EAAE,cAAc,qBAAqB,oDACzC,mBACA,WACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA;AAGJ,QAAM,oBAAoB,MACxB,KAAK,MAAM,KAAK,OACd,CAAC,QAAQ,SAAS;AAChB,QAAI,cAAc,OAAO,SAAS;AAClC,QAAI,OAAO,aAAa,SAAS,KAAK,SAAS;AAC7C,qBAAe;AACjB,WAAO,eAAe,GAAG,OAAO,gBAAgB,MAAM;AACtD,WAAO;AAAA,KAET,CAAC;AAGL,MAAI,cAAc;AAElB,MAAI;AACF,kBACE,gBAAgB,IAAI,YAAY,UAAU,GAAG,iBAAiB;AAAA,WACzD,gBAAgB,GAAG;AAC1B,kBAAc,oBAAoB,IAAI,CAAC,UAAU,UAC/C,mDAAC,QAAD;AAAA,MAAM,KAAK;AAAA,MAAO,WAAW,iBAAiB;AAAA,OAC3C;AAAA;AAKP,SACE,mDAAC,QAAD;AAAA,OACM;AAAA,IACJ,WAAW;AAAA,IACX,OAAO;AAAA,MACL,UAAU,gBAAgB,IAAI,WAAW;AAAA,SACtC;AAAA;AAAA,KAGJ,eACC,mDAAC,QAAD;AAAA,IAAM,WAAW,iBAAiB;AAAA,KAC/B,eAGH;AAAA;AAMR,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,MAAM,wBAAwB,gCAAS;AACvC,sBAAsB,YAAY;AAGlC,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/cjs/defaultProps.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/defaultProps.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe;AAAA,EAC1B,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/cjs/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["export * from './DSTextWrapper';\nexport { default } from './DSTextWrapper';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAAc;AACd,2BAAwB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/cjs/props.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/props.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,wBAA0B;AAEnB,MAAM,YAAY;AAAA,EACvB,gBAAgB,4BAAU,OAAO,YAC/B;AAAA,EAEF,WAAW,4BAAU,OAAO,YAAY;AAAA,EACxC,OAAO,4BAAU,OAAO,YAAY;AAAA,EACpC,MAAM,4BAAU,OAAO,YAAY,mBAAmB;AAAA,EACtD,eAAe,4BAAU,OAAO,YAC9B;AAAA,EAEF,UAAU,4BAAU,OAAO,YAAY;AAAA,EACvC,cAAc,4BAAU,KAAK,YAAY;AAAA,EACzC,eAAe,4BAAU,MAAM,CAAC,QAAQ,UAAU,UAAU,YAC1D;AAAA,EAEF,WAAW,4BAAU,KAAK,YAAY;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/esm/DSTextWrapper.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSTextWrapper.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
|
|
5
|
-
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AASA,MAAM,gBAAgB,CAAC;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,EAAE,cAAc,qBAAqB,0BACzC,mBACA,WACA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA;AAGJ,QAAM,oBAAoB,MACxB,KAAK,MAAM,KAAK,OACd,CAAC,QAAQ,SAAS;AAChB,QAAI,cAAc,OAAO,SAAS;AAClC,QAAI,OAAO,aAAa,SAAS,KAAK,SAAS;AAC7C,qBAAe;AACjB,WAAO,eAAe,GAAG,OAAO,gBAAgB,MAAM;AACtD,WAAO;AAAA,KAET,CAAC;AAGL,MAAI,cAAc;AAElB,MAAI;AACF,kBACE,gBAAgB,IAAI,YAAY,UAAU,GAAG,iBAAiB;AAAA,WACzD,gBAAgB,GAAG;AAC1B,kBAAc,oBAAoB,IAAI,CAAC,UAAU,UAC/C,qCAAC,QAAD;AAAA,MAAM,KAAK;AAAA,MAAO,WAAW,iBAAiB;AAAA,OAC3C;AAAA;AAKP,SACE,qCAAC,QAAD;AAAA,OACM;AAAA,IACJ,WAAW;AAAA,IACX,OAAO;AAAA,MACL,UAAU,gBAAgB,IAAI,WAAW;AAAA,SACtC;AAAA;AAAA,KAGJ,eACC,qCAAC,QAAD;AAAA,IAAM,WAAW,iBAAiB;AAAA,KAC/B,eAGH;AAAA;AAMR,cAAc,YAAY;AAC1B,cAAc,eAAe;AAE7B,MAAM,wBAAwB,SAAS;AACvC,sBAAsB,YAAY;AAGlC,IAAO,wBAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/esm/defaultProps.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/defaultProps.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA;ACAO,MAAM,eAAe;AAAA,EAC1B,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,eAAe;AAAA,EACf,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AAAA,EACf,WAAW;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/esm/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './DSTextWrapper';\nexport { default } from './DSTextWrapper';\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/esm/props.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/props.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,YAAY;AAAA,EACvB,gBAAgB,UAAU,OAAO,YAC/B;AAAA,EAEF,WAAW,UAAU,OAAO,YAAY;AAAA,EACxC,OAAO,UAAU,OAAO,YAAY;AAAA,EACpC,MAAM,UAAU,OAAO,YAAY,mBAAmB;AAAA,EACtD,eAAe,UAAU,OAAO,YAC9B;AAAA,EAEF,UAAU,UAAU,OAAO,YAAY;AAAA,EACvC,cAAc,UAAU,KAAK,YAAY;AAAA,EACzC,eAAe,UAAU,MAAM,CAAC,QAAQ,UAAU,UAAU,YAC1D;AAAA,EAEF,WAAW,UAAU,KAAK,YAAY;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|