@pyreon/ui-core 0.11.5 → 0.11.6

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,72 +1,72 @@
1
- import type { VNode } from "@pyreon/core"
2
- import { Fragment, h } from "@pyreon/core"
3
- import { describe, expect, it } from "vitest"
4
- import renderFn from "../render"
1
+ import type { VNode } from '@pyreon/core'
2
+ import { Fragment, h } from '@pyreon/core'
3
+ import { describe, expect, it } from 'vitest'
4
+ import renderFn from '../render'
5
5
 
6
6
  const TestComponent = (props: { label?: string }) => {
7
- return h("span", { "data-testid": "test" }, props.label ?? "default")
7
+ return h('span', { 'data-testid': 'test' }, props.label ?? 'default')
8
8
  }
9
9
 
10
- describe("render", () => {
11
- it("should return null for falsy content", () => {
10
+ describe('render', () => {
11
+ it('should return null for falsy content', () => {
12
12
  expect(renderFn(null)).toBeNull()
13
13
  expect(renderFn(undefined)).toBeNull()
14
14
  expect(renderFn(false as any)).toBeNull()
15
- expect(renderFn("" as any)).toBeNull()
15
+ expect(renderFn('' as any)).toBeNull()
16
16
  })
17
17
 
18
- it("should render a component with props", () => {
19
- const result = renderFn(TestComponent, { label: "hello" }) as VNode
18
+ it('should render a component with props', () => {
19
+ const result = renderFn(TestComponent, { label: 'hello' }) as VNode
20
20
  expect(result).toBeDefined()
21
21
  expect(result.type).toBe(TestComponent)
22
- expect(result.props.label).toBe("hello")
22
+ expect(result.props.label).toBe('hello')
23
23
  })
24
24
 
25
- it("should render a component without props", () => {
25
+ it('should render a component without props', () => {
26
26
  const result = renderFn(TestComponent) as VNode
27
27
  expect(result).toBeDefined()
28
28
  expect(result.type).toBe(TestComponent)
29
29
  })
30
30
 
31
- it("should return string content as-is (treated as text)", () => {
32
- expect(renderFn("div" as any)).toBe("div")
33
- expect(renderFn("hello" as any)).toBe("hello")
31
+ it('should return string content as-is (treated as text)', () => {
32
+ expect(renderFn('div' as any)).toBe('div')
33
+ expect(renderFn('hello' as any)).toBe('hello')
34
34
  })
35
35
 
36
- it("should return primitive values as-is", () => {
36
+ it('should return primitive values as-is', () => {
37
37
  expect(renderFn(42 as any)).toBe(42)
38
38
  expect(renderFn(true as any)).toBe(true)
39
- expect(renderFn("text" as any)).toBe("text")
39
+ expect(renderFn('text' as any)).toBe('text')
40
40
  })
41
41
 
42
- it("should return arrays as-is", () => {
43
- const arr = [h("span", { key: "1" }, "a"), h("span", { key: "2" }, "b")]
42
+ it('should return arrays as-is', () => {
43
+ const arr = [h('span', { key: '1' }, 'a'), h('span', { key: '2' }, 'b')]
44
44
  expect(renderFn(arr as any)).toBe(arr)
45
45
  })
46
46
 
47
- it("should return a VNode object without modification when no props", () => {
48
- const vnode = h(TestComponent, { label: "original" })
47
+ it('should return a VNode object without modification when no props', () => {
48
+ const vnode = h(TestComponent, { label: 'original' })
49
49
  const result = renderFn(vnode as any)
50
50
  // VNode objects are returned as-is
51
51
  expect(result).toBe(vnode)
52
52
  })
53
53
 
54
- it("should return a VNode object as-is even with props (VNode path does not merge)", () => {
55
- const vnode = h(TestComponent, { label: "original" })
56
- const result = renderFn(vnode as any, { label: "cloned" })
54
+ it('should return a VNode object as-is even with props (VNode path does not merge)', () => {
55
+ const vnode = h(TestComponent, { label: 'original' })
56
+ const result = renderFn(vnode as any, { label: 'cloned' })
57
57
  // In Pyreon's render, VNode objects hit the object branch and are returned as-is
58
58
  expect(result).toBe(vnode)
59
59
  })
60
60
 
61
- it("should return fragment as-is", () => {
62
- const frag = h(Fragment, null, h("span", null, "a"), h("span", null, "b"))
61
+ it('should return fragment as-is', () => {
62
+ const frag = h(Fragment, null, h('span', null, 'a'), h('span', null, 'b'))
63
63
  const result = renderFn(frag as any)
64
64
  expect(result).toBe(frag)
65
65
  })
66
66
 
67
- it("should return plain object as-is (fallback branch)", () => {
67
+ it('should return plain object as-is (fallback branch)', () => {
68
68
  // Plain objects are not valid elements, not primitives, not arrays
69
- const obj = { foo: "bar" }
69
+ const obj = { foo: 'bar' }
70
70
  expect(renderFn(obj as any)).toBe(obj)
71
71
  })
72
72
  })
@@ -1,9 +1,9 @@
1
- import { describe, expect, it, vi } from "vitest"
1
+ import { describe, expect, it, vi } from 'vitest'
2
2
 
3
3
  // ---------------------------------------------------------------------------
4
4
  // Minimal signal mock that stores state across calls
5
5
  // ---------------------------------------------------------------------------
6
- vi.mock("@pyreon/reactivity", () => ({
6
+ vi.mock('@pyreon/reactivity', () => ({
7
7
  signal: <T>(initial: T) => {
8
8
  let value = initial
9
9
  const sig = (() => value) as (() => T) & {
@@ -34,39 +34,39 @@ vi.mock("@pyreon/reactivity", () => ({
34
34
  },
35
35
  }))
36
36
 
37
- import useStableValue from "../useStableValue"
37
+ import useStableValue from '../useStableValue'
38
38
 
39
- describe("useStableValue", () => {
40
- describe("primitives", () => {
41
- it("returns the value on first call with a string", () => {
42
- const result = useStableValue("hello")
43
- expect(result).toBe("hello")
39
+ describe('useStableValue', () => {
40
+ describe('primitives', () => {
41
+ it('returns the value on first call with a string', () => {
42
+ const result = useStableValue('hello')
43
+ expect(result).toBe('hello')
44
44
  })
45
45
 
46
- it("returns the value on first call with a number", () => {
46
+ it('returns the value on first call with a number', () => {
47
47
  const result = useStableValue(42)
48
48
  expect(result).toBe(42)
49
49
  })
50
50
 
51
- it("returns the value on first call with a boolean", () => {
51
+ it('returns the value on first call with a boolean', () => {
52
52
  const result = useStableValue(true)
53
53
  expect(result).toBe(true)
54
54
  })
55
55
 
56
- it("returns the value on first call with null", () => {
56
+ it('returns the value on first call with null', () => {
57
57
  const result = useStableValue(null)
58
58
  expect(result).toBeNull()
59
59
  })
60
60
  })
61
61
 
62
- describe("objects", () => {
63
- it("returns the object value", () => {
64
- const obj = { a: 1, b: "two" }
62
+ describe('objects', () => {
63
+ it('returns the object value', () => {
64
+ const obj = { a: 1, b: 'two' }
65
65
  const result = useStableValue(obj)
66
- expect(result).toEqual({ a: 1, b: "two" })
66
+ expect(result).toEqual({ a: 1, b: 'two' })
67
67
  })
68
68
 
69
- it("returns same reference when called with deeply equal value", () => {
69
+ it('returns same reference when called with deeply equal value', () => {
70
70
  // Each call creates a new signal, so we verify the value is correct
71
71
  const obj1 = { x: 1, y: 2 }
72
72
  const result = useStableValue(obj1)
@@ -74,14 +74,14 @@ describe("useStableValue", () => {
74
74
  })
75
75
  })
76
76
 
77
- describe("arrays", () => {
78
- it("returns the array value", () => {
77
+ describe('arrays', () => {
78
+ it('returns the array value', () => {
79
79
  const arr = [1, 2, 3]
80
80
  const result = useStableValue(arr)
81
81
  expect(result).toEqual([1, 2, 3])
82
82
  })
83
83
 
84
- it("handles nested arrays", () => {
84
+ it('handles nested arrays', () => {
85
85
  const arr = [
86
86
  [1, 2],
87
87
  [3, 4],
@@ -94,14 +94,14 @@ describe("useStableValue", () => {
94
94
  })
95
95
  })
96
96
 
97
- describe("signal interaction", () => {
98
- it("creates a signal with the initial value and returns peek()", () => {
99
- const value = { key: "value" }
97
+ describe('signal interaction', () => {
98
+ it('creates a signal with the initial value and returns peek()', () => {
99
+ const value = { key: 'value' }
100
100
  const result = useStableValue(value)
101
101
  expect(result).toEqual(value)
102
102
  })
103
103
 
104
- it("returns the initial value even for complex nested objects", () => {
104
+ it('returns the initial value even for complex nested objects', () => {
105
105
  const complex = {
106
106
  nested: { deep: { value: 42 } },
107
107
  arr: [1, [2, 3]],