@times-design-system/components-react 1.2.1-alpha.7 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/AdContainer/AdContainer.cjs +1 -0
  3. package/dist/AdContainer/AdContainer.cjs.map +1 -1
  4. package/dist/AdContainer/AdContainer.js +1 -0
  5. package/dist/AdContainer/AdContainer.js.map +1 -1
  6. package/dist/Button/Button.cjs +1 -1
  7. package/dist/Button/Button.js +1 -1
  8. package/dist/Button/ButtonContainer.cjs +1 -1
  9. package/dist/Button/ButtonContainer.js +1 -1
  10. package/dist/Chip/Chip.cjs +1 -1
  11. package/dist/Chip/Chip.js +1 -1
  12. package/dist/DialogBox/DialogBox.d.ts +41 -0
  13. package/dist/Divider/Divider.cjs +1 -1
  14. package/dist/Divider/Divider.js +1 -1
  15. package/dist/Flag/Flag.cjs +1 -1
  16. package/dist/Flag/Flag.js +1 -1
  17. package/dist/Icon/Icon.cjs +1 -1
  18. package/dist/Icon/Icon.js +1 -1
  19. package/dist/IconButton/IconButton.cjs +1 -1
  20. package/dist/IconButton/IconButton.js +1 -1
  21. package/dist/Input/Input.cjs +1 -1
  22. package/dist/Input/Input.js +1 -1
  23. package/dist/InputHelperMessage/InputHelperMessage.d.ts +17 -0
  24. package/dist/Link/Link.cjs +1 -1
  25. package/dist/Link/Link.js +1 -1
  26. package/dist/Tab/Tab.d.ts +44 -0
  27. package/dist/TabGroup/TabGroup.d.ts +26 -0
  28. package/dist/Text/Text.cjs +16 -14
  29. package/dist/Text/Text.cjs.map +1 -1
  30. package/dist/Text/Text.d.ts +35 -9
  31. package/dist/Text/Text.js +16 -14
  32. package/dist/Text/Text.js.map +1 -1
  33. package/dist/Toast/Toast.cjs +1 -1
  34. package/dist/Toast/Toast.js +1 -1
  35. package/dist/index.cjs +382 -5
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.js +382 -5
  38. package/dist/index.js.map +1 -1
  39. package/dist/shared/{_rollupPluginBabelHelpers-xUOatjtv.cjs → _rollupPluginBabelHelpers-B3P3Gzh9.cjs} +14 -1
  40. package/dist/shared/_rollupPluginBabelHelpers-B3P3Gzh9.cjs.map +1 -0
  41. package/dist/shared/{_rollupPluginBabelHelpers-CSWl3xs2.js → _rollupPluginBabelHelpers-BYQx3gqx.js} +14 -2
  42. package/dist/shared/{_rollupPluginBabelHelpers-CSWl3xs2.js.map → _rollupPluginBabelHelpers-BYQx3gqx.js.map} +1 -1
  43. package/dist/styles.css +4 -71
  44. package/package.json +2 -2
  45. package/dist/shared/_rollupPluginBabelHelpers-xUOatjtv.cjs.map +0 -1
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import './styles.css';
3
+ import { IconName } from '@times-design-system/icons';
4
+ type TabState = 'base' | 'hover' | 'pressed' | 'disabled' | 'focus';
5
+ type TabSize = 'medium' | 'large';
6
+ export interface TabProps {
7
+ /** Visual preview state for parity/testing */
8
+ state?: TabState;
9
+ /** Tab size variant */
10
+ size?: TabSize;
11
+ /** Whether the tab is the selected tab in its group */
12
+ active?: boolean;
13
+ /** Applies channel color token family */
14
+ channel?: boolean;
15
+ /** Show a leading icon */
16
+ leftIcon?: IconName;
17
+ /** Show a trailing icon */
18
+ rightIcon?: IconName;
19
+ /** Visible label */
20
+ label?: React.ReactNode;
21
+ /** Optional alias for label content */
22
+ children?: React.ReactNode;
23
+ /** Optional accessible name override */
24
+ 'aria-label'?: string;
25
+ /** Optional camelCase alias for aria-label */
26
+ ariaLabel?: string;
27
+ /** Optional id for aria-controls relationships */
28
+ id?: string;
29
+ /** Id of the panel this tab controls */
30
+ 'aria-controls'?: string;
31
+ /** @ignore */
32
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
33
+ /** @ignore */
34
+ onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;
35
+ /** @ignore */
36
+ className?: string;
37
+ /** @ignore */
38
+ disabled?: boolean;
39
+ /** @ignore */
40
+ tabIndex?: number;
41
+ }
42
+ /** Single tab inside a TabGroup. Render through TabGroup for tablist semantics and keyboard nav. */
43
+ export declare const Tab: React.ForwardRefExoticComponent<TabProps & React.RefAttributes<HTMLButtonElement>>;
44
+ export {};
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import './styles.css';
3
+ type TabGroupBehaviour = 'hug' | '100%';
4
+ export interface TabGroupProps {
5
+ /** Sizing behaviour: hug content or fill the container */
6
+ behaviour?: TabGroupBehaviour;
7
+ /** Index of the initially selected tab (uncontrolled) */
8
+ defaultSelectedIndex?: number;
9
+ /** Index of the selected tab (controlled) */
10
+ selectedIndex?: number;
11
+ /** Callback fired when the selected tab changes */
12
+ onSelectedIndexChange?: (index: number) => void;
13
+ /** Tab children */
14
+ children?: React.ReactNode;
15
+ /** Optional accessible name for the tablist */
16
+ 'aria-label'?: string;
17
+ /** Optional camelCase alias for aria-label */
18
+ ariaLabel?: string;
19
+ /** Optional id for the tablist root */
20
+ id?: string;
21
+ /** @ignore */
22
+ className?: string;
23
+ }
24
+ /** Tablist container that manages selection and keyboard navigation across Tab children. */
25
+ export declare const TabGroup: React.FC<TabGroupProps>;
26
+ export {};
@@ -1,26 +1,28 @@
1
1
  'use strict';
