soinproduction-gutenberg 0.1.4 → 0.1.6

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 (283) hide show
  1. package/README.md +64 -0
  2. package/adapters/wordpress/blueprint.ts +8 -5
  3. package/adapters/wordpress/renderer.php +119 -27
  4. package/admin-ui/editor.css +26 -3
  5. package/bootstrap.php +6 -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/show/index.tsx +4 -2
  25. package/components/social-links/index.tsx +30 -0
  26. package/components/social-links/manifest.json +4 -0
  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/blueprint.d.ts +6 -0
  45. package/dist/adapters/wordpress/blueprint.js +7 -3
  46. package/dist/adapters/wordpress/blueprint.js.map +2 -2
  47. package/dist/adapters/wordpress/renderer.php +119 -27
  48. package/dist/admin-ui/editor.css +26 -3
  49. package/dist/bootstrap.php +6 -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/show/index.d.ts +3 -2
  98. package/dist/components/show/index.js +4 -2
  99. package/dist/components/show/index.js.map +2 -2
  100. package/dist/components/slider/index.d.ts +9 -3
  101. package/dist/components/social-links/index.d.ts +6 -0
  102. package/dist/components/social-links/index.js +27 -0
  103. package/dist/components/social-links/index.js.map +7 -0
  104. package/dist/components/social-links/manifest.json +4 -0
  105. package/dist/components/text/index.d.ts +6 -2
  106. package/dist/components/toggle/index.d.ts +3 -2
  107. package/dist/components/toggle/index.js +4 -2
  108. package/dist/components/toggle/index.js.map +2 -2
  109. package/dist/core/editor/manual-record.d.ts +5 -0
  110. package/dist/core/editor/manual-record.js +1 -0
  111. package/dist/core/editor/manual-record.js.map +2 -2
  112. package/dist/core/editor/record-link-format.d.ts +5 -0
  113. package/dist/core/editor/record-link-format.js +39 -0
  114. package/dist/core/editor/record-link-format.js.map +7 -0
  115. package/dist/core/editor/relationship.d.ts +3 -1
  116. package/dist/core/editor/relationship.js +7 -5
  117. package/dist/core/editor/relationship.js.map +2 -2
  118. package/dist/core/fields/category.d.ts +14 -0
  119. package/dist/core/fields/category.js +37 -0
  120. package/dist/core/fields/category.js.map +7 -0
  121. package/dist/core/fields/editor.js +12 -9
  122. package/dist/core/fields/editor.js.map +2 -2
  123. package/dist/core/fields/record-link.d.ts +4 -0
  124. package/dist/core/fields/record-link.js +32 -0
  125. package/dist/core/fields/record-link.js.map +7 -0
  126. package/dist/core/fields/record-title.d.ts +20 -0
  127. package/dist/core/fields/record-title.js +59 -0
  128. package/dist/core/fields/record-title.js.map +7 -0
  129. package/dist/core/fields/records.js +5 -4
  130. package/dist/core/fields/records.js.map +2 -2
  131. package/dist/core/fields/render.d.ts +26 -21
  132. package/dist/core/fields/render.js +98 -29
  133. package/dist/core/fields/render.js.map +2 -2
  134. package/dist/core/fields/schema.d.ts +2 -0
  135. package/dist/core/fields/schema.js +2 -0
  136. package/dist/core/fields/schema.js.map +2 -2
  137. package/dist/core/fields/view-classes.d.ts +6 -0
  138. package/dist/core/fields/view-classes.js +7 -0
  139. package/dist/core/fields/view-classes.js.map +7 -0
  140. package/dist/core/icons/list.d.ts +1 -0
  141. package/dist/core/icons/list.js +10 -7
  142. package/dist/core/icons/list.js.map +2 -2
  143. package/dist/core/media/image.d.ts +1 -1
  144. package/dist/core/media/image.js.map +2 -2
  145. package/dist/core/ui/button.d.ts +2 -2
  146. package/dist/core/ui/disclosure.d.ts +32 -9
  147. package/dist/core/ui/disclosure.js +316 -147
  148. package/dist/core/ui/disclosure.js.map +3 -3
  149. package/dist/core/ui/record-selection.d.ts +8 -0
  150. package/dist/core/ui/record-selection.js +172 -0
  151. package/dist/core/ui/record-selection.js.map +7 -0
  152. package/dist/core/ui/sheet.d.ts +1 -1
  153. package/dist/core/ui/slider.d.ts +3 -4
  154. package/dist/core/ui/slider.js +8 -5
  155. package/dist/core/ui/slider.js.map +2 -2
  156. package/dist/editor/list-icons.d.ts +7 -1
  157. package/dist/editor/list-icons.js +101 -39
  158. package/dist/editor/list-icons.js.map +2 -2
  159. package/dist/index.d.ts +4 -2
  160. package/dist/index.js +9 -3
  161. package/dist/index.js.map +2 -2
  162. package/dist/modules/booking/frontend/validation.d.ts +1 -1
  163. package/dist/modules/collections/blocks/review/component.d.ts +2 -0
  164. package/dist/modules/collections/blocks/review/component.js +14 -0
  165. package/dist/modules/collections/blocks/review/component.js.map +7 -0
  166. package/dist/modules/collections/blocks/review/editor.d.ts +1 -0
  167. package/dist/modules/collections/blocks/review/editor.js +11 -0
  168. package/dist/modules/collections/blocks/review/editor.js.map +7 -0
  169. package/dist/modules/collections/blocks/review/register.php +2 -0
  170. package/dist/modules/collections/blocks/review/schema.d.ts +7 -0
  171. package/dist/modules/collections/blocks/review/schema.js +14 -0
  172. package/dist/modules/collections/blocks/review/schema.js.map +7 -0
  173. package/dist/modules/collections/manifest.json +5 -0
  174. package/dist/modules/forms/blocks/builder/component.d.ts +1 -0
  175. package/dist/modules/forms/blocks/builder/component.js +30 -0
  176. package/dist/modules/forms/blocks/builder/component.js.map +7 -0
  177. package/dist/modules/forms/blocks/builder/editor.d.ts +1 -0
  178. package/dist/modules/forms/blocks/builder/editor.js +28 -0
  179. package/dist/modules/forms/blocks/builder/editor.js.map +7 -0
  180. package/dist/modules/forms/blocks/builder/register.php +2 -0
  181. package/dist/modules/forms/blocks/builder/schema.d.ts +7 -0
  182. package/dist/modules/forms/blocks/builder/schema.js +49 -0
  183. package/dist/modules/forms/blocks/builder/schema.js.map +7 -0
  184. package/dist/modules/forms/frontend/component.d.ts +3 -1
  185. package/dist/modules/forms/frontend/component.js +5 -3
  186. package/dist/modules/forms/frontend/component.js.map +2 -2
  187. package/dist/shared/index.d.ts +4 -8
  188. package/dist/shared/index.js +3 -3
  189. package/dist/shared/index.js.map +2 -2
  190. package/dist/tooling/block-paths.mjs +8 -0
  191. package/dist/tooling/build-doc-props.mjs +34 -0
  192. package/dist/tooling/build-editor.mjs +8 -4
  193. package/dist/tooling/build-package.mjs +1 -1
  194. package/dist/tooling/build-wordpress.mjs +8 -4
  195. package/dist/tooling/cli.mjs +136 -40
  196. package/dist/tooling/create-component.mjs +31 -0
  197. package/dist/tooling/create-module.mjs +8 -3
  198. package/dist/tooling/create-post-type.mjs +172 -0
  199. package/dist/tooling/create-section.mjs +45 -12
  200. package/dist/tooling/init-theme.mjs +183 -0
  201. package/dist/tooling/post-type-wizard.mjs +61 -0
  202. package/dist/tooling/prepare-project.mjs +4 -3
  203. package/dist/tooling/smoke-package.mjs +5 -3
  204. package/dist/tooling/sync-blocks.mjs +15 -5
  205. package/dist/tooling/sync-kit.mjs +2 -0
  206. package/dist/tooling/sync-sections.mjs +2 -2
  207. package/dist/wordpress/admin/appearance.php +24 -0
  208. package/dist/wordpress/api/content.php +122 -0
  209. package/dist/wordpress/api/modals.php +6 -0
  210. package/dist/wordpress/blocks.php +23 -0
  211. package/dist/wordpress/bootstrap.php +26 -0
  212. package/dist/wordpress/breakpoints.php +37 -0
  213. package/dist/wordpress/documents.php +142 -0
  214. package/dist/wordpress/editor.php +69 -0
  215. package/dist/wordpress/examples/post-type.example.php +65 -0
  216. package/dist/wordpress/frontend.php +7 -0
  217. package/dist/wordpress/integrations.php +60 -0
  218. package/dist/wordpress/options/archives.php +40 -0
  219. package/dist/wordpress/patterns.php +19 -0
  220. package/dist/wordpress/post-types/collections.php +87 -0
  221. package/dist/wordpress/post-types/modals.php +91 -0
  222. package/dist/wordpress/post-types/site-parts.php +25 -0
  223. package/dist/wordpress/rendering/bootstrap.php +95 -0
  224. package/dist/wordpress/rendering/performance.php +67 -0
  225. package/dist/wordpress/routing/archives.php +120 -0
  226. package/dist/wordpress/routing/headless.php +18 -0
  227. package/dist/wordpress/seo.php +110 -0
  228. package/dist/wordpress/setup.php +11 -0
  229. package/dist/wordpress/svg.php +36 -0
  230. package/editor/list-icons.tsx +84 -74
  231. package/index.tsx +4 -2
  232. package/modules/collections/blocks/review/component.tsx +7 -0
  233. package/modules/collections/blocks/review/editor.tsx +8 -0
  234. package/modules/collections/blocks/review/register.php +2 -0
  235. package/modules/collections/blocks/review/schema.ts +20 -0
  236. package/modules/collections/manifest.json +5 -0
  237. package/modules/forms/blocks/builder/component.tsx +29 -0
  238. package/modules/forms/blocks/builder/editor.tsx +23 -0
  239. package/modules/forms/blocks/builder/register.php +2 -0
  240. package/modules/forms/blocks/builder/schema.ts +61 -0
  241. package/modules/forms/frontend/component.tsx +7 -3
  242. package/package.json +2 -1
  243. package/shared/index.tsx +6 -10
  244. package/tooling/block-paths.mjs +8 -0
  245. package/tooling/build-doc-props.mjs +34 -0
  246. package/tooling/build-editor.mjs +8 -4
  247. package/tooling/build-package.mjs +1 -1
  248. package/tooling/build-wordpress.mjs +8 -4
  249. package/tooling/cli.mjs +136 -40
  250. package/tooling/create-component.mjs +31 -0
  251. package/tooling/create-module.mjs +8 -3
  252. package/tooling/create-post-type.mjs +172 -0
  253. package/tooling/create-section.mjs +45 -12
  254. package/tooling/init-theme.mjs +183 -0
  255. package/tooling/post-type-wizard.mjs +61 -0
  256. package/tooling/prepare-project.mjs +4 -3
  257. package/tooling/smoke-package.mjs +5 -3
  258. package/tooling/sync-blocks.mjs +15 -5
  259. package/tooling/sync-kit.mjs +2 -0
  260. package/tooling/sync-sections.mjs +2 -2
  261. package/wordpress/admin/appearance.php +24 -0
  262. package/wordpress/api/content.php +122 -0
  263. package/wordpress/api/modals.php +6 -0
  264. package/wordpress/blocks.php +23 -0
  265. package/wordpress/bootstrap.php +26 -0
  266. package/wordpress/breakpoints.php +37 -0
  267. package/wordpress/documents.php +142 -0
  268. package/wordpress/editor.php +69 -0
  269. package/wordpress/examples/post-type.example.php +65 -0
  270. package/wordpress/frontend.php +7 -0
  271. package/wordpress/integrations.php +60 -0
  272. package/wordpress/options/archives.php +40 -0
  273. package/wordpress/patterns.php +19 -0
  274. package/wordpress/post-types/collections.php +87 -0
  275. package/wordpress/post-types/modals.php +91 -0
  276. package/wordpress/post-types/site-parts.php +25 -0
  277. package/wordpress/rendering/bootstrap.php +95 -0
  278. package/wordpress/rendering/performance.php +67 -0
  279. package/wordpress/routing/archives.php +120 -0
  280. package/wordpress/routing/headless.php +18 -0
  281. package/wordpress/seo.php +110 -0
  282. package/wordpress/setup.php +11 -0
  283. package/wordpress/svg.php +36 -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,64 @@ 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.
