@uniweb/kit 0.19.7 → 0.19.8

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.19.7",
3
+ "version": "0.19.8",
4
4
  "description": "Standard component library for Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -43,8 +43,9 @@
43
43
  "shiki": "^3.0.0",
44
44
  "tailwind-merge": "^3.6.0",
45
45
  "temml": "^0.13.2",
46
- "@uniweb/projections": "^0.7.6",
47
- "@uniweb/core": "^0.32.0",
46
+ "@uniweb/core": "^0.32.1",
47
+ "@uniweb/projections": "^0.7.7",
48
+ "@uniweb/schemas": "^0.8.0",
48
49
  "@uniweb/scene": "^0.1.3",
49
50
  "@uniweb/semantic-parser": "^1.4.1"
50
51
  },
package/src/index.js CHANGED
@@ -158,6 +158,7 @@ export { Article } from './styled/Article/index.jsx'
158
158
  export { Code, Alert, Warning, Table, Details, Divider } from './styled/Section/renderers/index.js'
159
159
  export { Disclaimer } from './styled/Disclaimer/index.js'
160
160
  export { Visual } from './styled/Visual/index.jsx'
161
+ export { ChildGrid } from './styled/ChildGrid/index.jsx'
161
162
  export { Scene } from './styled/Scene/index.jsx'
162
163
 
163
164
  // ============================================================================
@@ -0,0 +1,70 @@
1
+ /**
2
+ * ChildGrid — a section's child sections, laid out in the columns its author chose.
3
+ *
4
+ * The author chooses with the section's reserved `grid:` key — `3` (equal columns) or
5
+ * `'40/60'` (relative widths) — one of the layouts the component offers in `meta.js`
6
+ * (`children: { grid: [2, 3, '40/60'] }`). A component opts in by rendering its
7
+ * children through this, so what a visual editor draws from the same value
8
+ * (`gridTemplate`, `@uniweb/schemas/grid`) is what renders.
9
+ *
10
+ * Narrow screens get one column; from the `md` breakpoint a layout of up to two
11
+ * columns applies as chosen and a wider one shows two equal columns; from `lg` the
12
+ * chosen layout applies whatever its width.
13
+ *
14
+ * @module @uniweb/kit/styled/ChildGrid
15
+ */
16
+
17
+ import React from 'react'
18
+ import { parseGrid, gridTemplate } from '@uniweb/schemas/grid'
19
+ import { ChildBlocks, cn } from '../../utils/index.js'
20
+
21
+ const TWO_EQUAL = 'repeat(2, minmax(0, 1fr))'
22
+
23
+ /**
24
+ * @param {Object} props
25
+ * @param {Object} props.from - the section's Block; its `childBlocks` are laid out
26
+ * @param {number|string} [props.fallback] - the layout when the section chose none
27
+ * (or chose something that is not a layout) — the component's default
28
+ * @param {boolean} [props.headerRow] - the first child spans every column
29
+ * @param {string} [props.className] - classes on the grid, e.g. a gap (`gap-8` by default)
30
+ * @param {string} [props.cellClassName] - classes on each child's cell
31
+ *
32
+ * @example
33
+ * <ChildGrid from={block} fallback={3} headerRow={params.headerRow} className="gap-6" />
34
+ */
35
+ export function ChildGrid({ from: block, fallback = null, headerRow = false, className, cellClassName }) {
36
+ const children = block?.childBlocks || []
37
+ if (children.length === 0) return null
38
+
39
+ const choice = parseGrid(block.grid) ? block.grid : fallback
40
+ const layout = parseGrid(choice)
41
+ const style = layout
42
+ ? {
43
+ '--uniweb-grid-cols': gridTemplate(choice),
44
+ '--uniweb-grid-cols-md': layout.columns <= 2 ? gridTemplate(choice) : TWO_EQUAL,
45
+ }
46
+ : undefined
47
+
48
+ return (
49
+ <div
50
+ className={cn(
51
+ 'grid grid-cols-1 gap-8',
52
+ layout && 'md:grid-cols-[var(--uniweb-grid-cols-md)] lg:grid-cols-[var(--uniweb-grid-cols)]',
53
+ className
54
+ )}
55
+ style={style}
56
+ data-grid={layout ? String(choice) : undefined}
57
+ >
58
+ {children.map((child, index) => (
59
+ <div
60
+ key={child.id || index}
61
+ className={cn(headerRow && index === 0 && 'md:col-span-full', cellClassName)}
62
+ >
63
+ <ChildBlocks blocks={[child]} />
64
+ </div>
65
+ ))}
66
+ </div>
67
+ )
68
+ }
69
+
70
+ export default ChildGrid
@@ -87,14 +87,15 @@ export const NOT_RENDERED = {
87
87
  dataBlock:
88
88
  'structured data, not prose — a component reads it from content.data[tag]',
89
89
  inset_ref:
90
- 'a BUILD-TIME intermediate. The reader emits it for `![](@Component)`; the ' +
91
- 'build\'s content-collector extracts it into the section\'s insets and leaves ' +
90
+ 'the stored form of a leaf inset (`![](@Component)`, `[@key]`, `[#id]`). ' +
91
+ '@uniweb/core lifts it when it builds a Block — a placeholder in place, a ' +
92
+ 'Block in `block.insets` — so a section\'s content reaches this renderer as ' +
92
93
  'an `inset_placeholder`, which is what the `inset` case resolves. Its attrs ' +
93
94
  'carry a component NAME and no refId, so there is nothing here to look up — ' +
94
95
  'and kit answering for the name is the shadowing the inset_block case ' +
95
- 'refuses. Consequence worth knowing: a document rendered straight from ' +
96
- 'markdown without that build step (a record body, say) loses its ' +
97
- 'inline component references.',
96
+ 'refuses. Consequence worth knowing: a document rendered here WITHOUT a Block ' +
97
+ 'built over it (a record\'s body passed straight in, say) keeps its ' +
98
+ 'inset_ref nodes, and they render nothing.',
98
99
  form: 'an editor node; its data reaches components as content.data[schemaId]',
99
100
  'card-group': 'an editor node, deprecated — maps to content.data[cardType]',
100
101
  'document-group': 'an editor node — its documents reach content.links',
@@ -42,6 +42,9 @@ export { Disclaimer } from './Disclaimer/index.js'
42
42
  // Visual - Unified visual renderer (inset > video > image)
43
43
  export { Visual } from './Visual/index.jsx'
44
44
 
45
+ // ChildGrid - A section's child sections in the columns its `grid:` chose
46
+ export { ChildGrid } from './ChildGrid/index.jsx'
47
+
45
48
  // Media - Video player with styled play button facade
46
49
  export { Media } from './Media/index.js'
47
50