2
2
 
3
+ var _rollupPluginBabelHelpers = require('../shared/_rollupPluginBabelHelpers-B3P3Gzh9.cjs');
3
4
  var React = require('react');
4
5
  var styleInject_es = require('../shared/style-inject.es-DnsWrQaj.cjs');
5
6
  var cn = require('../shared/cn-CPfjOlzZ.cjs');
6
7
 
7
- var css_248z = ".storybook-button{border:0;border-radius:3em;cursor:pointer;display:inline-block;font-family:Roboto,Roboto-Regular,Helvetica,Arial,sans-serif;font-weight:700;line-height:1}.storybook-button--primary{background-color:#555ab9;color:#fff}.storybook-button--secondary{background-color:transparent;box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);color:#333}.storybook-button--small{font-size:12px;padding:10px 16px}.storybook-button--medium{font-size:14px;padding:11px 20px}.storybook-button--large{font-size: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zMztcbn1cbi5zdG9yeWJvb2stYnV0dG9uLS1zbWFsbCB7XG4gIHBhZGRpbmc6IDEwcHggMTZweDtcbiAgZm9udC1zaXplOiAxMnB4O1xufVxuLnN0b3J5Ym9vay1idXR0b24tLW1lZGl1bSB7XG4gIHBhZGRpbmc6IDExcHggMjBweDtcbiAgZm9udC1zaXplOiAxNHB4O1xufVxuLnN0b3J5Ym9vay1idXR0b24tLWxhcmdlIHtcbiAgcGFkZGluZzogMTJweCAyNHB4O1xuICBmb250LXNpemU6IDE2cHg7XG59XG4iXX0= */";
8
+ var css_248z = ".tds-text{margin:0;padding:0}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsVUFDRSxRQUFTLENBQ1QsU0FDRiIsImZpbGUiOiJzdHlsZXMuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLyogVGV4dCBjb21wb25lbnQgcmVzZXQgLSByZW1vdmVzIGJyb3dzZXIgZGVmYXVsdHMgKi9cbi50ZHMtdGV4dCB7XG4gIG1hcmdpbjogMDtcbiAgcGFkZGluZzogMDtcbn1cbiJdfQ== */";
8
9
  styleInject_es.styleInject(css_248z);
9
10
 
10
- var Text = function Text(_ref) {
11
- var _typographyStyle$repl;
11
+ var _excluded = ["as", "typographyStyle", "className", "children"];
12
+ var Text = /*#__PURE__*/React.forwardRef(function Text(_ref, ref) {
12
13
  var as = _ref.as,
13
- typographyStyle = _ref.typographyStyle,
14
- styles = _ref.styles,
15
- classes = _ref.classes,
16
- children = _ref.children;
17
- var TextComponent = as || 'p';
18
- var transformedTypographyStyle = (_typographyStyle$repl = typographyStyle === null || typographyStyle === void 0 ? void 0 : typographyStyle.replaceAll('.', '-').toLowerCase()) !== null && _typographyStyle$repl !== void 0 ? _typographyStyle$repl : '';
19
- return /*#__PURE__*/React.createElement(TextComponent, {
20
- className: cn.cn(classes, typographyStyle ? transformedTypographyStyle : undefined),
21
- style: styles ? styles : undefined
22
- }, children);
23
- };
14
+ _ref$typographyStyle = _ref.typographyStyle,
15
+ typographyStyle = _ref$typographyStyle === void 0 ? 'utility.body.regular.medium' : _ref$typographyStyle,
16
+ className = _ref.className,
17
+ children = _ref.children,
18
+ rest = _rollupPluginBabelHelpers._objectWithoutProperties(_ref, _excluded);
19
+ var Component = as || 'span';
20
+ var typographyClass = typographyStyle.replaceAll('.', '-');
21
+ return /*#__PURE__*/React.createElement(Component, _rollupPluginBabelHelpers._objectSpread2({
22
+ ref: ref,
23
+ className: cn.cn('tds-text', typographyClass, className)
24
+ }, rest), children);
25
+ });
24
26
 