@@ -3,12 +3,12 @@ import {Children, Fragment, isValidElement, type ReactNode} from 'react';
3
3
  const marker = (name: string) => Object.assign((_props: any) => null, {kitName: name});
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
- Background = marker('Background'), Buttons = marker('Buttons'), 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'),
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'), 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,7 +29,7 @@ function describe(node: ReactNode): any[] {
26
29
 
27
30
  export function section(meta: any, View: () => ReactNode) {
28
31
  const template = describe(View());
29
- const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','Button','Show','Toggle','Choice']);
32
+ const staticTypes = new Set(['#text','Section','Text','Heading','Paragraphs','Image','Icon','Background','Buttons','SocialLinks','Button','Show','Toggle','Choice']);
30
33
  const isStatic = (nodes:any[]):boolean => nodes.every(node => (staticTypes.has(node.type) || /^[a-z]/.test(node.type)) && isStatic(node.children ?? []));
31
34
  return {name: 'site/' + meta.slug, title: meta.title, template, static: isStatic(template)};
32
35
  }
@@ -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,18 @@ 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);
74
+ }
75
+ function social_links(array $links, string $class = '', string $style = 'text'): string {
76
+ $labels = ['instagram'=>'Instagram', 'facebook'=>'Facebook', 'telegram'=>'Telegram', 'youtube'=>'YouTube', 'tiktok'=>'TikTok', 'linkedin'=>'LinkedIn'];
77
+ $html = '';
78
+ foreach ($labels as $network => $label) {
79
+ $url = $links[$network] ?? '';
80
+ if (is_string($url) && preg_match('~^https?://[^/]+~i', $url)) {
81
+ $html .= button(['text'=>$label, 'url'=>$url], $style);
82
+ }
83
+ }
84
+ return $html === '' ? '' : tag('div', ['class'=>$class], $html);
45
85
  }
