haze-ui 1.28.0 → 1.29.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 (83) hide show
  1. package/README.md +81 -33
  2. package/dist/components/Chart/chart-elements.js +108 -47
  3. package/dist/components/CountUp/CountUp.js +45 -0
  4. package/dist/components/CountUp/index.js +3 -0
  5. package/dist/components/Ellipsis/Ellipsis.js +53 -0
  6. package/dist/components/Ellipsis/index.js +3 -0
  7. package/dist/components/LocaleProvider/ar-sa.js +233 -0
  8. package/dist/components/LocaleProvider/de-de.js +233 -0
  9. package/dist/components/LocaleProvider/es-es.js +233 -0
  10. package/dist/components/LocaleProvider/fr-fr.js +233 -0
  11. package/dist/components/LocaleProvider/index.js +10 -2
  12. package/dist/components/LocaleProvider/it-it.js +233 -0
  13. package/dist/components/LocaleProvider/ja-jp.js +11 -0
  14. package/dist/components/LocaleProvider/ko-kr.js +233 -0
  15. package/dist/components/LocaleProvider/locale.js +11 -0
  16. package/dist/components/LocaleProvider/pt-br.js +233 -0
  17. package/dist/components/LocaleProvider/ru-ru.js +233 -0
  18. package/dist/components/LocaleProvider/zh-cn.js +11 -0
  19. package/dist/components/QRCode/QRCode.js +43 -0
  20. package/dist/components/QRCode/index.js +3 -0
  21. package/dist/components/Result/Result.js +229 -0
  22. package/dist/components/Result/index.js +3 -0
  23. package/dist/components/TreeSelect/TreeSelect.js +230 -0
  24. package/dist/components/TreeSelect/index.js +3 -0
  25. package/dist/components/Typography/Typography.js +39 -12
  26. package/dist/css/count-up.css +2 -0
  27. package/dist/css/ellipsis.css +2 -0
  28. package/dist/css/qr-code.css +2 -0
  29. package/dist/css/result.css +2 -0
  30. package/dist/css/tokens.css +3 -1
  31. package/dist/css/tree-select.css +3 -0
  32. package/dist/css/typography.css +1 -1
  33. package/dist/css-manifest.json +19 -0
  34. package/dist/design-tokens/dark.json +355 -0
  35. package/dist/design-tokens/light.json +355 -0
  36. package/dist/haze-ui.css +10 -2
  37. package/dist/index.js +233 -218
  38. package/dist/mcp-docs.json +9383 -0
  39. package/dist/registry.json +132 -30
  40. package/dist/tokens/brands.js +21 -0
  41. package/dist/tokens/density.js +6 -0
  42. package/dist/tokens/index.js +6 -5
  43. package/dist/tokens/palette.js +63 -55
  44. package/dist/types/components/Chart/Chart.d.ts +15 -11
  45. package/dist/types/components/Chart/chart-elements.d.ts +15 -7
  46. package/dist/types/components/CountUp/CountUp.d.ts +20 -0
  47. package/dist/types/components/CountUp/index.d.ts +2 -0
  48. package/dist/types/components/Ellipsis/Ellipsis.d.ts +19 -0
  49. package/dist/types/components/Ellipsis/index.d.ts +2 -0
  50. package/dist/types/components/LocaleProvider/ar-sa.d.ts +22 -0
  51. package/dist/types/components/LocaleProvider/de-de.d.ts +15 -0
  52. package/dist/types/components/LocaleProvider/es-es.d.ts +15 -0
  53. package/dist/types/components/LocaleProvider/fr-fr.d.ts +15 -0
  54. package/dist/types/components/LocaleProvider/index.d.ts +8 -0
  55. package/dist/types/components/LocaleProvider/it-it.d.ts +15 -0
  56. package/dist/types/components/LocaleProvider/ko-kr.d.ts +15 -0
  57. package/dist/types/components/LocaleProvider/locale.d.ts +11 -0
  58. package/dist/types/components/LocaleProvider/pt-br.d.ts +16 -0
  59. package/dist/types/components/LocaleProvider/ru-ru.d.ts +15 -0
  60. package/dist/types/components/QRCode/QRCode.d.ts +33 -0
  61. package/dist/types/components/QRCode/index.d.ts +2 -0
  62. package/dist/types/components/Result/Result.d.ts +16 -0
  63. package/dist/types/components/Result/index.d.ts +2 -0
  64. package/dist/types/components/TagGroup/SortableTagGroup.d.ts +3 -2
  65. package/dist/types/components/TagGroup/TagGroup.d.ts +1 -1
  66. package/dist/types/components/TagInput/SortableTagInput.d.ts +2 -3
  67. package/dist/types/components/TagInput/SortableTagInputCore.d.ts +3 -3
  68. package/dist/types/components/TreeSelect/TreeSelect.d.ts +93 -0
  69. package/dist/types/components/TreeSelect/index.d.ts +2 -0
  70. package/dist/types/components/Typography/Typography.d.ts +12 -3
  71. package/dist/types/components/Typography/index.d.ts +1 -1
  72. package/dist/types/index.d.ts +15 -2
  73. package/dist/types/tokens/brands.d.ts +28 -0
  74. package/dist/types/tokens/density.d.ts +3 -0
  75. package/dist/types/tokens/index.d.ts +1 -0
  76. package/dist/types/tokens/palette.d.ts +38 -1
  77. package/dist/types/tokens/spacing.d.ts +13 -0
  78. package/dist/types/utils/sortable-shared.d.ts +4 -4
  79. package/mcp/index.mjs +64 -0
  80. package/mcp/server.mjs +89 -0
  81. package/mcp/server.test.mjs +281 -0
  82. package/mcp/tools.mjs +240 -0
  83. package/package.json +61 -43