25
27
  exports.Text = Text;
26
28
  //# sourceMappingURL=Text.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.cjs","sources":["../../src/Text/Text.tsx"],"sourcesContent":["import React from 'react';\nimport './styles.css';\nimport { cn } from '../utils/cn';\n\ninterface TextProps {\n as?: 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5';\n typographyStyle?: string;\n classes?: string;\n styles?: { [key: string]: string };\n children?: React.ReactNode;\n}\n\nexport const Text: React.FC<TextProps> = ({\n as,\n typographyStyle,\n styles,\n classes,\n children\n}) => {\n const TextComponent = as || 'p';\n const transformedTypographyStyle =\n typographyStyle?.replaceAll('.', '-').toLowerCase() ?? '';\n\n return (\n <TextComponent\n className={cn(\n classes,\n typographyStyle ? transformedTypographyStyle : undefined\n )}\n style={styles ? styles : undefined}\n >\n {children}\n </TextComponent>\n );\n};\n"],"names":["Text","_ref","_typographyStyle$repl","as","typographyStyle","styles","classes","children","TextComponent","transformedTypographyStyle","replaceAll","toLowerCase","React","createElement","className","cn","undefined","style"],"mappings":";;;;;;;;;IAYaA,IAAI,GAAwB,SAA5BA,IAAIA,CAAAC,IAAA,EAMZ;AAAA,EAAA,IAAAC,qBAAA;AAAA,EAAA,IALHC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IACFC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IACPC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;AAER,EAAA,IAAMC,aAAa,GAAGL,EAAE,IAAI,GAAG;EAC/B,IAAMM,0BAA0B,GAAA,CAAAP,qBAAA,GAC9BE,eAAe,aAAfA,eAAe,KAAA,MAAA,GAAA,MAAA,GAAfA,eAAe,CAAEM,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAACC,WAAW,EAAE,MAAA,IAAA,IAAAT,qBAAA,KAAA,MAAA,GAAAA,qBAAA,GAAI,EAAE;AAE3D,EAAA,oBACEU,KAAA,CAAAC,aAAA,CAACL,aAAa,EAAA;IACZM,SAAS,EAAEC,KAAE,CACXT,OAAO,EACPF,eAAe,GAAGK,0BAA0B,GAAGO,SAAS,CACzD;AACDC,IAAAA,KAAK,EAAEZ,MAAM,GAAGA,MAAM,GAAGW;GAAS,EAEjCT,QAAQ,CACK;AAEpB;;;;"}
