@bug-on/m3-expressive 1.1.0 → 1.2.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 (61) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/buttons.d.mts +3 -3
  3. package/dist/buttons.d.ts +3 -3
  4. package/dist/buttons.js +708 -606
  5. package/dist/buttons.js.map +1 -1
  6. package/dist/buttons.mjs +707 -605
  7. package/dist/buttons.mjs.map +1 -1
  8. package/dist/core-Bc5Wj_pc.d.ts +497 -0
  9. package/dist/core-D4048_K5.d.mts +497 -0
  10. package/dist/core.d.mts +6 -422
  11. package/dist/core.d.ts +6 -422
  12. package/dist/core.js +223 -129
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +224 -130
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/feedback.js +85 -61
  17. package/dist/feedback.js.map +1 -1
  18. package/dist/feedback.mjs +85 -61
  19. package/dist/feedback.mjs.map +1 -1
  20. package/dist/forms.d.mts +2 -2
  21. package/dist/forms.d.ts +2 -2
  22. package/dist/forms.js +70 -8
  23. package/dist/forms.js.map +1 -1
  24. package/dist/forms.mjs +70 -8
  25. package/dist/forms.mjs.map +1 -1
  26. package/dist/{icon-button-D-gs0gfj.d.mts → icon-button-sSt6PPLg.d.mts} +6 -0
  27. package/dist/{icon-button-D-gs0gfj.d.ts → icon-button-sSt6PPLg.d.ts} +6 -0
  28. package/dist/index.css +6 -1
  29. package/dist/index.d.mts +68 -6
  30. package/dist/index.d.ts +68 -6
  31. package/dist/index.js +1177 -580
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +1172 -583
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/layout.d.mts +18 -1
  36. package/dist/layout.d.ts +18 -1
  37. package/dist/layout.js +94 -8
  38. package/dist/layout.js.map +1 -1
  39. package/dist/layout.mjs +94 -8
  40. package/dist/layout.mjs.map +1 -1
  41. package/dist/{md3-DFhj-NZj.d.mts → md3-Dty-Qcad.d.mts} +7 -1
  42. package/dist/{md3-DFhj-NZj.d.ts → md3-Dty-Qcad.d.ts} +7 -1
  43. package/dist/navigation.d.mts +134 -9
  44. package/dist/navigation.d.ts +134 -9
  45. package/dist/navigation.js +403 -93
  46. package/dist/navigation.js.map +1 -1
  47. package/dist/navigation.mjs +397 -94
  48. package/dist/navigation.mjs.map +1 -1
  49. package/dist/overlays.js +214 -189
  50. package/dist/overlays.js.map +1 -1
  51. package/dist/overlays.mjs +176 -151
  52. package/dist/overlays.mjs.map +1 -1
  53. package/dist/pickers.js +222 -197
  54. package/dist/pickers.js.map +1 -1
  55. package/dist/pickers.mjs +189 -164
  56. package/dist/pickers.mjs.map +1 -1
  57. package/dist/{split-button-trailing-uncheckable-BRPuTqi1.d.mts → split-button-trailing-uncheckable-BcPD_7uK.d.ts} +73 -7
  58. package/dist/{split-button-trailing-uncheckable-CjOFCoyW.d.ts → split-button-trailing-uncheckable-DtFJkTFr.d.mts} +73 -7
  59. package/dist/{text-field-eAIpz9z1.d.mts → text-field-T4Rg-9Bw.d.mts} +7 -0
  60. package/dist/{text-field-eAIpz9z1.d.ts → text-field-T4Rg-9Bw.d.ts} +7 -0
  61. package/package.json +4 -4