46
86
  /** Mirrors `flowPlacement` in frontend/kit/flow-layout.ts. */
47
87
  function flow_placement(int $grid,array $column,array $palette,int $max_col): array {
@@ -84,21 +124,38 @@ function holds_elements(array $block): bool {
84
124
  foreach($block['innerBlocks']??[] as $child)if(!str_starts_with($child['name']??'','core/')||holds_elements($child))return true;
85
125
  return false;
86
126
  }
87
- /** 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. */
88
139
  function list_icons(string $html,array $block,array $site): string {
89
- $processor=new \WP_HTML_Tag_Processor($html);$depth=0;$index=0;
90
- $items=array_values(array_filter($block['innerBlocks']??[],fn($child)=>($child['name']??'')==='core/list-item'));
140
+ $processor=new \WP_HTML_Tag_Processor($html);$stack=[];
91
141
  while($processor->next_tag(['tag_closers'=>'visit'])){
92
142
  $tag=$processor->get_tag();
93
143
  if(in_array($tag,['UL','OL'],true)){
94
- if($processor->is_tag_closer()){$depth--;continue;}
95
- $depth++;
96
- 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);}
97
- 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;
98
153
  }
99
- if($tag!=='LI'||$processor->is_tag_closer()||$depth!==1)continue;
100
- $mask=icon_mask($items[$index++]['attrs']['metadata']['siteListIcon']??null,$site);
101
- 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);
102
159
  }
