@vinyasa/typography 1.0.24 → 1.0.25

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 (50) hide show
  1. package/README.md +77 -2
  2. package/dist/cjs/caption.cjs +76 -12
  3. package/dist/cjs/caption.css +90 -0
  4. package/dist/cjs/heading.cjs +76 -12
  5. package/dist/cjs/heading.css +90 -0
  6. package/dist/cjs/highlight.cjs +700 -0
  7. package/dist/cjs/highlight.css +197 -0
  8. package/dist/cjs/index.cjs +583 -14
  9. package/dist/cjs/index.css +158 -0
  10. package/dist/cjs/label.cjs +76 -12
  11. package/dist/cjs/label.css +90 -0
  12. package/dist/cjs/link.cjs +76 -12
  13. package/dist/cjs/link.css +90 -0
  14. package/dist/cjs/list.cjs +431 -0
  15. package/dist/cjs/list.css +60 -0
  16. package/dist/cjs/mark.cjs +246 -0
  17. package/dist/cjs/mark.css +8 -0
  18. package/dist/cjs/markdown-renderer.cjs +76 -12
  19. package/dist/cjs/markdown-renderer.css +90 -0
  20. package/dist/cjs/paragraph.cjs +76 -12
  21. package/dist/cjs/paragraph.css +90 -0
  22. package/dist/cjs/text.cjs +76 -12
  23. package/dist/cjs/text.css +90 -0
  24. package/dist/esm/191.css +90 -0
  25. package/dist/esm/191.js +67 -11
  26. package/dist/esm/227.css +7 -0
  27. package/dist/esm/227.js +39 -0
  28. package/dist/esm/513.css +60 -0
  29. package/dist/esm/513.js +126 -0
  30. package/dist/esm/767.js +33 -0
  31. package/dist/esm/components/highlight/Highlight.d.ts +14 -0
  32. package/dist/esm/components/highlight/index.d.ts +1 -0
  33. package/dist/esm/components/list/List.css.d.ts +47 -0
  34. package/dist/esm/components/list/List.d.ts +52 -0
  35. package/dist/esm/components/list/index.d.ts +1 -0
  36. package/dist/esm/components/mark/Mark.css.d.ts +1 -0
  37. package/dist/esm/components/mark/Mark.d.ts +5 -0
  38. package/dist/esm/components/mark/index.d.ts +1 -0
  39. package/dist/esm/components/text/Text.css.d.ts +85 -1
  40. package/dist/esm/components/text/Text.d.ts +55 -9
  41. package/dist/esm/highlight.d.ts +2 -0
  42. package/dist/esm/highlight.js +1 -0
  43. package/dist/esm/index.d.ts +4 -0
  44. package/dist/esm/index.js +26 -0
  45. package/dist/esm/list.d.ts +2 -0
  46. package/dist/esm/list.js +1 -0
  47. package/dist/esm/mark.d.ts +2 -0
  48. package/dist/esm/mark.js +1 -0
  49. package/dist/esm/useIsTruncated.d.ts +15 -0
  50. package/package.json +25 -5