1
+ {"version":3,"file":"Text.cjs","sources":["../../src/Text/Text.tsx"],"sourcesContent":["import React from 'react';\nimport './styles.css';\nimport { cn } from '../utils/cn';\n\n// --- Typography Token Type ---\n\ntype BrandHeadingFluidWeight = 'light' | 'regular' | 'bold' | 'black';\ntype BrandHeadingFluidSize =\n | '2xsmall'\n | 'xsmall'\n | 'small'\n | 'medium'\n | 'large'\n | 'xlarge'\n | '2xlarge';\ntype BrandHeadingFluid =\n `brand.heading.fluid.${BrandHeadingFluidWeight}.${BrandHeadingFluidSize}`;\n\ntype BrandHeadingStaticWeight = 'bold' | 'black';\ntype BrandHeadingStaticSize =\n | '010'\n | '020'\n | '030'\n | '040'\n | '050'\n | '060'\n | '070'\n | '080'\n | '090'\n | '100';\ntype BrandHeadingStatic =\n `brand.heading.static.${BrandHeadingStaticWeight}.${BrandHeadingStaticSize}`;\n\ntype BrandSubheadingWeight = 'light' | 'regular' | 'bold';\ntype BrandSubheadingSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';\ntype BrandSubheading =\n `brand.subheading.${BrandSubheadingWeight}.${BrandSubheadingSize}`;\n\ntype BrandStandfirst = `brand.standfirst.${'medium' | 'large'}`;\n\ntype BrandParagraphWeight = 'regular' | 'bold';\ntype BrandParagraphSize = 'small' | 'medium';\ntype BrandParagraph =\n `brand.paragraph.${BrandParagraphWeight}.${BrandParagraphSize}`;\n\ntype BrandCaption = `brand.caption.${'small' | 'medium'}`;\ntype BrandByline = `brand.byline.${'small' | 'medium'}`;\n\ntype UtilityHeading = `utility.heading.${'small' | 'medium' | 'large'}`;\ntype UtilitySubheading =\n `utility.subheading.${'xsmall' | 'small' | 'medium' | 'large'}`;\n\ntype UtilityBodyWeight = 'regular' | 'bold';\ntype UtilityBodySize = '2xsmall' | 'xsmall' | 'small' | 'medium' | 'large';\ntype UtilityBody = `utility.body.${UtilityBodyWeight}.${UtilityBodySize}`;\n\ntype UtilityButton =\n `utility.button.${'xsmall' | 'small' | 'medium' | 'large'}`;\ntype UtilityLabel = `utility.label.${'xsmall' | 'small' | 'medium' | 'large'}`;\n\nexport type TypographyToken =\n | BrandHeadingFluid\n | BrandHeadingStatic\n | BrandSubheading\n | BrandStandfirst\n | BrandParagraph\n | BrandCaption\n | BrandByline\n | UtilityHeading\n | UtilitySubheading\n | UtilityBody\n | UtilityButton\n | UtilityLabel;\n\n// --- Element & Props Types ---\n\ntype AllowedElements =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'p'\n | 'span'\n | 'figcaption'\n | 'blockquote'\n | 'label'\n | 'legend'\n | 'li'\n | 'dt'\n | 'dd'\n | 'time'\n | 'address'\n | 'cite'\n | 'em'\n | 'strong';\n\n// Maps each element to its valid typography tokens\ntype TypographyTokenForElement<T extends AllowedElements> = T extends\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n ?\n | BrandHeadingFluid\n | BrandHeadingStatic\n | BrandSubheading\n | UtilityHeading\n | UtilitySubheading\n : T extends 'p' | 'li' | 'dt' | 'dd' | 'address'\n ? UtilityBody | BrandParagraph\n : T extends 'figcaption'\n ? BrandCaption\n : T extends 'blockquote'\n ? BrandStandfirst\n : T extends 'label' | 'legend'\n ? UtilityLabel | UtilityBody\n : T extends 'cite'\n ? BrandByline | BrandCaption\n : T extends 'time'\n ? UtilityBody | BrandCaption | BrandByline\n : TypographyToken;\n\ntype TextOwnProps<T extends AllowedElements = 'span'> = {\n as?: T;\n typographyStyle?: TypographyTokenForElement<T>;\n children?: React.ReactNode;\n className?: string;\n};\n\ntype TextProps<T extends AllowedElements = 'span'> = TextOwnProps<T> &\n Omit<React.ComponentPropsWithRef<T>, keyof TextOwnProps<T>>;\n\n// --- Component ---\n\ntype TextComponent = <T extends AllowedElements = 'span'>(\n props: TextProps<T> & { ref?: React.Ref<HTMLElement> }\n) => React.ReactElement | null;\n\nexport const Text: TextComponent = React.forwardRef<\n HTMLElement,\n TextProps<AllowedElements>\n>(function Text(\n {\n as,\n typographyStyle = 'utility.body.regular.medium',\n className,\n children,\n ...rest\n },\n ref\n) {\n const Component = (as || 'span') as React.ElementType;\n const typographyClass = typographyStyle.replaceAll('.', '-');\n\n return (\n <Component\n ref={ref}\n className={cn('tds-text', typographyClass, className)}\n {...rest}\n >\n {children}\n </Component>\n );\n}) as unknown as TextComponent;\n"],"names":["Text","React","forwardRef","_ref","ref","as","_ref$typographyStyle","typographyStyle","className","children","rest","_objectWithoutProperties","_excluded","Component","typographyClass","replaceAll","createElement","_objectSpread","cn"],"mappings":";;;;;;;;;;;AA8IO,IAAMA,IAAI,gBAAkBC,KAAK,CAACC,UAAU,CAGjD,SAASF,IAAIA,CAAAG,IAAA,EAQbC,GAAG,EAAA;AAAA,EAAA,IANDC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IAAAC,oBAAA,GAAAH,IAAA,CACFI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAA,MAAA,GAAG,6BAA6B,GAAAA,oBAAA;IAC/CE,SAAS,GAAAL,IAAA,CAATK,SAAS;IACTC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;AACLC,IAAAA,IAAI,GAAAC,kDAAA,CAAAR,IAAA,EAAAS,SAAA,CAAA;AAIT,EAAA,IAAMC,SAAS,GAAIR,EAAE,IAAI,MAA4B;EACrD,IAAMS,eAAe,GAAGP,eAAe,CAACQ,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAE5D,EAAA,oBACEd,KAAA,CAAAe,aAAA,CAACH,SAAS,EAAAI,wCAAA,CAAA;AACRb,IAAAA,GAAG,EAAEA,GAAG;AACRI,IAAAA,SAAS,EAAEU,KAAE,CAAC,UAAU,EAAEJ,eAAe,EAAEN,SAAS;GAAC,EACjDE,IAAI,CAAA,EAEPD,QAAQ,CACC;AAEhB,CAAC;;;;"}
@@ -1,13 +1,39 @@
1
1
  import React from 'react';
