@plitzi/sdk-authoring 0.39.2 → 0.39.4

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.
Files changed (27) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index-src.js +1204 -997
  3. package/dist/index.d.ts +73 -6
  4. package/dist/node.d.ts +57 -5
  5. package/dist/plugin.d.ts +1 -1
  6. package/package.json +7 -7
  7. package/skills/plitzi-authoring/recipes/accordion.ts +3 -1
  8. package/skills/plitzi-authoring/recipes/carousel.ts +68 -63
  9. package/skills/plitzi-authoring/recipes/detail-page.ts +43 -33
  10. package/skills/plitzi-authoring/recipes/embed-and-svg.ts +16 -11
  11. package/skills/plitzi-authoring/recipes/every-few-seconds.ts +52 -42
  12. package/skills/plitzi-authoring/recipes/feature-flag.ts +7 -2
  13. package/skills/plitzi-authoring/recipes/filter-a-list.ts +39 -31
  14. package/skills/plitzi-authoring/recipes/forms-and-modals.ts +34 -28
  15. package/skills/plitzi-authoring/recipes/from-tailwind.ts +11 -6
  16. package/skills/plitzi-authoring/recipes/link-to-a-section.ts +11 -6
  17. package/skills/plitzi-authoring/recipes/link-with-data.ts +21 -16
  18. package/skills/plitzi-authoring/recipes/marquee.ts +17 -12
  19. package/skills/plitzi-authoring/recipes/plugin.ts +16 -10
  20. package/skills/plitzi-authoring/recipes/scroll-a-row.ts +30 -25
  21. package/skills/plitzi-authoring/recipes/server-data.ts +15 -10
  22. package/skills/plitzi-authoring/recipes/show-data.ts +32 -24
  23. package/skills/plitzi-authoring/recipes/style-a-page.ts +9 -4
  24. package/skills/plitzi-authoring/recipes/typed-data.ts +26 -21
  25. package/skills/plitzi-authoring/recipes/usable-without-sight.ts +16 -11
  26. package/skills/plitzi-authoring/reference/authoring-errors.md +3 -0
  27. package/skills/plitzi-authoring/reference/efficiency.md +2 -1
