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