2
2
  import './styles.css';
3
- interface TextProps {
4
- as?: 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5';
5
- typographyStyle?: string;
6
- classes?: string;
7
- styles?: {
8
- [key: string]: string;
9
- };
3
+ type BrandHeadingFluidWeight = 'light' | 'regular' | 'bold' | 'black';
4
+ type BrandHeadingFluidSize = '2xsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge';
5
+ type BrandHeadingFluid = `brand.heading.fluid.${BrandHeadingFluidWeight}.${BrandHeadingFluidSize}`;
6
+ type BrandHeadingStaticWeight = 'bold' | 'black';
7
+ type BrandHeadingStaticSize = '010' | '020' | '030' | '040' | '050' | '060' | '070' | '080' | '090' | '100';
8
+ type BrandHeadingStatic = `brand.heading.static.${BrandHeadingStaticWeight}.${BrandHeadingStaticSize}`;
9
+ type BrandSubheadingWeight = 'light' | 'regular' | 'bold';
10
+ type BrandSubheadingSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
11
+ type BrandSubheading = `brand.subheading.${BrandSubheadingWeight}.${BrandSubheadingSize}`;
12
+ type BrandStandfirst = `brand.standfirst.${'medium' | 'large'}`;
13
+ type BrandParagraphWeight = 'regular' | 'bold';
14
+ type BrandParagraphSize = 'small' | 'medium';
15
+ type BrandParagraph = `brand.paragraph.${BrandParagraphWeight}.${BrandParagraphSize}`;
16
+ type BrandCaption = `brand.caption.${'small' | 'medium'}`;
17
+ type BrandByline = `brand.byline.${'small' | 'medium'}`;
18
+ type UtilityHeading = `utility.heading.${'small' | 'medium' | 'large'}`;
19
+ type UtilitySubheading = `utility.subheading.${'xsmall' | 'small' | 'medium' | 'large'}`;
20
+ type UtilityBodyWeight = 'regular' | 'bold';
21
+ type UtilityBodySize = '2xsmall' | 'xsmall' | 'small' | 'medium' | 'large';
22
+ type UtilityBody = `utility.body.${UtilityBodyWeight}.${UtilityBodySize}`;
23
+ type UtilityButton = `utility.button.${'xsmall' | 'small' | 'medium' | 'large'}`;
24
+ type UtilityLabel = `utility.label.${'xsmall' | 'small' | 'medium' | 'large'}`;
25
+ export type TypographyToken = BrandHeadingFluid | BrandHeadingStatic | BrandSubheading | BrandStandfirst | BrandParagraph | BrandCaption | BrandByline | UtilityHeading | UtilitySubheading | UtilityBody | UtilityButton | UtilityLabel;
26
+ type AllowedElements = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'figcaption' | 'blockquote' | 'label' | 'legend' | 'li' | 'dt' | 'dd' | 'time' | 'address' | 'cite' | 'em' | 'strong';
27
+ type TypographyTokenForElement<T extends AllowedElements> = T extends 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' ? BrandHeadingFluid | BrandHeadingStatic | BrandSubheading | UtilityHeading | UtilitySubheading : T extends 'p' | 'li' | 'dt' | 'dd' | 'address' ? UtilityBody | BrandParagraph : T extends 'figcaption' ? BrandCaption : T extends 'blockquote' ? BrandStandfirst : T extends 'label' | 'legend' ? UtilityLabel | UtilityBody : T extends 'cite' ? BrandByline | BrandCaption : T extends 'time' ? UtilityBody | BrandCaption | BrandByline : TypographyToken;
28
+ type TextOwnProps<T extends AllowedElements = 'span'> = {
29
+ as?: T;
30
+ typographyStyle?: TypographyTokenForElement<T>;
10
31
  children?: React.ReactNode;
11
- }
12
- export declare const Text: React.FC<TextProps>;
32
+ className?: string;
33
+ };
34
+ type TextProps<T extends AllowedElements = 'span'> = TextOwnProps<T> & Omit<React.ComponentPropsWithRef<T>, keyof TextOwnProps<T>>;
35
+ type TextComponent = <T extends AllowedElements = 'span'>(props: TextProps<T> & {
36
+ ref?: React.Ref<HTMLElement>;
37
+ }) => React.ReactElement | null;
38
+ export declare const Text: TextComponent;
13
39
  export {};