package/README.md CHANGED
@@ -129,30 +129,30 @@ checklist:
129
129
 
130
130
  ### Dependencies
131
131
 
132
- haze-ui ships two runtime dependencies — `react-use-control`, the engine
133
- behind `ControlOrValue<T>`, and `react-f0rm` (^1.3), the form engine
134
- behind `FormItem`/`FormList` (the same author's headless form store).
135
- Five integrations remain optional peers, installed only when you use the
136
- components that need them:
137
-
138
- ```sh
139
- npm i @tanstack/react-table # DataTable (peer range ^9.2.4)
140
- npm i recharts # Chart (peer range ^3.10.1)
141
- npm i @dnd-kit/core @dnd-kit/sortable \
142
- @dnd-kit/utilities # TagInput/TagGroup sortable
143
- # (^6.3.1 / ^10.0.0 / ^3.2.2)
144
- ```
145
-
146
- Everything else — `Button`, `Input`, `Dialog`, `Select`, … — runs with
147
- nothing beyond `react` and the two runtime dependencies. The dist is ESM
148
- with `preserveModules` and side-effect-free JS, so bundlers (Next.js,
149
- Vite, webpack, Turbopack, Rollup) tree-shake the unused re-export chains
150
- and never resolve peers you haven't installed: `import { Button } from
151
- 'haze-ui'` works without `@tanstack/react-table`. Only bundler-less
152
- consumers (bare Node ESM importing the barrel, which links the module
153
- graph eagerly) must install the optional peers; the
154
- `haze-ui/components/DataTable` and `haze-ui/components/Chart` subpaths
155
- bypass the barrel entirely.
132
+ haze-ui declares only the host environment as peers: `react` and
133
+ `react-dom` (^19). Everything else is a regular dependency — one
134
+ `npm i haze-ui` and every component works:
135
+
136
+ - `react-use-control` — the engine behind `ControlOrValue<T>`
137
+ - `react-f0rm` (^1.3) — the form engine behind `FormItem`/`FormList`
138
+ (the same author's headless form store)
139
+ - `@tanstack/react-table` — DataTable
140
+ - `recharts` — Chart
141
+ - `@dnd-kit/core` / `@dnd-kit/sortable` / `@dnd-kit/utilities` — the
142
+ sortable TagInput/TagGroup variants
143
+ - `qrcode` — QRCode
144
+
145
+ Swapping any of these engines for another library is invisible to your
146
+ code (the one deliberate exception: DataTable's column API exposes
147
+ TanStack's `ColumnDef` types). The dist is ESM with `preserveModules`
148
+ and side-effect-free JS, and engines are imported only by the components
149
+ that need them, so bundlers (Next.js, Vite, webpack, Turbopack, Rollup)
150
+ tree-shake the unused re-export chains: `import { Button } from
151
+ 'haze-ui'` never pulls `@tanstack/react-table` into the bundle. Engines
152
+ install as regular dependencies, so even bundler-less consumers (bare
153
+ Node ESM importing the barrel, which links the module graph eagerly)
154
+ work with zero manual installs; the `haze-ui/components/DataTable` and
155
+ `haze-ui/components/Chart` subpaths bypass the barrel entirely.
156
156
 
157
157
  ### Browser support
158
158
 
@@ -393,16 +393,18 @@ user-controllable, SSR/jsdom-safe when the underlying API is missing.
393
393
  | `useTitle(title)` | — | Document title while mounted |
394
394
  | `useToast()` | toast API | Requires a `ToastContainer` ancestor |
395
395
 
396
- ## Sortable tags and chips (optional dnd-kit peers)
396
+ ## Sortable tags and chips
397
397
 
398
- `TagInput` and `TagGroup` accept `sortable?: boolean` — opt-in drag
399
- reordering powered by `@dnd-kit/core` / `@dnd-kit/sortable` /
400
- `@dnd-kit/utilities` (optional peers, same tree-shaking contract as
401
- recharts and TanStack Table). `TagInput` writes the new array through
402
- `onChange`; `TagGroup` reports `onReorder(nextOrder)` (the new
403
- arrangement of original child indexes) and leaves re-rendering to the
404
- parent. Sorting is keyboard-complete: focus a tag, `Space` to lift,
405
- arrows to move, `Space` to drop, `Escape` to cancel.
398
+ Drag reordering is an opt-in variant: `SortableTagInput` /
399
+ `SortableTagInputCore` and `SortableTagGroup` statically import
400
+ `@dnd-kit/core` / `@dnd-kit/sortable` / `@dnd-kit/utilities` (regular
401
+ dependencies — the plain `TagInput`/`TagGroup` never touch them, so they
402
+ stay out of every bundle that doesn't import a Sortable variant).
403
+ `SortableTagInput` writes the new array through `onChange`;
404
+ `SortableTagGroup` reports `onReorder(nextOrder)` (the new arrangement of
405
+ original child indexes) and leaves re-rendering to the parent. Sorting is
406
+ keyboard-complete: focus a tag, `Space` to lift, arrows to move, `Space`
407
+ to drop, `Escape` to cancel.
406
408
 
407
409
  ## Imperative overlay handles
408
410
 
@@ -544,6 +546,52 @@ own css manifest. The same items are also installable straight from this
544
546
  GitHub repository — see
545
547
  [Install via shadcn CLI (GitHub registry)](#install-via-shadcn-cli-github-registry).
546
548
 
549
+ ## AI / MCP
550
+
551
+ **`haze-ui-mcp`** — an [MCP server](https://modelcontextprotocol.io) that puts the
552
+ whole component reference in your AI coding agent's tool belt. It serves the
553
+ same docs the site renders (props tables with types/defaults/descriptions,
554
+ import statements, CSS paths, peer deps, the full token registry), so the
555
+ agent never guesses a prop name or a stylesheet path again:
556
+
557
+ | Tool | What it returns |
558
+ | --- | --- |
559
+ | `haze_list_components` | Every component with its css family |
560
+ | `haze_get_component` | One component's full reference — props tables, import statement, CSS imports. Name matching is case-insensitive and accepts kebab-case (`data-table`) or PascalCase (`DataTable`) |
561
+ | `haze_get_tokens` | The `--haze-*` token registry with light and dark values, optionally filtered by category (`color`, `typography`, `spacing`, `radius`, `shadow`) |
562
+ | `haze_search_docs` | Top-10 ranked matches across component names, css families, prop names and descriptions |
563
+
564
+ **Claude Code**:
565
+
566
+ ```sh
567
+ claude mcp add haze-ui -- npx haze-ui-mcp
568
+ ```
569
+
570
+ **Cursor** (`.cursor/mcp.json`):
571
+
572
+ ```json
573
+ {
574
+ "mcpServers": {
575
+ "haze-ui": {
576
+ "command": "npx",
577
+ "args": ["haze-ui-mcp"]
578
+ }
579
+ }
580
+ }
581
+ ```
582
+
583
+ The server speaks stdio JSON-RPC and ships its own docs snapshot
584
+ (`dist/mcp-docs.json`, regenerated on every build by
585
+ `scripts/generate-mcp-docs.mjs`) — no project access, no indexing on startup.
586
+ In this repository you can run it directly against the local snapshot:
587
+
588
+ ```sh
589
+ node scripts/generate-mcp-docs.mjs
590
+ node mcp/index.mjs
591
+ ```
592
+
593
+ Point it at a custom snapshot with `HAZE_UI_MCP_DOCS=/path/to/mcp-docs.json`.
594
+
547
595
  ## AI runtime integration (Vercel AI SDK `useChat`)
548
596
 
549
597
  haze-ui ships the agent chat surface as **presentational** components —
@@ -1,32 +1,32 @@
1
1
  "use client";
2
2
  import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
3
- import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u, Pie as d, PieChart as f, ResponsiveContainer as p, Tooltip as m, XAxis as h, YAxis as g } from "recharts";
3
+ import { Area as r, AreaChart as i, Bar as a, BarChart as o, CartesianGrid as s, Legend as c, Line as l, LineChart as u, Pie as d, PieChart as f, PolarAngleAxis as p, PolarGrid as m, PolarRadiusAxis as h, Radar as g, RadarChart as _, ResponsiveContainer as v, Scatter as y, ScatterChart as b, Tooltip as x, XAxis as S, YAxis as C } from "recharts";
4
4
  //#region src/lib/components/Chart/chart-elements.tsx
5
- var _ = [
5
+ var w = [
6
6
  "var(--haze-color-primary)",
7
7
  "var(--haze-color-info)",
8
8
  "var(--haze-color-success)",
9
9
  "var(--haze-color-warning)",
10
10
  "var(--haze-color-danger)"
11
- ], v = "var(--haze-color-border)", y = {
11
+ ], T = "var(--haze-color-border)", E = {
12
12
  fontSize: "var(--haze-text-sm)",
13
13
  fill: "var(--haze-color-text-secondary)"
14
- }, b = {
14
+ }, D = {
15
15
  fontSize: "var(--haze-text-sm)",
16
16
  color: "var(--haze-color-text)"
17
- }, x = { fontSize: "var(--haze-text-sm)" };
18
- function S(e) {
19
- return _[e % _.length];
17
+ }, O = { fontSize: "var(--haze-text-sm)" };
18
+ function k(e) {
19
+ return w[e % w.length];
20
20
  }
21
- function C(e) {
21
+ function A(e) {
22
22
  return e.map((e) => ({
23
23
  key: e.key,
24
24
  label: e.label ?? e.key,
25
25
  color: e.color
26
26
  }));
27
27
  }
28
- function w(e, n, i = 0) {
29
- let { key: o, label: s } = n, c = n.color ?? S(i);
28
+ function j(e, n, i = 0) {
29
+ let { key: o, label: s } = n, c = n.color ?? k(i);
30
30
  switch (e) {
31
31
  case "area": return /* @__PURE__ */ t(r, {
32
32
  dataKey: o,
@@ -44,9 +44,21 @@ function w(e, n, i = 0) {
44
44
  name: s,
45
45
  stroke: c
46
46
  }, o);
47
+ case "radar": return /* @__PURE__ */ t(g, {
48
+ dataKey: o,
49
+ name: s,
50
+ stroke: c,
51
+ fill: c,
52
+ fillOpacity: .3
53
+ }, o);
54
+ case "scatter": return /* @__PURE__ */ t(y, {
55
+ dataKey: o,
56
+ name: s,
57
+ fill: c
58
+ }, o);
47
59
  }
48
60
  }
49
- function T(e, t, n) {
61
+ function M(e, t, n) {
50
62
  if (t <= 1) return {
51
63
  innerRadius: n,
52
64
  outerRadius: "80%"
@@ -57,10 +69,10 @@ function T(e, t, n) {
57
69
  outerRadius: `${i + (e + 1) * a}%`
58
70
  };
59
71
  }
60
- function E(e) {
61
- let { entry: n, data: r, nameKey: i, ringIndex: a, ringCount: o, innerRadius: s } = e, c = T(a, o, s), l = r.map((e, t) => ({
72
+ function N(e) {
73
+ let { entry: n, data: r, nameKey: i, ringIndex: a, ringCount: o, innerRadius: s } = e, c = M(a, o, s), l = r.map((e, t) => ({
62
74
  ...e,
63
- fill: n.color ?? S(t)
75
+ fill: n.color ?? k(t)
64
76
  }));
65
77
  return /* @__PURE__ */ t(d, {
66
78
  data: l,
@@ -71,7 +83,7 @@ function E(e) {
71
83
  stroke: "var(--haze-color-bg)"
72
84
  }, n.key);
73
85
  }
74
- function D(e, n, r, a = "horizontal") {
86
+ function P(e, n, r, a = "horizontal") {
75
87
  switch (e) {
76
88
  case "area": return /* @__PURE__ */ t(i, {
77
89
  data: n,
@@ -92,9 +104,17 @@ function D(e, n, r, a = "horizontal") {
92
104
  data: n,
93
105
  children: r
94
106
  });
107
+ case "radar": return /* @__PURE__ */ t(_, {
108
+ data: n,
109
+ children: r
110
+ });
111
+ case "scatter": return /* @__PURE__ */ t(b, {
112
+ data: n,
113
+ children: r
114
+ });
95
115
  }
96
116
  }
97
- function O(e) {
117
+ function F(e) {
98
118
  return (t) => {
99
119
  let { payload: n, label: r } = t;
100
120
  return e({
@@ -108,57 +128,98 @@ function O(e) {
108
128
  });
109
129
  };
110
130
  }
111
- function k(r) {
112
- let { type: i, data: a, xKey: o, showGrid: l, showTooltip: u, showLegend: d, series: f, layout: _ = "horizontal", innerRadius: S = 0, renderTooltip: C } = r, T = C ? O(C) : void 0;
113
- return i === "pie" ? /* @__PURE__ */ t(p, {
131
+ function I(r) {
132
+ let { type: i, data: a, xKey: o, showGrid: l, showTooltip: u, showLegend: d, series: f, layout: g = "horizontal", innerRadius: _ = 0, renderTooltip: y } = r, b = y ? F(y) : void 0;
133
+ return i === "pie" ? /* @__PURE__ */ t(v, {
114
134
  width: "100%",
115
135
  height: "100%",
116
- children: D(i, a, /* @__PURE__ */ n(e, { children: [
117
- u && /* @__PURE__ */ t(m, {
118
- contentStyle: b,
119
- content: T
136
+ children: P(i, a, /* @__PURE__ */ n(e, { children: [
137
+ u && /* @__PURE__ */ t(x, {
138
+ contentStyle: D,
139
+ content: b
120
140
  }),
121
- d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
122
- f.map((e, t) => E({
141
+ d && /* @__PURE__ */ t(c, { wrapperStyle: O }),
142
+ f.map((e, t) => N({
123
143
  entry: e,
124
144
  data: a,
125
145
  nameKey: o,
126
146
  ringIndex: t,
127
147
  ringCount: f.length,
128
- innerRadius: S
148
+ innerRadius: _
129
149
  }))
130
150
  ] }))
131
- }) : /* @__PURE__ */ t(p, {
151
+ }) : i === "radar" ? /* @__PURE__ */ t(v, {
152
+ width: "100%",
153
+ height: "100%",
154
+ children: P(i, a, /* @__PURE__ */ n(e, { children: [
155
+ l && /* @__PURE__ */ t(m, { stroke: "var(--haze-color-border)" }),
156
+ /* @__PURE__ */ t(p, {
157
+ dataKey: o,
158
+ tick: E
159
+ }),
160
+ /* @__PURE__ */ t(h, { tick: E }),
161
+ u && /* @__PURE__ */ t(x, {
162
+ contentStyle: D,
163
+ content: b
164
+ }),
165
+ d && /* @__PURE__ */ t(c, { wrapperStyle: O }),
166
+ f.map((e, t) => j("radar", e, t))
167
+ ] }))
168
+ }) : i === "scatter" ? /* @__PURE__ */ t(v, {
169
+ width: "100%",
170
+ height: "100%",
171
+ children: P(i, a, /* @__PURE__ */ n(e, { children: [
172
+ l && /* @__PURE__ */ t(s, { stroke: "var(--haze-color-border)" }),
173
+ /* @__PURE__ */ t(S, {
174
+ type: "number",
175
+ dataKey: o,
176
+ stroke: T,
177
+ tick: E
178
+ }),
179
+ /* @__PURE__ */ t(C, {
180
+ type: "number",
181
+ stroke: T,
182
+ tick: E
183
+ }),
184
+ u && /* @__PURE__ */ t(x, {
185
+ cursor: { stroke: "var(--haze-color-border)" },
186
+ contentStyle: D,
187
+ content: b
188
+ }),
189
+ d && /* @__PURE__ */ t(c, { wrapperStyle: O }),
190
+ f.map((e, t) => j("scatter", e, t))
191
+ ] }))
192
+ }) : /* @__PURE__ */ t(v, {
132
193
  width: "100%",
133
194
  height: "100%",
134
- children: D(i, a, /* @__PURE__ */ n(e, { children: [
195
+ children: P(i, a, /* @__PURE__ */ n(e, { children: [
135
196
  l && /* @__PURE__ */ t(s, { stroke: "var(--haze-color-border)" }),
136
- _ === "vertical" ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
197
+ g === "vertical" ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(S, {
137
198
  type: "number",
138
- stroke: v,
139
- tick: y
140
- }), /* @__PURE__ */ t(g, {
199
+ stroke: T,
200
+ tick: E
201
+ }), /* @__PURE__ */ t(C, {
141
202
  type: "category",
142
203
  dataKey: o,
143
- stroke: v,
144
- tick: y
145
- })] }) : /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(h, {
204
+ stroke: T,
205
+ tick: E
206
+ })] }) : /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t(S, {
146
207
  dataKey: o,
147
- stroke: v,
148
- tick: y
149
- }), /* @__PURE__ */ t(g, {
150
- stroke: v,
151
- tick: y
208
+ stroke: T,
209
+ tick: E
210
+ }), /* @__PURE__ */ t(C, {
211
+ stroke: T,
212
+ tick: E
152
213
  })] }),
153
- u && /* @__PURE__ */ t(m, {
214
+ u && /* @__PURE__ */ t(x, {
154
215
  cursor: { stroke: "var(--haze-color-border)" },
155
- contentStyle: b,
156
- content: T
216
+ contentStyle: D,
217
+ content: b
157
218
  }),
158
- d && /* @__PURE__ */ t(c, { wrapperStyle: x }),
159
- f.map((e, t) => w(i, e, t))
160
- ] }), _)
219
+ d && /* @__PURE__ */ t(c, { wrapperStyle: O }),
220
+ f.map((e, t) => j(i, e, t))
221
+ ] }), g)
161
222
  });
162
223
  }
163
224
  //#endregion
164
- export { v as AXIS_STROKE, y as AXIS_TICK, x as LEGEND_STYLE, b as TOOLTIP_STYLE, O as buildTooltipContent, D as chartElement, k as chartTree, E as pieElement, T as pieRingRadii, C as resolveChartSeries, w as seriesElement };
225
+ export { T as AXIS_STROKE, E as AXIS_TICK, O as LEGEND_STYLE, D as TOOLTIP_STYLE, F as buildTooltipContent, P as chartElement, I as chartTree, N as pieElement, M as pieRingRadii, A as resolveChartSeries, j as seriesElement };
@@ -0,0 +1,45 @@
1
+
2
+ "use client";
3
+ import { classnames as e } from "../../utils/classnames.js";
4
+ import { usePrefersReducedMotion as t } from "../../hooks/usePrefersReducedMotion.js";
5
+ /* empty css */
6
+ import { jsx as n } from "react/jsx-runtime";
7
+ import { useEffect as r, useRef as i, useState as a } from "react";
8
+ //#region src/lib/components/CountUp/CountUp.tsx
9
+ var o = "haze-CountUp__base", s = /* @__PURE__ */ new Map();
10
+ function c(e, t) {
11
+ let n = s.get(t);
12
+ return n || (n = new Intl.NumberFormat(void 0, {
13
+ minimumFractionDigits: t,
14
+ maximumFractionDigits: t
15
+ }), s.set(t, n)), n.format(e);
16
+ }
17
+ function l({ to: s, from: l = 0, duration: u = 1200, decimals: d = 0, format: f, autostart: p = !0, className: m, ...h }) {
18
+ let g = t(), [_, v] = a(l), y = i(l), b = i(0), x = i(!0);
19
+ return r(() => {
20
+ let e = x.current;
21
+ if (x.current = !1, e && !p) return;
22
+ let t = y.current;
23
+ if (g || u <= 0 || t === s) {
24
+ y.current = s, v(s);
25
+ return;
26
+ }
27
+ let n = performance.now(), r = (e) => {
28
+ let i = Math.min(Math.max((e - n) / u, 0), 1), a = 1 - (1 - i) ** 3, o = t + (s - t) * a;
29
+ y.current = o, v(o), i < 1 && (b.current = window.requestAnimationFrame(r));
30
+ };
31
+ return b.current = window.requestAnimationFrame(r), () => window.cancelAnimationFrame(b.current);
32
+ }, [
33
+ s,
34
+ l,
35
+ u,
36
+ g,
37
+ p
38
+ ]), /* @__PURE__ */ n("span", {
39
+ ...h,
40
+ className: e([o, m]),
41
+ children: f ? f(_) : c(_, d)
42
+ });
43
+ }
44
+ //#endregion
45
+ export { l as default };
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import e from "./CountUp.js";
3
+ export { e as CountUp };
@@ -0,0 +1,53 @@
1
+
2
+ "use client";
3
+ import { classnames as e } from "../../utils/classnames.js";
4
+ import { useStrings as t } from "../LocaleProvider/useStrings.js";
5
+ import n from "../Tooltip/Tooltip.js";
6
+ /* empty css */
7
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
8
+ import { useEffect as a, useRef as o, useState as s } from "react";
9
+ import { useControl as c } from "react-use-control";
10
+ //#region src/lib/components/Ellipsis/Ellipsis.tsx
11
+ var l = "haze-Ellipsis__root", u = "haze-Ellipsis__clampBase", d = "haze-Ellipsis__expandBtn";
12
+ function f({ children: f, lines: p = 1, tooltip: m = !1, expandable: h = !1, expanded: g, onExpandChange: _, className: v, ...y }) {
13
+ let b = t("ellipsis"), [x, S] = s(!1), [C, w] = c(g, !1), T = o(null);
14
+ a(() => {
15
+ if (C) return;
16
+ let e = T.current;
17
+ e && S(e.scrollHeight > e.clientHeight);
18
+ }, [
19
+ f,
20
+ p,
21
+ C
22
+ ]);
23
+ let E = () => {
24
+ let e = !C;
25
+ w(e), _?.(e);
26
+ }, D = x && !C, O = /* @__PURE__ */ r("span", {
27
+ ref: T,
28
+ style: D ? {
29
+ display: "-webkit-box",
30
+ WebkitBoxOrient: "vertical",
31
+ WebkitLineClamp: p,
32
+ overflow: "hidden"
33
+ } : void 0,
34
+ className: e([u]),
35
+ children: f
36
+ });
37
+ return /* @__PURE__ */ i("span", {
38
+ ...y,
39
+ className: e([l, v]),
40
+ children: [m && D ? /* @__PURE__ */ r(n, {
41
+ content: f,
42
+ children: O
43
+ }) : O, h && x && /* @__PURE__ */ r("button", {
44
+ type: "button",
45
+ "aria-expanded": C,
46
+ onClick: E,
47
+ className: e([d]),
48
+ children: C ? b.collapse : b.expand
49
+ })]
50
+ });
51
+ }
52
+ //#endregion
53
+ export { f as default };
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ import e from "./Ellipsis.js";
3
+ export { e as Ellipsis };