103
160
  return $processor->get_updated_html();
104
161
  }
@@ -138,30 +195,39 @@ function collection(array $rows,array $props,array $context,callable $render): s
138
195
  function node(array $node,array $context): string {
139
196
  $type=$node['type'];$p=$node['props']??[];$children=$node['children']??[];$data=$context['data']??[];$site=$context['site']??[];$record=$context['record']??[];
140
197
  $value=$data[$p['name']??'']??null;$class=classes($p);
198
+ if($type==='ClientComponent')return nodes($children,$context);
141
199
  if($type==='#text')return esc_html($node['value']);
142
- 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));}
143
201
  switch($type){
144
- 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]))));
145
- 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));
146
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],''));
147
206
  case 'AccordionTrigger':
148
207
  $settings=$context['disclosure']??[];$icon='';
149
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>';
150
209
  elseif($settings['icon'])$icon=node(['type'=>'Icon','props'=>['name'=>'indicator']],array_replace($context,['data'=>['indicator'=>$settings['icon']]]));
151
210
  return tag('summary',['class'=>$class],nodes($children,$context).($icon?tag('span',['data-disclosure-icon'=>true],$icon):''));
152
211
  case 'Section':if(!empty($p['when'])&&empty($data[$p['when']]))return '';return tag('section',['id'=>$data['sectionId']??null,'class'=>$class],nodes($children,$context));
