@bug-on/md3-react 2.0.2 → 3.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 (296) hide show
  1. package/.turbo/turbo-build.log +33 -0
  2. package/CHANGELOG.md +55 -0
  3. package/dist/index.css +23 -0
  4. package/dist/index.css.d.ts +2 -0
  5. package/dist/index.d.mts +6127 -0
  6. package/dist/index.d.ts +6127 -69
  7. package/dist/index.js +2536 -665
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +2443 -603
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/material-symbols-cdn.css.d.ts +2 -0
  12. package/dist/material-symbols-self-hosted.css.d.ts +2 -0
  13. package/dist/typography.css.d.ts +2 -0
  14. package/package.json +23 -19
  15. package/scripts/copy-assets.js +82 -0
  16. package/src/assets/fonts/GoogleSansFlex-VariableFont.woff2 +0 -0
  17. package/src/assets/fonts/MaterialSymbolsOutlined-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
  18. package/src/assets/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
  19. package/src/assets/fonts/MaterialSymbolsSharp-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
  20. package/src/assets/loading-indicator.svg +19 -0
  21. package/src/assets/material-symbols-cdn.css +65 -0
  22. package/src/assets/material-symbols-self-hosted.css +90 -0
  23. package/src/css.d.ts +20 -0
  24. package/{dist/hooks/index.d.ts → src/hooks/index.ts} +1 -0
  25. package/src/hooks/useClickOutside.ts +37 -0
  26. package/src/hooks/useMediaQuery.ts +28 -0
  27. package/src/hooks/useRipple.ts +88 -0
  28. package/src/index.css +23 -0
  29. package/src/index.ts +349 -0
  30. package/src/lib/material-symbols-preconnect.tsx +82 -0
  31. package/src/lib/theme-utils.ts +180 -0
  32. package/src/lib/utils.ts +6 -0
  33. package/src/test/button.test.tsx +59 -0
  34. package/src/test/icon.test.tsx +91 -0
  35. package/src/test/loading-indicator.test.tsx +128 -0
  36. package/src/test/progress-indicator.test.tsx +306 -0
  37. package/src/test/setup.ts +80 -0
  38. package/src/test/typography.test.tsx +206 -0
  39. package/src/types/index.ts +7 -0
  40. package/src/types/md3.ts +31 -0
  41. package/src/ui/Text.tsx +60 -0
  42. package/src/ui/__snapshots__/divider.test.tsx.snap +63 -0
  43. package/src/ui/app-bar/app-bar-column.tsx +99 -0
  44. package/src/ui/app-bar/app-bar-item-button.tsx +71 -0
  45. package/src/ui/app-bar/app-bar-items.test.tsx +89 -0
  46. package/src/ui/app-bar/app-bar-overflow-indicator.tsx +108 -0
  47. package/src/ui/app-bar/app-bar-row.tsx +104 -0
  48. package/src/ui/app-bar/app-bar.test.tsx +87 -0
  49. package/src/ui/app-bar/app-bar.tokens.ts +223 -0
  50. package/src/ui/app-bar/app-bar.types.ts +441 -0
  51. package/src/ui/app-bar/bottom-app-bar.test.tsx +42 -0
  52. package/src/ui/app-bar/bottom-app-bar.tsx +84 -0
  53. package/src/ui/app-bar/docked-toolbar.test.tsx +34 -0
  54. package/src/ui/app-bar/docked-toolbar.tsx +54 -0
  55. package/src/ui/app-bar/flexible-app-bar.test.tsx +75 -0
  56. package/src/ui/app-bar/hooks/use-app-bar-scroll.ts +110 -0
  57. package/src/ui/app-bar/hooks/use-flexible-app-bar.ts +123 -0
  58. package/{dist/ui/app-bar/index.d.ts → src/ui/app-bar/index.ts} +35 -2
  59. package/src/ui/app-bar/large-flexible-app-bar.tsx +165 -0
  60. package/src/ui/app-bar/medium-flexible-app-bar.tsx +167 -0
  61. package/src/ui/app-bar/search-app-bar.test.tsx +49 -0
  62. package/src/ui/app-bar/search-app-bar.tsx +176 -0
  63. package/src/ui/app-bar/search-view.tsx +227 -0
  64. package/src/ui/app-bar/small-app-bar.test.tsx +48 -0
  65. package/src/ui/app-bar/small-app-bar.tsx +203 -0
  66. package/src/ui/badge.test.tsx +345 -0
  67. package/src/ui/badge.tsx +282 -0
  68. package/src/ui/button-group.test.tsx +71 -0
  69. package/src/ui/button-group.tsx +350 -0
  70. package/src/ui/button.test.tsx +297 -0
  71. package/src/ui/button.tsx +669 -0
  72. package/src/ui/card.test.tsx +187 -0
  73. package/src/ui/card.tsx +259 -0
  74. package/src/ui/checkbox.test.tsx +423 -0
  75. package/src/ui/checkbox.tsx +525 -0
  76. package/src/ui/chip.test.tsx +292 -0
  77. package/src/ui/chip.tsx +548 -0
  78. package/src/ui/code-block.tsx +219 -0
  79. package/src/ui/dialog.test.tsx +300 -0
  80. package/src/ui/dialog.tsx +384 -0
  81. package/src/ui/divider.test.tsx +314 -0
  82. package/src/ui/divider.tsx +412 -0
  83. package/src/ui/drawer.tsx +240 -0
  84. package/src/ui/fab-menu.test.tsx +494 -0
  85. package/src/ui/fab-menu.tsx +739 -0
  86. package/src/ui/fab.test.tsx +232 -0
  87. package/src/ui/fab.tsx +505 -0
  88. package/src/ui/icon-button.test.tsx +515 -0
  89. package/src/ui/icon-button.tsx +525 -0
  90. package/src/ui/icon.test.tsx +197 -0
  91. package/src/ui/icon.tsx +179 -0
  92. package/src/ui/loading-indicator.test.tsx +73 -0
  93. package/src/ui/loading-indicator.tsx +312 -0
  94. package/src/ui/menu/context-menu.tsx +275 -0
  95. package/src/ui/menu/index.ts +77 -0
  96. package/src/ui/menu/menu-animations.ts +102 -0
  97. package/src/ui/menu/menu-context.tsx +99 -0
  98. package/src/ui/menu/menu-divider.tsx +47 -0
  99. package/src/ui/menu/menu-group.tsx +200 -0
  100. package/src/ui/menu/menu-item.tsx +294 -0
  101. package/src/ui/menu/menu-tokens.ts +208 -0
  102. package/src/ui/menu/menu-types.ts +313 -0
  103. package/src/ui/menu/menu.test.tsx +624 -0
  104. package/src/ui/menu/menu.tsx +289 -0
  105. package/src/ui/menu/sub-menu.tsx +223 -0
  106. package/src/ui/menu/vertical-menu.tsx +382 -0
  107. package/src/ui/navigation-rail.test.tsx +404 -0
  108. package/src/ui/navigation-rail.tsx +604 -0
  109. package/src/ui/progress-indicator/circular.tsx +248 -0
  110. package/src/ui/progress-indicator/hooks.ts +51 -0
  111. package/{dist/ui/progress-indicator/index.d.ts → src/ui/progress-indicator/index.tsx} +20 -2
  112. package/src/ui/progress-indicator/linear-flat.tsx +83 -0
  113. package/src/ui/progress-indicator/linear-wavy.tsx +243 -0
  114. package/src/ui/progress-indicator/linear.tsx +143 -0
  115. package/src/ui/progress-indicator/types.ts +158 -0
  116. package/src/ui/progress-indicator/utils.ts +73 -0
  117. package/src/ui/radio-button.test.tsx +407 -0
  118. package/src/ui/radio-button.tsx +551 -0
  119. package/src/ui/ripple.test.tsx +72 -0
  120. package/src/ui/ripple.tsx +234 -0
  121. package/src/ui/scroll-area.test.tsx +58 -0
  122. package/src/ui/scroll-area.tsx +139 -0
  123. package/src/ui/search/animated-placeholder.tsx +145 -0
  124. package/src/ui/search/hooks/use-search-keyboard.test.ts +202 -0
  125. package/src/ui/search/hooks/use-search-keyboard.ts +104 -0
  126. package/src/ui/search/hooks/use-search-view-focus.test.ts +96 -0
  127. package/src/ui/search/hooks/use-search-view-focus.ts +24 -0
  128. package/src/ui/search/index.ts +44 -0
  129. package/src/ui/search/search-bar.tsx +220 -0
  130. package/src/ui/search/search-context.tsx +42 -0
  131. package/src/ui/search/search-view-docked.tsx +194 -0
  132. package/src/ui/search/search-view-fullscreen.tsx +247 -0
  133. package/src/ui/search/search.test.tsx +233 -0
  134. package/src/ui/search/search.tokens.ts +134 -0
  135. package/src/ui/search/search.tsx +131 -0
  136. package/src/ui/search/search.types.ts +154 -0
  137. package/src/ui/search/trailing-action.tsx +49 -0
  138. package/src/ui/shared/constants.ts +122 -0
  139. package/{dist/ui/shared/touch-target.d.ts → src/ui/shared/touch-target.tsx} +13 -1
  140. package/src/ui/slider/hooks/useSliderMath.ts +195 -0
  141. package/{dist/ui/slider/index.d.ts → src/ui/slider/index.ts} +12 -1
  142. package/src/ui/slider/range-slider.tsx +561 -0
  143. package/src/ui/slider/slider-thumb.tsx +379 -0
  144. package/src/ui/slider/slider-track.tsx +912 -0
  145. package/src/ui/slider/slider.tokens.ts +189 -0
  146. package/src/ui/slider/slider.tsx +259 -0
  147. package/src/ui/slider/slider.types.ts +288 -0
  148. package/src/ui/snackbar/index.ts +20 -0
  149. package/src/ui/snackbar/snackbar.test.tsx +338 -0
  150. package/src/ui/snackbar/snackbar.tsx +476 -0
  151. package/{dist/ui/switch/index.d.ts → src/ui/switch/index.ts} +1 -0
  152. package/src/ui/switch/switch.stories.tsx +309 -0
  153. package/src/ui/switch/switch.test.tsx +243 -0
  154. package/src/ui/switch/switch.tokens.ts +89 -0
  155. package/src/ui/switch/switch.tsx +504 -0
  156. package/src/ui/switch/switch.types.ts +62 -0
  157. package/{dist/ui/tabs/index.d.ts → src/ui/tabs/index.ts} +8 -1
  158. package/src/ui/tabs/tab.tsx +407 -0
  159. package/src/ui/tabs/tabs-content.tsx +89 -0
  160. package/src/ui/tabs/tabs-list.tsx +146 -0
  161. package/src/ui/tabs/tabs.test.tsx +290 -0
  162. package/src/ui/tabs/tabs.tokens.ts +121 -0
  163. package/src/ui/tabs/tabs.tsx +229 -0
  164. package/src/ui/tabs/tabs.types.ts +185 -0
  165. package/{dist/ui/text-field/index.d.ts → src/ui/text-field/index.ts} +8 -1
  166. package/src/ui/text-field/subcomponents/active-indicator.tsx +67 -0
  167. package/src/ui/text-field/subcomponents/floating-label.tsx +161 -0
  168. package/src/ui/text-field/subcomponents/leading-icon.tsx +46 -0
  169. package/src/ui/text-field/subcomponents/outline-container.tsx +170 -0
  170. package/src/ui/text-field/subcomponents/prefix-suffix.tsx +59 -0
  171. package/src/ui/text-field/subcomponents/supporting-text.tsx +145 -0
  172. package/src/ui/text-field/subcomponents/trailing-icon.tsx +199 -0
  173. package/src/ui/text-field/text-field.test.tsx +454 -0
  174. package/src/ui/text-field/text-field.tokens.ts +104 -0
  175. package/src/ui/text-field/text-field.tsx +548 -0
  176. package/src/ui/text-field/text-field.types.ts +180 -0
  177. package/src/ui/theme-provider/index.tsx +190 -0
  178. package/src/ui/toc.test.tsx +108 -0
  179. package/src/ui/toc.tsx +172 -0
  180. package/src/ui/tooltip/plain-tooltip.tsx +63 -0
  181. package/src/ui/tooltip/rich-tooltip.tsx +94 -0
  182. package/src/ui/tooltip/tooltip-box.tsx +266 -0
  183. package/src/ui/tooltip/tooltip-caret-shape.tsx +68 -0
  184. package/src/ui/tooltip/tooltip.tokens.ts +26 -0
  185. package/src/ui/tooltip/tooltip.types.ts +70 -0
  186. package/src/ui/tooltip/use-tooltip-position.ts +208 -0
  187. package/src/ui/tooltip/use-tooltip-state.ts +41 -0
  188. package/src/ui/typography/__tests__/typography.test.tsx +170 -0
  189. package/{dist/ui/typography/index.d.ts → src/ui/typography/index.ts} +21 -3
  190. package/src/ui/typography/type-scale-tokens.ts +205 -0
  191. package/src/ui/typography/typography-key-tokens.ts +43 -0
  192. package/src/ui/typography/typography-tokens.ts +360 -0
  193. package/src/ui/typography/typography.css +22 -0
  194. package/src/ui/typography/typography.tsx +559 -0
  195. package/test-render.tsx +4 -0
  196. package/test-shadow.html +26 -0
  197. package/test_output.txt +164 -0
  198. package/test_output_v2.txt +5 -0
  199. package/tsconfig.build.json +10 -0
  200. package/tsconfig.json +18 -0
  201. package/tsup.config.ts +20 -0
  202. package/vitest.config.ts +11 -0
  203. package/dist/hooks/useMediaQuery.d.ts +0 -11
  204. package/dist/hooks/useRipple.d.ts +0 -26
  205. package/dist/lib/material-symbols-preconnect.d.ts +0 -42
  206. package/dist/lib/theme-utils.d.ts +0 -63
  207. package/dist/lib/utils.d.ts +0 -2
  208. package/dist/types/index.d.ts +0 -1
  209. package/dist/types/md3.d.ts +0 -14
  210. package/dist/ui/app-bar/app-bar-column.d.ts +0 -28
  211. package/dist/ui/app-bar/app-bar-item-button.d.ts +0 -16
  212. package/dist/ui/app-bar/app-bar-overflow-indicator.d.ts +0 -18
  213. package/dist/ui/app-bar/app-bar-row.d.ts +0 -36
  214. package/dist/ui/app-bar/app-bar.tokens.d.ts +0 -184
  215. package/dist/ui/app-bar/app-bar.types.d.ts +0 -392
  216. package/dist/ui/app-bar/bottom-app-bar.d.ts +0 -31
  217. package/dist/ui/app-bar/docked-toolbar.d.ts +0 -25
  218. package/dist/ui/app-bar/hooks/use-app-bar-scroll.d.ts +0 -42
  219. package/dist/ui/app-bar/hooks/use-flexible-app-bar.d.ts +0 -37
  220. package/dist/ui/app-bar/large-flexible-app-bar.d.ts +0 -26
  221. package/dist/ui/app-bar/medium-flexible-app-bar.d.ts +0 -28
  222. package/dist/ui/app-bar/search-app-bar.d.ts +0 -43
  223. package/dist/ui/app-bar/search-view.d.ts +0 -54
  224. package/dist/ui/app-bar/small-app-bar.d.ts +0 -37
  225. package/dist/ui/badge.d.ts +0 -125
  226. package/dist/ui/button-group.d.ts +0 -59
  227. package/dist/ui/button.d.ts +0 -148
  228. package/dist/ui/card.d.ts +0 -62
  229. package/dist/ui/checkbox.d.ts +0 -82
  230. package/dist/ui/chip.d.ts +0 -110
  231. package/dist/ui/code-block.d.ts +0 -14
  232. package/dist/ui/dialog.d.ts +0 -111
  233. package/dist/ui/divider.d.ts +0 -164
  234. package/dist/ui/drawer.d.ts +0 -39
  235. package/dist/ui/dropdown.d.ts +0 -29
  236. package/dist/ui/fab-menu.d.ts +0 -204
  237. package/dist/ui/fab.d.ts +0 -162
  238. package/dist/ui/icon-button.d.ts +0 -131
  239. package/dist/ui/icon.d.ts +0 -88
  240. package/dist/ui/loading-indicator.d.ts +0 -42
  241. package/dist/ui/navigation-rail.d.ts +0 -29
  242. package/dist/ui/progress-indicator/circular.d.ts +0 -3
  243. package/dist/ui/progress-indicator/hooks.d.ts +0 -3
  244. package/dist/ui/progress-indicator/linear-flat.d.ts +0 -10
  245. package/dist/ui/progress-indicator/linear-wavy.d.ts +0 -18
  246. package/dist/ui/progress-indicator/linear.d.ts +0 -3
  247. package/dist/ui/progress-indicator/types.d.ts +0 -151
  248. package/dist/ui/progress-indicator/utils.d.ts +0 -3
  249. package/dist/ui/radio-button.d.ts +0 -106
  250. package/dist/ui/ripple.d.ts +0 -126
  251. package/dist/ui/scroll-area.d.ts +0 -27
  252. package/dist/ui/shared/constants.d.ts +0 -86
  253. package/dist/ui/slider/hooks/useSliderMath.d.ts +0 -101
  254. package/dist/ui/slider/range-slider.d.ts +0 -47
  255. package/dist/ui/slider/slider-thumb.d.ts +0 -33
  256. package/dist/ui/slider/slider-track.d.ts +0 -25
  257. package/dist/ui/slider/slider.d.ts +0 -60
  258. package/dist/ui/slider/slider.tokens.d.ts +0 -151
  259. package/dist/ui/slider/slider.types.d.ts +0 -259
  260. package/dist/ui/snackbar/index.d.ts +0 -6
  261. package/dist/ui/snackbar/snackbar.d.ts +0 -197
  262. package/dist/ui/switch/switch.d.ts +0 -30
  263. package/dist/ui/switch/switch.stories.d.ts +0 -48
  264. package/dist/ui/switch/switch.tokens.d.ts +0 -67
  265. package/dist/ui/switch/switch.types.d.ts +0 -59
  266. package/dist/ui/tabs/tab.d.ts +0 -43
  267. package/dist/ui/tabs/tabs-content.d.ts +0 -36
  268. package/dist/ui/tabs/tabs-list.d.ts +0 -40
  269. package/dist/ui/tabs/tabs.d.ts +0 -60
  270. package/dist/ui/tabs/tabs.tokens.d.ts +0 -94
  271. package/dist/ui/tabs/tabs.types.d.ts +0 -172
  272. package/dist/ui/text-field/subcomponents/active-indicator.d.ts +0 -24
  273. package/dist/ui/text-field/subcomponents/floating-label.d.ts +0 -43
  274. package/dist/ui/text-field/subcomponents/leading-icon.d.ts +0 -23
  275. package/dist/ui/text-field/subcomponents/outline-container.d.ts +0 -42
  276. package/dist/ui/text-field/subcomponents/prefix-suffix.d.ts +0 -24
  277. package/dist/ui/text-field/subcomponents/supporting-text.d.ts +0 -37
  278. package/dist/ui/text-field/subcomponents/trailing-icon.d.ts +0 -41
  279. package/dist/ui/text-field/text-field.d.ts +0 -49
  280. package/dist/ui/text-field/text-field.tokens.d.ts +0 -76
  281. package/dist/ui/text-field/text-field.types.d.ts +0 -126
  282. package/dist/ui/theme-provider/index.d.ts +0 -48
  283. package/dist/ui/toc.d.ts +0 -80
  284. package/dist/ui/tooltip/plain-tooltip.d.ts +0 -2
  285. package/dist/ui/tooltip/rich-tooltip.d.ts +0 -2
  286. package/dist/ui/tooltip/tooltip-box.d.ts +0 -2
  287. package/dist/ui/tooltip/tooltip-caret-shape.d.ts +0 -9
  288. package/dist/ui/tooltip/tooltip.tokens.d.ts +0 -26
  289. package/dist/ui/tooltip/tooltip.types.d.ts +0 -56
  290. package/dist/ui/tooltip/use-tooltip-position.d.ts +0 -8
  291. package/dist/ui/tooltip/use-tooltip-state.d.ts +0 -2
  292. package/dist/ui/typography/type-scale-tokens.d.ts +0 -162
  293. package/dist/ui/typography/typography-key-tokens.d.ts +0 -40
  294. package/dist/ui/typography/typography-tokens.d.ts +0 -220
  295. package/dist/ui/typography/typography.d.ts +0 -265
  296. /package/{dist/ui/tooltip/index.d.ts → src/ui/tooltip/index.ts} +0 -0
