@hanzogui/text 2.0.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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/Emphasis.cjs +39 -0
  3. package/dist/cjs/Emphasis.native.js +42 -0
  4. package/dist/cjs/Emphasis.native.js.map +1 -0
  5. package/dist/cjs/Headings.cjs +125 -0
  6. package/dist/cjs/Headings.native.js +128 -0
  7. package/dist/cjs/Headings.native.js.map +1 -0
  8. package/dist/cjs/Paragraph.cjs +35 -0
  9. package/dist/cjs/Paragraph.native.js +38 -0
  10. package/dist/cjs/Paragraph.native.js.map +1 -0
  11. package/dist/cjs/SizableText.cjs +54 -0
  12. package/dist/cjs/SizableText.native.js +57 -0
  13. package/dist/cjs/SizableText.native.js.map +1 -0
  14. package/dist/cjs/index.cjs +23 -0
  15. package/dist/cjs/index.native.js +26 -0
  16. package/dist/cjs/index.native.js.map +1 -0
  17. package/dist/cjs/types.cjs +16 -0
  18. package/dist/cjs/types.native.js +19 -0
  19. package/dist/cjs/types.native.js.map +1 -0
  20. package/dist/cjs/wrapChildrenInText.cjs +65 -0
  21. package/dist/cjs/wrapChildrenInText.native.js +71 -0
  22. package/dist/cjs/wrapChildrenInText.native.js.map +1 -0
  23. package/dist/esm/Emphasis.mjs +14 -0
  24. package/dist/esm/Emphasis.mjs.map +1 -0
  25. package/dist/esm/Emphasis.native.js +14 -0
  26. package/dist/esm/Emphasis.native.js.map +1 -0
  27. package/dist/esm/Headings.mjs +96 -0
  28. package/dist/esm/Headings.mjs.map +1 -0
  29. package/dist/esm/Headings.native.js +96 -0
  30. package/dist/esm/Headings.native.js.map +1 -0
  31. package/dist/esm/Paragraph.mjs +12 -0
  32. package/dist/esm/Paragraph.mjs.map +1 -0
  33. package/dist/esm/Paragraph.native.js +12 -0
  34. package/dist/esm/Paragraph.native.js.map +1 -0
  35. package/dist/esm/SizableText.mjs +31 -0
  36. package/dist/esm/SizableText.mjs.map +1 -0
  37. package/dist/esm/SizableText.native.js +31 -0
  38. package/dist/esm/SizableText.native.js.map +1 -0
  39. package/dist/esm/index.js +7 -0
  40. package/dist/esm/index.js.map +1 -0
  41. package/dist/esm/index.mjs +7 -0
  42. package/dist/esm/index.mjs.map +1 -0
  43. package/dist/esm/index.native.js +7 -0
  44. package/dist/esm/index.native.js.map +1 -0
  45. package/dist/esm/types.mjs +2 -0
  46. package/dist/esm/types.mjs.map +1 -0
  47. package/dist/esm/types.native.js +2 -0
  48. package/dist/esm/types.native.js.map +1 -0
  49. package/dist/esm/wrapChildrenInText.mjs +32 -0
  50. package/dist/esm/wrapChildrenInText.mjs.map +1 -0
  51. package/dist/esm/wrapChildrenInText.native.js +34 -0
  52. package/dist/esm/wrapChildrenInText.native.js.map +1 -0
  53. package/dist/jsx/Emphasis.mjs +14 -0
  54. package/dist/jsx/Emphasis.mjs.map +1 -0
  55. package/dist/jsx/Emphasis.native.js +42 -0
  56. package/dist/jsx/Emphasis.native.js.map +1 -0
  57. package/dist/jsx/Headings.mjs +96 -0
  58. package/dist/jsx/Headings.mjs.map +1 -0
  59. package/dist/jsx/Headings.native.js +128 -0
  60. package/dist/jsx/Headings.native.js.map +1 -0
  61. package/dist/jsx/Paragraph.mjs +12 -0
  62. package/dist/jsx/Paragraph.mjs.map +1 -0
  63. package/dist/jsx/Paragraph.native.js +38 -0
  64. package/dist/jsx/Paragraph.native.js.map +1 -0
  65. package/dist/jsx/SizableText.mjs +31 -0
  66. package/dist/jsx/SizableText.mjs.map +1 -0
  67. package/dist/jsx/SizableText.native.js +57 -0
  68. package/dist/jsx/SizableText.native.js.map +1 -0
  69. package/dist/jsx/index.js +7 -0
  70. package/dist/jsx/index.js.map +1 -0
  71. package/dist/jsx/index.mjs +7 -0
  72. package/dist/jsx/index.mjs.map +1 -0
  73. package/dist/jsx/index.native.js +26 -0
  74. package/dist/jsx/index.native.js.map +1 -0
  75. package/dist/jsx/types.mjs +2 -0
  76. package/dist/jsx/types.mjs.map +1 -0
  77. package/dist/jsx/types.native.js +19 -0
  78. package/dist/jsx/types.native.js.map +1 -0
  79. package/dist/jsx/wrapChildrenInText.mjs +32 -0
  80. package/dist/jsx/wrapChildrenInText.mjs.map +1 -0
  81. package/dist/jsx/wrapChildrenInText.native.js +71 -0
  82. package/dist/jsx/wrapChildrenInText.native.js.map +1 -0
  83. package/package.json +52 -0
  84. package/src/Emphasis.tsx +15 -0
  85. package/src/Headings.tsx +117 -0
  86. package/src/Paragraph.tsx +15 -0
  87. package/src/SizableText.tsx +44 -0
  88. package/src/index.tsx +6 -0
  89. package/src/types.ts +19 -0
  90. package/src/wrapChildrenInText.tsx +62 -0
  91. package/types/Emphasis.d.ts +4 -0
  92. package/types/Headings.d.ts +31 -0
  93. package/types/Paragraph.d.ts +7 -0
  94. package/types/SizableText.d.ts +7 -0
  95. package/types/index.d.ts +7 -0
  96. package/types/types.d.ts +17 -0
  97. package/types/wrapChildrenInText.d.ts +12 -0
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@hanzogui/text",
3
+ "version": "2.0.0",
4
+ "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
+ "source": "src/index.tsx",
6
+ "files": [
7
+ "src",
8
+ "types",
9
+ "dist"
10
+ ],
11
+ "type": "module",
12
+ "sideEffects": [
13
+ "*.css"
14
+ ],
15
+ "main": "dist/cjs",
16
+ "module": "dist/esm",
17
+ "types": "./types/index.d.ts",
18
+ "exports": {
19
+ "./package.json": "./package.json",
20
+ ".": {
21
+ "types": "./types/index.d.ts",
22
+ "react-native": "./dist/esm/index.native.js",
23
+ "browser": "./dist/esm/index.mjs",
24
+ "module": "./dist/esm/index.mjs",
25
+ "import": "./dist/esm/index.mjs",
26
+ "require": "./dist/cjs/index.cjs",
27
+ "default": "./dist/esm/index.mjs"
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "hanzo-gui-build",
35
+ "watch": "hanzo-gui-build --watch",
36
+ "clean": "hanzo-gui-build clean",
37
+ "clean:build": "hanzo-gui-build clean:build"
38
+ },
39
+ "dependencies": {
40
+ "@hanzogui/get-font-sized": "2.0.0-rc.29",
41
+ "@hanzogui/helpers": "2.0.0-rc.29",
42
+ "@hanzogui/web": "2.0.0-rc.29"
43
+ },
44
+ "devDependencies": {
45
+ "@hanzogui/build": "2.0.0-rc.29",
46
+ "react": ">=19"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=19"
50
+ },
51
+ "module:jsx": "dist/jsx"
52
+ }
@@ -0,0 +1,15 @@
1
+ import { styled, Text } from '@hanzogui/web'
2
+
3
+ export const Strong = styled(Text, {
4
+ render: 'strong',
5
+ fontWeight: 'bold',
6
+ })
7
+
8
+ export const Span = styled(Text, {
9
+ render: 'span',
10
+ })
11
+
12
+ export const Em = styled(Text, {
13
+ render: 'em',
14
+ fontStyle: 'italic',
15
+ })
@@ -0,0 +1,117 @@
1
+ import type { GetProps } from '@hanzogui/web'
2
+ import { styled } from '@hanzogui/web'
3
+
4
+ import { Paragraph } from './Paragraph'
5
+
6
+ export const Heading = styled(Paragraph, {
7
+ render: 'span',
8
+ name: 'Heading',
9
+ role: 'heading',
10
+ fontFamily: '$heading',
11
+ size: '$8',
12
+ margin: 0,
13
+ })
14
+
15
+ export type HeadingProps = GetProps<typeof Heading>
16
+
17
+ export const H1 = styled(Heading, {
18
+ name: 'H1',
19
+ render: 'h1',
20
+
21
+ variants: {
22
+ unstyled: {
23
+ false: {
24
+ size: '$10',
25
+ },
26
+ },
27
+ } as const,
28
+
29
+ defaultVariants: {
30
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
31
+ },
32
+ })
33
+
34
+ export const H2 = styled(Heading, {
35
+ name: 'H2',
36
+ render: 'h2',
37
+
38
+ variants: {
39
+ unstyled: {
40
+ false: {
41
+ size: '$9',
42
+ },
43
+ },
44
+ } as const,
45
+
46
+ defaultVariants: {
47
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
48
+ },
49
+ })
50
+
51
+ export const H3 = styled(Heading, {
52
+ name: 'H3',
53
+ render: 'h3',
54
+
55
+ variants: {
56
+ unstyled: {
57
+ false: {
58
+ size: '$8',
59
+ },
60
+ },
61
+ } as const,
62
+
63
+ defaultVariants: {
64
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
65
+ },
66
+ })
67
+
68
+ export const H4 = styled(Heading, {
69
+ name: 'H4',
70
+ render: 'h4',
71
+
72
+ variants: {
73
+ unstyled: {
74
+ false: {
75
+ size: '$7',
76
+ },
77
+ },
78
+ } as const,
79
+
80
+ defaultVariants: {
81
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
82
+ },
83
+ })
84
+
85
+ export const H5 = styled(Heading, {
86
+ name: 'H5',
87
+ render: 'h5',
88
+
89
+ variants: {
90
+ unstyled: {
91
+ false: {
92
+ size: '$6',
93
+ },
94
+ },
95
+ } as const,
96
+
97
+ defaultVariants: {
98
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
99
+ },
100
+ })
101
+
102
+ export const H6 = styled(Heading, {
103
+ name: 'H6',
104
+ render: 'h6',
105
+
106
+ variants: {
107
+ unstyled: {
108
+ false: {
109
+ size: '$5',
110
+ },
111
+ },
112
+ } as const,
113
+
114
+ defaultVariants: {
115
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1' ? true : false,
116
+ },
117
+ })
@@ -0,0 +1,15 @@
1
+ import type { GetProps } from '@hanzogui/web'
2
+ import { styled } from '@hanzogui/web'
3
+
4
+ import { SizableText } from './SizableText'
5
+
6
+ export const Paragraph = styled(SizableText, {
7
+ name: 'Paragraph',
8
+ render: 'p',
9
+ userSelect: 'auto',
10
+ color: '$color',
11
+ size: '$true',
12
+ whiteSpace: 'normal',
13
+ })
14
+
15
+ export type ParagraphProps = GetProps<typeof Paragraph>
@@ -0,0 +1,44 @@
1
+ import { getFontSized } from '@hanzogui/get-font-sized'
2
+ import type { GetProps } from '@hanzogui/web'
3
+ import { Text, styled } from '@hanzogui/web'
4
+
5
+ export const SizableText = styled(Text, {
6
+ name: 'SizableText',
7
+ fontFamily: '$body',
8
+
9
+ variants: {
10
+ unstyled: {
11
+ false: {
12
+ size: '$true',
13
+ color: '$color',
14
+ },
15
+ },
16
+
17
+ size: getFontSized,
18
+ },
19
+
20
+ defaultVariants: {
21
+ unstyled: process.env.HANZO_GUI_HEADLESS === '1',
22
+ },
23
+ })
24
+
25
+ // we are doing weird stuff to avoid bad types
26
+ // TODO make this just work
27
+ SizableText.staticConfig.variants!.fontFamily = {
28
+ '...': (val, extras) => {
29
+ // pass through inherit directly without font variant expansion
30
+ if (val === 'inherit') {
31
+ return { fontFamily: 'inherit' }
32
+ }
33
+
34
+ const sizeProp = extras.props['size']
35
+ const fontSizeProp = extras.props['fontSize']
36
+ const size =
37
+ sizeProp === '$true' && fontSizeProp
38
+ ? fontSizeProp
39
+ : extras.props['size'] || '$true'
40
+ return getFontSized(size, extras)
41
+ },
42
+ }
43
+
44
+ export type SizableTextProps = GetProps<typeof SizableText>
package/src/index.tsx ADDED
@@ -0,0 +1,6 @@
1
+ export * from './Emphasis'
2
+ export * from './SizableText'
3
+ export * from './Paragraph'
4
+ export * from './Headings'
5
+ export * from './wrapChildrenInText'
6
+ export * from './types'
package/src/types.ts ADDED
@@ -0,0 +1,19 @@
1
+ import type { SizableTextProps } from './SizableText'
2
+
3
+ export type TextContextStyles = {
4
+ color?: SizableTextProps['color']
5
+ fontWeight?: SizableTextProps['fontWeight']
6
+ fontSize?: SizableTextProps['fontSize']
7
+ fontFamily?: SizableTextProps['fontFamily']
8
+ fontStyle?: SizableTextProps['fontStyle']
9
+ letterSpacing?: SizableTextProps['letterSpacing']
10
+ textAlign?: SizableTextProps['textAlign']
11
+ ellipsis?: SizableTextProps['ellipsis']
12
+ maxFontSizeMultiplier?: number
13
+ }
14
+
15
+ export type TextParentStyles = TextContextStyles & {
16
+ // all the other text controls
17
+ textProps?: Partial<SizableTextProps>
18
+ noTextWrap?: boolean
19
+ }
@@ -0,0 +1,62 @@
1
+ import type { SizeTokens } from '@hanzogui/web'
2
+ import React from 'react'
3
+
4
+ import type { TextParentStyles } from './types'
5
+
6
+ type Props = TextParentStyles & {
7
+ children?: React.ReactNode
8
+ size?: SizeTokens
9
+ }
10
+
11
+ export function wrapChildrenInText(
12
+ TextComponent: any,
13
+ propsIn: Props & {
14
+ unstyled?: boolean
15
+ },
16
+ extraProps?: Record<string, any>
17
+ ) {
18
+ const {
19
+ children,
20
+ textProps,
21
+ size,
22
+ noTextWrap,
23
+ color,
24
+ fontFamily,
25
+ fontSize,
26
+ fontWeight,
27
+ letterSpacing,
28
+ textAlign,
29
+ fontStyle,
30
+ maxFontSizeMultiplier,
31
+ } = propsIn
32
+
33
+ if (noTextWrap || !children) {
34
+ return [children]
35
+ }
36
+
37
+ const props = {
38
+ ...extraProps,
39
+ }
40
+
41
+ // to avoid setting undefined
42
+ if (color) props.color = color
43
+ if (fontFamily) props.fontFamily = fontFamily
44
+ if (fontSize) props.fontSize = fontSize
45
+ if (fontWeight) props.fontWeight = fontWeight
46
+ if (letterSpacing) props.letterSpacing = letterSpacing
47
+ if (textAlign) props.textAlign = textAlign
48
+ if (size) props.size = size
49
+ if (fontStyle) props.fontStyle = fontStyle
50
+ if (maxFontSizeMultiplier) props.maxFontSizeMultiplier = maxFontSizeMultiplier
51
+
52
+ return React.Children.toArray(children).map((child, index) => {
53
+ return typeof child === 'string' ? (
54
+ // so "data-disable-theme" is a hack to fix themeInverse, don't ask me why
55
+ <TextComponent key={index} {...props} {...textProps}>
56
+ {child}
57
+ </TextComponent>
58
+ ) : (
59
+ child
60
+ )
61
+ })
62
+ }
@@ -0,0 +1,4 @@
1
+ export declare const Strong: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {}, import("@gui/web").StaticConfigPublic>;
2
+ export declare const Span: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {}, import("@gui/web").StaticConfigPublic>;
3
+ export declare const Em: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {}, import("@gui/web").StaticConfigPublic>;
4
+ //# sourceMappingURL=Emphasis.d.ts.map
@@ -0,0 +1,31 @@
1
+ import type { GetProps } from '@gui/web';
2
+ export declare const Heading: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
3
+ unstyled?: boolean | undefined;
4
+ size?: import("@gui/web").FontSizeTokens | undefined;
5
+ }, import("@gui/web").StaticConfigPublic>;
6
+ export type HeadingProps = GetProps<typeof Heading>;
7
+ export declare const H1: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
8
+ unstyled?: boolean | undefined;
9
+ size?: import("@gui/web").FontSizeTokens | undefined;
10
+ }, import("@gui/web").StaticConfigPublic>;
11
+ export declare const H2: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
12
+ unstyled?: boolean | undefined;
13
+ size?: import("@gui/web").FontSizeTokens | undefined;
14
+ }, import("@gui/web").StaticConfigPublic>;
15
+ export declare const H3: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
16
+ unstyled?: boolean | undefined;
17
+ size?: import("@gui/web").FontSizeTokens | undefined;
18
+ }, import("@gui/web").StaticConfigPublic>;
19
+ export declare const H4: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
20
+ unstyled?: boolean | undefined;
21
+ size?: import("@gui/web").FontSizeTokens | undefined;
22
+ }, import("@gui/web").StaticConfigPublic>;
23
+ export declare const H5: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
24
+ unstyled?: boolean | undefined;
25
+ size?: import("@gui/web").FontSizeTokens | undefined;
26
+ }, import("@gui/web").StaticConfigPublic>;
27
+ export declare const H6: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
28
+ unstyled?: boolean | undefined;
29
+ size?: import("@gui/web").FontSizeTokens | undefined;
30
+ }, import("@gui/web").StaticConfigPublic>;
31
+ //# sourceMappingURL=Headings.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { GetProps } from '@gui/web';
2
+ export declare const Paragraph: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
3
+ unstyled?: boolean | undefined;
4
+ size?: import("@gui/web").FontSizeTokens | undefined;
5
+ }, import("@gui/web").StaticConfigPublic>;
6
+ export type ParagraphProps = GetProps<typeof Paragraph>;
7
+ //# sourceMappingURL=Paragraph.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { GetProps } from '@gui/web';
2
+ export declare const SizableText: import("@gui/web").GuiComponent<import("@gui/web").TamaDefer, import("@gui/web").GuiTextElement, import("@gui/web").TextNonStyleProps, import("@gui/web").TextStylePropsBase, {
3
+ unstyled?: boolean | undefined;
4
+ size?: import("@gui/web").FontSizeTokens | undefined;
5
+ }, import("@gui/web").StaticConfigPublic>;
6
+ export type SizableTextProps = GetProps<typeof SizableText>;
7
+ //# sourceMappingURL=SizableText.d.ts.map
@@ -0,0 +1,7 @@
1
+ export * from './Emphasis';
2
+ export * from './SizableText';
3
+ export * from './Paragraph';
4
+ export * from './Headings';
5
+ export * from './wrapChildrenInText';
6
+ export * from './types';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { SizableTextProps } from './SizableText';
2
+ export type TextContextStyles = {
3
+ color?: SizableTextProps['color'];
4
+ fontWeight?: SizableTextProps['fontWeight'];
5
+ fontSize?: SizableTextProps['fontSize'];
6
+ fontFamily?: SizableTextProps['fontFamily'];
7
+ fontStyle?: SizableTextProps['fontStyle'];
8
+ letterSpacing?: SizableTextProps['letterSpacing'];
9
+ textAlign?: SizableTextProps['textAlign'];
10
+ ellipsis?: SizableTextProps['ellipsis'];
11
+ maxFontSizeMultiplier?: number;
12
+ };
13
+ export type TextParentStyles = TextContextStyles & {
14
+ textProps?: Partial<SizableTextProps>;
15
+ noTextWrap?: boolean;
16
+ };
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { SizeTokens } from '@gui/web';
2
+ import React from 'react';
3
+ import type { TextParentStyles } from './types';
4
+ type Props = TextParentStyles & {
5
+ children?: React.ReactNode;
6
+ size?: SizeTokens;
7
+ };
8
+ export declare function wrapChildrenInText(TextComponent: any, propsIn: Props & {
9
+ unstyled?: boolean;
10
+ }, extraProps?: Record<string, any>): React.ReactNode[] | (number | bigint | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element)[];
11
+ export {};
12
+ //# sourceMappingURL=wrapChildrenInText.d.ts.map