@tinybigui/react 0.8.1 → 0.10.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.d.cts CHANGED
@@ -598,6 +598,9 @@ interface AppBarProps {
598
598
  * Renders a `<header role="banner">` and manages scroll elevation state.
599
599
  * Use this for full visual control when the styled `AppBar` is not sufficient.
600
600
  *
601
+ * Extends `React.HTMLAttributes<HTMLElement>` so all standard HTML attributes
602
+ * (including `data-*` attributes) are forwarded to the underlying `<header>`.
603
+ *
601
604
  * @example
602
605
  * ```tsx
603
606
  * <AppBarHeadless
@@ -609,11 +612,7 @@ interface AppBarProps {
609
612
  * </AppBarHeadless>
610
613
  * ```
611
614
  */
612
- interface AppBarHeadlessProps {
613
- /**
614
- * Additional CSS classes
615
- */
616
- className?: string;
615
+ interface AppBarHeadlessProps extends React__default.HTMLAttributes<HTMLElement> {
617
616
  /**
618
617
  * The content to render inside the header
619
618
  */
@@ -630,26 +629,41 @@ interface AppBarHeadlessProps {
630
629
  }
631
630
 
632
631
  /**
633
- * Material Design 3 Top App Bar Component
632
+ * Material Design 3 Top App Bar Component (M3 Expressive Flexible)
634
633
  *
635
634
  * Provides context and actions for the current screen. Supports four size variants,
636
- * a navigation icon slot, title, and trailing action icon slots. Implements
637
- * scroll-triggered elevation changes per MD3 specification.
635
+ * a navigation icon slot, title, optional subtitle, and trailing action icon slots.
636
+ * Implements scroll-triggered elevation changes per MD3 specification.
638
637
  *
639
638
  * **Architecture:**
640
- * - Layer 3 (this file): MD3 styled, CVA variants, layout composition
639
+ * - Layer 3 (this file): MD3 styled, CVA slot variants, layout composition
641
640
  * - Layer 2: `AppBarHeadless` — `<header role="banner">`, scroll state
642
641
  * - Layer 1: React Aria via `<IconButton>` in consumer slots
643
642
  *
643
+ * **Slot-based styling:**
644
+ * All layout and state styling follows the Variants vs States pattern:
645
+ * - `variant` prop drives design-time choices (height, type scale, alignment)
646
+ * - Scroll elevation state is emitted as `data-scrolled=""` on the root and
647
+ * consumed by `group-data-[scrolled]/appbar:*` selectors (presence-based)
648
+ * - Subtitle presence is emitted as `data-with-subtitle=""` on the root and
649
+ * used to grow medium/large bar heights (group-data-[with-subtitle]/appbar:*)
650
+ *
644
651
  * **Key Features:**
645
652
  * - 4 MD3 variants: small, center-aligned, medium, large
646
- * - Optional subtitle (per M3 Expressive spec) with per-variant typography
653
+ * - M3 Expressive flexible: medium and large grow vertically with a subtitle
654
+ * (136dp / 152dp respectively), per the M3 Expressive flexible spec
647
655
  * - Composable API: pass `<IconButton>` nodes into navigation and action slots
648
- * - Scroll elevation: flat (bg-surface) at rest → bg-surface-container + shadow-elevation-2 on scroll
656
+ * - Scroll elevation: bg-surface at rest → bg-surface-container + shadow-elevation-2
649
657
  * - Controlled and uncontrolled scroll state
658
+ * - MD3 motion: background-color + box-shadow use standard effects spring pair
650
659
  * - WCAG 2.1 AA: `role="banner"` landmark, keyboard accessible slots
651
660
  * - Dark mode via existing token system
652
661
  *
662
+ * **M3 Expressive Flexible subtitle type scales:**
663
+ * - small / center-aligned: label-medium, on-surface-variant
664
+ * - medium expanded: label-large, on-surface-variant
665
+ * - large expanded: title-medium, on-surface-variant
666
+ *
653
667
  * **MD3 Accessibility (m3.material.io/components/app-bars/accessibility):**
654
668
  * - Focus lands on the leading navigation button first (first interactive element in DOM)
655
669
  * - Tab navigates: leading icon → trailing action icons (left to right)
@@ -682,7 +696,7 @@ interface AppBarHeadlessProps {
682
696
  * onScrollStateChange={setIsScrolled}
683
697
  * />
684
698
  *
685
- * // Medium with expanded title and subtitle
699
+ * // Medium with expanded title and subtitle (grows to 136dp with subtitle)
686
700
  * <AppBar
687
701
  * variant="medium"
688
702
  * title="Article Title"
@@ -5690,21 +5704,22 @@ declare function SnackbarProvider({ children, maxVisible }: SnackbarProviderProp
5690
5704
  /**
5691
5705
  * The four MD3 chip types, each with distinct interaction semantics.
5692
5706
  *
5693
- * - `assist` – triggers an action (e.g. "Set alarm")
5694
- * - `filter` – toggles a filter on/off (`aria-pressed`)
5695
- * - `input` – represents a value the user entered; can be removed
5707
+ * - `assist` – triggers an action (e.g. "Set alarm")
5708
+ * - `filter` – toggles a filter on/off (`aria-pressed`)
5709
+ * - `input` – represents a value the user entered; can be removed
5696
5710
  * - `suggestion` – offers a contextual suggestion (acts like assist)
5697
5711
  */
5698
5712
  type ChipType = "assist" | "filter" | "input" | "suggestion";
5699
5713
  /**
5700
- * Surface style for Assist and Suggestion chips.
5714
+ * Surface style for chips.
5701
5715
  *
5702
- * - `tonal` uses secondary-container fill (default)
5703
- * - `elevated` – uses surface-container-low fill with elevation shadow
5716
+ * - `flat` transparent container with outline border (MD3 default)
5717
+ * - `elevated` – `surface-container-low` fill with elevation shadow; all four chip types support this
5718
+ * - `tonal` – @deprecated Use `flat` instead. Will be removed in a future minor version.
5704
5719
  *
5705
- * @default 'tonal'
5720
+ * @default 'flat'
5706
5721
  */
5707
- type ChipSurface = "tonal" | "elevated";
5722
+ type ChipSurface = "flat" | "elevated" | "tonal";
5708
5723
  /**
5709
5724
  * Material Design 3 Chip Component Props
5710
5725
  *
@@ -5736,8 +5751,13 @@ interface ChipProps {
5736
5751
  */
5737
5752
  label: string;
5738
5753
  /**
5739
- * Surface style (Assist and Suggestion chips only).
5740
- * @default 'tonal'
5754
+ * Surface style applied to the chip.
5755
+ *
5756
+ * - `flat` (default) — transparent container with outline border per MD3 spec.
5757
+ * - `elevated` — `surface-container-low` fill + elevation shadow; works with all chip types.
5758
+ * - `tonal` — @deprecated alias for `flat`; logs a console.warn in development.
5759
+ *
5760
+ * @default 'flat'
5741
5761
  */
5742
5762
  surface?: ChipSurface;
5743
5763
  /**
@@ -5762,6 +5782,11 @@ interface ChipProps {
5762
5782
  onRemove?: () => void;
5763
5783
  /**
5764
5784
  * Icon rendered before the label.
5785
+ * Color follows the MD3 spec per chip type:
5786
+ * - assist → `text-primary`
5787
+ * - filter (unselected) → `text-on-surface-variant`; (selected) → `text-on-secondary-container`
5788
+ * - input → `text-on-surface-variant`
5789
+ * - suggestion → `text-on-surface-variant`
5765
5790
  */
5766
5791
  leadingIcon?: React__default.ReactNode;
5767
5792
  /**
@@ -5778,6 +5803,53 @@ interface ChipProps {
5778
5803
  */
5779
5804
  className?: string;
5780
5805
  }
5806
+ /**
5807
+ * Props passed through to the chip body element (button) in ChipHeadless.
5808
+ * Allows the styled layer to inject data-* interaction attributes and
5809
+ * merged hover/focus event handlers.
5810
+ */
5811
+ interface ChipBodyPassthroughProps {
5812
+ /**
5813
+ * Merged hover/focus/press event handlers from the styled layer.
5814
+ * Spread onto the body <button>.
5815
+ */
5816
+ eventHandlers?: Record<string, unknown>;
5817
+ /**
5818
+ * data-* interaction attributes emitted by getInteractionDataAttributes.
5819
+ * Spread onto the body <button>.
5820
+ */
5821
+ dataAttributes?: Record<string, string | undefined>;
5822
+ /**
5823
+ * onPressStart forwarded into useButton/useToggleButton for isPressed tracking.
5824
+ */
5825
+ onPressStart?: () => void;
5826
+ /**
5827
+ * onPressEnd forwarded into useButton/useToggleButton for isPressed tracking.
5828
+ */
5829
+ onPressEnd?: () => void;
5830
+ }
5831
+ /**
5832
+ * Props passed through to the remove button element in InputChipImpl.
5833
+ */
5834
+ interface ChipRemovePassthroughProps {
5835
+ /**
5836
+ * data-* interaction attributes for the remove button.
5837
+ */
5838
+ dataAttributes?: Record<string, string | undefined>;
5839
+ /**
5840
+ * Merged hover/focus event handlers from useHover + useFocusRing.
5841
+ * Spread onto the remove <button> alongside React Aria's buttonProps.
5842
+ */
5843
+ eventHandlers?: Record<string, unknown>;
5844
+ /**
5845
+ * onPressStart for remove button isPressed tracking.
5846
+ */
5847
+ onPressStart?: () => void;
5848
+ /**
5849
+ * onPressEnd for remove button isPressed tracking.
5850
+ */
5851
+ onPressEnd?: () => void;
5852
+ }
5781
5853
  /**
5782
5854
  * Props for the headless ChipHeadless component (Layer 2).
5783
5855
  *
@@ -5827,7 +5899,7 @@ interface ChipHeadlessProps {
5827
5899
  */
5828
5900
  isDisabled?: boolean;
5829
5901
  /**
5830
- * Additional CSS classes (Tailwind).
5902
+ * Additional CSS classes applied to the chip body button.
5831
5903
  */
5832
5904
  className?: string;
5833
5905
  /**
@@ -5836,7 +5908,7 @@ interface ChipHeadlessProps {
5836
5908
  children?: React__default.ReactNode;
5837
5909
  /**
5838
5910
  * Icon rendered inside the remove button (Input chips only).
5839
- * Typically an ×/close SVG.
5911
+ * Typically an ×/close SVG wrapped in a fragment with a state layer span.
5840
5912
  */
5841
5913
  removeIcon?: React__default.ReactNode;
5842
5914
  /**
@@ -5848,6 +5920,16 @@ interface ChipHeadlessProps {
5848
5920
  * Used by the styled layer to trigger the ripple effect.
5849
5921
  */
5850
5922
  onMouseDown?: React__default.MouseEventHandler<HTMLButtonElement>;
5923
+ /**
5924
+ * Interaction data attributes + merged handlers from the styled layer.
5925
+ * Spread onto the body <button> to enable group-data-[x]/chip slot selectors.
5926
+ */
5927
+ bodyPassthrough?: ChipBodyPassthroughProps;
5928
+ /**
5929
+ * Interaction data attributes + handlers for the remove button (Input chips only).
5930
+ * Spread onto the remove <button>.
5931
+ */
5932
+ removePassthrough?: ChipRemovePassthroughProps;
5851
5933
  }
5852
5934
  /**
5853
5935
  * Props for the ChipSet container component.
@@ -5879,6 +5961,10 @@ interface ChipSetProps {
5879
5961
  * Unstyled chip primitive covering all four MD3 chip types. Delegates to the
5880
5962
  * correct React Aria hook per `type` — bring your own styles.
5881
5963
  *
5964
+ * The styled layer (Chip.tsx) passes `bodyPassthrough` to inject data-* interaction
5965
+ * attributes and merged hover/focus handlers onto the body button, enabling the
5966
+ * group-data-[x]/chip slot selectors defined in Chip.variants.ts.
5967
+ *
5882
5968
  * | type | Hook | Key behaviour |
5883
5969
  * |------------- |-----------------------------------------|----------------------------------|
5884
5970
  * | `assist` | `useButton` | Enter/Space → `onPress` |
@@ -5908,18 +5994,33 @@ declare const ChipHeadless: React$1.ForwardRefExoticComponent<ChipHeadlessProps
5908
5994
  *
5909
5995
  * Unified styled chip covering all four MD3 chip types.
5910
5996
  * Built on `ChipHeadless` for world-class accessibility via React Aria.
5911
- * Uses CVA for type-safe variant management.
5912
5997
  *
5913
- * | Type | Surface | Selection | Remove |
5914
- * |--------------|---------------|-----------|--------|
5915
- * | `assist` | tonal/elevated | | — |
5916
- * | `filter` | fixed tonal | ✅ | — |
5917
- * | `input` | fixed tonal | — | ✅ |
5918
- * | `suggestion` | tonal/elevated | — | — |
5998
+ * Implements the Variants-vs-States architecture: all interaction/selection
5999
+ * states are expressed as `data-*` attributes on the root and consumed by each
6000
+ * slot via `group-data-[x]/chip` Tailwind selectorsno state variants in CVA.
6001
+ *
6002
+ * Features:
6003
+ * - 4 MD3 chip types: assist, filter, input, suggestion
6004
+ * - ✅ 2 surfaces: flat (transparent + outline), elevated (shadow + fill)
6005
+ * - ✅ MD3-correct per-type icon colors (assist leading = primary, etc.)
6006
+ * - ✅ Filter chip checkmark with spring animation
6007
+ * - ✅ Input chip removal with animate-md-fade-out
6008
+ * - ✅ Proper MD3 state layer (hover 8%, focus 10%, pressed 10%)
6009
+ * - ✅ Spring motion tokens (no hardcoded durations)
6010
+ * - ✅ Dedicated focus ring slot (outside overflow-hidden)
6011
+ * - ✅ Full keyboard accessibility (via React Aria)
6012
+ * - ✅ Deprecated `surface="tonal"` — warns and maps to `flat`
6013
+ *
6014
+ * MD3 Specifications:
6015
+ * - Height: 32dp (h-8), corner-small 8dp (rounded-sm)
6016
+ * - Padding: 16dp base; 8dp leading side when icon present
6017
+ * - Icon size: 18px × 18px
6018
+ * - State layers: 8% hover, 10% focus/pressed
6019
+ * - Elevation: level-1 base → level-2 hover (elevated surface)
5919
6020
  *
5920
6021
  * @example
5921
6022
  * ```tsx
5922
- * // Assist chip
6023
+ * // Assist chip (default flat surface)
5923
6024
  * <Chip type="assist" label="Set alarm" onPress={handlePress} />
5924
6025
  *
5925
6026
  * // Elevated assist chip
@@ -5956,27 +6057,64 @@ declare const Chip: React__default.ForwardRefExoticComponent<ChipProps & React__
5956
6057
  declare const ChipSet: React$1.ForwardRefExoticComponent<ChipSetProps & React$1.RefAttributes<HTMLDivElement>>;
5957
6058
 
5958
6059
  /**
5959
- * Material Design 3 Chip Variants (CVA)
6060
+ * Material Design 3 Chip Variants (Slot-based "Variants vs States" architecture)
5960
6061
  *
5961
- * Covers all four chip types (assist, filter, input, suggestion) with
5962
- * surface, selection, disabled, and padding variants.
6062
+ * Architecture: Variants vs States
6063
+ * - CVA holds design-time structure only (chipType × surface).
6064
+ * - All interaction/selection states are driven by data-* attributes on the root
6065
+ * via group-data-[x]/chip Tailwind selectors in each slot's base classes.
6066
+ * - Content flags (data-with-leading, data-with-trailing) are set explicitly by
6067
+ * the component and consumed by the root slot for padding adjustments.
6068
+ *
6069
+ * Slot responsibilities:
6070
+ * chipVariants — root button/span; shape, color, elevation, padding
6071
+ * chipStateLayerVariants — hover/focus/press opacity overlay (absolute inset)
6072
+ * chipFocusRingVariants — keyboard focus outline, outside overflow-hidden
6073
+ * chipLeadingIconVariants — leading icon wrapper; color per type + selected/disabled
6074
+ * chipTrailingIconVariants — trailing icon wrapper; assist/suggestion only
6075
+ * chipCheckmarkVariants — filter chip checkmark container (width spring)
6076
+ * chipLabelVariants — label text slot
6077
+ * chipRemoveButtonVariants — input chip remove button wrapper
6078
+ * chipRemoveStateLayerVariants — state layer inside remove button circle
6079
+ *
6080
+ * MD3 Spec (Expressive):
6081
+ * Shape: corner-small (8dp) → rounded-sm
6082
+ * Height: 32dp → h-8
6083
+ * Padding: 16dp base; 8dp leading side with icon
6084
+ * Gap: 8dp → gap-2
6085
+ * Icon: 18px × 18px
6086
+ * State-layer opacities: hover 8% | focus 10% | pressed 10%
6087
+ * Disabled: container transparent, border 12% opacity, content 38% opacity
6088
+ *
6089
+ * Per-type color tokens (MD3 strict):
6090
+ * assist: bg=transparent border=outline label=on-surface leadingIcon=primary stateLayer=on-surface
6091
+ * filter: bg=transparent border=outline label=on-surface-variant stateLayer=on-surface-variant
6092
+ * filter sel: bg=secondary-container border=none label=on-secondary-container stateLayer=on-secondary-container
6093
+ * input: bg=transparent border=outline-variant label=on-surface-variant stateLayer=on-surface-variant
6094
+ * suggestion: bg=transparent border=outline label=on-surface-variant stateLayer=on-surface-variant
5963
6095
  *
5964
- * Padding resolution (via tailwind-merge in `cn()`):
5965
- * base `px-4` hasLeadingIcon overrides with `pl-3 pr-4`
5966
- * → hasRemoveButton overrides with `pl-3 pr-3`
5967
- * Both can be combined and the last-applied wins through tailwind-merge.
6096
+ * Elevation per state (elevated surface):
6097
+ * base=1hover=2 focus/pressed=1 (doubled pressed selector wins over hover)
6098
+ */
6099
+ /**
6100
+ * Root chip element.
6101
+ *
6102
+ * IMPORTANT — overflow is intentionally NOT on the root.
6103
+ * Clipping is delegated to the state-layer and ripple containers via
6104
+ * `overflow-hidden rounded-[inherit]` so the focus ring span (inset-[-3px])
6105
+ * can extend outside the chip boundary and remain fully visible.
6106
+ *
6107
+ * Padding is driven by content flags:
6108
+ * base px-4 (16dp)
6109
+ * data-[with-leading]: pl-2 pr-4 (8dp leading, 16dp trailing)
6110
+ * data-[with-trailing]: pl-4 pr-2
6111
+ * data-[with-leading][with-trailing]: pl-2 pr-2
6112
+ * These are self-targeting data-[x]: selectors (no group scope needed).
5968
6113
  */
5969
6114
  declare const chipVariants: (props?: ({
5970
6115
  chipType?: "filter" | "input" | "assist" | "suggestion" | null | undefined;
5971
- surface?: "tonal" | "elevated" | null | undefined;
5972
- selected?: boolean | null | undefined;
5973
- isDisabled?: boolean | null | undefined;
5974
- hasLeadingIcon?: boolean | null | undefined;
5975
- hasRemoveButton?: boolean | null | undefined;
6116
+ surface?: "tonal" | "elevated" | "flat" | null | undefined;
5976
6117
  } & class_variance_authority_types.ClassProp) | undefined) => string;
5977
- /**
5978
- * Extract variant prop types from CVA
5979
- */
5980
6118
  type ChipVariants = VariantProps<typeof chipVariants>;
5981
6119
 
5982
6120
  /**