package/dist/core.d.ts CHANGED
@@ -1,422 +1,6 @@
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 — SSR-safe responsive hook.
10
- *
11
- * Prevents hydration mismatch by initializing with `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
- /** Ripple animation duration (ms). Default: 600 */
22
- duration?: number;
23
- /** Ripple color. Default: 'currentColor' */
24
- color?: string;
25
- /** Opacity. Default: 0.12 (MD3 standard) */
26
- opacity?: number;
27
- /** Disable ripple (e.g. when component is disabled) */
28
- disabled?: boolean;
29
- }
30
- /**
31
- * useRipple — Material Design 3 Expressive Ripple Effect
32
- *
33
- * Pure DOM hook with zero external animation dependencies.
34
- * Note: Requires element to have `position: relative` and `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
- * Injects preconnect resource hints for Google Fonts CDN into <head>.
51
- * Place this component AS EARLY AS POSSIBLE in the app tree, ideally
52
- * directly inside <head> or root layout.
53
- *
54
- * WHY THIS MATTERS:
55
- * If @import url() is inside a CSS file, browser must:
56
- * 1. Parse HTML -> download JS bundle -> execute CSS -> hit @import -> start Google Fonts connection
57
- * Preconnect hints allow browser to establish TCP handshake + TLS connection early at step 1,
58
- * saving 100-500ms connection latency depending on network.
59
- *
60
- * USAGE:
61
- * ```tsx
62
- * // app/layout.tsx (Next.js) or 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: Use this component only with CDN mode.
78
- * Self-hosted fonts do not require preconnecting to external origins.
79
- */
80
- interface MaterialSymbolsPreconnectProps {
81
- /**
82
- * Array of Material Symbols font variants to load.
83
- * Include only variants used by application to minimize bandwidth.
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
- * All variable font axes are mapped directly to `font-variation-settings`.
166
- */
167
- interface IconProps extends React$1.HTMLAttributes<HTMLSpanElement> {
168
- /**
169
- * Name of the Material Symbol in snake_case format.
170
- * @example "home", "arrow_forward", "settings"
171
- * @see https://fonts.google.com/icons
172
- */
173
- name: string;
174
- /**
175
- * Geometric style variant — maps to font family.
176
- * @default "outlined"
177
- */
178
- variant?: "outlined" | "rounded" | "sharp";
179
- /**
180
- * `FILL` axis. `0` = outlined, `1` = filled.
181
- * Features spring animation when `animateFill` is true.
182
- * @default 0
183
- */
184
- fill?: 0 | 1;
185
- /**
186
- * `wght` axis — stroke weight. Should match surrounding text weight.
187
- * @default 400
188
- */
189
- weight?: 100 | 200 | 300 | 400 | 500 | 600 | 700;
190
- /**
191
- * `GRAD` axis — fine-tunes visual weight without affecting layout dimensions.
192
- * Use `-25` on dark backgrounds to offset light halation effects.
193
- * @default 0
194
- */
195
- grade?: -50 | -25 | 0 | 100 | 200;
196
- /**
197
- * `opsz` axis — optical size in dp. Used to set `font-size` if `size` is not specified.
198
- * Match rendered pixel size for best quality.
199
- * @default 24
200
- */
201
- opticalSize?: 20 | 24 | 40 | 48;
202
- /**
203
- * Direct `font-size` override in px. `opsz` axis still respects `opticalSize`.
204
- * @example size={18} opticalSize={20}
205
- */
206
- size?: number | "inherit";
207
- /**
208
- * Enables smooth spring animation when toggling FILL axis (uses `SPRING_TRANSITION_FAST`).
209
- * Requires `motion` dependency.
210
- * @default false
211
- * @example <Icon name="favorite" fill={isLiked ? 1 : 0} animateFill />
212
- */
213
- animateFill?: boolean;
214
- }
215
- /**
216
- * Material Symbols (variable font) Icon component.
217
- *
218
- * Make sure to import the icon font CSS before usage:
219
- * ```ts
220
- * import '@bug-on/m3-expressive/material-symbols-cdn.css';
221
- * ```
222
- *
223
- * @remarks
224
- * - Use snake_case for icon names: `"arrow_forward"`, NOT `"ArrowForward"`.
225
- * - `aria-hidden="true"` is attached automatically — provide screen reader labels on parent elements.
226
- *
227
- * @example
228
- * ```tsx
229
- * // Basic Icon
230
- * <Icon name="home" />
231
- *
232
- * // Visual customization (filled, heavy weight)
233
- * <Icon name="favorite" variant="rounded" fill={1} weight={300} />
234
- *
235
- * // Animated transition on state change
236
- * <Icon name="bookmark" fill={saved ? 1 : 0} animateFill />
237
- *
238
- * // Custom size override
239
- * <Icon name="close" size={18} opticalSize={20} />
240
- *
241
- * // Combination with other components
242
- * <Button icon={<Icon name="add" />}>Add to cart</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 };
1
+ export { I as Icon, a as IconProps, M as MD3ColorScheme, b as MD3ThemeProvider, c as MD3ThemeProviderProps, d as MaterialSymbolsPreconnect, R as Ripple, e as RippleOrigin, f as RippleProps, T as ThemeMode, U as UseRippleStateOptions, g as applyTheme, h as cn, i as generateM3Theme, r as resolveMode, u as useDOMRipple, j as useMediaQuery, k as useRipple, l as useRippleState, m as useTheme, n as useThemeMode } from './core-Bc5Wj_pc.js';
2
+ export { M as MD3ColorStyle, a as MD3Shape, b as MD3Size, P as PolymorphicProps, c as PolymorphicRef } from './md3-Dty-Qcad.js';
3
+ import 'react';
4
+ import 'react/jsx-runtime';
5
+ import 'clsx';
6
+ import './typography-339RV6v7.js';