soinproduction-gutenberg 0.1.5 → 0.1.7

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 (242) hide show
  1. package/README.md +72 -0
  2. package/adapters/wordpress/assets.php +4 -3
  3. package/adapters/wordpress/blueprint.ts +7 -3
  4. package/adapters/wordpress/renderer.php +108 -28
  5. package/admin-ui/editor.css +26 -3
  6. package/components/accordion/index.tsx +2 -2
  7. package/components/button/index.tsx +1 -1
  8. package/components/buttons/implementation/content.tsx +3 -1
  9. package/components/buttons/index.tsx +1 -1
  10. package/components/buttons/shared/index.tsx +2 -1
  11. package/components/categories/README.md +47 -0
  12. package/components/categories/index.tsx +81 -0
  13. package/components/categories/manifest.json +4 -0
  14. package/components/drag/editor.tsx +2 -1
  15. package/components/drag/index.tsx +4 -3
  16. package/components/forms/implementation/component.tsx +3 -0
  17. package/components/heading/editor.tsx +55 -0
  18. package/components/heading/index.tsx +28 -6
  19. package/components/heading/manifest.json +8 -1
  20. package/components/heading/model.ts +39 -0
  21. package/components/records/editor.tsx +13 -0
  22. package/components/records/index.tsx +34 -15
  23. package/components/records/manifest.json +8 -1
  24. package/components/section/index.tsx +2 -2
  25. package/components/show/index.tsx +4 -2
  26. package/components/social-links/index.tsx +4 -3
  27. package/components/toggle/index.tsx +4 -2
  28. package/core/editor/manual-record.tsx +1 -1
  29. package/core/editor/record-link-format.tsx +26 -0
  30. package/core/editor/relationship.tsx +9 -3
  31. package/core/fields/category.ts +35 -0
  32. package/core/fields/editor.tsx +11 -8
  33. package/core/fields/record-link.ts +29 -0
  34. package/core/fields/record-title.ts +57 -0
  35. package/core/fields/records.ts +5 -4
  36. package/core/fields/render.tsx +89 -35
  37. package/core/fields/schema.ts +4 -0
  38. package/core/fields/view-classes.ts +9 -0
  39. package/core/icons/list.tsx +10 -7
  40. package/core/media/image.tsx +1 -1
  41. package/core/ui/disclosure.tsx +201 -72
  42. package/core/ui/record-selection.ts +116 -0
  43. package/core/ui/slider.tsx +9 -5
  44. package/dist/adapters/wordpress/assets.php +4 -3
  45. package/dist/adapters/wordpress/blueprint.d.ts +4 -0
  46. package/dist/adapters/wordpress/blueprint.js +12 -2
  47. package/dist/adapters/wordpress/blueprint.js.map +2 -2
  48. package/dist/adapters/wordpress/renderer.php +108 -28
  49. package/dist/admin-ui/editor.css +26 -3
  50. package/dist/components/accordion/index.js +2 -2
  51. package/dist/components/accordion/index.js.map +2 -2
  52. package/dist/components/button/index.d.ts +6 -2
  53. package/dist/components/button/index.js +1 -1
  54. package/dist/components/button/index.js.map +2 -2
  55. package/dist/components/buttons/implementation/content.d.ts +2 -1
  56. package/dist/components/buttons/implementation/content.js +3 -2
  57. package/dist/components/buttons/implementation/content.js.map +2 -2
  58. package/dist/components/buttons/index.d.ts +6 -2
  59. package/dist/components/buttons/index.js +1 -1
  60. package/dist/components/buttons/index.js.map +2 -2
  61. package/dist/components/buttons/shared/index.d.ts +2 -1
  62. package/dist/components/buttons/shared/index.js +2 -1
  63. package/dist/components/buttons/shared/index.js.map +2 -2
  64. package/dist/components/categories/README.md +47 -0
  65. package/dist/components/categories/index.d.ts +41 -0
  66. package/dist/components/categories/index.js +102 -0
  67. package/dist/components/categories/index.js.map +7 -0
  68. package/dist/components/categories/manifest.json +4 -0
  69. package/dist/components/drag/editor.js +2 -1
  70. package/dist/components/drag/editor.js.map +2 -2
  71. package/dist/components/drag/index.js +4 -3
  72. package/dist/components/drag/index.js.map +2 -2
  73. package/dist/components/forms/implementation/component.js +3 -0
  74. package/dist/components/forms/implementation/component.js.map +2 -2
  75. package/dist/components/gallery/index.d.ts +6 -2
  76. package/dist/components/heading/editor.d.ts +1 -0
  77. package/dist/components/heading/editor.js +75 -0
  78. package/dist/components/heading/editor.js.map +7 -0
  79. package/dist/components/heading/index.d.ts +10 -12
  80. package/dist/components/heading/index.js +25 -5
  81. package/dist/components/heading/index.js.map +2 -2
  82. package/dist/components/heading/manifest.json +8 -1
  83. package/dist/components/heading/model.d.ts +23 -0
  84. package/dist/components/heading/model.js +34 -0
  85. package/dist/components/heading/model.js.map +7 -0
  86. package/dist/components/icon/index.d.ts +6 -2
  87. package/dist/components/image/index.d.ts +6 -2
  88. package/dist/components/paragraphs/index.d.ts +6 -2
  89. package/dist/components/records/editor.d.ts +2 -0
  90. package/dist/components/records/editor.js +23 -0
  91. package/dist/components/records/editor.js.map +7 -0
  92. package/dist/components/records/index.d.ts +19 -6
  93. package/dist/components/records/index.js +42 -9
  94. package/dist/components/records/index.js.map +3 -3
  95. package/dist/components/records/manifest.json +8 -1
  96. package/dist/components/reviews-carousel/index.d.ts +6 -2
  97. package/dist/components/section/index.js +2 -2
  98. package/dist/components/section/index.js.map +2 -2
  99. package/dist/components/show/index.d.ts +3 -2
  100. package/dist/components/show/index.js +4 -2
  101. package/dist/components/show/index.js.map +2 -2
  102. package/dist/components/slider/index.d.ts +9 -3
  103. package/dist/components/social-links/index.d.ts +3 -3
  104. package/dist/components/social-links/index.js +3 -1
  105. package/dist/components/social-links/index.js.map +2 -2
  106. package/dist/components/text/index.d.ts +6 -2
  107. package/dist/components/toggle/index.d.ts +3 -2
  108. package/dist/components/toggle/index.js +4 -2
  109. package/dist/components/toggle/index.js.map +2 -2
  110. package/dist/core/editor/manual-record.d.ts +5 -0
  111. package/dist/core/editor/manual-record.js +1 -0
  112. package/dist/core/editor/manual-record.js.map +2 -2
  113. package/dist/core/editor/record-link-format.d.ts +5 -0
  114. package/dist/core/editor/record-link-format.js +39 -0
  115. package/dist/core/editor/record-link-format.js.map +7 -0
  116. package/dist/core/editor/relationship.d.ts +3 -1
  117. package/dist/core/editor/relationship.js +7 -5
  118. package/dist/core/editor/relationship.js.map +2 -2
  119. package/dist/core/fields/category.d.ts +14 -0
  120. package/dist/core/fields/category.js +37 -0
  121. package/dist/core/fields/category.js.map +7 -0
  122. package/dist/core/fields/editor.js +12 -9
  123. package/dist/core/fields/editor.js.map +2 -2
  124. package/dist/core/fields/record-link.d.ts +4 -0
  125. package/dist/core/fields/record-link.js +32 -0
  126. package/dist/core/fields/record-link.js.map +7 -0
  127. package/dist/core/fields/record-title.d.ts +20 -0
  128. package/dist/core/fields/record-title.js +59 -0
  129. package/dist/core/fields/record-title.js.map +7 -0
  130. package/dist/core/fields/records.js +5 -4
  131. package/dist/core/fields/records.js.map +2 -2
  132. package/dist/core/fields/render.d.ts +26 -21
  133. package/dist/core/fields/render.js +98 -29
  134. package/dist/core/fields/render.js.map +2 -2
  135. package/dist/core/fields/schema.d.ts +2 -0
  136. package/dist/core/fields/schema.js +2 -0
  137. package/dist/core/fields/schema.js.map +2 -2
  138. package/dist/core/fields/view-classes.d.ts +6 -0
  139. package/dist/core/fields/view-classes.js +7 -0
  140. package/dist/core/fields/view-classes.js.map +7 -0
  141. package/dist/core/icons/list.d.ts +1 -0
  142. package/dist/core/icons/list.js +10 -7
  143. package/dist/core/icons/list.js.map +2 -2
  144. package/dist/core/media/image.d.ts +1 -1
  145. package/dist/core/media/image.js.map +2 -2
  146. package/dist/core/ui/button.d.ts +2 -2
  147. package/dist/core/ui/disclosure.d.ts +32 -9
  148. package/dist/core/ui/disclosure.js +316 -147
  149. package/dist/core/ui/disclosure.js.map +3 -3
  150. package/dist/core/ui/record-selection.d.ts +8 -0
  151. package/dist/core/ui/record-selection.js +172 -0
  152. package/dist/core/ui/record-selection.js.map +7 -0
  153. package/dist/core/ui/sheet.d.ts +1 -1
  154. package/dist/core/ui/slider.d.ts +3 -4
  155. package/dist/core/ui/slider.js +8 -5
  156. package/dist/core/ui/slider.js.map +2 -2
  157. package/dist/editor/list-icons.d.ts +7 -1
  158. package/dist/editor/list-icons.js +101 -39
  159. package/dist/editor/list-icons.js.map +2 -2
  160. package/dist/index.d.ts +3 -2
  161. package/dist/index.js +7 -3
  162. package/dist/index.js.map +2 -2
  163. package/dist/modules/booking/frontend/validation.d.ts +1 -1
  164. package/dist/modules/collections/blocks/review/component.d.ts +2 -0
  165. package/dist/modules/collections/blocks/review/component.js +14 -0
  166. package/dist/modules/collections/blocks/review/component.js.map +7 -0
  167. package/dist/modules/collections/blocks/review/editor.d.ts +1 -0
  168. package/dist/modules/collections/blocks/review/editor.js +11 -0
  169. package/dist/modules/collections/blocks/review/editor.js.map +7 -0
  170. package/dist/modules/collections/blocks/review/register.php +2 -0
  171. package/dist/modules/collections/blocks/review/schema.d.ts +7 -0
  172. package/dist/modules/collections/blocks/review/schema.js +14 -0
  173. package/dist/modules/collections/blocks/review/schema.js.map +7 -0
  174. package/dist/modules/collections/manifest.json +5 -0
  175. package/dist/modules/forms/blocks/builder/component.d.ts +1 -0
  176. package/dist/modules/forms/blocks/builder/component.js +30 -0
  177. package/dist/modules/forms/blocks/builder/component.js.map +7 -0
  178. package/dist/modules/forms/blocks/builder/editor.d.ts +1 -0
  179. package/dist/modules/forms/blocks/builder/editor.js +28 -0
  180. package/dist/modules/forms/blocks/builder/editor.js.map +7 -0
  181. package/dist/modules/forms/blocks/builder/register.php +2 -0
  182. package/dist/modules/forms/blocks/builder/schema.d.ts +7 -0
  183. package/dist/modules/forms/blocks/builder/schema.js +49 -0
  184. package/dist/modules/forms/blocks/builder/schema.js.map +7 -0
  185. package/dist/modules/forms/frontend/component.d.ts +3 -1
  186. package/dist/modules/forms/frontend/component.js +5 -3
  187. package/dist/modules/forms/frontend/component.js.map +2 -2
  188. package/dist/shared/index.d.ts +4 -8
  189. package/dist/shared/index.js +3 -3
  190. package/dist/shared/index.js.map +2 -2
  191. package/dist/tooling/block-paths.mjs +8 -0
  192. package/dist/tooling/build-doc-props.mjs +34 -0
  193. package/dist/tooling/build-editor.mjs +9 -4
  194. package/dist/tooling/build-wordpress.mjs +10 -4
  195. package/dist/tooling/cli.mjs +66 -23
  196. package/dist/tooling/create-component.mjs +31 -0
  197. package/dist/tooling/create-module.mjs +7 -1
  198. package/dist/tooling/create-post-type.mjs +156 -100
  199. package/dist/tooling/create-section.mjs +45 -12
  200. package/dist/tooling/post-type-wizard.mjs +61 -0
  201. package/dist/tooling/prepare-project.mjs +2 -1
  202. package/dist/tooling/section-styles.mjs +121 -0
  203. package/dist/tooling/sync-blocks.mjs +15 -5
  204. package/dist/tooling/sync-kit.mjs +2 -0
  205. package/dist/tooling/sync-sections.mjs +4 -3
  206. package/dist/wordpress/api/content.php +1 -1
  207. package/dist/wordpress/post-types/collections.php +14 -4
  208. package/dist/wordpress/rendering/bootstrap.php +3 -0
  209. package/dist/wordpress/rendering/section-styles.php +50 -0
  210. package/editor/list-icons.tsx +84 -74
  211. package/index.tsx +3 -2
  212. package/modules/collections/blocks/review/component.tsx +7 -0
  213. package/modules/collections/blocks/review/editor.tsx +8 -0
  214. package/modules/collections/blocks/review/register.php +2 -0
  215. package/modules/collections/blocks/review/schema.ts +20 -0
  216. package/modules/collections/manifest.json +5 -0
  217. package/modules/forms/blocks/builder/component.tsx +29 -0
  218. package/modules/forms/blocks/builder/editor.tsx +23 -0
  219. package/modules/forms/blocks/builder/register.php +2 -0
  220. package/modules/forms/blocks/builder/schema.ts +61 -0
  221. package/modules/forms/frontend/component.tsx +7 -3
  222. package/package.json +2 -1
  223. package/shared/index.tsx +6 -10
  224. package/tooling/block-paths.mjs +8 -0
  225. package/tooling/build-doc-props.mjs +34 -0
  226. package/tooling/build-editor.mjs +9 -4
  227. package/tooling/build-wordpress.mjs +10 -4
  228. package/tooling/cli.mjs +66 -23
  229. package/tooling/create-component.mjs +31 -0
  230. package/tooling/create-module.mjs +7 -1
  231. package/tooling/create-post-type.mjs +156 -100
  232. package/tooling/create-section.mjs +45 -12
  233. package/tooling/post-type-wizard.mjs +61 -0
  234. package/tooling/prepare-project.mjs +2 -1
  235. package/tooling/section-styles.mjs +121 -0
  236. package/tooling/sync-blocks.mjs +15 -5
  237. package/tooling/sync-kit.mjs +2 -0
  238. package/tooling/sync-sections.mjs +4 -3
  239. package/wordpress/api/content.php +1 -1
  240. package/wordpress/post-types/collections.php +14 -4
  241. package/wordpress/rendering/bootstrap.php +3 -0
  242. package/wordpress/rendering/section-styles.php +50 -0
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # soinproduction-gutenberg
2
2
 