@@ -0,0 +1,14 @@
1
+ import { type TextProps } from '../text/Text';
2
+ export type HighlightProps = Omit<TextProps, 'children'> & {
3
+ /** Plain text to search within. Rich `children` can't be reliably split and re-wrapped, so this only accepts a string, unlike Text's own `children`. */
4
+ children: string;
5
+ /** Substring(s) to wrap in a `Mark`, matched case-insensitively. */
6
+ highlight: string | string[];
7
+ };
8
+ declare const Highlight: import("react").ForwardRefExoticComponent<Omit<TextProps, "children"> & {
9
+ /** Plain text to search within. Rich `children` can't be reliably split and re-wrapped, so this only accepts a string, unlike Text's own `children`. */
10
+ children: string;
11
+ /** Substring(s) to wrap in a `Mark`, matched case-insensitively. */
12
+ highlight: string | string[];
13
+ } & import("react").RefAttributes<HTMLElement>>;
14
+ export default Highlight;
@@ -0,0 +1 @@
1
+ export { default, type HighlightProps } from './Highlight';
@@ -0,0 +1,47 @@
1
+ export declare const list: import("@vanilla-extract/recipes").RuntimeFn<{
2
+ spacing: {
3
+ 1: {
4
+ gap: `var(--${string})`;
5
+ };
6
+ 2: {
7
+ gap: `var(--${string})`;
8
+ };
9
+ 3: {
10
+ gap: `var(--${string})`;
11
+ };
12
+ 4: {
13
+ gap: `var(--${string})`;
14
+ };
15
+ 5: {
16
+ gap: `var(--${string})`;
17
+ };
18
+ 6: {
19
+ gap: `var(--${string})`;
20
+ };
21
+ };
22
+ withPadding: {
23
+ true: {
24
+ paddingLeft: `var(--${string})`;
25
+ };
26
+ false: {
27
+ paddingLeft: number;
28
+ listStyle: "none";
29
+ };
30
+ };
31
+ }>;
32
+ export declare const item: import("@vanilla-extract/recipes").RuntimeFn<{
33
+ withIcon: {
34
+ true: {
35
+ display: "flex";
36
+ alignItems: "flex-start";
37
+ gap: `var(--${string})`;
38
+ listStyle: "none";
39
+ };
40
+ };
41
+ center: {
42
+ true: {
43
+ alignItems: "center";
44
+ };
45
+ };
46
+ }>;
47
+ export declare const itemIcon: string;
@@ -0,0 +1,52 @@
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
2
+ import { type SpaceScale, type SpacingProps } from '../../spacing';
3
+ export type ListRootProps = Omit<ComponentPropsWithoutRef<'ul'>, 'type'> & SpacingProps & {
4
+ /** Renders `<ol>` instead of `<ul>`. */
5
+ type?: 'unordered' | 'ordered';
6
+ /** Gap between items, on the shared 1-6 space scale. */
7
+ spacing?: SpaceScale;
8
+ /**
9
+ * Keeps the browser's default list indent. On by default; turn off
10
+ * when every item supplies its own `icon`, which already replaces the
11
+ * native marker and its indent.
12
+ */
13
+ withPadding?: boolean;
14
+ /**
15
+ * Default icon rendered before every item's content, replacing the
16
+ * native bullet/number. Overridable per-item via `List.Item`'s own
17
+ * `icon`.
18
+ */
19
+ icon?: ReactNode;
20
+ /** Vertically centers each item's icon against its content instead of aligning both to the top. */
21
+ center?: boolean;
22
+ };
23
+ export type ListItemProps = ComponentPropsWithoutRef<'li'> & {
24
+ /** Overrides the list's own default `icon` for this item only. */
25
+ icon?: ReactNode;
26
+ };
27
+ declare const List: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref">, "type"> & SpacingProps & {
28
+ /** Renders `<ol>` instead of `<ul>`. */
29
+ type?: "unordered" | "ordered";
30
+ /** Gap between items, on the shared 1-6 space scale. */
31
+ spacing?: SpaceScale;
32
+ /**
33
+ * Keeps the browser's default list indent. On by default; turn off
34
+ * when every item supplies its own `icon`, which already replaces the
35
+ * native marker and its indent.
36
+ */
37
+ withPadding?: boolean;
38
+ /**
39
+ * Default icon rendered before every item's content, replacing the
40
+ * native bullet/number. Overridable per-item via `List.Item`'s own
41
+ * `icon`.
42
+ */
43
+ icon?: ReactNode;
44
+ /** Vertically centers each item's icon against its content instead of aligning both to the top. */
45
+ center?: boolean;
46
+ } & import("react").RefAttributes<HTMLOListElement | HTMLUListElement>> & {
47
+ Item: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
48
+ /** Overrides the list's own default `icon` for this item only. */
49
+ icon?: ReactNode;
50
+ } & import("react").RefAttributes<HTMLLIElement>>;
51
+ };
52
+ export default List;
@@ -0,0 +1 @@
1
+ export { default, type ListItemProps, type ListRootProps } from './List';
@@ -0,0 +1 @@
1
+ export declare const mark: string;
@@ -0,0 +1,5 @@
1
+ import { type ComponentPropsWithoutRef } from 'react';
2
+ import { type SpacingProps } from '../../spacing';
3
+ export type MarkProps = ComponentPropsWithoutRef<'mark'> & SpacingProps;
4
+ declare const Mark: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & SpacingProps & import("react").RefAttributes<HTMLElement>>;
5
+ export default Mark;
@@ -0,0 +1 @@
1
+ export { default, type MarkProps } from './Mark';
@@ -74,10 +74,94 @@ export declare const text: import("@vanilla-extract/recipes").RuntimeFn<{
74
74
  };
