@dynatrace/strato-components 0.84.31 → 0.84.42

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.
Files changed (214) hide show
  1. package/core/components/app-root/AppRoot.d.ts +2 -2
  2. package/core/hooks/useFontsUpdated.d.ts +9 -0
  3. package/core/hooks/useFontsUpdated.js +51 -0
  4. package/core/hooks/useMergeRefs.d.ts +7 -0
  5. package/core/hooks/useMergeRefs.js +34 -0
  6. package/core/index.d.ts +4 -0
  7. package/core/styles/focusRing.css +88 -0
  8. package/core/styles/focusRing.sty.d.ts +96 -0
  9. package/core/styles/focusRing.sty.js +27 -0
  10. package/core/styles/useFocusRing.d.ts +49 -0
  11. package/core/styles/useFocusRing.js +83 -0
  12. package/core/types/a11y-props.d.ts +19 -0
  13. package/core/types/a11y-props.js +15 -0
  14. package/core/types/dom.d.ts +19 -0
  15. package/core/types/dom.js +15 -0
  16. package/core/types/focusable-element.d.ts +5 -0
  17. package/core/types/focusable-element.js +15 -0
  18. package/core/types/heading.d.ts +9 -0
  19. package/core/types/heading.js +15 -0
  20. package/core/types/polymorph.d.ts +25 -0
  21. package/core/types/polymorph.js +15 -0
  22. package/core/utils/colorUtils.css +80 -0
  23. package/core/utils/colorUtils.sty.d.ts +48 -0
  24. package/core/utils/colorUtils.sty.js +27 -0
  25. package/esm/core/hooks/useFontsUpdated.js +33 -0
  26. package/esm/core/hooks/useFontsUpdated.js.map +7 -0
  27. package/esm/core/hooks/useMergeRefs.js +16 -0
  28. package/esm/core/hooks/useMergeRefs.js.map +7 -0
  29. package/esm/core/index.js.map +1 -1
  30. package/esm/core/styles/focusRing.css +88 -0
  31. package/esm/core/styles/focusRing.sty.js +9 -0
  32. package/esm/core/styles/focusRing.sty.js.map +7 -0
  33. package/esm/core/styles/useFocusRing.js +69 -0
  34. package/esm/core/styles/useFocusRing.js.map +7 -0
  35. package/esm/core/types/a11y-props.js +1 -0
  36. package/esm/core/types/a11y-props.js.map +7 -0
  37. package/esm/core/types/dom.js +1 -0
  38. package/esm/core/types/dom.js.map +7 -0
  39. package/esm/core/types/focusable-element.js +1 -0
  40. package/esm/core/types/focusable-element.js.map +7 -0
  41. package/esm/core/types/heading.js +1 -0
  42. package/esm/core/types/heading.js.map +7 -0
  43. package/esm/core/types/polymorph.js +1 -0
  44. package/esm/core/types/polymorph.js.map +7 -0
  45. package/esm/core/utils/colorUtils.css +80 -0
  46. package/esm/core/utils/colorUtils.sty.js +9 -0
  47. package/esm/core/utils/colorUtils.sty.js.map +7 -0
  48. package/esm/index.js +2 -0
  49. package/esm/index.js.map +2 -2
  50. package/esm/layouts/Divider/Divider.css +23 -0
  51. package/esm/layouts/Divider/Divider.js +39 -0
  52. package/esm/layouts/Divider/Divider.js.map +7 -0
  53. package/esm/layouts/Divider/Divider.sty.js +8 -0
  54. package/esm/layouts/Divider/Divider.sty.js.map +7 -0
  55. package/esm/layouts/index.js +5 -0
  56. package/esm/layouts/index.js.map +7 -0
  57. package/esm/styles/textStyle.css +64 -0
  58. package/esm/styles/textStyle.sty.js +7 -0
  59. package/esm/styles/textStyle.sty.js.map +7 -0
  60. package/esm/typography/BlockQuote/Blockquote.css +17 -0
  61. package/esm/typography/BlockQuote/Blockquote.js +34 -0
  62. package/esm/typography/BlockQuote/Blockquote.js.map +7 -0
  63. package/esm/typography/BlockQuote/Blockquote.sty.js +6 -0
  64. package/esm/typography/BlockQuote/Blockquote.sty.js.map +7 -0
  65. package/esm/typography/Code/Code.css +16 -0
  66. package/esm/typography/Code/Code.js +34 -0
  67. package/esm/typography/Code/Code.js.map +7 -0
  68. package/esm/typography/Code/Code.sty.js +6 -0
  69. package/esm/typography/Code/Code.sty.js.map +7 -0
  70. package/esm/typography/Emphasis/Emphasis.css +4 -0
  71. package/esm/typography/Emphasis/Emphasis.js +34 -0
  72. package/esm/typography/Emphasis/Emphasis.js.map +7 -0
  73. package/esm/typography/Emphasis/Emphasis.sty.js +6 -0
  74. package/esm/typography/Emphasis/Emphasis.sty.js.map +7 -0
  75. package/esm/typography/ExternalLink/ExternalLink.css +28 -0
  76. package/esm/typography/ExternalLink/ExternalLink.js +56 -0
  77. package/esm/typography/ExternalLink/ExternalLink.js.map +7 -0
  78. package/esm/typography/ExternalLink/ExternalLink.sty.js +6 -0
  79. package/esm/typography/ExternalLink/ExternalLink.sty.js.map +7 -0
  80. package/esm/typography/Heading/Heading.css +54 -0
  81. package/esm/typography/Heading/Heading.js +36 -0
  82. package/esm/typography/Heading/Heading.js.map +7 -0
  83. package/esm/typography/Heading/Heading.sty.js +7 -0
  84. package/esm/typography/Heading/Heading.sty.js.map +7 -0
  85. package/esm/typography/Highlight/Highlight.css +4 -0
  86. package/esm/typography/Highlight/Highlight.js +111 -0
  87. package/esm/typography/Highlight/Highlight.js.map +7 -0
  88. package/esm/typography/Highlight/Highlight.sty.js +6 -0
  89. package/esm/typography/Highlight/Highlight.sty.js.map +7 -0
  90. package/esm/typography/Link/Link.css +15 -0
  91. package/esm/typography/Link/Link.js +49 -0
  92. package/esm/typography/Link/Link.js.map +7 -0
  93. package/esm/typography/Link/Link.sty.js +6 -0
  94. package/esm/typography/Link/Link.sty.js.map +7 -0
  95. package/esm/typography/List/List.css +16 -0
  96. package/esm/typography/List/List.js +81 -0
  97. package/esm/typography/List/List.js.map +7 -0
  98. package/esm/typography/List/List.sty.js +8 -0
  99. package/esm/typography/List/List.sty.js.map +7 -0
  100. package/esm/typography/Paragraph/Paragraph.css +19 -0
  101. package/esm/typography/Paragraph/Paragraph.js +49 -0
  102. package/esm/typography/Paragraph/Paragraph.js.map +7 -0
  103. package/esm/typography/Paragraph/Paragraph.sty.js +7 -0
  104. package/esm/typography/Paragraph/Paragraph.sty.js.map +7 -0
  105. package/esm/typography/Strikethrough/Strikethrough.css +5 -0
  106. package/esm/typography/Strikethrough/Strikethrough.js +32 -0
  107. package/esm/typography/Strikethrough/Strikethrough.js.map +7 -0
  108. package/esm/typography/Strikethrough/Strikethrough.sty.js +6 -0
  109. package/esm/typography/Strikethrough/Strikethrough.sty.js.map +7 -0
  110. package/esm/typography/Strong/Strong.css +4 -0
  111. package/esm/typography/Strong/Strong.js +34 -0
  112. package/esm/typography/Strong/Strong.js.map +7 -0
  113. package/esm/typography/Strong/Strong.sty.js +6 -0
  114. package/esm/typography/Strong/Strong.sty.js.map +7 -0
  115. package/esm/typography/Text/Text.css +18 -0
  116. package/esm/typography/Text/Text.js +43 -0
  117. package/esm/typography/Text/Text.js.map +7 -0
  118. package/esm/typography/Text/Text.sty.js +7 -0
  119. package/esm/typography/Text/Text.sty.js.map +7 -0
  120. package/esm/typography/TextEllipsis/TextEllipsis.css +22 -0
  121. package/esm/typography/TextEllipsis/TextEllipsis.js +143 -0
  122. package/esm/typography/TextEllipsis/TextEllipsis.js.map +7 -0
  123. package/esm/typography/TextEllipsis/TextEllipsis.sty.js +7 -0
  124. package/esm/typography/TextEllipsis/TextEllipsis.sty.js.map +7 -0
  125. package/esm/typography/index.js +43 -0
  126. package/esm/typography/index.js.map +7 -0
  127. package/esm/typography/utils.js +101 -0
  128. package/esm/typography/utils.js.map +7 -0
  129. package/index.d.ts +2 -0
  130. package/index.js +2 -0
  131. package/lang/en.json +6 -0
  132. package/lang/uncompiled/en.json +6 -1
  133. package/layouts/Divider/Divider.css +23 -0
  134. package/layouts/Divider/Divider.d.ts +39 -0
  135. package/layouts/Divider/Divider.js +67 -0
  136. package/layouts/Divider/Divider.sty.d.ts +16 -0
  137. package/layouts/Divider/Divider.sty.js +26 -0
  138. package/layouts/index.d.ts +2 -0
  139. package/layouts/index.js +23 -0
  140. package/package.json +17 -2
  141. package/styles/textStyle.css +64 -0
  142. package/styles/textStyle.sty.d.ts +12 -0
  143. package/styles/textStyle.sty.js +25 -0
  144. package/testing/mocks/text-ellipsis-mock.d.ts +1 -1
  145. package/testing/mocks/text-ellipsis-mock.js +8 -3
  146. package/typography/BlockQuote/Blockquote.css +17 -0
  147. package/typography/BlockQuote/Blockquote.d.ts +19 -0
  148. package/typography/BlockQuote/Blockquote.js +62 -0
  149. package/typography/BlockQuote/Blockquote.sty.d.ts +1 -0
  150. package/typography/BlockQuote/Blockquote.sty.js +24 -0
  151. package/typography/Code/Code.css +16 -0
  152. package/typography/Code/Code.d.ts +17 -0
  153. package/typography/Code/Code.js +62 -0
  154. package/typography/Code/Code.sty.d.ts +1 -0
  155. package/typography/Code/Code.sty.js +24 -0
  156. package/typography/Emphasis/Emphasis.css +4 -0
  157. package/typography/Emphasis/Emphasis.d.ts +14 -0
  158. package/typography/Emphasis/Emphasis.js +62 -0
  159. package/typography/Emphasis/Emphasis.sty.d.ts +1 -0
  160. package/typography/Emphasis/Emphasis.sty.js +24 -0
  161. package/typography/ExternalLink/ExternalLink.css +28 -0
  162. package/typography/ExternalLink/ExternalLink.d.ts +21 -0
  163. package/typography/ExternalLink/ExternalLink.js +82 -0
  164. package/typography/ExternalLink/ExternalLink.sty.d.ts +1 -0
  165. package/typography/ExternalLink/ExternalLink.sty.js +24 -0
  166. package/typography/Heading/Heading.css +54 -0
  167. package/typography/Heading/Heading.d.ts +24 -0
  168. package/typography/Heading/Heading.js +64 -0
  169. package/typography/Heading/Heading.sty.d.ts +52 -0
  170. package/typography/Heading/Heading.sty.js +25 -0
  171. package/typography/Highlight/Highlight.css +4 -0
  172. package/typography/Highlight/Highlight.d.ts +27 -0
  173. package/typography/Highlight/Highlight.js +139 -0
  174. package/typography/Highlight/Highlight.sty.d.ts +1 -0
  175. package/typography/Highlight/Highlight.sty.js +24 -0
  176. package/typography/Link/Link.css +15 -0
  177. package/typography/Link/Link.d.ts +17 -0
  178. package/typography/Link/Link.js +75 -0
  179. package/typography/Link/Link.sty.d.ts +1 -0
  180. package/typography/Link/Link.sty.js +24 -0
  181. package/typography/List/List.css +16 -0
  182. package/typography/List/List.d.ts +39 -0
  183. package/typography/List/List.js +109 -0
  184. package/typography/List/List.sty.d.ts +2 -0
  185. package/typography/List/List.sty.js +26 -0
  186. package/typography/Paragraph/Paragraph.css +19 -0
  187. package/typography/Paragraph/Paragraph.d.ts +19 -0
  188. package/typography/Paragraph/Paragraph.js +77 -0
  189. package/typography/Paragraph/Paragraph.sty.d.ts +16 -0
  190. package/typography/Paragraph/Paragraph.sty.js +25 -0
  191. package/typography/Strikethrough/Strikethrough.css +5 -0
  192. package/typography/Strikethrough/Strikethrough.d.ts +15 -0
  193. package/typography/Strikethrough/Strikethrough.js +60 -0
  194. package/typography/Strikethrough/Strikethrough.sty.d.ts +1 -0
  195. package/typography/Strikethrough/Strikethrough.sty.js +24 -0
  196. package/typography/Strong/Strong.css +4 -0
  197. package/typography/Strong/Strong.d.ts +14 -0
  198. package/typography/Strong/Strong.js +62 -0
  199. package/typography/Strong/Strong.sty.d.ts +1 -0
  200. package/typography/Strong/Strong.sty.js +24 -0
  201. package/typography/Text/Text.css +18 -0
  202. package/typography/Text/Text.d.ts +26 -0
  203. package/typography/Text/Text.js +71 -0
  204. package/typography/Text/Text.sty.d.ts +16 -0
  205. package/typography/Text/Text.sty.js +25 -0
  206. package/typography/TextEllipsis/TextEllipsis.css +22 -0
  207. package/typography/TextEllipsis/TextEllipsis.d.ts +32 -0
  208. package/typography/TextEllipsis/TextEllipsis.js +167 -0
  209. package/typography/TextEllipsis/TextEllipsis.sty.d.ts +15 -0
  210. package/typography/TextEllipsis/TextEllipsis.sty.js +25 -0
  211. package/typography/index.d.ts +28 -0
  212. package/typography/index.js +54 -0
  213. package/typography/utils.d.ts +52 -0
  214. package/typography/utils.js +119 -0
