@elliemae/ds-text-wrapper 2.2.0-next.4 → 2.3.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,83 +1,89 @@
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, {
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, {
48
52
  textEllipsis,
49
53
  textAlignment,
50
54
  wordBreak
51
55
  });
52
-
53
- const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
56
+ const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
54
57
  let resultIndex = result.length - 1;
55
- if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
56
- result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
58
+ if (result[resultIndex].length + word.length > maxCharacters)
59
+ resultIndex += 1;
60
+ result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
57
61
  return result;
58
- }, ['']);
59
-
62
+ }, [""]);
60
63
  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));
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));
65
71
  }
66
- return /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
72
+ return /* @__PURE__ */ import_react.default.createElement("span", {
73
+ ...containerProps,
67
74
  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
+ 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);
75
82
  };
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;
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
+ }
@@ -1,17 +1,45 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
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"));
5
33
  const defaultProps = {
6
34
  containerProps: {},
7
- className: '',
35
+ className: "",
8
36
  style: {},
9
- text: '',
37
+ text: "",
10
38
  maxCharacters: 0,
11
- maxWidth: '100%',
39
+ maxWidth: "100%",
12
40
  textEllipsis: false,
13
- textAlignment: 'left',
41
+ textAlignment: "left",
14
42
  wordBreak: true
15
43
  };
16
-
17
- exports.defaultProps = defaultProps;
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
+ }
package/cjs/index.js CHANGED
@@ -1,11 +1,36 @@
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;
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
+ }
package/cjs/props.js CHANGED
@@ -1,19 +1,46 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactDesc = require('react-desc');
6
-
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");
7
34
  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')
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")
17
44
  };
18
-
19
- exports.textProps = textProps;
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
+ }
@@ -1,72 +1,60 @@
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, {
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, {
39
19
  textEllipsis,
40
20
  textAlignment,
41
21
  wordBreak
42
22
  });
43
-
44
- const limitPerCharacter = () => text.split(' ').reduce((result, word) => {
23
+ const limitPerCharacter = () => text.split(" ").reduce((result, word) => {
45
24
  let resultIndex = result.length - 1;
46
- if (result[resultIndex].length + word.length > maxCharacters) resultIndex += 1;
47
- result[resultIndex] = "".concat(result[resultIndex] || '', " ").concat(word);
25
+ if (result[resultIndex].length + word.length > maxCharacters)
26
+ resultIndex += 1;
27
+ result[resultIndex] = `${result[resultIndex] || ""} ${word}`;
48
28
  return result;
49
- }, ['']);
50
-
29
+ }, [""]);
51
30
  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));
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));
56
38
  }
57
- return /*#__PURE__*/jsx("span", _objectSpread(_objectSpread({}, containerProps), {}, {
39
+ return /* @__PURE__ */ React2.createElement("span", {
40
+ ...containerProps,
58
41
  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
- }));
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);
66
49
  };
67
-
50
+ DSTextWrapper.propTypes = textProps;
68
51
  DSTextWrapper.defaultProps = defaultProps;
69
52
  const TextWrapperWithSchema = describe(DSTextWrapper);
70
53
  TextWrapperWithSchema.propTypes = textProps;
71
-
72
- export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default };
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
+ }
@@ -1,13 +1,16 @@
1
+ import * as React from "react";
1
2
  const defaultProps = {
2
3
  containerProps: {},
3
- className: '',
4
+ className: "",
4
5
  style: {},
5
- text: '',
6
+ text: "",
6
7
  maxCharacters: 0,
7
- maxWidth: '100%',
8
+ maxWidth: "100%",
8
9
  textEllipsis: false,
9
- textAlignment: 'left',
10
+ textAlignment: "left",
10
11
  wordBreak: true
11
12
  };
12
-
13
- export { defaultProps };
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
+ }
package/esm/index.js CHANGED
@@ -1 +1,7 @@
1
- export { DSTextWrapper, TextWrapperWithSchema, DSTextWrapper as default } from './DSTextWrapper.js';
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
+ }
package/esm/props.js CHANGED
@@ -1,15 +1,17 @@
1
- import { PropTypes } from 'react-desc';
2
-
1
+ import * as React from "react";
2
+ import { PropTypes } from "react-desc";
3
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')
4
+ containerProps: PropTypes.object.description("Set of Properties attached to the main container"),
5
+ className: PropTypes.string.description("css class"),
6
+ style: PropTypes.object.description("css style"),
7
+ text: PropTypes.string.description("Text to display").isRequired,
8
+ maxCharacters: PropTypes.number.description("Maximum amount of charachters allowed"),
9
+ maxWidth: PropTypes.string.description("Maximum width allowed"),
10
+ textEllipsis: PropTypes.bool.description("Whether to show ellipsis or not"),
11
+ textAlignment: PropTypes.oneOf(["left", "center", "right"]).description("Text alignement"),
12
+ wordBreak: PropTypes.bool.description("Whether to break the line or not")
13
13
  };
14
-
15
- export { textProps };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-text-wrapper",
3
- "version": "2.2.0-next.4",
3
+ "version": "2.3.0-alpha.2",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Text Wrapper",
6
6
  "module": "./esm/index.js",
@@ -44,7 +44,7 @@
44
44
  "build": "node ../../scripts/build/build.js"
45
45
  },
46
46
  "dependencies": {
47
- "@elliemae/ds-classnames": "2.2.0-next.4",
47
+ "@elliemae/ds-classnames": "2.3.0-alpha.2",
48
48
  "react-desc": "~4.1.3"
49
49
  },
50
50
  "peerDependencies": {
@@ -83,17 +83,7 @@ declare const DSTextWrapper: {
83
83
  };
84
84
  };
85
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;
86
+ (props?: unknown): JSX.Element;
97
87
  propTypes: unknown;
98
88
  toTypescript: () => import("react-desc").TypescriptSchema;
99
89
  };