@entur/typography 2.0.0 → 2.0.2-beta.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.
- package/dist/beta/cjs/components/Text.cjs +1 -1
- package/dist/beta/cjs/components/Text.cjs.map +1 -1
- package/dist/beta/esm/components/Text.mjs +1 -1
- package/dist/beta/esm/components/Text.mjs.map +1 -1
- package/dist/beta/styles/components/heading.css +2 -2
- package/dist/beta/styles/components/text.css +2 -2
- package/dist/styles.css +2 -2
- package/package.json +6 -7
- package/scripts/{migrate-typography.js → migrate-typography.mjs} +15 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.cjs","sources":["../../../../src/beta/components/Text.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport {\n getSpacingClasses,\n getSemanticTypeFromTextVariant,\n} from '../utils/utils';\n\nimport {\n TypographySize,\n TypographyTextVariant,\n TypographyWeight,\n TypographySpacing,\n} from '../types';\n\nimport './text.scss';\n\ntype TextBaseProps = {\n /** Visuell tekststørrelse (typografi-token) */\n size?: TypographySize;\n /** Fontvekt */\n weight?: TypographyWeight;\n /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */\n variant?: TypographyTextVariant;\n /** Innhold */\n children: React.ReactNode;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n /** Ekstra klassenavn */\n className?: string;\n};\n\nexport type TextProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n TextBaseProps\n>;\n\nconst TypographyText = <C extends React.ElementType = 'p'>({\n children,\n as,\n size,\n variant,\n weight
|
|
1
|
+
{"version":3,"file":"Text.cjs","sources":["../../../../src/beta/components/Text.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport {\n getSpacingClasses,\n getSemanticTypeFromTextVariant,\n} from '../utils/utils';\n\nimport {\n TypographySize,\n TypographyTextVariant,\n TypographyWeight,\n TypographySpacing,\n} from '../types';\n\nimport './text.scss';\n\ntype TextBaseProps = {\n /** Visuell tekststørrelse (typografi-token) */\n size?: TypographySize;\n /** Fontvekt */\n weight?: TypographyWeight;\n /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */\n variant?: TypographyTextVariant;\n /** Innhold */\n children: React.ReactNode;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n /** Ekstra klassenavn */\n className?: string;\n};\n\nexport type TextProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n TextBaseProps\n>;\n\nconst TypographyText = <C extends React.ElementType = 'p'>({\n children,\n as,\n size,\n variant,\n weight,\n spacing,\n className,\n ...rest\n}: TextProps<C>) => {\n const BodyElement = as || getSemanticTypeFromTextVariant(variant);\n\n return (\n <BodyElement\n className={classNames(\n 'eds-text',\n variant && `eds-text--${variant}`,\n size && `eds-text--${size}`,\n weight && `eds-text--weight-${weight}`,\n getSpacingClasses(spacing, 'eds-text'),\n className,\n )}\n {...rest}\n >\n {children}\n </BodyElement>\n );\n};\n\n// Export as Text to avoid DOM conflicts\nexport const Text = TypographyText;\n"],"names":["getSemanticTypeFromTextVariant","jsx","getSpacingClasses"],"mappings":";;;;;;AAwCA,MAAM,iBAAiB,CAAoC;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoB;AAClB,QAAM,cAAc,MAAMA,MAAAA,+BAA+B,OAAO;AAEhE,SACEC,2BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW,aAAa,OAAO;AAAA,QAC/B,QAAQ,aAAa,IAAI;AAAA,QACzB,UAAU,oBAAoB,MAAM;AAAA,QACpCC,MAAAA,kBAAkB,SAAS,UAAU;AAAA,QACrC;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;AAGO,MAAM,OAAO;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.mjs","sources":["../../../../src/beta/components/Text.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport {\n getSpacingClasses,\n getSemanticTypeFromTextVariant,\n} from '../utils/utils';\n\nimport {\n TypographySize,\n TypographyTextVariant,\n TypographyWeight,\n TypographySpacing,\n} from '../types';\n\nimport './text.scss';\n\ntype TextBaseProps = {\n /** Visuell tekststørrelse (typografi-token) */\n size?: TypographySize;\n /** Fontvekt */\n weight?: TypographyWeight;\n /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */\n variant?: TypographyTextVariant;\n /** Innhold */\n children: React.ReactNode;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n /** Ekstra klassenavn */\n className?: string;\n};\n\nexport type TextProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n TextBaseProps\n>;\n\nconst TypographyText = <C extends React.ElementType = 'p'>({\n children,\n as,\n size,\n variant,\n weight
|
|
1
|
+
{"version":3,"file":"Text.mjs","sources":["../../../../src/beta/components/Text.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { PolymorphicComponentProps } from '@entur/utils';\n\nimport {\n getSpacingClasses,\n getSemanticTypeFromTextVariant,\n} from '../utils/utils';\n\nimport {\n TypographySize,\n TypographyTextVariant,\n TypographyWeight,\n TypographySpacing,\n} from '../types';\n\nimport './text.scss';\n\ntype TextBaseProps = {\n /** Visuell tekststørrelse (typografi-token) */\n size?: TypographySize;\n /** Fontvekt */\n weight?: TypographyWeight;\n /** Variant (kan brukes til spesielle typer tekst som for eksempel caption) */\n variant?: TypographyTextVariant;\n /** Innhold */\n children: React.ReactNode;\n /** Spacing around the component */\n spacing?: TypographySpacing;\n /** Ekstra klassenavn */\n className?: string;\n};\n\nexport type TextProps<C extends React.ElementType> = PolymorphicComponentProps<\n C,\n TextBaseProps\n>;\n\nconst TypographyText = <C extends React.ElementType = 'p'>({\n children,\n as,\n size,\n variant,\n weight,\n spacing,\n className,\n ...rest\n}: TextProps<C>) => {\n const BodyElement = as || getSemanticTypeFromTextVariant(variant);\n\n return (\n <BodyElement\n className={classNames(\n 'eds-text',\n variant && `eds-text--${variant}`,\n size && `eds-text--${size}`,\n weight && `eds-text--weight-${weight}`,\n getSpacingClasses(spacing, 'eds-text'),\n className,\n )}\n {...rest}\n >\n {children}\n </BodyElement>\n );\n};\n\n// Export as Text to avoid DOM conflicts\nexport const Text = TypographyText;\n"],"names":[],"mappings":";;;;AAwCA,MAAM,iBAAiB,CAAoC;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAoB;AAClB,QAAM,cAAc,MAAM,+BAA+B,OAAO;AAEhE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,WAAW,aAAa,OAAO;AAAA,QAC/B,QAAQ,aAAa,IAAI;AAAA,QACzB,UAAU,oBAAoB,MAAM;AAAA,QACpC,kBAAkB,SAAS,UAAU;AAAA,QACrC;AAAA,MAAA;AAAA,MAED,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EAAA;AAGP;AAGO,MAAM,OAAO;"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
--basecolors-frame-tint: #f6f6f9;
|
|
21
21
|
--basecolors-shape-accent: #181c56;
|
|
22
22
|
--basecolors-shape-bicycle-contrast: #00db9b;
|
|
23
|
-
--basecolors-shape-bicycle-default: #
|
|
23
|
+
--basecolors-shape-bicycle-default: #33826b;
|
|
24
24
|
--basecolors-shape-bus-contrast: #ff6392;
|
|
25
25
|
--basecolors-shape-bus-default: #c5044e;
|
|
26
26
|
--basecolors-shape-cableway-contrast: #b482fb;
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
--basecolors-shape-metro-contrast: #f08901;
|
|
41
41
|
--basecolors-shape-metro-default: #bf5826;
|
|
42
42
|
--basecolors-shape-mobility-contrast: #00db9b;
|
|
43
|
-
--basecolors-shape-mobility-default: #
|
|
43
|
+
--basecolors-shape-mobility-default: #33826b;
|
|
44
44
|
--basecolors-shape-plane-contrast: #fbafea;
|
|
45
45
|
--basecolors-shape-plane-default: #800664;
|
|
46
46
|
--basecolors-shape-subdued: #626493;
|
|
@@ -244,7 +244,7 @@ summary {
|
|
|
244
244
|
--basecolors-frame-tint: #f6f6f9;
|
|
245
245
|
--basecolors-shape-accent: #181c56;
|
|
246
246
|
--basecolors-shape-bicycle-contrast: #00db9b;
|
|
247
|
-
--basecolors-shape-bicycle-default: #
|
|
247
|
+
--basecolors-shape-bicycle-default: #33826b;
|
|
248
248
|
--basecolors-shape-bus-contrast: #ff6392;
|
|
249
249
|
--basecolors-shape-bus-default: #c5044e;
|
|
250
250
|
--basecolors-shape-cableway-contrast: #b482fb;
|
|
@@ -264,7 +264,7 @@ summary {
|
|
|
264
264
|
--basecolors-shape-metro-contrast: #f08901;
|
|
265
265
|
--basecolors-shape-metro-default: #bf5826;
|
|
266
266
|
--basecolors-shape-mobility-contrast: #00db9b;
|
|
267
|
-
--basecolors-shape-mobility-default: #
|
|
267
|
+
--basecolors-shape-mobility-default: #33826b;
|
|
268
268
|
--basecolors-shape-plane-contrast: #fbafea;
|
|
269
269
|
--basecolors-shape-plane-default: #800664;
|
|
270
270
|
--basecolors-shape-subdued: #626493;
|
package/dist/styles.css
CHANGED
|
@@ -198,7 +198,7 @@ summary {
|
|
|
198
198
|
--basecolors-frame-tint: #f6f6f9;
|
|
199
199
|
--basecolors-shape-accent: #181c56;
|
|
200
200
|
--basecolors-shape-bicycle-contrast: #00db9b;
|
|
201
|
-
--basecolors-shape-bicycle-default: #
|
|
201
|
+
--basecolors-shape-bicycle-default: #33826b;
|
|
202
202
|
--basecolors-shape-bus-contrast: #ff6392;
|
|
203
203
|
--basecolors-shape-bus-default: #c5044e;
|
|
204
204
|
--basecolors-shape-cableway-contrast: #b482fb;
|
|
@@ -218,7 +218,7 @@ summary {
|
|
|
218
218
|
--basecolors-shape-metro-contrast: #f08901;
|
|
219
219
|
--basecolors-shape-metro-default: #bf5826;
|
|
220
220
|
--basecolors-shape-mobility-contrast: #00db9b;
|
|
221
|
-
--basecolors-shape-mobility-default: #
|
|
221
|
+
--basecolors-shape-mobility-default: #33826b;
|
|
222
222
|
--basecolors-shape-plane-contrast: #fbafea;
|
|
223
223
|
--basecolors-shape-plane-default: #800664;
|
|
224
224
|
--basecolors-shape-subdued: #626493;
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/typography",
|
|
3
|
-
"version": "2.0.0",
|
|
3
|
+
"version": "2.0.2-beta.0",
|
|
4
4
|
"license": "SEE LICENSE IN README.md",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"main": "./dist/typography.cjs.js",
|
|
7
6
|
"module": "./dist/typography.esm.js",
|
|
8
7
|
"types": "./dist/index.d.ts",
|
|
9
8
|
"bin": {
|
|
10
|
-
"migrate": "scripts/migrate-typography.
|
|
9
|
+
"migrate": "scripts/migrate-typography.mjs"
|
|
11
10
|
},
|
|
12
11
|
"exports": {
|
|
13
12
|
".": {
|
|
@@ -55,15 +54,15 @@
|
|
|
55
54
|
"lint": "eslint src",
|
|
56
55
|
"start": "vite build --config vite.config.main.ts --watch",
|
|
57
56
|
"start:beta": "vite build --config vite.config.beta.ts --watch",
|
|
58
|
-
"migrate": "./scripts/migrate-typography.
|
|
57
|
+
"migrate": "./scripts/migrate-typography.mjs"
|
|
59
58
|
},
|
|
60
59
|
"peerDependencies": {
|
|
61
60
|
"react": ">=16.8.0",
|
|
62
61
|
"react-dom": ">=16.8.0"
|
|
63
62
|
},
|
|
64
63
|
"dependencies": {
|
|
65
|
-
"@entur/icons": "^8.0
|
|
66
|
-
"@entur/tokens": "^3.
|
|
64
|
+
"@entur/icons": "^8.1.0",
|
|
65
|
+
"@entur/tokens": "^3.20.0",
|
|
67
66
|
"@entur/utils": "^0.12.5",
|
|
68
67
|
"classnames": "^2.5.1",
|
|
69
68
|
"modern-normalize": "^3.0.1"
|
|
@@ -84,5 +83,5 @@
|
|
|
84
83
|
"vite": "^7.1.3",
|
|
85
84
|
"vite-plugin-dts": "^4.5.4"
|
|
86
85
|
},
|
|
87
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "4b9f4e324e6efef2fd56407909a5da32bcdf7662"
|
|
88
87
|
}
|
|
@@ -799,14 +799,20 @@ function updateComponents(content) {
|
|
|
799
799
|
let warnings = [];
|
|
800
800
|
|
|
801
801
|
Object.entries(COMPONENT_MAPPING).forEach(([oldComponent, mapping]) => {
|
|
802
|
-
// More robust regex to handle complex JSX
|
|
803
|
-
const componentRegex = new RegExp(
|
|
802
|
+
// More robust regex to handle complex JSX including self-closing tags
|
|
803
|
+
const componentRegex = new RegExp(
|
|
804
|
+
`<${oldComponent}(\\s+[^>]*?)?(?:/>|>)`,
|
|
805
|
+
'g',
|
|
806
|
+
);
|
|
804
807
|
|
|
805
808
|
updatedContent = updatedContent.replace(
|
|
806
809
|
componentRegex,
|
|
807
810
|
(match, propsString) => {
|
|
808
811
|
changes++;
|
|
809
812
|
|
|
813
|
+
// Check if this is a self-closing tag
|
|
814
|
+
const isSelfClosing = match.endsWith('/>');
|
|
815
|
+
|
|
810
816
|
// Parse existing props
|
|
811
817
|
const {
|
|
812
818
|
props: existingProps,
|
|
@@ -862,7 +868,8 @@ function updateComponents(content) {
|
|
|
862
868
|
);
|
|
863
869
|
const spreadPropsString =
|
|
864
870
|
spreadProps.length > 0 ? ` {...${spreadProps.join(', ...')}}` : '';
|
|
865
|
-
|
|
871
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
872
|
+
return `<Heading${propsString}${spreadPropsString}${closingTag}`;
|
|
866
873
|
}
|
|
867
874
|
|
|
868
875
|
// Handle Label components with special case for htmlFor prop
|
|
@@ -892,7 +899,8 @@ function updateComponents(content) {
|
|
|
892
899
|
|
|
893
900
|
// Only add as prop if it has a value
|
|
894
901
|
const asProp = asValue ? ` as="${asValue}"` : '';
|
|
895
|
-
|
|
902
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
903
|
+
return `<Text${asProp} variant="${variantValue}"${propsString}${spreadPropsString}${closingTag}`;
|
|
896
904
|
}
|
|
897
905
|
|
|
898
906
|
// Handle other components
|
|
@@ -917,11 +925,12 @@ function updateComponents(content) {
|
|
|
917
925
|
const otherPropsString = propsToString(finalProps, originalSyntax);
|
|
918
926
|
const spreadPropsString =
|
|
919
927
|
spreadProps.length > 0 ? ` {...${spreadProps.join(', ...')}}` : '';
|
|
920
|
-
|
|
928
|
+
const closingTag = isSelfClosing ? '/>' : '>';
|
|
929
|
+
return `<${componentName}${otherPropsString}${spreadPropsString}${closingTag}`;
|
|
921
930
|
},
|
|
922
931
|
);
|
|
923
932
|
|
|
924
|
-
// Update closing tags
|
|
933
|
+
// Update closing tags (only for non-self-closing tags)
|
|
925
934
|
const closingTagRegex = new RegExp(`</${oldComponent}>`, 'g');
|
|
926
935
|
const componentName = mapping.component;
|
|
927
936
|
updatedContent = updatedContent.replace(
|