@pyreon/elements 0.12.7 → 0.12.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/elements",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.9",
|
|
4
4
|
"description": "Foundational UI components for Pyreon",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@pyreon/typescript": "^0.12.
|
|
43
|
+
"@pyreon/typescript": "^0.12.9",
|
|
44
44
|
"@vitus-labs/tools-rolldown": "^1.15.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@pyreon/core": "^0.12.
|
|
48
|
-
"@pyreon/reactivity": "^0.12.
|
|
49
|
-
"@pyreon/ui-core": "^0.12.
|
|
50
|
-
"@pyreon/unistyle": "^0.12.
|
|
47
|
+
"@pyreon/core": "^0.12.9",
|
|
48
|
+
"@pyreon/reactivity": "^0.12.9",
|
|
49
|
+
"@pyreon/ui-core": "^0.12.9",
|
|
50
|
+
"@pyreon/unistyle": "^0.12.9"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">= 22"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { VNode } from '@pyreon/core'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Mocks — match patterns from existing element tests
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
vi.mock('~/utils', () => ({
|
|
8
|
+
IS_DEVELOPMENT: true,
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
vi.mock('@pyreon/ui-core', async (importOriginal) => {
|
|
12
|
+
const actual = (await importOriginal()) as Record<string, unknown>
|
|
13
|
+
return {
|
|
14
|
+
...actual,
|
|
15
|
+
render: (children: unknown) => children,
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
import { Element } from '../Element'
|
|
20
|
+
import Content from '../helpers/Content/component'
|
|
21
|
+
import Wrapper from '../helpers/Wrapper/component'
|
|
22
|
+
|
|
23
|
+
const asVNode = (v: unknown) => v as VNode
|
|
24
|
+
|
|
25
|
+
const getContentSlots = (result: VNode): VNode[] => {
|
|
26
|
+
const children = result.props.children
|
|
27
|
+
if (!Array.isArray(children)) return []
|
|
28
|
+
return children.filter(
|
|
29
|
+
(c: unknown) =>
|
|
30
|
+
c != null && typeof c === 'object' && 'type' in (c as VNode) && (c as VNode).type === Content,
|
|
31
|
+
) as VNode[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ─── Integration tests ───────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
describe('Element integration', () => {
|
|
37
|
+
it('renders with content prop producing Wrapper VNode', () => {
|
|
38
|
+
const result = asVNode(Element({ content: 'hello world', children: undefined }))
|
|
39
|
+
expect(result.type).toBe(Wrapper)
|
|
40
|
+
const children = result.props.children
|
|
41
|
+
expect(children).toBeDefined()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('three-section layout: beforeContent + content + afterContent', () => {
|
|
45
|
+
const result = asVNode(
|
|
46
|
+
Element({
|
|
47
|
+
beforeContent: 'icon',
|
|
48
|
+
content: 'main text',
|
|
49
|
+
afterContent: 'arrow',
|
|
50
|
+
children: undefined,
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
expect(result.type).toBe(Wrapper)
|
|
54
|
+
const slots = getContentSlots(result)
|
|
55
|
+
// With before/after content, there should be Content wrapper VNodes
|
|
56
|
+
expect(slots.length).toBeGreaterThanOrEqual(2)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('direction and alignX props pass through to Wrapper', () => {
|
|
60
|
+
const result = asVNode(
|
|
61
|
+
Element({
|
|
62
|
+
direction: 'inline',
|
|
63
|
+
alignX: 'center',
|
|
64
|
+
children: 'test',
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
// When beforeContent/afterContent are absent, direction falls through
|
|
69
|
+
// to wrapper level and contentDirection/contentAlignX take effect
|
|
70
|
+
expect(result.type).toBe(Wrapper)
|
|
71
|
+
// The wrapper receives alignment props
|
|
72
|
+
expect(result.props).toBeDefined()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('contentDirection overrides default direction on wrapper for simple element', () => {
|
|
76
|
+
const result = asVNode(
|
|
77
|
+
Element({
|
|
78
|
+
contentDirection: 'inline',
|
|
79
|
+
contentAlignX: 'center',
|
|
80
|
+
children: 'test',
|
|
81
|
+
}),
|
|
82
|
+
)
|
|
83
|
+
// Simple element (no before/after) uses contentDirection as wrapper direction
|
|
84
|
+
expect(result.props.direction).toBe('inline')
|
|
85
|
+
expect(result.props.alignX).toBe('center')
|
|
86
|
+
})
|
|
87
|
+
})
|