@orvain/utils 0.0.0-stage โ†’ 0.1.1

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 (51) hide show
  1. package/LICENSE +64 -0
  2. package/README.md +48 -2
  3. package/dist/a11y.d.cts +102 -0
  4. package/dist/a11y.d.ts +103 -0
  5. package/dist/breakpoints.d.cts +36 -0
  6. package/dist/breakpoints.d.ts +37 -0
  7. package/dist/calendar.d.cts +127 -0
  8. package/dist/calendar.d.ts +128 -0
  9. package/dist/chart/color.d.cts +72 -0
  10. package/dist/chart/color.d.ts +73 -0
  11. package/dist/chart/index.d.cts +2 -0
  12. package/dist/chart/index.d.ts +3 -0
  13. package/dist/chart/math.d.cts +66 -0
  14. package/dist/chart/math.d.ts +67 -0
  15. package/dist/chart-items/index.d.cts +64 -0
  16. package/dist/chart-items/index.d.ts +65 -0
  17. package/dist/codeTokenizer.d.cts +29 -0
  18. package/dist/codeTokenizer.d.ts +30 -0
  19. package/dist/cssModule.d.cts +12 -0
  20. package/dist/cssModule.d.ts +13 -0
  21. package/dist/dismiss.d.cts +40 -0
  22. package/dist/dismiss.d.ts +41 -0
  23. package/dist/floating.d.cts +137 -0
  24. package/dist/floating.d.ts +138 -0
  25. package/dist/formField.d.cts +58 -0
  26. package/dist/formField.d.ts +59 -0
  27. package/dist/helpers.d.cts +17 -0
  28. package/dist/helpers.d.ts +18 -0
  29. package/dist/index.cjs +11 -0
  30. package/dist/index.d.cts +17 -0
  31. package/dist/index.d.ts +18 -0
  32. package/dist/index.js +2819 -0
  33. package/dist/kanbanDnd.d.cts +71 -0
  34. package/dist/kanbanDnd.d.ts +72 -0
  35. package/dist/listNavigation.d.cts +36 -0
  36. package/dist/listNavigation.d.ts +37 -0
  37. package/dist/richText/blockquote.d.cts +11 -0
  38. package/dist/richText/blockquote.d.ts +12 -0
  39. package/dist/richText/editor.d.cts +117 -0
  40. package/dist/richText/editor.d.ts +118 -0
  41. package/dist/richText/index.d.cts +3 -0
  42. package/dist/richText/index.d.ts +4 -0
  43. package/dist/richText/model.d.cts +161 -0
  44. package/dist/richText/model.d.ts +162 -0
  45. package/dist/slider.d.cts +18 -0
  46. package/dist/slider.d.ts +19 -0
  47. package/dist/tree.d.cts +78 -0
  48. package/dist/tree.d.ts +79 -0
  49. package/dist/types.d.cts +22 -0
  50. package/dist/types.d.ts +23 -0
  51. package/package.json +56 -3
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Chart colour palette shared by every chart part, chart item and composed
3
+ * chart (React + Vue). Figma draws 8 series colours on the Key-Value and Chart
4
+ * pages ("Chart Legend Dots v2", "Bar Chart Item v2", โ€ฆ):
5
+ *
6
+ * | ChartColor | Figma name | Fill |
7
+ * |------------|-------------------------------|---------|
8
+ * | `neutral` | ๐Ÿฉถ Neutral / ๐Ÿค Light Gray | #F2F2F2 |
9
+ * | `grey` | ๐Ÿ–ค Grey / ๐Ÿฉถ Gray | #2A2A2A |
10
+ * | `blue` | ๐Ÿ’™ Brand / ๐Ÿ’™ Blue | #005CF8 |
11
+ * | `purple` | ๐Ÿ’œ Brand / ๐Ÿ’œ Purple | #9B49DD |
12
+ * | `yellow` | ๐Ÿ’› Yellow | #FDDA2A |
13
+ * | `orange` | ๐Ÿงก Orange | #FF9000 |
14
+ * | `green` | ๐Ÿ’š Green | #2ED714 |
15
+ * | `red` | โค๏ธ Red / ๐Ÿ’” Red | #EC0D33 |
16
+ *
17
+ * The values live in `packages/tokens/src/chart.json` (`--orvain-chart-*`).
18
+ * Some parts draw another shade of the same series colour (the v1 legend dot
19
+ * uses #4C4C4C for grey and #229A14 for green; the legend bar uses #CBCBCB for
20
+ * neutral), so each colour has three roles: `fill`, `dot` and `line`.
21
+ */
22
+ export type ChartColor = 'neutral' | 'grey' | 'blue' | 'purple' | 'yellow' | 'orange' | 'green' | 'red';
23
+ /** Every `ChartColor`, in Figma's variant order. */
24
+ export declare const CHART_COLORS: readonly ChartColor[];
25
+ /**
26
+ * Which shade of a series colour a part paints.
27
+ * - `fill`: bars, areas, donut segments, v2 legend swatches (Figma "Surface/Base").
28
+ * - `dot`: the v1 legend dot and the ForceTip dot.
29
+ * - `line`: the legend bar (Chart Legend Border).
30
+ */
31
+ export type ChartColorRole = 'fill' | 'dot' | 'line' | 'accent' | 'soft';
32
+ /**
33
+ * Extra shades the Chart page draws besides the 8 series colours (Donut v1/v2
34
+ * blues, Bar Chart Item v2 accents, Donut v4 rings, the dark green of stacked
35
+ * and grouped bars). Each one has the same token roles as a `ChartColor`.
36
+ *
37
+ * | ChartShade | Fill |
38
+ * |----------------|---------|
39
+ * | `blue-light` | #3582FF |
40
+ * | `blue-lighter` | #A6C5FF |
41
+ * | `blue-dark` | #0042B7 |
42
+ * | `yellow-light` | #FCE262 |
43
+ * | `orange-light` | #FFBE71 |
44
+ * | `green-dark` | #229A14 |
45
+ * | `green-darker` | #186112 |
46
+ */
47
+ export type ChartShade = 'blue-light' | 'blue-lighter' | 'blue-dark' | 'yellow-light' | 'orange-light' | 'green-dark' | 'green-darker';
48
+ /** Every `ChartShade`. */
49
+ export declare const CHART_SHADES: readonly ChartShade[];
50
+ /** Any paint a chart accepts: a series `ChartColor` or one of its `ChartShade`s. */
51
+ export type ChartFill = ChartColor | ChartShade;
52
+ /** Figma "Theme" of chart fills: Solid, Ghost 20% or Ghost 8% opacity. */
53
+ export type ChartTheme = 'solid' | 'ghost20' | 'ghost8';
54
+ /** CSS custom property holding a chart colour, e.g. `var(--orvain-chart-fill-blue)`. */
55
+ export declare function chartColorVar(color: ChartFill, role?: ChartColorRole): string;
56
+ /**
57
+ * Text colour for a series hue (tinted captions). Hues whose dot colour is too
58
+ * light for 4.5:1 text have a darker `--orvain-chart-caption-*` token; the
59
+ * others fall back to the dot colour.
60
+ */
61
+ export declare function chartCaptionColorVar(color: ChartFill): string;
62
+ /** Opacity of a chart fill for a Figma theme (Solid 1, Ghost 20% 0.2, Ghost 8% 0.08). */
63
+ export declare function chartThemeOpacity(theme?: ChartTheme): number;
64
+ /** Colour for the n-th series when the data doesn't set one (cycles the palette, skipping `neutral`). */
65
+ export declare function chartSeriesColor(index: number): ChartColor;
66
+ /**
67
+ * CSS custom properties for one series colour, read by the chart items:
68
+ * `--chart-color` (fill), `--chart-color-subtle` (accent edge) and
69
+ * `--chart-color-soft` (area gradient / line nodes), each a `--orvain-chart-*`
70
+ * token.
71
+ */
72
+ export declare function chartFillVars(color: ChartFill, prefix?: string): Record<string, string>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Chart colour palette shared by every chart part, chart item and composed
3
+ * chart (React + Vue). Figma draws 8 series colours on the Key-Value and Chart
4
+ * pages ("Chart Legend Dots v2", "Bar Chart Item v2", โ€ฆ):
5
+ *
6
+ * | ChartColor | Figma name | Fill |
7
+ * |------------|-------------------------------|---------|
8
+ * | `neutral` | ๐Ÿฉถ Neutral / ๐Ÿค Light Gray | #F2F2F2 |
9
+ * | `grey` | ๐Ÿ–ค Grey / ๐Ÿฉถ Gray | #2A2A2A |
10
+ * | `blue` | ๐Ÿ’™ Brand / ๐Ÿ’™ Blue | #005CF8 |
11
+ * | `purple` | ๐Ÿ’œ Brand / ๐Ÿ’œ Purple | #9B49DD |
12
+ * | `yellow` | ๐Ÿ’› Yellow | #FDDA2A |
13
+ * | `orange` | ๐Ÿงก Orange | #FF9000 |
14
+ * | `green` | ๐Ÿ’š Green | #2ED714 |
15
+ * | `red` | โค๏ธ Red / ๐Ÿ’” Red | #EC0D33 |
16
+ *
17
+ * The values live in `packages/tokens/src/chart.json` (`--orvain-chart-*`).
18
+ * Some parts draw another shade of the same series colour (the v1 legend dot
19
+ * uses #4C4C4C for grey and #229A14 for green; the legend bar uses #CBCBCB for
20
+ * neutral), so each colour has three roles: `fill`, `dot` and `line`.
21
+ */
22
+ export type ChartColor = 'neutral' | 'grey' | 'blue' | 'purple' | 'yellow' | 'orange' | 'green' | 'red';
23
+ /** Every `ChartColor`, in Figma's variant order. */
24
+ export declare const CHART_COLORS: readonly ChartColor[];
25
+ /**
26
+ * Which shade of a series colour a part paints.
27
+ * - `fill`: bars, areas, donut segments, v2 legend swatches (Figma "Surface/Base").
28
+ * - `dot`: the v1 legend dot and the ForceTip dot.
29
+ * - `line`: the legend bar (Chart Legend Border).
30
+ */
31
+ export type ChartColorRole = 'fill' | 'dot' | 'line' | 'accent' | 'soft';
32
+ /**
33
+ * Extra shades the Chart page draws besides the 8 series colours (Donut v1/v2
34
+ * blues, Bar Chart Item v2 accents, Donut v4 rings, the dark green of stacked
35
+ * and grouped bars). Each one has the same token roles as a `ChartColor`.
36
+ *
37
+ * | ChartShade | Fill |
38
+ * |----------------|---------|
39
+ * | `blue-light` | #3582FF |
40
+ * | `blue-lighter` | #A6C5FF |
41
+ * | `blue-dark` | #0042B7 |
42
+ * | `yellow-light` | #FCE262 |
43
+ * | `orange-light` | #FFBE71 |
44
+ * | `green-dark` | #229A14 |
45
+ * | `green-darker` | #186112 |
46
+ */
47
+ export type ChartShade = 'blue-light' | 'blue-lighter' | 'blue-dark' | 'yellow-light' | 'orange-light' | 'green-dark' | 'green-darker';
48
+ /** Every `ChartShade`. */
49
+ export declare const CHART_SHADES: readonly ChartShade[];
50
+ /** Any paint a chart accepts: a series `ChartColor` or one of its `ChartShade`s. */
51
+ export type ChartFill = ChartColor | ChartShade;
52
+ /** Figma "Theme" of chart fills: Solid, Ghost 20% or Ghost 8% opacity. */
53
+ export type ChartTheme = 'solid' | 'ghost20' | 'ghost8';
54
+ /** CSS custom property holding a chart colour, e.g. `var(--orvain-chart-fill-blue)`. */
55
+ export declare function chartColorVar(color: ChartFill, role?: ChartColorRole): string;
56
+ /**
57
+ * Text colour for a series hue (tinted captions). Hues whose dot colour is too
58
+ * light for 4.5:1 text have a darker `--orvain-chart-caption-*` token; the
59
+ * others fall back to the dot colour.
60
+ */
61
+ export declare function chartCaptionColorVar(color: ChartFill): string;
62
+ /** Opacity of a chart fill for a Figma theme (Solid 1, Ghost 20% 0.2, Ghost 8% 0.08). */
63
+ export declare function chartThemeOpacity(theme?: ChartTheme): number;
64
+ /** Colour for the n-th series when the data doesn't set one (cycles the palette, skipping `neutral`). */
65
+ export declare function chartSeriesColor(index: number): ChartColor;
66
+ /**
67
+ * CSS custom properties for one series colour, read by the chart items:
68
+ * `--chart-color` (fill), `--chart-color-subtle` (accent edge) and
69
+ * `--chart-color-soft` (area gradient / line nodes), each a `--orvain-chart-*`
70
+ * token.
71
+ */
72
+ export declare function chartFillVars(color: ChartFill, prefix?: string): Record<string, string>;
73
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './color.cjs';
2
+ export * from './math.cjs';
@@ -0,0 +1,3 @@
1
+ export * from './color.js';
2
+ export * from './math.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Small, dependency-free maths for SVG/CSS charts (no chart library). Shared
3
+ * by the React and Vue chart components.
4
+ */
5
+ import type { ChartColor } from './color.cjs';
6
+ /** One data point. Every chart takes `data: ChartDatum[]`. */
7
+ export interface ChartDatum {
8
+ label: string;
9
+ value: number;
10
+ color?: ChartColor;
11
+ }
12
+ /** Clamp `value` into `[min, max]`. */
13
+ export declare function clampChartValue(value: number, min: number, max: number): number;
14
+ /** Sum of the `value`s (non-finite values count as 0). */
15
+ export declare function sumValues(data: readonly {
16
+ value: number;
17
+ }[]): number;
18
+ /** Largest `value` (0 for an empty list). */
19
+ export declare function maxValue(data: readonly {
20
+ value: number;
21
+ }[]): number;
22
+ /** `value / total` as a 0โ€“100 percentage, clamped (0 when `total` is 0). */
23
+ export declare function toPercent(value: number, total: number): number;
24
+ /**
25
+ * A "nice" axis maximum โ‰ฅ `value`: 1, 2, 2.5 or 5 ร— 10โฟ (87 โ†’ 100, 7496 โ†’ 10000).
26
+ * Returns 1 for 0 or negative input so scales never divide by zero.
27
+ */
28
+ export declare function niceMax(value: number): number;
29
+ /** `count + 1` evenly spaced ticks from 0 to `max`, e.g. (100, 4) โ†’ [0, 25, 50, 75, 100]. */
30
+ export declare function ticks(max: number, count?: number): number[];
31
+ /** A linear scale mapping `[d0, d1]` onto `[r0, r1]`. */
32
+ export declare function linearScale(domain: readonly [number, number], range: readonly [number, number]): (value: number) => number;
33
+ /** Cumulative offsets for stacked series: each value gets its `start` and `end` along the stack. */
34
+ export declare function stackValues(values: readonly number[]): {
35
+ start: number;
36
+ end: number;
37
+ }[];
38
+ /** Point on a circle; angle in degrees, 0ยฐ = 12 o'clock, clockwise. */
39
+ export declare function polarToCartesian(cx: number, cy: number, r: number, angleDeg: number): {
40
+ x: number;
41
+ y: number;
42
+ };
43
+ /**
44
+ * SVG path `d` for a ring segment (donut slice) between two angles (degrees,
45
+ * 0ยฐ = 12 o'clock, clockwise). `innerR` 0 draws a pie slice.
46
+ */
47
+ export declare function arcPath(cx: number, cy: number, outerR: number, innerR: number, startAngle: number, endAngle: number): string;
48
+ /**
49
+ * Plain-text summary of a series for a chart's `aria-label` or hidden table
50
+ * caption ("Jan 20, Feb 35, Mar 12"). `format` formats each value.
51
+ */
52
+ export declare function describeData(data: readonly ChartDatum[], format?: (value: number) => string): string;
53
+ /**
54
+ * Roving-tabindex helper for chart data points (WAI-ARIA APG): the next index
55
+ * for an arrow / Home / End key, or `null` when the key isn't handled.
56
+ * Left/Up go back, Right/Down go forward; no wrap-around.
57
+ */
58
+ export declare function nextChartIndex(key: string, index: number, count: number): number | null;
59
+ /**
60
+ * Grid keyboard model (WAI-ARIA APG Grid) for cells laid out row by row,
61
+ * `columns` per row: the next cell index for a key, or `null` when the key
62
+ * isn't handled. Arrows move one cell without wrapping, Home / End go to the
63
+ * row's first / last cell, Ctrl+Home / Ctrl+End to the grid's first / last
64
+ * cell, Page Up / Page Down to the column's first / last cell.
65
+ */
66
+ export declare function nextGridCell(key: string, index: number, columns: number, count: number, ctrlKey?: boolean): number | null;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Small, dependency-free maths for SVG/CSS charts (no chart library). Shared
3
+ * by the React and Vue chart components.
4
+ */
5
+ import type { ChartColor } from './color.js';
6
+ /** One data point. Every chart takes `data: ChartDatum[]`. */
7
+ export interface ChartDatum {
8
+ label: string;
9
+ value: number;
10
+ color?: ChartColor;
11
+ }
12
+ /** Clamp `value` into `[min, max]`. */
13
+ export declare function clampChartValue(value: number, min: number, max: number): number;
14
+ /** Sum of the `value`s (non-finite values count as 0). */
15
+ export declare function sumValues(data: readonly {
16
+ value: number;
17
+ }[]): number;
18
+ /** Largest `value` (0 for an empty list). */
19
+ export declare function maxValue(data: readonly {
20
+ value: number;
21
+ }[]): number;
22
+ /** `value / total` as a 0โ€“100 percentage, clamped (0 when `total` is 0). */
23
+ export declare function toPercent(value: number, total: number): number;
24
+ /**
25
+ * A "nice" axis maximum โ‰ฅ `value`: 1, 2, 2.5 or 5 ร— 10โฟ (87 โ†’ 100, 7496 โ†’ 10000).
26
+ * Returns 1 for 0 or negative input so scales never divide by zero.
27
+ */
28
+ export declare function niceMax(value: number): number;
29
+ /** `count + 1` evenly spaced ticks from 0 to `max`, e.g. (100, 4) โ†’ [0, 25, 50, 75, 100]. */
30
+ export declare function ticks(max: number, count?: number): number[];
31
+ /** A linear scale mapping `[d0, d1]` onto `[r0, r1]`. */
32
+ export declare function linearScale(domain: readonly [number, number], range: readonly [number, number]): (value: number) => number;
33
+ /** Cumulative offsets for stacked series: each value gets its `start` and `end` along the stack. */
34
+ export declare function stackValues(values: readonly number[]): {
35
+ start: number;
36
+ end: number;
37
+ }[];
38
+ /** Point on a circle; angle in degrees, 0ยฐ = 12 o'clock, clockwise. */
39
+ export declare function polarToCartesian(cx: number, cy: number, r: number, angleDeg: number): {
40
+ x: number;
41
+ y: number;
42
+ };
43
+ /**
44
+ * SVG path `d` for a ring segment (donut slice) between two angles (degrees,
45
+ * 0ยฐ = 12 o'clock, clockwise). `innerR` 0 draws a pie slice.
46
+ */
47
+ export declare function arcPath(cx: number, cy: number, outerR: number, innerR: number, startAngle: number, endAngle: number): string;
48
+ /**
49
+ * Plain-text summary of a series for a chart's `aria-label` or hidden table
50
+ * caption ("Jan 20, Feb 35, Mar 12"). `format` formats each value.
51
+ */
52
+ export declare function describeData(data: readonly ChartDatum[], format?: (value: number) => string): string;
53
+ /**
54
+ * Roving-tabindex helper for chart data points (WAI-ARIA APG): the next index
55
+ * for an arrow / Home / End key, or `null` when the key isn't handled.
56
+ * Left/Up go back, Right/Down go forward; no wrap-around.
57
+ */
58
+ export declare function nextChartIndex(key: string, index: number, count: number): number | null;
59
+ /**
60
+ * Grid keyboard model (WAI-ARIA APG Grid) for cells laid out row by row,
61
+ * `columns` per row: the next cell index for a key, or `null` when the key
62
+ * isn't handled. Arrows move one cell without wrapping, Home / End go to the
63
+ * row's first / last cell, Ctrl+Home / Ctrl+End to the grid's first / last
64
+ * cell, Page Up / Page Down to the column's first / last cell.
65
+ */
66
+ export declare function nextGridCell(key: string, index: number, columns: number, count: number, ctrlKey?: boolean): number | null;
67
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Geometry helpers for the chart *items* (Figma "Chart" page 7006:30287):
3
+ * bar fill ratios, stacking shares, line/area paths and donut arcs.
4
+ *
5
+ * Pure functions, shared by the React and Vue packages. They live apart from
6
+ * `src/chart/` (scales, legends โ€” parts branch) so the two can merge without
7
+ * touching the same file.
8
+ */
9
+ export interface ChartPoint {
10
+ x: number;
11
+ y: number;
12
+ }
13
+ /** `value / max` as a 0โ€“1 ratio. Non-finite input, `max <= 0` โ†’ 0. */
14
+ export declare function chartRatio(value: number, max: number): number;
15
+ /** Sum of the finite, positive values. */
16
+ export declare function chartSum(values: readonly number[]): number;
17
+ export interface ChartStack {
18
+ /** Share of each value in the 0โ€“1 range (same order as the input). */
19
+ shares: number[];
20
+ /** Share left empty (track) when `max` is larger than the total. */
21
+ rest: number;
22
+ /** The scale used (`max` or, without it, the total). */
23
+ total: number;
24
+ }
25
+ /**
26
+ * Splits values into shares of one bar. Without `max` the values fill the
27
+ * whole bar; with a larger `max` the remainder is returned as `rest`.
28
+ */
29
+ export declare function chartStack(values: readonly number[], max?: number): ChartStack;
30
+ /** `M x y L โ€ฆ` straight polyline. */
31
+ export declare function linearLinePath(points: readonly ChartPoint[]): string;
32
+ /**
33
+ * Smooth line with horizontal tangents at every point (cubic Bรฉziers whose
34
+ * control points sit a third of the way along each step), the curve Figma's
35
+ * Area Chart v1/v3 vectors use. It never overshoots above or below a point.
36
+ */
37
+ export declare function smoothLinePath(points: readonly ChartPoint[]): string;
38
+ /**
39
+ * Stepped line: every point becomes a flat run `plateau` wide (centred on
40
+ * the point, clipped at the ends) joined by straight ramps. Approximates the
41
+ * hand-drawn Area Chart v2 silhouette.
42
+ */
43
+ export declare function plateauLinePath(points: readonly ChartPoint[], plateau: number): string;
44
+ /** Closes a line path down to `baseline` so it can be filled as an area. */
45
+ export declare function areaPath(line: string, points: readonly ChartPoint[], baseline: number): string;
46
+ /** Point on a circle; angle 0 = 12 o'clock, growing clockwise (radians). */
47
+ export declare function polarPoint(cx: number, cy: number, r: number, angle: number): ChartPoint;
48
+ /** Open circular arc from `a0` to `a1` (clockwise, radians), for stroked rings. */
49
+ export declare function strokeArcPath(cx: number, cy: number, r: number, a0: number, a1: number): string;
50
+ /**
51
+ * Filled ring sector between `rInner` and `rOuter` from `a0` to `a1`
52
+ * (clockwise, radians) with rounded corners of `corner` px.
53
+ */
54
+ export declare function annularSectorPath(cx: number, cy: number, rOuter: number, rInner: number, a0: number, a1: number, corner?: number): string;
55
+ export interface ChartArc {
56
+ start: number;
57
+ end: number;
58
+ }
59
+ /**
60
+ * Start/end angles (radians, 0 = 12 o'clock, clockwise) for each share of a
61
+ * full circle, leaving `gap` radians between neighbours. Zero shares get a
62
+ * zero-length arc.
63
+ */
64
+ export declare function donutArcs(shares: readonly number[], gap?: number): ChartArc[];
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Geometry helpers for the chart *items* (Figma "Chart" page 7006:30287):
3
+ * bar fill ratios, stacking shares, line/area paths and donut arcs.
4
+ *
5
+ * Pure functions, shared by the React and Vue packages. They live apart from
6
+ * `src/chart/` (scales, legends โ€” parts branch) so the two can merge without
7
+ * touching the same file.
8
+ */
9
+ export interface ChartPoint {
10
+ x: number;
11
+ y: number;
12
+ }
13
+ /** `value / max` as a 0โ€“1 ratio. Non-finite input, `max <= 0` โ†’ 0. */
14
+ export declare function chartRatio(value: number, max: number): number;
15
+ /** Sum of the finite, positive values. */
16
+ export declare function chartSum(values: readonly number[]): number;
17
+ export interface ChartStack {
18
+ /** Share of each value in the 0โ€“1 range (same order as the input). */
19
+ shares: number[];
20
+ /** Share left empty (track) when `max` is larger than the total. */
21
+ rest: number;
22
+ /** The scale used (`max` or, without it, the total). */
23
+ total: number;
24
+ }
25
+ /**
26
+ * Splits values into shares of one bar. Without `max` the values fill the
27
+ * whole bar; with a larger `max` the remainder is returned as `rest`.
28
+ */
29
+ export declare function chartStack(values: readonly number[], max?: number): ChartStack;
30
+ /** `M x y L โ€ฆ` straight polyline. */
31
+ export declare function linearLinePath(points: readonly ChartPoint[]): string;
32
+ /**
33
+ * Smooth line with horizontal tangents at every point (cubic Bรฉziers whose
34
+ * control points sit a third of the way along each step), the curve Figma's
35
+ * Area Chart v1/v3 vectors use. It never overshoots above or below a point.
36
+ */
37
+ export declare function smoothLinePath(points: readonly ChartPoint[]): string;
38
+ /**
39
+ * Stepped line: every point becomes a flat run `plateau` wide (centred on
40
+ * the point, clipped at the ends) joined by straight ramps. Approximates the
41
+ * hand-drawn Area Chart v2 silhouette.
42
+ */
43
+ export declare function plateauLinePath(points: readonly ChartPoint[], plateau: number): string;
44
+ /** Closes a line path down to `baseline` so it can be filled as an area. */
45
+ export declare function areaPath(line: string, points: readonly ChartPoint[], baseline: number): string;
46
+ /** Point on a circle; angle 0 = 12 o'clock, growing clockwise (radians). */
47
+ export declare function polarPoint(cx: number, cy: number, r: number, angle: number): ChartPoint;
48
+ /** Open circular arc from `a0` to `a1` (clockwise, radians), for stroked rings. */
49
+ export declare function strokeArcPath(cx: number, cy: number, r: number, a0: number, a1: number): string;
50
+ /**
51
+ * Filled ring sector between `rInner` and `rOuter` from `a0` to `a1`
52
+ * (clockwise, radians) with rounded corners of `corner` px.
53
+ */
54
+ export declare function annularSectorPath(cx: number, cy: number, rOuter: number, rInner: number, a0: number, a1: number, corner?: number): string;
55
+ export interface ChartArc {
56
+ start: number;
57
+ end: number;
58
+ }
59
+ /**
60
+ * Start/end angles (radians, 0 = 12 o'clock, clockwise) for each share of a
61
+ * full circle, leaving `gap` radians between neighbours. Zero shares get a
62
+ * zero-length arc.
63
+ */
64
+ export declare function donutArcs(shares: readonly number[], gap?: number): ChartArc[];
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Tiny built-in syntax tokenizer for <CodeSnippet> (React + Vue).
3
+ *
4
+ * Covers the roles the Figma "CodeSnippet [v1]" (7489:54806) colours:
5
+ * keywords, strings, comments, numbers, punctuation, function names,
6
+ * variables, types, JSX/HTML tags + attributes, for JS / JSX / TS / TSX /
7
+ * HTML / CSS. It is deliberately small (no grammar engine, no dependency):
8
+ * apps that need full-fidelity highlighting pass their own tokens
9
+ * (`tokens` / `highlight` props) from Shiki, Prism, etc.
10
+ */
11
+ export type CodeTokenType = 'plain' | 'keyword' | 'string' | 'comment' | 'number' | 'punctuation' | 'function' | 'variable' | 'type' | 'builtin' | 'tag' | 'attr' | 'text';
12
+ export interface CodeToken {
13
+ /** Raw text of the token (never contains a newline once split into lines). */
14
+ content: string;
15
+ /** Semantic role, mapped to a Figma syntax colour. Defaults to `plain`. */
16
+ type?: CodeTokenType;
17
+ /** Explicit colour from an external highlighter (e.g. Shiki). Wins over `type`. */
18
+ color?: string;
19
+ }
20
+ export type CodeLanguage = 'js' | 'jsx' | 'ts' | 'tsx' | 'html' | 'css' | 'plain';
21
+ /** Guess a language from a file name such as `Counter.tsx`. */
22
+ export declare function inferCodeLanguage(fileName?: string): CodeLanguage;
23
+ /** Splits a flat token stream into lines (tokens never span a newline afterwards). */
24
+ export declare function splitCodeTokensIntoLines(tokens: CodeToken[]): CodeToken[][];
25
+ /**
26
+ * Tokenizes `code` into lines of coloured tokens.
27
+ * @example tokenizeCode("const a = 1;", 'ts') // [[{content:'const',type:'keyword'}, โ€ฆ]]
28
+ */
29
+ export declare function tokenizeCode(code: string, language?: CodeLanguage): CodeToken[][];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Tiny built-in syntax tokenizer for <CodeSnippet> (React + Vue).
3
+ *
4
+ * Covers the roles the Figma "CodeSnippet [v1]" (7489:54806) colours:
5
+ * keywords, strings, comments, numbers, punctuation, function names,
6
+ * variables, types, JSX/HTML tags + attributes, for JS / JSX / TS / TSX /
7
+ * HTML / CSS. It is deliberately small (no grammar engine, no dependency):
8
+ * apps that need full-fidelity highlighting pass their own tokens
9
+ * (`tokens` / `highlight` props) from Shiki, Prism, etc.
10
+ */
11
+ export type CodeTokenType = 'plain' | 'keyword' | 'string' | 'comment' | 'number' | 'punctuation' | 'function' | 'variable' | 'type' | 'builtin' | 'tag' | 'attr' | 'text';
12
+ export interface CodeToken {
13
+ /** Raw text of the token (never contains a newline once split into lines). */
14
+ content: string;
15
+ /** Semantic role, mapped to a Figma syntax colour. Defaults to `plain`. */
16
+ type?: CodeTokenType;
17
+ /** Explicit colour from an external highlighter (e.g. Shiki). Wins over `type`. */
18
+ color?: string;
19
+ }
20
+ export type CodeLanguage = 'js' | 'jsx' | 'ts' | 'tsx' | 'html' | 'css' | 'plain';
21
+ /** Guess a language from a file name such as `Counter.tsx`. */
22
+ export declare function inferCodeLanguage(fileName?: string): CodeLanguage;
23
+ /** Splits a flat token stream into lines (tokens never span a newline afterwards). */
24
+ export declare function splitCodeTokensIntoLines(tokens: CodeToken[]): CodeToken[][];
25
+ /**
26
+ * Tokenizes `code` into lines of coloured tokens.
27
+ * @example tokenizeCode("const a = 1;", 'ts') // [[{content:'const',type:'keyword'}, โ€ฆ]]
28
+ */
29
+ export declare function tokenizeCode(code: string, language?: CodeLanguage): CodeToken[][];
30
+ //# sourceMappingURL=codeTokenizer.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Looks up a CSS Module class by a computed key, such as a variant name or
3
+ * `` `size-${px}` ``. A key the stylesheet doesn't define (typically the
4
+ * default variant, which the base rules already style) gives `undefined`,
5
+ * which clsx and Vue's `:class` drop.
6
+ *
7
+ * The class map must still define at least one key of the key's type, so a
8
+ * misspelt key family (`` `varaint-${v}` ``) fails to compile.
9
+ *
10
+ * @example clsx(styles.root, moduleClass(styles, variant))
11
+ */
12
+ export declare function moduleClass<K extends string>(styles: Partial<Record<NoInfer<K>, string>>, key: K): string | undefined;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Looks up a CSS Module class by a computed key, such as a variant name or
3
+ * `` `size-${px}` ``. A key the stylesheet doesn't define (typically the
4
+ * default variant, which the base rules already style) gives `undefined`,
5
+ * which clsx and Vue's `:class` drop.
6
+ *
7
+ * The class map must still define at least one key of the key's type, so a
8
+ * misspelt key family (`` `varaint-${v}` ``) fails to compile.
9
+ *
10
+ * @example clsx(styles.root, moduleClass(styles, variant))
11
+ */
12
+ export declare function moduleClass<K extends string>(styles: Partial<Record<NoInfer<K>, string>>, key: K): string | undefined;
13
+ //# sourceMappingURL=cssModule.d.ts.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Light-dismiss for open surfaces (menus, popovers, listboxes, dialogs):
3
+ * a pointer press outside, Escape, or focus moving outside closes them.
4
+ *
5
+ * Open surfaces form a stack in the order they open. Escape only closes the
6
+ * top one, so a menu inside a dialog closes before the dialog. A press or
7
+ * focus inside a surface that opened later (a submenu, or a popover portalled
8
+ * out of its parent) counts as inside every surface below it, so it never
9
+ * closes the parent.
10
+ *
11
+ * Containment uses `composedPath()`, so presses inside shadow roots count
12
+ * as inside the host that owns them.
13
+ */
14
+ export type DismissReason = 'outside' | 'escape' | 'focusout';
15
+ /**
16
+ * Why an overlay (modal, drawer, sheet, popover, lightbox) asked to close:
17
+ * its Cancel button, Escape, a press outside it, or its ร— / other close action.
18
+ */
19
+ export type OverlayCloseReason = 'cancel' | 'escape' | 'outside' | 'close';
20
+ /** Second argument of an overlay's `onOpenChange` / `openChange`. */
21
+ export interface OverlayOpenChangeDetails {
22
+ reason: OverlayCloseReason;
23
+ }
24
+ export interface DismissLayerOptions {
25
+ /** Elements that count as inside: the surface, its trigger, portalled parts. Read on every event. */
26
+ getElements: () => Iterable<Element | null | undefined>;
27
+ /** Asks the owner to close. The layer stays registered until its remove function runs. */
28
+ onDismiss: (reason: DismissReason, event: Event) => void;
29
+ /** Close on a pointer press outside. Default `true`. */
30
+ outsidePress?: boolean | undefined;
31
+ /** Close on Escape while this is the top layer. Default `true`. */
32
+ escapeKey?: boolean | undefined;
33
+ /** Close when focus moves outside. Default `false` (menus and listboxes keep focus on their trigger). */
34
+ focusOut?: boolean | undefined;
35
+ }
36
+ /**
37
+ * Registers an open surface on the dismiss stack; returns the function that
38
+ * removes it (call it when the surface closes or unmounts).
39
+ */
40
+ export declare function addDismissLayer(options: DismissLayerOptions): () => void;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Light-dismiss for open surfaces (menus, popovers, listboxes, dialogs):
3
+ * a pointer press outside, Escape, or focus moving outside closes them.
4
+ *
5
+ * Open surfaces form a stack in the order they open. Escape only closes the
6
+ * top one, so a menu inside a dialog closes before the dialog. A press or
7
+ * focus inside a surface that opened later (a submenu, or a popover portalled
8
+ * out of its parent) counts as inside every surface below it, so it never
9
+ * closes the parent.
10
+ *
11
+ * Containment uses `composedPath()`, so presses inside shadow roots count
12
+ * as inside the host that owns them.
13
+ */
14
+ export type DismissReason = 'outside' | 'escape' | 'focusout';
15
+ /**
16
+ * Why an overlay (modal, drawer, sheet, popover, lightbox) asked to close:
17
+ * its Cancel button, Escape, a press outside it, or its ร— / other close action.
18
+ */
19
+ export type OverlayCloseReason = 'cancel' | 'escape' | 'outside' | 'close';
20
+ /** Second argument of an overlay's `onOpenChange` / `openChange`. */
21
+ export interface OverlayOpenChangeDetails {
22
+ reason: OverlayCloseReason;
23
+ }
24
+ export interface DismissLayerOptions {
25
+ /** Elements that count as inside: the surface, its trigger, portalled parts. Read on every event. */
26
+ getElements: () => Iterable<Element | null | undefined>;
27
+ /** Asks the owner to close. The layer stays registered until its remove function runs. */
28
+ onDismiss: (reason: DismissReason, event: Event) => void;
29
+ /** Close on a pointer press outside. Default `true`. */
30
+ outsidePress?: boolean | undefined;
31
+ /** Close on Escape while this is the top layer. Default `true`. */
32
+ escapeKey?: boolean | undefined;
33
+ /** Close when focus moves outside. Default `false` (menus and listboxes keep focus on their trigger). */
34
+ focusOut?: boolean | undefined;
35
+ }
36
+ /**
37
+ * Registers an open surface on the dismiss stack; returns the function that
38
+ * removes it (call it when the surface closes or unmounts).
39
+ */
40
+ export declare function addDismissLayer(options: DismissLayerOptions): () => void;
41
+ //# sourceMappingURL=dismiss.d.ts.map