package/dist/Text/Text.js CHANGED
@@ -1,24 +1,26 @@
1
+ import { _ as _objectWithoutProperties, a as _objectSpread2 } from '../shared/_rollupPluginBabelHelpers-BYQx3gqx.js';
1
2
  import React from 'react';
2
3
  import { s as styleInject } from '../shared/style-inject.es-Br8gHeuy.js';
3
4
  import { c as cn } from '../shared/cn-DcOuz-3C.js';
4
5
 
5
- var css_248z = ".storybook-button{border:0;border-radius:3em;cursor:pointer;display:inline-block;font-family:Roboto,Roboto-Regular,Helvetica,Arial,sans-serif;font-weight:700;line-height:1}.storybook-button--primary{background-color:#555ab9;color:#fff}.storybook-button--secondary{background-color:transparent;box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);color:#333}.storybook-button--small{font-size:12px;padding:10px 16px}.storybook-button--medium{font-size:14px;padding:11px 20px}.storybook-button--large{font-size:16px;padding:12px 24px}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsa0JBR0UsUUFBUyxDQUNULGlCQUFrQixDQUZsQixjQUFlLENBRGYsb0JBQXFCLENBTXJCLDREQUFxRSxDQUZyRSxlQUFnQixDQUNoQixhQUVGLENBQ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tcbiAgcGFkZGluZzogMTJweCAyNHB4O1xuICBmb250LXNpemU6IDE2cHg7XG59XG4iXX0= */";
6
+ var css_248z = ".tds-text{margin:0;padding:0}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0eWxlcy5jc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsVUFDRSxRQUFTLENBQ1QsU0FDRiIsImZpbGUiOiJzdHlsZXMuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiLyogVGV4dCBjb21wb25lbnQgcmVzZXQgLSByZW1vdmVzIGJyb3dzZXIgZGVmYXVsdHMgKi9cbi50ZHMtdGV4dCB7XG4gIG1hcmdpbjogMDtcbiAgcGFkZGluZzogMDtcbn1cbiJdfQ== */";
6
7
  styleInject(css_248z);
7
8
 
8
- var Text = function Text(_ref) {
9
- var _typographyStyle$repl;
9
+ var _excluded = ["as", "typographyStyle", "className", "children"];
10
+ var Text = /*#__PURE__*/React.forwardRef(function Text(_ref, ref) {
10
11
  var as = _ref.as,
11
- typographyStyle = _ref.typographyStyle,
12
- styles = _ref.styles,
13
- classes = _ref.classes,
14
- children = _ref.children;
15
- var TextComponent = as || 'p';
16
- var transformedTypographyStyle = (_typographyStyle$repl = typographyStyle === null || typographyStyle === void 0 ? void 0 : typographyStyle.replaceAll('.', '-').toLowerCase()) !== null && _typographyStyle$repl !== void 0 ? _typographyStyle$repl : '';
17
- return /*#__PURE__*/React.createElement(TextComponent, {
18
- className: cn(classes, typographyStyle ? transformedTypographyStyle : undefined),
19
- style: styles ? styles : undefined
20
- }, children);
21
- };
12
+ _ref$typographyStyle = _ref.typographyStyle,
13
+ typographyStyle = _ref$typographyStyle === void 0 ? 'utility.body.regular.medium' : _ref$typographyStyle,
14
+ className = _ref.className,
15
+ children = _ref.children,
16
+ rest = _objectWithoutProperties(_ref, _excluded);
17
+ var Component = as || 'span';
18
+ var typographyClass = typographyStyle.replaceAll('.', '-');
19
+ return /*#__PURE__*/React.createElement(Component, _objectSpread2({
20
+ ref: ref,
21
+ className: cn('tds-text', typographyClass, className)
22
+ }, rest), children);
23
+ });
22
24
 
23
25
  export { Text };
