@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.
- package/core/components/app-root/AppRoot.d.ts +2 -2
- package/core/hooks/useFontsUpdated.d.ts +9 -0
- package/core/hooks/useFontsUpdated.js +51 -0
- package/core/hooks/useMergeRefs.d.ts +7 -0
- package/core/hooks/useMergeRefs.js +34 -0
- package/core/index.d.ts +4 -0
- package/core/styles/focusRing.css +88 -0
- package/core/styles/focusRing.sty.d.ts +96 -0
- package/core/styles/focusRing.sty.js +27 -0
- package/core/styles/useFocusRing.d.ts +49 -0
- package/core/styles/useFocusRing.js +83 -0
- package/core/types/a11y-props.d.ts +19 -0
- package/core/types/a11y-props.js +15 -0
- package/core/types/dom.d.ts +19 -0
- package/core/types/dom.js +15 -0
- package/core/types/focusable-element.d.ts +5 -0
- package/core/types/focusable-element.js +15 -0
- package/core/types/heading.d.ts +9 -0
- package/core/types/heading.js +15 -0
- package/core/types/polymorph.d.ts +25 -0
- package/core/types/polymorph.js +15 -0
- package/core/utils/colorUtils.css +80 -0
- package/core/utils/colorUtils.sty.d.ts +48 -0
- package/core/utils/colorUtils.sty.js +27 -0
- package/esm/core/hooks/useFontsUpdated.js +33 -0
- package/esm/core/hooks/useFontsUpdated.js.map +7 -0
- package/esm/core/hooks/useMergeRefs.js +16 -0
- package/esm/core/hooks/useMergeRefs.js.map +7 -0
- package/esm/core/index.js.map +1 -1
- package/esm/core/styles/focusRing.css +88 -0
- package/esm/core/styles/focusRing.sty.js +9 -0
- package/esm/core/styles/focusRing.sty.js.map +7 -0
- package/esm/core/styles/useFocusRing.js +69 -0
- package/esm/core/styles/useFocusRing.js.map +7 -0
- package/esm/core/types/a11y-props.js +1 -0
- package/esm/core/types/a11y-props.js.map +7 -0
- package/esm/core/types/dom.js +1 -0
- package/esm/core/types/dom.js.map +7 -0
- package/esm/core/types/focusable-element.js +1 -0
- package/esm/core/types/focusable-element.js.map +7 -0
- package/esm/core/types/heading.js +1 -0
- package/esm/core/types/heading.js.map +7 -0
- package/esm/core/types/polymorph.js +1 -0
- package/esm/core/types/polymorph.js.map +7 -0
- package/esm/core/utils/colorUtils.css +80 -0
- package/esm/core/utils/colorUtils.sty.js +9 -0
- package/esm/core/utils/colorUtils.sty.js.map +7 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +2 -2
- package/esm/layouts/Divider/Divider.css +23 -0
- package/esm/layouts/Divider/Divider.js +39 -0
- package/esm/layouts/Divider/Divider.js.map +7 -0
- package/esm/layouts/Divider/Divider.sty.js +8 -0
- package/esm/layouts/Divider/Divider.sty.js.map +7 -0
- package/esm/layouts/index.js +5 -0
- package/esm/layouts/index.js.map +7 -0
- package/esm/styles/textStyle.css +64 -0
- package/esm/styles/textStyle.sty.js +7 -0
- package/esm/styles/textStyle.sty.js.map +7 -0
- package/esm/typography/BlockQuote/Blockquote.css +17 -0
- package/esm/typography/BlockQuote/Blockquote.js +34 -0
- package/esm/typography/BlockQuote/Blockquote.js.map +7 -0
- package/esm/typography/BlockQuote/Blockquote.sty.js +6 -0
- package/esm/typography/BlockQuote/Blockquote.sty.js.map +7 -0
- package/esm/typography/Code/Code.css +16 -0
- package/esm/typography/Code/Code.js +34 -0
- package/esm/typography/Code/Code.js.map +7 -0
- package/esm/typography/Code/Code.sty.js +6 -0
- package/esm/typography/Code/Code.sty.js.map +7 -0
- package/esm/typography/Emphasis/Emphasis.css +4 -0
- package/esm/typography/Emphasis/Emphasis.js +34 -0
- package/esm/typography/Emphasis/Emphasis.js.map +7 -0
- package/esm/typography/Emphasis/Emphasis.sty.js +6 -0
- package/esm/typography/Emphasis/Emphasis.sty.js.map +7 -0
- package/esm/typography/ExternalLink/ExternalLink.css +28 -0
- package/esm/typography/ExternalLink/ExternalLink.js +56 -0
- package/esm/typography/ExternalLink/ExternalLink.js.map +7 -0
- package/esm/typography/ExternalLink/ExternalLink.sty.js +6 -0
- package/esm/typography/ExternalLink/ExternalLink.sty.js.map +7 -0
- package/esm/typography/Heading/Heading.css +54 -0
- package/esm/typography/Heading/Heading.js +36 -0
- package/esm/typography/Heading/Heading.js.map +7 -0
- package/esm/typography/Heading/Heading.sty.js +7 -0
- package/esm/typography/Heading/Heading.sty.js.map +7 -0
- package/esm/typography/Highlight/Highlight.css +4 -0
- package/esm/typography/Highlight/Highlight.js +111 -0
- package/esm/typography/Highlight/Highlight.js.map +7 -0
- package/esm/typography/Highlight/Highlight.sty.js +6 -0
- package/esm/typography/Highlight/Highlight.sty.js.map +7 -0
- package/esm/typography/Link/Link.css +15 -0
- package/esm/typography/Link/Link.js +49 -0
- package/esm/typography/Link/Link.js.map +7 -0
- package/esm/typography/Link/Link.sty.js +6 -0
- package/esm/typography/Link/Link.sty.js.map +7 -0
- package/esm/typography/List/List.css +16 -0
- package/esm/typography/List/List.js +81 -0
- package/esm/typography/List/List.js.map +7 -0
- package/esm/typography/List/List.sty.js +8 -0
- package/esm/typography/List/List.sty.js.map +7 -0
- package/esm/typography/Paragraph/Paragraph.css +19 -0
- package/esm/typography/Paragraph/Paragraph.js +49 -0
- package/esm/typography/Paragraph/Paragraph.js.map +7 -0
- package/esm/typography/Paragraph/Paragraph.sty.js +7 -0
- package/esm/typography/Paragraph/Paragraph.sty.js.map +7 -0
- package/esm/typography/Strikethrough/Strikethrough.css +5 -0
- package/esm/typography/Strikethrough/Strikethrough.js +32 -0
- package/esm/typography/Strikethrough/Strikethrough.js.map +7 -0
- package/esm/typography/Strikethrough/Strikethrough.sty.js +6 -0
- package/esm/typography/Strikethrough/Strikethrough.sty.js.map +7 -0
- package/esm/typography/Strong/Strong.css +4 -0
- package/esm/typography/Strong/Strong.js +34 -0
- package/esm/typography/Strong/Strong.js.map +7 -0
- package/esm/typography/Strong/Strong.sty.js +6 -0
- package/esm/typography/Strong/Strong.sty.js.map +7 -0
- package/esm/typography/Text/Text.css +18 -0
- package/esm/typography/Text/Text.js +43 -0
- package/esm/typography/Text/Text.js.map +7 -0
- package/esm/typography/Text/Text.sty.js +7 -0
- package/esm/typography/Text/Text.sty.js.map +7 -0
- package/esm/typography/TextEllipsis/TextEllipsis.css +22 -0
- package/esm/typography/TextEllipsis/TextEllipsis.js +143 -0
- package/esm/typography/TextEllipsis/TextEllipsis.js.map +7 -0
- package/esm/typography/TextEllipsis/TextEllipsis.sty.js +7 -0
- package/esm/typography/TextEllipsis/TextEllipsis.sty.js.map +7 -0
- package/esm/typography/index.js +43 -0
- package/esm/typography/index.js.map +7 -0
- package/esm/typography/utils.js +101 -0
- package/esm/typography/utils.js.map +7 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/lang/en.json +6 -0
- package/lang/uncompiled/en.json +6 -1
- package/layouts/Divider/Divider.css +23 -0
- package/layouts/Divider/Divider.d.ts +39 -0
- package/layouts/Divider/Divider.js +67 -0
- package/layouts/Divider/Divider.sty.d.ts +16 -0
- package/layouts/Divider/Divider.sty.js +26 -0
- package/layouts/index.d.ts +2 -0
- package/layouts/index.js +23 -0
- package/package.json +17 -2
- package/styles/textStyle.css +64 -0
- package/styles/textStyle.sty.d.ts +12 -0
- package/styles/textStyle.sty.js +25 -0
- package/testing/mocks/text-ellipsis-mock.d.ts +1 -1
- package/testing/mocks/text-ellipsis-mock.js +8 -3
- package/typography/BlockQuote/Blockquote.css +17 -0
- package/typography/BlockQuote/Blockquote.d.ts +19 -0
- package/typography/BlockQuote/Blockquote.js +62 -0
- package/typography/BlockQuote/Blockquote.sty.d.ts +1 -0
- package/typography/BlockQuote/Blockquote.sty.js +24 -0
- package/typography/Code/Code.css +16 -0
- package/typography/Code/Code.d.ts +17 -0
- package/typography/Code/Code.js +62 -0
- package/typography/Code/Code.sty.d.ts +1 -0
- package/typography/Code/Code.sty.js +24 -0
- package/typography/Emphasis/Emphasis.css +4 -0
- package/typography/Emphasis/Emphasis.d.ts +14 -0
- package/typography/Emphasis/Emphasis.js +62 -0
- package/typography/Emphasis/Emphasis.sty.d.ts +1 -0
- package/typography/Emphasis/Emphasis.sty.js +24 -0
- package/typography/ExternalLink/ExternalLink.css +28 -0
- package/typography/ExternalLink/ExternalLink.d.ts +21 -0
- package/typography/ExternalLink/ExternalLink.js +82 -0
- package/typography/ExternalLink/ExternalLink.sty.d.ts +1 -0
- package/typography/ExternalLink/ExternalLink.sty.js +24 -0
- package/typography/Heading/Heading.css +54 -0
- package/typography/Heading/Heading.d.ts +24 -0
- package/typography/Heading/Heading.js +64 -0
- package/typography/Heading/Heading.sty.d.ts +52 -0
- package/typography/Heading/Heading.sty.js +25 -0
- package/typography/Highlight/Highlight.css +4 -0
- package/typography/Highlight/Highlight.d.ts +27 -0
- package/typography/Highlight/Highlight.js +139 -0
- package/typography/Highlight/Highlight.sty.d.ts +1 -0
- package/typography/Highlight/Highlight.sty.js +24 -0
- package/typography/Link/Link.css +15 -0
- package/typography/Link/Link.d.ts +17 -0
- package/typography/Link/Link.js +75 -0
- package/typography/Link/Link.sty.d.ts +1 -0
- package/typography/Link/Link.sty.js +24 -0
- package/typography/List/List.css +16 -0
- package/typography/List/List.d.ts +39 -0
- package/typography/List/List.js +109 -0
- package/typography/List/List.sty.d.ts +2 -0
- package/typography/List/List.sty.js +26 -0
- package/typography/Paragraph/Paragraph.css +19 -0
- package/typography/Paragraph/Paragraph.d.ts +19 -0
- package/typography/Paragraph/Paragraph.js +77 -0
- package/typography/Paragraph/Paragraph.sty.d.ts +16 -0
- package/typography/Paragraph/Paragraph.sty.js +25 -0
- package/typography/Strikethrough/Strikethrough.css +5 -0
- package/typography/Strikethrough/Strikethrough.d.ts +15 -0
- package/typography/Strikethrough/Strikethrough.js +60 -0
- package/typography/Strikethrough/Strikethrough.sty.d.ts +1 -0
- package/typography/Strikethrough/Strikethrough.sty.js +24 -0
- package/typography/Strong/Strong.css +4 -0
- package/typography/Strong/Strong.d.ts +14 -0
- package/typography/Strong/Strong.js +62 -0
- package/typography/Strong/Strong.sty.d.ts +1 -0
- package/typography/Strong/Strong.sty.js +24 -0
- package/typography/Text/Text.css +18 -0
- package/typography/Text/Text.d.ts +26 -0
- package/typography/Text/Text.js +71 -0
- package/typography/Text/Text.sty.d.ts +16 -0
- package/typography/Text/Text.sty.js +25 -0
- package/typography/TextEllipsis/TextEllipsis.css +22 -0
- package/typography/TextEllipsis/TextEllipsis.d.ts +32 -0
- package/typography/TextEllipsis/TextEllipsis.js +167 -0
- package/typography/TextEllipsis/TextEllipsis.sty.d.ts +15 -0
- package/typography/TextEllipsis/TextEllipsis.sty.js +25 -0
- package/typography/index.d.ts +28 -0
- package/typography/index.js +54 -0
- package/typography/utils.d.ts +52 -0
- package/typography/utils.js +119 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { headingCSS } from "./Heading.sty.js";
|
|
4
|
+
const Heading = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
5
|
+
const {
|
|
6
|
+
level,
|
|
7
|
+
children,
|
|
8
|
+
as,
|
|
9
|
+
"data-testid": dataTestId,
|
|
10
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
11
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
12
|
+
className: consumerClassName,
|
|
13
|
+
style: consumerStyle,
|
|
14
|
+
...remainingProps
|
|
15
|
+
} = props;
|
|
16
|
+
const visualLevel = level ?? 1;
|
|
17
|
+
const HeadingTag = as ?? `h${visualLevel}`;
|
|
18
|
+
return /* @__PURE__ */ React.createElement(
|
|
19
|
+
HeadingTag,
|
|
20
|
+
{
|
|
21
|
+
ref: forwardedRef,
|
|
22
|
+
"data-testid": dataTestId,
|
|
23
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
24
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
25
|
+
className: clsx(headingCSS({ visualLevel }), consumerClassName),
|
|
26
|
+
style: consumerStyle,
|
|
27
|
+
...remainingProps
|
|
28
|
+
},
|
|
29
|
+
children
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
Heading.displayName = "Heading";
|
|
33
|
+
export {
|
|
34
|
+
Heading
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=Heading.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Heading/Heading.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { forwardRef } from 'react';\n\nimport { headingCSS } from './Heading.sty.js';\nimport {\n type DataTestId,\n type StylingProps,\n type WithChildren,\n type MaskingProps,\n} from '../../core/index.js';\nimport type { DOMProps } from '../../core/types/dom.js';\nimport type { _HeadingTag } from '../../core/types/heading.js';\n\n/**\n * @public\n * Props used for the Heading component */\nexport interface HeadingProps\n extends DOMProps,\n WithChildren,\n StylingProps,\n DataTestId,\n MaskingProps {\n /**\n * The visual level of the heading.\n * @defaultValue 1\n */\n level?: 1 | 2 | 3 | 4 | 5 | 6;\n /**\n * The polymorphed HTML tag that determines the semantic level of the heading.\n * @defaultValue 'h1'\n */\n as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n}\n\n/**\n * @public\n * Use the `Heading` to render semantic HTML heading elements (`h1`, `h2`, etc.).\n * The component allows you to independently define both the visual and the semantic level of the heading.\n */\nexport const Heading = /* @__PURE__ */ forwardRef<\n HTMLHeadingElement,\n HeadingProps\n>((props, forwardedRef) => {\n const {\n level,\n children,\n as,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n className: consumerClassName,\n style: consumerStyle,\n ...remainingProps\n } = props;\n\n const visualLevel = level ?? 1;\n // semantic level\n const HeadingTag: _HeadingTag = as ?? (`h${visualLevel}` as _HeadingTag);\n\n return (\n <HeadingTag\n ref={forwardedRef}\n data-testid={dataTestId}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n className={clsx(headingCSS({ visualLevel }), consumerClassName)}\n style={consumerStyle}\n {...remainingProps}\n >\n {children}\n </HeadingTag>\n );\n});\n(Heading as typeof Heading & { displayName: string }).displayName = 'Heading';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,SAAS,kBAAkB;AAElC,SAAS,kBAAkB;AAoCpB,MAAM,UAA0B,2BAGrC,CAAC,OAAO,iBAAiB;AACzB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,cAAc,SAAS;AAE7B,QAAM,aAA0B,MAAO,IAAI,WAAW;AAEtD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,eAAa;AAAA,MACb,mBAAiB;AAAA,MACjB,oBAAkB;AAAA,MAClB,WAAW,KAAK,WAAW,EAAE,YAAY,CAAC,GAAG,iBAAiB;AAAA,MAC9D,OAAO;AAAA,MACN,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ,CAAC;AACA,QAAqD,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./Heading.css";
|
|
2
|
+
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
3
|
+
var headingCSS = _7a468({ defaultClassName: "Heading_headingCSS__u4t9450", variantClassNames: { visualLevel: { "1": "Heading_headingCSS_visualLevel_1__u4t9451", "2": "Heading_headingCSS_visualLevel_2__u4t9452", "3": "Heading_headingCSS_visualLevel_3__u4t9453", "4": "Heading_headingCSS_visualLevel_4__u4t9454", "5": "Heading_headingCSS_visualLevel_5__u4t9455", "6": "Heading_headingCSS_visualLevel_6__u4t9456" } }, defaultVariants: {}, compoundVariants: [] });
|
|
4
|
+
export {
|
|
5
|
+
headingCSS
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=Heading.sty.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Heading/Heading.css.ts"],
|
|
4
|
+
"sourcesContent": ["import './Heading.css';\nimport { createRuntimeFn as _7a468 } from '@vanilla-extract/recipes/createRuntimeFn';\nexport var headingCSS = _7a468({defaultClassName:'Heading_headingCSS__u4t9450',variantClassNames:{visualLevel:{'1':'Heading_headingCSS_visualLevel_1__u4t9451','2':'Heading_headingCSS_visualLevel_2__u4t9452','3':'Heading_headingCSS_visualLevel_3__u4t9453','4':'Heading_headingCSS_visualLevel_4__u4t9454','5':'Heading_headingCSS_visualLevel_5__u4t9455','6':'Heading_headingCSS_visualLevel_6__u4t9456'}},defaultVariants:{},compoundVariants:[]});"],
|
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,mBAAmB,cAAc;AACnC,IAAI,aAAa,OAAO,EAAC,kBAAiB,+BAA8B,mBAAkB,EAAC,aAAY,EAAC,KAAI,6CAA4C,KAAI,6CAA4C,KAAI,6CAA4C,KAAI,6CAA4C,KAAI,6CAA4C,KAAI,4CAA2C,EAAC,GAAE,iBAAgB,CAAC,GAAE,kBAAiB,CAAC,EAAC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { highlightCSS } from "./Highlight.sty.js";
|
|
4
|
+
const HTML_CHARS_OVERRIDES = [
|
|
5
|
+
[/</g, "<"],
|
|
6
|
+
[/>/g, ">"],
|
|
7
|
+
[/&/g, "&"],
|
|
8
|
+
[/ /g, " "]
|
|
9
|
+
];
|
|
10
|
+
function escapeRegExp(text) {
|
|
11
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12
|
+
}
|
|
13
|
+
function highlightChildren(children, term, caseSensitive, dataTestId, dataDtrumMask, dataDtrumAllow) {
|
|
14
|
+
const terms = (() => {
|
|
15
|
+
if (Array.isArray(term)) {
|
|
16
|
+
return term.filter((t) => t);
|
|
17
|
+
}
|
|
18
|
+
return term ? [term] : [];
|
|
19
|
+
})();
|
|
20
|
+
return terms.length > 0 ? React.Children.map(
|
|
21
|
+
children,
|
|
22
|
+
(child) => highlightRecursive(
|
|
23
|
+
child,
|
|
24
|
+
terms,
|
|
25
|
+
caseSensitive,
|
|
26
|
+
dataTestId,
|
|
27
|
+
dataDtrumMask,
|
|
28
|
+
dataDtrumAllow
|
|
29
|
+
)
|
|
30
|
+
) : children;
|
|
31
|
+
}
|
|
32
|
+
function highlightRecursive(sourceElement, terms, caseSensitive, dataTestId, dataDtrumMask, dataDtrumAllow) {
|
|
33
|
+
if (!sourceElement) {
|
|
34
|
+
return sourceElement;
|
|
35
|
+
}
|
|
36
|
+
if (React.isValidElement(sourceElement)) {
|
|
37
|
+
const children = React.Children.map(
|
|
38
|
+
sourceElement.props.children,
|
|
39
|
+
(child) => highlightRecursive(
|
|
40
|
+
child,
|
|
41
|
+
terms,
|
|
42
|
+
caseSensitive,
|
|
43
|
+
dataTestId,
|
|
44
|
+
dataDtrumMask,
|
|
45
|
+
dataDtrumAllow
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
return React.cloneElement(sourceElement, sourceElement.props, children);
|
|
49
|
+
}
|
|
50
|
+
return highlightLeafElement(
|
|
51
|
+
sourceElement,
|
|
52
|
+
terms,
|
|
53
|
+
caseSensitive,
|
|
54
|
+
dataTestId,
|
|
55
|
+
dataDtrumMask,
|
|
56
|
+
dataDtrumAllow
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
function highlightLeafElement(textContent, terms, caseSensitive, dataTestId, dataDtrumMask, dataDtrumAllow) {
|
|
60
|
+
if (terms.length === 0) {
|
|
61
|
+
return textContent;
|
|
62
|
+
}
|
|
63
|
+
const sanitizedTextContent = HTML_CHARS_OVERRIDES.reduce(
|
|
64
|
+
(text, [needle, replacement]) => text.replace(needle, replacement),
|
|
65
|
+
`${textContent}`
|
|
66
|
+
);
|
|
67
|
+
const termsInLowerCase = terms.map((t) => t.toLowerCase());
|
|
68
|
+
return getTextTokens(sanitizedTextContent, terms, caseSensitive).map(
|
|
69
|
+
(token) => termsInLowerCase.includes(token.toLowerCase()) ? /* @__PURE__ */ React.createElement(
|
|
70
|
+
"mark",
|
|
71
|
+
{
|
|
72
|
+
role: "mark",
|
|
73
|
+
className: clsx(highlightCSS),
|
|
74
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
75
|
+
"data-dtrum-allow": dataDtrumAllow
|
|
76
|
+
},
|
|
77
|
+
token
|
|
78
|
+
) : /* @__PURE__ */ React.createElement("span", null, token)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function getTextTokens(textContent, terms, caseSensitive) {
|
|
82
|
+
const flags = caseSensitive ? "gm" : "gmi";
|
|
83
|
+
const regExp = new RegExp(
|
|
84
|
+
`(${terms.map((t) => escapeRegExp(t)).join("|")})`,
|
|
85
|
+
flags
|
|
86
|
+
);
|
|
87
|
+
return textContent.toString().split(regExp).filter((s) => s.length > 0);
|
|
88
|
+
}
|
|
89
|
+
const Highlight = (props) => {
|
|
90
|
+
const {
|
|
91
|
+
children,
|
|
92
|
+
term,
|
|
93
|
+
caseSensitive = false,
|
|
94
|
+
"data-testid": dataTestId,
|
|
95
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
96
|
+
"data-dtrum-allow": dataDtrumAllow
|
|
97
|
+
} = props;
|
|
98
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, highlightChildren(
|
|
99
|
+
children,
|
|
100
|
+
term,
|
|
101
|
+
caseSensitive,
|
|
102
|
+
dataTestId,
|
|
103
|
+
dataDtrumMask,
|
|
104
|
+
dataDtrumAllow
|
|
105
|
+
));
|
|
106
|
+
};
|
|
107
|
+
Highlight.displayName = "Highlight";
|
|
108
|
+
export {
|
|
109
|
+
Highlight
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=Highlight.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Highlight/Highlight.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { ReactElement, ReactNode, ReactText } from 'react';\n\nimport { highlightCSS } from './Highlight.sty.js';\nimport { type DataTestId, type WithChildren } from '../../core/index.js';\nimport type { MaskingProps } from '../../core/types/masking-props.js';\n\n/**\n * The props for the Heading component.\n * @public\n */\nexport interface HighlightProps extends WithChildren, DataTestId, MaskingProps {\n /**\n * Either a substring or an array of multiple different substrings that\n * should be highlighted in the projected content.\n * Every occurrence of the string(s) is highlighted accordingly.\n */\n term: string | string[];\n\n /**\n * Property that determines whether the highlighting search is case-sensitive.\n * If set to `true`, the component searches for case sensitive occurrences.\n * @defaultValue false\n */\n caseSensitive?: boolean;\n}\n\nconst HTML_CHARS_OVERRIDES: [RegExp, string][] = [\n [/</g, '<'],\n [/>/g, '>'],\n [/&/g, '&'],\n [/ /g, ' '],\n];\n\n/** Escapes all characters that could be dangerous for a regular expression */\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n}\n\n/** Highlights all occurences of a list of terms within a ReactNode. */\nfunction highlightChildren(\n children: ReactNode,\n term: string | string[],\n caseSensitive: boolean,\n dataTestId?: string,\n dataDtrumMask?: boolean,\n dataDtrumAllow?: boolean,\n) {\n const terms = (() => {\n if (Array.isArray(term)) {\n return term.filter((t) => t);\n }\n\n return term ? [term] : [];\n })();\n\n return terms.length > 0\n ? React.Children.map(children, (child: ReactNode) =>\n highlightRecursive(\n child,\n terms,\n caseSensitive,\n dataTestId,\n dataDtrumMask,\n dataDtrumAllow,\n ),\n )\n : children;\n}\n\n/**\n * Iterates over all children of a ReactNode recursively to look\n * for a list of terms and highlights them.\n */\nfunction highlightRecursive(\n sourceElement: ReactNode,\n terms: string[],\n caseSensitive: boolean,\n dataTestId?: string,\n dataDtrumMask?: boolean,\n dataDtrumAllow?: boolean,\n): ReactNode {\n if (!sourceElement) {\n return sourceElement;\n }\n\n if (React.isValidElement(sourceElement)) {\n const children = React.Children.map(sourceElement.props.children, (child) =>\n highlightRecursive(\n child,\n terms,\n caseSensitive,\n dataTestId,\n dataDtrumMask,\n dataDtrumAllow,\n ),\n );\n\n return React.cloneElement(sourceElement, sourceElement.props, children);\n }\n\n return highlightLeafElement(\n sourceElement as ReactText,\n terms,\n caseSensitive,\n dataTestId,\n dataDtrumMask,\n dataDtrumAllow,\n );\n}\n\n/** Highlights parts of the text that match a certain group of terms. */\nfunction highlightLeafElement(\n textContent: ReactText,\n terms: string[],\n caseSensitive: boolean,\n dataTestId?: string,\n dataDtrumMask?: boolean,\n dataDtrumAllow?: boolean,\n): ReactNode {\n if (terms.length === 0) {\n return textContent;\n }\n\n const sanitizedTextContent = HTML_CHARS_OVERRIDES.reduce(\n (text, [needle, replacement]) => text.replace(needle, replacement),\n `${textContent}`,\n );\n const termsInLowerCase = terms.map((t) => t.toLowerCase());\n\n return getTextTokens(sanitizedTextContent, terms, caseSensitive).map(\n (token: string) =>\n termsInLowerCase.includes(token.toLowerCase()) ? (\n <mark\n role=\"mark\"\n className={clsx(highlightCSS)}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n >\n {token}\n </mark>\n ) : (\n <span>{token}</span>\n ),\n );\n}\n\n/**\n * Splits text into an array of strings where a given list of terms\n * acts as separator strings.\n */\nfunction getTextTokens(\n textContent: ReactText,\n terms: string[],\n caseSensitive: boolean,\n): string[] {\n const flags = caseSensitive ? 'gm' : 'gmi';\n const regExp = new RegExp(\n `(${terms.map((t) => escapeRegExp(t)).join('|')})`,\n flags,\n );\n\n return textContent\n .toString()\n .split(regExp)\n .filter((s) => s.length > 0);\n}\n\n/**\n * @public\n * Use the `Highlight` component to highlight one or more substrings within a\n * text.\n */\nexport const Highlight = (props: HighlightProps): ReactElement => {\n const {\n children,\n term,\n caseSensitive = false,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n } = props;\n\n return (\n <>\n {highlightChildren(\n children,\n term,\n caseSensitive,\n dataTestId,\n dataDtrumMask,\n dataDtrumAllow,\n )}\n </>\n );\n};\n\n(Highlight as typeof Highlight & { displayName: string }).displayName =\n 'Highlight';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,WAAmD;AAE1D,SAAS,oBAAoB;AAwB7B,MAAM,uBAA2C;AAAA,EAC/C,CAAC,SAAS,GAAG;AAAA,EACb,CAAC,SAAS,GAAG;AAAA,EACb,CAAC,UAAU,GAAG;AAAA,EACd,CAAC,WAAW,GAAG;AACjB;AAGA,SAAS,aAAa,MAAsB;AAC1C,SAAO,KAAK,QAAQ,uBAAuB,MAAM;AACnD;AAGA,SAAS,kBACP,UACA,MACA,eACA,YACA,eACA,gBACA;AACA,QAAM,SAAS,MAAM;AACnB,QAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,aAAO,KAAK,OAAO,CAAC,MAAM,CAAC;AAAA,IAC7B;AAEA,WAAO,OAAO,CAAC,IAAI,IAAI,CAAC;AAAA,EAC1B,GAAG;AAEH,SAAO,MAAM,SAAS,IAClB,MAAM,SAAS;AAAA,IAAI;AAAA,IAAU,CAAC,UAC5B;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,IACA;AACN;AAMA,SAAS,mBACP,eACA,OACA,eACA,YACA,eACA,gBACW;AACX,MAAI,CAAC,eAAe;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,eAAe,aAAa,GAAG;AACvC,UAAM,WAAW,MAAM,SAAS;AAAA,MAAI,cAAc,MAAM;AAAA,MAAU,CAAC,UACjE;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,WAAO,MAAM,aAAa,eAAe,cAAc,OAAO,QAAQ;AAAA,EACxE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGA,SAAS,qBACP,aACA,OACA,eACA,YACA,eACA,gBACW;AACX,MAAI,MAAM,WAAW,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,uBAAuB,qBAAqB;AAAA,IAChD,CAAC,MAAM,CAAC,QAAQ,WAAW,MAAM,KAAK,QAAQ,QAAQ,WAAW;AAAA,IACjE,GAAG,WAAW;AAAA,EAChB;AACA,QAAM,mBAAmB,MAAM,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAEzD,SAAO,cAAc,sBAAsB,OAAO,aAAa,EAAE;AAAA,IAC/D,CAAC,UACC,iBAAiB,SAAS,MAAM,YAAY,CAAC,IAC3C;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAW,KAAK,YAAY;AAAA,QAC5B,mBAAiB;AAAA,QACjB,oBAAkB;AAAA;AAAA,MAEjB;AAAA,IACH,IAEA,oCAAC,cAAM,KAAM;AAAA,EAEnB;AACF;AAMA,SAAS,cACP,aACA,OACA,eACU;AACV,QAAM,QAAQ,gBAAgB,OAAO;AACrC,QAAM,SAAS,IAAI;AAAA,IACjB,IAAI,MAAM,IAAI,CAAC,MAAM,aAAa,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC;AAAA,IAC/C;AAAA,EACF;AAEA,SAAO,YACJ,SAAS,EACT,MAAM,MAAM,EACZ,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC/B;AAOO,MAAM,YAAY,CAAC,UAAwC;AAChE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,EACtB,IAAI;AAEJ,SACE,0DACG;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CACF;AAEJ;AAEC,UAAyD,cACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.Link_linkCSS__1ck42do0 {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
color: var(--dt-colors-text-primary-default, #454cc9);
|
|
4
|
+
text-decoration: underline;
|
|
5
|
+
overflow-wrap: anywhere;
|
|
6
|
+
}
|
|
7
|
+
.Link_linkCSS__1ck42do0:hover {
|
|
8
|
+
color: var(--dt-colors-text-primary-default-hover, #3332ae);
|
|
9
|
+
}
|
|
10
|
+
.Link_linkCSS__1ck42do0:active {
|
|
11
|
+
color: var(--dt-colors-text-primary-default-active, #241193);
|
|
12
|
+
}
|
|
13
|
+
.Link_linkCSS__1ck42do0:focus-visible {
|
|
14
|
+
text-decoration: none;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
_mergeProps
|
|
5
|
+
} from "../../core/index.js";
|
|
6
|
+
import { useFocusRing } from "../../core/styles/useFocusRing.js";
|
|
7
|
+
import { linkCSS } from "../Link/Link.sty.js";
|
|
8
|
+
const Link = /* @__PURE__ */ forwardRef(
|
|
9
|
+
({
|
|
10
|
+
children,
|
|
11
|
+
as,
|
|
12
|
+
"data-testid": dataTestId,
|
|
13
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
14
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
15
|
+
className: consumerClassName,
|
|
16
|
+
style: consumerStyle,
|
|
17
|
+
...remainingProps
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const { focusProps, focusClassName } = useFocusRing({
|
|
20
|
+
variant: "primary",
|
|
21
|
+
isMinimal: true
|
|
22
|
+
});
|
|
23
|
+
const LinkTag = as || "a";
|
|
24
|
+
return /* @__PURE__ */ React.createElement(
|
|
25
|
+
LinkTag,
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
"data-testid": dataTestId,
|
|
29
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
30
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
31
|
+
className: clsx(focusClassName, linkCSS, consumerClassName),
|
|
32
|
+
style: consumerStyle,
|
|
33
|
+
..._mergeProps(
|
|
34
|
+
// Need to cast this one as the inference of mergeProps would generate
|
|
35
|
+
// a not allowed overlap. The remainingProps type is too complex due to the
|
|
36
|
+
// polymorphic inheritance.
|
|
37
|
+
remainingProps,
|
|
38
|
+
focusProps
|
|
39
|
+
)
|
|
40
|
+
},
|
|
41
|
+
children
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
Link.displayName = "Link";
|
|
46
|
+
export {
|
|
47
|
+
Link
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=Link.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Link/Link.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { ElementType, forwardRef, ReactElement } from 'react';\n\nimport {\n type DataTestId,\n type StylingProps,\n type WithChildren,\n _mergeProps,\n} from '../../core/index.js';\nimport { useFocusRing } from '../../core/styles/useFocusRing.js';\nimport type { MaskingProps } from '../../core/types/masking-props.js';\nimport type { PolymorphicComponentProps } from '../../core/types/polymorph.js';\nimport { linkCSS } from '../Link/Link.sty.js';\n\n/**\n * The props for the Link component.\n * @public\n */\nexport type LinkProps<E extends ElementType> = PolymorphicComponentProps<\n E,\n WithChildren & StylingProps & DataTestId & MaskingProps\n>;\n\n/**\n * @public\n * Use the `Link` component to navigate to a different page within the application.\n * For external resources in a different domain, use the\n * {@link https://developer.dynatrace.com/reference/design-system/preview/typography/ExternalLink/ | `ExternalLink`}\n * component instead.\n */\nexport const Link: <E extends ElementType = 'a'>(\n props: LinkProps<E>,\n) => ReactElement | null = /* @__PURE__ */ forwardRef(\n <E extends ElementType>(\n {\n children,\n as,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n className: consumerClassName,\n style: consumerStyle,\n ...remainingProps\n }: LinkProps<E>,\n ref: typeof remainingProps.ref,\n ) => {\n const { focusProps, focusClassName } = useFocusRing({\n variant: 'primary',\n isMinimal: true,\n });\n const LinkTag = as || 'a';\n\n return (\n <LinkTag\n ref={ref}\n data-testid={dataTestId}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n className={clsx(focusClassName, linkCSS, consumerClassName)}\n style={consumerStyle}\n {..._mergeProps(\n // Need to cast this one as the inference of mergeProps would generate\n // a not allowed overlap. The remainingProps type is too complex due to the\n // polymorphic inheritance.\n remainingProps as Record<string, unknown>,\n focusProps,\n )}\n >\n {children}\n </LinkTag>\n );\n },\n);\n\n(Link as typeof Link & { displayName: string }).displayName = 'Link';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,SAAsB,kBAAgC;AAE7D;AAAA,EAIE;AAAA,OACK;AACP,SAAS,oBAAoB;AAG7B,SAAS,eAAe;AAkBjB,MAAM,OAE8B;AAAA,EACzC,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,YAAY,eAAe,IAAI,aAAa;AAAA,MAClD,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AACD,UAAM,UAAU,MAAM;AAEtB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAa;AAAA,QACb,mBAAiB;AAAA,QACjB,oBAAkB;AAAA,QAClB,WAAW,KAAK,gBAAgB,SAAS,iBAAiB;AAAA,QAC1D,OAAO;AAAA,QACN,GAAG;AAAA;AAAA;AAAA;AAAA,UAIF;AAAA,UACA;AAAA,QACF;AAAA;AAAA,MAEC;AAAA,IACH;AAAA,EAEJ;AACF;AAEC,KAA+C,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.List_listCSS__13d6w3n0 {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding-left: var(--dt-spacings-size-40, 40px);
|
|
4
|
+
}
|
|
5
|
+
.List_listCSS__13d6w3n0 .List_listCSS__13d6w3n0 {
|
|
6
|
+
margin-block: var(--dt-spacings-size-4, 4px);
|
|
7
|
+
padding-left: var(--dt-spacings-size-28, 28px);
|
|
8
|
+
}
|
|
9
|
+
.List_listItemCSS__13d6w3n1 {
|
|
10
|
+
position: relative;
|
|
11
|
+
overflow-wrap: break-word;
|
|
12
|
+
margin-block: var(--dt-spacings-size-2, 2px);
|
|
13
|
+
}
|
|
14
|
+
.List_listItemCSS__13d6w3n1::marker {
|
|
15
|
+
font-weight: var(--dt-typography-text-base-emphasized-weight, 500);
|
|
16
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { listCSS, listItemCSS } from "./List.sty.js";
|
|
4
|
+
import { Text } from "../Text/Text.js";
|
|
5
|
+
function interleaveListItems(listItems) {
|
|
6
|
+
const items = [];
|
|
7
|
+
React.Children.forEach(listItems, (listItem) => {
|
|
8
|
+
if (React.isValidElement(listItem)) {
|
|
9
|
+
if (listItem.type === List) {
|
|
10
|
+
if (items.length === 0) {
|
|
11
|
+
items.push([listItem]);
|
|
12
|
+
} else {
|
|
13
|
+
items[items.length - 1].push(listItem);
|
|
14
|
+
}
|
|
15
|
+
} else {
|
|
16
|
+
items.push([listItem]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return items.map((values, index) => {
|
|
21
|
+
const itemKey = `list-item-${getItemKey(values, index)}`;
|
|
22
|
+
return /* @__PURE__ */ React.createElement("li", { key: itemKey, className: listItemCSS }, values);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function getItemKey(values, index) {
|
|
26
|
+
const isArray = Array.isArray(values);
|
|
27
|
+
const value = isArray ? values?.[0] : values;
|
|
28
|
+
if (React.isValidElement(value)) {
|
|
29
|
+
if (value.key) {
|
|
30
|
+
return value.key;
|
|
31
|
+
} else if (value.props && value.props.children) {
|
|
32
|
+
return getItemKey(value.props.children, index);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
if (value === void 0) {
|
|
37
|
+
return index;
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
const List = /* @__PURE__ */ forwardRef(
|
|
42
|
+
(props, ref) => {
|
|
43
|
+
const {
|
|
44
|
+
children,
|
|
45
|
+
ordered = false,
|
|
46
|
+
textStyle,
|
|
47
|
+
fontStyle,
|
|
48
|
+
start = 1,
|
|
49
|
+
"data-testid": dataTestId,
|
|
50
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
51
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
52
|
+
className: consumerClassName,
|
|
53
|
+
style: consumerStyle,
|
|
54
|
+
...remainingProps
|
|
55
|
+
} = props;
|
|
56
|
+
return /* @__PURE__ */ React.createElement(
|
|
57
|
+
Text,
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
as: ordered ? "ol" : "ul",
|
|
61
|
+
...ordered && {
|
|
62
|
+
start
|
|
63
|
+
},
|
|
64
|
+
textStyle,
|
|
65
|
+
fontStyle,
|
|
66
|
+
"data-testid": dataTestId,
|
|
67
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
68
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
69
|
+
className: clsx(listCSS, consumerClassName),
|
|
70
|
+
style: consumerStyle,
|
|
71
|
+
...remainingProps
|
|
72
|
+
},
|
|
73
|
+
interleaveListItems(children)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
List.displayName = "List";
|
|
78
|
+
export {
|
|
79
|
+
List
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=List.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/List/List.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { forwardRef } from 'react';\n\nimport { listCSS, listItemCSS } from './List.sty.js';\nimport { DataTestId } from '../../core/types/data-props.js';\nimport type { MaskingProps } from '../../core/types/masking-props.js';\nimport { StylingProps } from '../../core/types/styling-props.js';\nimport { WithChildren } from '../../core/types/with-children.js';\nimport { Text } from '../Text/Text.js';\n\n/**\n * The props for the Link component.\n * @public\n */\nexport interface ListProps<TOrdered extends boolean = false>\n extends WithChildren,\n StylingProps,\n DataTestId,\n MaskingProps {\n /**\n * Whether the List is ordered or not. This changes whether numbers or bullets are used.\n * @defaultValue false\n */\n ordered?: TOrdered;\n /**\n * Sets the text style for the List.\n * @defaultValue 'base'\n */\n textStyle?: 'base' | 'base-emphasized' | 'small' | 'small-emphasized';\n /**\n * Sets the text style for the List.\n * @defaultValue 'text'\n */\n fontStyle?: 'text' | 'code';\n /**\n * Sets the starting number of the first item in an ordered list.\n * The value is always treated as an integer (floor).\n * @defaultValue 1\n */\n start?: number;\n}\n\n/** Maps a list of (potentially) nested list items to HTML list structure. */\nfunction interleaveListItems(listItems: React.ReactNode) {\n const items: React.ReactNode[][] = [];\n\n React.Children.forEach(listItems, (listItem) => {\n if (React.isValidElement(listItem)) {\n if (listItem.type === List) {\n if (items.length === 0) {\n items.push([listItem]);\n } else {\n items[items.length - 1].push(listItem);\n }\n } else {\n items.push([listItem]);\n }\n }\n });\n\n return items.map((values, index) => {\n const itemKey = `list-item-${getItemKey(values, index)}`;\n return (\n <li key={itemKey} className={listItemCSS}>\n {values}\n </li>\n );\n });\n}\n\n/**\n * Generates a key for a list item. We try to avoid\n * generating [Object object] by looking down levels\n * recursively. If there is an existing key defined in\n * a descendant uses that as part of the key otherwise\n * if we get a string value, use that. Otherwise uses\n * the index if nothing was found.\n * @param values - nodes inside the list item\n * @param index - current zero based index\n * @returns a key generated for the item\n */\nfunction getItemKey(values: React.ReactNode[], index: number): string | number {\n const isArray = Array.isArray(values);\n const value = isArray ? values?.[0] : values;\n if (React.isValidElement(value)) {\n if (value.key) {\n return value.key;\n } else if (value.props && value.props.children) {\n return getItemKey(value.props.children, index);\n }\n return value as unknown as string | number;\n }\n\n if (value === undefined) {\n return index;\n }\n\n return value as unknown as string | number;\n}\n\n/**\n * @public\n * The `List` component groups a set of related content in a list and can be arbitrarily nested.\n * List items are preceded by either a consecutive number (for ordered lists) or a bullet point\n * (for unordered lists).\n */\nexport const List = /* @__PURE__ */ forwardRef(\n <TOrdered extends boolean = false>(\n props: ListProps<TOrdered>,\n ref: React.ForwardedRef<\n TOrdered extends true ? HTMLOListElement : HTMLUListElement\n >,\n ) => {\n const {\n children,\n ordered = false,\n textStyle,\n fontStyle,\n start = 1,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n className: consumerClassName,\n style: consumerStyle,\n ...remainingProps\n } = props;\n\n return (\n <Text\n ref={ref}\n as={ordered ? 'ol' : 'ul'}\n {...(ordered && {\n start,\n })}\n textStyle={textStyle}\n fontStyle={fontStyle}\n data-testid={dataTestId}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n className={clsx(listCSS, consumerClassName)}\n style={consumerStyle}\n {...remainingProps}\n >\n {interleaveListItems(children)}\n </Text>\n );\n },\n);\n\n(List as typeof List & { displayName: string }).displayName = 'List';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,SAAS,kBAAkB;AAElC,SAAS,SAAS,mBAAmB;AAKrC,SAAS,YAAY;AAmCrB,SAAS,oBAAoB,WAA4B;AACvD,QAAM,QAA6B,CAAC;AAEpC,QAAM,SAAS,QAAQ,WAAW,CAAC,aAAa;AAC9C,QAAI,MAAM,eAAe,QAAQ,GAAG;AAClC,UAAI,SAAS,SAAS,MAAM;AAC1B,YAAI,MAAM,WAAW,GAAG;AACtB,gBAAM,KAAK,CAAC,QAAQ,CAAC;AAAA,QACvB,OAAO;AACL,gBAAM,MAAM,SAAS,CAAC,EAAE,KAAK,QAAQ;AAAA,QACvC;AAAA,MACF,OAAO;AACL,cAAM,KAAK,CAAC,QAAQ,CAAC;AAAA,MACvB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,MAAM,IAAI,CAAC,QAAQ,UAAU;AAClC,UAAM,UAAU,aAAa,WAAW,QAAQ,KAAK,CAAC;AACtD,WACE,oCAAC,QAAG,KAAK,SAAS,WAAW,eAC1B,MACH;AAAA,EAEJ,CAAC;AACH;AAaA,SAAS,WAAW,QAA2B,OAAgC;AAC7E,QAAM,UAAU,MAAM,QAAQ,MAAM;AACpC,QAAM,QAAQ,UAAU,SAAS,CAAC,IAAI;AACtC,MAAI,MAAM,eAAe,KAAK,GAAG;AAC/B,QAAI,MAAM,KAAK;AACb,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,SAAS,MAAM,MAAM,UAAU;AAC9C,aAAO,WAAW,MAAM,MAAM,UAAU,KAAK;AAAA,IAC/C;AACA,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,QAAW;AACvB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAQO,MAAM,OAAuB;AAAA,EAClC,CACE,OACA,QAGG;AACH,UAAM;AAAA,MACJ;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,eAAe;AAAA,MACf,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,WAAW;AAAA,MACX,OAAO;AAAA,MACP,GAAG;AAAA,IACL,IAAI;AAEJ,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,IAAI,UAAU,OAAO;AAAA,QACpB,GAAI,WAAW;AAAA,UACd;AAAA,QACF;AAAA,QACA;AAAA,QACA;AAAA,QACA,eAAa;AAAA,QACb,mBAAiB;AAAA,QACjB,oBAAkB;AAAA,QAClB,WAAW,KAAK,SAAS,iBAAiB;AAAA,QAC1C,OAAO;AAAA,QACN,GAAG;AAAA;AAAA,MAEH,oBAAoB,QAAQ;AAAA,IAC/B;AAAA,EAEJ;AACF;AAEC,KAA+C,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/List/List.css.ts"],
|
|
4
|
+
"sourcesContent": ["import './List.css';\nexport var listCSS = 'List_listCSS__13d6w3n0';\nexport var listItemCSS = 'List_listItemCSS__13d6w3n1';"],
|
|
5
|
+
"mappings": "AAAA,OAAO;AACA,IAAI,UAAU;AACd,IAAI,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.Paragraph_paragraphCSS__42lz6l0 {
|
|
2
|
+
margin-top: 0;
|
|
3
|
+
margin-bottom: 0;
|
|
4
|
+
overflow-wrap: break-word;
|
|
5
|
+
color: var(--dt-colors-text-neutral-default, #2b2a58);
|
|
6
|
+
font-style: normal;
|
|
7
|
+
}
|
|
8
|
+
.Paragraph_paragraphCSS_ellipsis_singleLine__42lz6l1 {
|
|
9
|
+
display: block;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
text-overflow: ellipsis;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
.Paragraph_paragraphCSS_ellipsis_multiLine__42lz6l2 {
|
|
15
|
+
display: -webkit-box;
|
|
16
|
+
-webkit-line-clamp: var(--strato-ellipsis-line-clamp);
|
|
17
|
+
-webkit-box-orient: vertical;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { paragraphCSS } from "./Paragraph.sty.js";
|
|
4
|
+
import { textStyleCSS } from "../../styles/textStyle.sty.js";
|
|
5
|
+
const Paragraph = /* @__PURE__ */ forwardRef((props, ref) => {
|
|
6
|
+
const {
|
|
7
|
+
children,
|
|
8
|
+
maxLines,
|
|
9
|
+
className: consumerClassName,
|
|
10
|
+
style: consumerStyle,
|
|
11
|
+
"data-testid": dataTestId,
|
|
12
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
13
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
14
|
+
...remainingProps
|
|
15
|
+
} = props;
|
|
16
|
+
let ellipsis;
|
|
17
|
+
if (maxLines === void 0 || maxLines === 0) {
|
|
18
|
+
ellipsis = void 0;
|
|
19
|
+
} else if (maxLines === 1) {
|
|
20
|
+
ellipsis = "singleLine";
|
|
21
|
+
} else {
|
|
22
|
+
ellipsis = "multiLine";
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ React.createElement(
|
|
25
|
+
"p",
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
"data-testid": dataTestId,
|
|
29
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
30
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
31
|
+
className: clsx(
|
|
32
|
+
paragraphCSS({ ellipsis }),
|
|
33
|
+
textStyleCSS(),
|
|
34
|
+
consumerClassName
|
|
35
|
+
),
|
|
36
|
+
style: {
|
|
37
|
+
...consumerStyle,
|
|
38
|
+
"--strato-ellipsis-line-clamp": maxLines
|
|
39
|
+
},
|
|
40
|
+
...remainingProps
|
|
41
|
+
},
|
|
42
|
+
children
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
Paragraph.displayName = "Paragraph";
|
|
46
|
+
export {
|
|
47
|
+
Paragraph
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=Paragraph.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Paragraph/Paragraph.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { type CSSProperties, forwardRef } from 'react';\n\nimport { paragraphCSS } from './Paragraph.sty.js';\nimport {\n type DataTestId,\n type StylingProps,\n type WithChildren,\n} from '../../core/index.js';\nimport type { DOMProps } from '../../core/types/dom.js';\nimport type { MaskingProps } from '../../core/types/masking-props.js';\nimport { textStyleCSS } from '../../styles/textStyle.sty.js';\n\n/**\n * The props for the Paragraph component.\n * @public\n * */\nexport interface ParagraphProps\n extends WithChildren,\n DOMProps,\n StylingProps,\n DataTestId,\n MaskingProps {\n /**\n * Limits the text to the given number of lines and adds ellipsis if the text would need more lines.\n */\n maxLines?: number;\n}\n\n/**\n * @public\n * The `Paragraph` component displays a block of text with the default text style and supports text truncation.\n */\nexport const Paragraph = /* @__PURE__ */ forwardRef<\n HTMLParagraphElement,\n ParagraphProps\n>((props, ref) => {\n const {\n children,\n maxLines,\n className: consumerClassName,\n style: consumerStyle,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n ...remainingProps\n } = props;\n\n let ellipsis: undefined | 'singleLine' | 'multiLine';\n if (maxLines === undefined || maxLines === 0) {\n ellipsis = undefined;\n } else if (maxLines === 1) {\n ellipsis = 'singleLine';\n } else {\n ellipsis = 'multiLine';\n }\n\n return (\n <p\n ref={ref}\n data-testid={dataTestId}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n className={clsx(\n paragraphCSS({ ellipsis }),\n textStyleCSS(),\n consumerClassName,\n )}\n style={\n {\n ...consumerStyle,\n '--strato-ellipsis-line-clamp': maxLines,\n } as CSSProperties\n }\n {...remainingProps}\n >\n {children}\n </p>\n );\n});\n(Paragraph as typeof Paragraph & { displayName: string }).displayName =\n 'Paragraph';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,SAA6B,kBAAkB;AAEtD,SAAS,oBAAoB;AAQ7B,SAAS,oBAAoB;AAsBtB,MAAM,YAA4B,2BAGvC,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,OAAO;AAAA,IACP,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,GAAG;AAAA,EACL,IAAI;AAEJ,MAAI;AACJ,MAAI,aAAa,UAAa,aAAa,GAAG;AAC5C,eAAW;AAAA,EACb,WAAW,aAAa,GAAG;AACzB,eAAW;AAAA,EACb,OAAO;AACL,eAAW;AAAA,EACb;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAa;AAAA,MACb,mBAAiB;AAAA,MACjB,oBAAkB;AAAA,MAClB,WAAW;AAAA,QACT,aAAa,EAAE,SAAS,CAAC;AAAA,QACzB,aAAa;AAAA,QACb;AAAA,MACF;AAAA,MACA,OACE;AAAA,QACE,GAAG;AAAA,QACH,gCAAgC;AAAA,MAClC;AAAA,MAED,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ,CAAC;AACA,UAAyD,cACxD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./Paragraph.css";
|
|
2
|
+
import { createRuntimeFn as _7a468 } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
3
|
+
var paragraphCSS = _7a468({ defaultClassName: "Paragraph_paragraphCSS__42lz6l0", variantClassNames: { ellipsis: { singleLine: "Paragraph_paragraphCSS_ellipsis_singleLine__42lz6l1", multiLine: "Paragraph_paragraphCSS_ellipsis_multiLine__42lz6l2" } }, defaultVariants: {}, compoundVariants: [] });
|
|
4
|
+
export {
|
|
5
|
+
paragraphCSS
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=Paragraph.sty.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Paragraph/Paragraph.css.ts"],
|
|
4
|
+
"sourcesContent": ["import './Paragraph.css';\nimport { createRuntimeFn as _7a468 } from '@vanilla-extract/recipes/createRuntimeFn';\nexport var paragraphCSS = _7a468({defaultClassName:'Paragraph_paragraphCSS__42lz6l0',variantClassNames:{ellipsis:{singleLine:'Paragraph_paragraphCSS_ellipsis_singleLine__42lz6l1',multiLine:'Paragraph_paragraphCSS_ellipsis_multiLine__42lz6l2'}},defaultVariants:{},compoundVariants:[]});"],
|
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,mBAAmB,cAAc;AACnC,IAAI,eAAe,OAAO,EAAC,kBAAiB,mCAAkC,mBAAkB,EAAC,UAAS,EAAC,YAAW,uDAAsD,WAAU,qDAAoD,EAAC,GAAE,iBAAgB,CAAC,GAAE,kBAAiB,CAAC,EAAC,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { strikethroughCSS } from "./Strikethrough.sty.js";
|
|
4
|
+
const Strikethrough = /* @__PURE__ */ forwardRef((props, ref) => {
|
|
5
|
+
const {
|
|
6
|
+
children,
|
|
7
|
+
"data-testid": dataTestId,
|
|
8
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
9
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
10
|
+
className: consumerClassName,
|
|
11
|
+
style: consumerStyle,
|
|
12
|
+
...remainingProps
|
|
13
|
+
} = props;
|
|
14
|
+
return /* @__PURE__ */ React.createElement(
|
|
15
|
+
"s",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
"data-testid": dataTestId,
|
|
19
|
+
"data-dtrum-mask": dataDtrumMask,
|
|
20
|
+
"data-dtrum-allow": dataDtrumAllow,
|
|
21
|
+
className: clsx(strikethroughCSS, consumerClassName),
|
|
22
|
+
style: consumerStyle,
|
|
23
|
+
...remainingProps
|
|
24
|
+
},
|
|
25
|
+
children
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
Strikethrough.displayName = "Strikethrough";
|
|
29
|
+
export {
|
|
30
|
+
Strikethrough
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=Strikethrough.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Strikethrough/Strikethrough.tsx"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport React, { forwardRef } from 'react';\n\nimport { strikethroughCSS } from './Strikethrough.sty.js';\nimport {\n type DataTestId,\n type StylingProps,\n type WithChildren,\n} from '../../core/index.js';\nimport type { MaskingProps } from '../../core/types/masking-props.js';\n\n/**\n * The props for the Strikethrough component.\n * @public\n * */\nexport interface StrikethroughProps\n extends WithChildren,\n StylingProps,\n DataTestId,\n MaskingProps {}\n\n/**\n * @public\n * The `Strikethrough` component renders text with a line through it. Use it to\n * represent things that are no longer relevant or accurate.\n */\nexport const Strikethrough = /* @__PURE__ */ forwardRef<\n HTMLElement,\n StrikethroughProps\n>((props, ref) => {\n const {\n children,\n 'data-testid': dataTestId,\n 'data-dtrum-mask': dataDtrumMask,\n 'data-dtrum-allow': dataDtrumAllow,\n className: consumerClassName,\n style: consumerStyle,\n ...remainingProps\n } = props;\n\n return (\n <s\n ref={ref}\n data-testid={dataTestId}\n data-dtrum-mask={dataDtrumMask}\n data-dtrum-allow={dataDtrumAllow}\n className={clsx(strikethroughCSS, consumerClassName)}\n style={consumerStyle}\n {...remainingProps}\n >\n {children}\n </s>\n );\n});\n(Strikethrough as typeof Strikethrough & { displayName: string }).displayName =\n 'Strikethrough';\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,UAAU;AACjB,OAAO,SAAS,kBAAkB;AAElC,SAAS,wBAAwB;AAuB1B,MAAM,gBAAgC,2BAG3C,CAAC,OAAO,QAAQ;AAChB,QAAM;AAAA,IACJ;AAAA,IACA,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,WAAW;AAAA,IACX,OAAO;AAAA,IACP,GAAG;AAAA,EACL,IAAI;AAEJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,eAAa;AAAA,MACb,mBAAiB;AAAA,MACjB,oBAAkB;AAAA,MAClB,WAAW,KAAK,kBAAkB,iBAAiB;AAAA,MACnD,OAAO;AAAA,MACN,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ,CAAC;AACA,cAAiE,cAChE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/typography/Strikethrough/Strikethrough.css.ts"],
|
|
4
|
+
"sourcesContent": ["import './Strikethrough.css';\nexport var strikethroughCSS = 'Strikethrough_strikethroughCSS__1178y080';"],
|
|
5
|
+
"mappings": "AAAA,OAAO;AACA,IAAI,mBAAmB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|