75
75
  };
76
76
  truncate: {
77
- true: {
77
+ end: {
78
+ display: "inline-block";
79
+ maxWidth: "100%";
80
+ overflow: "hidden";
81
+ textOverflow: "ellipsis";
82
+ whiteSpace: "nowrap";
83
+ };
84
+ start: {
85
+ display: "inline-block";
86
+ maxWidth: "100%";
78
87
  overflow: "hidden";
79
88
  textOverflow: "ellipsis";
80
89
  whiteSpace: "nowrap";
90
+ direction: "rtl";
91
+ textAlign: "left";
92
+ };
93
+ };
94
+ italic: {
95
+ true: {
96
+ fontStyle: "italic";
97
+ };
98
+ };
99
+ textTransform: {
100
+ uppercase: {
101
+ textTransform: "uppercase";
102
+ };
103
+ lowercase: {
104
+ textTransform: "lowercase";
105
+ };
106
+ capitalize: {
107
+ textTransform: "capitalize";
108
+ };
109
+ none: {
110
+ textTransform: "none";
111
+ };
112
+ };
113
+ decoration: {
114
+ underline: {
115
+ textDecoration: "underline";
116
+ };
117
+ 'line-through': {
118
+ textDecoration: "line-through";
119
+ };
120
+ none: {
121
+ textDecoration: "none";
122
+ };
123
+ };
124
+ letterSpacing: {
125
+ tight: {
126
+ letterSpacing: `var(--${string})`;
127
+ };
128
+ normal: {
129
+ letterSpacing: `var(--${string})`;
130
+ };
131
+ wide: {
132
+ letterSpacing: `var(--${string})`;
133
+ };
134
+ };
135
+ lineHeight: {
136
+ tight: {
137
+ lineHeight: `var(--${string})`;
138
+ };
139
+ normal: {
140
+ lineHeight: `var(--${string})`;
141
+ };
142
+ loose: {
143
+ lineHeight: `var(--${string})`;
144
+ };
145
+ };
146
+ textWrap: {
147
+ wrap: {
148
+ textWrap: "wrap";
149
+ };
150
+ balance: {
151
+ textWrap: "balance";
152
+ };
153
+ pretty: {
154
+ textWrap: "pretty";
155
+ };
156
+ nowrap: {
157
+ textWrap: "nowrap";
158
+ };
159
+ };
160
+ variant: {
161
+ gradient: {
162
+ backgroundClip: "text";
163
+ WebkitBackgroundClip: "text";
164
+ color: "transparent";
81
165
  };
82
166
  };
83
167
  }>;
@@ -2,13 +2,59 @@ import type { RecipeVariants } from '@vanilla-extract/recipes';
2
2
  import type { PolymorphicProps } from '../../polymorphic';
3
3
  import { type SpacingProps } from '../../spacing';
4
4
  import { text } from './Text.css';