24
26
  //# sourceMappingURL=Text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","sources":["../../src/Text/Text.tsx"],"sourcesContent":["import React from 'react';\nimport './styles.css';\nimport { cn } from '../utils/cn';\n\ninterface TextProps {\n as?: 'p' | 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5';\n typographyStyle?: string;\n classes?: string;\n styles?: { [key: string]: string };\n children?: React.ReactNode;\n}\n\nexport const Text: React.FC<TextProps> = ({\n as,\n typographyStyle,\n styles,\n classes,\n children\n}) => {\n const TextComponent = as || 'p';\n const transformedTypographyStyle =\n typographyStyle?.replaceAll('.', '-').toLowerCase() ?? '';\n\n return (\n <TextComponent\n className={cn(\n classes,\n typographyStyle ? transformedTypographyStyle : undefined\n )}\n style={styles ? styles : undefined}\n >\n {children}\n </TextComponent>\n );\n};\n"],"names":["Text","_ref","_typographyStyle$repl","as","typographyStyle","styles","classes","children","TextComponent","transformedTypographyStyle","replaceAll","toLowerCase","React","createElement","className","cn","undefined","style"],"mappings":";;;;;;;IAYaA,IAAI,GAAwB,SAA5BA,IAAIA,CAAAC,IAAA,EAMZ;AAAA,EAAA,IAAAC,qBAAA;AAAA,EAAA,IALHC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IACFC,eAAe,GAAAH,IAAA,CAAfG,eAAe;IACfC,MAAM,GAAAJ,IAAA,CAANI,MAAM;IACNC,OAAO,GAAAL,IAAA,CAAPK,OAAO;IACPC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;AAER,EAAA,IAAMC,aAAa,GAAGL,EAAE,IAAI,GAAG;EAC/B,IAAMM,0BAA0B,GAAA,CAAAP,qBAAA,GAC9BE,eAAe,aAAfA,eAAe,KAAA,MAAA,GAAA,MAAA,GAAfA,eAAe,CAAEM,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAACC,WAAW,EAAE,MAAA,IAAA,IAAAT,qBAAA,KAAA,MAAA,GAAAA,qBAAA,GAAI,EAAE;AAE3D,EAAA,oBACEU,KAAA,CAAAC,aAAA,CAACL,aAAa,EAAA;IACZM,SAAS,EAAEC,EAAE,CACXT,OAAO,EACPF,eAAe,GAAGK,0BAA0B,GAAGO,SAAS,CACzD;AACDC,IAAAA,KAAK,EAAEZ,MAAM,GAAGA,MAAM,GAAGW;GAAS,EAEjCT,QAAQ,CACK;AAEpB;;;;"}