@@ -39,36 +39,44 @@ export const recipe: SpaceSpec = {
39
39
  name: 'Home',
40
40
  slug: '',
41
41
  body: [
42
- text({ from: 'computed.cartCount', as: '{{ source }} in the cart' }),
43
- apiContainer({
44
- id: 'catalog',
45
- query: '/data/products.json',
46
- cache: true,
47
- // Shown in place of the rest until the first answer, and gone after it.
48
- loadingSlot: 'catalog-skeleton',
42
+ container({
43
+ subType: 'main',
49
44
  children: [
50
- container({ id: 'catalog-skeleton', class: skeleton }),
51
- // Inside a template a source is spelled in full; a binding's own source is `source`.
52
- text({ from: 'catalog.data.products', as: '{{ source|length }} products' }),
53
- list({
54
- id: 'products',
55
- class: grid,
56
- items: 'catalog.data.products',
45
+ text({ from: 'computed.cartCount', as: '{{ source }} in the cart' }),
46
+ apiContainer({
47
+ id: 'catalog',
48
+ query: '/data/products.json',
49
+ cache: true,
50
+ // Shown in place of the rest until the first answer, and gone after it.
51
+ loadingSlot: 'catalog-skeleton',
57
52
  children: [
58
- // One `<li>` per product. Inside a row, a binding names the row short (`products.item`), a template in
59
- // full (`list_products`).
60
- listItem({
61
- class: card,
53
+ container({ id: 'catalog-skeleton', class: skeleton }),
54
+ // Inside a template a source is spelled in full; a binding's own source is `source`.
55
+ text({ from: 'catalog.data.products', as: '{{ source|length }} products' }),
56
+ list({
57
+ id: 'products',
58
+ class: grid,
59
+ items: 'catalog.data.products',
62
60
  children: [
63
- heading({ subType: 'h3', from: 'products.item.title' }),
64
- text({ from: 'products.item.price', as: 'price' })
61
+ // One `<li>` per product. Inside a row, a binding names the row short (`products.item`), a template in
62
+ // full (`list_products`).
63
+ listItem({
64
+ class: card,
65
+ children: [
66
+ heading({ subType: 'h3', from: 'products.item.title' }),
67
+ text({ from: 'products.item.price', as: 'price' })
68
+ ]
69
+ })
65
70
  ]
71
+ }),
72
+ // Revealed by the data, so it starts hidden: nothing flashes while the file loads.
73
+ text('No products yet.', {
74
+ visible: {
75
+ source: 'catalog.data.products',
76
+ template: '{{ source is defined and source|length == 0 }}'
77
+ }
66
78
  })
67
79
  ]
68
- }),
69
- // Revealed by the data, so it starts hidden: nothing flashes while the file loads.
70
- text('No products yet.', {
71
- visible: { source: 'catalog.data.products', template: '{{ source is defined and source|length == 0 }}' }
72
80
  })
73
81
  ]
74
82
  })
@@ -33,11 +33,16 @@ export const recipe: SpaceSpec = {
33
33
  slug: '',
34
34
  css: { 'background-color': 'var(--card)', color: 'var(--foreground)', padding: '48px 24px' },
35
35
  body: [
36
- container({ class: card, children: [heading('Plain', { subType: 'h2' }), text('The class as it is.')] }),
37
36
  container({
38
- id: 'featured',
39
- class: [card, { 'border-width': '2px', 'border-style': 'solid', 'border-color': 'var(--primary)' }],
40
- children: [heading('Featured', { subType: 'h2' }), text('The class, plus one thing.')]
37
+ subType: 'main',
38
+ children: [
39
+ container({ class: card, children: [heading('Plain', { subType: 'h2' }), text('The class as it is.')] }),
40
+ container({
41
+ id: 'featured',
42
+ class: [card, { 'border-width': '2px', 'border-style': 'solid', 'border-color': 'var(--primary)' }],
43
+ children: [heading('Featured', { subType: 'h2' }), text('The class, plus one thing.')]
44
+ })
45
+ ]
41
46
  })
42
47
  ]
43
48
  }
@@ -3,7 +3,7 @@
3
3
  * `site.data.hero.titel` is a type error, not an empty heading. In a project the sample is the file itself:
4
4
  * `import home from '../data/home.json' with { type: 'json' }` — `src/data/`, or `public/data/` with no server.
5
5
  */
6
- import { apiContainer, heading, list, source, styles, text, twig, listItem } from '@plitzi/sdk-authoring';
6
+ import { apiContainer, container, heading, list, listItem, source, styles, text, twig } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
@@ -35,28 +35,33 @@ export const recipe: SpaceSpec = {
35
35
  name: 'Home',
36
36
  slug: '',
37
37
  body: [
38
- apiContainer({
39
- id: site.id,
40
- query: '/data/home.json',
41
- cache: true,
38
+ container({
39
+ subType: 'main',
42
40
  children: [
43
- heading({ from: site.data.hero.title }),
44
- text({ from: site.data.hero.subtitle }),
45
- // A template takes the paths through `twig`, each written in full.
46
- text({ content: twig`{{ ${site.data.products}|length }} products` }),
47
- list({
48
- id: 'products',
49
- class: grid,
50
- items: site.data.products,
51
- // The row's item is typed as the sample's: every field any product has.
52
- row: product =>
53
- listItem({
54
- children: [
55
- text({ from: product.item.title }),
56
- text({ from: product.item.price, as: 'price' }),
57
- text({ from: product.item.badge, visible: product.item.badge })
58
- ]
41
+ apiContainer({
42
+ id: site.id,
43
+ query: '/data/home.json',
44
+ cache: true,
45
+ children: [
46
+ heading({ from: site.data.hero.title }),
47
+ text({ from: site.data.hero.subtitle }),
48
+ // A template takes the paths through `twig`, each written in full.
49
+ text({ content: twig`{{ ${site.data.products}|length }} products` }),
50
+ list({
51
+ id: 'products',
52
+ class: grid,
53
+ items: site.data.products,
54
+ // The row's item is typed as the sample's: every field any product has.
55
+ row: product =>
56
+ listItem({
57
+ children: [
58
+ text({ from: product.item.title }),
59
+ text({ from: product.item.price, as: 'price' }),
60
+ text({ from: product.item.badge, visible: product.item.badge })
61
+ ]
62
+ })
59
63
  })
64
+ ]
60
65
  })
61
66
  ]
62
67
  })
@@ -3,7 +3,7 @@
3
3
  * button, a field keeps its label out of sight rather than dropping it, a picture says what it shows or that it only
4
4
  * decorates.
5
5
  */
6
- import { button, formControl, image, setState, styles, text, onClick } from '@plitzi/sdk-authoring';
6
+ import { button, container, formControl, image, onClick, setState, styles, text } from '@plitzi/sdk-authoring';
7
7
 
8
8
  import type { SpaceSpec } from '@plitzi/sdk-authoring';
9
9
 
@@ -23,16 +23,21 @@ export const recipe: SpaceSpec = {
23
23
  name: 'Home',
24
24
  slug: '',
25
25
  body: [
26
- button({ content: '', title: 'Search', icon: 'fa-solid fa-magnifying-glass' }),
27
- button({
28
- content: '',
29
- class: card,
30
- children: [text('Pro'), text('12 € a month')],
31
- flows: [[onClick(), setState({ key: 'plan', type: 'text', value: 'pro' })]]
32
- }),
33
- formControl({ name: 'q', label: 'Search the docs', hideLabel: true, placeholder: 'Search…' }),
34
- image({ src: '/team.jpg', alt: 'The team at the 2026 offsite' }),
35
- image({ src: '/grain.png', decorative: true })
26
+ container({
27
+ subType: 'main',
28
+ children: [
29
+ button({ content: '', title: 'Search', icon: 'fa-solid fa-magnifying-glass' }),
30
+ button({
31
+ content: '',
32
+ class: card,
33
+ children: [text('Pro'), text('12 € a month')],
34
+ flows: [[onClick(), setState({ key: 'plan', type: 'text', value: 'pro' })]]
35
+ }),
36
+ formControl({ name: 'q', label: 'Search the docs', hideLabel: true, placeholder: 'Search…' }),
37
+ image({ src: '/team.jpg', alt: 'The team at the 2026 offsite' }),
38
+ image({ src: '/grain.png', decorative: true })
39
+ ]
40
+ })
36
41
  ]
37
42
  }
38
43
  ]
@@ -280,9 +280,12 @@ Nothing is wrong: the page renders as written. Each is a shorter way to the same
280
280
  | `element-color-inherited` | `elements` giving a type — a heading, a text, a link — `color: inherit` or the page's own colour, which it takes by itself | remove it, and name the colour once on `elements.page`: every element reads in the page’s colour, a link’s words included |
281
281
  | `heading-level-skipped` | an `h4` right after an `h2` on a page as it is drawn — inside its layouts, with the headings a `markdown` writes, and without those that start hidden (`visible: false`): the outline misses a level (Lighthouse: "not in a sequentially-descending order") | the next level down; size it with its class |
282
282
  | `heavy-animation` | keyframes animating what the browser repaints or lays out again on every frame — a size, a position, a blur, a shadow, or a colour in a loop — which stutters whenever the page is busy, most of all while it loads | `opacity` and `transform`: a size or a position is `translate`/`scale`, a blur or a shadow is the `opacity` of a layer carrying it; a loop that must animate anything else starts `paused` and runs under `[data-hydrated]` |
283
+ | `heavy-page` | one page whose part of the document passes 250 KB — every visitor downloads it before the page is theirs — with the shapes written again most inside it, by what they weigh | the rows of data as one `list` of a component, read from the data (`list({ items, row })`), and a block written per state as one element whose state picks its content: the document then holds one copy — or, for an app's page heavy for how many elements it has, `quiet: ['heavy-page']` on the page, with why |
283
284
  | `literal-colour` | a colour written out in a class where the space has a token of that value — it stays put in the dark scheme | `var(--token)` when it should follow the scheme; a token of one value of its own when it must stay the same in both |
284
285
  | `not-found-page` | a space with no page of its own for an address no other page answers — a plain one was added, in the home page’s layout, sent with status 404 | a page whose slug is `'*'`: `{ id: 'not-found', name: 'Not found', slug: '*', layout: …, body: [...] }` |
286
+ | `page-without-main` | a page that draws no `main` landmark — neither it nor its layouts: a screen reader skipping to the content and a browser agent find no place where the page's own content starts (Lighthouse: "Document does not have a main landmark") | the container holding the page's content drawn as `main` (`container({ subType: 'main', children })`) — in the layout's slot when its pages share the shell — once a page |
285
287
  | `plugin-custom-host` | a `custom` element naming, by `renderType`, a plugin whose declaration the space was handed | place it from its declaration — `const seatPicker = defineElement(declaration)`, then `seatPicker({ id, … })`: typed by what it declares (a `definePlugin` declaration carries its attributes), the element the builder adds too |
288
+ | `repeated-expression` | the same long expression — its numbers and words aside — written into many bindings, steps or attributes: a sum or a choice worked out again in every copy, and carried by the document once per copy | what the copies share as a computed value (`computed: { chosen: '{{ … }}' }`, read as `computed.chosen`), answering `null` off the page that reads it (`navigation.currentPageId`), each copy keeping what differs; copies side by side as one `list` whose rows carry what differs (`list({ items, row })`) |
286
289
  | `repeated-on-pages` | the same block — a header, a footer, a side panel — written into several pages | a layout holding it once (`layouts`, and `layout: { id, slot }` on each page) — a component when only some pages of a layout carry it, written in its area’s folder and listed in the space’s `components`; a link marks its own page with the `current` state |
287
290
  | `repeated-shape` | the same structure written again and again with different words — cards, rows, tiles. Copies that read their data in a form of their own (their template) or render on the server are no repeats, and neither are copies side by side wired to different sources or state keys — controls written alike; copies apart that read different sources are one component, each instance handed its own | a component with props (`components`, `component(id, { props })`) — a source a copy reads handed in as a bound `json` prop (`component(id, { bind: [{ to: 'items', source }] })`, read inside as `props.items`) — or one `list` when they are rows of data side by side; a few cards a person rewords on the canvas can stay cards |
288
291
  | `unused-class` | a class declared in `classes` that no element, binding, flow or other class names | remove it from `classes` — or wear it where it was meant to go |
@@ -20,7 +20,8 @@ is a bug to fix; a suggestion is a shorter way to the same page — take it unle
20
20
  reason is usually that the copies are about to diverge. `npx @plitzi/cli explain repeated-on-pages` explains any code.
21
21
 
22
22
  Left on purpose, say so where it is written — `quiet` on an element it is about (a component's instance too:
23
- `component(id, { quiet })`), and it is not offered again, in the builder or over MCP either (it is kept in the
23
+ `component(id, { quiet })`; a page for `heavy-page`, an app's page heavy for how many elements it has), and it is not
24
+ offered again, in the builder or over MCP either (it is kept in the
24
25
  document):
25
26
 
26
27
  ```ts