3
+ [Справочник компонентов](https://soinproduction.github.io/soinproduction-gutenberg/) · [Паттерн компонентов](docs/PATTERN.md)
4
+
5
+
3
6
  Portable React / WordPress components with their field engine, editors, PHP rendering, administration UI and module assets.
4
7
 
5
8
  ```sh
@@ -86,3 +89,72 @@ Use the installed `soinproduction-kit` binary in npm scripts:
86
89
  `dev` and `start` select a free port automatically. Explicit `--port`/`-p` or `PORT` take precedence. Development propagates the actual origin to site/forms configuration and writes `build/next-server.json`; the Next PHP adapter loaded by `bootstrap.php` reads it for local frontend URLs. Public deployment URLs stay configured. Override the project-relative runtime path with `runtime.file` in `kit.config.json`.
87
90
 
88
91
  Generators prepare the installed kit automatically, then create the component schema, renderer, editor, PHP registration, styles and preview in the project. `new section` creates a declarative section. Use `--no-build` to generate without an editor build. `render` regenerates module markup from its schema. All commands accept `--project PATH`. The project owns component/section selection and optional `adapters.contentRenderer` / `adapters.editorAdapter` objects (`from`, `export`); portable defaults are provided. Preparation reuses unchanged package sources and refreshes generated connections without disturbing a running Next watcher.
92
+
93
+ ## Кастомные типы записей
94
+
95
+ Выполните команду из корня темы или из её папки `frontend`.
96
+
97
+ ```sh
98
+ npx soinproduction-kit create post-type case_study
99
+ ```
100
+
101
+ В терминале команда задаст вопросы о формате, названиях, публичности, архиве,
102
+ адресе, таксономиях и блоке карточки. Enter принимает предложенное значение.
103
+ Файлы записываются после подтверждения. Для автоматизации передайте параметры
104
+ флагами или добавьте `--no-interactive`, чтобы применить значения по умолчанию.
105
+
106
+ ```sh
107
+ npx soinproduction-kit create post-type case_study --collection \
108
+ --label "Кейс" --plural-label "Кейсы" --taxonomies category,post_tag
109
+ ```
110
+
111
+ Kit создаёт `inc/post-types/case_study.php`, подключает его в `inc/bootstrap.php`
112
+ и добавляет тип в `frontend/kit.config.json`. Для коллекции Kit создаёт блок
113
+ `site/case-study-card` с описанием и изображением и фиксирует его в шаблоне записи.
114
+ `--block site/study-card` задаёт другое имя. Если такой блок уже существует в теме,
115
+ Kit использует его. После генерации пересоберите редактор обычной командой проекта
116
+ (`npm run build:editor` из `frontend` в Complex Studio).
117
+
118
+ ```tsx
119
+ import { Records, RecordImage, RecordText, RecordTitle } from '@kit';
120
+
121
+ <Records name="caseStudies" type="case_study">
122
+ <article>
123
+ <RecordImage />
124
+ <RecordTitle />
125
+ <RecordText field="description" />
126
+ </article>
127
+ </Records>
128
+ ```
129
+
130
+ - `--public` и `--private` управляют отдельными страницами записей. Тип с `--collection` по умолчанию не имеет отдельных страниц, обычный тип публичен. Опубликованные записи обоих типов доступны в публичных данных Kit для вывода через `Records`.
131
+ - `--archive` включает архив публичного типа, `--rewrite case-studies` задаёт часть URL. После добавления или изменения публичного маршрута обновите правила постоянных ссылок в WordPress.
132
+ - `--taxonomies category,post_tag` привязывает существующие таксономии. Собственные таксономии и их параметры регистрируются через `register_taxonomy()`.
133
+ - `--label` и `--plural-label` задают названия в админке. Иконку, набор полей WordPress, полный набор лейблов и прочие параметры можно изменить в сгенерированном PHP.
134
+
135
+
136
+ Project scaffolding: create/new component writes only src/components/NAME/component.tsx; create/new section writes src/sections/section-NAME with declarative Kit fields and Tailwind markup, without Drag/Cols wrappers by default. Both commands accept a frontend or theme root. Explicit --schema retains legacy generators. No project sections or content are bundled.
137
+
138
+ ### Heading tag and appearance
139
+
140
+ `Heading` keeps the HTML tag separate from its visual class. The tag accepts `h1`–`h6`, `p` and
141
+ `span`; the visual class accepts `h1`–`h6`. The editor exposes independent **HTML tag** and **Heading style** button groups.
142
+ Each group supports arrow keys, Home/End and resetting to its section default.
143
+
144
+ ```tsx
145
+ <Heading name="title" label="Title" tag="h3" textStyle="h1" />
146
+ ```
147
+
148
+ This renders `<h3 class="h1">…</h3>`. Projects define the `.h1`–`.h6` typography in
149
+ their own theme tokens and Tailwind utilities. `level` remains supported, and
150
+ headings without `textStyle` retain their existing section classes. Editor choices
151
+ are saved separately under `__headings[fieldName]`; the text field stays a string.
152
+ The portable PHP renderer resolves the same tag, class and defaults as React.
153
+
154
+ ### Isolated section styles
155
+
156
+ Set `"sectionStyles": "isolated"` in `kit.config.json` to compile each section's `styles.css` into a hashed asset. Preparation emits `src/sections/styles.manifest.generated.json` and `public/kit/sections/`. Keep those public assets available alongside a deployed Next build. The shared stylesheet retains theme declarations; selectors and keyframes load per rendered section. Existing projects retain global imports unless they opt in.
157
+
158
+ The existing `Section` root receives `data-site-section="site/slug"`. Compiled selectors are guarded by that owner without increasing specificity; keyframe names are unique to the section. Document state ancestors such as `html[data-motion]` still work. Keep reset rules, fonts and global custom properties in the shared entry. Use unique names for section `@theme` tokens; global directives such as `@font-face`, `@property`, `@utility` and `@apply` are rejected inside isolated section styles.
159
+
160
+ In a custom React block renderer, look up the actual block name in the generated manifest and render `<link rel="stylesheet" href={asset.href} precedence="site-sections" />` beside its View. React hoists and deduplicates the stylesheet and waits for it before revealing the section. For WordPress browser islands use `site.runtime.sectionStyleBase + asset.file` when that base is supplied. Do not import every section stylesheet from a registry. Gutenberg receives all isolated section styles so newly inserted sections work immediately; the WordPress build copies the assets and enqueues only section names found in the current page and its layout slots, including synced blocks.
@@ -1,7 +1,7 @@
1
1
  <?php
2
2
  /** Public compiled assets only; no WordPress bootstrap or source-file access. */
3
3
  $asset = ltrim( $_SERVER['PATH_INFO'] ?? '', '/' );
4
- if ( ! preg_match( '~^(?:runtime\.js|site\.css|chunks/[A-Za-z0-9_-]+\.js|images/[A-Za-z0-9_-]+\.png)$~D', $asset ) ) {
4
+ if ( ! preg_match( '~^(?:runtime\.js|site\.css|chunks/[A-Za-z0-9_-]+\.js|images/[A-Za-z0-9_-]+\.png|sections/[a-z0-9-]+\.css|sections/assets/[a-f0-9]{12}\.(?:png|jpe?g|webp|avif|gif|svg|woff2?))$~D', $asset ) ) {
5
5
  http_response_code( 404 );
6
6
  exit;
7
7
  }
@@ -14,13 +14,14 @@
14
14
  $etag = '"' . filemtime( $file ) . '-' . filesize( $file ) . ( $gzip ? '-gzip' : '' ) . '"';
15
15
  header( 'ETag: ' . $etag );
16
16
  header( 'Vary: Accept-Encoding' );
17
- header( 'Cache-Control: public, max-age=' . ( str_starts_with( $asset, 'chunks/' ) ? '31536000, immutable' : '3600' ) );
17
+ header( 'Cache-Control: public, max-age=' . ( (str_starts_with( $asset, 'chunks/' ) || str_starts_with($asset, 'sections/')) ? '31536000, immutable' : '3600' ) );
18
18
  header( 'X-Content-Type-Options: nosniff' );
19
19
  if ( ( $_SERVER['HTTP_IF_NONE_MATCH'] ?? '' ) === $etag ) {
20
20
  http_response_code( 304 );
21
21
  exit;
22
22
  }
23
- header( 'Content-Type: ' . ( str_ends_with( $asset, '.js' ) ? 'application/javascript; charset=UTF-8' : ( str_ends_with( $asset, '.css' ) ? 'text/css; charset=UTF-8' : 'image/png' ) ) );
23
+ $types = ['js'=>'application/javascript; charset=UTF-8','css'=>'text/css; charset=UTF-8','png'=>'image/png','jpg'=>'image/jpeg','jpeg'=>'image/jpeg','gif'=>'image/gif','svg'=>'image/svg+xml','webp'=>'image/webp','avif'=>'image/avif','woff'=>'font/woff','woff2'=>'font/woff2'];
24
+ header('Content-Type: ' . $types[pathinfo($asset, PATHINFO_EXTENSION)]);
24
25
  if ( $gzip ) {
25
26
  header( 'Content-Encoding: gzip' );
26
27
  $file .= '.gz';
@@ -4,11 +4,11 @@ const marker = (name: string) => Object.assign((_props: any) => null, {kitName:
4
4
  export const Section = marker('Section'), Text = marker('Text'), Heading = marker('Heading'),
5
5
  Paragraphs = marker('Paragraphs'), Image = marker('Image'), Icon = marker('Icon'),
6
6
  Background = marker('Background'), Buttons = marker('Buttons'), SocialLinks = marker('SocialLinks'), Button = marker('Button'), List = marker('List'),
7
- PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),
7
+ PricingPlans = marker('PricingPlans'), ReviewsCarousel = marker('ReviewsCarousel'), Form = marker('Form'), Records = marker('Records'), Categories = marker('Categories'), RecordEdit = marker('RecordEdit'), RecordImage = marker('RecordImage'),
8
8
  RecordDate = marker('RecordDate'), RecordTitle = marker('RecordTitle'), RecordExcerpt = marker('RecordExcerpt'), RecordLink = marker('RecordLink'),
9
9
  RecordIndex = marker('RecordIndex'), Drag = marker('Drag'), Cols = marker('Cols'), Toggle = marker('Toggle'),
10
10
  Choice = marker('Choice'), Show = marker('Show'), Area = marker('Area'), Gallery = marker('Gallery'),
11
- Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'),
11
+ Accordion = marker('Accordion'), AccordionItem = marker('AccordionItem'), AccordionTrigger = marker('AccordionTrigger'), AccordionContent = marker('AccordionContent'), AccordionProgress = marker('AccordionProgress'),
12
12
  Slider = marker('Slider'), SliderButton = marker('SliderButton'), SliderPagination = marker('SliderPagination'), RecordText = marker('RecordText'), RecordContent = marker('RecordContent'), Media = marker('Media');
13
13
 
14
14
  function describe(node: ReactNode): any[] {
@@ -18,7 +18,10 @@ function describe(node: ReactNode): any[] {
18
18
  const props = {...child.props as any};
19
19
  delete props.children;
20
20
  const type = typeof child.type === 'string' ? child.type : (child.type as any).kitName;
21
- if (!type) throw new Error('WordPress compiler: unsupported React component. Supply an adapter before using it in a portable section.');
21
+ // Stateful project components mount through the existing browser island.
22
+ // Preserve declarative children as the PHP fallback, without serializing callback props.
23
+ if (!type) return [{type: 'ClientComponent', props: {}, children: describe((child.props as any).children)}];
24
+ if (type === 'Categories' && props.tab !== undefined) props.tab = describe(props.tab);
22
25
  for (const [key, value] of Object.entries(props)) if (typeof value === 'function') throw new Error(`WordPress compiler: callback ${key} cannot be serialized`);
23
26
  return [{type, props, children: describe((child.props as any).children)}];
24
27
  });
@@ -26,6 +29,7 @@ function describe(node: ReactNode): any[] {
26
29
 
27
30
  export function section(meta: any, View: () => ReactNode) {
28
31
  const template = describe(View());
32
+ const mark=(nodes:any[])=>{for(const node of nodes){if(node.type==='Section')node.props['data-site-section']='site/'+meta.slug;mark(node.children??[]);}};mark(template);
29
33
  const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);
30
34
  const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
31
35
  return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};
@@ -18,6 +18,35 @@ function tag(string $name,array $attributes,string $content=''): string {
18
18
  if(!preg_match('/^[a-z][a-z0-9-]*$/',$name)||in_array($name,['script','iframe','style'],true))return '';
19
19
  return '<'.$name.attrs($attributes).'>'.(in_array($name,['img','source','br','hr','input'],true)?'':$content.'</'.$name.'>');
20
20
  }
21
+ function classed_content(string $class,string $html): string {return $class?tag('div',['class'=>$class],$html):$html;}
22
+ /** Resolve collection rows once for both rendering and category badges. */
23
+ function relationship_rows($value,array $props,array $site,array $data,?array $category=null,bool $taxonomy=false): array {
24
+ $library=$taxonomy?($site['taxonomies'][$props['taxonomy']??'category']??[]):($site[($props['type']??'post').'s']??[]);
25
+ if($taxonomy)$library=array_map(fn($term)=>array_replace($term,['title'=>$term['title']??$term['name']??'','excerpt'=>$term['excerpt']??$term['description']??'','url'=>$term['url']??'']),$library);
26
+ if(!$taxonomy&&!empty($props['fromCategory'])&&$category){
27
+ $library=!empty($category['manual'])?[]:array_values(array_filter($library,fn($row)=>in_array((int)$category['id'],array_map('intval',(array)($row[$category['taxonomy']]??[])),true)));
28
+ }
29
+ $rows=[];$seen=[];
30
+ foreach(is_array($value)?$value:[] as $item){
31
+ if(is_array($item)){if(!empty($item['manual']))$rows[]=$item;continue;}
32
+ $id=(int)$item;if(isset($seen[$id]))continue;$seen[$id]=true;
33
+ foreach($library as $row)if((int)$row['id']===$id){$rows[]=$row;break;}
34
+ }
35
+ if(!empty($props['latest'])&&empty($category['manual'])&&($data[$props['modeField']??'']??'latest')!=='manual'){
36
+ $rows=$library;usort($rows,fn($a,$b)=>(strtotime($b['publishedAt']??$b['date']??'')<=>strtotime($a['publishedAt']??$a['date']??''))?:((int)($b['id']??0)<=>(int)($a['id']??0)));
37
+ $rows=array_slice($rows,0,max(0,(int)$props['latest']));
38
+ }
39
+ return $rows;
40
+ }
41
+ /** A countField references a child Records declaration, including inside layout elements. */
42
+ function category_count_template(array $children,string $name): ?array {
43
+ foreach($children as $child){
44
+ if(($child['type']??'')==='Records'&&($child['props']['name']??'')===$name)return $child['props'];
45
+ if(($child['type']??'')==='Categories')continue;
46
+ $found=category_count_template($child['children']??[],$name);if($found)return $found;
47
+ }
48
+ return null;
49
+ }
21
50
  function nodes(array $nodes,array $context): string {return implode('',array_map(fn($node)=>node($node,$context),$nodes));}
22
51
  function image($value,string $class=''): string {
23
52
  if(is_string($value))$value=['url'=>$value];$url=$value['url']??'';
@@ -29,7 +58,7 @@ function background_poster(string $url): string {
29
58
  $id=attachment_url_to_postid($url);
30
59
  return $id?(wp_get_attachment_image_url($id,'large')?:$url):$url;
31
60
  }
32
- function button(array $value,?string $fallback=null,array $site=[]): string {
61
+ function button(array $value,?string $fallback=null,array $site=[],string $extra_class=''): string {
33
62
  if(empty($value['text']))return '';
34
63
  $url=$value['url']??'#';$id=(int)($value['modalId']??0);
35
64
  if($id)foreach($site['modals']??[] as $modal)if($modal['id']===$id)$url='#modal-'.($modal['slug']??$id);
@@ -41,7 +70,7 @@ function button(array $value,?string $fallback=null,array $site=[]): string {
41
70
  $mask='url("data:image/svg+xml,'.rawurlencode($icon['svg']).'")';
42
71
  $label=tag('span',['class'=>'site-button-label site-button-icon-'.(($metadata['siteButtonIconPosition']??'')==='before'?'before':'after'),'style'=>'--site-button-icon:'.$mask],$label);break;
43
72
  }
44
- return tag('a',['href'=>esc_url($url),'class'=>$class,'data-modal-plan'=>$value['plan']??null],$label);
73
+ return tag('a',['href'=>esc_url($url),'class'=>trim($class.' '.$extra_class),'data-modal-plan'=>$value['plan']??null],$label);
45
74
  }
46
75
  function social_links(array $links, string $class = '', string $style = 'text'): string {
47
76
  $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
@@ -95,21 +124,38 @@ function holds_elements(array $block): bool {
95
124
  foreach($block['innerBlocks']??[] as $child)if(!str_starts_with($child['name']??'','core/')||holds_elements($child))return true;
96
125
  return false;
97
126
  }
98
- /** Library icons as list markers: one for the list, one per top-level item over it. */
127
+ /** Native list presentation is metadata, preserving the saved HTML and existing styles. */
128
+ function list_presentation(\WP_HTML_Tag_Processor $processor,array $metadata,array $site,bool $list): void {
129
+ $styles=[];
130
+ if($mask=icon_mask($metadata['siteListIcon']??null,$site)){
131
+ $processor->add_class($list?'site-icon-list':'site-icon-item');$styles[]='--site-list-icon:'.$mask;
132
+ }
133
+ $color=$metadata['siteListIconColor']??null;
134
+ if(is_string($color)&&preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D',$color))$styles[]='--site-list-icon-color:var(--wp--preset--color--'.$color.')';
135
+ if($list&&in_array($metadata['siteListColumns']??null,[2,3],true))$processor->add_class('site-list-columns-'.$metadata['siteListColumns']);
136
+ if($styles)$processor->set_attribute('style',rtrim($processor->get_attribute('style')??'',';').';'.implode(';',$styles));
137
+ }
138
+ /** Walk nested list metadata alongside the existing UL/OL/LI tree. */
99
139
  function list_icons(string $html,array $block,array $site): string {
100
- $processor=new \WP_HTML_Tag_Processor($html);$depth=0;$index=0;
101
- $items=array_values(array_filter($block['innerBlocks']??[],fn($child)=>($child['name']??'')==='core/list-item'));
140
+ $processor=new \WP_HTML_Tag_Processor($html);$stack=[];
102
141
  while($processor->next_tag(['tag_closers'=>'visit'])){
103
142
  $tag=$processor->get_tag();
104
143
  if(in_array($tag,['UL','OL'],true)){
105
- if($processor->is_tag_closer()){$depth--;continue;}
106
- $depth++;
107
- if($depth===1&&($mask=icon_mask($block['attrs']['metadata']['siteListIcon']??null,$site))){$processor->add_class('site-icon-list');$processor->set_attribute('style','--site-list-icon:'.$mask);}
108
- continue;
144
+ if($processor->is_tag_closer()){array_pop($stack);continue;}
145
+ if(!$stack)$current=$block;
146
+ else{
147
+ $parent=&$stack[count($stack)-1];
148
+ $nested=array_values(array_filter($parent['item']['innerBlocks']??[],fn($child)=>($child['name']??'')==='core/list'));
149
+ $current=$nested[$parent['nested']++]??[];unset($parent);
150
+ }
151
+ $stack[]=['block'=>$current,'index'=>0,'item'=>[],'nested'=>0];
152
+ list_presentation($processor,$current['attrs']['metadata']??[],$site,true);continue;
109
153
  }
110
- if($tag!=='LI'||$processor->is_tag_closer()||$depth!==1)continue;
111
- $mask=icon_mask($items[$index++]['attrs']['metadata']['siteListIcon']??null,$site);
112
- if($mask){$processor->add_class('site-icon-item');$processor->set_attribute('style','--site-list-icon:'.$mask);}
154
+ if($tag!=='LI'||$processor->is_tag_closer()||!$stack)continue;
155
+ $frame=&$stack[count($stack)-1];
156
+ $items=array_values(array_filter($frame['block']['innerBlocks']??[],fn($child)=>($child['name']??'')==='core/list-item'));
157
+ $frame['item']=$items[$frame['index']++]??[];$frame['nested']=0;
158
+ list_presentation($processor,$frame['item']['attrs']['metadata']??[],$site,false);unset($frame);
113
159
  }
114
160
  return $processor->get_updated_html();
115
161
  }
@@ -149,31 +195,39 @@ function collection(array $rows,array $props,array $context,callable $render): s
149
195
  function node(array $node,array $context): string {
150
196
  $type=$node['type'];$p=$node['props']??[];$children=$node['children']??[];$data=$context['data']??[];$site=$context['site']??[];$record=$context['record']??[];
151
197
  $value=$data[$p['name']??'']??null;$class=classes($p);
198
+ if($type==='ClientComponent')return nodes($children,$context);
152
199
  if($type==='#text')return esc_html($node['value']);
153
- if(ctype_lower(substr($type,0,1))){$attributes=$p;unset($attributes['children'],$attributes['className'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
200
+ if(ctype_lower(substr($type,0,1))){$attributes=$p;unset($attributes['children'],$attributes['className'],$attributes['adminClassName'],$attributes['frontClassName'],$attributes['initial']);if($class)$attributes['class']=$class;return tag($type,$attributes,nodes($children,$context));}
154
201
  switch($type){
155
- case 'Accordion':return tag('div',['class'=>$class,'data-disclosure-mode'=>'accordion','data-icon-position'=>$p['iconPosition']??'after'],tag('div',['data-disclosure-items'=>true],nodes($children,array_replace($context,['disclosure'=>$p]))));
156
- case 'AccordionItem':return tag('details',['class'=>$class,'data-disclosure-item'=>true],nodes($children,$context));
202
+ case 'Accordion':return tag('div',['class'=>$class,'data-disclosure-mode'=>$p['mode']??'accordion','data-icon-position'=>$p['iconPosition']??'after'],tag('div',['data-disclosure-items'=>true],nodes($children,array_replace($context,['disclosure'=>$p]))));
203
+ case 'AccordionItem':return tag('details',['class'=>$class,'data-disclosure-item'=>true,'open'=>($context['disclosure']['mode']??'')==='static'],nodes($children,$context));
157
204
  case 'AccordionContent':return tag('div',['class'=>$class,'data-disclosure-content'=>true],nodes($children,$context));
205
+ case 'AccordionProgress':return tag('div',['class'=>$class,'data-disclosure-progress'=>true,'aria-hidden'=>'true','hidden'=>true],tag('span',['class'=>$p['fillClassName']??'','data-disclosure-progress-fill'=>true],''));
158
206
  case 'AccordionTrigger':
159
207
  $settings=$context['disclosure']??[];$icon='';
160
208
  if(!array_key_exists('icon',$settings))$icon='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="m6 9 6 6 6-6"></path></svg>';
161
209
  elseif($settings['icon'])$icon=node(['type'=>'Icon','props'=>['name'=>'indicator']],array_replace($context,['data'=>['indicator'=>$settings['icon']]]));
162
210
  return tag('summary',['class'=>$class],nodes($children,$context).($icon?tag('span',['data-disclosure-icon'=>true],$icon):''));
163
- case 'Section':if(!empty($p['when'])&&empty($data[$p['when']]))return '';return tag('section',['id'=>$data['sectionId']??null,'class'=>$class],nodes($children,$context));
164
- case 'Text':case 'Heading':return tag($type==='Heading'?'h'.($p['level']??2):'p',['class'=>$class],wp_kses_post((string)($value??'')));
211
+ case 'Section':if(!empty($p['when'])&&empty($data[$p['when']]))return '';return tag('section',['id'=>$data['sectionId']??null,'class'=>$class,'data-site-section'=>$p['data-site-section']??null],nodes($children,$context));
212
+ case 'Text':return tag('p',['class'=>$class],wp_kses_post((string)($value??'')));
213
+ case 'Heading':
214
+ $valid_tag=static fn($v)=>is_string($v)&&preg_match('/^(?:h[1-6]|p|span)$/D',$v);$valid_style=static fn($v)=>is_string($v)&&preg_match('/^h[1-6]$/D',$v);$settings=$data['__headings'][$p['name']??'']??[];
215
+ $fallback=$valid_tag($p['tag']??null)?$p['tag']:($valid_style('h'.($p['level']??2))?'h'.($p['level']??2):'h2');
216
+ $heading_tag=$valid_tag($settings['tag']??null)?$settings['tag']:$fallback;
217
+ $heading_style=$valid_style($settings['textStyle']??null)?$settings['textStyle']:($valid_style($p['textStyle']??null)?$p['textStyle']:'');
218
+ return tag($heading_tag,['class'=>trim($heading_style.' '.$class)],wp_kses_post((string)($value??'')));
165
219
  case 'Paragraphs':return tag('div',['class'=>'site-paragraph-flow '.$class],implode('',array_map(fn($v,$i)=>tag('div',['class'=>trim('site-description-row '.(is_array($v)&&($v['style']??'')==='accent-line'?'is-style-studio-accent-line ':'').($i?($p['paragraphClassName']??''):''))],tag('p',[],wp_kses_post(is_array($v)?($v['text']??''):$v))),is_array($value)?$value:[],array_keys(is_array($value)?$value:[]))));
166
220
  case 'Image':return image($value,$class);
167
221
  case 'Icon':
168
222
  if(!$value)return '';$name=is_string($value)?$value:($value['type']??'');
169
223
  foreach($site['icons']??[] as $icon){if(($icon['value']??'')===$name){$mask='url("data:image/svg+xml,'.rawurlencode($icon['svg']).'")';return tag('span',['class'=>trim('inline-flex shrink-0 leading-none text-flame '.$class),'aria-hidden'=>'true'],tag('span',['style'=>'display:inline-block;width:.9em;height:.9em;background-color:currentColor;mask:'.$mask.' center/contain no-repeat;-webkit-mask:'.$mask.' center/contain no-repeat']));}}return '';
170
224
  case 'Choice':case 'RecordEdit':return '';
171
- case 'Toggle':return ($value??($p['default']??false))?nodes($children,$context):'';
225
+ case 'Toggle':return ($value??($p['default']??false))?classed_content($class,nodes($children,$context)):'';
172
226
  case 'Show':
173
- $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?nodes($children,$context):'';
174
- case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
227
+ $visible=is_array($p['when'])?(bool)array_filter($p['when'],fn($key)=>trim(wp_strip_all_tags((string)($data[$key]??'')))!==''):(isset($p['is'])?($data[$p['when']]??null)===$p['is']:!empty($data[$p['when']]));return $visible?classed_content($class,nodes($children,$context)):'';
228
+ case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site,$class);
175
229
  case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
176
- case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>$class],$html);
230
+ case 'Buttons':$html='';foreach(is_array($value)?$value:[] as $i=>$button)$html.=button($button,$p['styles'][$i]??null,$site);return tag('div',['class'=>'site-actions '.($class?:'flex flex-wrap gap-3')],$html);
177
231
  case 'Background':case 'Media':
178
232
  if(!$value)return '';if(is_string($value)||($value['type']??'image')==='image')return image(is_string($value)?$value:['url'=>$value['image']??$value['url']??'','alt'=>$value['alt']??''],$class?:'absolute inset-0 h-full w-full object-cover');
179
233
  return tag('video',['class'=>$class?:'absolute inset-0 h-full w-full object-cover','poster'=>esc_url(background_poster($value['poster']??'')),'src'=>esc_url($value['video']??$value['mp4']??''),'muted'=>$value['muted']??true,'preload'=>'none','data-site-background'=>'true','data-autoplay'=>($value['autoplay']??true)?'true':'false','autoplay'=>false,'loop'=>$value['loop']??true,'playsinline'=>true,'controls'=>$value['controls']??false]);
@@ -191,24 +245,50 @@ function node(array $node,array $context): string {
191
245
  $direction=($p['direction']??'next')==='previous'?'previous':'next';
192
246
  return tag('button',['type'=>'button','class'=>$class,'data-slider-for'=>$p['slider']??'','data-slider-button'=>$direction,'aria-label'=>$p['label']??($direction==='previous'?'Previous slide':'Next slide'),'disabled'=>true],$children?nodes($children,$context):($direction==='previous'?'←':'→'));
193
247
  case 'SliderPagination':return tag('div',['class'=>$class,'data-slider-for'=>$p['slider']??'','data-slider-pagination'=>'','data-slider-page-class'=>$p['buttonClassName']??'','data-slider-page-label'=>$p['pageLabel']??'Slide','role'=>'group','aria-label'=>$p['label']??'Slider pages'],'');
194
- case 'RecordContent':return native_blocks(is_array($record[$p['field']??'']??null)?$record[$p['field']]:[],$context);
248
+ case 'RecordContent':$blocks=$record[$p['field']??'']??[];return is_array($blocks)&&$blocks?classed_content($class,native_blocks($blocks,$context)):'';
195
249
  case 'RecordText':$text=$record[$p['field']??'']??'';return $text?tag(in_array($p['as']??'p',['p','span','div','blockquote'],true)?($p['as']??'p'):'p',['class'=>$class],wp_kses_post((string)$text)):'';
196
250
  case 'Gallery':$html='';foreach(is_array($value)?$value:[] as $row)$html.=image($row,'w-full h-full object-cover');return tag('div',['class'=>$class],$html);
197
251
  case 'PricingPlans':return pricing_plans(is_array($value)?$value:null,$site,$class);
198
252
  // The form is interactive and mounts in the browser.
199
253
  case 'Form':return tag('div',['class'=>$class],'');
200
254
  case 'ReviewsCarousel':return reviews_carousel(is_array($value)?$value:null,$site,$class);
201
- case 'Records':
202
- $library=$site[($p['type']??'post').'s']??[];$rows=[];
203
- foreach(is_array($value)?$value:[] as $item){if(is_array($item)&&!empty($item['manual'])){$rows[]=$item;continue;}$id=is_array($item)?($item['id']??0):$item;foreach($library as $r)if((string)$r['id']===(string)$id)$rows[]=$r;}
204
- if(!empty($p['latest'])&&($data[$p['modeField']??'']??'latest')!=='manual'){$rows=$library;usort($rows,fn($a,$b)=>(strtotime($b['publishedAt']??$b['date']??'')<=>strtotime($a['publishedAt']??$a['date']??''))?:((int)($b['id']??0)<=>(int)($a['id']??0)));$rows=array_slice($rows,0,max(0,(int)$p['latest']));}
255
+ case 'Categories':case 'Records':
256
+ $rows=relationship_rows($value,$p,$site,$data,$context['category']??null,$type==='Categories');
257
+ if($type==='Categories'&&($p['mode']??'list')==='tabs'){
258
+ $html='';$panels='';$id=wp_unique_id('categories-');$nested=array_key_exists('tab',$p);$count_template=!empty($p['countField'])?category_count_template($children,$p['countField']):null;
259
+ foreach($rows as $i=>$row){
260
+ $category=array_replace($row,['taxonomy'=>$p['taxonomy']??'category']);
261
+ $key=!empty($row['manual'])?'manual:'.$row['id']:'term:'.$category['taxonomy'].':'.$row['id'];
262
+ $content=$data[($p['name']??'').'Content'][$key]??[];
263
+ $count=$count_template?tag('span',['class'=>$p['countClassName']??''],(string)count(relationship_rows($content[$p['countField']]??[],$count_template,$site,$content,$category))):'';
264
+ $html.=tag('button',['type'=>'button','role'=>'tab','id'=>$id.'-tab-'.$i,'aria-controls'=>$nested?$id.'-panel-'.$i:null,'class'=>$p['itemClassName']??'','data-category-index'=>$i,'aria-selected'=>$i===0?'true':'false','tabindex'=>$i===0?0:-1],nodes($nested?$p['tab']:$children,array_replace($context,['record'=>$row,'index'=>$i])).$count);
265
+ if($nested){
266
+ $panels.=tag('div',['role'=>'tabpanel','id'=>$id.'-panel-'.$i,'aria-labelledby'=>$id.'-tab-'.$i,'hidden'=>$i!==0,'class'=>$p['contentClassName']??''],nodes($children,array_replace($context,['data'=>$content,'category'=>$category])));
267
+ }
268
+ }
269
+ $tabs=tag('div',['class'=>$nested?($p['tabsClassName']??''):$class,'role'=>'tablist','aria-label'=>$p['label']??'Categories'],$html);
270
+ return $nested?tag('div',['class'=>$class],$tabs.$panels):$tabs;
271
+ }
205
272
  return collection($rows,$p,$context,fn($row,$i)=>nodes($children,array_replace($context,['record'=>$row,'index'=>$i])));
206
273
  case 'RecordDate':$timestamp=strtotime($record['publishedAt']??$record['date']??'');return $timestamp===false?'':tag('time',['class'=>$class,'datetime'=>gmdate('c',$timestamp)],gmdate('d.m.Y',$timestamp));
207
- case 'RecordTitle':return tag('h3',['class'=>$class],wp_kses_post($record['title']??''));
274
+ case 'RecordTitle':
275
+ $title_settings=array_key_exists('beforeText',$p)||array_key_exists('afterText',$p)?($data['__recordTitles'][$p['name']??'title']??[]):[];
276
+ $before=is_string($title_settings['beforeText']??null)?$title_settings['beforeText']:($p['beforeText']??'');
277
+ $after=is_string($title_settings['afterText']??null)?$title_settings['afterText']:($p['afterText']??'');
278
+ $record_title=!empty($record['manual'])?($record['title']??''):($title_settings['titles'][(string)($record['id']??'')]??$record['title']??'');
279
+ return tag(in_array($p['as']??'h3',['h1','h2','h3','h4','h5','h6','span','p','div'],true)?($p['as']??'h3'):'h3',['class'=>$class],wp_kses_post($title_settings['beforeHtml']??esc_html($before)).wp_kses_post(!empty($context['recordLink'])?preg_replace('~</?a\b[^>]*>~i','',$record_title):$record_title).wp_kses_post($title_settings['afterHtml']??esc_html($after)));
208
280
  case 'RecordExcerpt':return tag('p',['class'=>$class],wp_kses_post($record['excerpt']??''));
209
281
  case 'RecordIndex':return tag('span',['class'=>$class],sprintf('%02d',($context['index']??0)+1));
210
282
  case 'RecordImage':return image(['url'=>$record['image']??'','alt'=>$record['alt']??''],$class);
211
- case 'RecordLink':$url=$record['url']??$record['to']??'';return $url?tag('a',['href'=>esc_url($url),'class'=>$class],nodes($children,$context)):tag('div',['class'=>$class],nodes($children,$context));
283
+ case 'RecordLink':
284
+ $url=$record['url']??$record['to']??'';
285
+ if(!$url&&!empty($record['title'])&&class_exists('WP_HTML_Tag_Processor')){
286
+ $links=new \WP_HTML_Tag_Processor($record['title']);
287
+ while($links->next_tag('A')){if($candidate=esc_url($links->get_attribute('href')??'')){$url=$candidate;break;}}
288
+ }
289
+ $label=nodes($children,array_replace($context,['recordLink'=>true]));
290
+ if(!empty($p['icon']))foreach($site['icons']??[] as $icon)if(($icon['value']??'')===$p['icon']){$label=tag('span',['class'=>'site-button-label site-button-icon-after','style'=>'--site-button-icon:url("data:image/svg+xml,'.rawurlencode($icon['svg']).'")'],$label);break;}
291
+ return $url?tag('a',['href'=>esc_url($url),'class'=>$class],$label):tag('div',['class'=>$class],$label);
212
292
  case 'Area':
213
293
  $html='';foreach(is_array($value)?$value:[] as $item)foreach($children as $child)if(strtolower($child['props']['type']??$child['type'])===($item['type']??'')){$child['props']['name']='value';$html.=node($child,array_replace($context,['data'=>['value'=>$item['value']??null]]));break;}return tag('div',['class'=>$class],$html);
214
294
  case 'Drag':
@@ -629,12 +629,23 @@
629
629
  width: 280px;
630
630
  padding: 8px;
631
631
  }
632
- .site-list-icon-toggle,
633
- .site-list-icon-toggle svg {
632
+ .site-list-icon-toggle {
634
633
  display: block;
634
+ flex: 0 0 20px;
635
635
  width: 20px;
636
636
  height: 20px;
637
- }
637
+ background-color: currentColor;
638
+ mask: center / contain no-repeat;
639
+ }
640
+ .site-list-column-options { display: flex; width: 100%; }
641
+ .site-list-column-options > .components-button { flex: 1; justify-content: center; box-shadow: inset 0 0 0 1px var(--sp-ui-border); }
642
+ .site-list-column-options > .components-button[aria-pressed='true'] { background: var(--wp-admin-theme-color); color: #fff; }
643
+ /* Compact mode only hides native presentation controls; stored attributes and bindings survive. */
644
+ .block-editor-block-inspector:has(.site-native-list-settings.is-compact) :is(
645
+ .typography-block-support-panel, .color-block-support-panel, .background-block-support-panel,
646
+ .border-block-support-panel, .dimensions-block-support-panel, .spacing-block-support-panel, .elements-block-support-panel,
647
+ .block-editor-bindings__panel, .block-editor-block-inspector__advanced
648
+ ) { display: none; }
638
649
  .site-menu-card-body > .site-menu-delete.components-button {
639
650
  margin-top: 16px;
640
651
  }
@@ -757,3 +768,15 @@
757
768
  .site-collection-icon-header .components-button{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:28px;min-width:28px;height:28px;padding:0;color:#1e1e1e;background:#fff;border-radius:2px}
758
769
  .site-collection-icon-header .components-button:hover{background:#f0f0f0;color:var(--wp-admin-theme-color,#3858e9)}
759
770
  .site-collection-icon-header .components-button:focus-visible{outline:2px solid var(--wp-admin-theme-color,#3858e9);outline-offset:1px}
771
+ /* Independent HTML tag and heading style presets. */
772
+ .site-heading-setting{border:0;margin:0 0 calc(var(--sp-ui-space)*2);padding:0;min-width:0}
773
+ .site-heading-setting:last-child{margin-bottom:0}
774
+ .site-heading-setting legend{display:flex;align-items:center;justify-content:space-between;width:100%;margin-bottom:var(--sp-ui-space);padding:0;font-size:11px;font-weight:500;text-transform:uppercase}
775
+ .site-heading-setting legend>.components-button{height:auto;min-height:0;padding:0;font-size:11px;text-transform:none}
776
+ .site-heading-options{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:2px;padding:3px;border:1px solid var(--sp-ui-border);border-radius:var(--sp-ui-radius-control);background:var(--sp-ui-canvas)}
777
+ .site-heading-options>.components-button{display:flex;justify-content:center;min-width:0;height:var(--sp-ui-control-small);padding:0;border-radius:calc(var(--sp-ui-radius-control) - 3px);background:transparent;color:var(--sp-ui-muted);box-shadow:none}
778
+ .site-heading-options>.components-button:hover{background:var(--sp-ui-surface-soft);color:var(--sp-ui-ink)}
779
+ .site-heading-options>.components-button[aria-checked="true"]{background:var(--sp-ui-surface);color:var(--sp-ui-accent);font-weight:600;box-shadow:0 0 0 1px var(--sp-ui-border)}
780
+ .site-heading-options>.components-button:focus-visible{outline:2px solid var(--sp-ui-accent);outline-offset:1px}
781
+
782
+ .site-heading-options.is-tag{grid-template-columns:repeat(4,minmax(0,1fr))}
@@ -9,6 +9,6 @@ import { useClasses } from '../../shared/index.js';
9
9
 
10
10
  /** Modes, motion and indicators are configured in code; only item content is editable. */
11
11
  export function Accordion(props:Props & DisclosureSettings & {children:ReactNode}){
12
- const {mode='accordion',multiple=false,firstOpen=false,duration=240,icon,iconPosition='after',responsive}=props;
13
- return <DisclosureView editor={!!useFieldScope().edit} settings={{mode,multiple,firstOpen,duration,icon,iconPosition,responsive}} breakpoints={BREAKPOINTS} className={useClasses(props)}>{props.children}</DisclosureView>;
12
+ const {mode='accordion',multiple=false,firstOpen=false,duration=240,icon,iconPosition='after',responsive,autoplay,autoplayAbove,hoverPreview,motionStateAttribute}=props;
13
+ return <DisclosureView editor={!!useFieldScope().edit} settings={{mode,multiple,firstOpen,duration,icon,iconPosition,responsive,autoplay,autoplayAbove,hoverPreview,motionStateAttribute}} breakpoints={BREAKPOINTS} className={useClasses(props)}>{props.children}</DisclosureView>;
14
14
  }
@@ -17,7 +17,7 @@ export function ButtonView({ name, className, style }: Props & { name: string; s
17
17
  </span>
18
18
  </span>
19
19
  );
20
- return scope.value?.text ? <SiteButton button={scope.value} fallback={style} /> : null;
20
+ return scope.value?.text ? <SiteButton button={scope.value} fallback={style} className={className} /> : null;
21
21
  }
22
22
 
23
23
  export const Button = kit<Props & { style?: string }>(
@@ -15,16 +15,18 @@ export { buttonClasses } from '../../../core/ui/button-appearance.js';
15
15
  export function ContentButton({
16
16
  attributes,
17
17
  fixedLayout = false,
18
+ className,
18
19
  }: {
19
20
  attributes: any;
20
21
  fixedLayout?: boolean;
22
+ className?: string;
21
23
  }) {
22
24
  const context = useContext(ContentContext);
23
25
  const openModal = useContext(ModalContext);
24
26
  const cardPlan = useContext(BookingPlanContext);
25
27
  const linkedUrl = recordUrl(context.site, attributes.metadata?.siteLinkId);
26
28
  const a = linkedUrl ? {...attributes, url: linkedUrl} : attributes;
27
- const classes = buttonClasses(a.className);
29
+ const classes = [buttonClasses(a.className), className].filter(Boolean).join(' ');
28
30
  const isBooking = String(a.url ?? '').startsWith('/booking');
29
31
  const plan = isBooking
30
32
  ? new URL(a.url, 'http://local').searchParams.get('plan') ?? 'hour'
@@ -50,7 +50,7 @@ export function ButtonsView(props: Props & AddButton & { name: string; styles?:
50
50
  if(scope.edit)return <ButtonsEditor {...props} />;
51
51
  const buttons = Array.isArray(scope.value) ? scope.value : [];
52
52
  return (
53
- <div className={className}>
53
+ <div className={className ? 'site-actions ' + className : 'site-actions flex flex-wrap gap-3'}>
54
54
  {buttons.map((button: any, index: number) => (
55
55
  <SiteButton key={index} button={button} fallback={styles[index]} />
56
56
  ))}
@@ -9,10 +9,11 @@ export const buttonStyle = (button: any, fallback?: string) => {
9
9
  return style ? `is-style-studio-${style}` : undefined;
10
10
  };
11
11
 
12
- export function SiteButton({ button, fallback }: { button: any; fallback?: string }) {
12
+ export function SiteButton({ button, fallback, className }: { button: any; fallback?: string; className?: string }) {
13
13
  return (
14
14
  <ContentButton
15
15
  fixedLayout
16
+ className={className}
16
17
  attributes={{
17
18
  text: button.text,
18
19
  url: button.url,
@@ -0,0 +1,47 @@
1
+ # Categories
2
+
3
+ A taxonomy relationship using the same selection and ordering controls as Records. It stores term IDs; `manual` also allows local items with an editable title. Manual tabs do not create WordPress terms. The host supplies terms through `site.taxonomies[taxonomy]` (`id`, `title` or `name`, optional `description`, `count`, `slug`, `url`).
4
+
5
+ ```tsx
6
+ <Accordion mode="tabs" firstOpen icon="">
7
+ <Categories name="categories" taxonomy="category" manual className="contents">
8
+ <AccordionItem>
9
+ <AccordionTrigger><RecordTitle as="span" /></AccordionTrigger>
10
+ <AccordionContent />
11
+ </AccordionItem>
12
+ </Categories>
13
+ </Accordion>
14
+ ```
15
+
16
+ Children are the shared markup of one category or manual tab. Categories provides data and editing; Accordion provides tab behavior. Titles of linked categories follow the taxonomy. Manual titles are edited inline. This first element does not select or render posts inside a category.
17
+
18
+ ## A single row of tabs
19
+
20
+ ```tsx
21
+ <Categories name="categories" taxonomy="category" mode="tabs" manual
22
+ className="inline-flex gap-2"
23
+ itemClassName="rounded-full px-5 py-3 aria-selected:bg-primary">
24
+ <RecordTitle as="span" />
25
+ </Categories>
26
+ ```
27
+
28
+ This mode needs no Accordion or disclosure panels. Manual names are edited directly on their tab. Arrow keys, Home and End move between tabs; editing text retains the arrow keys for caret movement. Post content is outside the scope of this first selector.
29
+
30
+ ## Independent content for each tab
31
+
32
+ Pass the tab-label template through `tab` and place fields in `children`:
33
+
34
+ ```tsx
35
+ <Categories name="topics" taxonomy="category" mode="tabs" manual
36
+ tab={<RecordTitle as="span" />}
37
+ tabsClassName="inline-flex gap-2"
38
+ contentClassName="mt-6">
39
+ <Records name="articles" type="post" fromCategory manual>
40
+ <article><RecordTitle /><RecordExcerpt /><RecordImage /></article>
41
+ </Records>
42
+ </Categories>
43
+ ```
44
+
45
+ Nested fields belong to each term or local tab, not to the section root. Saved IDs and local category objects retain their original shape. Child data is stored separately in `topicsContent`, keyed by `term:<taxonomy>:<id>` or `manual:<id>`. Reordering or renaming tabs preserves their data; removing and re-adding a term restores its selection. No taxonomy or post content is copied into the selection.
46
+
47
+ `Records fromCategory` filters its picker to posts whose taxonomy IDs include the current term. It still permits manual cards when `manual` is set. Within a local tab it forces manual cards and hides the available-post picker. Only the active tab mounts editor controls. The public document contains all panels, with inactive panels hidden. The host controls published/draft visibility in its record collections.