@tinybigui/react 0.22.0 → 0.23.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/dist/index.js CHANGED
@@ -467,6 +467,10 @@ var buttonVariants = cva(
467
467
  * Filled/Tonal hover→level-1, focus/pressed→level-0
468
468
  * Elevated base→level-1, hover→level-2, focus/pressed→level-1
469
469
  * Outlined/Text no elevation
470
+ *
471
+ * Self-targeting `data-[x]:` is used for elevation because these classes
472
+ * sit on the root element (the group host) — group-data descendant
473
+ * selectors cannot match an element against itself.
470
474
  */
471
475
  variant: {
472
476
  /**
@@ -475,17 +479,17 @@ var buttonVariants = cva(
475
479
  * Elevation: 0 base → 1 hover → 0 focus → 0 pressed
476
480
  */
477
481
  filled: [
478
- "bg-primary text-on-primary shadow-none",
482
+ "text-on-primary shadow-none",
479
483
  // Hover: gains level-1 elevation
480
- "group-data-[hovered]/button:shadow-elevation-1",
484
+ "data-[hovered]:shadow-elevation-1",
481
485
  // Focus/pressed: shadow must explicitly return to level-0
482
486
  // (doubled attribute selector → higher specificity than hover)
483
- "group-data-[focus-visible]/button:shadow-none",
484
- "group-data-[pressed]/button:group-data-[pressed]/button:shadow-none",
485
- // Disabled overrides
486
- "group-data-[disabled]/button:bg-on-surface/12",
487
- "group-data-[disabled]/button:text-on-surface/38",
488
- "group-data-[disabled]/button:shadow-none"
487
+ "data-[focus-visible]:data-[focus-visible]:shadow-none",
488
+ "data-[pressed]:data-[pressed]:data-[pressed]:shadow-none",
489
+ // Disabled overrides — root owns text color + shadow only;
490
+ // disabled bg override lives on buttonContainerVariants (filled variant)
491
+ "data-[disabled]:text-on-surface/38",
492
+ "data-[disabled]:shadow-none"
489
493
  ],
490
494
  /**
491
495
  * Outlined — medium emphasis. Transparent with border.
@@ -493,10 +497,10 @@ var buttonVariants = cva(
493
497
  * Elevation: always 0
494
498
  */
495
499
  outlined: [
496
- "bg-transparent border border-outline text-primary",
500
+ "border border-outline text-primary",
497
501
  // Disabled overrides
498
- "group-data-[disabled]/button:border-on-surface/12",
499
- "group-data-[disabled]/button:text-on-surface/38"
502
+ "data-[disabled]:border-on-surface/12",
503
+ "data-[disabled]:text-on-surface/38"
500
504
  ],
501
505
  /**
502
506
  * Tonal — secondary emphasis.
@@ -504,16 +508,15 @@ var buttonVariants = cva(
504
508
  * Elevation: 0 base → 1 hover → 0 focus → 0 pressed
505
509
  */
506
510
  tonal: [
507
- "bg-secondary-container text-on-secondary-container shadow-none",
511
+ "text-on-secondary-container shadow-none",
508
512
  // Hover: gains level-1 elevation (same as filled)
509
- "group-data-[hovered]/button:shadow-elevation-1",
513
+ "data-[hovered]:shadow-elevation-1",
510
514
  // Focus/pressed: return to level-0
511
- "group-data-[focus-visible]/button:shadow-none",
512
- "group-data-[pressed]/button:group-data-[pressed]/button:shadow-none",
515
+ "data-[focus-visible]:data-[focus-visible]:shadow-none",
516
+ "data-[pressed]:data-[pressed]:data-[pressed]:shadow-none",
513
517
  // Disabled overrides
514
- "group-data-[disabled]/button:bg-on-surface/12",
515
- "group-data-[disabled]/button:text-on-surface/38",
516
- "group-data-[disabled]/button:shadow-none"
518
+ "data-[disabled]:text-on-surface/38",
519
+ "data-[disabled]:shadow-none"
517
520
  ],
518
521
  /**
519
522
  * Elevated — separation via shadow.
@@ -521,17 +524,16 @@ var buttonVariants = cva(
521
524
  * Elevation: 1 base → 2 hover → 1 focus → 1 pressed
522
525
  */
523
526
  elevated: [
524
- "bg-surface-container-low text-primary shadow-elevation-1",
527
+ "text-primary shadow-elevation-1",
525
528
  // Hover: gains extra elevation
526
- "group-data-[hovered]/button:shadow-elevation-2",
529
+ "data-[hovered]:shadow-elevation-2",
527
530
  // Focus/pressed: return to base level-1
528
531
  // (doubled selector wins over single hover selector at same cascade position)
529
- "group-data-[focus-visible]/button:shadow-elevation-1",
530
- "group-data-[pressed]/button:group-data-[pressed]/button:shadow-elevation-1",
532
+ "data-[focus-visible]:data-[focus-visible]:shadow-elevation-1",
533
+ "data-[pressed]:data-[pressed]:data-[pressed]:shadow-elevation-1",
531
534
  // Disabled overrides
532
- "group-data-[disabled]/button:bg-on-surface/12",
533
- "group-data-[disabled]/button:text-on-surface/38",
534
- "group-data-[disabled]/button:shadow-none"
535
+ "data-[disabled]:text-on-surface/38",
536
+ "data-[disabled]:shadow-none"
535
537
  ],
536
538
  /**
537
539
  * Text — lowest emphasis.
@@ -539,9 +541,9 @@ var buttonVariants = cva(
539
541
  * Elevation: always 0
540
542
  */
541
543
  text: [
542
- "bg-transparent text-primary",
544
+ "text-primary",
543
545
  // Disabled overrides
544
- "group-data-[disabled]/button:text-on-surface/38"
546
+ "data-[disabled]:text-on-surface/38"
545
547
  ]
546
548
  },
547
549
  /**
@@ -579,6 +581,29 @@ var buttonVariants = cva(
579
581
  }
580
582
  }
581
583
  );
584
+ var buttonContainerVariants = cva(
585
+ [
586
+ "absolute inset-0 rounded-[inherit] pointer-events-none",
587
+ // Effects transition for background-color — no overshoot
588
+ "transition-[background-color] duration-spring-standard-fast-effects ease-spring-standard-fast-effects"
589
+ ],
590
+ {
591
+ variants: {
592
+ variant: {
593
+ // MD3 disabled: filled containers replace bg with on-surface/12.
594
+ // group-data descendant selector targets this child span (not the root host).
595
+ filled: "bg-primary group-data-[disabled]/button:bg-on-surface/12",
596
+ // outlined/text: container stays transparent when disabled — only border + label fade.
597
+ outlined: "bg-transparent",
598
+ // MD3 disabled: tonal and elevated containers also replace bg with on-surface/12.
599
+ tonal: "bg-secondary-container group-data-[disabled]/button:bg-on-surface/12",
600
+ elevated: "bg-surface-container-low group-data-[disabled]/button:bg-on-surface/12",
601
+ text: "bg-transparent"
602
+ }
603
+ },
604
+ defaultVariants: { variant: "filled" }
605
+ }
606
+ );
582
607
  var buttonStateLayerVariants = cva(
583
608
  [
584
609
  "absolute inset-0 rounded-[inherit] overflow-hidden pointer-events-none opacity-0",
@@ -881,6 +906,7 @@ var Button = forwardRef(
881
906
  className
882
907
  ),
883
908
  children: [
909
+ /* @__PURE__ */ jsx("span", { className: cn(buttonContainerVariants({ variant })), "aria-hidden": "true" }),
884
910
  ripples,
885
911
  /* @__PURE__ */ jsx("span", { className: cn(buttonStateLayerVariants({ variant })), "aria-hidden": "true" }),
886
912
  /* @__PURE__ */ jsx("span", { className: cn(buttonFocusRingVariants()), "aria-hidden": "true" }),
@@ -5947,6 +5973,416 @@ var CardActions = forwardRef(function CardActions2({ children, className }, ref)
5947
5973
  return /* @__PURE__ */ jsx("div", { ref, className: cn("flex items-center justify-end gap-2 p-4 pt-0", className), children });
5948
5974
  });
