@bug-on/m3-expressive 1.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.
- package/CHANGELOG.md +110 -0
- package/README.md +110 -0
- package/dist/assets/fonts/GoogleSansFlex-VariableFont.woff2 +0 -0
- package/dist/assets/fonts/MaterialSymbolsOutlined-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsRounded-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/fonts/MaterialSymbolsSharp-VariableFont_FILL,GRAD,opsz,wght.ttf +0 -0
- package/dist/assets/loading-indicator.svg +19 -0
- package/dist/assets/material-symbols-cdn.css +65 -0
- package/dist/assets/material-symbols-self-hosted.css +94 -0
- package/dist/buttons.d.mts +180 -0
- package/dist/buttons.d.ts +180 -0
- package/dist/buttons.js +4282 -0
- package/dist/buttons.js.map +1 -0
- package/dist/buttons.mjs +4227 -0
- package/dist/buttons.mjs.map +1 -0
- package/dist/core.d.mts +422 -0
- package/dist/core.d.ts +422 -0
- package/dist/core.js +2581 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +2547 -0
- package/dist/core.mjs.map +1 -0
- package/dist/feedback.d.mts +600 -0
- package/dist/feedback.d.ts +600 -0
- package/dist/feedback.js +2357 -0
- package/dist/feedback.js.map +1 -0
- package/dist/feedback.mjs +2321 -0
- package/dist/feedback.mjs.map +1 -0
- package/dist/forms.d.mts +40 -0
- package/dist/forms.d.ts +40 -0
- package/dist/forms.js +4263 -0
- package/dist/forms.js.map +1 -0
- package/dist/forms.mjs +4228 -0
- package/dist/forms.mjs.map +1 -0
- package/dist/icon-button-D-gs0gfj.d.mts +136 -0
- package/dist/icon-button-D-gs0gfj.d.ts +136 -0
- package/dist/index.css +309 -0
- package/dist/index.css.d.ts +2 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23972 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +23668 -0
- package/dist/index.mjs.map +1 -0
- package/dist/layout.d.mts +610 -0
- package/dist/layout.d.ts +610 -0
- package/dist/layout.js +5091 -0
- package/dist/layout.js.map +1 -0
- package/dist/layout.mjs +5042 -0
- package/dist/layout.mjs.map +1 -0
- package/dist/material-symbols-cdn.css +65 -0
- package/dist/material-symbols-cdn.css.d.ts +2 -0
- package/dist/material-symbols-self-hosted.css +94 -0
- package/dist/material-symbols-self-hosted.css.d.ts +2 -0
- package/dist/md3-DFhj-NZj.d.mts +17 -0
- package/dist/md3-DFhj-NZj.d.ts +17 -0
- package/dist/navigation.d.mts +2766 -0
- package/dist/navigation.d.ts +2766 -0
- package/dist/navigation.js +6684 -0
- package/dist/navigation.js.map +1 -0
- package/dist/navigation.mjs +6573 -0
- package/dist/navigation.mjs.map +1 -0
- package/dist/overlays.d.mts +161 -0
- package/dist/overlays.d.ts +161 -0
- package/dist/overlays.js +3298 -0
- package/dist/overlays.js.map +1 -0
- package/dist/overlays.mjs +3244 -0
- package/dist/overlays.mjs.map +1 -0
- package/dist/pickers.d.mts +1074 -0
- package/dist/pickers.d.ts +1074 -0
- package/dist/pickers.js +4240 -0
- package/dist/pickers.js.map +1 -0
- package/dist/pickers.mjs +4200 -0
- package/dist/pickers.mjs.map +1 -0
- package/dist/plugin.d.mts +1 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/dist/plugin.mjs +3 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/scroll-area-CVS6HyLl.d.mts +33 -0
- package/dist/scroll-area-CVS6HyLl.d.ts +33 -0
- package/dist/shapes.d.mts +1119 -0
- package/dist/shapes.d.ts +1119 -0
- package/dist/shapes.js +2941 -0
- package/dist/shapes.js.map +1 -0
- package/dist/shapes.mjs +2889 -0
- package/dist/shapes.mjs.map +1 -0
- package/dist/side-sheet-modal-BY6VCC8p.d.mts +553 -0
- package/dist/side-sheet-modal-CglP6KYA.d.ts +553 -0
- package/dist/split-button-trailing-uncheckable-C5CLCIKP.d.ts +731 -0
- package/dist/split-button-trailing-uncheckable-MXj_kyNt.d.mts +731 -0
- package/dist/text-field-eAIpz9z1.d.mts +1038 -0
- package/dist/text-field-eAIpz9z1.d.ts +1038 -0
- package/dist/typography-339RV6v7.d.mts +486 -0
- package/dist/typography-339RV6v7.d.ts +486 -0
- package/dist/typography.css +22 -0
- package/dist/typography.css.d.ts +2 -0
- package/package.json +207 -0
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
5
|
+
export { M as MD3ColorStyle, a as MD3Shape, b as MD3Size, P as PolymorphicProps, c as PolymorphicRef } from './md3-DFhj-NZj.js';
|
|
6
|
+
import { a as Typography, F as FontVariationAxes } from './typography-339RV6v7.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* useMediaQuery — Responsive hook chuẩn SSR-safe
|
|
10
|
+
*
|
|
11
|
+
* Tránh hydration mismatch bằng cách khởi tạo với `false`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const isMobile = useMediaQuery('(max-width: 768px)');
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function useMediaQuery(query: string): boolean;
|
|
19
|
+
|
|
20
|
+
interface RippleOptions {
|
|
21
|
+
/** Thời gian hiệu ứng ripple (ms). Mặc định: 600 */
|
|
22
|
+
duration?: number;
|
|
23
|
+
/** Màu ripple. Mặc định: 'currentColor' */
|
|
24
|
+
color?: string;
|
|
25
|
+
/** Opacity. Mặc định: 0.12 (chuẩn MD3) */
|
|
26
|
+
opacity?: number;
|
|
27
|
+
/** Tắt ripple (ví dụ khi disabled) */
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* useRipple — Material Design 3 Expressive Ripple Effect
|
|
32
|
+
*
|
|
33
|
+
* Hook thuần DOM, không phụ thuộc thư viện animation ngoài.
|
|
34
|
+
* Chú ý: Yêu cầu element có `position: relative` và `overflow: hidden`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const { rippleRef, onPointerDown } = useRipple();
|
|
39
|
+
* <button ref={rippleRef} onPointerDown={onPointerDown}>Click me</button>
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function useRipple$1<T extends HTMLElement = HTMLElement>(options?: RippleOptions): {
|
|
43
|
+
rippleRef: React$1.RefObject<T | null>;
|
|
44
|
+
onPointerDown: (event: React.PointerEvent<T>) => void;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* MaterialSymbolsPreconnect
|
|
49
|
+
*
|
|
50
|
+
* Inject preconnect resource hints cho Google Fonts CDN và <head>.
|
|
51
|
+
* Đặt component này CÀNG SỚM CÀNG TỐT trong app tree, lý tưởng là
|
|
52
|
+
* ngay trong <head> hoặc root layout.
|
|
53
|
+
*
|
|
54
|
+
* WHY THIS MATTERS:
|
|
55
|
+
* Nếu @import url() nằm trong CSS file, browser phải:
|
|
56
|
+
* 1. Parse HTML -> download JS bundle -> execute CSS -> gặp @import -> mới bắt đầu connect Google Fonts
|
|
57
|
+
* Preconnect hints cho phép browser bắt đầu TCP handshake + TLS ngay từ bước 1,
|
|
58
|
+
* tiết kiệm 100-500ms connection time tùy network.
|
|
59
|
+
*
|
|
60
|
+
* USAGE:
|
|
61
|
+
* ```tsx
|
|
62
|
+
* // app/layout.tsx (Next.js) hoặc index.html equivalent
|
|
63
|
+
* import { MaterialSymbolsPreconnect } from '@bug-on/m3-expressive';
|
|
64
|
+
*
|
|
65
|
+
* export default function RootLayout({ children }) {
|
|
66
|
+
* return (
|
|
67
|
+
* <html>
|
|
68
|
+
* <head>
|
|
69
|
+
* <MaterialSymbolsPreconnect />
|
|
70
|
+
* </head>
|
|
71
|
+
* <body>{children}</body>
|
|
72
|
+
* </html>
|
|
73
|
+
* );
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* NOTE: Chỉ dùng component này với CDN mode.
|
|
78
|
+
* Với self-hosted fonts thì không cần preconnect đến external origin.
|
|
79
|
+
*/
|
|
80
|
+
interface MaterialSymbolsPreconnectProps {
|
|
81
|
+
/**
|
|
82
|
+
* Mảng các biến thể font Material Symbols cần tải.
|
|
83
|
+
* Chỉ nên chọn các biến thể mà ứng dụng thực sự sử dụng để tiết kiệm băng thông.
|
|
84
|
+
* @default ["outlined"]
|
|
85
|
+
*/
|
|
86
|
+
variants?: Array<"outlined" | "rounded" | "sharp">;
|
|
87
|
+
}
|
|
88
|
+
declare function MaterialSymbolsPreconnect({ variants, }: MaterialSymbolsPreconnectProps): react_jsx_runtime.JSX.Element;
|
|
89
|
+
|
|
90
|
+
type ThemeMode = "light" | "dark" | "system";
|
|
91
|
+
/**
|
|
92
|
+
* Resolves the effective color scheme from a ThemeMode.
|
|
93
|
+
* When mode is "system", reads the OS preference via matchMedia.
|
|
94
|
+
* Returns "light" as the safe default in SSR environments.
|
|
95
|
+
*/
|
|
96
|
+
declare function resolveMode(mode: ThemeMode): "light" | "dark";
|
|
97
|
+
interface MD3ColorScheme {
|
|
98
|
+
primary: string;
|
|
99
|
+
onPrimary: string;
|
|
100
|
+
primaryContainer: string;
|
|
101
|
+
onPrimaryContainer: string;
|
|
102
|
+
inversePrimary: string;
|
|
103
|
+
primaryFixed: string;
|
|
104
|
+
primaryFixedDim: string;
|
|
105
|
+
onPrimaryFixed: string;
|
|
106
|
+
onPrimaryFixedVariant: string;
|
|
107
|
+
secondary: string;
|
|
108
|
+
onSecondary: string;
|
|
109
|
+
secondaryContainer: string;
|
|
110
|
+
onSecondaryContainer: string;
|
|
111
|
+
secondaryFixed: string;
|
|
112
|
+
secondaryFixedDim: string;
|
|
113
|
+
onSecondaryFixed: string;
|
|
114
|
+
onSecondaryFixedVariant: string;
|
|
115
|
+
tertiary: string;
|
|
116
|
+
onTertiary: string;
|
|
117
|
+
tertiaryContainer: string;
|
|
118
|
+
onTertiaryContainer: string;
|
|
119
|
+
tertiaryFixed: string;
|
|
120
|
+
tertiaryFixedDim: string;
|
|
121
|
+
onTertiaryFixed: string;
|
|
122
|
+
onTertiaryFixedVariant: string;
|
|
123
|
+
error: string;
|
|
124
|
+
onError: string;
|
|
125
|
+
errorContainer: string;
|
|
126
|
+
onErrorContainer: string;
|
|
127
|
+
surface: string;
|
|
128
|
+
onSurface: string;
|
|
129
|
+
surfaceVariant: string;
|
|
130
|
+
onSurfaceVariant: string;
|
|
131
|
+
surfaceTint: string;
|
|
132
|
+
surfaceContainerLowest: string;
|
|
133
|
+
surfaceContainerLow: string;
|
|
134
|
+
surfaceContainer: string;
|
|
135
|
+
surfaceContainerHigh: string;
|
|
136
|
+
surfaceContainerHighest: string;
|
|
137
|
+
inverseSurface: string;
|
|
138
|
+
inverseOnSurface: string;
|
|
139
|
+
background: string;
|
|
140
|
+
onBackground: string;
|
|
141
|
+
outline: string;
|
|
142
|
+
outlineVariant: string;
|
|
143
|
+
shadow: string;
|
|
144
|
+
scrim: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Generate a complete MD3 color scheme from a source color hex string.
|
|
148
|
+
* Uses the HCT color space algorithm — same as Material You on Android.
|
|
149
|
+
*/
|
|
150
|
+
declare function generateM3Theme(sourceColorHex: string, mode?: "light" | "dark"): MD3ColorScheme;
|
|
151
|
+
/**
|
|
152
|
+
* Apply an MD3 dynamic color scheme to the document root as CSS custom properties.
|
|
153
|
+
* Sets both `--md-sys-color-*` tokens (used by components) and
|
|
154
|
+
* `--color-m3-*` tokens (used by Tailwind arbitrary values in apps).
|
|
155
|
+
*
|
|
156
|
+
* Also sets `data-theme` attribute for dark mode CSS selectors.
|
|
157
|
+
*/
|
|
158
|
+
declare function applyTheme(sourceColorHex: string, mode?: ThemeMode, root?: HTMLElement): void;
|
|
159
|
+
|
|
160
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Props cho component {@link Icon}.
|
|
164
|
+
*
|
|
165
|
+
* Tất cả các trục biến thiên (variable font axes) được map trực tiếp sang `font-variation-settings`.
|
|
166
|
+
*/
|
|
167
|
+
interface IconProps extends React$1.HTMLAttributes<HTMLSpanElement> {
|
|
168
|
+
/**
|
|
169
|
+
* Tên của Material Symbol theo định dạng snake_case.
|
|
170
|
+
* @example "home", "arrow_forward", "settings"
|
|
171
|
+
* @see https://fonts.google.com/icons
|
|
172
|
+
*/
|
|
173
|
+
name: string;
|
|
174
|
+
/**
|
|
175
|
+
* Kiểu hình học (Geometric style variant) — tương ứng với font family được tải.
|
|
176
|
+
* @default "outlined"
|
|
177
|
+
*/
|
|
178
|
+
variant?: "outlined" | "rounded" | "sharp";
|
|
179
|
+
/**
|
|
180
|
+
* Trục FILL. `0` = outlined (viền), `1` = filled (tràn màu).
|
|
181
|
+
* Có hiệu ứng spring khi `animateFill` là true.
|
|
182
|
+
* @default 0
|
|
183
|
+
*/
|
|
184
|
+
fill?: 0 | 1;
|
|
185
|
+
/**
|
|
186
|
+
* Trục wght — độ dày của nét (stroke weight). Nên khớp với độ dày text xung quanh.
|
|
187
|
+
* @default 400
|
|
188
|
+
*/
|
|
189
|
+
weight?: 100 | 200 | 300 | 400 | 500 | 600 | 700;
|
|
190
|
+
/**
|
|
191
|
+
* Trục GRAD — tinh chỉnh độ dày thị giác mà không ảnh hưởng tới layout.
|
|
192
|
+
* Dùng mức `-25` trên nền tối để bù trừ hiệu ứng phát sáng (halation).
|
|
193
|
+
* @default 0
|
|
194
|
+
*/
|
|
195
|
+
grade?: -50 | -25 | 0 | 100 | 200;
|
|
196
|
+
/**
|
|
197
|
+
* Trục opsz — kích thước quang học (optical size) tính bằng dp. Dùng để thiết lập `font-size` nếu không truyền `size`.
|
|
198
|
+
* Hãy để giá trị khớp với pixel sẽ render ra để thấy chất lượng tốt nhất.
|
|
199
|
+
* @default 24
|
|
200
|
+
*/
|
|
201
|
+
opticalSize?: 20 | 24 | 40 | 48;
|
|
202
|
+
/**
|
|
203
|
+
* Ghi đè trực tiếp `font-size` bằng px. Trục `opsz` vẫn sẽ tuân theo thuộc tính `opticalSize`.
|
|
204
|
+
* @example size={18} opticalSize={20}
|
|
205
|
+
*/
|
|
206
|
+
size?: number | "inherit";
|
|
207
|
+
/**
|
|
208
|
+
* Kích hoạt hiệu ứng spring mượt mà khi chuyển đổi giá trị FILL (sử dụng cấu hình `SPRING_TRANSITION_FAST`).
|
|
209
|
+
* Yêu cầu dependency `motion/react`.
|
|
210
|
+
* @default false
|
|
211
|
+
* @example <Icon name="favorite" fill={isLiked ? 1 : 0} animateFill />
|
|
212
|
+
*/
|
|
213
|
+
animateFill?: boolean;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Component hiển thị Icon bằng Material Symbols (variable font).
|
|
217
|
+
*
|
|
218
|
+
* Hãy đảm bảo đã import CSS chứa font trước khi dùng:
|
|
219
|
+
* ```ts
|
|
220
|
+
* import '@bug-on/m3-expressive/material-symbols.css';
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @remarks
|
|
224
|
+
* - Đặt tên icon dùng snake_case: `"arrow_forward"`, KHÔNG PHẢI `"ArrowForward"`.
|
|
225
|
+
* - Thuộc tính `aria-hidden="true"` được tự động thêm vào — bạn cần thêm label đọc bằng giọng nói (accessible labels) ở phần tử cha.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```tsx
|
|
229
|
+
* // Icon cơ bản
|
|
230
|
+
* <Icon name="home" />
|
|
231
|
+
*
|
|
232
|
+
* // Tùy chỉnh trực quan (filled, nét dày)
|
|
233
|
+
* <Icon name="favorite" variant="rounded" fill={1} weight={300} />
|
|
234
|
+
*
|
|
235
|
+
* // Animate khi trạng thái thay đổi
|
|
236
|
+
* <Icon name="bookmark" fill={saved ? 1 : 0} animateFill />
|
|
237
|
+
*
|
|
238
|
+
* // Đổi kích thước icon cụ thể
|
|
239
|
+
* <Icon name="close" size={18} opticalSize={20} />
|
|
240
|
+
*
|
|
241
|
+
* // Kết hợp với các component khác
|
|
242
|
+
* <Button icon={<Icon name="add" />}>Thêm vào giỏ</Button>
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @see https://fonts.google.com/icons
|
|
246
|
+
* @see https://m3.material.io/styles/icons/overview
|
|
247
|
+
*/
|
|
248
|
+
declare const Icon: React$1.NamedExoticComponent<IconProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Represents a single ripple wave instance with position and size metadata.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```tsx
|
|
255
|
+
* const ripple: RippleOrigin = { id: Date.now(), x: 50, y: 30, size: 200 };
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
interface RippleOrigin {
|
|
259
|
+
/** Unique identifier used as React key and for removal. */
|
|
260
|
+
id: number;
|
|
261
|
+
/** X coordinate of the pointer event relative to the container's left edge (px). */
|
|
262
|
+
x: number;
|
|
263
|
+
/** Y coordinate of the pointer event relative to the container's top edge (px). */
|
|
264
|
+
y: number;
|
|
265
|
+
/**
|
|
266
|
+
* Diameter of the ripple circle (px).
|
|
267
|
+
* Typically `Math.hypot(width, height) * 2` to ensure it fills the container.
|
|
268
|
+
*/
|
|
269
|
+
size: number;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Props for the `Ripple` presentation component.
|
|
273
|
+
*/
|
|
274
|
+
interface RippleProps {
|
|
275
|
+
/** Active ripple instances to render. Managed by the parent via `useRipple`. */
|
|
276
|
+
ripples: RippleOrigin[];
|
|
277
|
+
/** Called when a ripple's exit animation completes — remove it from state. */
|
|
278
|
+
onRippleDone: (id: number) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Completely disables the ripple effect.
|
|
281
|
+
* Use this when the parent element is disabled or interaction is not desired.
|
|
282
|
+
* @default false
|
|
283
|
+
*/
|
|
284
|
+
disabled?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* When `true`, the ripple respects the user's OS-level
|
|
287
|
+
* `prefers-reduced-motion` accessibility setting and renders nothing if active.
|
|
288
|
+
*
|
|
289
|
+
* Set to `false` to always show ripples regardless of system preference.
|
|
290
|
+
* @default true
|
|
291
|
+
*/
|
|
292
|
+
respectSystemMotion?: boolean;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* MD3 Expressive Ripple — animated touch-feedback wave layer.
|
|
296
|
+
*
|
|
297
|
+
* Renders absolutely-positioned ripple circles inside an `overflow-hidden`
|
|
298
|
+
* container. Must be placed as a direct child of the interactive element.
|
|
299
|
+
*
|
|
300
|
+
* @remarks
|
|
301
|
+
* - The parent element **must** have `overflow: hidden` and `position: relative`
|
|
302
|
+
* (or equivalent) for clipping to work correctly.
|
|
303
|
+
* - Set `disabled` to `true` on parent's disabled state to avoid stale ripples.
|
|
304
|
+
* - The ripple color is `currentColor` at 12% opacity — matching MD3 state layer spec.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```tsx
|
|
308
|
+
* const { ripples, onPointerDown, removeRipple } = useRippleState();
|
|
309
|
+
*
|
|
310
|
+
* <button onPointerDown={onPointerDown} className="relative overflow-hidden">
|
|
311
|
+
* <Ripple ripples={ripples} onRippleDone={removeRipple} />
|
|
312
|
+
* Click me
|
|
313
|
+
* </button>
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @see {@link useRippleState} for the state management hook
|
|
317
|
+
* @see https://m3.material.io/foundations/interaction/states/overview
|
|
318
|
+
*/
|
|
319
|
+
declare function Ripple({ ripples, onRippleDone, disabled, respectSystemMotion, }: RippleProps): react_jsx_runtime.JSX.Element | null;
|
|
320
|
+
/**
|
|
321
|
+
* Options for configuring `useRippleState` behaviour.
|
|
322
|
+
*/
|
|
323
|
+
interface UseRippleStateOptions {
|
|
324
|
+
/**
|
|
325
|
+
* When `true`, the ripple is suppressed — `onPointerDown` becomes a no-op.
|
|
326
|
+
* Use this to sync the ripple with the parent element's `disabled` state.
|
|
327
|
+
* @default false
|
|
328
|
+
*/
|
|
329
|
+
disabled?: boolean;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* `useRippleState` — state manager for MD3 Expressive ripple waves.
|
|
333
|
+
*
|
|
334
|
+
* Tracks active ripple instances and provides pointer event handlers.
|
|
335
|
+
* Pair with the `<Ripple>` component for rendering.
|
|
336
|
+
*
|
|
337
|
+
* @remarks
|
|
338
|
+
* This hook only manages ripple *state* (coordinates, size, lifecycle).
|
|
339
|
+
* The actual animation is handled by `<Ripple>` via Framer Motion.
|
|
340
|
+
* Respecting `prefers-reduced-motion` is handled by `<Ripple>` itself.
|
|
341
|
+
*
|
|
342
|
+
* @param options - Configuration options. See {@link UseRippleStateOptions}.
|
|
343
|
+
* @returns `{ ripples, onPointerDown, removeRipple }` — bind to the interactive element.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```tsx
|
|
347
|
+
* function MyButton({ disabled, children }) {
|
|
348
|
+
* const { ripples, onPointerDown, removeRipple } = useRippleState({ disabled });
|
|
349
|
+
*
|
|
350
|
+
* return (
|
|
351
|
+
* <button
|
|
352
|
+
* disabled={disabled}
|
|
353
|
+
* onPointerDown={onPointerDown}
|
|
354
|
+
* className="relative overflow-hidden"
|
|
355
|
+
* >
|
|
356
|
+
* <Ripple ripples={ripples} onRippleDone={removeRipple} disabled={disabled} />
|
|
357
|
+
* {children}
|
|
358
|
+
* </button>
|
|
359
|
+
* );
|
|
360
|
+
* }
|
|
361
|
+
* ```
|
|
362
|
+
*
|
|
363
|
+
* @see {@link Ripple} for the rendering component
|
|
364
|
+
*/
|
|
365
|
+
declare function useRippleState(options?: UseRippleStateOptions): {
|
|
366
|
+
ripples: RippleOrigin[];
|
|
367
|
+
onPointerDown: (e: React$1.PointerEvent<HTMLElement>) => void;
|
|
368
|
+
removeRipple: (id: number) => void;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* @deprecated Use `useRippleState` instead. This alias will be removed in a future version.
|
|
372
|
+
* @see {@link useRippleState}
|
|
373
|
+
*/
|
|
374
|
+
declare const useRipple: typeof useRippleState;
|
|
375
|
+
|
|
376
|
+
interface ThemeContextValue {
|
|
377
|
+
sourceColor: string;
|
|
378
|
+
setSourceColor: (color: string) => void;
|
|
379
|
+
mode: ThemeMode;
|
|
380
|
+
setMode: (mode: ThemeMode) => void;
|
|
381
|
+
/** The resolved color scheme actually applied — always "light" or "dark". */
|
|
382
|
+
effectiveMode: "light" | "dark";
|
|
383
|
+
}
|
|
384
|
+
interface MD3ThemeProviderProps {
|
|
385
|
+
children: ReactNode;
|
|
386
|
+
sourceColor?: string;
|
|
387
|
+
defaultMode?: ThemeMode;
|
|
388
|
+
persistToLocalStorage?: boolean;
|
|
389
|
+
/**
|
|
390
|
+
* A fully custom `Typography` instance.
|
|
391
|
+
* When provided, `fontFamily` and `fontVariationAxes` are ignored.
|
|
392
|
+
*/
|
|
393
|
+
typography?: Typography;
|
|
394
|
+
/**
|
|
395
|
+
* Override the CSS `font-family` for all typography styles.
|
|
396
|
+
* Ignored when `typography` prop is provided.
|
|
397
|
+
* @example "'Inter', sans-serif"
|
|
398
|
+
*/
|
|
399
|
+
fontFamily?: string;
|
|
400
|
+
/**
|
|
401
|
+
* Variable font axes applied globally via `font-variation-settings`.
|
|
402
|
+
* Merged on top of defaults (`ROND: 100`). Ignored when `typography` is provided.
|
|
403
|
+
* @example { ROND: 50 }
|
|
404
|
+
*/
|
|
405
|
+
fontVariationAxes?: FontVariationAxes;
|
|
406
|
+
/**
|
|
407
|
+
* When `true`, mounts `SnackbarHost` inside the provider and exposes
|
|
408
|
+
* `useSnackbar()` to all descendants — no separate `<SnackbarProvider>` needed.
|
|
409
|
+
*
|
|
410
|
+
* Opt-in, default `false`. For advanced usage (e.g., scoped snackbars or
|
|
411
|
+
* custom host positioning), keep this `false` and use `<SnackbarProvider>`
|
|
412
|
+
* or `<SnackbarHost>` directly.
|
|
413
|
+
*
|
|
414
|
+
* @default false
|
|
415
|
+
*/
|
|
416
|
+
enableSnackbar?: boolean;
|
|
417
|
+
}
|
|
418
|
+
declare function MD3ThemeProvider({ children, sourceColor: initialSourceColor, defaultMode, persistToLocalStorage, typography: typographyProp, fontFamily, fontVariationAxes, enableSnackbar, }: MD3ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
419
|
+
declare function useTheme(): ThemeContextValue;
|
|
420
|
+
declare function useThemeMode(): Pick<ThemeContextValue, "mode" | "setMode" | "effectiveMode">;
|
|
421
|
+
|
|
422
|
+
export { Icon, type IconProps, type MD3ColorScheme, MD3ThemeProvider, type MD3ThemeProviderProps, MaterialSymbolsPreconnect, Ripple, type RippleOrigin, type RippleProps, type ThemeMode, type UseRippleStateOptions, applyTheme, cn, generateM3Theme, resolveMode, useRipple$1 as useDOMRipple, useMediaQuery, useRipple, useRippleState, useTheme, useThemeMode };
|