@wyxos/vibe 1.6.27 → 1.6.29

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.
@@ -41,10 +41,8 @@ export function createMasonryTransitions(
41
41
  el.style.opacity = '1'
42
42
  el.style.transform = `translate3d(${left}px, ${top}px, 0) scale(1)`
43
43
  el.style.removeProperty('--masonry-opacity-delay')
44
- requestAnimationFrame(() => {
45
- el.style.transition = ''
46
- done()
47
- })
44
+ el.style.transition = ''
45
+ done()
48
46
  return
49
47
  }
50
48
 
@@ -61,20 +59,18 @@ export function createMasonryTransitions(
61
59
  const prevOpacityDelay = el.style.getPropertyValue('--masonry-opacity-delay')
62
60
  el.style.setProperty('--masonry-opacity-delay', `${delay}ms`)
63
61
 
64
- requestAnimationFrame(() => {
65
- el.style.opacity = '1'
66
- el.style.transform = `translate3d(${left}px, ${top}px, 0) scale(1)`
67
- const clear = () => {
68
- if (prevOpacityDelay) {
69
- el.style.setProperty('--masonry-opacity-delay', prevOpacityDelay)
70
- } else {
71
- el.style.removeProperty('--masonry-opacity-delay')
72
- }
73
- el.removeEventListener('transitionend', clear)
74
- done()
62
+ el.style.opacity = '1'
63
+ el.style.transform = `translate3d(${left}px, ${top}px, 0) scale(1)`
64
+ const clear = () => {
65
+ if (prevOpacityDelay) {
66
+ el.style.setProperty('--masonry-opacity-delay', prevOpacityDelay)
67
+ } else {
68
+ el.style.removeProperty('--masonry-opacity-delay')
75
69
  }
76
- el.addEventListener('transitionend', clear)
77
- })
70
+ el.removeEventListener('transitionend', clear)
71
+ done()
72
+ }
73
+ el.addEventListener('transitionend', clear)
78
74
  }
79
75
 
80
76
  function onBeforeEnter(el: HTMLElement) {
@@ -115,10 +111,7 @@ export function createMasonryTransitions(
115
111
  el.style.opacity = '1'
116
112
  el.style.transform = `translate3d(${left}px, ${top}px, 0) scale(1)`
117
113
  el.style.removeProperty('--masonry-opacity-delay')
118
- // Avoid forced reflow: re-enable transition on the next frame
119
- requestAnimationFrame(() => {
120
- el.style.transition = ''
121
- })
114
+ el.style.transition = ''
122
115
  }
123
116
 
124
117
  function onLeave(el: HTMLElement, done: () => void) {
@@ -168,12 +161,10 @@ export function createMasonryTransitions(
168
161
  done()
169
162
  }, leaveMs + 100)
170
163
 
171
- requestAnimationFrame(() => {
172
- el.style.transitionDuration = `${leaveMs}ms`
173
- el.style.opacity = '0'
174
- el.style.transform = `translate3d(${left}px, ${top + 10}px, 0) scale(0.985)`
175
- el.addEventListener('transitionend', onEnd as any)
176
- })
164
+ el.style.transitionDuration = `${leaveMs}ms`
165
+ el.style.opacity = '0'
166
+ el.style.transform = `translate3d(${left}px, ${top + 10}px, 0) scale(0.985)`
167
+ el.addEventListener('transitionend', onEnd as any)
177
168
  }
178
169
 
179
170
  return {
package/src/types.ts CHANGED
@@ -1,38 +1,101 @@
1
- export type MasonryItem = {
2
- id: string
3
- width: number
4
- height: number
5
- page: number
6
- index: number
7
- src: string
8
- // allow extra fields
9
- [key: string]: any
10
- }
11
-
12
- export type ProcessedMasonryItem = MasonryItem & {
13
- columnWidth: number
14
- imageHeight: number
15
- columnHeight: number
16
- left: number
17
- top: number
18
- }
19
-
20
- export type LayoutOptions = {
21
- gutterX?: number
22
- gutterY?: number
23
- header?: number
24
- footer?: number
25
- paddingLeft?: number
26
- paddingRight?: number
27
- sizes?: {
28
- base: number
29
- sm?: number
30
- md?: number
31
- lg?: number
32
- xl?: number
33
- '2xl'?: number
34
- }
35
- placement?: 'masonry' | 'sequential-balanced'
36
- }
37
-
38
- export type GetPageResult = { items: MasonryItem[]; nextPage: number | null }
1
+ export type MasonryItem = {
2
+ id: string
3
+ width: number
4
+ height: number
5
+ page: number
6
+ index: number
7
+ src: string
8
+ // allow extra fields
9
+ [key: string]: any
10
+ }
11
+
12
+ export type ProcessedMasonryItem = MasonryItem & {
13
+ columnWidth: number
14
+ imageHeight: number
15
+ columnHeight: number
16
+ left: number
17
+ top: number
18
+ }
19
+
20
+ export type LayoutOptions = {
21
+ gutterX?: number
22
+ gutterY?: number
23
+ header?: number
24
+ footer?: number
25
+ paddingLeft?: number
26
+ paddingRight?: number
27
+ sizes?: {
28
+ base: number
29
+ sm?: number
30
+ md?: number
31
+ lg?: number
32
+ xl?: number
33
+ '2xl'?: number
34
+ }
35
+ placement?: 'masonry' | 'sequential-balanced'
36
+ }
37
+
38
+ export type GetPageResult = { items: MasonryItem[]; nextPage: number | null }
39
+
40
+ /**
41
+ * Type for the Masonry component instance (what's exposed via defineExpose)
42
+ * Use this type when accessing the component via template refs
43
+ */
44
+ export interface MasonryInstance {
45
+ // Cancels any ongoing load operations (page loads, backfills, etc.)
46
+ cancelLoad: () => void
47
+ // Opaque caller context passed through to getPage(page, context)
48
+ context: any
49
+ // Container height (wrapper element) in pixels
50
+ containerHeight: number
51
+ // Container width (wrapper element) in pixels
52
+ containerWidth: number
53
+ // Current Tailwind breakpoint name (base, sm, md, lg, xl, 2xl) based on containerWidth
54
+ currentBreakpoint: string
55
+ // Current page number or cursor being displayed
56
+ currentPage: number | string | null
57
+ // Completely destroys the component, clearing all state and resetting to initial state
58
+ destroy: () => void
59
+ // Boolean indicating if the end of the list has been reached (no more pages to load)
60
+ hasReachedEnd: boolean
61
+ // Initializes the component with items, page, and next page cursor. Use this for manual init mode.
62
+ initialize: (items: MasonryItem[], page: number | string, next: number | string | null) => Promise<void> | void
63
+ // Boolean indicating if the component has been initialized (first content has loaded)
64
+ isInitialized: boolean
65
+ // Boolean indicating if a page load or backfill operation is currently in progress
66
+ isLoading: boolean
67
+ // Error object if the last load operation failed, null otherwise
68
+ loadError: Error | null
69
+ // Loads the next page of items asynchronously
70
+ loadNext: () => Promise<void>
71
+ // Loads a specific page number or cursor asynchronously
72
+ loadPage: (page: number | string) => Promise<void>
73
+ // Array tracking pagination history (pages/cursors that have been loaded)
74
+ paginationHistory: Array<number | string | null>
75
+ // Refreshes the current page by clearing items and reloading from the current page
76
+ refreshCurrentPage: () => Promise<void>
77
+ // Recalculates the layout positions for all items. Call this after manually modifying items.
78
+ refreshLayout: (items: MasonryItem[]) => void
79
+ // Removes a single item from the masonry
80
+ remove: (item: MasonryItem) => void
81
+ // Removes all items from the masonry
82
+ removeAll: () => void
83
+ // Removes multiple items from the masonry in a single operation
84
+ removeMany: (items: MasonryItem[]) => Promise<void> | void
85
+ // Resets the component to initial state (clears items, resets pagination, scrolls to top)
86
+ reset: () => void
87
+ // Restores a single item at its original index (useful for undo operations)
88
+ restore: (item: MasonryItem, index: number) => Promise<void> | void
89
+ // Restores multiple items at their original indices (useful for undo operations)
90
+ restoreMany: (items: MasonryItem[], indices: number[]) => Promise<void> | void
91
+ // Scrolls the container to a specific position
92
+ scrollTo: (position: number) => void
93
+ // Scrolls the container to the top
94
+ scrollToTop: () => void
95
+ // Sets the opaque caller context (alternative to v-model:context)
96
+ setContext: (val: any) => void
97
+ // Sets fixed dimensions for the container, overriding ResizeObserver. Pass null to restore automatic sizing.
98
+ setFixedDimensions: (dimensions: { width: number; height: number } | null) => void
99
+ // Computed property returning the total number of items currently in the masonry
100
+ totalItems: number
101
+ }