5
- type TextVariants = RecipeVariants<typeof text>;
6
- export type TextProps = PolymorphicProps & TextVariants & SpacingProps;
7
- declare const Text: import("react").ForwardRefExoticComponent<PolymorphicProps & {
8
- size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | undefined;
9
- weight?: "medium" | "bold" | "regular" | "semibold" | undefined;
10
- align?: "left" | "right" | "center" | undefined;
11
- color?: "default" | "muted" | "primary" | "info" | "success" | "warning" | "error" | undefined;
12
- truncate?: boolean | undefined;
13
- } & SpacingProps & import("react").RefAttributes<HTMLElement>>;
5
+ type TextVariants = Omit<NonNullable<RecipeVariants<typeof text>>, 'truncate'>;
6
+ export type TextProps = PolymorphicProps & TextVariants & SpacingProps & {
7
+ /**
8
+ * Truncate to one line with an ellipsis. `true` (or `'end'`) clips the
9
+ * end; `'start'` clips the beginning instead e.g. a long file path
10
+ * where the filename at the end matters most.
11
+ */
12
+ truncate?: boolean | 'start' | 'end';
13
+ /**
14
+ * Clamp to this many lines with a trailing ellipsis instead of a
15
+ * single-line `truncate`. Takes precedence over `truncate` when both
16
+ * are set.
17
+ */
18
+ lineClamp?: number;
19
+ /**
20
+ * Skip Text's own font-size/weight/color/line-height and inherit them
21
+ * from the closest styled ancestor — for composing Text inside a
22
+ * heading or another Text where it should pick up the surrounding
23
+ * type instead of resetting to Text's own defaults.
24
+ */
25
+ inherit?: boolean;
26
+ /** Paints the text with a gradient instead of a solid `color`. Only applied when `variant="gradient"`. */
27
+ gradient?: {
28
+ from: string;
29
+ to: string;
30
+ deg?: number;
31
+ };
32
+ };
33
+ declare const Text: import("react").ForwardRefExoticComponent<PolymorphicProps & TextVariants & SpacingProps & {
34
+ /**
35
+ * Truncate to one line with an ellipsis. `true` (or `'end'`) clips the
36
+ * end; `'start'` clips the beginning instead — e.g. a long file path
37
+ * where the filename at the end matters most.
38
+ */
39
+ truncate?: boolean | "start" | "end";
40
+ /**
41
+ * Clamp to this many lines with a trailing ellipsis instead of a
42
+ * single-line `truncate`. Takes precedence over `truncate` when both
43
+ * are set.
44
+ */
45
+ lineClamp?: number;
46
+ /**
47
+ * Skip Text's own font-size/weight/color/line-height and inherit them
48
+ * from the closest styled ancestor — for composing Text inside a
49
+ * heading or another Text where it should pick up the surrounding
50
+ * type instead of resetting to Text's own defaults.
51
+ */
52
+ inherit?: boolean;
53
+ /** Paints the text with a gradient instead of a solid `color`. Only applied when `variant="gradient"`. */
54
+ gradient?: {
55
+ from: string;
56
+ to: string;
57
+ deg?: number;
58
+ };
59
+ } & import("react").RefAttributes<HTMLElement>>;
14
60
  export default Text;
@@ -0,0 +1,2 @@
1
+ export * from './components/highlight/index';
2
+ export { default } from './components/highlight/index';
@@ -0,0 +1 @@
1
+ export { Highlight as default } from "./767.js";
@@ -2,9 +2,13 @@ export { default as Blockquote, type BlockquoteProps } from './components/blockq
2
2
  export { default as Caption, type CaptionProps } from './components/caption';
3
3
  export { default as Code, type CodeProps } from './components/code';
4
4
  export { default as Heading, type HeadingLevel, type HeadingProps } from './components/heading';
5
+ export { default as Highlight, type HighlightProps } from './components/highlight';
5
6
  export { default as Kbd, type KbdProps } from './components/kbd';
6
7
  export { default as Label, type LabelProps } from './components/label';
7
8
  export { default as Link, type LinkProps } from './components/link';
9
+ export { default as List, type ListItemProps, type ListRootProps } from './components/list';
10
+ export { default as Mark, type MarkProps } from './components/mark';
8
11
  export { default as MarkdownRenderer, type MarkdownRendererProps, } from './components/markdown-renderer';
9
12
  export { default as Paragraph, type ParagraphProps } from './components/paragraph';
10
13
  export { default as Text, type TextProps } from './components/text';
14
+ export { useIsTruncated } from './useIsTruncated';
package/dist/esm/index.js CHANGED
@@ -1,10 +1,36 @@
1
+ import { useLayoutEffect, useRef, useState } from "react";
2
+ const checkOverflow = (element)=>element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
3
+ const useIsTruncated = (deps = [])=>{
4
+ const ref = useRef(null);
5
+ const [isTruncated, setIsTruncated] = useState(false);
6
+ useLayoutEffect(()=>{
7
+ const element = ref.current;
8
+ if (!element) return;
9
+ setIsTruncated(checkOverflow(element));
10
+ const observer = new ResizeObserver(()=>{
11
+ setIsTruncated(checkOverflow(element));
12
+ });
13
+ observer.observe(element);
14
+ return ()=>{
15
+ observer.disconnect();
16
+ };
17
+ }, deps);
18
+ return [
19
+ ref,
20
+ isTruncated
21
+ ];
22
+ };
1
23
  export { Blockquote } from "./783.js";
2
24
  export { Caption } from "./975.js";
3
25
  export { Code } from "./651.js";
