@viglet/shio-sections 2026.3.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # @viglet/shio-sections
2
+
3
+ [![npm](https://img.shields.io/npm/v/@viglet/shio-sections?logo=npm)](https://www.npmjs.com/package/@viglet/shio-sections)
4
+ [![License](https://img.shields.io/npm/l/@viglet/shio-sections)](https://github.com/openviglet/shio/blob/HEAD/LICENSE)
5
+ [![Website](https://img.shields.io/badge/shio.viglet.org-0ea5e9?logo=googlechrome&logoColor=white)](https://shio.viglet.org/)
6
+
7
+ The **page-section vocabulary** for **[Viglet Shio](https://shio.viglet.org/)**,
8
+ the open source **headless CMS built for coding agents**: composable section
9
+ post-types authored with [`@viglet/shio-model`](https://www.npmjs.com/package/@viglet/shio-model),
10
+ plus the matching **React** components.
11
+
12
+ One shared language for the agent, the console and the front end — **a page is an
13
+ ordered list of known sections** instead of an ad-hoc content model per site. An
14
+ AI agent driving Shio through [Claude Code](https://claude.com/claude-code) and
15
+ MCP writes `Hero`, `FeatureGrid`, `Cta`; the console shows the same names; the
16
+ front end renders them with the components below.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @viglet/shio-sections
22
+ # React is an optional peer — only needed for the render half
23
+ npm install react
24
+ ```
25
+
26
+ ## The vocabulary
27
+
28
+ Seven sections, plus the page and menu types that hold them:
29
+
30
+ | Post-type | Factory | React component | For |
31
+ |---|---|---|---|
32
+ | `SectionHero` | `sectionHero()` | `<Hero>` | Headline, subheadline, image, call to action |
33
+ | `SectionFeatureGrid` | `sectionFeatureGrid()` | `<FeatureGrid>` | A grid of features or services |
34
+ | `SectionCta` | `sectionCta()` | `<Cta>` | A single call-to-action band |
35
+ | `SectionLogoWall` | `sectionLogoWall()` | `<LogoWall>` | Customer / partner logos |
36
+ | `SectionTestimonial` | `sectionTestimonial()` | `<Testimonial>` | Quote, author, portrait |
37
+ | `SectionFaq` | `sectionFaq()` | `<Faq>` | Question / answer rows |
38
+ | `SectionRichText` | `sectionRichText()` | `<RichText>` | Free-form HTML body |
39
+ | `Page` | `page()` | `<Sections>` | The ordered list of sections |
40
+ | `Menu` / `MenuItem` | `menu()` / `menuItem()` | — | Navigation |
41
+
42
+ `SECTION_TYPES`, `PAGE_TYPE`, `MENU_TYPE` and `MENU_ITEM_TYPE` export the names;
43
+ `sectionPostTypes()` returns every definition at once.
44
+
45
+ ## Author the content model
46
+
47
+ ```ts
48
+ // shio/post-types/sections.ts
49
+ import { sectionPostTypes } from "@viglet/shio-sections";
50
+
51
+ export default sectionPostTypes(); // Page, Menu, MenuItem and all seven sections
52
+ ```
53
+
54
+ Then push it to your Shio instance with the
55
+ [CLI](https://www.npmjs.com/package/@viglet/shio):
56
+
57
+ ```bash
58
+ npx @viglet/shio push --dry-run # preview
59
+ npx @viglet/shio push # apply
60
+ ```
61
+
62
+ ## Render the front end
63
+
64
+ ```tsx
65
+ import { Sections } from "@viglet/shio-sections";
66
+ import { ShioClient } from "@viglet/shio-client";
67
+
68
+ const shio = new ShioClient({ baseUrl: process.env.SHIO_URL! });
69
+
70
+ export default async function Page({ params }: { params: { slug?: string[] } }) {
71
+ const post = await shio.getPostByUrl(
72
+ process.env.SHIO_SITE_ID!,
73
+ "/" + (params.slug?.join("/") ?? ""),
74
+ );
75
+ if (!post) return null;
76
+ return <Sections post={post} />;
77
+ }
78
+ ```
79
+
80
+ `<Sections>` dispatches each row of the page to the right component through
81
+ `SECTION_COMPONENTS`. Use a single component directly when you want to:
82
+
83
+ ```tsx
84
+ import { Hero, FeatureGrid } from "@viglet/shio-sections";
85
+
86
+ <Hero data={heroData} className="my-hero" />
87
+ <FeatureGrid data={featureData} />
88
+ ```
89
+
90
+ ### Assets
91
+
92
+ Every component that renders an image takes a `resolveAsset` prop so you decide
93
+ how a stored file reference becomes a URL (CDN, image proxy, Next.js loader).
94
+ `defaultResolveAsset` is the identity-ish default.
95
+
96
+ ## API
97
+
98
+ ```ts
99
+ // Content model (post-type definitions)
100
+ import {
101
+ SECTION_TYPES, PAGE_TYPE, MENU_TYPE, MENU_ITEM_TYPE,
102
+ page, menu, menuItem, sectionPostTypes,
103
+ sectionHero, sectionFeatureGrid, sectionCta, sectionLogoWall,
104
+ sectionTestimonial, sectionFaq, sectionRichText,
105
+ } from "@viglet/shio-sections";
106
+
107
+ // Render
108
+ import {
109
+ Sections, SECTION_COMPONENTS,
110
+ Hero, FeatureGrid, Cta, LogoWall, Testimonial, Faq, RichText,
111
+ } from "@viglet/shio-sections";
112
+
113
+ // Helpers and types
114
+ import { defaultResolveAsset, rows, str } from "@viglet/shio-sections";
115
+ import type {
116
+ SectionsProps, SectionProps, SectionPost,
117
+ HeroData, FeatureGridData, CtaData, LogoWallData,
118
+ TestimonialData, FaqData, RichTextData,
119
+ } from "@viglet/shio-sections";
120
+ ```
121
+
122
+ ## Related packages
123
+
124
+ | Package | For |
125
+ |---|---|
126
+ | [`@viglet/shio`](https://www.npmjs.com/package/@viglet/shio) | The Shio CLI and MCP bridge |
127
+ | [`@viglet/shio-model`](https://www.npmjs.com/package/@viglet/shio-model) | The DSL these post-types are authored with |
128
+ | [`@viglet/shio-client`](https://www.npmjs.com/package/@viglet/shio-client) | Zero-dependency Content Delivery API client |
129
+ | [`@viglet/shio-react-sdk`](https://www.npmjs.com/package/@viglet/shio-react-sdk) | React hooks and render components |
130
+ | [`@viglet/create-shio-app`](https://www.npmjs.com/package/@viglet/create-shio-app) | Next.js starter generator |
131
+
132
+ ## Develop
133
+
134
+ ```bash
135
+ npm run build # vite lib build + .d.ts
136
+ npm run typecheck
137
+ npm test # node:test
138
+ ```
139
+
140
+ ## License
141
+
142
+ Apache-2.0 — [Viglet Shio](https://shio.viglet.org/) ·
143
+ [github.com/openviglet/shio](https://github.com/openviglet/shio) ·
144
+ [docs.viglet.org/shio](https://docs.viglet.org/shio/) ·
145
+ part of the [Viglet](https://www.viglet.org) open source family.
@@ -0,0 +1,17 @@
1
+ import type { JSX } from "react";
2
+ import { type CtaData, type FaqData, type FeatureGridData, type HeroData, type LogoWallData, type RichTextData, type SectionProps, type TestimonialData } from "./types";
3
+ export declare function Hero({ data, resolveAsset, className, postId }: SectionProps<HeroData>): JSX.Element;
4
+ export declare function FeatureGrid({ data, className, postId }: SectionProps<FeatureGridData>): JSX.Element;
5
+ export declare function Cta({ data, className, postId }: SectionProps<CtaData>): JSX.Element;
6
+ export declare function LogoWall({ data, resolveAsset, className, postId }: SectionProps<LogoWallData>): JSX.Element;
7
+ export declare function Testimonial({ data, resolveAsset, className, postId }: SectionProps<TestimonialData>): JSX.Element;
8
+ export declare function Faq({ data, className, postId }: SectionProps<FaqData>): JSX.Element;
9
+ export declare function RichText({ data, className, postId }: SectionProps<RichTextData>): JSX.Element;
10
+ /**
11
+ * Post-type name → component.
12
+ *
13
+ * This map is the whole reason the vocabulary is worth having: the front end never asks
14
+ * "what kind of page is this", it asks each section what it is and renders it. Adding a
15
+ * section type is one entry here and one post-type there — no page template changes.
16
+ */
17
+ export declare const SECTION_COMPONENTS: Record<string, (props: SectionProps<never>) => JSX.Element>;
@@ -0,0 +1,6 @@
1
+ export { MENU_ITEM_TYPE, MENU_TYPE, PAGE_TYPE, SECTION_TYPES, menu, menuItem, page, sectionCta, sectionFaq, sectionFeatureGrid, sectionHero, sectionLogoWall, sectionRichText, sectionTestimonial, sectionPostTypes, } from "./post-types";
2
+ export { Cta, Faq, FeatureGrid, Hero, LogoWall, RichText, Testimonial, SECTION_COMPONENTS, } from "./components";
3
+ export { Sections } from "./sections";
4
+ export type { SectionsProps } from "./sections";
5
+ export { defaultResolveAsset, rows, str } from "./types";
6
+ export type { CtaData, FaqData, FeatureGridData, HeroData, LogoWallData, RichTextData, SectionPost, SectionProps, TestimonialData, } from "./types";
@@ -0,0 +1,78 @@
1
+ import { type ShPostTypeDef } from "@viglet/shio-model";
2
+ /** The post-type name of every section, keyed by its short vocabulary name. */
3
+ export declare const SECTION_TYPES: {
4
+ readonly hero: "SectionHero";
5
+ readonly featureGrid: "SectionFeatureGrid";
6
+ readonly cta: "SectionCta";
7
+ readonly logoWall: "SectionLogoWall";
8
+ readonly testimonial: "SectionTestimonial";
9
+ readonly faq: "SectionFaq";
10
+ readonly richText: "SectionRichText";
11
+ };
12
+ /** The post-type of a page that composes sections. */
13
+ export declare const PAGE_TYPE = "Page";
14
+ /**
15
+ * A curated menu, and the item it is made of (SH382).
16
+ *
17
+ * Why these are here rather than in the render model. A menu *looks* like renderer machinery,
18
+ * and SH249's test for that is whether it needs a new mechanism: this one needs none. It is
19
+ * ordinary content, so `post.upsert`, the file projection, `shio verify` and the section
20
+ * overlay all work on it the day it exists — and the composition rule is the one `Page` already
21
+ * uses, which is why `references: "post"` gives SH154's `dangling-reference` coverage of a menu
22
+ * entry pointing at a deleted page **for free**, with no lint written for it.
23
+ *
24
+ * Why the folder tree could not be the source, even after SH381 gave `{{#navigation}}` a `url`.
25
+ * A real site's navigation is **curated**: a label that differs from the page title, groups that
26
+ * are not folders, an ordering that is editorial, entries that leave the site, a page
27
+ * deliberately left out, and one menu per locale on a translated tree. A folder chain expresses
28
+ * none of those, so every site was hand-writing its nav into every layout.
29
+ */
30
+ export declare const MENU_TYPE = "Menu";
31
+ export declare const MENU_ITEM_TYPE = "MenuItem";
32
+ /**
33
+ * A page: metadata plus an ordered list of section URLs.
34
+ *
35
+ * `sections` is a Multi Select scoped to no single post-type on purpose — the values are
36
+ * addresses, and each address resolves to a post that carries its own type. The front end
37
+ * dispatches on that type (see `SECTION_COMPONENTS`), so adding a section type to the
38
+ * vocabulary never requires editing `Page`.
39
+ */
40
+ export declare const page: () => ShPostTypeDef;
41
+ /**
42
+ * A menu: a title the template asks for, and an ordered list of addresses.
43
+ *
44
+ * The same composition rule as `Page.sections`, deliberately — one shape to learn. Each address
45
+ * resolves to a post that carries its own type, and three are meaningful: a `MenuItem` (a label
46
+ * and/or an external link), another `Menu` (a nested group), or **any page at all**, which is the
47
+ * cheap case and takes its label from the page's own title. `postType` stays open for exactly that
48
+ * reason.
49
+ */
50
+ export declare const menu: () => ShPostTypeDef;
51
+ /**
52
+ * One entry: the label override, the link override, and where it points.
53
+ *
54
+ * `target` is a Multi Select holding **one** address, which looks like the wrong field kind and is
55
+ * the right one: `references: "post"` is declared on Multi Select alone, so it is the only shape the
56
+ * lint and the digest already understand — and a `Content Select` stores a post **id**, which would
57
+ * put a UUID in a content file and break SH79's rule that no address a human writes is a UUID.
58
+ *
59
+ * An item needs `target` or `href`, never both, and that is a `shio verify` rule rather than a
60
+ * schema one: the model has no way to express "exactly one of these", and a required field would
61
+ * make an external link impossible.
62
+ */
63
+ export declare const menuItem: () => ShPostTypeDef;
64
+ export declare const sectionHero: () => ShPostTypeDef;
65
+ export declare const sectionFeatureGrid: () => ShPostTypeDef;
66
+ export declare const sectionCta: () => ShPostTypeDef;
67
+ export declare const sectionLogoWall: () => ShPostTypeDef;
68
+ export declare const sectionTestimonial: () => ShPostTypeDef;
69
+ export declare const sectionFaq: () => ShPostTypeDef;
70
+ export declare const sectionRichText: () => ShPostTypeDef;
71
+ /**
72
+ * The whole vocabulary, in a fixed order.
73
+ *
74
+ * Order is alphabetical by post-type name and it is load-bearing: these definitions are
75
+ * serialized into blueprint packages, and a set that iterated in a different order would
76
+ * produce different bytes from the same source (P5).
77
+ */
78
+ export declare const sectionPostTypes: () => ShPostTypeDef[];
@@ -0,0 +1,27 @@
1
+ import type { JSX } from "react";
2
+ import { type SectionPost } from "./types";
3
+ export interface SectionsProps {
4
+ /** The page's sections, already resolved, in render order. */
5
+ sections: SectionPost[];
6
+ resolveAsset?: (value: string) => string;
7
+ className?: string;
8
+ /**
9
+ * What to render for a section type this vocabulary does not know.
10
+ *
11
+ * Defaults to nothing. An unknown section is a site that has grown its own type, which
12
+ * is legitimate — but rendering a placeholder by default would put the CMS's diagnostics
13
+ * on somebody's home page.
14
+ */
15
+ fallback?: (section: SectionPost) => JSX.Element | null;
16
+ }
17
+ /**
18
+ * Renders each section with the component registered for its post-type.
19
+ *
20
+ * Deliberately takes resolved sections rather than fetching them. A page's `sections`
21
+ * field holds friendly URLs, and resolving a URL is the delivery client's job
22
+ * (`@viglet/shio-client`) — a component that fetched would tie this vocabulary to one
23
+ * data-loading strategy and make it unusable from a server component, a loader, or a
24
+ * static build. The resolution is three lines in the app; the vocabulary is the part
25
+ * worth sharing.
26
+ */
27
+ export declare function Sections({ sections, resolveAsset, className, fallback, }: SectionsProps): JSX.Element;
@@ -0,0 +1,541 @@
1
+ import { aceHtml as e, comboBox as t, file as n, htmlEditor as r, multiSelect as i, postType as a, relator as o, text as s, textArea as c } from "@viglet/shio-model";
2
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
3
+ //#region src/post-types.ts
4
+ var f = {
5
+ hero: "SectionHero",
6
+ featureGrid: "SectionFeatureGrid",
7
+ cta: "SectionCta",
8
+ logoWall: "SectionLogoWall",
9
+ testimonial: "SectionTestimonial",
10
+ faq: "SectionFaq",
11
+ richText: "SectionRichText"
12
+ }, p = "Page", m = "Menu", h = "MenuItem", g = () => a(p, {
13
+ title: "Page",
14
+ namePlural: "Pages",
15
+ description: "A page composed of sections. `sections` lists section friendly URLs in render order.",
16
+ fields: [
17
+ s("title", {
18
+ label: "Title",
19
+ required: !0,
20
+ isTitle: !0
21
+ }),
22
+ c("description", {
23
+ label: "Description",
24
+ description: "Used as the page summary and the meta description.",
25
+ isSummary: !0
26
+ }),
27
+ i("sections", {
28
+ label: "Sections",
29
+ description: "Friendly URLs of the section posts, in render order — e.g. /sections/home/hero.",
30
+ references: "post"
31
+ }),
32
+ e("content", {
33
+ label: "Content",
34
+ description: "Markup this page carries itself, rendered around its sections. A conversion writes the source's own body here for the blocks nobody made authorable."
35
+ })
36
+ ]
37
+ }), _ = () => a(m, {
38
+ title: "Menu",
39
+ namePlural: "Menus",
40
+ description: "A curated menu. `items` lists addresses in render order: a MenuItem, a nested Menu, or a page.",
41
+ fields: [s("title", {
42
+ label: "Title",
43
+ required: !0,
44
+ isTitle: !0
45
+ }), i("items", {
46
+ label: "Items",
47
+ description: "Friendly URLs in render order — a MenuItem, a nested Menu, or a page (which uses its own title).",
48
+ references: "post"
49
+ })]
50
+ }), v = () => a(h, {
51
+ title: "Menu Item",
52
+ namePlural: "Menu Items",
53
+ description: "One menu entry: a label, and either a target page or an external URL. Not both.",
54
+ fields: [
55
+ s("label", {
56
+ label: "Label",
57
+ required: !0,
58
+ isTitle: !0
59
+ }),
60
+ i("target", {
61
+ label: "Target page",
62
+ description: "The friendly URL of the page this points at. Leave empty for an external link.",
63
+ references: "post"
64
+ }),
65
+ s("href", {
66
+ label: "External URL",
67
+ description: "An absolute URL, for an entry that leaves the site. Ignored when a target is set."
68
+ }),
69
+ t("rel", {
70
+ label: "Link relationship",
71
+ description: "Emitted as rel= — what an external entry needs and an internal one does not.",
72
+ choices: {
73
+ "noopener noreferrer": "External (noopener noreferrer)",
74
+ nofollow: "Nofollow"
75
+ },
76
+ allowNull: !0
77
+ })
78
+ ]
79
+ }), y = () => a(f.hero, {
80
+ title: "Hero Section",
81
+ namePlural: "Hero Sections",
82
+ description: "The opening statement of a page: a headline, a line of support, one call to action.",
83
+ fields: [
84
+ s("heading", {
85
+ label: "Heading",
86
+ required: !0,
87
+ isTitle: !0
88
+ }),
89
+ c("subheading", {
90
+ label: "Subheading",
91
+ isSummary: !0
92
+ }),
93
+ r("body", { label: "Body" }),
94
+ s("ctaLabel", { label: "Call-to-action label" }),
95
+ s("ctaHref", { label: "Call-to-action link" }),
96
+ n("image", { label: "Image" }),
97
+ t("align", {
98
+ label: "Alignment",
99
+ choices: {
100
+ left: "Left",
101
+ center: "Centered"
102
+ },
103
+ allowNull: !0
104
+ })
105
+ ]
106
+ }), b = () => a(f.featureGrid, {
107
+ title: "Feature Grid Section",
108
+ namePlural: "Feature Grid Sections",
109
+ description: "A short list of capabilities, each with a title and a sentence.",
110
+ fields: [
111
+ s("heading", {
112
+ label: "Heading",
113
+ required: !0,
114
+ isTitle: !0
115
+ }),
116
+ c("intro", {
117
+ label: "Intro",
118
+ isSummary: !0
119
+ }),
120
+ t("columns", {
121
+ label: "Columns",
122
+ choices: {
123
+ 2: "Two",
124
+ 3: "Three",
125
+ 4: "Four"
126
+ },
127
+ allowNull: !0
128
+ }),
129
+ o("features", {
130
+ label: "Features",
131
+ title: "Feature",
132
+ fields: [
133
+ s("title", {
134
+ label: "Title",
135
+ required: !0
136
+ }),
137
+ c("body", { label: "Body" }),
138
+ s("icon", {
139
+ label: "Icon",
140
+ description: "An icon name your front end knows."
141
+ })
142
+ ]
143
+ })
144
+ ]
145
+ }), x = () => a(f.cta, {
146
+ title: "Call-to-action Section",
147
+ namePlural: "Call-to-action Sections",
148
+ description: "One decision, stated once: a heading, a sentence and a button.",
149
+ fields: [
150
+ s("heading", {
151
+ label: "Heading",
152
+ required: !0,
153
+ isTitle: !0
154
+ }),
155
+ c("body", {
156
+ label: "Body",
157
+ isSummary: !0
158
+ }),
159
+ s("ctaLabel", { label: "Button label" }),
160
+ s("ctaHref", { label: "Button link" }),
161
+ t("variant", {
162
+ label: "Variant",
163
+ choices: {
164
+ primary: "Primary",
165
+ subtle: "Subtle"
166
+ },
167
+ allowNull: !0
168
+ })
169
+ ]
170
+ }), S = () => a(f.logoWall, {
171
+ title: "Logo Wall Section",
172
+ namePlural: "Logo Wall Sections",
173
+ description: "Social proof as a row of logos.",
174
+ fields: [s("heading", {
175
+ label: "Heading",
176
+ isTitle: !0
177
+ }), o("logos", {
178
+ label: "Logos",
179
+ title: "Logo",
180
+ fields: [
181
+ s("name", {
182
+ label: "Name",
183
+ required: !0
184
+ }),
185
+ n("image", { label: "Image" }),
186
+ s("href", { label: "Link" })
187
+ ]
188
+ })]
189
+ }), C = () => a(f.testimonial, {
190
+ title: "Testimonial Section",
191
+ namePlural: "Testimonial Sections",
192
+ description: "What customers said, attributed.",
193
+ fields: [s("heading", {
194
+ label: "Heading",
195
+ isTitle: !0
196
+ }), o("quotes", {
197
+ label: "Quotes",
198
+ title: "Quote",
199
+ fields: [
200
+ c("quote", {
201
+ label: "Quote",
202
+ required: !0
203
+ }),
204
+ s("author", {
205
+ label: "Author",
206
+ required: !0
207
+ }),
208
+ s("role", { label: "Role" }),
209
+ n("avatar", { label: "Avatar" })
210
+ ]
211
+ })]
212
+ }), w = () => a(f.faq, {
213
+ title: "FAQ Section",
214
+ namePlural: "FAQ Sections",
215
+ description: "Questions people actually ask, answered in place.",
216
+ fields: [
217
+ s("heading", {
218
+ label: "Heading",
219
+ isTitle: !0
220
+ }),
221
+ c("intro", {
222
+ label: "Intro",
223
+ isSummary: !0
224
+ }),
225
+ o("questions", {
226
+ label: "Questions",
227
+ title: "Question",
228
+ fields: [s("question", {
229
+ label: "Question",
230
+ required: !0
231
+ }), r("answer", { label: "Answer" })]
232
+ })
233
+ ]
234
+ }), T = () => a(f.richText, {
235
+ title: "Rich Text Section",
236
+ namePlural: "Rich Text Sections",
237
+ description: "Prose. The escape hatch that keeps the other sections from growing fields they do not need.",
238
+ fields: [s("heading", {
239
+ label: "Heading",
240
+ isTitle: !0
241
+ }), r("body", {
242
+ label: "Body",
243
+ required: !0
244
+ })]
245
+ }), E = () => [
246
+ _(),
247
+ v(),
248
+ g(),
249
+ x(),
250
+ w(),
251
+ b(),
252
+ y(),
253
+ S(),
254
+ T(),
255
+ C()
256
+ ];
257
+ //#endregion
258
+ //#region src/types.ts
259
+ function D(e, t) {
260
+ return t ? {
261
+ "data-shio-prop": e,
262
+ "data-shio-prop-attr": t
263
+ } : { "data-shio-prop": e };
264
+ }
265
+ function O(e, t) {
266
+ return e ? {
267
+ "data-shio-post": e,
268
+ "data-shio-post-type": t
269
+ } : {};
270
+ }
271
+ var k = (e) => /^(https?:)?\/\//.test(e) || e.startsWith("/") ? e : `/api/v2/staticfile/${e}`;
272
+ function A(e) {
273
+ return Array.isArray(e) ? e : [];
274
+ }
275
+ function j(e) {
276
+ if (typeof e != "string") return;
277
+ let t = e.trim();
278
+ return t.length > 0 ? t : void 0;
279
+ }
280
+ //#endregion
281
+ //#region src/components.tsx
282
+ var M = (...e) => e.filter(Boolean).join(" "), N = (e) => ({ __html: e });
283
+ function P({ data: e, resolveAsset: t = k, className: n, postId: r }) {
284
+ let i = j(e.image), a = j(e.ctaHref), o = j(e.ctaLabel);
285
+ return /* @__PURE__ */ d("section", {
286
+ className: M("shio-section", "shio-hero", j(e.align) === "center" ? "shio-hero--center" : void 0, n),
287
+ ...O(r, "SectionHero"),
288
+ children: [
289
+ j(e.heading) && /* @__PURE__ */ u("h1", {
290
+ className: "shio-hero__heading",
291
+ ...D("heading"),
292
+ children: e.heading
293
+ }),
294
+ j(e.subheading) && /* @__PURE__ */ u("p", {
295
+ className: "shio-hero__subheading",
296
+ ...D("subheading"),
297
+ children: e.subheading
298
+ }),
299
+ j(e.body) && /* @__PURE__ */ u("div", {
300
+ className: "shio-hero__body",
301
+ ...D("body"),
302
+ dangerouslySetInnerHTML: N(e.body)
303
+ }),
304
+ a && o && /* @__PURE__ */ u("a", {
305
+ className: "shio-hero__cta",
306
+ href: a,
307
+ ...D("ctaHref", "href"),
308
+ children: /* @__PURE__ */ u("span", {
309
+ ...D("ctaLabel"),
310
+ children: o
311
+ })
312
+ }),
313
+ i && /* @__PURE__ */ u("img", {
314
+ className: "shio-hero__image",
315
+ src: t(i),
316
+ alt: j(e.heading) ?? "",
317
+ ...D("image", "src")
318
+ })
319
+ ]
320
+ });
321
+ }
322
+ function F({ data: e, className: t, postId: n }) {
323
+ let r = A(e.features);
324
+ return /* @__PURE__ */ d("section", {
325
+ className: M("shio-section", "shio-features", t),
326
+ "data-columns": j(e.columns) ?? "3",
327
+ ...D("columns", "data-columns"),
328
+ ...O(n, "SectionFeatureGrid"),
329
+ children: [
330
+ j(e.heading) && /* @__PURE__ */ u("h2", {
331
+ className: "shio-features__heading",
332
+ ...D("heading"),
333
+ children: e.heading
334
+ }),
335
+ j(e.intro) && /* @__PURE__ */ u("p", {
336
+ className: "shio-features__intro",
337
+ ...D("intro"),
338
+ children: e.intro
339
+ }),
340
+ /* @__PURE__ */ u("ul", {
341
+ className: "shio-features__list",
342
+ ...D("features"),
343
+ children: r.map((e, t) => /* @__PURE__ */ d("li", {
344
+ className: "shio-features__item",
345
+ children: [
346
+ j(e.icon) && /* @__PURE__ */ u("span", {
347
+ className: "shio-features__icon",
348
+ "data-icon": e.icon,
349
+ "aria-hidden": "true"
350
+ }),
351
+ j(e.title) && /* @__PURE__ */ u("h3", {
352
+ className: "shio-features__title",
353
+ children: e.title
354
+ }),
355
+ j(e.body) && /* @__PURE__ */ u("p", {
356
+ className: "shio-features__body",
357
+ children: e.body
358
+ })
359
+ ]
360
+ }, j(e.title) ?? t))
361
+ })
362
+ ]
363
+ });
364
+ }
365
+ function I({ data: e, className: t, postId: n }) {
366
+ let r = j(e.ctaHref), i = j(e.ctaLabel);
367
+ return /* @__PURE__ */ d("section", {
368
+ className: M("shio-section", "shio-cta", t),
369
+ "data-variant": j(e.variant) ?? "primary",
370
+ ...D("variant", "data-variant"),
371
+ ...O(n, "SectionCta"),
372
+ children: [
373
+ j(e.heading) && /* @__PURE__ */ u("h2", {
374
+ className: "shio-cta__heading",
375
+ ...D("heading"),
376
+ children: e.heading
377
+ }),
378
+ j(e.body) && /* @__PURE__ */ u("p", {
379
+ className: "shio-cta__body",
380
+ ...D("body"),
381
+ children: e.body
382
+ }),
383
+ r && i && /* @__PURE__ */ u("a", {
384
+ className: "shio-cta__button",
385
+ href: r,
386
+ ...D("ctaHref", "href"),
387
+ children: /* @__PURE__ */ u("span", {
388
+ ...D("ctaLabel"),
389
+ children: i
390
+ })
391
+ })
392
+ ]
393
+ });
394
+ }
395
+ function L({ data: e, resolveAsset: t = k, className: n, postId: r }) {
396
+ let i = A(e.logos);
397
+ return /* @__PURE__ */ d("section", {
398
+ className: M("shio-section", "shio-logos", n),
399
+ ...O(r, "SectionLogoWall"),
400
+ children: [j(e.heading) && /* @__PURE__ */ u("h2", {
401
+ className: "shio-logos__heading",
402
+ ...D("heading"),
403
+ children: e.heading
404
+ }), /* @__PURE__ */ u("ul", {
405
+ className: "shio-logos__list",
406
+ ...D("logos"),
407
+ children: i.map((e, n) => {
408
+ let r = j(e.image), i = r ? /* @__PURE__ */ u("img", {
409
+ className: "shio-logos__image",
410
+ src: t(r),
411
+ alt: j(e.name) ?? ""
412
+ }) : /* @__PURE__ */ u("span", {
413
+ className: "shio-logos__name",
414
+ children: j(e.name)
415
+ }), a = j(e.href);
416
+ return /* @__PURE__ */ u("li", {
417
+ className: "shio-logos__item",
418
+ children: a ? /* @__PURE__ */ u("a", {
419
+ href: a,
420
+ children: i
421
+ }) : i
422
+ }, j(e.name) ?? n);
423
+ })
424
+ })]
425
+ });
426
+ }
427
+ function R({ data: e, resolveAsset: t = k, className: n, postId: r }) {
428
+ let i = A(e.quotes);
429
+ return /* @__PURE__ */ d("section", {
430
+ className: M("shio-section", "shio-testimonials", n),
431
+ ...O(r, "SectionTestimonial"),
432
+ children: [
433
+ j(e.heading) && /* @__PURE__ */ u("h2", {
434
+ className: "shio-testimonials__heading",
435
+ ...D("heading"),
436
+ children: e.heading
437
+ }),
438
+ /* @__PURE__ */ u("div", {
439
+ hidden: !0,
440
+ ...D("quotes")
441
+ }),
442
+ i.map((e, n) => {
443
+ let r = j(e.avatar);
444
+ return /* @__PURE__ */ d("figure", {
445
+ className: "shio-testimonials__item",
446
+ children: [
447
+ r && /* @__PURE__ */ u("img", {
448
+ className: "shio-testimonials__avatar",
449
+ src: t(r),
450
+ alt: j(e.author) ?? ""
451
+ }),
452
+ j(e.quote) && /* @__PURE__ */ u("blockquote", {
453
+ className: "shio-testimonials__quote",
454
+ children: e.quote
455
+ }),
456
+ /* @__PURE__ */ d("figcaption", {
457
+ className: "shio-testimonials__author",
458
+ children: [j(e.author), j(e.role) && /* @__PURE__ */ u("span", {
459
+ className: "shio-testimonials__role",
460
+ children: e.role
461
+ })]
462
+ })
463
+ ]
464
+ }, j(e.author) ?? n);
465
+ })
466
+ ]
467
+ });
468
+ }
469
+ function z({ data: e, className: t, postId: n }) {
470
+ let r = A(e.questions);
471
+ return /* @__PURE__ */ d("section", {
472
+ className: M("shio-section", "shio-faq", t),
473
+ ...O(n, "SectionFaq"),
474
+ children: [
475
+ j(e.heading) && /* @__PURE__ */ u("h2", {
476
+ className: "shio-faq__heading",
477
+ ...D("heading"),
478
+ children: e.heading
479
+ }),
480
+ j(e.intro) && /* @__PURE__ */ u("p", {
481
+ className: "shio-faq__intro",
482
+ ...D("intro"),
483
+ children: e.intro
484
+ }),
485
+ /* @__PURE__ */ u("dl", {
486
+ className: "shio-faq__list",
487
+ ...D("questions"),
488
+ children: r.map((e, t) => /* @__PURE__ */ d("div", {
489
+ className: "shio-faq__item",
490
+ children: [j(e.question) && /* @__PURE__ */ u("dt", {
491
+ className: "shio-faq__question",
492
+ children: e.question
493
+ }), j(e.answer) && /* @__PURE__ */ u("dd", {
494
+ className: "shio-faq__answer",
495
+ dangerouslySetInnerHTML: N(e.answer)
496
+ })]
497
+ }, j(e.question) ?? t))
498
+ })
499
+ ]
500
+ });
501
+ }
502
+ function B({ data: e, className: t, postId: n }) {
503
+ return /* @__PURE__ */ d("section", {
504
+ className: M("shio-section", "shio-richtext", t),
505
+ ...O(n, "SectionRichText"),
506
+ children: [j(e.heading) && /* @__PURE__ */ u("h2", {
507
+ className: "shio-richtext__heading",
508
+ ...D("heading"),
509
+ children: e.heading
510
+ }), j(e.body) && /* @__PURE__ */ u("div", {
511
+ className: "shio-richtext__body",
512
+ ...D("body"),
513
+ dangerouslySetInnerHTML: N(e.body)
514
+ })]
515
+ });
516
+ }
517
+ var V = {
518
+ [f.hero]: P,
519
+ [f.featureGrid]: F,
520
+ [f.cta]: I,
521
+ [f.logoWall]: L,
522
+ [f.testimonial]: R,
523
+ [f.faq]: z,
524
+ [f.richText]: B
525
+ };
526
+ //#endregion
527
+ //#region src/sections.tsx
528
+ function H({ sections: e, resolveAsset: t = k, className: n, fallback: r }) {
529
+ return /* @__PURE__ */ u(l, { children: e.map((e, i) => {
530
+ let a = V[e.type];
531
+ if (!a) return r ? r(e) : null;
532
+ let o = {
533
+ data: e.data,
534
+ resolveAsset: t,
535
+ className: n
536
+ };
537
+ return /* @__PURE__ */ u(a, { ...o }, e.url ?? `${e.type}-${i}`);
538
+ }) });
539
+ }
540
+ //#endregion
541
+ export { I as Cta, z as Faq, F as FeatureGrid, P as Hero, L as LogoWall, h as MENU_ITEM_TYPE, m as MENU_TYPE, p as PAGE_TYPE, B as RichText, V as SECTION_COMPONENTS, f as SECTION_TYPES, H as Sections, R as Testimonial, k as defaultResolveAsset, _ as menu, v as menuItem, g as page, A as rows, x as sectionCta, w as sectionFaq, b as sectionFeatureGrid, y as sectionHero, S as sectionLogoWall, E as sectionPostTypes, T as sectionRichText, C as sectionTestimonial, j as str };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@viglet/shio-model"),require("react/jsx-runtime")):typeof define==`function`&&define.amd?define([`exports`,`@viglet/shio-model`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ShioSections={},e.ShioModel,e.jsxRuntime))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r={hero:`SectionHero`,featureGrid:`SectionFeatureGrid`,cta:`SectionCta`,logoWall:`SectionLogoWall`,testimonial:`SectionTestimonial`,faq:`SectionFaq`,richText:`SectionRichText`},i=`Page`,a=`Menu`,o=`MenuItem`,s=()=>(0,t.postType)(i,{title:`Page`,namePlural:`Pages`,description:"A page composed of sections. `sections` lists section friendly URLs in render order.",fields:[(0,t.text)(`title`,{label:`Title`,required:!0,isTitle:!0}),(0,t.textArea)(`description`,{label:`Description`,description:`Used as the page summary and the meta description.`,isSummary:!0}),(0,t.multiSelect)(`sections`,{label:`Sections`,description:`Friendly URLs of the section posts, in render order — e.g. /sections/home/hero.`,references:`post`}),(0,t.aceHtml)(`content`,{label:`Content`,description:`Markup this page carries itself, rendered around its sections. A conversion writes the source's own body here for the blocks nobody made authorable.`})]}),c=()=>(0,t.postType)(a,{title:`Menu`,namePlural:`Menus`,description:"A curated menu. `items` lists addresses in render order: a MenuItem, a nested Menu, or a page.",fields:[(0,t.text)(`title`,{label:`Title`,required:!0,isTitle:!0}),(0,t.multiSelect)(`items`,{label:`Items`,description:`Friendly URLs in render order — a MenuItem, a nested Menu, or a page (which uses its own title).`,references:`post`})]}),l=()=>(0,t.postType)(o,{title:`Menu Item`,namePlural:`Menu Items`,description:`One menu entry: a label, and either a target page or an external URL. Not both.`,fields:[(0,t.text)(`label`,{label:`Label`,required:!0,isTitle:!0}),(0,t.multiSelect)(`target`,{label:`Target page`,description:`The friendly URL of the page this points at. Leave empty for an external link.`,references:`post`}),(0,t.text)(`href`,{label:`External URL`,description:`An absolute URL, for an entry that leaves the site. Ignored when a target is set.`}),(0,t.comboBox)(`rel`,{label:`Link relationship`,description:`Emitted as rel= — what an external entry needs and an internal one does not.`,choices:{"noopener noreferrer":`External (noopener noreferrer)`,nofollow:`Nofollow`},allowNull:!0})]}),u=()=>(0,t.postType)(r.hero,{title:`Hero Section`,namePlural:`Hero Sections`,description:`The opening statement of a page: a headline, a line of support, one call to action.`,fields:[(0,t.text)(`heading`,{label:`Heading`,required:!0,isTitle:!0}),(0,t.textArea)(`subheading`,{label:`Subheading`,isSummary:!0}),(0,t.htmlEditor)(`body`,{label:`Body`}),(0,t.text)(`ctaLabel`,{label:`Call-to-action label`}),(0,t.text)(`ctaHref`,{label:`Call-to-action link`}),(0,t.file)(`image`,{label:`Image`}),(0,t.comboBox)(`align`,{label:`Alignment`,choices:{left:`Left`,center:`Centered`},allowNull:!0})]}),d=()=>(0,t.postType)(r.featureGrid,{title:`Feature Grid Section`,namePlural:`Feature Grid Sections`,description:`A short list of capabilities, each with a title and a sentence.`,fields:[(0,t.text)(`heading`,{label:`Heading`,required:!0,isTitle:!0}),(0,t.textArea)(`intro`,{label:`Intro`,isSummary:!0}),(0,t.comboBox)(`columns`,{label:`Columns`,choices:{2:`Two`,3:`Three`,4:`Four`},allowNull:!0}),(0,t.relator)(`features`,{label:`Features`,title:`Feature`,fields:[(0,t.text)(`title`,{label:`Title`,required:!0}),(0,t.textArea)(`body`,{label:`Body`}),(0,t.text)(`icon`,{label:`Icon`,description:`An icon name your front end knows.`})]})]}),f=()=>(0,t.postType)(r.cta,{title:`Call-to-action Section`,namePlural:`Call-to-action Sections`,description:`One decision, stated once: a heading, a sentence and a button.`,fields:[(0,t.text)(`heading`,{label:`Heading`,required:!0,isTitle:!0}),(0,t.textArea)(`body`,{label:`Body`,isSummary:!0}),(0,t.text)(`ctaLabel`,{label:`Button label`}),(0,t.text)(`ctaHref`,{label:`Button link`}),(0,t.comboBox)(`variant`,{label:`Variant`,choices:{primary:`Primary`,subtle:`Subtle`},allowNull:!0})]}),p=()=>(0,t.postType)(r.logoWall,{title:`Logo Wall Section`,namePlural:`Logo Wall Sections`,description:`Social proof as a row of logos.`,fields:[(0,t.text)(`heading`,{label:`Heading`,isTitle:!0}),(0,t.relator)(`logos`,{label:`Logos`,title:`Logo`,fields:[(0,t.text)(`name`,{label:`Name`,required:!0}),(0,t.file)(`image`,{label:`Image`}),(0,t.text)(`href`,{label:`Link`})]})]}),m=()=>(0,t.postType)(r.testimonial,{title:`Testimonial Section`,namePlural:`Testimonial Sections`,description:`What customers said, attributed.`,fields:[(0,t.text)(`heading`,{label:`Heading`,isTitle:!0}),(0,t.relator)(`quotes`,{label:`Quotes`,title:`Quote`,fields:[(0,t.textArea)(`quote`,{label:`Quote`,required:!0}),(0,t.text)(`author`,{label:`Author`,required:!0}),(0,t.text)(`role`,{label:`Role`}),(0,t.file)(`avatar`,{label:`Avatar`})]})]}),h=()=>(0,t.postType)(r.faq,{title:`FAQ Section`,namePlural:`FAQ Sections`,description:`Questions people actually ask, answered in place.`,fields:[(0,t.text)(`heading`,{label:`Heading`,isTitle:!0}),(0,t.textArea)(`intro`,{label:`Intro`,isSummary:!0}),(0,t.relator)(`questions`,{label:`Questions`,title:`Question`,fields:[(0,t.text)(`question`,{label:`Question`,required:!0}),(0,t.htmlEditor)(`answer`,{label:`Answer`})]})]}),g=()=>(0,t.postType)(r.richText,{title:`Rich Text Section`,namePlural:`Rich Text Sections`,description:`Prose. The escape hatch that keeps the other sections from growing fields they do not need.`,fields:[(0,t.text)(`heading`,{label:`Heading`,isTitle:!0}),(0,t.htmlEditor)(`body`,{label:`Body`,required:!0})]}),_=()=>[c(),l(),s(),f(),h(),d(),u(),p(),g(),m()];function v(e,t){return t?{"data-shio-prop":e,"data-shio-prop-attr":t}:{"data-shio-prop":e}}function y(e,t){return e?{"data-shio-post":e,"data-shio-post-type":t}:{}}var b=e=>/^(https?:)?\/\//.test(e)||e.startsWith(`/`)?e:`/api/v2/staticfile/${e}`;function x(e){return Array.isArray(e)?e:[]}function S(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}var C=(...e)=>e.filter(Boolean).join(` `),w=e=>({__html:e});function T({data:e,resolveAsset:t=b,className:r,postId:i}){let a=S(e.image),o=S(e.ctaHref),s=S(e.ctaLabel);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-hero`,S(e.align)===`center`?`shio-hero--center`:void 0,r),...y(i,`SectionHero`),children:[S(e.heading)&&(0,n.jsx)(`h1`,{className:`shio-hero__heading`,...v(`heading`),children:e.heading}),S(e.subheading)&&(0,n.jsx)(`p`,{className:`shio-hero__subheading`,...v(`subheading`),children:e.subheading}),S(e.body)&&(0,n.jsx)(`div`,{className:`shio-hero__body`,...v(`body`),dangerouslySetInnerHTML:w(e.body)}),o&&s&&(0,n.jsx)(`a`,{className:`shio-hero__cta`,href:o,...v(`ctaHref`,`href`),children:(0,n.jsx)(`span`,{...v(`ctaLabel`),children:s})}),a&&(0,n.jsx)(`img`,{className:`shio-hero__image`,src:t(a),alt:S(e.heading)??``,...v(`image`,`src`)})]})}function E({data:e,className:t,postId:r}){let i=x(e.features);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-features`,t),"data-columns":S(e.columns)??`3`,...v(`columns`,`data-columns`),...y(r,`SectionFeatureGrid`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-features__heading`,...v(`heading`),children:e.heading}),S(e.intro)&&(0,n.jsx)(`p`,{className:`shio-features__intro`,...v(`intro`),children:e.intro}),(0,n.jsx)(`ul`,{className:`shio-features__list`,...v(`features`),children:i.map((e,t)=>(0,n.jsxs)(`li`,{className:`shio-features__item`,children:[S(e.icon)&&(0,n.jsx)(`span`,{className:`shio-features__icon`,"data-icon":e.icon,"aria-hidden":`true`}),S(e.title)&&(0,n.jsx)(`h3`,{className:`shio-features__title`,children:e.title}),S(e.body)&&(0,n.jsx)(`p`,{className:`shio-features__body`,children:e.body})]},S(e.title)??t))})]})}function D({data:e,className:t,postId:r}){let i=S(e.ctaHref),a=S(e.ctaLabel);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-cta`,t),"data-variant":S(e.variant)??`primary`,...v(`variant`,`data-variant`),...y(r,`SectionCta`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-cta__heading`,...v(`heading`),children:e.heading}),S(e.body)&&(0,n.jsx)(`p`,{className:`shio-cta__body`,...v(`body`),children:e.body}),i&&a&&(0,n.jsx)(`a`,{className:`shio-cta__button`,href:i,...v(`ctaHref`,`href`),children:(0,n.jsx)(`span`,{...v(`ctaLabel`),children:a})})]})}function O({data:e,resolveAsset:t=b,className:r,postId:i}){let a=x(e.logos);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-logos`,r),...y(i,`SectionLogoWall`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-logos__heading`,...v(`heading`),children:e.heading}),(0,n.jsx)(`ul`,{className:`shio-logos__list`,...v(`logos`),children:a.map((e,r)=>{let i=S(e.image),a=i?(0,n.jsx)(`img`,{className:`shio-logos__image`,src:t(i),alt:S(e.name)??``}):(0,n.jsx)(`span`,{className:`shio-logos__name`,children:S(e.name)}),o=S(e.href);return(0,n.jsx)(`li`,{className:`shio-logos__item`,children:o?(0,n.jsx)(`a`,{href:o,children:a}):a},S(e.name)??r)})})]})}function k({data:e,resolveAsset:t=b,className:r,postId:i}){let a=x(e.quotes);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-testimonials`,r),...y(i,`SectionTestimonial`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-testimonials__heading`,...v(`heading`),children:e.heading}),(0,n.jsx)(`div`,{hidden:!0,...v(`quotes`)}),a.map((e,r)=>{let i=S(e.avatar);return(0,n.jsxs)(`figure`,{className:`shio-testimonials__item`,children:[i&&(0,n.jsx)(`img`,{className:`shio-testimonials__avatar`,src:t(i),alt:S(e.author)??``}),S(e.quote)&&(0,n.jsx)(`blockquote`,{className:`shio-testimonials__quote`,children:e.quote}),(0,n.jsxs)(`figcaption`,{className:`shio-testimonials__author`,children:[S(e.author),S(e.role)&&(0,n.jsx)(`span`,{className:`shio-testimonials__role`,children:e.role})]})]},S(e.author)??r)})]})}function A({data:e,className:t,postId:r}){let i=x(e.questions);return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-faq`,t),...y(r,`SectionFaq`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-faq__heading`,...v(`heading`),children:e.heading}),S(e.intro)&&(0,n.jsx)(`p`,{className:`shio-faq__intro`,...v(`intro`),children:e.intro}),(0,n.jsx)(`dl`,{className:`shio-faq__list`,...v(`questions`),children:i.map((e,t)=>(0,n.jsxs)(`div`,{className:`shio-faq__item`,children:[S(e.question)&&(0,n.jsx)(`dt`,{className:`shio-faq__question`,children:e.question}),S(e.answer)&&(0,n.jsx)(`dd`,{className:`shio-faq__answer`,dangerouslySetInnerHTML:w(e.answer)})]},S(e.question)??t))})]})}function j({data:e,className:t,postId:r}){return(0,n.jsxs)(`section`,{className:C(`shio-section`,`shio-richtext`,t),...y(r,`SectionRichText`),children:[S(e.heading)&&(0,n.jsx)(`h2`,{className:`shio-richtext__heading`,...v(`heading`),children:e.heading}),S(e.body)&&(0,n.jsx)(`div`,{className:`shio-richtext__body`,...v(`body`),dangerouslySetInnerHTML:w(e.body)})]})}var M={[r.hero]:T,[r.featureGrid]:E,[r.cta]:D,[r.logoWall]:O,[r.testimonial]:k,[r.faq]:A,[r.richText]:j};function N({sections:e,resolveAsset:t=b,className:r,fallback:i}){return(0,n.jsx)(n.Fragment,{children:e.map((e,a)=>{let o=M[e.type];if(!o)return i?i(e):null;let s={data:e.data,resolveAsset:t,className:r};return(0,n.jsx)(o,{...s},e.url??`${e.type}-${a}`)})})}e.Cta=D,e.Faq=A,e.FeatureGrid=E,e.Hero=T,e.LogoWall=O,e.MENU_ITEM_TYPE=o,e.MENU_TYPE=a,e.PAGE_TYPE=i,e.RichText=j,e.SECTION_COMPONENTS=M,e.SECTION_TYPES=r,e.Sections=N,e.Testimonial=k,e.defaultResolveAsset=b,e.menu=c,e.menuItem=l,e.page=s,e.rows=x,e.sectionCta=f,e.sectionFaq=h,e.sectionFeatureGrid=d,e.sectionHero=u,e.sectionLogoWall=p,e.sectionPostTypes=_,e.sectionRichText=g,e.sectionTestimonial=m,e.str=S});
@@ -0,0 +1,118 @@
1
+ /** A section as the delivery API hands it over: its post-type name and its field values. */
2
+ export interface SectionPost {
3
+ /** The post-type name — the key `SECTION_COMPONENTS` dispatches on. */
4
+ type: string;
5
+ /** The section's friendly URL, when the caller resolved it from one. */
6
+ url?: string;
7
+ /** Field values, keyed by attribute name. */
8
+ data: Record<string, unknown>;
9
+ }
10
+ /**
11
+ * Props every section component takes.
12
+ *
13
+ * `data` is loosely typed because it comes off the wire. Each component narrows what it
14
+ * needs and renders nothing for what is absent — a section with an empty field is a page
15
+ * the editor has not finished, not a crash.
16
+ */
17
+ export interface SectionProps<T = Record<string, unknown>> {
18
+ data: T;
19
+ /**
20
+ * Turns a `File`-field value into a URL.
21
+ *
22
+ * A File field stores the **post id** of the uploaded file, and the public bytes live
23
+ * at `/file_source/<postId>/<fileName>` — a path that needs the file's name, which the
24
+ * field value does not carry. Until the projection resolves assets by path (SH145) that
25
+ * lookup belongs to the app, so this hook exists and the default is the id-keyed
26
+ * streaming endpoint, which works but authenticates as the console.
27
+ */
28
+ resolveAsset?: (value: string) => string;
29
+ className?: string;
30
+ /**
31
+ * The section post's id, which turns the rendered markup into something the editor can edit
32
+ * (SH638).
33
+ *
34
+ * <h3>The host contract, which is the part that needed deciding</h3>
35
+ *
36
+ * The Java renderer emits `data-shio-post` / `data-shio-prop` itself, because it knows which post
37
+ * it is rendering. A headless host does not get that for free: it fetched the section over the
38
+ * CDA and React draws it, so **only the host knows the id**. Passing it here is that contract,
39
+ * stated in one optional prop rather than in prose a host has to find.
40
+ *
41
+ * Optional on purpose. A public page has no reason to carry editing metadata, and a host that
42
+ * omits it renders byte-identical markup to before — so the annotations cost nothing where they
43
+ * are not wanted, and the editor is opt-in per render rather than per build.
44
+ */
45
+ postId?: string;
46
+ }
47
+ /**
48
+ * The attributes that make one field editable in place (SH638).
49
+ *
50
+ * `data-shio-prop` names the field; `data-shio-prop-attr` names *which attribute* carries the value
51
+ * when it is not the element's text — an `href` or a `src`. Both forms exist because `shio
52
+ * annotations` counts both, and once a complete page read as 9 of 10 because only the first was
53
+ * counted (SH503's near-miss regression).
54
+ */
55
+ export declare function editable(field: string, attribute?: string): Record<string, string>;
56
+ /** The section root's own annotation: which post this markup is, and of what type. */
57
+ export declare function editableSection(postId: string | undefined, type: string): Record<string, string>;
58
+ export interface HeroData {
59
+ heading?: string;
60
+ subheading?: string;
61
+ body?: string;
62
+ ctaLabel?: string;
63
+ ctaHref?: string;
64
+ image?: string;
65
+ align?: string;
66
+ }
67
+ export interface FeatureGridData {
68
+ heading?: string;
69
+ intro?: string;
70
+ columns?: string;
71
+ features?: Array<{
72
+ title?: string;
73
+ body?: string;
74
+ icon?: string;
75
+ }>;
76
+ }
77
+ export interface CtaData {
78
+ heading?: string;
79
+ body?: string;
80
+ ctaLabel?: string;
81
+ ctaHref?: string;
82
+ variant?: string;
83
+ }
84
+ export interface LogoWallData {
85
+ heading?: string;
86
+ logos?: Array<{
87
+ name?: string;
88
+ image?: string;
89
+ href?: string;
90
+ }>;
91
+ }
92
+ export interface TestimonialData {
93
+ heading?: string;
94
+ quotes?: Array<{
95
+ quote?: string;
96
+ author?: string;
97
+ role?: string;
98
+ avatar?: string;
99
+ }>;
100
+ }
101
+ export interface FaqData {
102
+ heading?: string;
103
+ intro?: string;
104
+ questions?: Array<{
105
+ question?: string;
106
+ answer?: string;
107
+ }>;
108
+ }
109
+ export interface RichTextData {
110
+ heading?: string;
111
+ body?: string;
112
+ }
113
+ /** Default asset resolution: pass URLs and paths through, stream anything else by id. */
114
+ export declare const defaultResolveAsset: (value: string) => string;
115
+ /** A Relator field's rows — tolerant of an absent or non-array value. */
116
+ export declare function rows<T>(value: unknown): T[];
117
+ /** Trimmed string, or undefined — so a blank field renders as nothing, not as an empty tag. */
118
+ export declare function str(value: unknown): string | undefined;
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "@viglet/shio-sections",
3
+ "version": "2026.3.2",
4
+ "description": "The Shio page-section vocabulary (SH95): composable section post-types authored with @viglet/shio-model, plus the matching React components. One shared language for the agent, the console and the front end — a page is an ordered list of known sections instead of an ad-hoc content model per site.",
5
+ "homepage": "https://shio.viglet.org/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/openviglet/shio.git",
9
+ "directory": "shio-sections"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/openviglet/shio/issues"
13
+ },
14
+ "type": "module",
15
+ "main": "dist/shio-sections.umd.cjs",
16
+ "module": "dist/shio-sections.js",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/shio-sections.js",
22
+ "require": "./dist/shio-sections.umd.cjs"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "sideEffects": false,
30
+ "dependencies": {
31
+ "@viglet/shio-model": "2026.3.2"
32
+ },
33
+ "peerDependencies": {
34
+ "react": ">=18.0.0"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "react": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "devDependencies": {
42
+ "@types/react": "^19.2.18",
43
+ "react": "^19.2.8",
44
+ "typescript": "^5.8.3",
45
+ "vite": "^8.2.0"
46
+ },
47
+ "keywords": [
48
+ "shio",
49
+ "viglet",
50
+ "cms",
51
+ "headless-cms",
52
+ "content-management-system",
53
+ "agent",
54
+ "ai",
55
+ "mcp",
56
+ "model-context-protocol",
57
+ "claude-code",
58
+ "sections",
59
+ "blocks",
60
+ "page-builder",
61
+ "react",
62
+ "content-as-code",
63
+ "landing-page",
64
+ "headless"
65
+ ],
66
+ "author": {
67
+ "name": "Viglet Team",
68
+ "url": "https://www.viglet.org"
69
+ },
70
+ "license": "Apache-2.0",
71
+ "scripts": {
72
+ "dev": "vite build --watch",
73
+ "build": "vite build && tsc --emitDeclarationOnly",
74
+ "typecheck": "tsc --noEmit",
75
+ "emit": "node scripts/emit.mjs",
76
+ "test": "node --test \"test/*.test.mjs\""
77
+ }
78
+ }