@noxickon/onyx 4.1.2 → 4.1.3

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/AI-README.md CHANGED
@@ -4123,16 +4123,18 @@ function SearchBox() {
4123
4123
 
4124
4124
  ## useOverflowDetection
4125
4125
 
4126
- Detects overflow and hides overflowing elements.
4126
+ Calculates how many items fit in a container and returns visible/overflow counts (MUI-style approach).
4127
4127
 
4128
4128
  ### Signature
4129
4129
 
4130
4130
  ```tsx
4131
- function useOverflowDetection(options?: {
4131
+ function useOverflowDetection(options: {
4132
+ totalItems: number; // Total number of items (required)
4132
4133
  selector?: string; // Default: '[data-ox-state="selected"]'
4134
+ minVisible?: number; // Minimum items to always show (default: 1)
4133
4135
  }): {
4134
- overflowAmount: number; // Number of hidden items
4135
- checkOverflow: () => void;
4136
+ visibleCount: number; // Number of items that fit
4137
+ overflowAmount: number; // Number of hidden items (totalItems - visibleCount)
4136
4138
  handleResize: (node: HTMLDivElement | null) => () => void; // Ref callback with cleanup
4137
4139
  };
4138
4140
  ```
@@ -4141,16 +4143,23 @@ function useOverflowDetection(options?: {
4141
4143
 
4142
4144
  ```tsx
4143
4145
  function TagList({ tags }) {
4144
- const { overflowAmount, handleResize } = useOverflowDetection();
4146
+ const { visibleCount, overflowAmount, handleResize } = useOverflowDetection({
4147
+ totalItems: tags.length,
4148
+ selector: '[data-tag]',
4149
+ });
4150
+
4151
+ const visibleTags = tags.slice(0, visibleCount);
4145
4152
 
4146
4153
  return (
4147
- <div ref={handleResize}>
4148
- {tags.map((tag) => (
4149
- <span key={tag} data-ox-state="selected">
4154
+ <div className="flex gap-2" ref={handleResize}>
4155
+ {visibleTags.map((tag) => (
4156
+ <span key={tag} data-tag>
4150
4157
  {tag}
4151
4158
  </span>
4152
4159
  ))}
4153
- {overflowAmount > 0 && <span>+{overflowAmount} more</span>}
4160
+ {overflowAmount > 0 && (
4161
+ <span data-ox-overflow-indicator>+{overflowAmount} more</span>
4162
+ )}
4154
4163
  </div>
4155
4164
  );
4156
4165
  }
@@ -4158,9 +4167,10 @@ function TagList({ tags }) {
4158
4167
 
4159
4168
  **Notes**:
4160
4169
 
4161
- - ResizeObserver integration
4162
- - Automatically hides overflow from end
4163
- - Returns hidden element count
4170
+ - ResizeObserver integration for automatic recalculation on resize
4171
+ - Consumer controls rendering - only render `visibleCount` items (no display:none)
4172
+ - Measures items via selector and calculates how many fit in container width
4173
+ - Accounts for gap and overflow indicator width in calculation
4164
4174
 
4165
4175
  ---
4166
4176