@@ -1,10 +0,0 @@
1
- import * as React from "react";
2
- export declare const FlatLinearTrack: React.NamedExoticComponent<{
3
- trackHeight: number;
4
- activeColor: string;
5
- trackColor: string;
6
- value?: number;
7
- isRtl: boolean;
8
- gapSize: number;
9
- crawlerSpeed: number;
10
- }>;
@@ -1,18 +0,0 @@
1
- import * as React from "react";
2
- export declare const WavyLinearTrack: React.NamedExoticComponent<{
3
- trackHeight: number;
4
- svgHeight: number;
5
- amplitude: number;
6
- wavelength: number;
7
- indeterminateWavelength: number;
8
- activeColor: string;
9
- trackColor: string;
10
- value?: number;
11
- isRtl: boolean;
12
- gapSize: number;
13
- waveSpeed: number;
14
- crawlerSpeed: number;
15
- determinateAnimation: "md3" | "continuous";
16
- indeterminateAnimation: "md3" | "continuous";
17
- trackShape: "flat" | "wavy";
18
- }>;
@@ -1,3 +0,0 @@
1
- import * as React from "react";
2
- import type { LinearProgressProps } from "./types";
3
- export declare const LinearProgress: React.ForwardRefExoticComponent<LinearProgressProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,151 +0,0 @@
1
- import type * as React from "react";
2
- export interface ProgressBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
3
- /**
4
- * Giá trị phần trăm tiến trình hiện tại (từ 0 đến 100).
5
- * Nếu truyền giá trị này, tiến trình sẽ hiển thị ở trạng thái Determinate.
6
- * Nếu bỏ trống (undefined), tiến trình sẽ tự động ở trạng thái Indeterminate.
7
- *
8
- * @example
9
- * ```tsx
10
- * <ProgressIndicator value={45} aria-label="Loading profile..." />
11
- * ```
12
- */
13
- value?: number;
14
- /**
15
- * Nhan đề mô tả mục đích của thanh tiến trình dành cho screen readers (bắt buộc).
16
- */
17
- "aria-label": string;
18
- /**
19
- * Độ dày của track (đường nền) của thanh tiến trình (đơn vị: px).
20
- * - Với Linear: là chiều cao của thanh.
21
- * - Với Circular: là độ dày của viền hình tròn.
22
- *
23
- * @example
24
- * trackHeight={8} // Dày hơn bình thường
25
- */
26
- trackHeight?: number;
27
- /**
28
- * Màu sắc của phần tiến trình (phần đã hoàn thành).
29
- * Mặc định mượn màu `currentColor` của thẻ wrap, để dễ dàng tuỳ biến qua utility class.
30
- *
31
- * @example
32
- * color="var(--md-sys-color-primary)" // Sử dụng custom token
33
- */
34
- color?: string;
35
- /**
36
- * Màu sắc của thanh nền (phần chưa hoàn thành).
37
- * Mặc định sử dụng màu được tính toán từ bề mặt hoặc transparency để tạo sự tinh tế.
38
- */
39
- trackColor?: string;
40
- }
41
- export interface LinearProgressProps extends ProgressBaseProps {
42
- /** Phân loại component sang kiểu dáng Linear (đường thẳng ngang). */
43
- variant: "linear";
44
- /**
45
- * Hình dáng của vạch tiến trình (phần đã hoàn thành).
46
- * - `flat`: Đường nét liền phẳng (mặc định)
47
- * - `wavy`: Đường lượn sóng động
48
- */
49
- shape?: "flat" | "wavy";
50
- /**
51
- * Hình dáng của thanh nền chờ (track).
52
- * - `flat`: Đường nét liền phẳng (mặc định)
53
- * - `wavy`: Đường lượn sóng cố định hoặc động
54
- */
55
- trackShape?: "flat" | "wavy";
56
- /**
57
- * Biên độ sóng (áp dụng khi `shape` hoặc `trackShape` là "wavy").
58
- * Chỉ định độ lượn cao thấp của con sóng.
59
- */
60
- amplitude?: number;
61
- /**
62
- * Chiều dài một nhịp sóng (áp dụng khi `shape` là "wavy" theo determinate).
63
- * Khoảng cách giữa 2 đỉnh sóng kề nhau.
64
- */
65
- wavelength?: number;
66
- /**
67
- * Nhịp sóng dành riêng cho trạng thái chạy liên tục (Indeterminate Wavy).
68
- */
69
- indeterminateWavelength?: number;
70
- /**
71
- * Khoảng hở kết dính giữa cụm vạch đang chạy và thanh nền.
72
- * Cho phép truyền \`0\` để hai thanh chạm sát vào nhau liền mạch.
73
- *
74
- * @example
75
- * ```tsx
76
- * <ProgressIndicator variant="linear" shape="wavy" gapSize={0} /> // Sóng chạm track liền nét
77
- * ```
78
- */
79
- gapSize?: number;
80
- /**
81
- * Tốc độ dao động vỗ của sóng (Multiplier). Mặc định là \`1\`.
82
- * Tăng giá trị (VD: 1.5, 2) để sóng dao động nhanh hơn.
83
- */
84
- waveSpeed?: number;
85
- /**
86
- * Tốc độ lướt / cuộn dải màu dọc trên track (Crawler) đối với trạng thái Indeterminate.
87
- * Mặc định là \`1\`.
88
- */
89
- crawlerSpeed?: number;
90
- /**
91
- * Cấu hình hiệu ứng gợn khi thanh determinate ở mức xấp xỉ mép viền (<= 10% hoặc >= 90%).
92
- * - `md3`: Tự động ép phẳng biên độ sóng thành số 0 một cách mềm mại (Chuẩn Google MD3).
93
- * - `continuous`: Bỏ qua các ràng buộc ép phẳng, con sóng vẫn gợn lấp lóa trên mọi giá trị phần trăm.
94
- *
95
- * @example
96
- * ```tsx
97
- * <ProgressIndicator variant="linear" shape="wavy" determinateAnimation="continuous" />
98
- * ```
99
- */
100
- determinateAnimation?: "md3" | "continuous";
101
- /**
102
- * Kiểu kịch bản tịnh tiến cho thanh Indeterminate.
103
- * - `md3`: Render 2 vạch song song vọt tới & co giãn mô phỏng vật lý (Chuẩn Google MD3).
104
- * - `continuous`: Vạch không ngắt quãng mà tràn lướt vòng lặp mượt mà.
105
- *
106
- * @example
107
- * ```tsx
108
- * <ProgressIndicator variant="linear" indeterminateAnimation="continuous" />
109
- * ```
110
- */
111
- indeterminateAnimation?: "md3" | "continuous";
112
- /**
113
- * Bật/tắt dấm chấm điểm báo kết thúc ở cuối track (Stop Indicator).
114
- * - `true`: Luôn thấy một chấm tròn bé xíu ở cuối đường đi
115
- * - `false`: Tắt hoàn toàn
116
- * - `"auto"`: Chấm tròn chỉ hiển thị và hòa trộn khi progress đạt 100%
117
- */
118
- showStopIndicator?: boolean | "auto";
119
- }
120
- export interface CircularProgressProps extends ProgressBaseProps {
121
- /** Phân loại component sang kiểu dáng Circular (hình tròn khép kín). */
122
- variant: "circular";
123
- /**
124
- * Đường kính hiển thị của vòng biểu đồ, đơn vị px.
125
- *
126
- * @example
127
- * ```tsx
128
- * <ProgressIndicator variant="circular" size={48} aria-label="Loading..." />
129
- * ```
130
- */
131
- size?: number;
132
- /**
133
- * Phong cách nét vẽ của đường viền trong trạng thái trượt.
134
- * - `flat`: Đường nét cứng, vuốt tròn hai đầu stroke.
135
- * - `wavy`: Vệt màu chuyển động rung tạo hình răng cưa/gợn sóng.
136
- */
137
- shape?: "flat" | "wavy";
138
- /**
139
- * Biên độ gợn của trạng thái `wavy` cho vòng tròn.
140
- */
141
- amplitude?: number;
142
- /** Bước sóng bao trọn chu vi hình tròn. */
143
- wavelength?: number;
144
- /** Khoảng hở khe đứt ngang nối đỉnh nét vẽ. */
145
- gapSize?: number;
146
- /**
147
- * Xoay nhanh hay chậm theo số nhân cho Crawler Circular quay Indeterminate.
148
- */
149
- crawlerSpeed?: number;
150
- }
151
- export type ProgressIndicatorProps = LinearProgressProps | CircularProgressProps;
@@ -1,3 +0,0 @@
1
- export declare function easeInOutCubic(x: number): number;
2
- export declare function generateWavyCircularPath(center: number, radius: number, amplitude: number, wavelength: number): string;
3
- export declare function getSinePath(startX: number, endX: number, phase: number, wl: number, amp: number): string;
@@ -1,106 +0,0 @@
1
- /**
2
- * @file radio-button.tsx
3
- * MD3 Expressive RadioButton — single-select with RadioGroup support.
4
- * Spec: https://m3.material.io/components/radio-button/overview
5
- */
6
- import * as React from "react";
7
- /**
8
- * Color variant for `RadioButton`.
9
- * - `"primary"` — standard selection (default)
10
- * - `"error"` — error/invalid state
11
- */
12
- export type RadioButtonColors = "primary" | "error";
13
- /** Props for `RadioButton`. */
14
- export interface RadioButtonProps {
15
- /** Whether this radio is selected. */
16
- selected?: boolean;
17
- /** Initial selected state (uncontrolled). @default false */
18
- defaultSelected?: boolean;
19
- /** Called when user clicks. Pass `null` to disable interaction. */
20
- onClick?: (() => void) | null;
21
- /** Disables the radio — visual disabled state + no interaction. @default false */
22
- disabled?: boolean;
23
- /** Color variant. @default "primary" */
24
- color?: RadioButtonColors;
25
- /** Error state — changes colors to `m3-error`. @default false */
26
- error?: boolean;
27
- /** Adjacent label text. Renders a `<label>` wrapper. */
28
- label?: string;
29
- /** Value used for form submission. */
30
- value?: string;
31
- /** Name for grouping (used in RadioGroup context). */
32
- name?: string;
33
- /** ID for the hidden `<input>`. Auto-generated when `label` is set. */
34
- id?: string;
35
- /** Extra class names on the outermost wrapper. */
36
- className?: string;
37
- /** ARIA label for the radio when no visible label exists. */
38
- "aria-label"?: string;
39
- "aria-labelledby"?: string;
40
- "aria-describedby"?: string;
41
- /** Whether the radio is required for form submission. */
42
- required?: boolean;
43
- /** Ref to the hidden `<input type="radio">`. */
44
- ref?: React.Ref<HTMLInputElement>;
45
- }
46
- /** Props for `RadioGroup`. */
47
- export interface RadioGroupProps {
48
- /** The name attribute shared across all child RadioButtons. */
49
- name: string;
50
- /** The currently selected value (controlled). */
51
- value?: string;
52
- /** Default value (uncontrolled). */
53
- defaultValue?: string;
54
- /** Called when selection changes. */
55
- onValueChange?: (value: string) => void;
56
- /** Disables all radio buttons in the group. */
57
- disabled?: boolean;
58
- /** Error state for the entire group. */
59
- error?: boolean;
60
- /** Label for the group (renders as visually hidden or visible heading). */
61
- label?: string;
62
- /** ID of an external element that labels this group. */
63
- "aria-labelledby"?: string;
64
- /** Direction of layout. @default "vertical" */
65
- orientation?: "horizontal" | "vertical";
66
- /** Whether at least one radio in the group must be selected. */
67
- required?: boolean;
68
- children: React.ReactNode;
69
- className?: string;
70
- }
71
- /**
72
- * MD3 Expressive RadioButton component.
73
- *
74
- * Single-select control. Supports standalone (controlled/uncontrolled) and
75
- * `RadioGroup` context. Animated per MD3 spec: inner dot radius morph,
76
- * outer ring color transition, state layer, and ripple.
77
- *
78
- * @example
79
- * ```tsx
80
- * <RadioButton selected={isSelected} onClick={() => setSelected(true)} label="Option A" />
81
- *
82
- * <RadioGroup name="plan" value={plan} onValueChange={setPlan}>
83
- * <RadioButton value="free" label="Free" />
84
- * <RadioButton value="pro" label="Pro" />
85
- * </RadioGroup>
86
- * ```
87
- * @see https://m3.material.io/components/radio-button/overview
88
- */
89
- export declare const RadioButton: React.NamedExoticComponent<Omit<RadioButtonProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
90
- /**
91
- * MD3 Expressive RadioGroup component.
92
- *
93
- * Groups multiple `RadioButton` components under a shared `name` with keyboard
94
- * navigation (Arrow keys with wrapping) and ARIA `radiogroup` semantics.
95
- *
96
- * @example
97
- * ```tsx
98
- * <RadioGroup name="theme" value={theme} onValueChange={setTheme} label="Theme">
99
- * <RadioButton value="light" label="Light" />
100
- * <RadioButton value="dark" label="Dark" />
101
- * <RadioButton value="system" label="System" />
102
- * </RadioGroup>
103
- * ```
104
- * @see https://m3.material.io/components/radio-button/overview
105
- */
106
- export declare const RadioGroup: React.NamedExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,126 +0,0 @@
1
- import * as React from "react";
2
- /**
3
- * Represents a single ripple wave instance with position and size metadata.
4
- *
5
- * @example
6
- * ```tsx
7
- * const ripple: RippleOrigin = { id: Date.now(), x: 50, y: 30, size: 200 };
8
- * ```
9
- */
10
- export interface RippleOrigin {
11
- /** Unique identifier used as React key and for removal. */
12
- id: number;
13
- /** X coordinate of the pointer event relative to the container's left edge (px). */
14
- x: number;
15
- /** Y coordinate of the pointer event relative to the container's top edge (px). */
16
- y: number;
17
- /**
18
- * Diameter of the ripple circle (px).
19
- * Typically `Math.hypot(width, height) * 2` to ensure it fills the container.
20
- */
21
- size: number;
22
- }
23
- /**
24
- * Props for the `Ripple` presentation component.
25
- */
26
- export interface RippleProps {
27
- /** Active ripple instances to render. Managed by the parent via `useRipple`. */
28
- ripples: RippleOrigin[];
29
- /** Called when a ripple's exit animation completes — remove it from state. */
30
- onRippleDone: (id: number) => void;
31
- /**
32
- * Completely disables the ripple effect.
33
- * Use this when the parent element is disabled or interaction is not desired.
34
- * @default false
35
- */
36
- disabled?: boolean;
37
- /**
38
- * When `true`, the ripple respects the user's OS-level
39
- * `prefers-reduced-motion` accessibility setting and renders nothing if active.
40
- *
41
- * Set to `false` to always show ripples regardless of system preference.
42
- * @default true
43
- */
44
- respectSystemMotion?: boolean;
45
- }
46
- /**
47
- * MD3 Expressive Ripple — animated touch-feedback wave layer.
48
- *
49
- * Renders absolutely-positioned ripple circles inside an `overflow-hidden`
50
- * container. Must be placed as a direct child of the interactive element.
51
- *
52
- * @remarks
53
- * - The parent element **must** have `overflow: hidden` and `position: relative`
54
- * (or equivalent) for clipping to work correctly.
55
- * - Set `disabled` to `true` on parent's disabled state to avoid stale ripples.
56
- * - The ripple color is `currentColor` at 12% opacity — matching MD3 state layer spec.
57
- *
58
- * @example
59
- * ```tsx
60
- * const { ripples, onPointerDown, removeRipple } = useRippleState();
61
- *
62
- * <button onPointerDown={onPointerDown} className="relative overflow-hidden">
63
- * <Ripple ripples={ripples} onRippleDone={removeRipple} />
64
- * Click me
65
- * </button>
66
- * ```
67
- *
68
- * @see {@link useRippleState} for the state management hook
69
- * @see https://m3.material.io/foundations/interaction/states/overview
70
- */
71
- export declare function Ripple({ ripples, onRippleDone, disabled, respectSystemMotion, }: RippleProps): import("react/jsx-runtime").JSX.Element | null;
72
- /**
73
- * Options for configuring `useRippleState` behaviour.
74
- */
75
- export interface UseRippleStateOptions {
76
- /**
77
- * When `true`, the ripple is suppressed — `onPointerDown` becomes a no-op.
78
- * Use this to sync the ripple with the parent element's `disabled` state.
79
- * @default false
80
- */
81
- disabled?: boolean;
82
- }
83
- /**
84
- * `useRippleState` — state manager for MD3 Expressive ripple waves.
85
- *
86
- * Tracks active ripple instances and provides pointer event handlers.
87
- * Pair with the `<Ripple>` component for rendering.
88
- *
89
- * @remarks
90
- * This hook only manages ripple *state* (coordinates, size, lifecycle).
91
- * The actual animation is handled by `<Ripple>` via Framer Motion.
92
- * Respecting `prefers-reduced-motion` is handled by `<Ripple>` itself.
93
- *
94
- * @param options - Configuration options. See {@link UseRippleStateOptions}.
95
- * @returns `{ ripples, onPointerDown, removeRipple }` — bind to the interactive element.
96
- *
97
- * @example
98
- * ```tsx
99
- * function MyButton({ disabled, children }) {
100
- * const { ripples, onPointerDown, removeRipple } = useRippleState({ disabled });
101
- *
102
- * return (
103
- * <button
104
- * disabled={disabled}
105
- * onPointerDown={onPointerDown}
106
- * className="relative overflow-hidden"
107
- * >
108
- * <Ripple ripples={ripples} onRippleDone={removeRipple} disabled={disabled} />
109
- * {children}
110
- * </button>
111
- * );
112
- * }
113
- * ```
114
- *
115
- * @see {@link Ripple} for the rendering component
116
- */
117
- export declare function useRippleState(options?: UseRippleStateOptions): {
118
- ripples: RippleOrigin[];
119
- onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
120
- removeRipple: (id: number) => void;
121
- };
122
- /**
123
- * @deprecated Use `useRippleState` instead. This alias will be removed in a future version.
124
- * @see {@link useRippleState}
125
- */
126
- export declare const useRipple: typeof useRippleState;
@@ -1,27 +0,0 @@
1
- import * as RadixScrollArea from "@radix-ui/react-scroll-area";
2
- import * as React from "react";
3
- /** Radix accepts hover/scroll/always/auto. We add 'none' as a UI-only hide. */
4
- export type ScrollAreaType = "hover" | "scroll" | "always" | "none";
5
- export type ScrollAreaOrientation = "vertical" | "horizontal" | "both";
6
- export interface ScrollAreaProps extends Omit<React.ComponentPropsWithoutRef<typeof RadixScrollArea.Root>, "type"> {
7
- /**
8
- * Controls when the scrollbars are visible.
9
- * - `hover`: Show on hover (default, recommended for desktop)
10
- * - `scroll`: Show only while scrolling (recommended for mobile)
11
- * - `always`: Always visible
12
- * - `none`: Never visible
13
- */
14
- type?: ScrollAreaType;
15
- /**
16
- * The scrollbar orientation to render.
17
- * @default "vertical"
18
- */
19
- orientation?: ScrollAreaOrientation;
20
- /** Delay in ms before scrollbars hide when `type` is `hover` or `scroll`. */
21
- scrollHideDelay?: number;
22
- /** Extra classes applied to the inner viewport element. */
23
- viewportClassName?: string;
24
- }
25
- declare const ScrollArea: React.ForwardRefExoticComponent<ScrollAreaProps & React.RefAttributes<HTMLDivElement>>;
26
- declare const ScrollAreaScrollbar: React.ForwardRefExoticComponent<Omit<RadixScrollArea.ScrollAreaScrollbarProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
27
- export { ScrollArea, ScrollAreaScrollbar };
@@ -1,86 +0,0 @@
1
- /**
2
- * @file shared/constants.ts
3
- *
4
- * Shared animation constants for MD3 Expressive UI components.
5
- * Centralises spring transition configs and motion variant objects to avoid
6
- * duplication across button, icon-button, FAB, and other interactive components.
7
- *
8
- * @see https://m3.material.io/foundations/animation/overview
9
- */
10
- import type { Target, TargetAndTransition, Transition } from "motion/react";
11
- /**
12
- * Fast critically-damped spring — used for border-radius morphing.
13
- *
14
- * - Duration: 200ms
15
- * - Bounce: 0 (no overshoot → prevents negative radius jitter)
16
- *
17
- * @example
18
- * ```tsx
19
- * <m.button transition={{ borderRadius: SPRING_TRANSITION_FAST }}>...</m.button>
20
- * ```
21
- */
22
- export declare const SPRING_TRANSITION_FAST: Transition;
23
- /**
24
- * Standard critically-damped spring — used for icon/content scale animations.
25
- *
26
- * - Duration: 300ms
27
- * - Bounce: 0 (no overshoot)
28
- *
29
- * @example
30
- * ```tsx
31
- * <m.span transition={SPRING_TRANSITION}>...</m.span>
32
- * ```
33
- */
34
- export declare const SPRING_TRANSITION: Transition;
35
- /**
36
- * Framer Motion variants for animating icon spans in/out.
37
- *
38
- * Scale from near-zero → 1 on enter; back to near-zero on exit.
39
- * The near-zero value (0.01) avoids the SMIL freeze bug on Chromium
40
- * that occurs when an element starts at exactly `scale(0)`.
41
- *
42
- * @example
43
- * ```tsx
44
- * <AnimatePresence mode="wait">
45
- * {loading ? (
46
- * <m.span key="loading" {...ICON_SPAN_VARIANTS} transition={SPRING_TRANSITION}>
47
- * <LoadingIndicator />
48
- * </m.span>
49
- * ) : (
50
- * <m.span key="icon" {...ICON_SPAN_VARIANTS} transition={SPRING_TRANSITION}>
51
- * {icon}
52
- * </m.span>
53
- * )}
54
- * </AnimatePresence>
55
- * ```
56
- */
57
- export declare const ICON_SPAN_VARIANTS: {
58
- initial: Target;
59
- animate: TargetAndTransition;
60
- exit: TargetAndTransition;
61
- };
62
- /**
63
- * MD3 Standard easing curve — used for label float, active indicator expand.
64
- * cubic-bezier(0.2, 0, 0, 1)
65
- *
66
- * @see https://m3.material.io/foundations/animation/easing-and-duration
67
- */
68
- export declare const MD3_STANDARD_EASING: [number, number, number, number];
69
- /**
70
- * Duration for floating label transition: 150ms.
71
- * Used when label moves between inline position ↔ floated position.
72
- */
73
- export declare const MD3_LABEL_FLOAT_DURATION = 0.15;
74
- /**
75
- * Duration for active indicator expand/collapse: 200ms.
76
- * Used for the bottom border (filled) and outline (outlined) on focus.
77
- */
78
- export declare const MD3_INDICATOR_DURATION = 0.2;
79
- /**
80
- * Duration for supporting text / error text appear/disappear: 120ms.
81
- */
82
- export declare const MD3_SUPPORTING_DURATION = 0.12;
83
- /**
84
- * Duration for trailing icon appear/disappear (clear button, password toggle): 100ms.
85
- */
86
- export declare const MD3_ICON_SWAP_DURATION = 0.1;
@@ -1,101 +0,0 @@
1
- /**
2
- * @file useSliderMath.ts
3
- * MD3 Expressive Slider — Math utility hook.
4
- *
5
- * Handles all slider math in one place:
6
- * - value coercion to [min, max]
7
- * - step snapping for discrete mode
8
- * - value ↔ percent conversion
9
- * - keyboard delta calculation
10
- * - tick position generation
11
- *
12
- * Exported as a pure hook for testability and reuse in both Slider and RangeSlider.
13
- */
14
- /**
15
- * Clamps `value` to the closed interval `[min, max]`.
16
- *
17
- * @example coerceValue(150, 0, 100) → 100
18
- */
19
- export declare function coerceValue(value: number, min: number, max: number): number;
20
- /**
21
- * Rounds `value` to the nearest multiple of `step` relative to `min`.
22
- * When `step === 0`, returns `value` unchanged (continuous mode).
23
- *
24
- * @example snapToStep(23, 0, 10) → 20
25
- * @example snapToStep(27, 0, 10) → 30
26
- */
27
- export declare function snapToStep(value: number, min: number, step: number): number;
28
- /**
29
- * Converts a raw value to a 0–1 fraction of the [min, max] range.
30
- * Returns 0 when max === min (degenerate range).
31
- *
32
- * @example valueToPercent(50, 0, 100) → 0.5
33
- */
34
- export declare function valueToPercent(value: number, min: number, max: number): number;
35
- /**
36
- * Converts a 0–1 fraction to a value within [min, max], then snaps to step.
37
- * The result is also coerced to [min, max].
38
- *
39
- * @example percentToValue(0.5, 0, 100, 10) → 50
40
- * @example percentToValue(0.23, 0, 100, 10) → 20
41
- */
42
- export declare function percentToValue(percent: number, min: number, max: number, step: number): number;
43
- /**
44
- * Computes the keyboard increment for a given key.
45
- *
46
- * Key mappings per WAI-ARIA Slider pattern:
47
- * - ArrowRight/Up → +step (or +1% of range if continuous)
48
- * - ArrowLeft/Down → -step (or -1% of range)
49
- * - PageUp → +10% of range (snapped to step)
50
- * - PageDown → -10% of range (snapped to step)
51
- * - Home / End → handled by the caller (jump to min/max)
52
- *
53
- * @returns the signed delta to add to current value, or `null` for Home/End.
54
- */
55
- export declare function getKeyboardDelta(key: string, step: number, min: number, max: number): number | null;
56
- /**
57
- * Generates the list of value positions for tick marks.
58
- * Returns an empty array when `step === 0` (continuous mode).
59
- *
60
- * @example generateTicks(0, 100, 10) → [0, 10, 20, ..., 100]
61
- */
62
- export declare function generateTicks(min: number, max: number, step: number): number[];
63
- export interface UseSliderMathOptions {
64
- min: number;
65
- max: number;
66
- step: number;
67
- }
68
- export interface UseSliderMathReturn {
69
- /** Clamp value to [min, max]. */
70
- coerce: (v: number) => number;
71
- /** Snap value to nearest step (no-op if step=0). */
72
- snap: (v: number) => number;
73
- /** Value → percent [0, 1]. */
74
- toPercent: (v: number) => number;
75
- /** Percent [0, 1] → snapped value. */
76
- fromPercent: (pct: number) => number;
77
- /**
78
- * Signed delta for a keyboard key.
79
- * Returns `null` for Home/End (jump to min/max, handled by caller).
80
- */
81
- getKeyDelta: (key: string) => number | null;
82
- /** Tick positions. Empty array in continuous mode. */
83
- ticks: number[];
84
- }
85
- /**
86
- * Math utility hook for MD3 Slider components.
87
- *
88
- * Memoizes all math functions against `min`, `max`, `step` changes.
89
- * Use this in both `<Slider>` and `<RangeSlider>` to share logic.
90
- *
91
- * @example
92
- * ```ts
93
- * const { coerce, snap, toPercent, fromPercent, getKeyDelta, ticks } =
94
- * useSliderMath({ min: 0, max: 100, step: 10 });
95
- *
96
- * const percent = toPercent(value); // → 0.5 for value=50
97
- * const newValue = fromPercent(dragPercent); // → 50
98
- * const delta = getKeyDelta("ArrowRight"); // → 10
99
- * ```
100
- */
101
- export declare function useSliderMath({ min, max, step, }: UseSliderMathOptions): UseSliderMathReturn;