@uniweb/kit 0.7.1 → 0.7.2
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": "@uniweb/kit",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"fuse.js": "^7.0.0",
|
|
47
47
|
"shiki": "^3.0.0",
|
|
48
48
|
"tailwind-merge": "^2.6.0",
|
|
49
|
-
"@uniweb/core": "0.5.
|
|
49
|
+
"@uniweb/core": "0.5.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -239,17 +239,17 @@ function RenderNode({ node, block, ...props }) {
|
|
|
239
239
|
return <Divider type={attrs?.type} className="my-6" />
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
case '
|
|
242
|
+
case 'inset_placeholder': {
|
|
243
243
|
const refId = attrs?.refId
|
|
244
244
|
if (!block || !refId) return null
|
|
245
245
|
|
|
246
|
-
const
|
|
247
|
-
if (!
|
|
246
|
+
const insetBlock = block.getInset(refId)
|
|
247
|
+
if (!insetBlock) return null
|
|
248
248
|
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
249
|
+
const InsetRenderer = insetBlock.getChildBlockRenderer()
|
|
250
|
+
if (!InsetRenderer) return null
|
|
251
251
|
|
|
252
|
-
return <
|
|
252
|
+
return <InsetRenderer blocks={[insetBlock]} as="div" />
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
case 'button': {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual Component
|
|
3
|
+
*
|
|
4
|
+
* Renders the first visual element from content: inset > video > image.
|
|
5
|
+
* Used by section types with a visual slot (SplitContent, Showcase, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Section types that declare `visuals: 1` (any type) should use this component.
|
|
8
|
+
* Section types that declare `visuals: 'image'` (media only) should use Media/Image directly.
|
|
9
|
+
*
|
|
10
|
+
* @module @uniweb/kit/styled/Visual
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import React from 'react'
|
|
14
|
+
import { Media } from '../../components/Media/Media.jsx'
|
|
15
|
+
import { Image } from '../../components/Image/index.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders the first visual from content, checking insets first, then video, then image.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props
|
|
21
|
+
* @param {Object} props.content - Parsed content from prepare-props
|
|
22
|
+
* @param {Object} props.block - Block instance (provides block.insets)
|
|
23
|
+
* @param {string} [props.className] - CSS classes for the visual container
|
|
24
|
+
* @param {React.ReactNode} [props.fallback] - Fallback when no visual is found
|
|
25
|
+
*/
|
|
26
|
+
export function Visual({ content, block, className, fallback = null }) {
|
|
27
|
+
// Priority 1: Inset component (from @ComponentName in markdown)
|
|
28
|
+
const inset = block?.insets?.[0]
|
|
29
|
+
if (inset) {
|
|
30
|
+
const Renderer = inset.getChildBlockRenderer?.()
|
|
31
|
+
if (Renderer) {
|
|
32
|
+
return <Renderer blocks={[inset]} as="div" extra={{ className }} />
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Priority 2: Video
|
|
37
|
+
const video = content?.videos?.[0]
|
|
38
|
+
if (video) {
|
|
39
|
+
return <Media src={video.src || video} className={className} />
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Priority 3: Image
|
|
43
|
+
const img = content?.images?.[0] || content?.imgs?.[0]
|
|
44
|
+
if (img) {
|
|
45
|
+
return <Image src={img.src} alt={img.alt} className={className} />
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return fallback
|
|
49
|
+
}
|
package/src/styled/index.js
CHANGED
|
@@ -39,6 +39,9 @@ export { Code, Alert, Warning, Table, Details, Divider } from './Section/rendere
|
|
|
39
39
|
// Disclaimer - Modal dialog for legal disclaimers
|
|
40
40
|
export { Disclaimer } from './Disclaimer/index.js'
|
|
41
41
|
|
|
42
|
+
// Visual - Unified visual renderer (inset > video > image)
|
|
43
|
+
export { Visual } from './Visual/index.jsx'
|
|
44
|
+
|
|
42
45
|
// Media - Video player with styled play button facade
|
|
43
46
|
export { Media } from './Media/index.js'
|
|
44
47
|
|