153
- case 'Text':case 'Heading':return tag($type==='Heading'?'h'.($p['level']??2):'p',['class'=>$class],wp_kses_post((string)($value??'')));
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??'')));
154
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:[]))));
155
220
  case 'Image':return image($value,$class);
156
221
  case 'Icon':
157
222
  if(!$value)return '';$name=is_string($value)?$value:($value['type']??'');
158
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 '';
159
224
  case 'Choice':case 'RecordEdit':return '';
160
- case 'Toggle':return ($value??($p['default']??false))?nodes($children,$context):'';
225
+ case 'Toggle':return ($value??($p['default']??false))?classed_content($class,nodes($children,$context)):'';
161
226
  case 'Show':
162
- $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):'';
163
- case 'Button':return button(is_array($value)?$value:[],$p['style']??null,$site);
164
- 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);
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);
229
+ case 'SocialLinks':return social_links($site['settings']['socialLinks']??[],$class,$p['buttonStyle']??'text');
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);
165
231
  case 'Background':case 'Media':
166
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');
167
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]);
@@ -179,24 +245,50 @@ function node(array $node,array $context): string {
179
245
  $direction=($p['direction']??'next')==='previous'?'previous':'next';
180
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'?'←':'→'));
181
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'],'');
182
- 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)):'';
183
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)):'';
184
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);
185
251
  case 'PricingPlans':return pricing_plans(is_array($value)?$value:null,$site,$class);
186
252
  // The form is interactive and mounts in the browser.
187
253
  case 'Form':return tag('div',['class'=>$class],'');
188
254
  case 'ReviewsCarousel':return reviews_carousel(is_array($value)?$value:null,$site,$class);
189
- case 'Records':
190
- $library=$site[($p['type']??'post').'s']??[];$rows=[];
191
- 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;}
192
- 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
+ }
193
272
  return collection($rows,$p,$context,fn($row,$i)=>nodes($children,array_replace($context,['record'=>$row,'index'=>$i])));
194
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));
195
- 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)));
196
280
  case 'RecordExcerpt':return tag('p',['class'=>$class],wp_kses_post($record['excerpt']??''));
197
281
  case 'RecordIndex':return tag('span',['class'=>$class],sprintf('%02d',($context['index']??0)+1));
198
282
  case 'RecordImage':return image(['url'=>$record['image']??'','alt'=>$record['alt']??''],$class);
