@pyreon/kinetic 0.11.5 → 0.11.7

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.
@@ -1,6 +1,6 @@
1
- import type { VNode } from "@pyreon/core"
2
- import GroupRenderer from "../kinetic/GroupRenderer"
3
- import type { KineticConfig } from "../kinetic/types"
1
+ import type { VNode } from '@pyreon/core'
2
+ import GroupRenderer from '../kinetic/GroupRenderer'
3
+ import type { KineticConfig } from '../kinetic/types'
4
4
 
5
5
  // Mock rAF for deterministic testing
6
6
  let rafCallbacks: (() => void)[] = []
@@ -12,52 +12,52 @@ beforeEach(() => {
12
12
  rafCallbacks = []
13
13
 
14
14
  vi.stubGlobal(
15
- "requestAnimationFrame",
15
+ 'requestAnimationFrame',
16
16
  vi.fn((cb: () => void) => {
17
17
  rafCallbacks.push(cb)
18
18
  return rafCallbacks.length
19
19
  }),
20
20
  )
21
21
 
22
- vi.stubGlobal("cancelAnimationFrame", vi.fn())
22
+ vi.stubGlobal('cancelAnimationFrame', vi.fn())
23
23
  })
24
24
 
25
25
  afterEach(() => {
26
26
  vi.useRealTimers()
27
- vi.stubGlobal("requestAnimationFrame", originalRaf)
28
- vi.stubGlobal("cancelAnimationFrame", originalCaf)
27
+ vi.stubGlobal('requestAnimationFrame', originalRaf)
28
+ vi.stubGlobal('cancelAnimationFrame', originalCaf)
29
29
  })
30
30
 
31
31
  const makeConfig = (overrides: Partial<KineticConfig> = {}): KineticConfig => ({
32
- tag: "div",
33
- mode: "group",
34
- enter: "g-enter",
35
- enterFrom: "g-enter-from",
36
- enterTo: "g-enter-to",
37
- leave: "g-leave",
38
- leaveFrom: "g-leave-from",
39
- leaveTo: "g-leave-to",
32
+ tag: 'div',
33
+ mode: 'group',
34
+ enter: 'g-enter',
35
+ enterFrom: 'g-enter-from',
36
+ enterTo: 'g-enter-to',
37
+ leave: 'g-leave',
38
+ leaveFrom: 'g-leave-from',
39
+ leaveTo: 'g-leave-to',
40
40
  ...overrides,
41
41
  })
42
42
 
43
43
  /** Unwrap reactive accessors returned by GroupRenderer. */
44
44
  const unwrap = (val: any): any => {
45
45
  let result = val
46
- while (typeof result === "function") result = result()
46
+ while (typeof result === 'function') result = result()
47
47
  return result
48
48
  }
49
49
 
50
50
  const makeKeyedChild = (key: string | number, text: string): VNode => ({
51
- type: "span",
52
- props: { "data-testid": `child-${key}` },
51
+ type: 'span',
52
+ props: { 'data-testid': `child-${key}` },
53
53
  children: [text],
54
54
  key,
55
55
  })
56
56
 