4
26
  export { Heading } from "./63.js";
27
+ export { Highlight } from "./767.js";
5
28
  export { Kbd } from "./919.js";
6
29
  export { Label } from "./691.js";
7
30
  export { Link } from "./57.js";
31
+ export { List } from "./513.js";
32
+ export { Mark } from "./227.js";
8
33
  export { MarkdownRenderer } from "./654.js";
9
34
  export { Paragraph } from "./895.js";
10
35
  export { Text } from "./191.js";
36
+ export { useIsTruncated };
@@ -0,0 +1,2 @@
1
+ export * from './components/list/index';
2
+ export { default } from './components/list/index';
@@ -0,0 +1 @@
1
+ export { List as default } from "./513.js";
@@ -0,0 +1,2 @@
1
+ export * from './components/mark/index';
2
+ export { default } from './components/mark/index';
@@ -0,0 +1 @@
1
+ export { Mark as default } from "./227.js";
@@ -0,0 +1,15 @@
1
+ import { type DependencyList, type RefObject } from 'react';
2
+ /**
3
+ * Reports whether the element the returned ref is attached to currently
4
+ * overflows its own box — horizontally (Text's `truncate`) or vertically
5
+ * (Text's `lineClamp`) — so a caller can show a tooltip with the full
6
+ * content only when it's actually clipped, instead of on every hover.
7
+ *
8
+ * Re-checks whenever the element itself resizes (via `ResizeObserver`,
9
+ * covering the common "container got narrower/wider" case). A content
10
+ * change that doesn't also resize the element (e.g. a fixed-width truncated
11
+ * label whose text changes at runtime) won't retrigger the observer on its
12
+ * own — pass the changing value(s) in `deps` (e.g. `[children]`) to force a
13
+ * re-check for that case too.
14
+ */
15
+ export declare const useIsTruncated: <T extends HTMLElement>(deps?: DependencyList) => [RefObject<T | null>, boolean];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinyasa/typography",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -93,14 +93,34 @@
93
93
  "require": "./dist/cjs/markdown-renderer.cjs",
94
94
  "default": "./dist/esm/markdown-renderer.js"
95
95
  },
96
+ "./mark": {
97
+ "types": "./dist/esm/mark.d.ts",
98
+ "import": "./dist/esm/mark.js",
99
+ "require": "./dist/cjs/mark.cjs",
100
+ "default": "./dist/esm/mark.js"
101
+ },
102
+ "./mark/style.css": "./dist/esm/mark.css",
103
+ "./highlight": {
104
+ "types": "./dist/esm/highlight.d.ts",
105
+ "import": "./dist/esm/highlight.js",
106
+ "require": "./dist/cjs/highlight.cjs",
107
+ "default": "./dist/esm/highlight.js"
108
+ },
109
+ "./list": {
110
+ "types": "./dist/esm/list.d.ts",
111
+ "import": "./dist/esm/list.js",
112
+ "require": "./dist/cjs/list.cjs",
113
+ "default": "./dist/esm/list.js"
114
+ },
115
+ "./list/style.css": "./dist/esm/list.css",
96
116
  "./style.css": "./dist/esm/index.css",
97
117
  "./package.json": "./package.json"
98
118
  },
99
119
  "peerDependencies": {
100
120
  "react": "^18.0.0 || ^19.0.0",
101
121
  "react-dom": "^18.0.0 || ^19.0.0",
102
- "@vinyasa/layout": "^1.0.24",
103
- "@vinyasa/tokens": "^1.0.24"
122
+ "@vinyasa/tokens": "^1.0.25",
123
+ "@vinyasa/layout": "^1.0.25"
104
124
  },
105
125
  "dependencies": {
106
126
  "react-markdown": "^10.1.0"
@@ -116,8 +136,8 @@
116
136
  "@vanilla-extract/vite-plugin": "^5.2.3",
117
137
  "@vanilla-extract/webpack-plugin": "^2.3.27",
118
138
  "typescript": "^5.7.3",
119
- "@vinyasa/layout": "1.0.24",
120
- "@vinyasa/tokens": "1.0.24"
139
+ "@vinyasa/layout": "1.0.25",
140
+ "@vinyasa/tokens": "1.0.25"
121
141
  },
122
142
  "scripts": {
123
143
  "build": "rslib build && node ../../scripts/postbuild-package.mjs",