199
- 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);
200
292
  case 'Area':
201
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);
202
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))}
package/bootstrap.php CHANGED
@@ -3,7 +3,10 @@ namespace SiteTheme\Kit;
3
3
  defined('ABSPATH') || exit;
4
4
  /** One host connection; generated entries belong to components and modules. */
5
5
  require_once __DIR__.'/adapters/next/runtime.php';
6
- require_once __DIR__.'/admin-ui/bootstrap.php';
7
- foreach (require __DIR__.'/generated/modules.php' as $entry) {
8
- require_once __DIR__.'/'.$entry;
6
+ if (function_exists('add_action')) {
7
+ require_once __DIR__.'/admin-ui/bootstrap.php';
8
+ foreach (require __DIR__.'/generated/modules.php' as $entry) {
9
+ require_once __DIR__.'/'.$entry;
10
+ }
9
11
  }
12
+ require_once __DIR__.'/wordpress/bootstrap.php';
@@ -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.
@@ -0,0 +1,81 @@
1
+ 'use client';
2
+ import { createContext, useContext, useId, useRef, useState, type ReactNode, type RefObject } from 'react';
3
+ import { FieldScope, Relationship, useField, useFieldScope, useRelatedRecord } from '../../core/fields/render.js';
4
+ import { relationshipRecords } from '../../core/fields/records.js';
5
+ import { selectedRecords } from '../../core/relationships/selection.js';
6
+ import { CategoryContext, categoryRecordCount, categoryContent, categoryContentKey, setCategoryContent, type CategoryValue } from '../../core/fields/category.js';
7
+ import { collectFields } from '../../schema/index.js';
8
+ import { kit, addClasses, type Props, type AddButton } from '../../shared/index.js';
9
+
10
+ type Tabs = { active: string; select: (key: string) => void; rows: CategoryValue[]; root: RefObject<HTMLDivElement | null>; id: string; taxonomy: string; panels: boolean; counts: Record<string, number | undefined>; countClassName?: string };
11
+ const TabsContext = createContext<Tabs | null>(null);
12
+ function CategoryTab({ children, className }: { children: ReactNode; className?: string }) {
13
+ const record = useRelatedRecord(), tabs = useContext(TabsContext)!;
14
+ if (!record.id) return <span className={className}>{children}</span>;
15
+ const category = { ...record, taxonomy: tabs.taxonomy }, key = categoryContentKey(category);
16
+ return <button type="button" role="tab" className={className} data-category-index={record.index}
17
+ id={`${tabs.id}-tab-${record.index}`} aria-controls={tabs.panels ? `${tabs.id}-panel-${record.index}` : undefined}
18
+ aria-selected={tabs.active === key} tabIndex={tabs.active === key ? 0 : -1}
19
+ onClick={() => tabs.select(key)} onFocus={() => tabs.select(key)}
20
+ onKeyDown={event => {
21
+ if ((event.target as HTMLElement).closest('[contenteditable=true]')) return;
22
+ const count = tabs.rows.length;
23
+ const next = event.key === 'ArrowRight' ? (record.index + 1) % count
24
+ : event.key === 'ArrowLeft' ? (record.index + count - 1) % count
25
+ : event.key === 'Home' ? 0 : event.key === 'End' ? count - 1 : -1;
26
+ if (next < 0) return;
27
+ event.preventDefault(); tabs.select(categoryContentKey(tabs.rows[next]));
28
+ tabs.root.current?.querySelector<HTMLElement>(`[role=tab][data-category-index="${next}"]`)?.focus();
29
+ }}>{children}{tabs.counts[key] !== undefined && <span className={tabs.countClassName}>{tabs.counts[key]}</span>}</button>;
30
+ }
31
+ function CategoryPanel({ name, category, children, className, index }: { name: string; category: CategoryValue; children: ReactNode; className?: string; index: number }) {
32
+ const parent = useFieldScope(), tabs = useContext(TabsContext)!;
33
+ const field = parent.schema.find(field => field.name === name)!;
34
+ const active = tabs.active === categoryContentKey(category);
35
+ // Only the active editor panel mounts its sidebar controls. Public panels stay in the document.
36
+ if (parent.edit && !active) return null;
37
+ return <div role="tabpanel" id={`${tabs.id}-panel-${index}`} aria-labelledby={`${tabs.id}-tab-${index}`} hidden={!active} className={className}>
38
+ <CategoryContext.Provider value={category}>
39
+ <FieldScope {...parent} schema={field.fields ?? []} resolvedValue={undefined}
40
+ value={categoryContent(parent.value, name, category)}
41
+ onChange={next => parent.onChange?.(setCategoryContent(parent.value, name, category, next))}>
42
+ {children}
43
+ </FieldScope>
44
+ </CategoryContext.Provider>
45
+ </div>;
46
+ }
47
+
48
+ /** Ordered taxonomy terms or local tabs, with optional independently stored child fields. */
49
+ export const Categories = kit<Props & AddButton & {
50
+ taxonomy: string; manual?: boolean; max?: number; mode?: 'list' | 'tabs'; itemClassName?: string;
51
+ tab?: ReactNode; tabsClassName?: string; contentClassName?: string; children: ReactNode;
52
+ countField?: string; countClassName?: string;
53
+ }>(
54
+ 'categories',
55
+ ({ label, taxonomy, manual, max, tab, children }) => ({
56
+ type: 'relationship', label: label ?? 'Categories', taxonomy, manual, max, defaultValue: [],
57
+ ...(tab !== undefined ? { fields: collectFields(children) } : {}),
58
+ controlOptions: { manualLabel: 'Add custom tab', manualTitle: 'New tab' },
59
+ }),
60
+ ({ name, label = 'Categories', className, children, buttonPosition, buttonText = 'Add tab', mode = 'list', itemClassName, tab, tabsClassName, contentClassName, countField, countClassName }) => {
61
+ const parent = useFieldScope(), scope = useField(name), root = useRef<HTMLDivElement>(null), [selected, select] = useState<string | null>(null);
62
+ const id = 'categories-' + useId().replace(/[^a-zA-Z0-9_-]/g, '');
63
+ const rows = selectedRecords(scope.value, relationshipRecords(scope.field, scope.site)).map(record => ({ ...record, taxonomy: scope.field.taxonomy! }));
64
+ const counts = Object.fromEntries(rows.map(row => [categoryContentKey(row), countField ? categoryRecordCount(parent.value, name, row, scope.field, countField, scope.site) : undefined]));
65
+ const active = rows.some(row => categoryContentKey(row) === selected) ? selected! : rows[0] ? categoryContentKey(rows[0]) : '';
66
+ if (mode !== 'tabs') return <Relationship name={name} className={className}
67
+ options={{ addClass: addClasses(buttonPosition), addText: buttonText }}>{children}</Relationship>;
68
+ const tabs = <div role="tablist" aria-label={label} className={tab === undefined ? className : tabsClassName}>
69
+ <Relationship name={name} className="contents" options={{ addClass: addClasses(buttonPosition), addText: buttonText,
70
+ shape: <span className={itemClassName}>{buttonText}</span> }}>
71
+ <CategoryTab className={itemClassName}>{tab === undefined ? children : tab}</CategoryTab>
72
+ </Relationship>
73
+ </div>;
74
+ return <TabsContext.Provider value={{ active, select, rows, root, id, taxonomy: scope.field.taxonomy!, panels: tab !== undefined, counts, countClassName }}>
75
+ <div ref={root} className={tab === undefined ? 'contents' : className}>
76
+ {tabs}
77
+ {tab !== undefined && rows.map((category, index) => <CategoryPanel key={categoryContentKey(category)} name={name} category={category} index={index} className={contentClassName}>{children}</CategoryPanel>)}
78
+ </div>
79
+ </TabsContext.Provider>;
80
+ }
81
+ );