@elliemae/ds-text-wrapper 2.3.0-next.3 → 3.0.0-alpha.0

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.
@@ -0,0 +1,89 @@
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 DSTextWrapper_exports = {};
29
+ __export(DSTextWrapper_exports, {
30
+ DSTextWrapper: () => DSTextWrapper,
31
+ TextWrapperWithSchema: () => TextWrapperWithSchema,
32
+ default: () => DSTextWrapper_default
33
+ });
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_react_desc = require("react-desc");
37
+ var import_ds_classnames = require("@elliemae/ds-classnames");
38
+ var import_props = require("./props");
39
+ var import_defaultProps = require("./defaultProps");
40
+ const DSTextWrapper = ({
41
+ containerProps,
42
+ className,
43
+ style,
44
+ text,
45
+ maxCharacters,
46
+ maxWidth,
47
+ textEllipsis,
48
+ textAlignment,
49
+ wordBreak
50
+ }) => {
51
+ const { cssClassName, classNameElement } = (0, import_ds_classnames.convertPropToCssClassName)("text-wrapperRef", className, {
52
+ textEllipsis,
53
+ textAlignment,
54
+ wordBreak
55
+ });
56
+ const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
57
+ let resultIndex = result.length - 1;
58
+ if (result[resultIndex].length + word.length > maxCharacters)
59
+ resultIndex += 1;
60
+ result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
61
+ return result;
62
+ }, [""]);
63
+ let displayText = text;
64
+ if (textEllipsis)
65
+ displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;
66
+ else if (maxCharacters > 0) {
67
+ displayText = limitPerCharacter().map((textpart, index) => /* @__PURE__ */ import_react.default.createElement("span", {
68
+ key: index,
69
+ className: classNameElement("line")
70
+ }, textpart));
71
+ }
72
+ return /* @__PURE__ */ import_react.default.createElement("span", {
73
+ ...containerProps,
74
+ className: cssClassName,
75
+ style: {
76
+ maxWidth: maxCharacters < 1 ? maxWidth : null,
77
+ ...style
78
+ }
79
+ }, textEllipsis ? /* @__PURE__ */ import_react.default.createElement("span", {
80
+ className: classNameElement("ellipsis-wrapperRef")
81
+ }, displayText) : displayText);
82
+ };
83
+ DSTextWrapper.propTypes = import_props.textProps;
84
+ DSTextWrapper.defaultProps = import_defaultProps.defaultProps;
85
+ const TextWrapperWithSchema = (0, import_react_desc.describe)(DSTextWrapper);
86
+ TextWrapperWithSchema.propTypes = import_props.textProps;
87
+ var DSTextWrapper_default = DSTextWrapper;
88
+ module.exports = __toCommonJS(DSTextWrapper_exports);
89
+ //# 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;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
+ }
@@ -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,60 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { describe } from "react-desc";
4
+ import { convertPropToCssClassName } from "@elliemae/ds-classnames";
5
+ import { textProps } from "./props";
6
+ import { defaultProps } from "./defaultProps";
7
+ const DSTextWrapper = ({
8
+ containerProps,
9
+ className,
10
+ style,
11
+ text,
12
+ maxCharacters,
13
+ maxWidth,
14
+ textEllipsis,
15
+ textAlignment,
16
+ wordBreak
17
+ }) => {
18
+ const { cssClassName, classNameElement } = convertPropToCssClassName("text-wrapperRef", className, {
19
+ textEllipsis,
20
+ textAlignment,
21
+ wordBreak
22
+ });
23
+ const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
24
+ let resultIndex = result.length - 1;
25
+ if (result[resultIndex].length + word.length > maxCharacters)
26
+ resultIndex += 1;
27
+ result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
28
+ return result;
29
+ }, [""]);
30
+ let displayText = text;
31
+ if (textEllipsis)
32
+ displayText = maxCharacters > 0 ? displayText.substring(0, maxCharacters) : displayText;
33
+ else if (maxCharacters > 0) {
34
+ displayText = limitPerCharacter().map((textpart, index) => /* @__PURE__ */ React2.createElement("span", {
35
+ key: index,
36
+ className: classNameElement("line")
37
+ }, textpart));
38
+ }
39
+ return /* @__PURE__ */ React2.createElement("span", {
40
+ ...containerProps,
41
+ className: cssClassName,
42
+ style: {
43
+ maxWidth: maxCharacters < 1 ? maxWidth : null,
44
+ ...style
45
+ }
46
+ }, textEllipsis ? /* @__PURE__ */ React2.createElement("span", {
47
+ className: classNameElement("ellipsis-wrapperRef")
48
+ }, displayText) : displayText);
49
+ };
50
+ DSTextWrapper.propTypes = textProps;
51
+ DSTextWrapper.defaultProps = defaultProps;
52
+ const TextWrapperWithSchema = describe(DSTextWrapper);
53
+ TextWrapperWithSchema.propTypes = textProps;
54
+ var DSTextWrapper_default = DSTextWrapper;
55
+ export {
56
+ DSTextWrapper,
57
+ TextWrapperWithSchema,
58
+ DSTextWrapper_default as default
59
+ };
60
+ //# 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;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
+ }
@@ -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
+ import * as React from "react";
2
+ export * from "./DSTextWrapper";
3
+ import { default as default2 } from "./DSTextWrapper";
4
+ export {
5
+ default2 as default
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -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
+ }
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,27 +1,30 @@
1
1
  {
2
2
  "name": "@elliemae/ds-text-wrapper",
3
- "version": "2.3.0-next.3",
3
+ "version": "3.0.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Text Wrapper",
6
- "module": "./esm/index.js",
7
- "main": "./cjs/index.js",
8
- "types": "./types/index.d.ts",
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
- "npm": ">=7",
37
- "node": ">=14"
39
+ "pnpm": ">=6",
40
+ "node": ">=16"
38
41
  },
39
42
  "author": "ICE MT",
40
- "scripts": {
41
- "dev": "cross-env NODE_ENV=development && node ../../scripts/build/build.js -w",
42
- "prebuild": "exit 0",
43
- "predev": "exit 0",
44
- "build": "node ../../scripts/build/build.js"
43
+ "jestSonar": {
44
+ "sonar56x": true,
45
+ "reportPath": "reports",
46
+ "reportFile": "tests.xml",
47
+ "indent": 4
45
48
  },
46
49
  "dependencies": {
47
- "@elliemae/ds-classnames": "2.3.0-next.3",
50
+ "@elliemae/ds-classnames": "3.0.0-alpha.0",
48
51
  "react-desc": "~4.1.3"
49
52
  },
50
53
  "peerDependencies": {
@@ -54,7 +57,12 @@
54
57
  },
55
58
  "publishConfig": {
56
59
  "access": "public",
57
- "directory": "dist",
58
- "generateSubmodules": true
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
+ "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs"
59
67
  }
60
68
  }
@@ -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;
@@ -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;
@@ -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 };
@@ -1,13 +0,0 @@
1
- const defaultProps = {
2
- containerProps: {},
3
- className: '',
4
- style: {},
5
- text: '',
6
- maxCharacters: 0,
7
- maxWidth: '100%',
8
- textEllipsis: false,
9
- textAlignment: 'left',
10
- wordBreak: true
11
- };
12
-
13
- export { defaultProps };
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 };