@chayns-components/core 5.0.0-beta.896 → 5.0.0-beta.897

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.
@@ -11,18 +11,26 @@ const doesElementHasOnlyText = element => {
11
11
  // If element has text (not empty), it is only text.
12
12
  return element.textContent !== '';
13
13
  }
14
+
14
15
  // Element has child elements or no text, so it's not only text.
15
16
  return false;
16
17
  };
17
18
  const removeLastLeafElement = element => {
18
19
  // remove last element of html element where the last element is a leaf element and its content is a string
19
- const lastChild = element.lastElementChild;
20
- if (lastChild && !doesElementHasOnlyText(lastChild) && lastChild.hasChildNodes()) {
21
- removeLastLeafElement(lastChild);
22
- } else if (lastChild && doesElementHasOnlyText(lastChild) && lastChild.textContent && lastChild.textContent.length > 25) {
20
+ const {
21
+ lastElementChild,
22
+ lastChild
23
+ } = element;
24
+ if (lastElementChild && !doesElementHasOnlyText(lastElementChild) && lastElementChild.hasChildNodes()) {
25
+ removeLastLeafElement(lastElementChild);
26
+ } else if (lastChild && lastChild.nodeType === Node.TEXT_NODE && lastChild.textContent && lastChild.textContent.length > 25) {
23
27
  lastChild.textContent = `${lastChild.textContent.substring(0, lastChild.textContent.length - 25)} ...`;
28
+ } else if (lastElementChild && doesElementHasOnlyText(lastElementChild) && lastElementChild.textContent && lastElementChild.textContent.length > 25) {
29
+ lastElementChild.textContent = `${lastElementChild.textContent.substring(0, lastElementChild.textContent.length - 25)} ...`;
24
30
  } else if (lastChild) {
25
31
  element.removeChild(lastChild);
32
+ } else if (lastElementChild) {
33
+ element.removeChild(lastElementChild);
26
34
  }
27
35
  };
28
36
  const truncateElement = (element, referenceHeight) => {
@@ -1 +1 @@
1
- {"version":3,"file":"truncation.js","names":["doesElementOverflow","element","referenceHeight","scrollHeight","doesElementHasOnlyText","children","length","textContent","removeLastLeafElement","lastChild","lastElementChild","hasChildNodes","substring","removeChild","truncateElement","exports"],"sources":["../../../src/utils/truncation.ts"],"sourcesContent":["const doesElementOverflow = (element: HTMLElement, referenceHeight: number): boolean =>\n element.scrollHeight > referenceHeight;\n\nconst doesElementHasOnlyText = (element: HTMLElement): boolean => {\n // Check if element has no child elements.\n if (element.children.length === 0) {\n // If element has text (not empty), it is only text.\n return element.textContent !== '';\n }\n // Element has child elements or no text, so it's not only text.\n return false;\n};\n\nconst removeLastLeafElement = (element: HTMLElement) => {\n // remove last element of html element where the last element is a leaf element and its content is a string\n const lastChild: Element | null = element.lastElementChild;\n if (\n lastChild &&\n !doesElementHasOnlyText(lastChild as HTMLElement) &&\n lastChild.hasChildNodes()\n ) {\n removeLastLeafElement(lastChild as HTMLElement);\n } else if (\n lastChild &&\n doesElementHasOnlyText(lastChild as HTMLElement) &&\n lastChild.textContent &&\n lastChild.textContent.length > 25\n ) {\n lastChild.textContent = `${lastChild.textContent.substring(\n 0,\n lastChild.textContent.length - 25,\n )} ...`;\n } else if (lastChild) {\n element.removeChild(lastChild);\n }\n};\nexport const truncateElement = (element: HTMLElement, referenceHeight: number) => {\n while (doesElementOverflow(element, referenceHeight)) {\n removeLastLeafElement(element);\n }\n};\n"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAGA,CAACC,OAAoB,EAAEC,eAAuB,KACtED,OAAO,CAACE,YAAY,GAAGD,eAAe;AAE1C,MAAME,sBAAsB,GAAIH,OAAoB,IAAc;EAC9D;EACA,IAAIA,OAAO,CAACI,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE;IAC/B;IACA,OAAOL,OAAO,CAACM,WAAW,KAAK,EAAE;EACrC;EACA;EACA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMC,qBAAqB,GAAIP,OAAoB,IAAK;EACpD;EACA,MAAMQ,SAAyB,GAAGR,OAAO,CAACS,gBAAgB;EAC1D,IACID,SAAS,IACT,CAACL,sBAAsB,CAACK,SAAwB,CAAC,IACjDA,SAAS,CAACE,aAAa,CAAC,CAAC,EAC3B;IACEH,qBAAqB,CAACC,SAAwB,CAAC;EACnD,CAAC,MAAM,IACHA,SAAS,IACTL,sBAAsB,CAACK,SAAwB,CAAC,IAChDA,SAAS,CAACF,WAAW,IACrBE,SAAS,CAACF,WAAW,CAACD,MAAM,GAAG,EAAE,EACnC;IACEG,SAAS,CAACF,WAAW,GAAG,GAAGE,SAAS,CAACF,WAAW,CAACK,SAAS,CACtD,CAAC,EACDH,SAAS,CAACF,WAAW,CAACD,MAAM,GAAG,EACnC,CAAC,MAAM;EACX,CAAC,MAAM,IAAIG,SAAS,EAAE;IAClBR,OAAO,CAACY,WAAW,CAACJ,SAAS,CAAC;EAClC;AACJ,CAAC;AACM,MAAMK,eAAe,GAAGA,CAACb,OAAoB,EAAEC,eAAuB,KAAK;EAC9E,OAAOF,mBAAmB,CAACC,OAAO,EAAEC,eAAe,CAAC,EAAE;IAClDM,qBAAqB,CAACP,OAAO,CAAC;EAClC;AACJ,CAAC;AAACc,OAAA,CAAAD,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"truncation.js","names":["doesElementOverflow","element","referenceHeight","scrollHeight","doesElementHasOnlyText","children","length","textContent","removeLastLeafElement","lastElementChild","lastChild","hasChildNodes","nodeType","Node","TEXT_NODE","substring","removeChild","truncateElement","exports"],"sources":["../../../src/utils/truncation.ts"],"sourcesContent":["const doesElementOverflow = (element: HTMLElement, referenceHeight: number): boolean =>\n element.scrollHeight > referenceHeight;\n\nconst doesElementHasOnlyText = (element: HTMLElement): boolean => {\n // Check if element has no child elements.\n if (element.children.length === 0) {\n // If element has text (not empty), it is only text.\n return element.textContent !== '';\n }\n\n // Element has child elements or no text, so it's not only text.\n return false;\n};\n\nconst removeLastLeafElement = (element: HTMLElement) => {\n // remove last element of html element where the last element is a leaf element and its content is a string\n const { lastElementChild, lastChild } = element;\n\n if (\n lastElementChild &&\n !doesElementHasOnlyText(lastElementChild as HTMLElement) &&\n lastElementChild.hasChildNodes()\n ) {\n removeLastLeafElement(lastElementChild as HTMLElement);\n } else if (\n lastChild &&\n lastChild.nodeType === Node.TEXT_NODE &&\n lastChild.textContent &&\n lastChild.textContent.length > 25\n ) {\n lastChild.textContent = `${lastChild.textContent.substring(0, lastChild.textContent.length - 25)} ...`;\n } else if (\n lastElementChild &&\n doesElementHasOnlyText(lastElementChild as HTMLElement) &&\n lastElementChild.textContent &&\n lastElementChild.textContent.length > 25\n ) {\n lastElementChild.textContent = `${lastElementChild.textContent.substring(\n 0,\n lastElementChild.textContent.length - 25,\n )} ...`;\n } else if (lastChild) {\n element.removeChild(lastChild);\n } else if (lastElementChild) {\n element.removeChild(lastElementChild);\n }\n};\nexport const truncateElement = (element: HTMLElement, referenceHeight: number) => {\n while (doesElementOverflow(element, referenceHeight)) {\n removeLastLeafElement(element);\n }\n};\n"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAGA,CAACC,OAAoB,EAAEC,eAAuB,KACtED,OAAO,CAACE,YAAY,GAAGD,eAAe;AAE1C,MAAME,sBAAsB,GAAIH,OAAoB,IAAc;EAC9D;EACA,IAAIA,OAAO,CAACI,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE;IAC/B;IACA,OAAOL,OAAO,CAACM,WAAW,KAAK,EAAE;EACrC;;EAEA;EACA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMC,qBAAqB,GAAIP,OAAoB,IAAK;EACpD;EACA,MAAM;IAAEQ,gBAAgB;IAAEC;EAAU,CAAC,GAAGT,OAAO;EAE/C,IACIQ,gBAAgB,IAChB,CAACL,sBAAsB,CAACK,gBAA+B,CAAC,IACxDA,gBAAgB,CAACE,aAAa,CAAC,CAAC,EAClC;IACEH,qBAAqB,CAACC,gBAA+B,CAAC;EAC1D,CAAC,MAAM,IACHC,SAAS,IACTA,SAAS,CAACE,QAAQ,KAAKC,IAAI,CAACC,SAAS,IACrCJ,SAAS,CAACH,WAAW,IACrBG,SAAS,CAACH,WAAW,CAACD,MAAM,GAAG,EAAE,EACnC;IACEI,SAAS,CAACH,WAAW,GAAG,GAAGG,SAAS,CAACH,WAAW,CAACQ,SAAS,CAAC,CAAC,EAAEL,SAAS,CAACH,WAAW,CAACD,MAAM,GAAG,EAAE,CAAC,MAAM;EAC1G,CAAC,MAAM,IACHG,gBAAgB,IAChBL,sBAAsB,CAACK,gBAA+B,CAAC,IACvDA,gBAAgB,CAACF,WAAW,IAC5BE,gBAAgB,CAACF,WAAW,CAACD,MAAM,GAAG,EAAE,EAC1C;IACEG,gBAAgB,CAACF,WAAW,GAAG,GAAGE,gBAAgB,CAACF,WAAW,CAACQ,SAAS,CACpE,CAAC,EACDN,gBAAgB,CAACF,WAAW,CAACD,MAAM,GAAG,EAC1C,CAAC,MAAM;EACX,CAAC,MAAM,IAAII,SAAS,EAAE;IAClBT,OAAO,CAACe,WAAW,CAACN,SAAS,CAAC;EAClC,CAAC,MAAM,IAAID,gBAAgB,EAAE;IACzBR,OAAO,CAACe,WAAW,CAACP,gBAAgB,CAAC;EACzC;AACJ,CAAC;AACM,MAAMQ,eAAe,GAAGA,CAAChB,OAAoB,EAAEC,eAAuB,KAAK;EAC9E,OAAOF,mBAAmB,CAACC,OAAO,EAAEC,eAAe,CAAC,EAAE;IAClDM,qBAAqB,CAACP,OAAO,CAAC;EAClC;AACJ,CAAC;AAACiB,OAAA,CAAAD,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -5,18 +5,26 @@ const doesElementHasOnlyText = element => {
5
5
  // If element has text (not empty), it is only text.
6
6
  return element.textContent !== '';
7
7
  }
8
+
8
9
  // Element has child elements or no text, so it's not only text.
9
10
  return false;
10
11
  };
11
12
  const removeLastLeafElement = element => {
12
13
  // remove last element of html element where the last element is a leaf element and its content is a string
13
- const lastChild = element.lastElementChild;
14
- if (lastChild && !doesElementHasOnlyText(lastChild) && lastChild.hasChildNodes()) {
15
- removeLastLeafElement(lastChild);
16
- } else if (lastChild && doesElementHasOnlyText(lastChild) && lastChild.textContent && lastChild.textContent.length > 25) {
14
+ const {
15
+ lastElementChild,
16
+ lastChild
17
+ } = element;
18
+ if (lastElementChild && !doesElementHasOnlyText(lastElementChild) && lastElementChild.hasChildNodes()) {
19
+ removeLastLeafElement(lastElementChild);
20
+ } else if (lastChild && lastChild.nodeType === Node.TEXT_NODE && lastChild.textContent && lastChild.textContent.length > 25) {
17
21
  lastChild.textContent = `${lastChild.textContent.substring(0, lastChild.textContent.length - 25)} ...`;
22
+ } else if (lastElementChild && doesElementHasOnlyText(lastElementChild) && lastElementChild.textContent && lastElementChild.textContent.length > 25) {
23
+ lastElementChild.textContent = `${lastElementChild.textContent.substring(0, lastElementChild.textContent.length - 25)} ...`;
18
24
  } else if (lastChild) {
19
25
  element.removeChild(lastChild);
26
+ } else if (lastElementChild) {
27
+ element.removeChild(lastElementChild);
20
28
  }
21
29
  };
22
30
  export const truncateElement = (element, referenceHeight) => {
@@ -1 +1 @@
1
- {"version":3,"file":"truncation.js","names":["doesElementOverflow","element","referenceHeight","scrollHeight","doesElementHasOnlyText","children","length","textContent","removeLastLeafElement","lastChild","lastElementChild","hasChildNodes","substring","removeChild","truncateElement"],"sources":["../../../src/utils/truncation.ts"],"sourcesContent":["const doesElementOverflow = (element: HTMLElement, referenceHeight: number): boolean =>\n element.scrollHeight > referenceHeight;\n\nconst doesElementHasOnlyText = (element: HTMLElement): boolean => {\n // Check if element has no child elements.\n if (element.children.length === 0) {\n // If element has text (not empty), it is only text.\n return element.textContent !== '';\n }\n // Element has child elements or no text, so it's not only text.\n return false;\n};\n\nconst removeLastLeafElement = (element: HTMLElement) => {\n // remove last element of html element where the last element is a leaf element and its content is a string\n const lastChild: Element | null = element.lastElementChild;\n if (\n lastChild &&\n !doesElementHasOnlyText(lastChild as HTMLElement) &&\n lastChild.hasChildNodes()\n ) {\n removeLastLeafElement(lastChild as HTMLElement);\n } else if (\n lastChild &&\n doesElementHasOnlyText(lastChild as HTMLElement) &&\n lastChild.textContent &&\n lastChild.textContent.length > 25\n ) {\n lastChild.textContent = `${lastChild.textContent.substring(\n 0,\n lastChild.textContent.length - 25,\n )} ...`;\n } else if (lastChild) {\n element.removeChild(lastChild);\n }\n};\nexport const truncateElement = (element: HTMLElement, referenceHeight: number) => {\n while (doesElementOverflow(element, referenceHeight)) {\n removeLastLeafElement(element);\n }\n};\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAGA,CAACC,OAAoB,EAAEC,eAAuB,KACtED,OAAO,CAACE,YAAY,GAAGD,eAAe;AAE1C,MAAME,sBAAsB,GAAIH,OAAoB,IAAc;EAC9D;EACA,IAAIA,OAAO,CAACI,QAAQ,CAACC,MAAM,KAAK,CAAC,EAAE;IAC/B;IACA,OAAOL,OAAO,CAACM,WAAW,KAAK,EAAE;EACrC;EACA;EACA,OAAO,KAAK;AAChB,CAAC;AAED,MAAMC,qBAAqB,GAAIP,OAAoB,IAAK;EACpD;EACA,MAAMQ,SAAyB,GAAGR,OAAO,CAACS,gBAAgB;EAC1D,IACID,SAAS,IACT,CAACL,sBAAsB,CAACK,SAAwB,CAAC,IACjDA,SAAS,CAACE,aAAa,CAAC,CAAC,EAC3B;IACEH,qBAAqB,CAACC,SAAwB,CAAC;EACnD,CAAC,MAAM,IACHA,SAAS,IACTL,sBAAsB,CAACK,SAAwB,CAAC,IAChDA,SAAS,CAACF,WAAW,IACrBE,SAAS,CAACF,WAAW,CAACD,MAAM,GAAG,EAAE,EACnC;IACEG,SAAS,CAACF,WAAW,GAAG,GAAGE,SAAS,CAACF,WAAW,CAACK,SAAS,CACtD,CAAC,EACDH,SAAS,CAACF,WAAW,CAACD,MAAM,GAAG,EACnC,CAAC,MAAM;EACX,CAAC,MAAM,IAAIG,SAAS,EAAE;IAClBR,OAAO,CAACY,WAAW,CAACJ,SAAS,CAAC;EAClC;AACJ,CAAC;AACD,OAAO,MAAMK,eAAe,GAAGA,CAACb,OAAoB,EAAEC,eAAuB,KAAK;EAC9E,OAAOF,mBAAmB,CAACC,OAAO,EAAEC,eAAe,CAAC,EAAE;IAClDM,qBAAqB,CAACP,OAAO,CAAC;EAClC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"truncation.js","names":["doesElementOverflow","element","referenceHeight","scrollHeight","doesElementHasOnlyText","children","length","textContent","removeLastLeafElement","lastElementChild","lastChild","hasChildNodes","nodeType","Node","TEXT_NODE","substring","removeChild","truncateElement"],"sources":["../../../src/utils/truncation.ts"],"sourcesContent":["const doesElementOverflow = (element: HTMLElement, referenceHeight: number): boolean =>\n element.scrollHeight > referenceHeight;\n\nconst doesElementHasOnlyText = (element: HTMLElement): boolean => {\n // Check if element has no child elements.\n if (element.children.length === 0) {\n // If element has text (not empty), it is only text.\n return element.textContent !== '';\n }\n\n // Element has child elements or no text, so it's not only text.\n return false;\n};\n\nconst removeLastLeafElement = (element: HTMLElement) => {\n // remove last element of html element where the last element is a leaf element and its content is a string\n const { lastElementChild, lastChild } = element;\n\n if (\n lastElementChild &&\n !doesElementHasOnlyText(lastElementChild as HTMLElement) &&\n lastElementChild.hasChildNodes()\n ) {\n removeLastLeafElement(lastElementChild as HTMLElement);\n } else if (\n lastChild &&\n lastChild.nodeType === Node.TEXT_NODE &&\n lastChild.textContent &&\n lastChild.textContent.length > 25\n ) {\n lastChild.textContent = `${lastChild.textContent.substring(0, lastChild.textContent.length - 25)} ...`;\n } else if (\n lastElementChild &&\n doesElementHasOnlyText(lastElementChild as HTMLElement) &&\n lastElementChild.textContent &&\n lastElementChild.textContent.length > 25\n ) {\n lastElementChild.textContent = `${lastElementChild.textContent.substring(\n 0,\n lastElementChild.textContent.length - 25,\n )} ...`;\n } else if (lastChild) {\n element.removeChild(lastChild);\n } else if (lastElementChild) {\n element.removeChild(lastElementChild);\n }\n};\nexport const truncateElement = (element: HTMLElement, referenceHeight: number) => {\n while (doesElementOverflow(element, referenceHeight)) {\n removeLastLeafElement(element);\n }\n};\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAGA,CAACC,OAAoB,EAAEC,eAAuB,KACtED,OAAO,CAACE,YAAY,GAAGD,eAAe;AAE1C,MAAME,sBAAsB,GAAIH,OAAoB,IAAc;EAC9D;EACA,IA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AoB,EAAEC,eAAuB,KAAK;EAC9E,OAAOF,mBAAmB,CAACC,OAAO,EAAEC,eAAe,CAAC,EAAE;IAClDM,qBAAqB,CAACP,OAAO,CAAC;EAClC;AACJ,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.0.0-beta.896",
3
+ "version": "5.0.0-beta.897",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -87,5 +87,5 @@
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  },
90
- "gitHead": "a26417c8b34a4abb052c1a699e07eac6fb76b72d"
90
+ "gitHead": "ffa8d3e183074655201b4d698d30d1fb789348b2"
91
91
  }