57
- describe("GroupRenderer", () => {
58
- it("returns a VNode wrapping children in config.tag", () => {
57
+ describe('GroupRenderer', () => {
58
+ it('returns a VNode wrapping children in config.tag', () => {
59
59
  const config = makeConfig()
60
- const children = [makeKeyedChild("a", "Alpha"), makeKeyedChild("b", "Beta")]
60
+ const children = [makeKeyedChild('a', 'Alpha'), makeKeyedChild('b', 'Beta')]
61
61
 
62
62
  const vnode = unwrap(
63
63
  GroupRenderer({
@@ -69,12 +69,12 @@ describe("GroupRenderer", () => {
69
69
  )
70
70
 
71
71
  expect(vnode).not.toBeNull()
72
- expect(vnode?.type).toBe("div")
72
+ expect(vnode?.type).toBe('div')
73
73
  })
74
74
 
75
- it("uses custom tag from config", () => {
76
- const config = makeConfig({ tag: "ul" })
77
- const children = [makeKeyedChild("a", "Alpha")]
75
+ it('uses custom tag from config', () => {
76
+ const config = makeConfig({ tag: 'ul' })
77
+ const children = [makeKeyedChild('a', 'Alpha')]
78
78
 
79
79
  const vnode = unwrap(
80
80
  GroupRenderer({
@@ -85,30 +85,30 @@ describe("GroupRenderer", () => {
85
85
  }),
86
86
  )
87
87
 
88
- expect(vnode?.type).toBe("ul")
88
+ expect(vnode?.type).toBe('ul')
89
89
  })
90
90
 
91
- it("passes htmlProps to the wrapper element", () => {
91
+ it('passes htmlProps to the wrapper element', () => {
92
92
  const config = makeConfig()
93
- const children = [makeKeyedChild("a", "Alpha")]
93
+ const children = [makeKeyedChild('a', 'Alpha')]
94
94
 
95
95
  const vnode = unwrap(
96
96
  GroupRenderer({
97
97
  config,
98
- htmlProps: { "data-testid": "group-wrapper", class: "my-group" },
98
+ htmlProps: { 'data-testid': 'group-wrapper', class: 'my-group' },
99
99
  callbacks: {},
100
100
  children,
101
101
  }),
102
102
  )
103
103
 
104
104
  const props = vnode?.props as Record<string, unknown>
105
- expect(props?.["data-testid"]).toBe("group-wrapper")
106
- expect(props?.class).toBe("my-group")
105
+ expect(props?.['data-testid']).toBe('group-wrapper')
106
+ expect(props?.class).toBe('my-group')
107
107
  })
108
108
 
109
- it("wraps each keyed child in a TransitionItem", () => {
109
+ it('wraps each keyed child in a TransitionItem', () => {
110
110
  const config = makeConfig()
111
- const children = [makeKeyedChild("a", "Alpha"), makeKeyedChild("b", "Beta")]
111
+ const children = [makeKeyedChild('a', 'Alpha'), makeKeyedChild('b', 'Beta')]
112
112
 
113
113
  const vnode = unwrap(
114
114
  GroupRenderer({
@@ -128,15 +128,15 @@ describe("GroupRenderer", () => {
128
128
  // Each child should be a TransitionItem (function component)
129
129
  for (const child of childArray) {
130
130
  const childVNode = child as VNode
131
- expect(typeof childVNode.type).toBe("function")
131
+ expect(typeof childVNode.type).toBe('function')
132
132
  }
133
133
  })
134
134
 
135
- it("sets appear=true for newly added children (non-initial)", () => {
135
+ it('sets appear=true for newly added children (non-initial)', () => {
136
136
  const config = makeConfig()
137
137
 
138
138
  // First render with initial children
139
- const initialChildren = [makeKeyedChild("a", "Alpha")]
139
+ const initialChildren = [makeKeyedChild('a', 'Alpha')]
140
140
  unwrap(
141
141
  GroupRenderer({
142
142
  config,
@@ -147,7 +147,7 @@ describe("GroupRenderer", () => {
147
147
  )
148
148
 
149
149
  // Second render with a new child added
150
- const updatedChildren = [makeKeyedChild("a", "Alpha"), makeKeyedChild("b", "Beta")]
150
+ const updatedChildren = [makeKeyedChild('a', 'Alpha'), makeKeyedChild('b', 'Beta')]
151
151
  const vnode = unwrap(
152
152
  GroupRenderer({
153
153
  config,
@@ -161,16 +161,16 @@ describe("GroupRenderer", () => {
161
161
  expect(wrapperChildren.length).toBe(2)
162
162
  })
163
163
 
164
- it("passes transition class config to TransitionItem children", () => {
164
+ it('passes transition class config to TransitionItem children', () => {
165
165
  const config = makeConfig({
166
- enter: "custom-enter",
167
- enterFrom: "custom-from",
168
- enterTo: "custom-to",
169
- leave: "custom-leave",
170
- leaveFrom: "custom-lfrom",
171
- leaveTo: "custom-lto",
166
+ enter: 'custom-enter',
167
+ enterFrom: 'custom-from',
168
+ enterTo: 'custom-to',
169
+ leave: 'custom-leave',
170
+ leaveFrom: 'custom-lfrom',
171
+ leaveTo: 'custom-lto',
172
172
  })
173
- const children = [makeKeyedChild("a", "Alpha")]
173
+ const children = [makeKeyedChild('a', 'Alpha')]
174
174
 
175
175
  const vnode = unwrap(
176
176
  GroupRenderer({
@@ -185,24 +185,24 @@ describe("GroupRenderer", () => {
185
185
  const transitionItemVNode = wrapperChildren[0] as VNode
186
186
  const tiProps = transitionItemVNode.props as Record<string, unknown>
187
187
 
188
- expect(tiProps.enter).toBe("custom-enter")
189
- expect(tiProps.enterFrom).toBe("custom-from")
190
- expect(tiProps.enterTo).toBe("custom-to")
191
- expect(tiProps.leave).toBe("custom-leave")
192
- expect(tiProps.leaveFrom).toBe("custom-lfrom")
193
- expect(tiProps.leaveTo).toBe("custom-lto")
188
+ expect(tiProps.enter).toBe('custom-enter')
189
+ expect(tiProps.enterFrom).toBe('custom-from')
190
+ expect(tiProps.enterTo).toBe('custom-to')
191
+ expect(tiProps.leave).toBe('custom-leave')
192
+ expect(tiProps.leaveFrom).toBe('custom-lfrom')
193
+ expect(tiProps.leaveTo).toBe('custom-lto')
194
194
  })
195
195
 
196
- it("passes style transition config to TransitionItem children", () => {
196
+ it('passes style transition config to TransitionItem children', () => {
197
197
  const config = makeConfig({
198
198
  enterStyle: { opacity: 0 },
199
199
  enterToStyle: { opacity: 1 },
200
- enterTransition: "opacity 300ms ease",
200
+ enterTransition: 'opacity 300ms ease',
201
201
  leaveStyle: { opacity: 1 },
202
202
  leaveToStyle: { opacity: 0 },
203
- leaveTransition: "opacity 200ms ease-in",
203
+ leaveTransition: 'opacity 200ms ease-in',
204
204
  })
205
- const children = [makeKeyedChild("a", "Alpha")]
205
+ const children = [makeKeyedChild('a', 'Alpha')]
206
206
 
207
207
  const vnode = unwrap(
208
208
  GroupRenderer({
@@ -218,15 +218,15 @@ describe("GroupRenderer", () => {
218
218
 
219
219
  expect(tiProps.enterStyle).toEqual({ opacity: 0 })
220
220
  expect(tiProps.enterToStyle).toEqual({ opacity: 1 })
221
- expect(tiProps.enterTransition).toBe("opacity 300ms ease")
221
+ expect(tiProps.enterTransition).toBe('opacity 300ms ease')
222
222
  expect(tiProps.leaveStyle).toEqual({ opacity: 1 })
223
223
  expect(tiProps.leaveToStyle).toEqual({ opacity: 0 })
224
- expect(tiProps.leaveTransition).toBe("opacity 200ms ease-in")
224
+ expect(tiProps.leaveTransition).toBe('opacity 200ms ease-in')
225
225
  })
226
226
 
227
- it("uses effectiveAppear from config when appear prop is not provided", () => {
227
+ it('uses effectiveAppear from config when appear prop is not provided', () => {
228
228
  const config = makeConfig({ appear: true })
229
- const children = [makeKeyedChild("a", "Alpha")]
229
+ const children = [makeKeyedChild('a', 'Alpha')]
230
230
 
231
231
  const vnode = unwrap(
232
232
  GroupRenderer({
@@ -244,9 +244,9 @@ describe("GroupRenderer", () => {
244
244
  expect(tiProps.appear).toBe(true)
245
245
  })
246
246
 
247
- it("uses effectiveTimeout from config when timeout prop is not provided", () => {
247
+ it('uses effectiveTimeout from config when timeout prop is not provided', () => {
248
248
  const config = makeConfig({ timeout: 2000 })
249
- const children = [makeKeyedChild("a", "Alpha")]
249
+ const children = [makeKeyedChild('a', 'Alpha')]
250
250
 
251
251
  const vnode = unwrap(
252
252
  GroupRenderer({
@@ -263,9 +263,9 @@ describe("GroupRenderer", () => {
263
263
  expect(tiProps.timeout).toBe(2000)
264
264
  })
265
265
 
266
- it("defaults timeout to 5000 when not provided", () => {
266
+ it('defaults timeout to 5000 when not provided', () => {
267
267
  const config = makeConfig()
268
- const children = [makeKeyedChild("a", "Alpha")]
268
+ const children = [makeKeyedChild('a', 'Alpha')]
269
269
 
270
270
  const vnode = unwrap(
271
271
  GroupRenderer({
@@ -282,10 +282,10 @@ describe("GroupRenderer", () => {
282
282
  expect(tiProps.timeout).toBe(5000)
283
283
  })
284
284
 
285
- it("ignores children without keys", () => {
285
+ it('ignores children without keys', () => {
286
286
  const config = makeConfig()
287
- const keyedChild = makeKeyedChild("a", "Alpha")
288
- const unkeyedChild: VNode = { type: "span", props: {}, children: ["No key"], key: null }
287
+ const keyedChild = makeKeyedChild('a', 'Alpha')
288
+ const unkeyedChild: VNode = { type: 'span', props: {}, children: ['No key'], key: null }
289
289
 
290
290
  const vnode = unwrap(
291
291
  GroupRenderer({
@@ -301,9 +301,9 @@ describe("GroupRenderer", () => {
301
301
  expect(wrapperChildren.length).toBe(1)
302
302
  })
303
303
 
304
- it("appear prop overrides config.appear", () => {
304
+ it('appear prop overrides config.appear', () => {
305
305
  const config = makeConfig({ appear: false })
306
- const children = [makeKeyedChild("a", "Alpha")]
306
+ const children = [makeKeyedChild('a', 'Alpha')]
307
307
 
308
308
  const vnode = unwrap(
309
309
  GroupRenderer({
@@ -321,9 +321,9 @@ describe("GroupRenderer", () => {
321
321
  expect(tiProps.appear).toBe(true)
322
322
  })
323
323
 
324
- it("timeout prop overrides config.timeout", () => {
324
+ it('timeout prop overrides config.timeout', () => {
325
325
  const config = makeConfig({ timeout: 2000 })
326
- const children = [makeKeyedChild("a", "Alpha")]
326
+ const children = [makeKeyedChild('a', 'Alpha')]
327
327
 
328
328
  const vnode = unwrap(
329
329
  GroupRenderer({
@@ -341,10 +341,10 @@ describe("GroupRenderer", () => {
341
341
  expect(tiProps.timeout).toBe(3000)
342
342
  })
343
343
 
344
- it("handleAfterLeave fires the callbacks.onAfterLeave and updates forceUpdateSignal", () => {
344
+ it('handleAfterLeave fires the callbacks.onAfterLeave and updates forceUpdateSignal', () => {
345
345
  const onAfterLeave = vi.fn()
346
346
  const config = makeConfig()
347
- const children = [makeKeyedChild("a", "Alpha")]
347
+ const children = [makeKeyedChild('a', 'Alpha')]
348
348
 
349
349
  const vnode = unwrap(
350
350
  GroupRenderer({
@@ -366,9 +366,9 @@ describe("GroupRenderer", () => {
366
366
  expect(onAfterLeave).toHaveBeenCalledTimes(1)
367
367
  })
368
368
 
369
- it("TransitionItem children have show returning true for current children", () => {
369
+ it('TransitionItem children have show returning true for current children', () => {
370
370
  const config = makeConfig()
371
- const children = [makeKeyedChild("a", "Alpha"), makeKeyedChild("b", "Beta")]
371
+ const children = [makeKeyedChild('a', 'Alpha'), makeKeyedChild('b', 'Beta')]
372
372
 
373
373
  const vnode = unwrap(
374
374
  GroupRenderer({
@@ -388,9 +388,9 @@ describe("GroupRenderer", () => {
388
388
  }
389
389
  })
390
390
 
391
- it("initial children use effectiveAppear for appear prop", () => {
391
+ it('initial children use effectiveAppear for appear prop', () => {
392
392
  const config = makeConfig({ appear: false })
393
- const children = [makeKeyedChild("a", "Alpha")]
393
+ const children = [makeKeyedChild('a', 'Alpha')]
394
394
 
395
395
  const vnode = unwrap(
396
396
  GroupRenderer({
@@ -408,9 +408,9 @@ describe("GroupRenderer", () => {
408
408
  expect(tiProps.appear).toBe(false)
409
409
  })
410
410
 
411
- it("each TransitionItem child gets the element as its children", () => {
411
+ it('each TransitionItem child gets the element as its children', () => {
412
412
  const config = makeConfig()
413
- const children = [makeKeyedChild("a", "Alpha")]
413
+ const children = [makeKeyedChild('a', 'Alpha')]
414
414
 
415
415
  const vnode = unwrap(
416
416
  GroupRenderer({