@@ -0,0 +1,119 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var utils_exports = {};
19
+ __export(utils_exports, {
20
+ _ELLIPSIS_APPROXIMATION_THRESHOLD: () => _ELLIPSIS_APPROXIMATION_THRESHOLD,
21
+ _ELLIPSIS_CHARACTER: () => _ELLIPSIS_CHARACTER,
22
+ _calculateEllipsisInfo: () => _calculateEllipsisInfo,
23
+ _centerEllipsizeText: () => _centerEllipsizeText,
24
+ _getTextHeight: () => _getTextHeight,
25
+ _getTextWidth: () => _getTextWidth
26
+ });
27
+ module.exports = __toCommonJS(utils_exports);
28
+ const _ELLIPSIS_CHARACTER = "\u2026";
29
+ const _ELLIPSIS_APPROXIMATION_THRESHOLD = 15;
30
+ let inMemContext2d;
31
+ function _getTextWidth(text, textFont) {
32
+ const context = getCanvasContext2d();
33
+ context.font = getFontString(textFont);
34
+ const textMetrics = context.measureText(text);
35
+ if (textMetrics.width < 0) {
36
+ return textMetrics.width;
37
+ }
38
+ const actualTextWidth = Math.abs(textMetrics.actualBoundingBoxLeft) + Math.abs(textMetrics.actualBoundingBoxRight);
39
+ return Math.ceil(actualTextWidth);
40
+ }
41
+ function _getTextHeight(text, textFont) {
42
+ const context = getCanvasContext2d();
43
+ context.font = getFontString(textFont);
44
+ const textMetrics = context.measureText(text);
45
+ const actualTextHeight = Math.abs(textMetrics.actualBoundingBoxAscent) + Math.abs(textMetrics.actualBoundingBoxDescent);
46
+ return Math.ceil(actualTextHeight);
47
+ }
48
+ function _centerEllipsizeText(originalText, textFont, maxWidthInPx) {
49
+ const ellipsisInfo = _calculateEllipsisInfo(
50
+ originalText,
51
+ textFont,
52
+ maxWidthInPx
53
+ );
54
+ if (ellipsisInfo === null) {
55
+ return originalText;
56
+ }
57
+ const { ellipsisWidth, avgLetterWidth } = ellipsisInfo;
58
+ const availableTextWidth = maxWidthInPx - ellipsisWidth;
59
+ if (availableTextWidth <= ellipsisWidth) {
60
+ return _ELLIPSIS_CHARACTER;
61
+ }
62
+ const initialPrefixSuffixLength = Math.floor(availableTextWidth / avgLetterWidth / 2) + 1;
63
+ let prefix;
64
+ let suffix;
65
+ let ellipsizedText;
66
+ let approximatedTextWidth;
67
+ let attempt = 1;
68
+ let prefixLength = initialPrefixSuffixLength;
69
+ let suffixLength = initialPrefixSuffixLength;
70
+ do {
71
+ prefixLength -= attempt % 2 === 1 ? 1 : 0;
72
+ suffixLength -= attempt % 2 === 0 ? 1 : 0;
73
+ prefix = originalText.substring(0, prefixLength);
74
+ suffix = originalText.substring(originalText.length - suffixLength);
75
+ ellipsizedText = `${prefix}${_ELLIPSIS_CHARACTER}${suffix}`;
76
+ approximatedTextWidth = _getTextWidth(ellipsizedText, textFont);
77
+ attempt++;
78
+ } while (attempt <= _ELLIPSIS_APPROXIMATION_THRESHOLD && approximatedTextWidth >= maxWidthInPx);
79
+ return ellipsizedText;
80
+ }
81
+ function getFontString(textFont) {
82
+ const { fontStyle, fontWeight, fontSize, fontFamily } = textFont;
83
+ return [
84
+ fontStyle === "normal" ? "" : fontStyle,
85
+ fontWeight === "400" ? "" : fontWeight,
86
+ fontSize,
87
+ fontFamily
88
+ ].filter((value) => value !== void 0 && value !== "").map(
89
+ (value) => (
90
+ // we need to resolve CSS variables manually because they are not supported by the canvas API
91
+ value?.trim().startsWith("var(") ? value.replace(/^\s*var\(--[0-9A-Za-z-]+,\s*([^)]+)\)\s*$/, "$1") : value
92
+ )
93
+ ).join(" ");
94
+ }
95
+ function _calculateEllipsisInfo(originalText, textFont, maxWidthInPx) {
96
+ const originalTextLength = originalText.length;
97
+ if (originalTextLength <= 1) {
98
+ return null;
99
+ }
100
+ const textWidth = _getTextWidth(originalText, textFont);
101
+ const avgLetterWidth = textWidth / originalTextLength;
102
+ return textWidth > maxWidthInPx ? {
103
+ ellipsisWidth: _getTextWidth(_ELLIPSIS_CHARACTER, textFont),
104
+ avgLetterWidth
105
+ } : null;
106
+ }
107
+ function getCanvasContext2d() {
108
+ if (!inMemContext2d) {
109
+ const context = document.createElement("canvas").getContext("2d");
110
+ if (context !== null) {
111
+ context.imageSmoothingEnabled = false;
112
+ context.imageSmoothingQuality = "low";
113
+ inMemContext2d = context;
114
+ } else {
115
+ throw new Error("Failed to create a Canvas 2D context");
116
+ }
117
+ }
118
+ return inMemContext2d;
119
+ }