5949
5975
  CardActions.displayName = "CardActions";
5976
+ var menuContainerVariants = cva(
5977
+ [
5978
+ // Width constraints: 112dp min / 280dp max per MD3 spec
5979
+ "min-w-28 max-w-70",
5980
+ "flex flex-col",
5981
+ // Scroll behaviour
5982
+ "max-h-[calc(var(--visual-viewport-height,100vh)-2rem)]",
5983
+ // Stacking
5984
+ "z-50",
5985
+ "gap-0.5",
5986
+ // Focus outline delegated to React Aria
5987
+ "outline-none"
5988
+ ],
5989
+ {
5990
+ variants: {
5991
+ /**
5992
+ * Color scheme — drives item/segment background and content colors.
5993
+ * standard: surface-container-low item background.
5994
+ * vibrant: tertiary-container item background.
5995
+ */
5996
+ colorScheme: {
5997
+ standard: [],
5998
+ vibrant: []
5999
+ },
6000
+ /**
6001
+ * Visual style — drives corner radius and container background.
6002
+ *
6003
+ * baseline: solid surface-container, 4dp corners, 8dp vertical padding.
6004
+ * vertical: transparent container, 16dp corners, no container padding —
6005
+ * items own their segment surface, gaps reveal the page background.
6006
+ */
6007
+ menuStyle: {
6008
+ baseline: ["rounded-xs", "bg-surface-container", "py-2"],
6009
+ vertical: ["bg-transparent"]
6010
+ }
6011
+ },
6012
+ defaultVariants: {
6013
+ colorScheme: "standard",
6014
+ menuStyle: "baseline"
6015
+ }
6016
+ }
6017
+ );
6018
+ var menuPopoverVariants = cva([
6019
+ "will-change-[transform,opacity]",
6020
+ "data-[entering]:pointer-events-none data-[exiting]:pointer-events-none",
6021
+ "data-[entering]:animate-md-scale-in",
6022
+ "data-[exiting]:animate-md-scale-out",
6023
+ "origin-top",
6024
+ "data-[placement=top]:origin-bottom",
6025
+ "data-[placement=left]:origin-right",
6026
+ "data-[placement=right]:origin-left",
6027
+ "motion-reduce:data-[entering]:animate-none motion-reduce:data-[exiting]:animate-none"
6028
+ ]);
6029
+ var menuItemVariants = cva(
6030
+ [
6031
+ // Layout — height set by density context in MenuItem component
6032
+ // gap is style-specific: baseline = 12dp (gap-3), vertical = 8dp (gap-2)
6033
+ "relative flex w-full items-center",
6034
+ // Typography: Label Large per MD3 menu spec
6035
+ "text-label-large",
6036
+ // Interaction
6037
+ "cursor-pointer select-none outline-none",
6038
+ // Color transition (effects — no overshoot)
6039
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6040
+ // Disabled — self-targeting data-[x]: selectors (RAC emits data-disabled)
6041
+ "data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed"
6042
+ ],
6043
+ {
6044
+ variants: {
6045
+ /**
6046
+ * Color scheme — drives item bg, default text/icon color, and selection colors.
6047
+ *
6048
+ * standard: surface-container-low bg, on-surface text, on-surface-variant icons.
6049
+ * Selected/open: tertiary-container bg highlight, on-tertiary-container content.
6050
+ * vibrant: tertiary-container bg, on-tertiary-container text AND icons.
6051
+ * Selected/open: tertiary bg highlight, on-tertiary content.
6052
+ */
6053
+ colorScheme: {
6054
+ standard: ["text-on-surface"],
6055
+ vibrant: ["text-on-tertiary-container"]
6056
+ },
6057
+ /**
6058
+ * Visual style — drives padding, gap, segment surface, and corner rounding.
6059
+ *
6060
+ * baseline: 12dp h-padding, 12dp icon-to-label gap, no item background (container provides it).
6061
+ * vertical: 12dp h-padding, 8dp icon-to-label gap, item owns segment surface, segmented rounding
6062
+ * via first/last + adjacent-sibling gap selectors.
6063
+ */
6064
+ menuStyle: {
6065
+ baseline: ["px-3", "gap-3"],
6066
+ vertical: [
6067
+ "px-3",
6068
+ "gap-2",
6069
+ // Default: inner item (4dp all corners)
6070
+ "rounded-md"
6071
+ // Last item in the whole menu → 16dp bottom corners
6072
+ ]
6073
+ }
6074
+ },
6075
+ compoundVariants: [
6076
+ // vertical + standard: selected/open text → on-tertiary-container
6077
+ {
6078
+ menuStyle: "vertical",
6079
+ colorScheme: "standard",
6080
+ class: [
6081
+ "data-[selected]:text-on-tertiary-container",
6082
+ "data-[open]:text-on-tertiary-container"
6083
+ ]
6084
+ },
6085
+ // vertical + vibrant: selected/open text → on-tertiary
6086
+ {
6087
+ menuStyle: "vertical",
6088
+ colorScheme: "vibrant",
6089
+ class: ["data-[selected]:text-on-tertiary", "data-[open]:text-on-tertiary"]
6090
+ }
6091
+ ],
6092
+ defaultVariants: {
6093
+ colorScheme: "standard",
6094
+ menuStyle: "baseline"
6095
+ }
6096
+ }
6097
+ );
6098
+ var menuItemHighlightVariants = cva(
6099
+ [
6100
+ "absolute inset-0 pointer-events-none",
6101
+ // Inherit the item's own corner radius (inner 4dp or outer 16dp)
6102
+ "rounded-[inherit]",
6103
+ // Effects transition for background-color — no overshoot
6104
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6105
+ // z-0: below state layer (z-[1]) and content (z-10)
6106
+ "z-0"
6107
+ ],
6108
+ {
6109
+ variants: {
6110
+ menuStyle: {
6111
+ baseline: [],
6112
+ vertical: []
6113
+ },
6114
+ colorScheme: {
6115
+ standard: [
6116
+ // baseline selected bg
6117
+ "group-data-[selected]/menuitem:bg-surface-container-highest"
6118
+ ],
6119
+ vibrant: [
6120
+ // baseline + vibrant: use surface-container-highest as fallback
6121
+ "group-data-[selected]/menuitem:bg-surface-container-highest"
6122
+ ]
6123
+ }
6124
+ },
6125
+ compoundVariants: [
6126
+ // vertical + standard: selected/open highlight → tertiary-container
6127
+ {
6128
+ menuStyle: "vertical",
6129
+ colorScheme: "standard",
6130
+ class: [
6131
+ "group-data-[selected]/menuitem:bg-tertiary-container",
6132
+ "group-data-[open]/menuitem:bg-tertiary-container"
6133
+ ]
6134
+ },
6135
+ // vertical + vibrant: selected/open highlight → tertiary
6136
+ {
6137
+ menuStyle: "vertical",
6138
+ colorScheme: "vibrant",
6139
+ class: [
6140
+ "group-data-[selected]/menuitem:bg-tertiary",
6141
+ "group-data-[open]/menuitem:bg-tertiary"
6142
+ ]
6143
+ }
6144
+ ],
6145
+ defaultVariants: {
6146
+ menuStyle: "baseline",
6147
+ colorScheme: "standard"
6148
+ }
6149
+ }
6150
+ );
6151
+ var menuItemStateLayerVariants = cva(
6152
+ [
6153
+ "absolute inset-0 rounded-[inherit] overflow-hidden pointer-events-none opacity-0",
6154
+ // Effects transition — opacity must NOT overshoot
6155
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6156
+ // Hover: 8%
6157
+ "group-data-[hovered]/menuitem:opacity-8",
6158
+ // Pressed: 10%, doubled selector wins over hover at same cascade position
6159
+ "group-data-[pressed]/menuitem:group-data-[pressed]/menuitem:opacity-10",
6160
+ // No state layer when disabled
6161
+ "group-data-[disabled]/menuitem:hidden",
6162
+ // z-[1]: above highlight layer (z-0), below content (z-10)
6163
+ "z-[1]"
6164
+ ],
6165
+ {
6166
+ variants: {
6167
+ colorScheme: {
6168
+ standard: ["bg-on-surface"],
6169
+ vibrant: ["bg-on-tertiary-container"]
6170
+ },
6171
+ menuStyle: {
6172
+ baseline: [],
6173
+ vertical: []
6174
+ }
6175
+ },
6176
+ compoundVariants: [
6177
+ // vertical + standard: selected/open state layer → on-tertiary-container
6178
+ {
6179
+ menuStyle: "vertical",
6180
+ colorScheme: "standard",
6181
+ class: [
6182
+ "group-data-[selected]/menuitem:bg-on-tertiary-container",
6183
+ "group-data-[open]/menuitem:bg-on-tertiary-container"
6184
+ ]
6185
+ },
6186
+ // vertical + vibrant: selected/open state layer → on-tertiary
6187
+ {
6188
+ menuStyle: "vertical",
6189
+ colorScheme: "vibrant",
6190
+ class: [
6191
+ "group-data-[selected]/menuitem:bg-on-tertiary",
6192
+ "group-data-[open]/menuitem:bg-on-tertiary"
6193
+ ]
6194
+ }
6195
+ ],
6196
+ defaultVariants: {
6197
+ colorScheme: "standard",
6198
+ menuStyle: "baseline"
6199
+ }
6200
+ }
6201
+ );
6202
+ var menuItemFocusRingVariants = cva([
6203
+ "pointer-events-none absolute inset-0 rounded-[inherit]",
6204
+ "outline outline-2 -outline-offset-2 outline-secondary",
6205
+ // Effects transition — opacity must not overshoot
6206
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6207
+ "opacity-0",
6208
+ "group-data-[focus-visible]/menuitem:opacity-100",
6209
+ // z-[2]: above state layer (z-[1]) and highlight (z-0), below content (z-10)
6210
+ "z-[2]"
6211
+ ]);
6212
+ var menuItemIconVariants = cva(
6213
+ [
6214
+ "relative z-10 shrink-0 flex items-center justify-center",
6215
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6216
+ // Disabled: 38% opacity on icon color
6217
+ "group-data-[disabled]/menuitem:text-on-surface/38"
6218
+ ],
6219
+ {
6220
+ variants: {
6221
+ colorScheme: {
6222
+ standard: ["text-on-surface-variant"],
6223
+ vibrant: ["text-on-tertiary-container"]
6224
+ },
6225
+ menuStyle: {
6226
+ baseline: ["h-6 w-6"],
6227
+ vertical: ["h-5 w-5"]
6228
+ }
6229
+ },
6230
+ compoundVariants: [
6231
+ // vertical + standard: selected/open icon → on-tertiary-container
6232
+ {
6233
+ menuStyle: "vertical",
6234
+ colorScheme: "standard",
6235
+ class: [
6236
+ "group-data-[selected]/menuitem:text-on-tertiary-container",
6237
+ "group-data-[open]/menuitem:text-on-tertiary-container"
6238
+ ]
6239
+ },
6240
+ // vertical + vibrant: selected/open icon → on-tertiary
6241
+ {
6242
+ menuStyle: "vertical",
6243
+ colorScheme: "vibrant",
6244
+ class: [
6245
+ "group-data-[selected]/menuitem:text-on-tertiary",
6246
+ "group-data-[open]/menuitem:text-on-tertiary"
6247
+ ]
6248
+ }
6249
+ ],
6250
+ defaultVariants: {
6251
+ colorScheme: "standard",
6252
+ menuStyle: "baseline"
6253
+ }
6254
+ }
6255
+ );
6256
+ var menuSectionVariants = cva(["flex flex-col w-full"]);
6257
+ var menuSectionHeaderVariants = cva(
6258
+ [
6259
+ // 32dp tall region, content vertically centred, 12dp leading padding aligned with items
6260
+ "px-3 h-8 flex items-center",
6261
+ "text-title-small",
6262
+ "select-none"
6263
+ ],
6264
+ {
6265
+ variants: {
6266
+ colorScheme: {
6267
+ standard: ["text-on-surface-variant"],
6268
+ vibrant: ["text-on-tertiary-container"]
6269
+ }
6270
+ },
6271
+ defaultVariants: {
6272
+ colorScheme: "standard"
6273
+ }
6274
+ }
6275
+ );
6276
+ var menuDividerVariants = cva(["border-t border-outline-variant", "my-0.5 mx-3"]);
6277
+ cva(["h-0.5 w-full"]);
6278
+ var menuItemTrailingTextVariants = cva(
6279
+ [
6280
+ "ml-auto shrink-0 text-label-large",
6281
+ "select-none",
6282
+ "group-data-[disabled]/menuitem:text-on-surface/38"
6283
+ ],
6284
+ {
6285
+ variants: {
6286
+ colorScheme: {
6287
+ standard: ["text-on-surface-variant"],
6288
+ vibrant: ["text-on-tertiary-container"]
6289
+ },
6290
+ menuStyle: {
6291
+ baseline: [],
6292
+ vertical: [
6293
+ "group-data-[selected]/menuitem:text-on-tertiary-container",
6294
+ "group-data-[open]/menuitem:text-on-tertiary-container"
6295
+ ]
6296
+ }
6297
+ },
6298
+ compoundVariants: [
6299
+ // vertical + vibrant: selected/open trailing text → on-tertiary
6300
+ {
6301
+ menuStyle: "vertical",
6302
+ colorScheme: "vibrant",
6303
+ class: [
6304
+ "group-data-[selected]/menuitem:text-on-tertiary",
6305
+ "group-data-[open]/menuitem:text-on-tertiary"
6306
+ ]
6307
+ }
6308
+ ],
6309
+ defaultVariants: {
6310
+ colorScheme: "standard",
6311
+ menuStyle: "baseline"
6312
+ }
6313
+ }
6314
+ );
6315
+ var menuItemDescriptionVariants = cva(
6316
+ ["text-body-medium", "select-none", "group-data-[disabled]/menuitem:text-on-surface/38"],
6317
+ {
6318
+ variants: {
6319
+ colorScheme: {
6320
+ standard: ["text-on-surface-variant"],
6321
+ vibrant: ["text-on-tertiary-container"]
6322
+ },
6323
+ menuStyle: {
6324
+ baseline: [],
6325
+ vertical: [
6326
+ "group-data-[selected]/menuitem:text-on-tertiary-container",
6327
+ "group-data-[open]/menuitem:text-on-tertiary-container"
6328
+ ]
6329
+ }
6330
+ },
6331
+ compoundVariants: [
6332
+ // vertical + vibrant: selected/open description → on-tertiary
6333
+ {
6334
+ menuStyle: "vertical",
6335
+ colorScheme: "vibrant",
6336
+ class: [
6337
+ "group-data-[selected]/menuitem:text-on-tertiary",
6338
+ "group-data-[open]/menuitem:text-on-tertiary"
6339
+ ]
6340
+ }
6341
+ ],
6342
+ defaultVariants: {
6343
+ colorScheme: "standard",
6344
+ menuStyle: "baseline"
6345
+ }
6346
+ }
6347
+ );
6348
+ cva(
6349
+ [
6350
+ "flex flex-col w-full",
6351
+ "px-1 py-0.5 gap-0.5",
6352
+ "rounded-lg first:rounded-b-sm last:rounded-t-sm",
6353
+ "shadow-elevation-1"
6354
+ ],
6355
+ {
6356
+ variants: {
6357
+ menuStyle: {
6358
+ vertical: ["bg-surface-container-low"],
6359
+ baseline: []
6360
+ },
6361
+ colorScheme: {
6362
+ standard: ["bg-surface-container-low"],
6363
+ vibrant: ["bg-tertiary-container"]
6364
+ }
6365
+ },
6366
+ compoundVariants: [
6367
+ // vertical + standard: item background = surface-container-low
6368
+ {
6369
+ menuStyle: "vertical",
6370
+ colorScheme: "standard",
6371
+ class: ["bg-surface-container-low"]
6372
+ },
6373
+ // vertical + vibrant: item background = tertiary-container
6374
+ {
6375
+ menuStyle: "vertical",
6376
+ colorScheme: "vibrant",
6377
+ class: ["bg-tertiary-container"]
6378
+ }
6379
+ ],
6380
+ defaultVariants: {
6381
+ menuStyle: "vertical",
6382
+ colorScheme: "standard"
6383
+ }
6384
+ }
6385
+ );
5950
6386
  var MenuContext = createContext(null);
