@tinybigui/react 0.8.1 → 0.9.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.cjs CHANGED
@@ -6468,18 +6468,43 @@ function SnackbarProvider({ children, maxVisible = 5 }) {
6468
6468
  )
6469
6469
  ] });
6470
6470
  }
6471
+ function stripAriaProps(handlers) {
6472
+ const {
6473
+ isDisabled: _isDisabled,
6474
+ onPress: _onPress,
6475
+ onPressStart: _onPressStart,
6476
+ onPressEnd: _onPressEnd,
6477
+ onPressChange: _onPressChange,
6478
+ onPressUp: _onPressUp,
6479
+ ...html
6480
+ } = handlers;
6481
+ return html;
6482
+ }
6483
+ function buildPressCallbacks(onPressStart, onPressEnd) {
6484
+ return {
6485
+ ...onPressStart !== void 0 && { onPressStart },
6486
+ ...onPressEnd !== void 0 && { onPressEnd }
6487
+ };
6488
+ }
6471
6489
  var AssistChipImpl = React.forwardRef(
6472
- ({ label, onPress, isDisabled, className, onMouseDown, children }, forwardedRef) => {
6490
+ ({ label, onPress, isDisabled, className, onMouseDown, children, bodyPassthrough }, forwardedRef) => {
6473
6491
  const internalRef = React.useRef(null);
6474
6492
  const ref = forwardedRef ?? internalRef;
6475
6493
  const { buttonProps } = reactAria.useButton(
6476
6494
  {
6477
6495
  ...onPress !== void 0 && { onPress },
6478
- ...isDisabled !== void 0 && { isDisabled }
6496
+ ...isDisabled !== void 0 && { isDisabled },
6497
+ ...buildPressCallbacks(bodyPassthrough?.onPressStart, bodyPassthrough?.onPressEnd)
6479
6498
  },
6480
6499
  ref
6481
6500
  );
6482
- const mergedProps = utils.mergeProps(buttonProps, { onMouseDown });
6501
+ const htmlPassthrough = stripAriaProps(bodyPassthrough?.eventHandlers ?? {});
6502
+ const mergedProps = utils.mergeProps(
6503
+ buttonProps,
6504
+ { onMouseDown },
6505
+ bodyPassthrough?.dataAttributes ?? {},
6506
+ htmlPassthrough
6507
+ );
6483
6508
  return /* @__PURE__ */ jsxRuntime.jsx("button", { ...mergedProps, type: "button", ref, className, children: children ?? label });
6484
6509
  }
6485
6510
  );
@@ -6493,7 +6518,8 @@ var FilterChipImpl = React.forwardRef(
6493
6518
  isDisabled,
6494
6519
  className,
6495
6520
  onMouseDown,
6496
- children
6521
+ children,
6522
+ bodyPassthrough
6497
6523
  }, forwardedRef) => {
6498
6524
  const internalRef = React.useRef(null);
6499
6525
  const ref = forwardedRef ?? internalRef;
@@ -6501,11 +6527,18 @@ var FilterChipImpl = React.forwardRef(
6501
6527
  ...selected !== void 0 && { isSelected: selected },
6502
6528
  ...defaultSelected !== void 0 && { defaultSelected },
6503
6529
  ...onSelectionChange !== void 0 && { onChange: onSelectionChange },
6504
- ...isDisabled !== void 0 && { isDisabled }
6530
+ ...isDisabled !== void 0 && { isDisabled },
6531
+ ...buildPressCallbacks(bodyPassthrough?.onPressStart, bodyPassthrough?.onPressEnd)
6505
6532
  };
6506
6533
  const state = reactStately.useToggleState(toggleProps);
6507
6534
  const { buttonProps } = reactAria.useToggleButton(toggleProps, state, ref);
6508
- const mergedProps = utils.mergeProps(buttonProps, { onMouseDown });
6535
+ const htmlPassthrough = stripAriaProps(bodyPassthrough?.eventHandlers ?? {});
6536
+ const mergedProps = utils.mergeProps(
6537
+ buttonProps,
6538
+ { onMouseDown },
6539
+ bodyPassthrough?.dataAttributes ?? {},
6540
+ htmlPassthrough
6541
+ );
6509
6542
  return /* @__PURE__ */ jsxRuntime.jsx("button", { ...mergedProps, type: "button", ref, className, children: children ?? label });
6510
6543
  }
6511
6544
  );
