@elliemae/ds-text-wrapper 3.0.0-next.0 → 3.0.0-next.4
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/dist/cjs/DSTextWrapper.js +104 -0
- package/dist/cjs/DSTextWrapper.js.map +7 -0
- package/dist/cjs/defaultProps.js +45 -0
- package/dist/cjs/defaultProps.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/props.js +46 -0
- package/dist/cjs/props.js.map +7 -0
- package/dist/esm/DSTextWrapper.js +77 -0
- package/dist/esm/DSTextWrapper.js.map +7 -0
- package/dist/esm/defaultProps.js +16 -0
- package/dist/esm/defaultProps.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/props.js +17 -0
- package/dist/esm/props.js.map +7 -0
- package/package.json +31 -22
- package/cjs/DSTextWrapper.js +0 -83
- package/cjs/defaultProps.js +0 -17
- package/cjs/index.js +0 -11
- package/cjs/props.js +0 -19
- package/esm/DSTextWrapper.js +0 -72
- package/esm/defaultProps.js +0 -13
- package/esm/index.js +0 -1
- package/esm/props.js +0 -15
- package/types/DSTextWrapper.d.ts +0 -101
- package/types/defaultProps.d.ts +0 -11
- package/types/index.d.ts +0 -2
- package/types/props.d.ts +0 -52
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __export = (target, all) => {
|
|
26
|
+
for (var name in all)
|
|
27
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
|
+
};
|
|
29
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
30
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
31
|
+
for (let key of __getOwnPropNames(module2))
|
|
32
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
33
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (module2, isNodeMode) => {
|
|
38
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
39
|
+
};
|
|
40
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
+
return (module2, temp) => {
|
|
42
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
+
};
|
|
44
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
45
|
+
var DSTextWrapper_exports = {};
|
|
46
|
+
__export(DSTextWrapper_exports, {
|
|
47
|
+
DSTextWrapper: () => DSTextWrapper,
|
|
48
|
+
TextWrapperWithSchema: () => TextWrapperWithSchema,
|
|
49
|
+
default: () => DSTextWrapper_default
|
|
50
|
+
});
|
|
51
|
+
var React = __toESM(require("react"));
|
|
52
|
+
var import_react = __toESM(require("react"));
|
|
53
|
+
var import_react_desc = require("react-desc");
|
|
54
|
+
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
55
|
+
var import_props = require("./props");
|
|
56
|
+
var import_defaultProps = require("./defaultProps");
|
|
57
|
+
const DSTextWrapper = ({
|
|
58
|
+
containerProps,
|
|
59
|
+
className,
|
|
60
|
+
style,
|
|
61
|
+
text,
|
|
62
|
+
maxCharacters,
|
|
63
|
+
maxWidth,
|
|
64
|
+
textEllipsis,
|
|
65
|
+
textAlignment,
|
|
66
|
+
wordBreak
|
|
67
|
+
}) => {
|
|
68
|
+
const { cssClassName, classNameElement } = (0, import_ds_classnames.convertPropToCssClassName)("text-wrapperRef", className, {
|
|
69
|
+
textEllipsis,
|
|
70
|
+
textAlignment,
|
|
71
|
+
wordBreak
|
|
72
|
+
});
|
|
73
|
+
const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
|
|
74
|
+
let resultIndex = result.length - 1;
|
|
75
|
+
if (result[resultIndex].length + word.length > maxCharacters)
|
|
76
|
+
resultIndex += 1;
|
|
77
|
+
result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
|
|
78
|
+
return result;
|
|
79
|
+
}, [""]);
|
|
80
|
+
let displayText = text;
|
|
81
|
+
if (textEllipsis)
|
|
82
|
+
displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;
|
|
83
|
+
else if (maxCharacters > 0) {
|
|
84
|
+
displayText = limitPerCharacter().map((textpart, index) => /* @__PURE__ */ import_react.default.createElement("span", {
|
|
85
|
+
key: index,
|
|
86
|
+
className: classNameElement("line")
|
|
87
|
+
}, textpart));
|
|
88
|
+
}
|
|
89
|
+
return /* @__PURE__ */ import_react.default.createElement("span", __spreadProps(__spreadValues({}, containerProps), {
|
|
90
|
+
className: cssClassName,
|
|
91
|
+
style: __spreadValues({
|
|
92
|
+
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
93
|
+
}, style)
|
|
94
|
+
}), textEllipsis ? /* @__PURE__ */ import_react.default.createElement("span", {
|
|
95
|
+
className: classNameElement("ellipsis-wrapperRef")
|
|
96
|
+
}, displayText) : displayText);
|
|
97
|
+
};
|
|
98
|
+
DSTextWrapper.propTypes = import_props.textProps;
|
|
99
|
+
DSTextWrapper.defaultProps = import_defaultProps.defaultProps;
|
|
100
|
+
const TextWrapperWithSchema = (0, import_react_desc.describe)(DSTextWrapper);
|
|
101
|
+
TextWrapperWithSchema.propTypes = import_props.textProps;
|
|
102
|
+
var DSTextWrapper_default = DSTextWrapper;
|
|
103
|
+
module.exports = __toCommonJS(DSTextWrapper_exports);
|
|
104
|
+
//# sourceMappingURL=DSTextWrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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,iCACM,iBADN;AAAA,IAEE,WAAW;AAAA,IACX,OAAO;AAAA,MACL,UAAU,gBAAgB,IAAI,WAAW;AAAA,OACtC;AAAA,MAGJ,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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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"));
|
|
33
|
+
const defaultProps = {
|
|
34
|
+
containerProps: {},
|
|
35
|
+
className: "",
|
|
36
|
+
style: {},
|
|
37
|
+
text: "",
|
|
38
|
+
maxCharacters: 0,
|
|
39
|
+
maxWidth: "100%",
|
|
40
|
+
textEllipsis: false,
|
|
41
|
+
textAlignment: "left",
|
|
42
|
+
wordBreak: true
|
|
43
|
+
};
|
|
44
|
+
module.exports = __toCommonJS(defaultProps_exports);
|
|
45
|
+
//# sourceMappingURL=defaultProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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 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 = __toESM(require("./DSTextWrapper"));
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
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 props_exports = {};
|
|
29
|
+
__export(props_exports, {
|
|
30
|
+
textProps: () => textProps
|
|
31
|
+
});
|
|
32
|
+
var React = __toESM(require("react"));
|
|
33
|
+
var import_react_desc = require("react-desc");
|
|
34
|
+
const textProps = {
|
|
35
|
+
containerProps: import_react_desc.PropTypes.object.description("Set of Properties attached to the main container"),
|
|
36
|
+
className: import_react_desc.PropTypes.string.description("css class"),
|
|
37
|
+
style: import_react_desc.PropTypes.object.description("css style"),
|
|
38
|
+
text: import_react_desc.PropTypes.string.description("Text to display").isRequired,
|
|
39
|
+
maxCharacters: import_react_desc.PropTypes.number.description("Maximum amount of charachters allowed"),
|
|
40
|
+
maxWidth: import_react_desc.PropTypes.string.description("Maximum width allowed"),
|
|
41
|
+
textEllipsis: import_react_desc.PropTypes.bool.description("Whether to show ellipsis or not"),
|
|
42
|
+
textAlignment: import_react_desc.PropTypes.oneOf(["left", "center", "right"]).description("Text alignement"),
|
|
43
|
+
wordBreak: import_react_desc.PropTypes.bool.description("Whether to break the line or not")
|
|
44
|
+
};
|
|
45
|
+
module.exports = __toCommonJS(props_exports);
|
|
46
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import { describe } from "react-desc";
|
|
23
|
+
import { convertPropToCssClassName } from "@elliemae/ds-classnames";
|
|
24
|
+
import { textProps } from "./props";
|
|
25
|
+
import { defaultProps } from "./defaultProps";
|
|
26
|
+
const DSTextWrapper = ({
|
|
27
|
+
containerProps,
|
|
28
|
+
className,
|
|
29
|
+
style,
|
|
30
|
+
text,
|
|
31
|
+
maxCharacters,
|
|
32
|
+
maxWidth,
|
|
33
|
+
textEllipsis,
|
|
34
|
+
textAlignment,
|
|
35
|
+
wordBreak
|
|
36
|
+
}) => {
|
|
37
|
+
const { cssClassName, classNameElement } = convertPropToCssClassName("text-wrapperRef", className, {
|
|
38
|
+
textEllipsis,
|
|
39
|
+
textAlignment,
|
|
40
|
+
wordBreak
|
|
41
|
+
});
|
|
42
|
+
const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
|
|
43
|
+
let resultIndex = result.length - 1;
|
|
44
|
+
if (result[resultIndex].length + word.length > maxCharacters)
|
|
45
|
+
resultIndex += 1;
|
|
46
|
+
result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
|
|
47
|
+
return result;
|
|
48
|
+
}, [""]);
|
|
49
|
+
let displayText = text;
|
|
50
|
+
if (textEllipsis)
|
|
51
|
+
displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;
|
|
52
|
+
else if (maxCharacters > 0) {
|
|
53
|
+
displayText = limitPerCharacter().map((textpart, index) => /* @__PURE__ */ React2.createElement("span", {
|
|
54
|
+
key: index,
|
|
55
|
+
className: classNameElement("line")
|
|
56
|
+
}, textpart));
|
|
57
|
+
}
|
|
58
|
+
return /* @__PURE__ */ React2.createElement("span", __spreadProps(__spreadValues({}, containerProps), {
|
|
59
|
+
className: cssClassName,
|
|
60
|
+
style: __spreadValues({
|
|
61
|
+
maxWidth: maxCharacters < 1 ? maxWidth : null
|
|
62
|
+
}, style)
|
|
63
|
+
}), textEllipsis ? /* @__PURE__ */ React2.createElement("span", {
|
|
64
|
+
className: classNameElement("ellipsis-wrapperRef")
|
|
65
|
+
}, displayText) : displayText);
|
|
66
|
+
};
|
|
67
|
+
DSTextWrapper.propTypes = textProps;
|
|
68
|
+
DSTextWrapper.defaultProps = defaultProps;
|
|
69
|
+
const TextWrapperWithSchema = describe(DSTextWrapper);
|
|
70
|
+
TextWrapperWithSchema.propTypes = textProps;
|
|
71
|
+
var DSTextWrapper_default = DSTextWrapper;
|
|
72
|
+
export {
|
|
73
|
+
DSTextWrapper,
|
|
74
|
+
TextWrapperWithSchema,
|
|
75
|
+
DSTextWrapper_default as default
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=DSTextWrapper.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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,iCACM,iBADN;AAAA,IAEE,WAAW;AAAA,IACX,OAAO;AAAA,MACL,UAAU,gBAAgB,IAAI,WAAW;AAAA,OACtC;AAAA,MAGJ,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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const defaultProps = {
|
|
3
|
+
containerProps: {},
|
|
4
|
+
className: "",
|
|
5
|
+
style: {},
|
|
6
|
+
text: "",
|
|
7
|
+
maxCharacters: 0,
|
|
8
|
+
maxWidth: "100%",
|
|
9
|
+
textEllipsis: false,
|
|
10
|
+
textAlignment: "left",
|
|
11
|
+
wordBreak: true
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
defaultProps
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=defaultProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "react-desc";
|
|
3
|
+
const textProps = {
|
|
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
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
textProps
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-text-wrapper",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Text Wrapper",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
|
-
"import": "./esm/index.js",
|
|
12
|
-
"require": "./cjs/index.js"
|
|
14
|
+
"import": "./dist/esm/index.js",
|
|
15
|
+
"require": "./dist/cjs/index.js"
|
|
13
16
|
},
|
|
14
17
|
"./props": {
|
|
15
|
-
"import": "./esm/props.js",
|
|
16
|
-
"require": "./cjs/props.js"
|
|
18
|
+
"import": "./dist/esm/props.js",
|
|
19
|
+
"require": "./dist/cjs/props.js"
|
|
17
20
|
},
|
|
18
21
|
"./DSTextWrapper": {
|
|
19
|
-
"import": "./esm/DSTextWrapper.js",
|
|
20
|
-
"require": "./cjs/DSTextWrapper.js"
|
|
22
|
+
"import": "./dist/esm/DSTextWrapper.js",
|
|
23
|
+
"require": "./dist/cjs/DSTextWrapper.js"
|
|
21
24
|
},
|
|
22
25
|
"./defaultProps": {
|
|
23
|
-
"import": "./esm/defaultProps.js",
|
|
24
|
-
"require": "./cjs/defaultProps.js"
|
|
26
|
+
"import": "./dist/esm/defaultProps.js",
|
|
27
|
+
"require": "./dist/cjs/defaultProps.js"
|
|
25
28
|
}
|
|
26
29
|
},
|
|
27
30
|
"sideEffects": [
|
|
@@ -33,18 +36,18 @@
|
|
|
33
36
|
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
34
37
|
},
|
|
35
38
|
"engines": {
|
|
36
|
-
"
|
|
37
|
-
"node": ">=
|
|
39
|
+
"pnpm": ">=6",
|
|
40
|
+
"node": ">=16"
|
|
38
41
|
},
|
|
39
42
|
"author": "ICE MT",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"jestSonar": {
|
|
44
|
+
"sonar56x": true,
|
|
45
|
+
"reportPath": "reports",
|
|
46
|
+
"reportFile": "tests.xml",
|
|
47
|
+
"indent": 4
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
|
-
"@elliemae/ds-classnames": "3.0.0-next.
|
|
50
|
+
"@elliemae/ds-classnames": "3.0.0-next.4",
|
|
48
51
|
"react-desc": "~4.1.3"
|
|
49
52
|
},
|
|
50
53
|
"peerDependencies": {
|
|
@@ -54,7 +57,13 @@
|
|
|
54
57
|
},
|
|
55
58
|
"publishConfig": {
|
|
56
59
|
"access": "public",
|
|
57
|
-
"
|
|
58
|
-
|
|
60
|
+
"typeSafety": false
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"dev": "cross-env NODE_ENV=development node ../../scripts/build/build.mjs --watch",
|
|
64
|
+
"test": "node ../../scripts/testing/test.mjs",
|
|
65
|
+
"lint": "node ../../scripts/lint.mjs",
|
|
66
|
+
"dts": "node ../../scripts/dts.mjs",
|
|
67
|
+
"build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
|
|
59
68
|
}
|
|
60
69
|
}
|
package/cjs/DSTextWrapper.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
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, {
|
|
48
|
-
textEllipsis,
|
|
49
|
-
textAlignment,
|
|
50
|
-
wordBreak
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
54
|
-
let resultIndex = result.length - 1;
|
|
55
|
-
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
56
|
-
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
57
|
-
return result;
|
|
58
|
-
}, ['']);
|
|
59
|
-
|
|
60
|
-
let displayText = text;
|
|
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));
|
|
65
|
-
}
|
|
66
|
-
return /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
67
|
-
className: cssClassName,
|
|
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
|
-
}));
|
|
75
|
-
};
|
|
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
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const defaultProps = {
|
|
6
|
-
containerProps: {},
|
|
7
|
-
className: '',
|
|
8
|
-
style: {},
|
|
9
|
-
text: '',
|
|
10
|
-
maxCharacters: 0,
|
|
11
|
-
maxWidth: '100%',
|
|
12
|
-
textEllipsis: false,
|
|
13
|
-
textAlignment: 'left',
|
|
14
|
-
wordBreak: true
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.defaultProps = defaultProps;
|
package/cjs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var reactDesc = require('react-desc');
|
|
6
|
-
|
|
7
|
-
const textProps = {
|
|
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')
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.textProps = textProps;
|
package/esm/DSTextWrapper.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
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, {
|
|
39
|
-
textEllipsis,
|
|
40
|
-
textAlignment,
|
|
41
|
-
wordBreak
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
|
|
45
|
-
let resultIndex = result.length - 1;
|
|
46
|
-
if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
|
|
47
|
-
result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
|
|
48
|
-
return result;
|
|
49
|
-
}, ['']);
|
|
50
|
-
|
|
51
|
-
let displayText = text;
|
|
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));
|
|
56
|
-
}
|
|
57
|
-
return /*#__PURE__*/jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
58
|
-
className: cssClassName,
|
|
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
|
-
}));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
DSTextWrapper.defaultProps = defaultProps;
|
|
69
|
-
const TextWrapperWithSchema = describe(DSTextWrapper);
|
|
70
|
-
TextWrapperWithSchema.propTypes = textProps;
|
|
71
|
-
|
|
72
|
-
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default };
|
package/esm/defaultProps.js
DELETED
package/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default } from './DSTextWrapper.js';
|
package/esm/props.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PropTypes } from 'react-desc';
|
|
2
|
-
|
|
3
|
-
const textProps = {
|
|
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
|
-
};
|
|
14
|
-
|
|
15
|
-
export { textProps };
|
package/types/DSTextWrapper.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
|
-
/**
|
|
4
|
-
* if we don't care about word break
|
|
5
|
-
* const regx = new RegExp(`.{1,${maxCharacters}}`, 'g')
|
|
6
|
-
* text.match(regx)
|
|
7
|
-
*
|
|
8
|
-
* @param {*} param0
|
|
9
|
-
*/
|
|
10
|
-
declare const DSTextWrapper: {
|
|
11
|
-
({ containerProps, className, style, text, maxCharacters, maxWidth, textEllipsis, textAlignment, wordBreak, }: {
|
|
12
|
-
containerProps: any;
|
|
13
|
-
className: any;
|
|
14
|
-
style: any;
|
|
15
|
-
text: any;
|
|
16
|
-
maxCharacters: any;
|
|
17
|
-
maxWidth: any;
|
|
18
|
-
textEllipsis: any;
|
|
19
|
-
textAlignment: any;
|
|
20
|
-
wordBreak: any;
|
|
21
|
-
}): JSX.Element;
|
|
22
|
-
propTypes: {
|
|
23
|
-
containerProps: {
|
|
24
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
25
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
26
|
-
};
|
|
27
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
28
|
-
};
|
|
29
|
-
className: {
|
|
30
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
31
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
32
|
-
};
|
|
33
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
34
|
-
};
|
|
35
|
-
style: {
|
|
36
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
37
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
38
|
-
};
|
|
39
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
40
|
-
};
|
|
41
|
-
text: import("react-desc").PropTypesDescValue;
|
|
42
|
-
maxCharacters: {
|
|
43
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
44
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
45
|
-
};
|
|
46
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
47
|
-
};
|
|
48
|
-
maxWidth: {
|
|
49
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
50
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
51
|
-
};
|
|
52
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
53
|
-
};
|
|
54
|
-
textEllipsis: {
|
|
55
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
56
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
57
|
-
};
|
|
58
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
59
|
-
};
|
|
60
|
-
textAlignment: {
|
|
61
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
62
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
63
|
-
};
|
|
64
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
65
|
-
};
|
|
66
|
-
wordBreak: {
|
|
67
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
68
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
69
|
-
};
|
|
70
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
defaultProps: {
|
|
74
|
-
containerProps: {};
|
|
75
|
-
className: string;
|
|
76
|
-
style: {};
|
|
77
|
-
text: string;
|
|
78
|
-
maxCharacters: number;
|
|
79
|
-
maxWidth: string;
|
|
80
|
-
textEllipsis: boolean;
|
|
81
|
-
textAlignment: string;
|
|
82
|
-
wordBreak: boolean;
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
declare const TextWrapperWithSchema: {
|
|
86
|
-
(props?: {
|
|
87
|
-
containerProps: any;
|
|
88
|
-
className: any;
|
|
89
|
-
style: any;
|
|
90
|
-
text: any;
|
|
91
|
-
maxCharacters: any;
|
|
92
|
-
maxWidth: any;
|
|
93
|
-
textEllipsis: any;
|
|
94
|
-
textAlignment: any;
|
|
95
|
-
wordBreak: any;
|
|
96
|
-
} | undefined): JSX.Element;
|
|
97
|
-
propTypes: unknown;
|
|
98
|
-
toTypescript: () => import("react-desc").TypescriptSchema;
|
|
99
|
-
};
|
|
100
|
-
export { DSTextWrapper, TextWrapperWithSchema };
|
|
101
|
-
export default DSTextWrapper;
|
package/types/defaultProps.d.ts
DELETED
package/types/index.d.ts
DELETED
package/types/props.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/// <reference path="../../../../shared/typings/react-desc.d.ts" />
|
|
2
|
-
export declare const textProps: {
|
|
3
|
-
containerProps: {
|
|
4
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
5
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
6
|
-
};
|
|
7
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
8
|
-
};
|
|
9
|
-
className: {
|
|
10
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
11
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
12
|
-
};
|
|
13
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
14
|
-
};
|
|
15
|
-
style: {
|
|
16
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
17
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
18
|
-
};
|
|
19
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
20
|
-
};
|
|
21
|
-
text: import("react-desc").PropTypesDescValue;
|
|
22
|
-
maxCharacters: {
|
|
23
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
24
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
25
|
-
};
|
|
26
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
27
|
-
};
|
|
28
|
-
maxWidth: {
|
|
29
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
30
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
31
|
-
};
|
|
32
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
33
|
-
};
|
|
34
|
-
textEllipsis: {
|
|
35
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
36
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
37
|
-
};
|
|
38
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
39
|
-
};
|
|
40
|
-
textAlignment: {
|
|
41
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
42
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
43
|
-
};
|
|
44
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
45
|
-
};
|
|
46
|
-
wordBreak: {
|
|
47
|
-
defaultValue(arg: import("react-desc").ReactDescPossibleDefaultValues): {
|
|
48
|
-
deprecated: import("react-desc").PropTypesDescValidator;
|
|
49
|
-
};
|
|
50
|
-
isRequired: import("react-desc").PropTypesDescValue;
|
|
51
|
-
};
|
|
52
|
-
};
|