5951
6387
  function useMenuContext() {
5952
6388
  return useContext(MenuContext);
@@ -5984,7 +6420,16 @@ function HeadlessMenuTrigger({
5984
6420
  const [triggerChild, menuChild] = childrenArray;
5985
6421
  return /* @__PURE__ */ jsxs(MenuTrigger$1, { ...rest, children: [
5986
6422
  /* @__PURE__ */ jsx(TriggerBridge, { children: triggerChild }),
5987
- /* @__PURE__ */ jsx(Popover, { placement, shouldFlip, offset: 4, children: menuChild })
6423
+ /* @__PURE__ */ jsx(
6424
+ Popover,
6425
+ {
6426
+ placement,
6427
+ shouldFlip,
6428
+ offset: 4,
6429
+ className: menuPopoverVariants(),
6430
+ children: menuChild
6431
+ }
6432
+ )
5988
6433
  ] });
5989
6434
  }
5990
6435
  function HeadlessMenu({
@@ -6036,192 +6481,6 @@ function HeadlessMenuDivider({
6036
6481
  }) {
6037
6482
  return /* @__PURE__ */ jsx(Separator, { ...props, className: className ?? "" });
6038
6483
  }
6039
- var menuContainerVariants = cva(
6040
- [
6041
- // Elevation
6042
- "shadow-elevation-2",
6043
- // Width constraints per MD3 spec (112dp min / 280dp max)
6044
- "min-w-28 max-w-70",
6045
- // Layout
6046
- "py-2",
6047
- // Scroll: show scrollbar when content overflows; max height avoids clipping
6048
- "overflow-y-auto",
6049
- "max-h-[calc(var(--visual-viewport-height,100vh)-2rem)]",
6050
- // Stacking
6051
- "z-50",
6052
- // Focus outline handled by React Aria
6053
- "outline-none",
6054
- // GPU compositing — promotes menu to its own compositor layer so
6055
- // scale + opacity animations run without triggering layout reflow.
6056
- "will-change-[transform,opacity]",
6057
- // Pointer events blocked during animation to prevent accidental clicks
6058
- // on menu items while the panel is still animating in or out.
6059
- "data-[entering]:pointer-events-none data-[exiting]:pointer-events-none",
6060
- // ── Enter animation ────────────────────────────────────────────────────
6061
- // @keyframes menu-enter (defined in styles.css): scale(0.8)+opacity:0 →
6062
- // scale(1)+opacity:1 in 120ms with cubic-bezier(0,0,0.2,1) (standard
6063
- // decelerate — matches Angular Material's _mat-menu-enter keyframe).
6064
- "data-[entering]:animate-[menu-enter_120ms_cubic-bezier(0,0,0.2,1)_both]",
6065
- // ── Exit animation ─────────────────────────────────────────────────────
6066
- // @keyframes menu-exit (defined in styles.css): opacity:1 → opacity:0
6067
- // in 100ms after 25ms delay, linear — matches Angular Material's
6068
- // _mat-menu-exit keyframe (fade-only, no reverse scale).
6069
- "data-[exiting]:animate-[menu-exit_100ms_25ms_linear_both]",
6070
- // ── Transform origin (placement-aware) ────────────────────────────────
6071
- // RAC sets data-placement="bottom|top|left|right" on the Popover element.
6072
- // Default (bottom): origin at top edge (menu expands downward).
6073
- "origin-top",
6074
- // top: origin at bottom edge (menu expands upward)
6075
- "data-[placement=top]:origin-bottom",
6076
- // left: origin at right edge
6077
- "data-[placement=left]:origin-right",
6078
- // right: origin at left edge
6079
- "data-[placement=right]:origin-left",
6080
- // ── Reduced motion ────────────────────────────────────────────────────
6081
- // Skip both animations entirely for users who prefer reduced motion.
6082
- "motion-reduce:data-[entering]:animate-none motion-reduce:data-[exiting]:animate-none"
6083
- ],
6084
- {
6085
- variants: {
6086
- /**
6087
- * Color scheme — drives the container background.
6088
- * baseline+standard uses a separate compound variant.
6089
- */
6090
- colorScheme: {
6091
- standard: [],
6092
- vibrant: []
6093
- },
6094
- /**
6095
- * Visual style — drives corner radius and baseline vs vertical background.
6096
- */
6097
- menuStyle: {
6098
- baseline: ["rounded-xs", "bg-surface-container"],
6099
- vertical: ["rounded-lg", "bg-surface-container-low"]
6100
- }
6101
- },
6102
- compoundVariants: [
6103
- // Vertical + vibrant: tertiary container background
6104
- {
6105
- menuStyle: "vertical",
6106
- colorScheme: "vibrant",
6107
- class: ["bg-tertiary-container"]
6108
- }
6109
- ],
6110
- defaultVariants: {
6111
- colorScheme: "standard",
6112
- menuStyle: "baseline"
6113
- }
6114
- }
6115
- );
6116
- var menuItemVariants = cva(
6117
- [
6118
- // Layout — height set by density context in MenuItem component
6119
- "relative flex w-full items-center",
6120
- "px-3 gap-3",
6121
- // Typography: Body Large per MD3 baseline spec
6122
- "text-body-large",
6123
- // Interaction
6124
- "cursor-pointer select-none outline-none",
6125
- // State layer pseudo-element
6126
- "before:absolute before:inset-0 before:rounded-[inherit]",
6127
- "before:transition-opacity before:duration-short2 before:ease-standard",
6128
- "before:opacity-0",
6129
- // Hover state layer
6130
- "hover:before:opacity-8",
6131
- // Focus visible state layer
6132
- "focus-visible:before:opacity-12",
6133
- // Active pressed state layer
6134
- "active:before:opacity-12",
6135
- // Color transition for selection
6136
- "transition-colors duration-short2 ease-standard"
6137
- ],
6138
- {
6139
- variants: {
6140
- /**
6141
- * Disabled state: reduces opacity and blocks interaction.
6142
- */
6143
- isDisabled: {
6144
- true: ["opacity-38 cursor-not-allowed pointer-events-none"],
6145
- false: []
6146
- },
6147
- /**
6148
- * Selected state: background and text color driven by compound variants.
6149
- */
6150
- isSelected: {
6151
- true: [],
6152
- false: []
6153
- },
6154
- /**
6155
- * Color scheme: drives default text and state layer colors.
6156
- * - standard: on-surface text, on-surface state layer
6157
- * - vibrant (vertical only): on-tertiary-container text + state layer
6158
- */
6159
- colorScheme: {
6160
- standard: ["text-on-surface", "before:bg-on-surface"],
6161
- vibrant: ["text-on-tertiary-container", "before:bg-on-tertiary-container"]
6162
- },
6163
- /**
6164
- * Visual style: drives corner radius on items (vertical uses rounded-lg
6165
- * inherited from container, items stay flat inside).
6166
- */
6167
- menuStyle: {
6168
- baseline: [],
6169
- vertical: []
6170
- }
6171
- },
6172
- compoundVariants: [
6173
- // ── Baseline selection (both colorSchemes) ──────────────────────────
6174
- {
6175
- isSelected: true,
6176
- menuStyle: "baseline",
6177
- class: [
6178
- "bg-surface-container-highest"
6179
- // text-on-surface already applied by standard colorScheme variant
6180
- ]
6181
- },
6182
- // ── Vertical + Standard selection ───────────────────────────────────
6183
- {
6184
- isSelected: true,
6185
- menuStyle: "vertical",
6186
- colorScheme: "standard",
6187
- class: [
6188
- "bg-tertiary-container",
6189
- "text-on-tertiary-container",
6190
- "before:bg-on-tertiary-container"
6191
- ]
6192
- },
6193
- // ── Vertical + Vibrant selection ─────────────────────────────────────
6194
- {
6195
- isSelected: true,
6196
- menuStyle: "vertical",
6197
- colorScheme: "vibrant",
6198
- class: ["bg-tertiary", "text-on-tertiary", "before:bg-on-tertiary"]
6199
- }
6200
- ],
6201
- defaultVariants: {
6202
- isDisabled: false,
6203
- isSelected: false,
6204
- colorScheme: "standard",
6205
- menuStyle: "baseline"
6206
- }
6207
- }
6208
- );
6209
- var menuSectionVariants = cva(["flex flex-col w-full"]);
6210
- var menuSectionHeaderVariants = cva([
6211
- "px-3 pt-2 pb-1",
6212
- "text-title-small text-on-surface-variant",
6213
- "select-none"
6214
- ]);
6215
- var menuDividerVariants = cva(["border-t border-outline-variant", "my-2 mx-0"]);
6216
- cva(["h-2 w-full"]);
6217
- var menuItemTrailingTextVariants = cva([
6218
- "ml-auto shrink-0 text-label-large text-on-surface-variant",
6219
- "select-none"
6220
- ]);
6221
- var menuItemDescriptionVariants = cva([
6222
- "text-body-medium text-on-surface-variant",
6223
- "select-none"
6224
- ]);
6225
6484
  var Menu = forwardRef(function Menu2({
6226
6485
  children,
6227
6486
  className,
@@ -6281,7 +6540,13 @@ function CheckIcon() {
6281
6540
  }
6282
6541
  );
6283
6542
  }
6284
- var DENSITY_HEIGHT = {
6543
+ var BASELINE_DENSITY_HEIGHT = {
6544
+ 0: "h-12",
6545
+ [-1]: "h-11",
6546
+ [-2]: "h-10",
6547
+ [-3]: "h-9"
6548
+ };
6549
+ var VERTICAL_DENSITY_HEIGHT = {
6285
6550
  0: "h-12",
6286
6551
  [-1]: "h-11",
6287
6552
  [-2]: "h-10",
@@ -6304,19 +6569,18 @@ var MenuItem = forwardRef(function MenuItem2({
6304
6569
  const menuStyle = ctx?.menuStyle ?? "baseline";
6305
6570
  const density = ctx?.density ?? 0;
6306
6571
  const selectionMode = ctx?.selectionMode;
6307
- const heightClass = DENSITY_HEIGHT[density];
6572
+ const heightClass = menuStyle === "vertical" ? VERTICAL_DENSITY_HEIGHT[density] : BASELINE_DENSITY_HEIGHT[density];
6308
6573
  const isSelectionMenu = selectionMode != null;
6309
6574
  const { ripples, onMouseDown } = useRipple({ disabled: disableRipple });
6310
- const computeClassName = ({ isDisabled, isSelected }) => cn(
6311
- menuItemVariants({
6312
- isDisabled,
6313
- isSelected: isSelected ?? false,
6314
- colorScheme,
6315
- menuStyle
6316
- }),
6575
+ const computeClassName = ({ isSelected }) => cn(
6576
+ menuItemVariants({ colorScheme, menuStyle }),
6577
+ // group/menuitem scope: all slot children read state via group-data-[x]/menuitem
6578
+ "group/menuitem",
6317
6579
  // Height: auto when description is present (multi-line), otherwise density
6318
6580
  description ? "min-h-12 py-2 h-auto items-start" : heightClass,
6319
- className
6581
+ className,
6582
+ // Silence the isSelected lint — value consumed in render-prop below
6583
+ isSelected ? "" : ""
6320
6584
  );
6321
6585
  return /* @__PURE__ */ jsx(
6322
6586
  HeadlessMenuItem,
@@ -6326,24 +6590,48 @@ var MenuItem = forwardRef(function MenuItem2({
6326
6590
  className: computeClassName,
6327
6591
  onMouseDown,
6328
6592
  children: ({ isSelected }) => /* @__PURE__ */ jsxs(Fragment, { children: [
6329
- !disableRipple && /* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute inset-0 z-0 overflow-hidden rounded-[inherit]", children: ripples }),
6330
- (leadingIcon != null || isSelectionMenu) && /* @__PURE__ */ jsx(
6593
+ /* @__PURE__ */ jsx(
6594
+ "span",
6595
+ {
6596
+ "aria-hidden": "true",
6597
+ "data-testid": "menuitem-highlight",
6598
+ className: menuItemHighlightVariants({ colorScheme, menuStyle })
6599
+ }
6600
+ ),
6601
+ /* @__PURE__ */ jsx(
6602
+ "span",
6603
+ {
6604
+ "aria-hidden": "true",
6605
+ className: menuItemStateLayerVariants({ colorScheme, menuStyle })
6606
+ }
6607
+ ),
6608
+ /* @__PURE__ */ jsx(
6331
6609
  "span",
6332
6610
  {
6333
- className: "text-on-surface-variant relative z-10 flex h-6 w-6 shrink-0 items-center justify-center",
6334
6611
  "aria-hidden": "true",
6335
- children: isSelectionMenu && leadingIcon == null ? isSelected ? /* @__PURE__ */ jsx(CheckIcon, {}) : null : leadingIcon
6612
+ "data-testid": "menuitem-focus-ring",
6613
+ className: menuItemFocusRingVariants()
6336
6614
  }
6337
6615
  ),
6616
+ !disableRipple && /* @__PURE__ */ jsx(
6617
+ "span",
6618
+ {
6619
+ className: cn(
6620
+ "pointer-events-none absolute inset-0 z-[3] overflow-hidden rounded-[inherit]"
6621
+ ),
6622
+ children: ripples
6623
+ }
6624
+ ),
6625
+ (leadingIcon != null || isSelectionMenu) && /* @__PURE__ */ jsx("span", { className: menuItemIconVariants({ colorScheme, menuStyle }), "aria-hidden": "true", children: isSelectionMenu && leadingIcon == null ? isSelected ? /* @__PURE__ */ jsx(CheckIcon, {}) : null : leadingIcon }),
6338
6626
  description != null ? /* @__PURE__ */ jsxs("span", { className: "relative z-10 flex min-w-0 flex-1 flex-col", children: [
6339
- /* @__PURE__ */ jsx("span", { className: "text-body-large", children }),
6340
- /* @__PURE__ */ jsx("span", { className: menuItemDescriptionVariants(), children: description })
6341
- ] }) : /* @__PURE__ */ jsx("span", { className: "text-body-large relative z-10 min-w-0 flex-1", children }),
6627
+ /* @__PURE__ */ jsx("span", { className: "text-label-large group-data-[disabled]/menuitem:text-on-surface/38", children }),
6628
+ /* @__PURE__ */ jsx("span", { className: menuItemDescriptionVariants({ colorScheme, menuStyle }), children: description })
6629
+ ] }) : /* @__PURE__ */ jsx("span", { className: "text-label-large group-data-[disabled]/menuitem:text-on-surface/38 relative z-10 min-w-0 flex-1", children }),
6342
6630
  badge != null && /* @__PURE__ */ jsx("span", { className: "relative z-10 shrink-0", children: badge }),
6343
6631
  trailingIcon != null && trailingText == null && /* @__PURE__ */ jsx(
6344
6632
  "span",
6345
6633
  {
6346
- className: "text-on-surface-variant relative z-10 ml-auto flex h-6 w-6 shrink-0 items-center justify-center",
6634
+ className: cn(menuItemIconVariants({ colorScheme, menuStyle }), "ml-auto"),
6347
6635
  "aria-hidden": "true",
6348
6636
  children: trailingIcon
6349
6637
  }
@@ -6351,7 +6639,10 @@ var MenuItem = forwardRef(function MenuItem2({
6351
6639
  trailingText != null && trailingIcon == null && /* @__PURE__ */ jsx(
6352
6640
  "span",
6353
6641
  {
6354
- className: cn(menuItemTrailingTextVariants(), "relative z-10"),
6642
+ className: cn(
6643
+ menuItemTrailingTextVariants({ colorScheme, menuStyle }),
6644
+ "relative z-10"
6645
+ ),
6355
6646
  "aria-keyshortcuts": trailingText,
6356
6647
  children: trailingText
6357
6648
  }
@@ -6367,6 +6658,8 @@ function MenuSection({
6367
6658
  className,
6368
6659
  "aria-label": ariaLabel
6369
6660
  }) {
6661
+ const ctx = useMenuContext();
6662
+ const colorScheme = ctx?.colorScheme ?? "standard";
6370
6663
  const sectionAriaLabel = ariaLabel ?? header;
6371
6664
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6372
6665
  showDivider && /* @__PURE__ */ jsx(HeadlessMenuDivider, { className: menuDividerVariants() }),
@@ -6376,7 +6669,7 @@ function MenuSection({
6376
6669
  "aria-label": sectionAriaLabel,
6377
6670
  className: cn(menuSectionVariants(), className),
6378
6671
  children: [
6379
- header && /* @__PURE__ */ jsx(Header, { className: menuSectionHeaderVariants(), "aria-hidden": "true", children: header }),
6672
+ header && /* @__PURE__ */ jsx(Header, { className: menuSectionHeaderVariants({ colorScheme }), "aria-hidden": "true", children: header }),
6380
6673
  children
6381
6674
  ]
6382
6675
  }