@@ -6519,7 +6552,9 @@ var InputChipImpl = React.forwardRef(
6519
6552
  onMouseDown,
6520
6553
  removeIcon,
6521
6554
  removeButtonClassName,
6522
- children
6555
+ children,
6556
+ bodyPassthrough,
6557
+ removePassthrough
6523
6558
  }, forwardedRef) => {
6524
6559
  const chipRef = React.useRef(null);
6525
6560
  const ref = forwardedRef ?? chipRef;
@@ -6527,7 +6562,8 @@ var InputChipImpl = React.forwardRef(
6527
6562
  const { buttonProps: chipButtonProps } = reactAria.useButton(
6528
6563
  {
6529
6564
  "aria-label": label,
6530
- ...isDisabled !== void 0 && { isDisabled }
6565
+ ...isDisabled !== void 0 && { isDisabled },
6566
+ ...buildPressCallbacks(bodyPassthrough?.onPressStart, bodyPassthrough?.onPressEnd)
6531
6567
  },
6532
6568
  ref
6533
6569
  );
@@ -6535,7 +6571,8 @@ var InputChipImpl = React.forwardRef(
6535
6571
  {
6536
6572
  "aria-label": `Remove ${label}`,
6537
6573
  onPress: () => onRemove?.(),
6538
- ...isDisabled !== void 0 && { isDisabled }
6574
+ ...isDisabled !== void 0 && { isDisabled },
6575
+ ...buildPressCallbacks(removePassthrough?.onPressStart, removePassthrough?.onPressEnd)
6539
6576
  },
6540
6577
  removeRef
6541
6578
  );
@@ -6545,13 +6582,25 @@ var InputChipImpl = React.forwardRef(
6545
6582
  onRemove?.();
6546
6583
  }
6547
6584
  };
6548
- const mergedChipProps = utils.mergeProps(chipButtonProps, { onKeyDown: handleKeyDown, onMouseDown });
6585
+ const htmlBodyPassthrough = stripAriaProps(bodyPassthrough?.eventHandlers ?? {});
6586
+ const htmlRemovePassthrough = stripAriaProps(removePassthrough?.eventHandlers ?? {});
6587
+ const mergedChipProps = utils.mergeProps(
6588
+ chipButtonProps,
6589
+ { onKeyDown: handleKeyDown, onMouseDown },
6590
+ bodyPassthrough?.dataAttributes ?? {},
6591
+ htmlBodyPassthrough
6592
+ );
6593
+ const mergedRemoveProps = utils.mergeProps(
6594
+ removeButtonProps,
6595
+ removePassthrough?.dataAttributes ?? {},
6596
+ htmlRemovePassthrough
6597
+ );
6549
6598
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className, children: [
6550
6599
  /* @__PURE__ */ jsxRuntime.jsx("button", { ...mergedChipProps, type: "button", ref, children: children ?? label }),
6551
6600
  /* @__PURE__ */ jsxRuntime.jsx(
6552
6601
  "button",
6553
6602
  {
6554
- ...removeButtonProps,
6603
+ ...mergedRemoveProps,
6555
6604
  type: "button",
6556
6605
  ref: removeRef,
6557
6606
  className: removeButtonClassName,
@@ -6563,17 +6612,24 @@ var InputChipImpl = React.forwardRef(
6563
6612
  );
6564
6613
  InputChipImpl.displayName = "InputChipImpl";
6565
6614
  var SuggestionChipImpl = React.forwardRef(
6566
- ({ label, onPress, isDisabled, className, onMouseDown, children }, forwardedRef) => {
6615
+ ({ label, onPress, isDisabled, className, onMouseDown, children, bodyPassthrough }, forwardedRef) => {
6567
6616
  const internalRef = React.useRef(null);
6568
6617
  const ref = forwardedRef ?? internalRef;
6569
6618
  const { buttonProps } = reactAria.useButton(
6570
6619
  {
6571
6620
  ...onPress !== void 0 && { onPress },
6572
- ...isDisabled !== void 0 && { isDisabled }
6621
+ ...isDisabled !== void 0 && { isDisabled },
6622
+ ...buildPressCallbacks(bodyPassthrough?.onPressStart, bodyPassthrough?.onPressEnd)
6573
6623
  },
6574
6624
  ref
6575
6625
  );
6576
- const mergedProps = utils.mergeProps(buttonProps, { onMouseDown });
6626
+ const htmlPassthrough = stripAriaProps(bodyPassthrough?.eventHandlers ?? {});
6627
+ const mergedProps = utils.mergeProps(
6628
+ buttonProps,
6629
+ { onMouseDown },
6630
+ bodyPassthrough?.dataAttributes ?? {},
6631
+ htmlPassthrough
6632
+ );
6577
6633
  return /* @__PURE__ */ jsxRuntime.jsx("button", { ...mergedProps, type: "button", ref, className, children: children ?? label });
6578
6634
  }
6579
6635
  );
@@ -6593,123 +6649,246 @@ var ChipHeadless = React.forwardRef((props, ref) => {
6593
6649
  ChipHeadless.displayName = "ChipHeadless";
6594
6650
  var chipVariants = classVarianceAuthority.cva(
6595
6651
  [
6596
- // Base layout — always applied
6597
- "relative inline-flex items-center overflow-hidden rounded-sm h-8",
6598
- "text-label-large cursor-pointer gap-1 group px-4",
6599
- // Focus ring
6600
- "focus-visible:outline-primary focus-visible:outline-2 focus-visible:outline-offset-2"
6652
+ // Layout + shape
6653
+ "relative inline-flex items-center justify-center",
6654
+ "h-8 rounded-sm cursor-pointer select-none",
6655
+ "text-label-large gap-2",
6656
+ // Base padding (no icons)
6657
+ "px-4",
6658
+ // Content-flag padding overrides (self-targeting)
6659
+ "data-[with-leading]:pl-2 data-[with-leading]:pr-4",
6660
+ "data-[with-trailing]:pr-2",
6661
+ // Effects transition (color/bg/shadow/border)
6662
+ "transition-[background-color,border-color,box-shadow,color]",
6663
+ "duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6664
+ // Disabled self-targeting
6665
+ "data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none",
6666
+ "data-[disabled]:text-on-surface/38 data-[disabled]:border-on-surface/12",
6667
+ "data-[disabled]:bg-transparent data-[disabled]:shadow-none"
6601
6668
  ],
6602
6669
  {
6603
6670
  variants: {
6604
6671
  /**
6605
- * MD3 chip type — determines interaction model and default styling.
6672
+ * MD3 chip type — determines base color tokens.
6606
6673
  */
6607
6674
  chipType: {
6608
- assist: "",
6609
- // Filter and Input chips have a fixed tonal surface style.
6610
- // The transition is on the base class so deselection also animates
6611
- // (adding it only in the selected compound variant would mean the
6612
- // transition property disappears at the same moment the color reverts,
6613
- // causing an instant jump back to the unselected color).
6614
- filter: "bg-surface-container-low text-on-surface border border-outline transition-[background-color,color] duration-short4 ease-standard",
6615
- input: "bg-surface-container-low text-on-surface border border-outline",
6616
- suggestion: ""
6675
+ /**
6676
+ * Assist transparent + outline border; label on-surface; leading icon primary.
6677
+ * State layer color: on-surface.
6678
+ */
6679
+ assist: ["bg-transparent border border-outline text-on-surface"],
6680
+ /**
6681
+ * Filter transparent + outline border; label on-surface-variant.
6682
+ * Selected state via group-data selectors (no CVA variant key).
6683
+ * State layer color: on-surface-variant → on-secondary-container when selected.
6684
+ */
6685
+ filter: [
6686
+ "bg-transparent border border-outline text-on-surface-variant",
6687
+ // Selected: secondary-container fill, no border, on-secondary-container label
6688
+ "group-data-[selected]/chip:bg-secondary-container",
6689
+ "group-data-[selected]/chip:border-0",
6690
+ "group-data-[selected]/chip:text-on-secondary-container",
6691
+ // Disabled + selected overrides (self-targeting, doubled to win over singly-chained selected)
6692
+ "data-[selected]:data-[disabled]:bg-on-surface/12",
6693
+ "data-[selected]:data-[disabled]:border-0"
6694
+ ],
6695
+ /**
6696
+ * Input — transparent + outline-variant border; label/icons on-surface-variant.
6697
+ * State layer color: on-surface-variant.
6698
+ */
6699
+ input: ["bg-transparent border border-outline-variant text-on-surface-variant"],
6700
+ /**
6701
+ * Suggestion — transparent + outline border; label on-surface-variant.
6702
+ * State layer color: on-surface-variant.
6703
+ */
6704
+ suggestion: ["bg-transparent border border-outline text-on-surface-variant"]
6617
6705
  },
6618
6706
  /**
6619
- * Surface style for Assist and Suggestion chips only.
6620
- * Applied via compound variants so it has no effect on Filter/Input.
6707
+ * Surface style elevated adds shadow and surface-container-low background.
6708
+ * All four chip types support elevated.
6709
+ * Note: "flat" and the deprecated "tonal" both resolve to the same base style
6710
+ * (transparent + border from chipType). The elevated compound variant overrides.
6621
6711
  */
6622
6712
  surface: {
6623
- tonal: "",
6624
- elevated: ""
6625
- },
6626
- /**
6627
- * Selected state — only meaningful for Filter chips.
6628
- * Applied via compound variant.
6629
- */
6630
- selected: {
6631
- true: "",
6632
- false: ""
6633
- },
6634
- /**
6635
- * MD3 disabled state: content 38% opacity, border 12% opacity, no background.
6636
- * Kept here only for `pointer-events-none`; color/bg overrides live in the
6637
- * disabled compound variants at the bottom so they win over surface compounds.
6638
- */
6639
- isDisabled: {
6640
- true: "pointer-events-none",
6641
- false: ""
6642
- },
6643
- /**
6644
- * Adjusts leading padding when a leading icon is present.
6645
- * Overrides the base `px-4` → `pl-3 pr-4`.
6646
- */
6647
- hasLeadingIcon: {
6648
- true: "pl-3 pr-4",
6649
- false: ""
6650
- },
6651
- /**
6652
- * Adjusts trailing padding for Input chips with a remove button.
6653
- * Takes precedence over hasLeadingIcon via tailwind-merge: `pl-3 pr-3`.
6654
- */
6655
- hasRemoveButton: {
6656
- true: "pl-3 pr-3",
6657
- false: ""
6713
+ flat: "",
6714
+ elevated: "",
6715
+ /** @deprecated Use `flat` instead. */
6716
+ tonal: ""
6658
6717
  }
6659
6718
  },
6660
6719
  compoundVariants: [
6661
- // ── Assist chip surfaces ───────────────────────────────────────────────
6720
+ // ── Elevated surface (all chip types) ─────────────────────────────────
6721
+ // Shared elevated base: surface-container-low fill, no border, level-1 elevation
6662
6722
  {
6723
+ surface: "elevated",
6663
6724
  chipType: "assist",
6664
- surface: "tonal",
6665
- className: "bg-surface-container-low text-on-surface border border-outline"
6725
+ className: [
6726
+ "bg-surface-container-low border-0 shadow-elevation-1",
6727
+ "data-[hovered]:shadow-elevation-2",
6728
+ "data-[focus-visible]:shadow-elevation-1",
6729
+ "data-[pressed]:data-[pressed]:shadow-elevation-1"
6730
+ ]
6666
6731
  },
6667
6732
  {
6668
- chipType: "assist",
6669
6733
  surface: "elevated",
6734
+ chipType: "filter",
6670
6735
  className: [
6671
- "bg-surface-container-low text-on-surface shadow-elevation-1",
6672
- "hover:shadow-elevation-2 transition-shadow duration-short2 ease-standard"
6736
+ "bg-surface-container-low border-0 shadow-elevation-1",
6737
+ "data-[hovered]:shadow-elevation-2",
6738
+ "data-[focus-visible]:shadow-elevation-1",
6739
+ "data-[pressed]:data-[pressed]:shadow-elevation-1",
6740
+ // Selected overrides bg; elevation stays
6741
+ "group-data-[selected]/chip:bg-secondary-container"
6673
6742
  ]
6674
6743
  },
6675
- // ── Suggestion chip surfaces ───────────────────────────────────────────
6676
6744
  {
6677
- chipType: "suggestion",
6678
- surface: "tonal",
6679
- className: "bg-surface-container-low text-on-surface border border-outline"
6745
+ surface: "elevated",
6746
+ chipType: "input",
6747
+ className: [
6748
+ "bg-surface-container-low border-0 shadow-elevation-1",
6749
+ "data-[hovered]:shadow-elevation-2",
6750
+ "data-[focus-visible]:shadow-elevation-1",
6751
+ "data-[pressed]:data-[pressed]:shadow-elevation-1"
6752
+ ]
6680
6753
  },
6681
6754
  {
6682
- chipType: "suggestion",
6683
6755
  surface: "elevated",
6756
+ chipType: "suggestion",
6684
6757
  className: [
6685
- "bg-surface-container-low text-on-surface shadow-elevation-1",
6686
- "hover:shadow-elevation-2 transition-shadow duration-short2 ease-standard"
6758
+ "bg-surface-container-low border-0 shadow-elevation-1",
6759
+ "data-[hovered]:shadow-elevation-2",
6760
+ "data-[focus-visible]:shadow-elevation-1",
6761
+ "data-[pressed]:data-[pressed]:shadow-elevation-1"
6687
6762
  ]
6688
6763
  },
6689
- // ── Filter chip selected state ─────────────────────────────────────────
6764
+ // Deprecated tonal maps to flat (same as no override)
6765
+ {
6766
+ surface: "tonal",
6767
+ chipType: "assist",
6768
+ className: ""
6769
+ },
6690
6770
  {
6771
+ surface: "tonal",
6691
6772
  chipType: "filter",
6692
- selected: true,
6693
- className: "bg-secondary-container text-on-secondary-container border-0"
6773
+ className: ""
6694
6774
  },
6695
- // ── Disabled overrides — placed last so they always win ────────────────
6696
- // These must follow all surface/selection compound variants to ensure
6697
- // tailwind-merge keeps the disabled classes over any surface classes.
6698
6775
  {
6699
- isDisabled: true,
6700
- className: "text-on-surface/38 border-on-surface/12 bg-transparent"
6776
+ surface: "tonal",
6777
+ chipType: "input",
6778
+ className: ""
6779
+ },
6780
+ {
6781
+ surface: "tonal",
6782
+ chipType: "suggestion",
6783
+ className: ""
6701
6784
  }
6702
6785
  ],
6703
6786
  defaultVariants: {
6704
6787
  chipType: "assist",
6705
- surface: "tonal",
6706
- selected: false,
6707
- isDisabled: false,
6708
- hasLeadingIcon: false,
6709
- hasRemoveButton: false
6788
+ surface: "flat"
6710
6789
  }
6711
6790
  }
6712
6791
  );
6792
+ var chipStateLayerVariants = classVarianceAuthority.cva(
6793
+ [
6794
+ "absolute inset-0 rounded-[inherit] overflow-hidden pointer-events-none opacity-0",
6795
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6796
+ // Hover: 8%
6797
+ "group-data-[hovered]/chip:opacity-8",
6798
+ // Focus: 10%
6799
+ "group-data-[focus-visible]/chip:opacity-10",
6800
+ // Pressed: 10%, doubled selector wins over hover
6801
+ "group-data-[pressed]/chip:group-data-[pressed]/chip:opacity-10",
6802
+ // No state layer when disabled
6803
+ "group-data-[disabled]/chip:hidden"
6804
+ ],
6805
+ {
6806
+ variants: {
6807
+ chipType: {
6808
+ assist: "bg-on-surface",
6809
+ filter: [
6810
+ "bg-on-surface-variant",
6811
+ // Selected: switch to on-secondary-container color
6812
+ "group-data-[selected]/chip:bg-on-secondary-container"
6813
+ ],
6814
+ input: "bg-on-surface-variant",
6815
+ suggestion: "bg-on-surface-variant"
6816
+ }
6817
+ },
6818
+ defaultVariants: { chipType: "assist" }
6819
+ }
6820
+ );
6821
+ var chipFocusRingVariants = classVarianceAuthority.cva([
6822
+ "pointer-events-none absolute inset-[-3px] rounded-sm",
6823
+ "outline outline-2 outline-offset-0 outline-secondary",
6824
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6825
+ "opacity-0",
6826
+ "group-data-[focus-visible]/chip:opacity-100"
6827
+ ]);
6828
+ var chipLeadingIconVariants = classVarianceAuthority.cva(
6829
+ [
6830
+ "relative z-10 inline-flex shrink-0 items-center justify-center size-[18px]",
6831
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6832
+ "group-data-[disabled]/chip:text-on-surface/38"
6833
+ ],
6834
+ {
6835
+ variants: {
6836
+ chipType: {
6837
+ assist: "text-primary",
6838
+ filter: [
6839
+ "text-on-surface-variant",
6840
+ "group-data-[selected]/chip:text-on-secondary-container"
6841
+ ],
6842
+ input: "text-on-surface-variant",
6843
+ suggestion: "text-on-surface-variant"
6844
+ }
6845
+ },
6846
+ defaultVariants: { chipType: "assist" }
6847
+ }
6848
+ );
6849
+ var chipTrailingIconVariants = classVarianceAuthority.cva([
6850
+ "relative z-10 inline-flex shrink-0 items-center justify-center size-[18px]",
6851
+ "text-on-surface-variant",
6852
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6853
+ "group-data-[disabled]/chip:text-on-surface/38"
6854
+ ]);
6855
+ var chipCheckmarkVariants = classVarianceAuthority.cva([
6856
+ "inline-flex overflow-hidden shrink-0",
6857
+ // Spatial spring for width (moves adjacent text — this is a spatial animation)
6858
+ "transition-[width] duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial",
6859
+ // Collapsed state
6860
+ "w-0",
6861
+ // Expanded state when selected
6862
+ "group-data-[selected]/chip:w-[18px]"
6863
+ ]);
6864
+ var chipCheckmarkIconVariants = classVarianceAuthority.cva([
6865
+ "inline-flex items-center justify-center size-[18px] shrink-0",
6866
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6867
+ "opacity-0",
6868
+ "group-data-[selected]/chip:opacity-100",
6869
+ // Color: on-secondary-container when selected; inherits on-surface-variant at rest (invisible)
6870
+ "text-on-secondary-container",
6871
+ "group-data-[disabled]/chip:text-on-surface/38"
6872
+ ]);
6873
+ var chipLabelVariants = classVarianceAuthority.cva(["relative z-10 inline-flex items-center"]);
6874
+ var chipRemoveButtonVariants = classVarianceAuthority.cva([
6875
+ "relative z-10 inline-flex size-[18px] shrink-0 items-center justify-center",
6876
+ "rounded-full cursor-pointer",
6877
+ "text-on-surface-variant",
6878
+ "group/chip-remove",
6879
+ "transition-colors duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6880
+ "data-[disabled]:text-on-surface/38 data-[disabled]:cursor-not-allowed data-[disabled]:pointer-events-none"
6881
+ ]);
6882
+ var chipRemoveStateLayerVariants = classVarianceAuthority.cva([
6883
+ // Slightly larger circle (32dp touch target centered on 18dp icon)
6884
+ "absolute inset-[-7px] rounded-full pointer-events-none opacity-0",
6885
+ "bg-on-surface-variant",
6886
+ "transition-opacity duration-spring-standard-fast-effects ease-spring-standard-fast-effects",
6887
+ "group-data-[hovered]/chip-remove:opacity-8",
6888
+ "group-data-[focus-visible]/chip-remove:opacity-10",
6889
+ "group-data-[pressed]/chip-remove:group-data-[pressed]/chip-remove:opacity-10",
6890
+ "group-data-[disabled]/chip-remove:hidden"
6891
+ ]);
6713
6892
  var CloseIcon2 = () => /* @__PURE__ */ jsxRuntime.jsx(
6714
6893
  "svg",
6715
6894
  {
@@ -6734,22 +6913,11 @@ var CheckIcon2 = () => /* @__PURE__ */ jsxRuntime.jsx(
6734
6913
  children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
6735
6914
  }
6736
6915
  );
6737
- var StateLayer = () => /* @__PURE__ */ jsxRuntime.jsx(
6738
- "span",
6739
- {
6740
- "aria-hidden": "true",
6741
- className: cn(
6742
- "bg-on-surface pointer-events-none absolute inset-0 rounded-sm opacity-0",
6743
- "duration-spring-standard-fast-effects ease-spring-standard-fast-effects transition-opacity",
6744
- "group-focus-within:opacity-12 group-hover:opacity-8 group-active:opacity-12"
6745
- )
6746
- }
6747
- );
6748
6916
  var Chip = React.forwardRef(
6749
6917
  ({
6750
6918
  type,
6751
6919
  label,
6752
- surface = "tonal",
6920
+ surface: surfaceProp = "flat",
6753
6921
  selected,
6754
6922
  defaultSelected,
6755
6923
  onSelectionChange,
@@ -6760,6 +6928,17 @@ var Chip = React.forwardRef(
6760
6928
  isDisabled = false,
6761
6929
  className
6762
6930
  }, ref) => {
6931
+ const surface = (() => {
6932
+ if (surfaceProp === "tonal") {
6933
+ if (process.env.NODE_ENV !== "production") {
6934
+ console.warn(
6935
+ '[Chip] surface="tonal" is deprecated. Use surface="flat" instead. "tonal" will be removed in a future minor version.'
6936
+ );
6937
+ }
6938
+ return "flat";
6939
+ }
6940
+ return surfaceProp;
6941
+ })();
6763
6942
  const [localSelected, setLocalSelected] = React.useState(defaultSelected ?? false);
6764
6943
  const isControlled = selected !== void 0;
6765
6944
  const effectiveSelected = type === "filter" ? isControlled ? selected : localSelected : false;
@@ -6772,8 +6951,16 @@ var Chip = React.forwardRef(
6772
6951
  },
6773
6952
  [isControlled, onSelectionChange]
6774
6953
  );
6954
+ const [isPressed, setIsPressed] = React.useState(false);
6955
+ const handlePressStart = React.useCallback(() => setIsPressed(true), []);
6956
+ const handlePressEnd = React.useCallback(() => setIsPressed(false), []);
6957
+ const { isHovered, hoverProps } = reactAria.useHover({ isDisabled });
6958
+ const { isFocusVisible, focusProps } = reactAria.useFocusRing();
6959
+ const [isRemovePressed, setIsRemovePressed] = React.useState(false);
6960
+ const { isHovered: isRemoveHovered, hoverProps: removeHoverProps } = reactAria.useHover({ isDisabled });
6961
+ const { isFocusVisible: isRemoveFocusVisible, focusProps: removeFocusProps } = reactAria.useFocusRing();
6775
6962
  const { onMouseDown: handleRipple, ripples } = useRipple({ disabled: isDisabled });
6776
- const hasLeadingIcon = Boolean(leadingIcon);
6963
+ const hasLeadingIcon = Boolean(leadingIcon) || type === "filter";
6777
6964
  const [isRemoving, setIsRemoving] = React.useState(false);
6778
6965
  const handleRemove = React.useCallback(() => {
6779
6966
  setIsRemoving(true);
@@ -6783,35 +6970,38 @@ var Chip = React.forwardRef(
6783
6970
  onRemove?.();
6784
6971
  }
6785
6972
  }, [isRemoving, onRemove]);
6786
- const chipClass = () => cn(
6787
- chipVariants({
6788
- chipType: type,
6789
- surface: type === "assist" || type === "suggestion" ? surface : void 0,
6790
- selected: type === "filter" ? effectiveSelected : void 0,
6791
- isDisabled,
6792
- hasLeadingIcon,
6793
- hasRemoveButton: false
6794
- }),
6795
- className
6796
- );
6973
+ const bodyDataAttrs = getInteractionDataAttributes({
6974
+ isHovered,
6975
+ isFocusVisible,
6976
+ isPressed,
6977
+ ...type === "filter" && { isSelected: effectiveSelected },
6978
+ isDisabled
6979
+ });
6980
+ const rootClass = cn(chipVariants({ chipType: type, surface }), "group/chip", className);
6797
6981
  if (type === "input") {
6982
+ const removeDataAttrs = getInteractionDataAttributes({
6983
+ isHovered: isRemoveHovered,
6984
+ isFocusVisible: isRemoveFocusVisible,
6985
+ isPressed: isRemovePressed,
6986
+ isDisabled
6987
+ });
6798
6988
  return /* @__PURE__ */ jsxRuntime.jsxs(
6799
6989
  "span",
6800
6990
  {
6801
6991
  className: cn(
6802
- chipVariants({
6803
- chipType: "input",
6804
- isDisabled,
6805
- hasLeadingIcon,
6806
- hasRemoveButton: true
6807
- }),
6992
+ chipVariants({ chipType: "input", surface }),
6993
+ "group/chip",
6808
6994
  isRemoving && "animate-md-fade-out",
6809
6995
  className
6810
6996
  ),
6997
+ ...bodyDataAttrs,
6998
+ "data-with-leading": hasLeadingIcon ? "" : void 0,
6999
+ "data-with-trailing": "",
6811
7000
  onAnimationEnd: handleAnimationEnd,
6812
7001
  children: [
6813
7002
  ripples,
6814
- /* @__PURE__ */ jsxRuntime.jsx(StateLayer, {}),
7003
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipStateLayerVariants({ chipType: "input" })), "aria-hidden": "true" }),
7004
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipFocusRingVariants()), "aria-hidden": "true" }),
6815
7005
  /* @__PURE__ */ jsxRuntime.jsxs(
6816
7006
  ChipHeadless,
6817
7007
  {
@@ -6820,20 +7010,40 @@ var Chip = React.forwardRef(
6820
7010
  isDisabled,
6821
7011
  onRemove: handleRemove,
6822
7012
  onMouseDown: handleRipple,
6823
- removeIcon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {}),
6824
- removeButtonClassName: "relative z-10 inline-flex size-4.5 shrink-0 items-center text-on-surface-variant",
7013
+ removeButtonClassName: cn(chipRemoveButtonVariants()),
7014
+ removeIcon: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
7015
+ /* @__PURE__ */ jsxRuntime.jsx(
7016
+ "span",
7017
+ {
7018
+ className: cn(chipRemoveStateLayerVariants()),
7019
+ "aria-hidden": "true",
7020
+ ...{ "data-remove-state-layer": "" }
7021
+ }
7022
+ ),
7023
+ /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {})
7024
+ ] }),
6825
7025
  ref,
6826
7026
  className: "contents",
7027
+ bodyPassthrough: {
7028
+ onPressStart: handlePressStart,
7029
+ onPressEnd: handlePressEnd
7030
+ },
7031
+ removePassthrough: {
7032
+ dataAttributes: removeDataAttrs,
7033
+ eventHandlers: reactAria.mergeProps(removeHoverProps, removeFocusProps),
7034
+ onPressStart: () => setIsRemovePressed(true),
7035
+ onPressEnd: () => setIsRemovePressed(false)
7036
+ },
6827
7037
  children: [
6828
7038
  leadingIcon && /* @__PURE__ */ jsxRuntime.jsx(
6829
7039
  "span",
6830
7040
  {
6831
7041
  "aria-hidden": "true",
6832
- className: "relative z-10 inline-flex size-4.5 shrink-0 items-center",
7042
+ className: cn(chipLeadingIconVariants({ chipType: "input" })),
6833
7043
  children: leadingIcon
6834
7044
  }
6835
7045
  ),
6836
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative z-10", children: label })
7046
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipLabelVariants()), children: label })
6837
7047
  ]
6838
7048
  }
6839
7049
  )
@@ -6854,37 +7064,21 @@ var Chip = React.forwardRef(
6854
7064
  ...type !== "filter" && onPress !== void 0 && { onPress },
6855
7065
  isDisabled,
6856
7066
  onMouseDown: handleRipple,
6857
- className: chipClass(),
7067
+ className: cn(rootClass),
7068
+ bodyPassthrough: {
7069
+ dataAttributes: bodyDataAttrs,
7070
+ onPressStart: handlePressStart,
7071
+ onPressEnd: handlePressEnd,
7072
+ eventHandlers: reactAria.mergeProps(hoverProps, focusProps)
7073
+ },
6858
7074
  children: [
6859
7075
  ripples,
6860
- /* @__PURE__ */ jsxRuntime.jsx(StateLayer, {}),
6861
- type === "filter" && /* @__PURE__ */ jsxRuntime.jsx(
6862
- "span",
6863
- {
6864
- className: cn(
6865
- "duration-short4 ease-emphasized-decelerate inline-flex overflow-hidden transition-[width,opacity]",
6866
- effectiveSelected ? "w-4.5 opacity-100" : "w-0 opacity-0"
6867
- ),
6868
- children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon2, {})
6869
- }
6870
- ),
6871
- leadingIcon && /* @__PURE__ */ jsxRuntime.jsx(
6872
- "span",
6873
- {
6874
- "aria-hidden": "true",
6875
- className: "relative z-10 inline-flex size-4.5 shrink-0 items-center",
6876
- children: leadingIcon
6877
- }
6878
- ),
6879
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative z-10", children: label }),
6880
- trailingIcon && /* @__PURE__ */ jsxRuntime.jsx(
6881
- "span",
6882
- {
6883
- "aria-hidden": "true",
6884
- className: "relative z-10 inline-flex size-4.5 shrink-0 items-center",
6885
- children: trailingIcon
6886
- }
6887
- )
7076
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipStateLayerVariants({ chipType: type })), "aria-hidden": "true" }),
7077
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipFocusRingVariants()), "aria-hidden": "true" }),
7078
+ type === "filter" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipCheckmarkVariants()), "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipCheckmarkIconVariants()), children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon2, {}) }) }),
7079
+ leadingIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: cn(chipLeadingIconVariants({ chipType: type })), children: leadingIcon }),
7080
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(chipLabelVariants()), children: label }),
7081
+ trailingIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: cn(chipTrailingIconVariants()), children: trailingIcon })
6888
7082
  ]
6889
7083
  }
6890
7084
  );