@bug-on/m3-expressive 1.3.6 → 1.3.7
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 +6 -0
- package/dist/buttons.d.mts +3 -3
- package/dist/buttons.d.ts +3 -3
- package/dist/buttons.js +110 -91
- package/dist/buttons.js.map +1 -1
- package/dist/buttons.mjs +110 -91
- package/dist/buttons.mjs.map +1 -1
- package/dist/{core-Cckt8qEm.d.ts → core-DamhB5Yd.d.ts} +1 -1
- package/dist/{core-DDfG4pym.d.mts → core-Wsfqn9_N.d.mts} +1 -1
- package/dist/core.d.mts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/{fading-blur-mask--uZbBKLj.d.ts → fading-blur-mask-CX-bwjNU.d.mts} +6 -1
- package/dist/{fading-blur-mask--uZbBKLj.d.mts → fading-blur-mask-D57UMguz.d.ts} +6 -1
- package/dist/feedback.d.mts +17 -5
- package/dist/feedback.d.ts +17 -5
- package/dist/feedback.js +1 -1
- package/dist/feedback.js.map +1 -1
- package/dist/feedback.mjs +1 -1
- package/dist/feedback.mjs.map +1 -1
- package/dist/forms.d.mts +3 -3
- package/dist/forms.d.ts +3 -3
- package/dist/{icon-button-CxyJv7UV.d.mts → icon-button-BpX9_fwZ.d.mts} +1 -1
- package/dist/{icon-button-Di8VX6ou.d.ts → icon-button-DFXp9hze.d.ts} +1 -1
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +1098 -976
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +924 -802
- package/dist/index.mjs.map +1 -1
- package/dist/layout.d.mts +92 -23
- package/dist/layout.d.ts +92 -23
- package/dist/layout.js +118 -13
- package/dist/layout.js.map +1 -1
- package/dist/layout.mjs +118 -15
- package/dist/layout.mjs.map +1 -1
- package/dist/md3-xBl4wgND.d.mts +44 -0
- package/dist/md3-xBl4wgND.d.ts +44 -0
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.js +1 -1
- package/dist/navigation.js.map +1 -1
- package/dist/navigation.mjs +1 -1
- package/dist/navigation.mjs.map +1 -1
- package/dist/overlays.d.mts +4 -4
- package/dist/overlays.d.ts +4 -4
- package/dist/overlays.js +1 -1
- package/dist/overlays.js.map +1 -1
- package/dist/overlays.mjs +1 -1
- package/dist/overlays.mjs.map +1 -1
- package/dist/pickers.js +1 -1
- package/dist/pickers.js.map +1 -1
- package/dist/pickers.mjs +1 -1
- package/dist/pickers.mjs.map +1 -1
- package/dist/shapes.d.mts +9 -2
- package/dist/shapes.d.ts +9 -2
- package/dist/{side-sheet-modal-Cw4vemKx.d.ts → side-sheet-modal-BfdgYjd3.d.ts} +1 -1
- package/dist/{side-sheet-modal-BycxrabB.d.mts → side-sheet-modal-kLfHINFZ.d.mts} +1 -1
- package/dist/{split-button-trailing-uncheckable-CGzk7KcG.d.ts → split-button-trailing-uncheckable-BpyIlOdn.d.ts} +7 -3
- package/dist/{split-button-trailing-uncheckable-gAz6OAIi.d.mts → split-button-trailing-uncheckable-CpT8iPpr.d.mts} +7 -3
- package/dist/{text-field-C0VQLp8Y.d.ts → text-field-Ct-LT_2T.d.ts} +1 -1
- package/dist/{text-field-B1fLh5Sh.d.mts → text-field-D5xiGn-q.d.mts} +1 -1
- package/llms-full.txt +18 -3
- package/llms.txt +4 -1
- package/package.json +1 -1
- package/dist/md3-BQhRygSi.d.mts +0 -31
- package/dist/md3-BQhRygSi.d.ts +0 -31
package/dist/layout.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { createContext, useState, useCallback, useMemo, useEffect, useContext, c
|
|
|
7
7
|
import { clsx } from 'clsx';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
|
-
import { cornerRadius } from '@bug-on/m3-tokens';
|
|
10
|
+
import { cornerRadius, framerSprings } from '@bug-on/m3-tokens';
|
|
11
11
|
import * as RadixScrollArea from '@radix-ui/react-scroll-area';
|
|
12
12
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
13
13
|
import { sortableKeyboardCoordinates, SortableContext, verticalListSortingStrategy, useSortable, arrayMove } from '@dnd-kit/sortable';
|
|
@@ -122,8 +122,6 @@ function useRippleState(options = {}) {
|
|
|
122
122
|
}, []);
|
|
123
123
|
return { ripples, onPointerDown, removeRipple };
|
|
124
124
|
}
|
|
125
|
-
|
|
126
|
-
// src/ui/cards/card/card-tokens.ts
|
|
127
125
|
var SHADOW = {
|
|
128
126
|
level0: "none",
|
|
129
127
|
level1: "0px 1px 2px 0px rgba(0,0,0,.3), 0px 1px 3px 1px rgba(0,0,0,.15)",
|
|
@@ -226,6 +224,45 @@ function useCardElevation({
|
|
|
226
224
|
}
|
|
227
225
|
};
|
|
228
226
|
}
|
|
227
|
+
function resolveCornerRadius(level, fallback, maxPillRadius) {
|
|
228
|
+
if (level === void 0) return `${fallback}px`;
|
|
229
|
+
if (typeof level === "number") return `${level}px`;
|
|
230
|
+
if (level === "full" && maxPillRadius !== void 0 && maxPillRadius > 0) {
|
|
231
|
+
return `${maxPillRadius}px`;
|
|
232
|
+
}
|
|
233
|
+
if (level in cornerRadius) {
|
|
234
|
+
return `${cornerRadius[level]}px`;
|
|
235
|
+
}
|
|
236
|
+
return `${fallback}px`;
|
|
237
|
+
}
|
|
238
|
+
function useCardMorphRadius({
|
|
239
|
+
morphRadius,
|
|
240
|
+
disabled = false,
|
|
241
|
+
isInteractive = false,
|
|
242
|
+
isForceMotion = false,
|
|
243
|
+
hoverEffect = true,
|
|
244
|
+
maxPillRadius
|
|
245
|
+
}) {
|
|
246
|
+
if (!morphRadius) return null;
|
|
247
|
+
if (!isInteractive && !isForceMotion) return null;
|
|
248
|
+
const config = typeof morphRadius === "object" ? morphRadius : {};
|
|
249
|
+
const restRadius = resolveCornerRadius(
|
|
250
|
+
config.rest,
|
|
251
|
+
cornerRadius.large,
|
|
252
|
+
maxPillRadius
|
|
253
|
+
);
|
|
254
|
+
const hoverRadius = hoverEffect ? resolveCornerRadius(config.hover, cornerRadius.extraLarge, maxPillRadius) : restRadius;
|
|
255
|
+
const pressedRadius = config.pressed !== void 0 ? resolveCornerRadius(config.pressed, cornerRadius.large, maxPillRadius) : restRadius;
|
|
256
|
+
return {
|
|
257
|
+
animate: { borderRadius: restRadius },
|
|
258
|
+
whileHover: disabled || !hoverEffect ? void 0 : { borderRadius: hoverRadius },
|
|
259
|
+
whileTap: disabled ? void 0 : { borderRadius: pressedRadius },
|
|
260
|
+
whileFocus: disabled || !hoverEffect ? void 0 : { borderRadius: hoverRadius },
|
|
261
|
+
transition: {
|
|
262
|
+
borderRadius: framerSprings.fast.spatial
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
229
266
|
var cardVariants = cva(
|
|
230
267
|
"rounded-m3-lg flex flex-col relative overflow-hidden transition-all duration-200",
|
|
231
268
|
{
|
|
@@ -269,6 +306,8 @@ var CardImpl = React23.forwardRef(
|
|
|
269
306
|
whileDrag,
|
|
270
307
|
transition,
|
|
271
308
|
asChild = false,
|
|
309
|
+
morphRadius = false,
|
|
310
|
+
forceMotion = false,
|
|
272
311
|
children
|
|
273
312
|
} = _b, props = __objRest(_b, [
|
|
274
313
|
"className",
|
|
@@ -295,6 +334,8 @@ var CardImpl = React23.forwardRef(
|
|
|
295
334
|
"whileDrag",
|
|
296
335
|
"transition",
|
|
297
336
|
"asChild",
|
|
337
|
+
"morphRadius",
|
|
338
|
+
"forceMotion",
|
|
298
339
|
"children"
|
|
299
340
|
]);
|
|
300
341
|
const safeVariant = variant || "elevated";
|
|
@@ -302,6 +343,39 @@ var CardImpl = React23.forwardRef(
|
|
|
302
343
|
const isHoverEnabled = hoverEffect !== false && !disableHoverEffect;
|
|
303
344
|
const isRippleEnabled = ripple !== false && !disableRipple && isInteractive && !disabled;
|
|
304
345
|
const isStateLayerEnabled = stateLayer !== false && !disableStateLayer && isInteractive && !disabled;
|
|
346
|
+
const containerRef = React23.useRef(null);
|
|
347
|
+
const setRefs = React23.useCallback(
|
|
348
|
+
(node) => {
|
|
349
|
+
containerRef.current = node;
|
|
350
|
+
if (typeof ref === "function") {
|
|
351
|
+
ref(node);
|
|
352
|
+
} else if (ref) {
|
|
353
|
+
ref.current = node;
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
[ref]
|
|
357
|
+
);
|
|
358
|
+
const hasFullRadius = typeof morphRadius === "object" && (morphRadius.rest === "full" || morphRadius.hover === "full" || morphRadius.pressed === "full");
|
|
359
|
+
const [pillRadius, setPillRadius] = React23.useState(
|
|
360
|
+
void 0
|
|
361
|
+
);
|
|
362
|
+
React23.useEffect(() => {
|
|
363
|
+
if (!hasFullRadius || !containerRef.current) return;
|
|
364
|
+
const el = containerRef.current;
|
|
365
|
+
const updateRadius = () => {
|
|
366
|
+
const h = el.offsetHeight;
|
|
367
|
+
const w = el.offsetWidth;
|
|
368
|
+
if (h > 0 && w > 0) {
|
|
369
|
+
setPillRadius(Math.ceil(Math.min(h, w) / 2));
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
updateRadius();
|
|
373
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
374
|
+
const ro = new ResizeObserver(updateRadius);
|
|
375
|
+
ro.observe(el);
|
|
376
|
+
return () => ro.disconnect();
|
|
377
|
+
}
|
|
378
|
+
}, [hasFullRadius]);
|
|
305
379
|
const elevationProps = useCardElevation({
|
|
306
380
|
variant: safeVariant,
|
|
307
381
|
disabled,
|
|
@@ -310,6 +384,14 @@ var CardImpl = React23.forwardRef(
|
|
|
310
384
|
disableElevation,
|
|
311
385
|
hoverEffect: isHoverEnabled
|
|
312
386
|
});
|
|
387
|
+
const morphRadiusProps = useCardMorphRadius({
|
|
388
|
+
morphRadius,
|
|
389
|
+
disabled,
|
|
390
|
+
isInteractive,
|
|
391
|
+
isForceMotion: forceMotion,
|
|
392
|
+
hoverEffect: isHoverEnabled,
|
|
393
|
+
maxPillRadius: pillRadius
|
|
394
|
+
});
|
|
313
395
|
const {
|
|
314
396
|
ripples,
|
|
315
397
|
onPointerDown: rippleOnPointerDown,
|
|
@@ -323,8 +405,10 @@ var CardImpl = React23.forwardRef(
|
|
|
323
405
|
event
|
|
324
406
|
);
|
|
325
407
|
};
|
|
408
|
+
const rawVariants = cardVariants({ variant: safeVariant });
|
|
409
|
+
const variantClass = morphRadiusProps ? rawVariants.replace("rounded-m3-lg", "").replace("transition-all", "") : rawVariants;
|
|
326
410
|
const baseClass = cn(
|
|
327
|
-
|
|
411
|
+
variantClass,
|
|
328
412
|
// Disabled state:
|
|
329
413
|
// - pointer-events-none → disable interactions completely
|
|
330
414
|
// - opacity-[0.38] → MD3 DisabledContainerOpacity
|
|
@@ -344,11 +428,12 @@ var CardImpl = React23.forwardRef(
|
|
|
344
428
|
// Outlined interactive card: smooth transition of border color to m3-outline on hover/focus/press
|
|
345
429
|
safeVariant === "outlined" && "transition-colors duration-200 hover:border-m3-outline focus-visible:border-m3-outline active:border-m3-outline"
|
|
346
430
|
);
|
|
347
|
-
const
|
|
348
|
-
const
|
|
349
|
-
const
|
|
431
|
+
const mergedAnimate = __spreadValues(__spreadValues({}, elevationProps.animate), (morphRadiusProps == null ? void 0 : morphRadiusProps.animate) || {});
|
|
432
|
+
const mergedWhileHover = elevationProps.whileHover || (morphRadiusProps == null ? void 0 : morphRadiusProps.whileHover) || whileHover ? __spreadValues(__spreadValues(__spreadValues({}, elevationProps.whileHover), morphRadiusProps == null ? void 0 : morphRadiusProps.whileHover), typeof whileHover === "object" ? whileHover : {}) : void 0;
|
|
433
|
+
const mergedWhileTap = elevationProps.whileTap || (morphRadiusProps == null ? void 0 : morphRadiusProps.whileTap) || whileTap ? __spreadValues(__spreadValues(__spreadValues({}, elevationProps.whileTap), morphRadiusProps == null ? void 0 : morphRadiusProps.whileTap), typeof whileTap === "object" ? whileTap : {}) : void 0;
|
|
434
|
+
const mergedWhileFocus = elevationProps.whileFocus || (morphRadiusProps == null ? void 0 : morphRadiusProps.whileFocus) || whileFocus ? __spreadValues(__spreadValues(__spreadValues({}, elevationProps.whileFocus), morphRadiusProps == null ? void 0 : morphRadiusProps.whileFocus), typeof whileFocus === "object" ? whileFocus : {}) : void 0;
|
|
350
435
|
const mergedWhileDrag = elevationProps.whileDrag || whileDrag ? __spreadValues(__spreadValues({}, elevationProps.whileDrag), typeof whileDrag === "object" ? whileDrag : {}) : void 0;
|
|
351
|
-
const mergedTransition = elevationProps.transition || transition ? __spreadValues(__spreadValues({}, elevationProps.transition), typeof transition === "object" ? transition : {}) : void 0;
|
|
436
|
+
const mergedTransition = elevationProps.transition || (morphRadiusProps == null ? void 0 : morphRadiusProps.transition) || transition ? __spreadValues(__spreadValues(__spreadValues({}, elevationProps.transition), morphRadiusProps == null ? void 0 : morphRadiusProps.transition), typeof transition === "object" ? transition : {}) : void 0;
|
|
352
437
|
if (asChild) {
|
|
353
438
|
const child = React23.Children.only(children);
|
|
354
439
|
const innerContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -358,7 +443,7 @@ var CardImpl = React23.forwardRef(
|
|
|
358
443
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
359
444
|
Slot,
|
|
360
445
|
__spreadProps(__spreadValues({
|
|
361
|
-
ref,
|
|
446
|
+
ref: setRefs,
|
|
362
447
|
className: cn(baseClass, interactiveClass),
|
|
363
448
|
"aria-disabled": disabled ? true : void 0,
|
|
364
449
|
tabIndex: disabled ? -1 : 0,
|
|
@@ -370,10 +455,28 @@ var CardImpl = React23.forwardRef(
|
|
|
370
455
|
) });
|
|
371
456
|
}
|
|
372
457
|
if (!isInteractive) {
|
|
458
|
+
if (forceMotion && morphRadiusProps) {
|
|
459
|
+
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsx(
|
|
460
|
+
m.div,
|
|
461
|
+
__spreadProps(__spreadValues({
|
|
462
|
+
ref: setRefs,
|
|
463
|
+
className: baseClass,
|
|
464
|
+
"aria-disabled": disabled ? true : void 0,
|
|
465
|
+
animate: mergedAnimate,
|
|
466
|
+
whileHover: mergedWhileHover,
|
|
467
|
+
whileTap: mergedWhileTap,
|
|
468
|
+
whileFocus: mergedWhileFocus,
|
|
469
|
+
whileDrag: mergedWhileDrag,
|
|
470
|
+
transition: mergedTransition
|
|
471
|
+
}, props), {
|
|
472
|
+
children
|
|
473
|
+
})
|
|
474
|
+
) });
|
|
475
|
+
}
|
|
373
476
|
return /* @__PURE__ */ jsx(
|
|
374
477
|
"div",
|
|
375
478
|
__spreadProps(__spreadValues({
|
|
376
|
-
ref,
|
|
479
|
+
ref: setRefs,
|
|
377
480
|
className: baseClass,
|
|
378
481
|
style: __spreadValues({
|
|
379
482
|
boxShadow: elevationProps.animate.boxShadow
|
|
@@ -389,7 +492,7 @@ var CardImpl = React23.forwardRef(
|
|
|
389
492
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
390
493
|
m.a,
|
|
391
494
|
__spreadProps(__spreadValues({
|
|
392
|
-
ref,
|
|
495
|
+
ref: setRefs,
|
|
393
496
|
href: disabled ? void 0 : href,
|
|
394
497
|
target,
|
|
395
498
|
rel: safeRel,
|
|
@@ -397,7 +500,7 @@ var CardImpl = React23.forwardRef(
|
|
|
397
500
|
"aria-disabled": disabled ? true : void 0,
|
|
398
501
|
tabIndex: disabled ? -1 : 0,
|
|
399
502
|
onPointerDown: handlePointerDown,
|
|
400
|
-
animate:
|
|
503
|
+
animate: mergedAnimate,
|
|
401
504
|
whileHover: mergedWhileHover,
|
|
402
505
|
whileTap: mergedWhileTap,
|
|
403
506
|
whileFocus: mergedWhileFocus,
|
|
@@ -414,7 +517,7 @@ var CardImpl = React23.forwardRef(
|
|
|
414
517
|
return /* @__PURE__ */ jsx(LazyMotion, { features: domMax, strict: true, children: /* @__PURE__ */ jsxs(
|
|
415
518
|
m.button,
|
|
416
519
|
__spreadProps(__spreadValues({
|
|
417
|
-
ref,
|
|
520
|
+
ref: setRefs,
|
|
418
521
|
type: "button",
|
|
419
522
|
disabled,
|
|
420
523
|
onClick,
|
|
@@ -422,7 +525,7 @@ var CardImpl = React23.forwardRef(
|
|
|
422
525
|
"aria-disabled": disabled ? true : void 0,
|
|
423
526
|
tabIndex: disabled ? -1 : 0,
|
|
424
527
|
onPointerDown: handlePointerDown,
|
|
425
|
-
animate:
|
|
528
|
+
animate: mergedAnimate,
|
|
426
529
|
whileHover: mergedWhileHover,
|
|
427
530
|
whileTap: mergedWhileTap,
|
|
428
531
|
whileFocus: mergedWhileFocus,
|
|
@@ -6732,6 +6835,6 @@ function TypographyProvider({
|
|
|
6732
6835
|
return /* @__PURE__ */ jsx(TypographyContext.Provider, { value, children });
|
|
6733
6836
|
}
|
|
6734
6837
|
|
|
6735
|
-
export { Card, CardContent, CardFooter, CardHeader, CardMedia, Carousel, CarouselGrid, CarouselItem, CarouselScrollClient, CarouselTokens, CodeBlock, DEFAULT_FONT_VARIATION_AXES, Divider, FadingBlurMask, LIST_TOKENS, List, ListContext, ListDivider, ListItem, MD3_EXPRESSIVE_FONT_VARIATION, SHADOW, ScrollArea, ScrollAreaScrollbar, TableOfContents, Text, TypeScaleTokens, Typography, TypographyContext, TypographyKeyTokens, TypographyProvider, TypographyTokens, VARIANT_ELEVATION, buildWavePath, cardVariants, getExpressiveShape, getListItemHeight, resolveElevationShadow, serializeFontVariationAxes, shouldTopAlign, typographyVariants, useCardElevation, useCarouselA11y, useCarouselKeylines, useListContext, useTypography };
|
|
6838
|
+
export { Card, CardContent, CardFooter, CardHeader, CardMedia, Carousel, CarouselGrid, CarouselItem, CarouselScrollClient, CarouselTokens, CodeBlock, DEFAULT_FONT_VARIATION_AXES, Divider, FadingBlurMask, LIST_TOKENS, List, ListContext, ListDivider, ListItem, MD3_EXPRESSIVE_FONT_VARIATION, SHADOW, ScrollArea, ScrollAreaScrollbar, TableOfContents, Text, TypeScaleTokens, Typography, TypographyContext, TypographyKeyTokens, TypographyProvider, TypographyTokens, VARIANT_ELEVATION, buildWavePath, cardVariants, getExpressiveShape, getListItemHeight, resolveCornerRadius, resolveElevationShadow, serializeFontVariationAxes, shouldTopAlign, typographyVariants, useCardElevation, useCardMorphRadius, useCarouselA11y, useCarouselKeylines, useListContext, useTypography };
|
|
6736
6839
|
//# sourceMappingURL=layout.mjs.map
|
|
6737
6840
|
//# sourceMappingURL=layout.mjs.map
|