1
+ {"version":3,"file":"Text.js","sources":["../../src/Text/Text.tsx"],"sourcesContent":["import React from 'react';\nimport './styles.css';\nimport { cn } from '../utils/cn';\n\n// --- Typography Token Type ---\n\ntype BrandHeadingFluidWeight = 'light' | 'regular' | 'bold' | 'black';\ntype BrandHeadingFluidSize =\n | '2xsmall'\n | 'xsmall'\n | 'small'\n | 'medium'\n | 'large'\n | 'xlarge'\n | '2xlarge';\ntype BrandHeadingFluid =\n `brand.heading.fluid.${BrandHeadingFluidWeight}.${BrandHeadingFluidSize}`;\n\ntype BrandHeadingStaticWeight = 'bold' | 'black';\ntype BrandHeadingStaticSize =\n | '010'\n | '020'\n | '030'\n | '040'\n | '050'\n | '060'\n | '070'\n | '080'\n | '090'\n | '100';\ntype BrandHeadingStatic =\n `brand.heading.static.${BrandHeadingStaticWeight}.${BrandHeadingStaticSize}`;\n\ntype BrandSubheadingWeight = 'light' | 'regular' | 'bold';\ntype BrandSubheadingSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';\ntype BrandSubheading =\n `brand.subheading.${BrandSubheadingWeight}.${BrandSubheadingSize}`;\n\ntype BrandStandfirst = `brand.standfirst.${'medium' | 'large'}`;\n\ntype BrandParagraphWeight = 'regular' | 'bold';\ntype BrandParagraphSize = 'small' | 'medium';\ntype BrandParagraph =\n `brand.paragraph.${BrandParagraphWeight}.${BrandParagraphSize}`;\n\ntype BrandCaption = `brand.caption.${'small' | 'medium'}`;\ntype BrandByline = `brand.byline.${'small' | 'medium'}`;\n\ntype UtilityHeading = `utility.heading.${'small' | 'medium' | 'large'}`;\ntype UtilitySubheading =\n `utility.subheading.${'xsmall' | 'small' | 'medium' | 'large'}`;\n\ntype UtilityBodyWeight = 'regular' | 'bold';\ntype UtilityBodySize = '2xsmall' | 'xsmall' | 'small' | 'medium' | 'large';\ntype UtilityBody = `utility.body.${UtilityBodyWeight}.${UtilityBodySize}`;\n\ntype UtilityButton =\n `utility.button.${'xsmall' | 'small' | 'medium' | 'large'}`;\ntype UtilityLabel = `utility.label.${'xsmall' | 'small' | 'medium' | 'large'}`;\n\nexport type TypographyToken =\n | BrandHeadingFluid\n | BrandHeadingStatic\n | BrandSubheading\n | BrandStandfirst\n | BrandParagraph\n | BrandCaption\n | BrandByline\n | UtilityHeading\n | UtilitySubheading\n | UtilityBody\n | UtilityButton\n | UtilityLabel;\n\n// --- Element & Props Types ---\n\ntype AllowedElements =\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'p'\n | 'span'\n | 'figcaption'\n | 'blockquote'\n | 'label'\n | 'legend'\n | 'li'\n | 'dt'\n | 'dd'\n | 'time'\n | 'address'\n | 'cite'\n | 'em'\n | 'strong';\n\n// Maps each element to its valid typography tokens\ntype TypographyTokenForElement<T extends AllowedElements> = T extends\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n ?\n | BrandHeadingFluid\n | BrandHeadingStatic\n | BrandSubheading\n | UtilityHeading\n | UtilitySubheading\n : T extends 'p' | 'li' | 'dt' | 'dd' | 'address'\n ? UtilityBody | BrandParagraph\n : T extends 'figcaption'\n ? BrandCaption\n : T extends 'blockquote'\n ? BrandStandfirst\n : T extends 'label' | 'legend'\n ? UtilityLabel | UtilityBody\n : T extends 'cite'\n ? BrandByline | BrandCaption\n : T extends 'time'\n ? UtilityBody | BrandCaption | BrandByline\n : TypographyToken;\n\ntype TextOwnProps<T extends AllowedElements = 'span'> = {\n as?: T;\n typographyStyle?: TypographyTokenForElement<T>;\n children?: React.ReactNode;\n className?: string;\n};\n\ntype TextProps<T extends AllowedElements = 'span'> = TextOwnProps<T> &\n Omit<React.ComponentPropsWithRef<T>, keyof TextOwnProps<T>>;\n\n// --- Component ---\n\ntype TextComponent = <T extends AllowedElements = 'span'>(\n props: TextProps<T> & { ref?: React.Ref<HTMLElement> }\n) => React.ReactElement | null;\n\nexport const Text: TextComponent = React.forwardRef<\n HTMLElement,\n TextProps<AllowedElements>\n>(function Text(\n {\n as,\n typographyStyle = 'utility.body.regular.medium',\n className,\n children,\n ...rest\n },\n ref\n) {\n const Component = (as || 'span') as React.ElementType;\n const typographyClass = typographyStyle.replaceAll('.', '-');\n\n return (\n <Component\n ref={ref}\n className={cn('tds-text', typographyClass, className)}\n {...rest}\n >\n {children}\n </Component>\n );\n}) as unknown as TextComponent;\n"],"names":["Text","React","forwardRef","_ref","ref","as","_ref$typographyStyle","typographyStyle","className","children","rest","_objectWithoutProperties","_excluded","Component","typographyClass","replaceAll","createElement","_objectSpread","cn"],"mappings":";;;;;;;;;AA8IO,IAAMA,IAAI,gBAAkBC,KAAK,CAACC,UAAU,CAGjD,SAASF,IAAIA,CAAAG,IAAA,EAQbC,GAAG,EAAA;AAAA,EAAA,IANDC,EAAE,GAAAF,IAAA,CAAFE,EAAE;IAAAC,oBAAA,GAAAH,IAAA,CACFI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAA,MAAA,GAAG,6BAA6B,GAAAA,oBAAA;IAC/CE,SAAS,GAAAL,IAAA,CAATK,SAAS;IACTC,QAAQ,GAAAN,IAAA,CAARM,QAAQ;AACLC,IAAAA,IAAI,GAAAC,wBAAA,CAAAR,IAAA,EAAAS,SAAA,CAAA;AAIT,EAAA,IAAMC,SAAS,GAAIR,EAAE,IAAI,MAA4B;EACrD,IAAMS,eAAe,GAAGP,eAAe,CAACQ,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;AAE5D,EAAA,oBACEd,KAAA,CAAAe,aAAA,CAACH,SAAS,EAAAI,cAAA,CAAA;AACRb,IAAAA,GAAG,EAAEA,GAAG;AACRI,IAAAA,SAAS,EAAEU,EAAE,CAAC,UAAU,EAAEJ,eAAe,EAAEN,SAAS;GAAC,EACjDE,IAAI,CAAA,EAEPD,QAAQ,CACC;AAEhB,CAAC;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var _rollupPluginBabelHelpers = require('../shared/_rollupPluginBabelHelpers-xUOatjtv.cjs');
3
+ var _rollupPluginBabelHelpers = require('../shared/_rollupPluginBabelHelpers-B3P3Gzh9.cjs');
4
4
  var React = require('react');
5
5
  var Icon_Icon = require('../Icon/Icon.cjs');
6
6
  var cn = require('../shared/cn-CPfjOlzZ.cjs');
@@ -1,4 +1,4 @@
1
- import { _ as _objectWithoutProperties, b as _slicedToArray, a as _objectSpread2 } from '../shared/_rollupPluginBabelHelpers-CSWl3xs2.js';
1
+ import { _ as _objectWithoutProperties, b as _slicedToArray, a as _objectSpread2 } from '../shared/_rollupPluginBabelHelpers-BYQx3gqx.js';
2
2
  import React, { useState, useEffect } from 'react';
3
3
  import { Icon } from '../Icon/Icon.js';
4
4
  import { c as cn } from '../shared/cn-DcOuz-3C.js';