@bettercms-ai/kit 2.0.10 → 3.0.0

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 (122) hide show
  1. package/README.md +1 -2
  2. package/dist/adapters/schema.js +45 -5
  3. package/dist/adapters/schema.js.map +1 -1
  4. package/dist/brand/logo.js.map +1 -1
  5. package/dist/context.d.ts +7 -0
  6. package/dist/context.js +6 -1
  7. package/dist/context.js.map +1 -1
  8. package/dist/controls/button.js +1 -1
  9. package/dist/controls/code.d.ts +24 -1
  10. package/dist/controls/code.js +36 -20
  11. package/dist/controls/code.js.map +1 -1
  12. package/dist/controls/icon.d.ts +28 -0
  13. package/dist/controls/icon.js +205 -61
  14. package/dist/controls/icon.js.map +1 -1
  15. package/dist/controls/index.d.ts +20 -2
  16. package/dist/controls/index.js +21 -20
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.js +4 -4
  19. package/dist/controls/link.js.map +1 -1
  20. package/dist/controls/location.js +1 -1
  21. package/dist/controls/media.js +2 -2
  22. package/dist/controls/reference.js +3 -2
  23. package/dist/controls/reference.js.map +1 -1
  24. package/dist/controls/rich-text/blocks.js +2 -2
  25. package/dist/controls/rich-text/control.js +1 -1
  26. package/dist/controls/rich-text/editor.js +5 -5
  27. package/dist/controls/rich-text/embed.js +1 -1
  28. package/dist/controls/rich-text/toc.js +1 -1
  29. package/dist/controls/slot-register.js +1 -1
  30. package/dist/controls/table/table.js +1 -1
  31. package/dist/controls/text.js +5 -4
  32. package/dist/controls/text.js.map +1 -1
  33. package/dist/core/core.js +1 -1
  34. package/dist/engine/array.js +4 -8
  35. package/dist/engine/array.js.map +1 -1
  36. package/dist/engine/bits.js +1 -1
  37. package/dist/engine/breadcrumb.js +1 -1
  38. package/dist/engine/expand.js +1 -1
  39. package/dist/engine/field-shell.js +8 -7
  40. package/dist/engine/field-shell.js.map +1 -1
  41. package/dist/engine/frame.d.ts +1 -12
  42. package/dist/engine/frame.js +7 -149
  43. package/dist/engine/frame.js.map +1 -1
  44. package/dist/engine/group-summary.js +7 -4
  45. package/dist/engine/group-summary.js.map +1 -1
  46. package/dist/engine/grouping.js +2 -2
  47. package/dist/engine/item-list.js +2 -2
  48. package/dist/engine/kit-field.js +3 -7
  49. package/dist/engine/kit-field.js.map +1 -1
  50. package/dist/engine/schema-form.d.ts +10 -5
  51. package/dist/engine/schema-form.js +18 -10
  52. package/dist/engine/schema-form.js.map +1 -1
  53. package/dist/engine/slot.js +2 -2
  54. package/dist/index.d.ts +9 -9
  55. package/dist/index.js +32 -6
  56. package/dist/index.js.map +1 -1
  57. package/dist/kit.css +3 -11
  58. package/dist/lib/cn.js.map +1 -1
  59. package/dist/lib/frames.js +1 -1
  60. package/dist/lib/schema.d.ts +8 -1
  61. package/dist/lib/schema.js +18 -2
  62. package/dist/lib/schema.js.map +1 -1
  63. package/dist/lib/utils.d.ts +1 -4
  64. package/dist/lib/utils.js +4 -14
  65. package/dist/lib/utils.js.map +1 -1
  66. package/dist/lib/validate.d.ts +14 -1
  67. package/dist/lib/validate.js +26 -10
  68. package/dist/lib/validate.js.map +1 -1
  69. package/dist/library/coreNotes.d.ts +1 -1
  70. package/dist/library/coreNotes.js.map +1 -1
  71. package/dist/library/entries/advanced.entries.js +2 -2
  72. package/dist/library/entries/advanced.entries.js.map +1 -1
  73. package/dist/library/entries/commerce.entries.js +1 -1
  74. package/dist/library/entries/commerce.entries.js.map +1 -1
  75. package/dist/library/entries/company.entries.js +1 -1
  76. package/dist/library/entries/company.entries.js.map +1 -1
  77. package/dist/library/entries/conversion.entries.js +8 -0
  78. package/dist/library/entries/conversion.entries.js.map +1 -1
  79. package/dist/library/entries/features.entries.js +7 -2
  80. package/dist/library/entries/features.entries.js.map +1 -1
  81. package/dist/library/entries/heroes.entries.js +1 -1
  82. package/dist/library/entries/heroes.entries.js.map +1 -1
  83. package/dist/library/entries/listings.entries.js +1 -1
  84. package/dist/library/entries/listings.entries.js.map +1 -1
  85. package/dist/library/entries/media.entries.js +5 -5
  86. package/dist/library/entries/media.entries.js.map +1 -1
  87. package/dist/library/entries/navigation.entries.js +4 -4
  88. package/dist/library/entries/navigation.entries.js.map +1 -1
  89. package/dist/library/examples/faq.js +1 -0
  90. package/dist/library/examples/faq.js.map +1 -1
  91. package/dist/library/examples/journalStory.js +1 -2
  92. package/dist/library/examples/journalStory.js.map +1 -1
  93. package/dist/library/kit-catalog.json +17 -17
  94. package/dist/schema/adapters.js +17 -3
  95. package/dist/schema/adapters.js.map +1 -1
  96. package/dist/schema/sources.d.ts +9 -1
  97. package/dist/schema/sources.js +1 -1
  98. package/dist/schema/sources.js.map +1 -1
  99. package/dist/schema/types.d.ts +31 -3
  100. package/dist/schema/types.js.map +1 -1
  101. package/dist/styles.css +1 -1
  102. package/dist/table/table.css +1 -1
  103. package/dist/theme.css +18 -9
  104. package/dist/tokens.css +32 -60
  105. package/dist/ui/action-tray.d.ts +1 -3
  106. package/dist/ui/action-tray.js +3 -20
  107. package/dist/ui/action-tray.js.map +1 -1
  108. package/dist/ui/display.d.ts +1 -4
  109. package/dist/ui/display.js +4 -6
  110. package/dist/ui/display.js.map +1 -1
  111. package/dist/ui/index.js +3 -3
  112. package/dist/ui/overlay.d.ts +2 -5
  113. package/dist/ui/overlay.js +3 -4
  114. package/dist/ui/overlay.js.map +1 -1
  115. package/dist/ui/path-crumbs.d.ts +0 -2
  116. package/dist/ui/path-crumbs.js.map +1 -1
  117. package/dist/ui/surfaces.d.ts +2 -18
  118. package/dist/ui/surfaces.js +3 -19
  119. package/dist/ui/surfaces.js.map +1 -1
  120. package/dist/ui/toast.js +1 -1
  121. package/dist/ui/toast.js.map +1 -1
  122. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"logo.js","names":[],"sources":["../../src/brand/logo.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/* OFFICIAL BetterCMS logo — exported from the V2 Figma (node 60995:8678 \"Link - BetterCMS home\").\n Mark: three facets with the brand gradient (#A878D2 → #ED6262 → #D13A3A).\n Wordmark: --wordmark (#291018 on light, = --fg on dark; kit.css has no wordmark token yet, so the V2 values are the fallbacks). Never redraw or recolor the mark. */\n\nconst ICON = [\"M12.7575 27.0001L1.51134 20.0938C0.572213 19.5171 0.000244141 18.4961 0.000244141 17.3965V8.59934C0.000244141 7.45142 0.623145 6.3933 1.62844 5.83354L9.5867 1.4023C10.4896 0.899541 11.5815 0.866267 12.5135 1.3131L23.8336 6.74014L14.354 12.1618C13.3665 12.7265 12.7575 13.7747 12.7575 14.9096V27.0001Z\", \"M14.3398 16.0219V18.8735L22.2169 13.8627C23.1316 13.2808 23.6853 12.2739 23.6853 11.1921V8.29945L15.7983 13.3576C14.8893 13.9406 14.3398 14.9443 14.3398 16.0219Z\", \"M14.3398 22.2591V25.1107L22.2169 20.0999C23.1316 19.518 23.6853 18.5111 23.6853 17.4293V14.5367L15.7983 19.5948C14.8893 20.1779 14.3398 21.1815 14.3398 22.2591Z\"];\nconst WORD = [\"M70.5658 20.3613V10.9967H72.1245V12.1933C72.8865 11.2048 73.8044 10.8407 75.2418 10.9274V12.7136C73.2675 12.6095 72.1245 13.598 72.1245 15.4362V20.3613H70.5658Z\", \"M65.4408 20.5694C62.8083 20.5694 61.1977 18.4537 61.1977 15.679C61.1977 12.8696 62.8603 10.8406 65.3888 10.8406C67.8134 10.8406 69.4067 12.7309 69.4067 15.4015V16.0779H62.8083C62.9123 17.76 63.8994 19.0433 65.4408 19.0433C66.5319 19.0433 67.4497 18.4363 67.9866 17.2744L69.2682 17.9161C68.4889 19.7023 67.138 20.5694 65.4408 20.5694ZM62.8776 14.6212H67.7615C67.5883 13.2858 66.705 12.3494 65.3888 12.3494C64.0207 12.3494 63.1028 13.3379 62.8776 14.6212Z\", \"M59.2561 20.5693C57.5935 20.5693 56.918 19.9276 56.918 18.2975V12.5053H55.394V10.9966H56.918V8.37799H58.4767V10.9966H60.3298V12.5053H58.4767V18.072C58.4767 18.8524 58.8231 19.0085 59.3253 19.0085H60.4164V20.4999C60.07 20.5346 59.6371 20.5693 59.2561 20.5693Z\", \"M53.3658 20.5693C51.7033 20.5693 51.0278 19.9276 51.0278 18.2975V12.5053H49.5038V10.9966H51.0278V8.37799H52.5865V10.9966H54.4396V12.5053H52.5865V18.072C52.5865 18.8524 52.9329 19.0085 53.4351 19.0085H54.5262V20.4999C54.1798 20.5346 53.7469 20.5693 53.3658 20.5693Z\", \"M44.9815 20.5695C42.3491 20.5695 40.7384 18.4538 40.7384 15.6791C40.7384 12.8697 42.401 10.8408 44.9296 10.8408C47.3542 10.8408 48.9475 12.731 48.9475 15.4016V16.078H42.3491C42.453 17.7601 43.4402 19.0434 44.9815 19.0434C46.0726 19.0434 46.9905 18.4365 47.5274 17.2746L48.8089 17.9162C48.0296 19.7024 46.6787 20.5695 44.9815 20.5695ZM42.4184 14.6213H47.3022C47.129 13.286 46.2458 12.3495 44.9296 12.3495C43.5614 12.3495 42.6435 13.338 42.4184 14.6213Z\", \"M29.834 20.3613V7.32031H35.1162C37.6447 7.32031 39.0995 8.5169 39.0995 10.5806C39.0995 11.8639 38.5279 12.8697 37.4542 13.4593C38.8743 13.9449 39.6537 15.0894 39.6537 16.5808C39.6537 18.8353 37.8352 20.3613 35.1854 20.3613H29.834ZM31.3927 12.7483H34.6486C36.4151 12.7483 37.5581 11.9506 37.5581 10.6673C37.5581 9.52272 36.6229 8.86373 35.0469 8.86373H31.3927V12.7483ZM31.3927 18.8006H35.0642C36.9346 18.8006 38.0603 17.9682 38.043 16.5808C38.0603 15.1415 36.848 14.257 34.891 14.257H31.3927V18.8006Z\", \"M107.608 20.6788C104.835 20.6788 103.115 19.3074 102.697 16.7653L104.2 16.4643C104.501 18.2538 105.637 19.1736 107.524 19.1736C109.345 19.1736 110.614 18.3039 110.614 17.0663C110.614 15.9793 109.629 15.2267 107.224 14.5242C104.301 13.688 103.048 12.4504 103.048 10.7111C103.048 8.72086 104.685 7.48326 107.307 7.48326C109.862 7.48326 111.399 8.65396 111.917 10.895L110.364 11.2295C110.03 9.72433 109.027 8.97173 107.274 8.97173C105.637 8.97173 104.618 9.60726 104.618 10.6943C104.618 11.6978 105.47 12.3835 107.858 13.1194C110.998 14.0727 112.167 15.3103 112.167 17.0663C112.167 19.2572 110.38 20.6788 107.608 20.6788Z\", \"M89.8249 20.3612V7.78442H91.7289L95.871 18.2204L99.9463 7.78442H101.85V20.3612H100.347V10.6945L96.5725 20.3612H95.1695L91.328 10.6945V20.3612H89.8249Z\", \"M83.2802 20.6788C79.6558 20.6788 77.0837 18.0364 77.0837 14.24C77.0837 10.3766 79.8061 7.4833 83.4639 7.4833C85.9692 7.4833 87.9902 8.82125 88.9756 11.079L87.3889 11.4303C86.6206 9.90833 85.2009 9.02194 83.4305 9.02194C80.6579 9.02194 78.7038 11.1961 78.7038 14.1731C78.7038 17.0998 80.5911 19.1569 83.2635 19.1569C85.2343 19.1569 86.8043 18.0364 87.5392 16.1967L89.0424 16.5312C88.0737 19.1569 86.036 20.6788 83.2802 20.6788Z\"];\n/** boxicons:sparkle-circle-filled — path from public/brand/ai-sparkle-glyph.svg (viewBox 2 2 16 16). */\nexport const SPARKLE_PATH = \"M9.4668 2.37243C9.64848 1.87586 10.351 1.87586 10.5326 2.37243L11.0754 3.85459C11.501 5.01732 12.1751 6.07325 13.0506 6.94879C13.9262 7.82432 14.9821 8.4984 16.1448 8.92405L17.627 9.4668C18.1243 9.64848 18.1243 10.351 17.627 10.5326L16.1448 11.0754C14.9821 11.501 13.9262 12.1751 13.0506 13.0506C12.1751 13.9262 11.501 14.9821 11.0754 16.1448L10.5326 17.627C10.351 18.1243 9.64848 18.1243 9.4668 17.627L8.92405 16.1448C8.4984 14.9821 7.82432 13.9262 6.94879 13.0506C6.07325 12.1751 5.01732 11.501 3.85459 11.0754L2.37243 10.5326C1.87586 10.351 1.87586 9.64848 2.37243 9.4668L3.85459 8.92405C5.01732 8.4984 6.07325 7.82432 6.94879 6.94879C7.82432 6.07325 8.4984 5.01732 8.92405 3.85459L9.4668 2.37243Z\";\nexport const BRAND_STOPS = [\n { offset: 0.0817, color: \"#A878D2\" },\n { offset: 0.4808, color: \"#ED6262\" },\n { offset: 0.9231, color: \"#D13A3A\" },\n];\n\nfunction MarkGradient({ id }: { id: string }) {\n return (\n <linearGradient id={id} x1=\"8.81595\" y1=\"-2.84571\" x2=\"18.8801\" y2=\"29.1204\" gradientUnits=\"userSpaceOnUse\">\n {BRAND_STOPS.map((s) => <stop key={s.offset} offset={s.offset} stopColor={s.color} />)}\n </linearGradient>\n );\n}\n\n/** The mark alone (square). */\nexport function LogoMark({ size = 24, className }: { size?: number; className?: string }) {\n const id = React.useId().replace(/:/g, \"\");\n return (\n <svg width={size} height={size} viewBox=\"-1 0 26 28\" className={cn(\"shrink-0\", className)} aria-hidden>\n <defs><MarkGradient id={`bm${id}`} /></defs>\n {ICON.map((d) => <path key={d.slice(0, 12)} d={d} fill={`url(#bm${id})`} />)}\n </svg>\n );\n}\n\n/** Full lockup: mark + \"BetterCMS\" wordmark. Height-driven (default 24px → 106px wide). */\nexport function Logo({ className, compact, height = 24 }: { className?: string; compact?: boolean; height?: number }) {\n const id = React.useId().replace(/:/g, \"\");\n if (compact) return <LogoMark size={height} className={className} />;\n return (\n <svg height={height} width={(height * 113) / 28} viewBox=\"0 0 113 28\" className={cn(\"shrink-0 text-[var(--kit-wordmark,#291018)] [.dark_&]:text-[var(--kit-fg,#e1e1e4)]\", className)} role=\"img\" aria-label=\"BetterCMS\">\n <defs><MarkGradient id={`bl${id}`} /></defs>\n {ICON.map((d) => <path key={d.slice(0, 12)} d={d} fill={`url(#bl${id})`} />)}\n {WORD.map((d) => <path key={d.slice(0, 12)} d={d} fill=\"currentColor\" />)}\n </svg>\n );\n}\n"],"mappings":";;;;AAOA,IAAM,OAAO;CAAC;CAAgT;CAAqK;AAAkK;AACroB,IAAM,OAAO;CAAC;CAAoK;CAAyc;CAAsQ;CAA4Q;CAAuc;CAAuf;CAA8mB;CAA0J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,cAAD,EAAc,IAAI,KAAK,KAAO,CAAA,EAAO,CAAA;GAC1C,KAAK,KAAK,MAAM,oBAAC,QAAD;IAA8B;IAAG,MAAM,UAAU,GAAG;GAAK,GAA9C,EAAE,MAAM,GAAG,EAAE,CAAiC,CAAC;GAC1E,KAAK,KAAK,MAAM,oBAAC,QAAD;IAA8B;IAAG,MAAK;GAAgB,GAA3C,EAAE,MAAM,GAAG,EAAE,CAA8B,CAAC;EACrE;;AAET"}
1
+ {"version":3,"file":"logo.js","names":[],"sources":["../../src/brand/logo.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../lib/cn\";\n\n/* OFFICIAL BetterCMS logo — exported from the V2 Figma (node 60995:8678 \"Link - BetterCMS home\").\n Mark: three facets with the brand gradient (#A878D2 → #ED6262 → #D13A3A).\n Wordmark: --kit-wordmark (#291018 on light, = --kit-fg on dark). Never redraw or recolor the mark. */\n\nconst ICON = [\"M12.7575 27.0001L1.51134 20.0938C0.572213 19.5171 0.000244141 18.4961 0.000244141 17.3965V8.59934C0.000244141 7.45142 0.623145 6.3933 1.62844 5.83354L9.5867 1.4023C10.4896 0.899541 11.5815 0.866267 12.5135 1.3131L23.8336 6.74014L14.354 12.1618C13.3665 12.7265 12.7575 13.7747 12.7575 14.9096V27.0001Z\", \"M14.3398 16.0219V18.8735L22.2169 13.8627C23.1316 13.2808 23.6853 12.2739 23.6853 11.1921V8.29945L15.7983 13.3576C14.8893 13.9406 14.3398 14.9443 14.3398 16.0219Z\", \"M14.3398 22.2591V25.1107L22.2169 20.0999C23.1316 19.518 23.6853 18.5111 23.6853 17.4293V14.5367L15.7983 19.5948C14.8893 20.1779 14.3398 21.1815 14.3398 22.2591Z\"];\nconst WORD = [\"M70.5658 20.3613V10.9967H72.1245V12.1933C72.8865 11.2048 73.8044 10.8407 75.2418 10.9274V12.7136C73.2675 12.6095 72.1245 13.598 72.1245 15.4362V20.3613H70.5658Z\", \"M65.4408 20.5694C62.8083 20.5694 61.1977 18.4537 61.1977 15.679C61.1977 12.8696 62.8603 10.8406 65.3888 10.8406C67.8134 10.8406 69.4067 12.7309 69.4067 15.4015V16.0779H62.8083C62.9123 17.76 63.8994 19.0433 65.4408 19.0433C66.5319 19.0433 67.4497 18.4363 67.9866 17.2744L69.2682 17.9161C68.4889 19.7023 67.138 20.5694 65.4408 20.5694ZM62.8776 14.6212H67.7615C67.5883 13.2858 66.705 12.3494 65.3888 12.3494C64.0207 12.3494 63.1028 13.3379 62.8776 14.6212Z\", \"M59.2561 20.5693C57.5935 20.5693 56.918 19.9276 56.918 18.2975V12.5053H55.394V10.9966H56.918V8.37799H58.4767V10.9966H60.3298V12.5053H58.4767V18.072C58.4767 18.8524 58.8231 19.0085 59.3253 19.0085H60.4164V20.4999C60.07 20.5346 59.6371 20.5693 59.2561 20.5693Z\", \"M53.3658 20.5693C51.7033 20.5693 51.0278 19.9276 51.0278 18.2975V12.5053H49.5038V10.9966H51.0278V8.37799H52.5865V10.9966H54.4396V12.5053H52.5865V18.072C52.5865 18.8524 52.9329 19.0085 53.4351 19.0085H54.5262V20.4999C54.1798 20.5346 53.7469 20.5693 53.3658 20.5693Z\", \"M44.9815 20.5695C42.3491 20.5695 40.7384 18.4538 40.7384 15.6791C40.7384 12.8697 42.401 10.8408 44.9296 10.8408C47.3542 10.8408 48.9475 12.731 48.9475 15.4016V16.078H42.3491C42.453 17.7601 43.4402 19.0434 44.9815 19.0434C46.0726 19.0434 46.9905 18.4365 47.5274 17.2746L48.8089 17.9162C48.0296 19.7024 46.6787 20.5695 44.9815 20.5695ZM42.4184 14.6213H47.3022C47.129 13.286 46.2458 12.3495 44.9296 12.3495C43.5614 12.3495 42.6435 13.338 42.4184 14.6213Z\", \"M29.834 20.3613V7.32031H35.1162C37.6447 7.32031 39.0995 8.5169 39.0995 10.5806C39.0995 11.8639 38.5279 12.8697 37.4542 13.4593C38.8743 13.9449 39.6537 15.0894 39.6537 16.5808C39.6537 18.8353 37.8352 20.3613 35.1854 20.3613H29.834ZM31.3927 12.7483H34.6486C36.4151 12.7483 37.5581 11.9506 37.5581 10.6673C37.5581 9.52272 36.6229 8.86373 35.0469 8.86373H31.3927V12.7483ZM31.3927 18.8006H35.0642C36.9346 18.8006 38.0603 17.9682 38.043 16.5808C38.0603 15.1415 36.848 14.257 34.891 14.257H31.3927V18.8006Z\", \"M107.608 20.6788C104.835 20.6788 103.115 19.3074 102.697 16.7653L104.2 16.4643C104.501 18.2538 105.637 19.1736 107.524 19.1736C109.345 19.1736 110.614 18.3039 110.614 17.0663C110.614 15.9793 109.629 15.2267 107.224 14.5242C104.301 13.688 103.048 12.4504 103.048 10.7111C103.048 8.72086 104.685 7.48326 107.307 7.48326C109.862 7.48326 111.399 8.65396 111.917 10.895L110.364 11.2295C110.03 9.72433 109.027 8.97173 107.274 8.97173C105.637 8.97173 104.618 9.60726 104.618 10.6943C104.618 11.6978 105.47 12.3835 107.858 13.1194C110.998 14.0727 112.167 15.3103 112.167 17.0663C112.167 19.2572 110.38 20.6788 107.608 20.6788Z\", \"M89.8249 20.3612V7.78442H91.7289L95.871 18.2204L99.9463 7.78442H101.85V20.3612H100.347V10.6945L96.5725 20.3612H95.1695L91.328 10.6945V20.3612H89.8249Z\", \"M83.2802 20.6788C79.6558 20.6788 77.0837 18.0364 77.0837 14.24C77.0837 10.3766 79.8061 7.4833 83.4639 7.4833C85.9692 7.4833 87.9902 8.82125 88.9756 11.079L87.3889 11.4303C86.6206 9.90833 85.2009 9.02194 83.4305 9.02194C80.6579 9.02194 78.7038 11.1961 78.7038 14.1731C78.7038 17.0998 80.5911 19.1569 83.2635 19.1569C85.2343 19.1569 86.8043 18.0364 87.5392 16.1967L89.0424 16.5312C88.0737 19.1569 86.036 20.6788 83.2802 20.6788Z\"];\n/** boxicons:sparkle-circle-filled — path from public/brand/ai-sparkle-glyph.svg (viewBox 2 2 16 16). */\nexport const SPARKLE_PATH = \"M9.4668 2.37243C9.64848 1.87586 10.351 1.87586 10.5326 2.37243L11.0754 3.85459C11.501 5.01732 12.1751 6.07325 13.0506 6.94879C13.9262 7.82432 14.9821 8.4984 16.1448 8.92405L17.627 9.4668C18.1243 9.64848 18.1243 10.351 17.627 10.5326L16.1448 11.0754C14.9821 11.501 13.9262 12.1751 13.0506 13.0506C12.1751 13.9262 11.501 14.9821 11.0754 16.1448L10.5326 17.627C10.351 18.1243 9.64848 18.1243 9.4668 17.627L8.92405 16.1448C8.4984 14.9821 7.82432 13.9262 6.94879 13.0506C6.07325 12.1751 5.01732 11.501 3.85459 11.0754L2.37243 10.5326C1.87586 10.351 1.87586 9.64848 2.37243 9.4668L3.85459 8.92405C5.01732 8.4984 6.07325 7.82432 6.94879 6.94879C7.82432 6.07325 8.4984 5.01732 8.92405 3.85459L9.4668 2.37243Z\";\nexport const BRAND_STOPS = [\n { offset: 0.0817, color: \"#A878D2\" },\n { offset: 0.4808, color: \"#ED6262\" },\n { offset: 0.9231, color: \"#D13A3A\" },\n];\n\nfunction MarkGradient({ id }: { id: string }) {\n return (\n <linearGradient id={id} x1=\"8.81595\" y1=\"-2.84571\" x2=\"18.8801\" y2=\"29.1204\" gradientUnits=\"userSpaceOnUse\">\n {BRAND_STOPS.map((s) => <stop key={s.offset} offset={s.offset} stopColor={s.color} />)}\n </linearGradient>\n );\n}\n\n/** The mark alone (square). */\nexport function LogoMark({ size = 24, className }: { size?: number; className?: string }) {\n const id = React.useId().replace(/:/g, \"\");\n return (\n <svg width={size} height={size} viewBox=\"-1 0 26 28\" className={cn(\"shrink-0\", className)} aria-hidden>\n <defs><MarkGradient id={`bm${id}`} /></defs>\n {ICON.map((d) => <path key={d.slice(0, 12)} d={d} fill={`url(#bm${id})`} />)}\n </svg>\n );\n}\n\n/** Full lockup: mark + \"BetterCMS\" wordmark. Height-driven (default 24px → 106px wide). */\nexport function Logo({ className, compact, height = 24 }: { className?: string; compact?: boolean; height?: number }) {\n const id = React.useId().replace(/:/g, \"\");\n if (compact) return <LogoMark size={height} className={className} />;\n return (\n <svg height={height} width={(height * 113) / 28} viewBox=\"0 0 113 28\" className={cn(\"shrink-0 text-[var(--kit-wordmark,#291018)] [.dark_&]:text-[var(--kit-fg,#e1e1e4)]\", className)} role=\"img\" aria-label=\"BetterCMS\">\n <defs><MarkGradient id={`bl${id}`} /></defs>\n {ICON.map((d) => <path key={d.slice(0, 12)} d={d} fill={`url(#bl${id})`} />)}\n {WORD.map((d) => <path key={d.slice(0, 12)} d={d} fill=\"currentColor\" />)}\n </svg>\n );\n}\n"],"mappings":";;;;AAOA,IAAM,OAAO;CAAC;CAAgT;CAAqK;AAAkK;AACroB,IAAM,OAAO;CAAC;CAAoK;CAAyc;CAAsQ;CAA4Q;CAAuc;CAAuf;CAA8mB;CAA0J;AAA4a;;AAE/vG,IAAa,eAAe;AAC5B,IAAa,cAAc;CACzB;EAAE,QAAQ;EAAQ,OAAO;CAAU;CACnC;EAAE,QAAQ;EAAQ,OAAO;CAAU;CACnC;EAAE,QAAQ;EAAQ,OAAO;CAAU;AACrC;AAEA,SAAS,aAAa,EAAE,MAAsB;CAC5C,OACE,oBAAC,kBAAD;EAAoB;EAAI,IAAG;EAAU,IAAG;EAAW,IAAG;EAAU,IAAG;EAAU,eAAc;EACxF,UAAA,YAAY,KAAK,MAAM,oBAAC,QAAD;GAAqB,QAAQ,EAAE;GAAQ,WAAW,EAAE;EAAQ,GAAjD,EAAE,MAA+C,CAAC;CACvE,CAAA;AAEpB;;AAGA,SAAgB,SAAS,EAAE,OAAO,IAAI,aAAoD;CACxF,MAAM,KAAK,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,EAAE;CACzC,OACE,qBAAC,OAAD;EAAK,OAAO;EAAM,QAAQ;EAAM,SAAQ;EAAa,WAAW,GAAG,YAAY,SAAS;EAAG,eAAA;EAA3F,UAAA,CACE,oBAAC,QAAD,EAAA,UAAM,oBAAC,cAAD,EAAc,IAAI,KAAK,KAAO,CAAA,EAAO,CAAA,GAC1C,KAAK,KAAK,MAAM,oBAAC,QAAD;GAA8B;GAAG,MAAM,UAAU,GAAG;EAAK,GAA9C,EAAE,MAAM,GAAG,EAAE,CAAiC,CAAC,CACxE;;AAET;;AAGA,SAAgB,KAAK,EAAE,WAAW,SAAS,SAAS,MAAkE;CACpH,MAAM,KAAK,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,EAAE;CACzC,IAAI,SAAS,OAAO,oBAAC,UAAD;EAAU,MAAM;EAAmB;CAAY,CAAA;CACnE,OACE,qBAAC,OAAD;EAAa;EAAQ,OAAQ,SAAS,MAAO;EAAI,SAAQ;EAAa,WAAW,GAAG,sFAAsF,SAAS;EAAG,MAAK;EAAM,cAAW;EAA5M,UAAA;GACE,oBAAC,QAAD,EAAA,UAAM,oBAAC,cAAD,EAAc,IAAI,KAAK,KAAO,CAAA,EAAO,CAAA;GAC1C,KAAK,KAAK,MAAM,oBAAC,QAAD;IAA8B;IAAG,MAAM,UAAU,GAAG;GAAK,GAA9C,EAAE,MAAM,GAAG,EAAE,CAAiC,CAAC;GAC1E,KAAK,KAAK,MAAM,oBAAC,QAAD;IAA8B;IAAG,MAAK;GAAgB,GAA3C,EAAE,MAAM,GAAG,EAAE,CAA8B,CAAC;EACrE;;AAET"}
package/dist/context.d.ts CHANGED
@@ -281,6 +281,8 @@ export interface KitEnv {
281
281
  helpDisplay?: "inline" | "tooltip";
282
282
  /** D61 Review changes: the host's change markers, present only while its History panel is open. */
283
283
  review?: KitReview;
284
+ /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */
285
+ onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;
284
286
  /**
285
287
  * "quiet": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field
286
288
  * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a
@@ -317,6 +319,11 @@ export interface KitReview {
317
319
  /** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats
318
320
  * its section's title ("Options" › "Options"): the section heading names it. */
319
321
  export declare const KitSectionTitle: React.Context<string | null>;
322
+ /**
323
+ * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host
324
+ * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.
325
+ */
326
+ export declare const KitAddressContext: React.Context<((slug: string) => React.ReactNode) | null>;
320
327
  export declare const DEFAULT_ENV: KitEnv;
321
328
  /** D58 field access: fields in the `seo` group default to `{ edit: "seo.edit" }`. */
322
329
  export declare const fieldAccessOf: (field: FieldSchema) => FieldAccess | undefined;
package/dist/context.js CHANGED
@@ -162,6 +162,11 @@ var SITE_PALETTE = [
162
162
  /** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats
163
163
  * its section's title ("Options" › "Options"): the section heading names it. */
164
164
  var KitSectionTitle = React.createContext(null);
165
+ /**
166
+ * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host
167
+ * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.
168
+ */
169
+ var KitAddressContext = React.createContext(null);
165
170
  var DEFAULT_ENV = {
166
171
  variant: "panel",
167
172
  docId: "kit",
@@ -251,6 +256,6 @@ var FormCtx = React.createContext(null);
251
256
  var FormProvider = FormCtx.Provider;
252
257
  var useForm = () => React.useContext(FormCtx);
253
258
  //#endregion
254
- export { AI_PRESETS, DEFAULT_ENV, FieldHeaderSlot, FormProvider, KitEnvProvider, KitSectionTitle, KitServicesProvider, SITE_PALETTE, fieldAccessOf, registerKitServices, resolveFieldAccess, seesDevSurfaces, useForm, useKitEnv, useKitServices, useRichTextRefs, visibleFields, visibleSchema };
259
+ export { AI_PRESETS, DEFAULT_ENV, FieldHeaderSlot, FormProvider, KitAddressContext, KitEnvProvider, KitSectionTitle, KitServicesProvider, SITE_PALETTE, fieldAccessOf, registerKitServices, resolveFieldAccess, seesDevSurfaces, useForm, useKitEnv, useKitServices, useRichTextRefs, visibleFields, visibleSchema };
255
260
 
256
261
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * The host's own control for a type (a FieldRenderer arm in the dashboard), drawn for a stored value a kit control\n * hands off because it cannot carry it unchanged (rich text, LegacyFallback). Bare inside the kit FieldShell, which\n * owns the label row and the help; the box is tagged `data-kit-legacy`. Absent → the field says why in words.\n */\n LegacyControl?: React.ComponentType<ControlProps>;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/** One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio). */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAgD;CAC3D;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAU,OAAO;CAAS;CAChC;EAAE,IAAI;EAAY,OAAO;CAAW;CACpC;EAAE,IAAI;EAAW,OAAO;CAAyB;CACjD;EAAE,IAAI;EAAa,OAAO;CAAuB;AACnD;;;;;AAmHA,SAAgB,gBAAgB,KAAwH;CACtJ,MAAM,EAAE,wBAAwB,eAAe;CAC/C,MAAM,MAAM,MAAM,KAAK,UAAU,GAAG,IAAI;CACxC,MAAM,CAAC,OAAO,YAAY,MAAM,SAA0E,IAAI;CAC9G,MAAM,gBAAgB;EACpB,IAAI,CAAC,uBAAuB,CAAC,KAAK;EAClC,IAAI,OAAO;EACX,oBAAoB,KAAK,MAAM,GAAG,CAA0B,CAAC,CAAC,MAC3D,UAAU,QAAQ,SAAS;GAAE;GAAK;EAAM,CAAC,IACzC,MAAe,QAAQ,SAAS;GAAE;GAAK,OAAO,CAAC;GAAG,OAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;EAAE,CAAC,CACxG;EACA,a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IAAI,MAAM,EAAE,QAAQ,IAAI;IAAE,GAAG;IAAG,QAAQ;GAAE;EAC5C;EACA,IAAI,MAAM,QAAQ,EAAE,EAAE,GAAG;GACvB,MAAM,IAAI,cAAc,EAAE,IAAI,GAAG;GACjC,IAAI,MAAM,EAAE,IAAI,IAAI;IAAE,GAAG;IAAG,IAAI;GAAE;EACpC;EACA,IAAI,EAAE,cAAc;GAClB,MAAM,IAAI,cAAc,EAAE,cAAc,GAAG;GAC3C,IAAI,MAAM,EAAE,cAAc,IAAI;IAAE,GAAG;IAAG,cAAc;GAAE;EACxD;EACA,IAAI,MAAM,GAAG,UAAU;EACvB,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,UAAU,MAAM;AACzB;AACA,SAAgB,cAAc,QAAoB,KAAgC;CAChF,MAAM,SAAS,cAAc,OAAO,QAAQ,GAAG;CAC/C,OAAO,WAAW,OAAO,SAAS,SAAS;EAAE,GAAG;EAAQ;CAAO;AACjE;;AAGA,IAAa,mBAAmB,QAA6B,IAAI,IAAI,aAAa,KAAK,IAAI,IAAI,UAAU;AACzG,IAAa,iBAAiB,OAAO;AACrC,IAAa,kBAAkB,MAAM,WAAW,MAAM;AAkDtD,IAAM,UAAU,MAAM,cAA8B,IAAI;AACxD,IAAa,eAAe,QAAQ;AACpC,IAAa,gBAAgB,MAAM,WAAW,OAAO"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/**\n * Kit runtime contexts (V2 HEAD 9829bf1 kit/context.tsx).\n *\n * - KitServices — pluggable app services (media library picker, upload sink, toast, AI rewrite, comment threads).\n * Hosts register theirs once (`registerKitServices`) or provide them (`KitServicesProvider`); the kit\n * never imports a feature. A service that is absent hides the surface that needs it.\n * - KitEnv — the editing environment a control renders in: variant (panel | document), doc identity, site\n * palette, permissions, presence, comments. Has safe defaults so a control can render alone.\n * - FormApi — present only inside <SchemaForm>: value, writes, navigation, issues, baselines, history.\n */\nimport * as React from \"react\";\nimport type { Cap } from \"./schema/sources\";\nimport type { FieldAccess, FieldPath, FieldSchema, Fieldset, TypeSchema } from \"./schema/types\";\nimport type { KitIssue } from \"./lib/validate\";\nimport type { ControlProps } from \"./types\";\nimport type { LinkTarget } from \"./controls/link\";\n\n/* ── Services ─────────────────────────────────────────────────────────── */\n/** The media asset a picker hands back (the host's media library row, narrowed to what the kit reads). */\nexport interface KitMediaAsset {\n id: string;\n url: string;\n name?: string;\n alt?: string;\n kind?: \"image\" | \"video\" | \"file\" | \"svg\";\n width?: number;\n height?: number;\n size?: number;\n}\nexport interface KitMediaPickerProps {\n open: boolean;\n onOpenChange: (v: boolean) => void;\n onPick: (assets: KitMediaAsset[]) => void;\n multiple?: boolean;\n accept?: (\"image\" | \"video\" | \"file\" | \"svg\")[];\n /** What the dialog is for, in the author's words (\"Replace icon\"). Absent: the host's own title. */\n title?: string;\n /** An icon's Remove, in the dialog's footer (its row has no room for one). Absent: no Remove. */\n onRemove?: () => void;\n /**\n * An icon's first tab: the icons already on this site, each with the value it is stored as. The field's own icon\n * leads, marked `current`: picking it closes the dialog with no write. Absent: no such tab.\n */\n icons?: KitSiteIcon[];\n onPickIcon?: (value: unknown) => void;\n}\n/** One icon already on the site (KitServices.useSiteIcons), as the picker's first tab draws it. */\nexport interface KitSiteIcon {\n url: string;\n value: unknown;\n assetId?: string;\n current?: boolean;\n}\nexport interface KitToastOptions {\n /** the second line under the message (V2 sonner `description`) */\n description?: string;\n action?: { label: string; onClick: () => void };\n duration?: number;\n icon?: React.ReactNode;\n}\n/** The host's toaster. The kit has no toast dependency (V2 re-exported sonner's). */\nexport interface KitToast {\n (message: string, opts?: KitToastOptions): void;\n success: (message: string, opts?: KitToastOptions) => void;\n}\n/** Rewrite with AI presets (V2 lib/ai.ts). The host's `aiRewrite` service produces the text. */\nexport type AiPreset = \"improve\" | \"shorter\" | \"longer\" | \"simplify\" | \"grammar\" | \"translate\";\nexport const AI_PRESETS: { id: AiPreset; label: string }[] = [\n { id: \"improve\", label: \"Improve\" },\n { id: \"shorter\", label: \"Shorter\" },\n { id: \"longer\", label: \"Longer\" },\n { id: \"simplify\", label: \"Simplify\" },\n { id: \"grammar\", label: \"Fix spelling & grammar\" },\n { id: \"translate\", label: \"Translate to Spanish\" },\n];\n/** The in-place field comments popover (V2 FieldThreads over the comments store), drawn by the host. */\nexport interface KitFieldCommentsProps {\n docId: string;\n /** pathKey of the field (\"items.1.answer\") */\n fieldKey: string;\n label: string;\n /** the field's text, first 80 characters */\n quote?: string;\n onClose: () => void;\n /** \"Open in panel\": set when the host has a comments panel (`env.onComment`) */\n onOpenPanel?: () => void;\n}\n/** One field's ⋯ menu, as the host's extra items see it (KitServices.FieldMenuExtras). */\nexport interface KitFieldMenuExtrasProps {\n field: FieldSchema;\n path: FieldPath;\n /** the field is read-only for the lens: a host offers nothing that edits */\n readOnly: boolean;\n}\n/* The popover around FieldComments keeps itself open on Escape while focus is on an element marked `data-esc-owner`\n (V2 guardEscape): the composer marks its input so Escape clears or blurs the draft instead of losing it. */\nexport interface KitServices {\n /** The media library picker. */\n MediaPicker?: React.ComponentType<KitMediaPickerProps>;\n /** Called after an upload so the host can file the assets into its media library. */\n onUploaded?: (assets: KitMediaAsset[]) => void;\n /**\n * Image placements keep their edits BESIDE the url (`${name}Alt` · `${name}Focal` · `${name}Crop` ·\n * `${name}Decorative`) instead of turning the value into an object — the Visuals block model.\n */\n imageSiblings?: boolean;\n /** Real metadata for an image url (the host's media library), so captions never show placeholders. */\n resolveImage?: (url: string) => { name?: string; width?: number; height?: number; size?: number } | undefined;\n /** The host's full image editor (crop, rotate, focal, alt…), opened in place. */\n editImage?: (req: { docId: string; path: FieldPath; title: string }) => void;\n /** The project's forms for `reference: { to: [\"form\"] }` (the host's Forms store). */\n forms?: () => { id: string; title: string; subtitle: string }[];\n /** Toasts for Copy / Paste / Reset / AI (each with Undo). Absent → the action still runs, silently. */\n toast?: KitToast;\n /**\n * A slug's \"Save new address\" with \"Redirect it to the new address\" ticked (V2 SlugControl): the host files the\n * redirect from the old slug to the new one. Absent → no checkbox is offered, and the toast says the old address\n * will return \"Not found\", which is what happens. A rejection is named in a toast (the new slug is already saved).\n */\n redirectSlug?: (from: string, to: string) => void | Promise<void>;\n /**\n * A slug's \"Save new address\": the host writes the new address before any redirect is filed. Absent → the form's\n * value is the save (V2). A rejection is named in a toast and the old-address box stays for another try.\n */\n saveSlug?: (to: string) => Promise<void>;\n /** Rewrite with AI. Absent → the ⋯ menu offers no rewrite. `attempt` counts \"Try again\" presses. */\n aiRewrite?: (text: string, preset: AiPreset, attempt: number) => string | Promise<string>;\n /** In-place field comments. Absent and no `env.onComment` → the field shows no add-comment control. */\n FieldComments?: React.ComponentType<KitFieldCommentsProps>;\n /**\n * A React hook: open (unresolved) threads on one field, read from the same store FieldComments draws (V2 counted\n * `useBlockThreads(docId, key)`). Used while the host has no `env.onComment`; absent → SchemaForm `comments` counts.\n */\n useFieldCommentCount?: (docId: string, fieldKey: string) => number;\n /**\n * The host's own control for a type (a FieldRenderer arm in the dashboard), drawn for a stored value a kit control\n * hands off because it cannot carry it unchanged (rich text, LegacyFallback). Bare inside the kit FieldShell, which\n * owns the label row and the help; the box is tagged `data-kit-legacy`. Absent → the field says why in words.\n */\n LegacyControl?: React.ComponentType<ControlProps>;\n /**\n * The host's own items for a field's ⋯ menu (the entry editor's Move up · Move down · Move to panel), drawn after\n * History and before Rewrite with AI. It renders kit `MenuItem`s, with its own leading `MenuSeparator`, or null.\n * Absent → the menu is exactly V2's.\n */\n FieldMenuExtras?: React.ComponentType<KitFieldMenuExtrasProps>;\n /**\n * A React HOOK: the project's pages and CMS items a link can point at (controls/link.tsx). The host passes the same\n * function for the life of the form (it is called on every render of a link control). Absent → the link picker says\n * page search isn't available and takes a typed path. `error` is a whole sentence naming what failed (\"Pages couldn't\n * be loaded: …\", \"Items from Blog couldn't be loaded: …\"); the picker shows it under whatever did load.\n */\n useLinkTargets?: () => { targets: LinkTarget[]; loading?: boolean; error?: string };\n /**\n * A React HOOK: every SVG the site already uses (its pages, header and footer, the library's SVGs), for an icon's\n * picker. The host passes the same function for the life of the form. Absent → the picker has no site tab.\n */\n useSiteIcons?: () => KitSiteIcon[];\n /**\n * The entries a rich text's related posts or author bio block shows (kit-richtext-blocks-plan.md RT8). `ids`: the\n * hand-picked entries (an author bio's one author, related posts in hand-picked mode), answered in that order with\n * any the host cannot find left out. `query`: related posts chosen for the reader (owner 2026-10-24: `topic` = same\n * tags or category, `newest` = the collection newest first; `count` of them, `excludeId` the entry being edited).\n * Absent → the blocks show their empty state; a rejection's message is shown as said.\n */\n resolveRichTextRefs?: (req: KitRichTextRefRequest) => Promise<KitRichTextRef[]>;\n}\n\n/** What a related posts or author bio block asks the host for (KitServices.resolveRichTextRefs). */\nexport interface KitRichTextRefRequest {\n kind: \"relatedPosts\" | \"authorBio\";\n ids?: string[];\n query?: { collection?: string; mode: \"topic\" | \"newest\"; count: number; excludeId?: string };\n}\n/** One resolved entry, as the block draws it: a post card (title, cover, category) or an author (avatar, title as name, bio). */\nexport interface KitRichTextRef {\n id: string;\n title: string;\n href?: string;\n cover?: string;\n category?: string;\n avatar?: string;\n bio?: string;\n}\n\n/**\n * A React HOOK over KitServices.resolveRichTextRefs: `unavailable` when the host offers no resolver (draw the empty\n * state), else `loading`, then `items` or `error` (a sentence). `req` null asks nothing (a block with nothing picked).\n */\nexport function useRichTextRefs(req: KitRichTextRefRequest | null): { items: KitRichTextRef[]; loading: boolean; error?: string; unavailable: boolean } {\n const { resolveRichTextRefs } = useKitServices();\n const key = req ? JSON.stringify(req) : \"\";\n const [state, setState] = React.useState<{ key: string; items: KitRichTextRef[]; error?: string } | null>(null);\n React.useEffect(() => {\n if (!resolveRichTextRefs || !key) return;\n let live = true;\n resolveRichTextRefs(JSON.parse(key) as KitRichTextRefRequest).then(\n (items) => live && setState({ key, items }),\n (e: unknown) => live && setState({ key, items: [], error: e instanceof Error ? e.message : String(e) }),\n );\n return () => void (live = false);\n }, [resolveRichTextRefs, key]);\n if (!resolveRichTextRefs) return { items: [], loading: false, unavailable: true };\n if (!key) return { items: [], loading: false, unavailable: false };\n const done = state?.key === key ? state : null;\n return { items: done?.items ?? [], loading: !done, error: done?.error, unavailable: false };\n}\nlet registry: KitServices = {};\nconst listeners = new Set<() => void>();\n/** Register app services once at module load (e.g. the Content feature registers its media library). */\nexport function registerKitServices(s: KitServices) {\n registry = { ...registry, ...s };\n listeners.forEach((l) => l());\n}\nconst ServicesCtx = React.createContext<KitServices | null>(null);\nexport function KitServicesProvider({ value, children }: { value: KitServices; children: React.ReactNode }) {\n return <ServicesCtx.Provider value={value}>{children}</ServicesCtx.Provider>;\n}\nexport function useKitServices(): KitServices {\n const local = React.useContext(ServicesCtx);\n const global = React.useSyncExternalStore(\n (cb) => {\n listeners.add(cb);\n return () => listeners.delete(cb);\n },\n () => registry,\n () => registry,\n );\n return local ? { ...global, ...local } : global;\n}\n\n/** A host header element a top-level field (by path key) renders its actions into, instead of a label row. */\nexport const FieldHeaderSlot = React.createContext<{ key: string; el: HTMLElement } | null>(null);\n\n/* ── Environment ──────────────────────────────────────────────────────── */\nexport type KitVariant = \"panel\" | \"document\";\nexport interface KitPeer {\n id?: string;\n name: string;\n avatar?: string;\n /** presence colour (avatar ring, field border, caret flag) */\n color?: string;\n /** \"editing\" (soft lock + border) or \"viewing\" */\n status?: \"editing\" | \"viewing\";\n}\nexport interface Swatch {\n name: string;\n value: string;\n token?: string;\n}\n\n/** V2's demo site palette (Caldera). Hosts pass the project's brand palette through `env.palette`. */\nexport const SITE_PALETTE: Swatch[] = [\n { name: \"Ember\", value: \"#E0663B\", token: \"brand.ember\" },\n { name: \"Ochre\", value: \"#D97706\", token: \"brand.ochre\" },\n { name: \"Moss\", value: \"#4F6B4A\", token: \"brand.moss\" },\n { name: \"Lake\", value: \"#2563EB\", token: \"accent.lake\" },\n { name: \"Dusk\", value: \"#7C3AED\", token: \"accent.dusk\" },\n { name: \"Berry\", value: \"#DB2777\", token: \"accent.berry\" },\n { name: \"Char\", value: \"#1E1B18\", token: \"neutral.900\" },\n { name: \"Slate\", value: \"#4B5563\", token: \"neutral.600\" },\n { name: \"Bone\", value: \"#E7E0D6\", token: \"neutral.200\" },\n { name: \"Paper\", value: \"#F6F1EA\", token: \"neutral.50\" },\n];\n\nexport interface KitEnv {\n variant: KitVariant;\n /** Identity of the document/block being edited (rich-text sync, comments, history). */\n docId: string;\n /** The document's title — slug generation. */\n docTitle?: string;\n /** Public URL prefix for slug previews, e.g. \"caldera.bettercms.site/journal/\". */\n urlPrefix?: string;\n /** The document has been published (slug changes warn about the old address). */\n isPublished?: boolean;\n /**\n * The form's slug is the document's ADDRESS (a page's or an entry's URL). Only then does a changed slug on a published\n * document say the old address will stop working and offer the redirect. A slug prop or a key is not an address, so\n * it gets no such box (V2 draws it on document hosts only: its component-prop forms pass no published state).\n */\n slugIsAddress?: boolean;\n palette: Swatch[];\n /** The whole form is read-only for the lens (the host's content.edit rule, a generated twin…). */\n readOnly: boolean;\n /**\n * D58: the host's access check for the lens (`useCan` at the host). The kit never imports the store; it asks this for\n * field-level `access` and for developer surfaces (field keys, IDs, API names: `schema.view` or `api.view`).\n * Hosts that omit it (staff tools, demos) get allow-all.\n */\n can: (cap: Cap) => boolean;\n /** pathKey → teammates in that field */\n presence: Record<string, KitPeer[]>;\n /** pathKey → open comment threads */\n comments: Record<string, number>;\n /** Host comment panel. When absent, field comments live in the in-place popover only. */\n /** `quote`: the words selected in a rich text field when the comment came from its toolbar */\n onComment?: (path: FieldPath, field: FieldSchema, quote?: string) => void;\n /** The whole form is a global block (\"Navigation\") — every field is synced. */\n syncedFrom?: string;\n /** \"Open {title}\" on a reference card: the host edits the referenced entry in place (stacked panel). */\n onOpenReference?: (ref: { collectionId: string; entryId: string; title: string }) => void;\n /** CPO D39: \"inline\" (default) shows help under the label; \"tooltip\" moves it behind the ⓘ — for dense hosts (grid cells, popovers). */\n helpDisplay?: \"inline\" | \"tooltip\";\n /** D61 Review changes: the host's change markers, present only while its History panel is open. */\n review?: KitReview;\n /** D61 field ⋯ › History: the host opens its one History panel on this field. Absent = no History item. */\n onFieldHistory?: (path: FieldPath, field: FieldSchema) => void;\n /**\n * \"quiet\": a meta-form, like the schema editor's field settings (founder call, 2026-10-05). No comment, ⋯ or per-field\n * undo on the fields, and an on/off field is a label-left row with its switch on the right (the inspector's PRow), not a\n * switch card. \"preview\": the same chrome-free fields, controls exactly as editors see them (a schema preview, where a\n * comment would land on a sample, never a real document). Default \"full\".\n */\n fieldChrome?: \"full\" | \"preview\" | \"quiet\";\n /**\n * A host's own control for one field, by its path key (\"type\", \"options\"), drawn inside the usual shell. The schema\n * editor's field settings plug their Type, Options, Key and Show this field controls in here. Absent = kit controls only.\n */\n controls?: Record<string, React.ComponentType<ControlProps>>;\n /**\n * A collapsed fieldset's summary as chips, from the host (the schema editor's field settings: \"Required\", \"3 options\").\n * `undefined` falls back to the kit's own one-line summary. Keep it stable (a new function re-renders the form).\n */\n sectionSummary?: (set: Fieldset, value: Record<string, unknown>) => string[] | undefined;\n}\n\n/**\n * D61 Review changes, as the kit sees it. The host owns the history model; the kit only asks, per field path, whether\n * it changed in the range, and renders the host's marker (a 2px bar in the author's colour at the field's left edge,\n * with its hover card) where the at-rest \"changed\" dot would be.\n */\nexport interface KitReview {\n /** changes at or inside this field in the range (0 = unchanged) */\n count: (path: FieldPath) => number;\n /** the presence colour of whoever changed it last (list rows draw their own bar) */\n color: (path: FieldPath) => string | undefined;\n /** the host's change bar and hover card for a changed field (null when unchanged) */\n bar: (path: FieldPath, field: FieldSchema) => React.ReactNode;\n /** Show only changes: unchanged fields fold into one quiet line each run */\n onlyChanges: boolean;\n}\n\n/** The title of the fieldset a field sits in (null outside one). A quiet meta-form drops a field label that only repeats\n * its section's title (\"Options\" › \"Options\"): the section heading names it. */\nexport const KitSectionTitle = React.createContext<string | null>(null);\n/**\n * D66: the host's address row under a slug field (production URL, who serves it, the preview, live state). The host\n * knows the site's hosting; the kit only asks it to render the row for the slug being typed. Absent = the kit's own row.\n */\nexport const KitAddressContext = React.createContext<((slug: string) => React.ReactNode) | null>(null);\nexport const DEFAULT_ENV: KitEnv = {\n variant: \"panel\",\n docId: \"kit\",\n palette: [],\n readOnly: false,\n can: () => true,\n presence: {},\n comments: {},\n};\nconst EnvCtx = React.createContext<KitEnv>(DEFAULT_ENV);\n\n/** D58 field access: fields in the `seo` group default to `{ edit: \"seo.edit\" }`. */\nexport const fieldAccessOf = (field: FieldSchema): FieldAccess | undefined => field.access ?? (field.group === \"seo\" ? { edit: \"seo.edit\" } : undefined);\n\n/**\n * One field for the lens: hidden (no `view`), read-only (plain text: no `edit`, the field is `readOnly`, or the whole form\n * is read-only and the field has no edit cap of its own), or editable. An explicit `edit` cap wins over the form's\n * read-only rule, so an SEO specialist edits SEO fields inside a form they can't otherwise change.\n */\nexport function resolveFieldAccess(field: FieldSchema, env: Pick<KitEnv, \"can\" | \"readOnly\">): { hidden: boolean; readOnly: boolean } {\n const a = fieldAccessOf(field);\n if (a?.view && !env.can(a.view)) return { hidden: true, readOnly: true };\n if (field.readOnly === true) return { hidden: false, readOnly: true };\n if (a?.edit) return { hidden: false, readOnly: !env.can(a.edit) };\n return { hidden: false, readOnly: env.readOnly };\n}\n/** Drop the fields the lens can't `view` (recursively), so they are neither rendered nor validated. Same object back when\n * nothing is hidden. Values of dropped fields stay in the document untouched. */\nexport function visibleFields(fields: FieldSchema[], can: KitEnv[\"can\"]): FieldSchema[] {\n let changed = false;\n const out: FieldSchema[] = [];\n for (const f of fields) {\n const a = fieldAccessOf(f);\n if (a?.view && !can(a.view)) {\n changed = true;\n continue;\n }\n let g = f;\n if (f.fields) {\n const n = visibleFields(f.fields, can);\n if (n !== f.fields) g = { ...g, fields: n };\n }\n if (Array.isArray(f.of)) {\n const n = visibleFields(f.of, can);\n if (n !== f.of) g = { ...g, of: n };\n }\n if (f.slotSettings) {\n const n = visibleFields(f.slotSettings, can);\n if (n !== f.slotSettings) g = { ...g, slotSettings: n };\n }\n if (g !== f) changed = true;\n out.push(g);\n }\n return changed ? out : fields;\n}\nexport function visibleSchema(schema: TypeSchema, can: KitEnv[\"can\"]): TypeSchema {\n const fields = visibleFields(schema.fields, can);\n return fields === schema.fields ? schema : { ...schema, fields };\n}\n\n/** Developer surfaces (field keys, API names, IDs): `schema.view` or `api.view`. */\nexport const seesDevSurfaces = (env: Pick<KitEnv, \"can\">) => env.can(\"schema.view\") || env.can(\"api.view\");\nexport const KitEnvProvider = EnvCtx.Provider;\nexport const useKitEnv = () => React.useContext(EnvCtx);\n\n/* ── Form runtime (inside <SchemaForm>) ──────────────────────────────── */\nexport interface HistoryEntry {\n value: unknown;\n at: number;\n by: string;\n label?: string;\n}\nexport interface FormApi {\n schema: TypeSchema;\n value: Record<string, unknown>;\n /** write a value; `record: false` skips the field undo/history stack (e.g. programmatic sync) */\n setAt: (path: FieldPath, v: unknown, opts?: { record?: boolean; label?: string }) => void;\n getAt: (path: FieldPath) => unknown;\n /** value when the form mounted (field undo baseline) */\n baselineAt: (path: FieldPath) => unknown;\n /** published value (changed dot, Reset to published); undefined when never published */\n publishedAt: (path: FieldPath) => unknown;\n hasPublished: boolean;\n /** component instances (CPO D28): top-level fields inherit from a component unless overridden */\n inherited?: { from: string; isOverridden: (key: string) => boolean; reset: (key: string) => void };\n /** the current navigation path (drill-in stack) */\n path: FieldPath;\n navigate: (path: FieldPath) => void;\n /** the form draws frames for a non-root path. False while SchemaForm renders only the root frame: History and\n * drill-in rows hide or go inert instead of navigating to a path nothing shows (no silent no-op). */\n canNavigate: boolean;\n resolveSchema?: (blockType: string) => TypeSchema | undefined;\n /** blocks offered by \"+ Add block\" in slots (filtered by each slot's allow list) */\n blockLibrary?: TypeSchema[];\n /** all issues by pathKey */\n issues: Map<string, KitIssue>;\n /** the issue shown for a key (rules on blur, required after blur or a publish attempt) */\n visibleIssue: (key: string) => KitIssue | undefined;\n /** visible issues under a path prefix (rollup dots on rows, crumbs and tabs) */\n rollup: (prefix: FieldPath) => { errors: number; warnings: number };\n touch: (key: string) => void;\n showAllErrors: boolean;\n /** per-field undo (Undo last change to {label}) */\n canUndo: (key: string) => boolean;\n undo: (key: string) => void;\n /** versions of a field this session (newest first) */\n history: (key: string) => HistoryEntry[];\n /** the last change to this field came from AI (⋯ shows \"Undo AI change\") */\n aiKeys: Set<string>;\n markAi: (key: string, on: boolean) => void;\n /** remembered UI state per frame (selected group tab, open fieldsets) */\n memory: Map<string, unknown>;\n}\nconst FormCtx = React.createContext<FormApi | null>(null);\nexport const FormProvider = FormCtx.Provider;\nexport const useForm = () => React.useContext(FormCtx);\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,aAAgD;CAC3D;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAW,OAAO;CAAU;CAClC;EAAE,IAAI;EAAU,OAAO;CAAS;CAChC;EAAE,IAAI;EAAY,OAAO;CAAW;CACpC;EAAE,IAAI;EAAW,OAAO;CAAyB;CACjD;EAAE,IAAI;EAAa,OAAO;CAAuB;AACnD;;;;;AAmHA,SAAgB,gBAAgB,KAAwH;CACtJ,MAAM,EAAE,wBAAwB,eAAe;CAC/C,MAAM,MAAM,MAAM,KAAK,UAAU,GAAG,IAAI;CACxC,MAAM,CAAC,OAAO,YAAY,MAAM,SAA0E,IAAI;CAC9G,MAAM,gBAAgB;EACpB,IAAI,CAAC,uBAAuB,CAAC,KAAK;EAClC,IAAI,OAAO;EACX,oBAAoB,KAAK,MAAM,GAAG,CAA0B,CAAC,CAAC,MAC3D,UAAU,QAAQ,SAAS;GAAE;GAAK;EAAM,CAAC,IACzC,MAAe,QAAQ,SAAS;GAAE;GAAK,OAAO,CAAC;GAAG,OAAO,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;EAAE,CAAC,CACxG;EACA,aAAa,MAAM,OAAO;CAC5B,GAAG,CAAC,qBAAqB,GAAG,CAAC;CAC7B,IAAI,CAAC,qBAAqB,OAAO;EAAE,OAAO,CAAC;EAAG,SAAS;EAAO,aAAa;CAAK;CAChF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E,EAAE,GAAG;GACvB,MAAM,IAAI,cAAc,EAAE,IAAI,GAAG;GACjC,IAAI,MAAM,EAAE,IAAI,IAAI;IAAE,GAAG;IAAG,IAAI;GAAE;EACpC;EACA,IAAI,EAAE,cAAc;GAClB,MAAM,IAAI,cAAc,EAAE,cAAc,GAAG;GAC3C,IAAI,MAAM,EAAE,cAAc,IAAI;IAAE,GAAG;IAAG,cAAc;GAAE;EACxD;EACA,IAAI,MAAM,GAAG,UAAU;EACvB,IAAI,KAAK,CAAC;CACZ;CACA,OAAO,UAAU,MAAM;AACzB;AACA,SAAgB,cAAc,QAAoB,KAAgC;CAChF,MAAM,SAAS,cAAc,OAAO,QAAQ,GAAG;CAC/C,OAAO,WAAW,OAAO,SAAS,SAAS;EAAE,GAAG;EAAQ;CAAO;AACjE;;AAGA,IAAa,mBAAmB,QAA6B,IAAI,IAAI,aAAa,KAAK,IAAI,IAAI,UAAU;AACzG,IAAa,iBAAiB,OAAO;AACrC,IAAa,kBAAkB,MAAM,WAAW,MAAM;AAkDtD,IAAM,UAAU,MAAM,cAA8B,IAAI;AACxD,IAAa,eAAe,QAAQ;AACpC,IAAa,gBAAgB,MAAM,WAAW,OAAO"}
@@ -1,7 +1,7 @@
1
1
  import { BUTTON_VARIANTS, DOCK_ICON_NAME_SET } from "../adapters/prod-types.js";
2
+ import { isObj } from "../lib/path.js";
2
3
  import { cn } from "../lib/cn.js";
3
4
  import { useForm, useKitEnv } from "../context.js";
4
- import { isObj } from "../lib/path.js";
5
5
  import { KIT_ICONS, KitIcon, iconLabel } from "../lib/icons.js";
6
6
  import { Segmented, Switch } from "../ui/controls.js";
7
7
  import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "../ui/overlay.js";
@@ -1,3 +1,17 @@
1
+ /**
2
+ * CODE — the code field (DESIGN 8.21), V2 controls/misc.tsx (CodeSurface, CodeControl) fitted to what prod stores.
3
+ *
4
+ * Values (backend reference-validation `code`, adapters/values.ts codeToProd):
5
+ * "<p>hi</p>" a bare string, kept a string
6
+ * { language?: "html", code: "…" } the object form; only `code` and `language` are written back
7
+ * The language list sits in the surface header. Picking one writes the object form; a value that never changes its
8
+ * language keeps the shape it was stored in. A value over CODE_MAX_LENGTH characters is refused with the reason.
9
+ *
10
+ * Panel: a one-line summary button that opens a `lg` dialog editing a draft (Cancel / Done). Document: the surface
11
+ * inline. The surface: mono 12/20 textarea with line numbers, Tab inserts two spaces (Shift+Tab leaves the field),
12
+ * Copy, and for JSON a Format action and a live "Invalid JSON · {reason}" footer (json.tsx).
13
+ */
14
+ import * as React from "react";
1
15
  import type { ControlProps } from "../types";
2
16
  /** Why a JSON text does not parse ("" when it does, or is empty). */
3
17
  export declare function jsonProblem(text: string): string;
@@ -17,8 +31,17 @@ export interface CodeSurfaceProps {
17
31
  minRows?: number;
18
32
  label?: string;
19
33
  describedBy?: string;
34
+ /** The host's own findings, a line each (V2 Schema editor WP3). Given, they replace the built-in check: their lines are
35
+ * marked in the gutter and the messages list under the code. */
36
+ diagnostics?: {
37
+ line?: number;
38
+ message: string;
39
+ hint?: string;
40
+ }[];
41
+ /** The host's own header actions, before Format and Copy. */
42
+ actions?: React.ReactNode;
20
43
  }
21
- export declare function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows, label, describedBy }: CodeSurfaceProps): import("react/jsx-runtime").JSX.Element;
44
+ export declare function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows, label, describedBy, diagnostics, actions }: CodeSurfaceProps): import("react/jsx-runtime").JSX.Element;
22
45
  export declare function CodeDialogField({ kind, title, description, text, readOnly, id, invalid, language, languages, onDone, }: {
23
46
  kind: "json" | "code";
24
47
  title: string;
@@ -1,7 +1,7 @@
1
1
  import { CODE_MAX_LENGTH } from "../adapters/prod-types.js";
2
+ import { isObj } from "../lib/path.js";
2
3
  import { cn } from "../lib/cn.js";
3
4
  import { useKitEnv, useKitServices } from "../context.js";
4
- import { isObj } from "../lib/path.js";
5
5
  import { Button } from "../ui/button.js";
6
6
  import { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from "../ui/overlay.js";
7
7
  import { Select } from "../ui/select.js";
@@ -85,10 +85,12 @@ function jsonProblem(text) {
85
85
  return e.message.replace(/^JSON\.parse: /, "");
86
86
  }
87
87
  }
88
- function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows = 8, label, describedBy }) {
88
+ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows = 8, label, describedBy, diagnostics, actions }) {
89
89
  const { toast } = useKitServices();
90
90
  const lines = Math.max(minRows, value.split("\n").length);
91
- const problem = kind === "json" ? jsonProblem(value) : value.length > 1e5 ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString("en-US")} characters; this has ${value.length.toLocaleString("en-US")}.` : "";
91
+ const marked = new Set((diagnostics ?? []).map((d) => d.line).filter((n) => !!n));
92
+ const problem = diagnostics ? "" : kind === "json" ? jsonProblem(value) : value.length > 1e5 ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString("en-US")} characters; this has ${value.length.toLocaleString("en-US")}.` : "";
93
+ const flagged = !!problem || !!diagnostics?.length;
92
94
  const footerId = id ? `${id}-problem` : void 0;
93
95
  const format = () => {
94
96
  try {
@@ -103,13 +105,13 @@ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, r
103
105
  toast?.success("Copied");
104
106
  };
105
107
  return /* @__PURE__ */ jsxs("div", {
106
- className: cn("overflow-hidden rounded-kit-lg border bg-kit-subtle", invalid || problem ? "border-[var(--kit-field-invalid)]" : "border-kit-line"),
108
+ className: cn("overflow-hidden rounded-kit-lg border bg-kit-subtle", invalid || flagged ? "border-[var(--kit-field-invalid)]" : "border-kit-line"),
107
109
  children: [
108
110
  /* @__PURE__ */ jsxs("div", {
109
111
  className: "flex h-8 items-center justify-between border-b border-kit-line px-2",
110
112
  children: [kind === "json" ? /* @__PURE__ */ jsx("span", {
111
113
  className: "px-1 font-kit-mono text-kit-xs text-kit-fg-3",
112
- children: "JSON"
114
+ children: label ?? "JSON"
113
115
  }) : onLanguage ? /* @__PURE__ */ jsx(Select, {
114
116
  "aria-label": "Code language",
115
117
  size: "sm",
@@ -123,18 +125,22 @@ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, r
123
125
  children: "Code"
124
126
  }), /* @__PURE__ */ jsxs("div", {
125
127
  className: "flex items-center gap-1",
126
- children: [kind === "json" ? /* @__PURE__ */ jsx("button", {
127
- type: "button",
128
- disabled: readOnly,
129
- className: "rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg",
130
- onClick: format,
131
- children: "Format"
132
- }) : null, /* @__PURE__ */ jsx("button", {
133
- type: "button",
134
- className: "rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg",
135
- onClick: copy,
136
- children: "Copy"
137
- })]
128
+ children: [
129
+ actions,
130
+ kind === "json" ? /* @__PURE__ */ jsx("button", {
131
+ type: "button",
132
+ disabled: readOnly,
133
+ className: "rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg",
134
+ onClick: format,
135
+ children: "Format"
136
+ }) : null,
137
+ /* @__PURE__ */ jsx("button", {
138
+ type: "button",
139
+ className: "rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg",
140
+ onClick: copy,
141
+ children: "Copy"
142
+ })
143
+ ]
138
144
  })]
139
145
  }),
140
146
  /* @__PURE__ */ jsxs("div", {
@@ -142,7 +148,10 @@ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, r
142
148
  children: [/* @__PURE__ */ jsx("div", {
143
149
  "aria-hidden": true,
144
150
  className: "select-none border-r border-kit-line bg-kit-subtle px-2 py-2 text-right text-kit-fg-4",
145
- children: Array.from({ length: lines }).map((_, i) => /* @__PURE__ */ jsx("div", { children: i + 1 }, i))
151
+ children: Array.from({ length: lines }).map((_, i) => /* @__PURE__ */ jsx("div", {
152
+ className: marked.has(i + 1) ? "bg-kit-danger-soft text-kit-danger-fg" : void 0,
153
+ children: i + 1
154
+ }, i))
146
155
  }), /* @__PURE__ */ jsx("textarea", {
147
156
  id,
148
157
  spellCheck: false,
@@ -150,9 +159,9 @@ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, r
150
159
  autoCorrect: "off",
151
160
  value,
152
161
  readOnly,
153
- "aria-invalid": invalid || !!problem || void 0,
162
+ "aria-invalid": invalid || flagged || void 0,
154
163
  "aria-label": label,
155
- "aria-describedby": [describedBy, problem ? footerId : void 0].filter(Boolean).join(" ") || void 0,
164
+ "aria-describedby": [describedBy, flagged ? footerId : void 0].filter(Boolean).join(" ") || void 0,
156
165
  onChange: (e) => onChange(e.target.value),
157
166
  onKeyDown: (e) => {
158
167
  if (e.key === "Tab" && !e.shiftKey && !readOnly) {
@@ -171,6 +180,13 @@ function CodeSurface({ kind, value, onChange, language, onLanguage, languages, r
171
180
  id: footerId,
172
181
  className: "border-t border-kit-danger-line bg-kit-danger-soft px-3 py-1.5 text-kit-xs text-kit-danger-fg",
173
182
  children: kind === "json" ? `Invalid JSON · ${problem}` : problem
183
+ }) : diagnostics?.length ? /* @__PURE__ */ jsx("ul", {
184
+ id: footerId,
185
+ className: "flex flex-col gap-1 border-t border-kit-danger-line bg-kit-danger-soft px-3 py-1.5 text-kit-xs text-kit-danger-fg",
186
+ children: diagnostics.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [d.message, d.hint ? /* @__PURE__ */ jsx("span", {
187
+ className: "block font-kit-mono text-kit-fg-3",
188
+ children: d.hint
189
+ }) : null] }, i))
174
190
  }) : null
175
191
  ]
176
192
  });
@@ -1 +1 @@
1
- {"version":3,"file":"code.js","names":[],"sources":["../../src/controls/code.tsx"],"sourcesContent":["/**\n * CODE — the code field (DESIGN 8.21), V2 controls/misc.tsx (CodeSurface, CodeControl) fitted to what prod stores.\n *\n * Values (backend reference-validation `code`, adapters/values.ts codeToProd):\n * \"<p>hi</p>\" a bare string, kept a string\n * { language?: \"html\", code: \"…\" } the object form; only `code` and `language` are written back\n * The language list sits in the surface header. Picking one writes the object form; a value that never changes its\n * language keeps the shape it was stored in. A value over CODE_MAX_LENGTH characters is refused with the reason.\n *\n * Panel: a one-line summary button that opens a `lg` dialog editing a draft (Cancel / Done). Document: the surface\n * inline. The surface: mono 12/20 textarea with line numbers, Tab inserts two spaces (Shift+Tab leaves the field),\n * Copy, and for JSON a Format action and a live \"Invalid JSON · {reason}\" footer (json.tsx).\n */\nimport * as React from \"react\";\nimport { IconAlertTriangle, IconBraces, IconCode, IconMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { useKitEnv, useKitServices } from \"../context\";\nimport { CODE_MAX_LENGTH } from \"../adapters/prod-types\";\nimport type { ControlProps } from \"../types\";\nimport { Button } from \"../ui/button\";\nimport { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from \"../ui/overlay\";\nimport { Select } from \"../ui/select\";\n\nconst CODE_LANGUAGES: { value: string; label: string }[] = [\n { value: \"html\", label: \"HTML\" },\n { value: \"css\", label: \"CSS\" },\n { value: \"js\", label: \"JS\" },\n { value: \"ts\", label: \"TS\" },\n { value: \"json\", label: \"JSON\" },\n { value: \"liquid\", label: \"Liquid\" },\n { value: \"markdown\", label: \"Markdown\" },\n { value: \"shell\", label: \"Shell\" },\n];\nconst PLAIN = \"plain\";\n\n/** The picker: Plain text, then the field's allowed languages (or the built-in list), then the stored one if it is outside them. */\nfunction languageOptions(language: string | undefined, allowed: string[] | undefined) {\n const list = allowed ? allowed.map((v) => CODE_LANGUAGES.find((l) => l.value === v) ?? { value: v, label: v }) : CODE_LANGUAGES;\n return [{ value: PLAIN, label: \"Plain text\" }, ...list, ...(language && !list.some((l) => l.value === language) ? [{ value: language, label: language }] : [])];\n}\n\n/** Why a JSON text does not parse (\"\" when it does, or is empty). */\nexport function jsonProblem(text: string): string {\n if (!text.trim()) return \"\";\n try {\n JSON.parse(text);\n return \"\";\n } catch (e) {\n return (e as Error).message.replace(/^JSON\\.parse: /, \"\");\n }\n}\n\n/* ── The surface ──────────────────────────────────────────────────────── */\nexport interface CodeSurfaceProps {\n /** \"json\": the JSON header, Format and the parse footer. \"code\": the language list. */\n kind: \"json\" | \"code\";\n value: string;\n onChange: (v: string) => void;\n /** code: the language shown in the header (\"\" = none) and what picking one does; absent = no list */\n language?: string;\n onLanguage?: (language: string) => void;\n /** code: the only languages the field allows (its config.languages); absent = the built-in list */\n languages?: string[];\n readOnly?: boolean;\n id?: string;\n invalid?: boolean;\n minRows?: number;\n label?: string;\n describedBy?: string;\n}\n\nexport function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows = 8, label, describedBy }: CodeSurfaceProps) {\n const { toast } = useKitServices();\n const lines = Math.max(minRows, value.split(\"\\n\").length);\n const problem = kind === \"json\" ? jsonProblem(value) : value.length > CODE_MAX_LENGTH ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString(\"en-US\")} characters; this has ${value.length.toLocaleString(\"en-US\")}.` : \"\";\n const footerId = id ? `${id}-problem` : undefined;\n const format = () => {\n try {\n onChange(JSON.stringify(JSON.parse(value), null, 2));\n toast?.success(\"JSON formatted\");\n } catch {\n toast?.(\"Fix the JSON before formatting\");\n }\n };\n const copy = () => {\n void navigator.clipboard?.writeText(value);\n toast?.success(\"Copied\");\n };\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border bg-kit-subtle\", invalid || problem ? \"border-[var(--kit-field-invalid)]\" : \"border-kit-line\")}>\n <div className=\"flex h-8 items-center justify-between border-b border-kit-line px-2\">\n {kind === \"json\" ? (\n <span className=\"px-1 font-kit-mono text-kit-xs text-kit-fg-3\">JSON</span>\n ) : onLanguage ? (\n <Select\n aria-label=\"Code language\"\n size=\"sm\"\n variant=\"ghost\"\n disabled={readOnly}\n value={language || PLAIN}\n onValueChange={(l) => onLanguage(l === PLAIN ? \"\" : l)}\n options={languageOptions(language, languages)}\n />\n ) : (\n <span className=\"px-1 font-kit-mono text-kit-xs text-kit-fg-3\">Code</span>\n )}\n <div className=\"flex items-center gap-1\">\n {kind === \"json\" ? (\n <button type=\"button\" disabled={readOnly} className=\"rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\" onClick={format}>\n Format\n </button>\n ) : null}\n <button type=\"button\" className=\"rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\" onClick={copy}>\n Copy\n </button>\n </div>\n </div>\n <div className=\"flex max-h-[60vh] overflow-auto font-kit-mono text-kit-xs leading-5\">\n <div aria-hidden className=\"select-none border-r border-kit-line bg-kit-subtle px-2 py-2 text-right text-kit-fg-4\">\n {Array.from({ length: lines }).map((_, i) => (\n <div key={i}>{i + 1}</div>\n ))}\n </div>\n <textarea\n id={id}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n value={value}\n readOnly={readOnly}\n aria-invalid={invalid || !!problem || undefined}\n aria-label={label}\n aria-describedby={[describedBy, problem ? footerId : undefined].filter(Boolean).join(\" \") || undefined}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Tab\" && !e.shiftKey && !readOnly) {\n e.preventDefault();\n const el = e.currentTarget;\n const s = el.selectionStart;\n onChange(value.slice(0, s) + \" \" + value.slice(el.selectionEnd));\n requestAnimationFrame(() => el.setSelectionRange(s + 2, s + 2));\n }\n }}\n style={{ height: lines * 20 + 16 }}\n className=\"min-w-0 flex-1 resize-none bg-kit-field-bg px-3 py-2 text-kit-fg outline-none\"\n />\n </div>\n {problem ? (\n <div id={footerId} className=\"border-t border-kit-danger-line bg-kit-danger-soft px-3 py-1.5 text-kit-xs text-kit-danger-fg\">\n {kind === \"json\" ? `Invalid JSON · ${problem}` : problem}\n </div>\n ) : null}\n </div>\n );\n}\n\n/* ── Panel: summary button + dialog over a draft ─────────────────────── */\nexport function CodeDialogField({\n kind, title, description, text, readOnly, id, invalid, language, languages, onDone,\n}: {\n kind: \"json\" | \"code\";\n title: string;\n description?: string;\n text: string;\n readOnly?: boolean;\n id: string;\n invalid?: boolean;\n language?: string;\n languages?: string[];\n /** commit the draft; returns the reason it can't be saved, or null when saved */\n onDone: (draft: string, language: string | undefined) => string | null;\n}) {\n const { toast } = useKitServices();\n const [open, setOpen] = React.useState(false);\n const [draft, setDraft] = React.useState(text);\n const [lang, setLang] = React.useState(language);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const first = text.split(\"\\n\").find((l) => l.trim()) ?? \"\";\n const Icon = kind === \"json\" ? IconBraces : IconCode;\n return (\n <>\n <button\n id={id}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-invalid={invalid || undefined}\n onClick={() => {\n setDraft(text);\n setLang(language);\n setRefusal(null);\n setOpen(true);\n }}\n className={cn(\n \"group/code flex w-full items-center gap-2 rounded-kit-md border border-kit-line bg-kit-subtle px-2.5 py-2 text-left transition-colors hover:border-kit-line-strong\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n )}\n >\n <Icon className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <span className={cn(\"min-w-0 flex-1 truncate font-kit-mono text-kit-xs\", first ? \"text-kit-fg-2\" : \"text-kit-fg-3\")}>{first || \"Empty\"}</span>\n <span className=\"tabular-nums shrink-0 text-kit-2xs text-kit-fg-3\">{text ? `${text.split(\"\\n\").length} lines` : \"\"}</span>\n <IconMaximize className=\"size-3.5 shrink-0 text-kit-fg-3 group-hover/code:text-kit-fg\" stroke={1.5} aria-hidden />\n </button>\n <Modal open={open} onOpenChange={setOpen}>\n <ModalContent size=\"lg\">\n <ModalHeader title={title} description={description ?? (kind === \"json\" ? \"Structured data for developers\" : \"Custom code\")} />\n <ModalBody>\n <CodeSurface kind={kind} value={draft} onChange={setDraft} language={lang ?? \"\"} onLanguage={kind === \"code\" ? setLang : undefined} languages={languages} readOnly={readOnly} minRows={14} label={title} />\n {refusal ? (\n <p role=\"alert\" className=\"mt-2 flex items-start gap-1.5 text-kit-xs text-kit-danger-fg\">\n <IconAlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {refusal}\n </p>\n ) : null}\n </ModalBody>\n <ModalFooter>\n <span data-hint=\"shortcuts\" className=\"text-kit-xs text-kit-fg-3\">\n Esc to close\n </span>\n <span className=\"mr-auto\" aria-hidden />\n <Button variant=\"ghost\" onClick={() => setOpen(false)}>\n Cancel\n </Button>\n <Button\n variant=\"primary\"\n disabled={readOnly}\n onClick={() => {\n const why = onDone(draft, lang);\n if (why) {\n setRefusal(why);\n toast?.(kind === \"json\" ? \"Invalid JSON\" : \"Can't save this code\", { description: \"Fix it before saving.\" });\n return;\n }\n setOpen(false);\n }}\n >\n Done\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n </>\n );\n}\n\n/* ── The control ──────────────────────────────────────────────────────── */\ntype CodeRead = { ok: true; code: string; language?: string; object: boolean } | { ok: false };\nfunction readCode(v: unknown): CodeRead {\n if (v == null) return { ok: true, code: \"\", object: false };\n if (typeof v === \"string\") return { ok: true, code: v, object: false };\n if (isObj(v) && typeof v.code === \"string\" && (v.language === undefined || typeof v.language === \"string\")) return { ok: true, code: v.code, language: v.language as string | undefined, object: true };\n return { ok: false };\n}\n\n/** The stored shape for edited code: a string stays a string until a language is picked; the object keeps its form. */\nfunction codeValue(prev: CodeRead & { ok: true }, code: string, language: string | undefined): string | { language?: string; code: string } {\n const lang = language ?? prev.language ?? \"\";\n if (!prev.object && !lang) return code;\n return lang ? { language: lang, code } : { code };\n}\nconst tooLong = (code: string) => (code.length > CODE_MAX_LENGTH ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString(\"en-US\")} characters; this has ${code.length.toLocaleString(\"en-US\")}.` : null);\n\nexport function CodeControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { variant } = useKitEnv();\n const [refused, setRefused] = React.useState<string | null>(null);\n const read = readCode(value);\n if (!read.ok) return <UnreadableValue id={id} title={field.title} kind=\"code\" value={value} />;\n if (variant === \"document\")\n return (\n <div className=\"flex flex-col gap-1.5\">\n <CodeSurface\n kind=\"code\"\n id={id}\n invalid={invalid || !!refused}\n readOnly={readOnly}\n value={read.code}\n language={read.language ?? \"\"}\n languages={field.languages}\n onChange={(code) => {\n const why = tooLong(code);\n setRefused(why);\n if (!why) onChange(codeValue(read, code, undefined));\n }}\n onLanguage={(l) => onChange(codeValue(read, read.code, l))}\n />\n {refused ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refused}\n </p>\n ) : null}\n </div>\n );\n return (\n <CodeDialogField\n kind=\"code\"\n id={id}\n title={field.title}\n description={field.description || undefined}\n text={read.code}\n language={read.language}\n languages={field.languages}\n readOnly={readOnly}\n invalid={invalid}\n onDone={(draft, lang) => {\n const why = tooLong(draft);\n if (why) return why;\n const next = codeValue(read, draft, lang);\n if (draft !== read.code || (lang ?? \"\") !== (read.language ?? \"\")) onChange(next);\n return null;\n }}\n />\n );\n}\n\n/** A stored value the control cannot read: named, shown, kept as it is (never replaced by a stray edit). */\nexport function UnreadableValue({ id, title, kind, value }: { id: string; title: string; kind: string; value: unknown }) {\n let raw: string;\n try {\n raw = typeof value === \"string\" ? value : JSON.stringify(value, null, 2);\n } catch {\n raw = String(value);\n }\n return (\n <output\n id={id}\n tabIndex={0}\n data-slot={`${kind}-unreadable`}\n className=\"flex min-w-0 items-start gap-2 rounded-kit-md border border-dashed border-kit-line-strong bg-kit-subtle px-2.5 py-2 text-kit-xs text-kit-fg-2 outline-none focus-visible:outline-2 focus-visible:outline-kit-focus-ring\"\n >\n <IconAlertTriangle className=\"mt-0.5 size-3.5 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0\">\n {title} holds a value this {kind} editor can't read, so it is kept as it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AAO,MAAM,SAAsE;CACvH,IAAI;CACJ,IAAI;EACF,MAAM,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,OAAO,MAAM,CAAC;CACzE,QAAQ;EACN,MAAM,OAAO,KAAK;CACpB;CACA,OACE,qBAAC,UAAD;EACM;EACJ,UAAU;EACV,aAAW,GAAG,KAAK;EACnB,WAAU;EAJZ,UAAA,CAME,oBAAC,mBAAD;GAAmB,WAAU;GAA+C,QAAQ;GAAK,eAAA;EAAa,CAAA,GACtG,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA;IACG;IAAM;IAAqB;IAAK;IAA4C;IAC7E,oBAAC,QAAD;KAAM,WAAU;KAAwF,UAAA;IAAU,CAAA;GAC9G;EACA,CAAA,CAAA;;AAEZ"}
1
+ {"version":3,"file":"code.js","names":[],"sources":["../../src/controls/code.tsx"],"sourcesContent":["/**\n * CODE — the code field (DESIGN 8.21), V2 controls/misc.tsx (CodeSurface, CodeControl) fitted to what prod stores.\n *\n * Values (backend reference-validation `code`, adapters/values.ts codeToProd):\n * \"<p>hi</p>\" a bare string, kept a string\n * { language?: \"html\", code: \"…\" } the object form; only `code` and `language` are written back\n * The language list sits in the surface header. Picking one writes the object form; a value that never changes its\n * language keeps the shape it was stored in. A value over CODE_MAX_LENGTH characters is refused with the reason.\n *\n * Panel: a one-line summary button that opens a `lg` dialog editing a draft (Cancel / Done). Document: the surface\n * inline. The surface: mono 12/20 textarea with line numbers, Tab inserts two spaces (Shift+Tab leaves the field),\n * Copy, and for JSON a Format action and a live \"Invalid JSON · {reason}\" footer (json.tsx).\n */\nimport * as React from \"react\";\nimport { IconAlertTriangle, IconBraces, IconCode, IconMaximize } from \"@tabler/icons-react\";\nimport { cn } from \"../lib/cn\";\nimport { isObj } from \"../lib/path\";\nimport { useKitEnv, useKitServices } from \"../context\";\nimport { CODE_MAX_LENGTH } from \"../adapters/prod-types\";\nimport type { ControlProps } from \"../types\";\nimport { Button } from \"../ui/button\";\nimport { Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from \"../ui/overlay\";\nimport { Select } from \"../ui/select\";\n\nconst CODE_LANGUAGES: { value: string; label: string }[] = [\n { value: \"html\", label: \"HTML\" },\n { value: \"css\", label: \"CSS\" },\n { value: \"js\", label: \"JS\" },\n { value: \"ts\", label: \"TS\" },\n { value: \"json\", label: \"JSON\" },\n { value: \"liquid\", label: \"Liquid\" },\n { value: \"markdown\", label: \"Markdown\" },\n { value: \"shell\", label: \"Shell\" },\n];\nconst PLAIN = \"plain\";\n\n/** The picker: Plain text, then the field's allowed languages (or the built-in list), then the stored one if it is outside them. */\nfunction languageOptions(language: string | undefined, allowed: string[] | undefined) {\n const list = allowed ? allowed.map((v) => CODE_LANGUAGES.find((l) => l.value === v) ?? { value: v, label: v }) : CODE_LANGUAGES;\n return [{ value: PLAIN, label: \"Plain text\" }, ...list, ...(language && !list.some((l) => l.value === language) ? [{ value: language, label: language }] : [])];\n}\n\n/** Why a JSON text does not parse (\"\" when it does, or is empty). */\nexport function jsonProblem(text: string): string {\n if (!text.trim()) return \"\";\n try {\n JSON.parse(text);\n return \"\";\n } catch (e) {\n return (e as Error).message.replace(/^JSON\\.parse: /, \"\");\n }\n}\n\n/* ── The surface ──────────────────────────────────────────────────────── */\nexport interface CodeSurfaceProps {\n /** \"json\": the JSON header, Format and the parse footer. \"code\": the language list. */\n kind: \"json\" | \"code\";\n value: string;\n onChange: (v: string) => void;\n /** code: the language shown in the header (\"\" = none) and what picking one does; absent = no list */\n language?: string;\n onLanguage?: (language: string) => void;\n /** code: the only languages the field allows (its config.languages); absent = the built-in list */\n languages?: string[];\n readOnly?: boolean;\n id?: string;\n invalid?: boolean;\n minRows?: number;\n label?: string;\n describedBy?: string;\n /** The host's own findings, a line each (V2 Schema editor WP3). Given, they replace the built-in check: their lines are\n * marked in the gutter and the messages list under the code. */\n diagnostics?: { line?: number; message: string; hint?: string }[];\n /** The host's own header actions, before Format and Copy. */\n actions?: React.ReactNode;\n}\n\nexport function CodeSurface({ kind, value, onChange, language, onLanguage, languages, readOnly, id, invalid, minRows = 8, label, describedBy, diagnostics, actions }: CodeSurfaceProps) {\n const { toast } = useKitServices();\n const lines = Math.max(minRows, value.split(\"\\n\").length);\n const marked = new Set((diagnostics ?? []).map((d) => d.line).filter((n): n is number => !!n));\n const problem = diagnostics ? \"\" : kind === \"json\" ? jsonProblem(value) : value.length > CODE_MAX_LENGTH ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString(\"en-US\")} characters; this has ${value.length.toLocaleString(\"en-US\")}.` : \"\";\n const flagged = !!problem || !!diagnostics?.length;\n const footerId = id ? `${id}-problem` : undefined;\n const format = () => {\n try {\n onChange(JSON.stringify(JSON.parse(value), null, 2));\n toast?.success(\"JSON formatted\");\n } catch {\n toast?.(\"Fix the JSON before formatting\");\n }\n };\n const copy = () => {\n void navigator.clipboard?.writeText(value);\n toast?.success(\"Copied\");\n };\n return (\n <div className={cn(\"overflow-hidden rounded-kit-lg border bg-kit-subtle\", invalid || flagged ? \"border-[var(--kit-field-invalid)]\" : \"border-kit-line\")}>\n <div className=\"flex h-8 items-center justify-between border-b border-kit-line px-2\">\n {kind === \"json\" ? (\n <span className=\"px-1 font-kit-mono text-kit-xs text-kit-fg-3\">{label ?? \"JSON\"}</span>\n ) : onLanguage ? (\n <Select\n aria-label=\"Code language\"\n size=\"sm\"\n variant=\"ghost\"\n disabled={readOnly}\n value={language || PLAIN}\n onValueChange={(l) => onLanguage(l === PLAIN ? \"\" : l)}\n options={languageOptions(language, languages)}\n />\n ) : (\n <span className=\"px-1 font-kit-mono text-kit-xs text-kit-fg-3\">Code</span>\n )}\n <div className=\"flex items-center gap-1\">\n {actions}\n {kind === \"json\" ? (\n <button type=\"button\" disabled={readOnly} className=\"rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\" onClick={format}>\n Format\n </button>\n ) : null}\n <button type=\"button\" className=\"rounded-kit-md px-1.5 py-0.5 text-kit-xs text-kit-fg-2 hover:bg-kit-hover hover:text-kit-fg\" onClick={copy}>\n Copy\n </button>\n </div>\n </div>\n <div className=\"flex max-h-[60vh] overflow-auto font-kit-mono text-kit-xs leading-5\">\n <div aria-hidden className=\"select-none border-r border-kit-line bg-kit-subtle px-2 py-2 text-right text-kit-fg-4\">\n {Array.from({ length: lines }).map((_, i) => (\n <div key={i} className={marked.has(i + 1) ? \"bg-kit-danger-soft text-kit-danger-fg\" : undefined}>\n {i + 1}\n </div>\n ))}\n </div>\n <textarea\n id={id}\n spellCheck={false}\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n value={value}\n readOnly={readOnly}\n aria-invalid={invalid || flagged || undefined}\n aria-label={label}\n aria-describedby={[describedBy, flagged ? footerId : undefined].filter(Boolean).join(\" \") || undefined}\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Tab\" && !e.shiftKey && !readOnly) {\n e.preventDefault();\n const el = e.currentTarget;\n const s = el.selectionStart;\n onChange(value.slice(0, s) + \" \" + value.slice(el.selectionEnd));\n requestAnimationFrame(() => el.setSelectionRange(s + 2, s + 2));\n }\n }}\n style={{ height: lines * 20 + 16 }}\n className=\"min-w-0 flex-1 resize-none bg-kit-field-bg px-3 py-2 text-kit-fg outline-none\"\n />\n </div>\n {problem ? (\n <div id={footerId} className=\"border-t border-kit-danger-line bg-kit-danger-soft px-3 py-1.5 text-kit-xs text-kit-danger-fg\">\n {kind === \"json\" ? `Invalid JSON · ${problem}` : problem}\n </div>\n ) : diagnostics?.length ? (\n <ul id={footerId} className=\"flex flex-col gap-1 border-t border-kit-danger-line bg-kit-danger-soft px-3 py-1.5 text-kit-xs text-kit-danger-fg\">\n {diagnostics.map((d, i) => (\n <li key={i}>\n {d.message}\n {d.hint ? <span className=\"block font-kit-mono text-kit-fg-3\">{d.hint}</span> : null}\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n\n/* ── Panel: summary button + dialog over a draft ─────────────────────── */\nexport function CodeDialogField({\n kind, title, description, text, readOnly, id, invalid, language, languages, onDone,\n}: {\n kind: \"json\" | \"code\";\n title: string;\n description?: string;\n text: string;\n readOnly?: boolean;\n id: string;\n invalid?: boolean;\n language?: string;\n languages?: string[];\n /** commit the draft; returns the reason it can't be saved, or null when saved */\n onDone: (draft: string, language: string | undefined) => string | null;\n}) {\n const { toast } = useKitServices();\n const [open, setOpen] = React.useState(false);\n const [draft, setDraft] = React.useState(text);\n const [lang, setLang] = React.useState(language);\n const [refusal, setRefusal] = React.useState<string | null>(null);\n const first = text.split(\"\\n\").find((l) => l.trim()) ?? \"\";\n const Icon = kind === \"json\" ? IconBraces : IconCode;\n return (\n <>\n <button\n id={id}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-invalid={invalid || undefined}\n onClick={() => {\n setDraft(text);\n setLang(language);\n setRefusal(null);\n setOpen(true);\n }}\n className={cn(\n \"group/code flex w-full items-center gap-2 rounded-kit-md border border-kit-line bg-kit-subtle px-2.5 py-2 text-left transition-colors hover:border-kit-line-strong\",\n invalid && \"border-[var(--kit-field-invalid)]\",\n )}\n >\n <Icon className=\"size-4 shrink-0 text-kit-fg-3\" stroke={1.5} aria-hidden />\n <span className={cn(\"min-w-0 flex-1 truncate font-kit-mono text-kit-xs\", first ? \"text-kit-fg-2\" : \"text-kit-fg-3\")}>{first || \"Empty\"}</span>\n <span className=\"tabular-nums shrink-0 text-kit-2xs text-kit-fg-3\">{text ? `${text.split(\"\\n\").length} lines` : \"\"}</span>\n <IconMaximize className=\"size-3.5 shrink-0 text-kit-fg-3 group-hover/code:text-kit-fg\" stroke={1.5} aria-hidden />\n </button>\n <Modal open={open} onOpenChange={setOpen}>\n <ModalContent size=\"lg\">\n <ModalHeader title={title} description={description ?? (kind === \"json\" ? \"Structured data for developers\" : \"Custom code\")} />\n <ModalBody>\n <CodeSurface kind={kind} value={draft} onChange={setDraft} language={lang ?? \"\"} onLanguage={kind === \"code\" ? setLang : undefined} languages={languages} readOnly={readOnly} minRows={14} label={title} />\n {refusal ? (\n <p role=\"alert\" className=\"mt-2 flex items-start gap-1.5 text-kit-xs text-kit-danger-fg\">\n <IconAlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" stroke={1.5} aria-hidden />\n {refusal}\n </p>\n ) : null}\n </ModalBody>\n <ModalFooter>\n <span data-hint=\"shortcuts\" className=\"text-kit-xs text-kit-fg-3\">\n Esc to close\n </span>\n <span className=\"mr-auto\" aria-hidden />\n <Button variant=\"ghost\" onClick={() => setOpen(false)}>\n Cancel\n </Button>\n <Button\n variant=\"primary\"\n disabled={readOnly}\n onClick={() => {\n const why = onDone(draft, lang);\n if (why) {\n setRefusal(why);\n toast?.(kind === \"json\" ? \"Invalid JSON\" : \"Can't save this code\", { description: \"Fix it before saving.\" });\n return;\n }\n setOpen(false);\n }}\n >\n Done\n </Button>\n </ModalFooter>\n </ModalContent>\n </Modal>\n </>\n );\n}\n\n/* ── The control ──────────────────────────────────────────────────────── */\ntype CodeRead = { ok: true; code: string; language?: string; object: boolean } | { ok: false };\nfunction readCode(v: unknown): CodeRead {\n if (v == null) return { ok: true, code: \"\", object: false };\n if (typeof v === \"string\") return { ok: true, code: v, object: false };\n if (isObj(v) && typeof v.code === \"string\" && (v.language === undefined || typeof v.language === \"string\")) return { ok: true, code: v.code, language: v.language as string | undefined, object: true };\n return { ok: false };\n}\n\n/** The stored shape for edited code: a string stays a string until a language is picked; the object keeps its form. */\nfunction codeValue(prev: CodeRead & { ok: true }, code: string, language: string | undefined): string | { language?: string; code: string } {\n const lang = language ?? prev.language ?? \"\";\n if (!prev.object && !lang) return code;\n return lang ? { language: lang, code } : { code };\n}\nconst tooLong = (code: string) => (code.length > CODE_MAX_LENGTH ? `Code can hold up to ${CODE_MAX_LENGTH.toLocaleString(\"en-US\")} characters; this has ${code.length.toLocaleString(\"en-US\")}.` : null);\n\nexport function CodeControl({ field, value, onChange, readOnly, id, invalid }: ControlProps) {\n const { variant } = useKitEnv();\n const [refused, setRefused] = React.useState<string | null>(null);\n const read = readCode(value);\n if (!read.ok) return <UnreadableValue id={id} title={field.title} kind=\"code\" value={value} />;\n if (variant === \"document\")\n return (\n <div className=\"flex flex-col gap-1.5\">\n <CodeSurface\n kind=\"code\"\n id={id}\n invalid={invalid || !!refused}\n readOnly={readOnly}\n value={read.code}\n language={read.language ?? \"\"}\n languages={field.languages}\n onChange={(code) => {\n const why = tooLong(code);\n setRefused(why);\n if (!why) onChange(codeValue(read, code, undefined));\n }}\n onLanguage={(l) => onChange(codeValue(read, read.code, l))}\n />\n {refused ? (\n <p role=\"alert\" className=\"text-kit-xs text-kit-danger-fg\">\n {refused}\n </p>\n ) : null}\n </div>\n );\n return (\n <CodeDialogField\n kind=\"code\"\n id={id}\n title={field.title}\n description={field.description || undefined}\n text={read.code}\n language={read.language}\n languages={field.languages}\n readOnly={readOnly}\n invalid={invalid}\n onDone={(draft, lang) => {\n const why = tooLong(draft);\n if (why) return why;\n const next = codeValue(read, draft, lang);\n if (draft !== read.code || (lang ?? \"\") !== (read.language ?? \"\")) onChange(next);\n return null;\n }}\n />\n );\n}\n\n/** A stored value the control cannot read: named, shown, kept as it is (never replaced by a stray edit). */\nexport function UnreadableValue({ id, title, kind, value }: { id: string; title: string; kind: string; value: unknown }) {\n let raw: string;\n try {\n raw = typeof value === \"string\" ? value : JSON.stringify(value, null, 2);\n } catch {\n raw = String(value);\n }\n return (\n <output\n id={id}\n tabIndex={0}\n data-slot={`${kind}-unreadable`}\n className=\"flex min-w-0 items-start gap-2 rounded-kit-md border border-dashed border-kit-line-strong bg-kit-subtle px-2.5 py-2 text-kit-xs text-kit-fg-2 outline-none focus-visible:outline-2 focus-visible:outline-kit-focus-ring\"\n >\n <IconAlertTriangle className=\"mt-0.5 size-3.5 shrink-0 text-kit-warning-fg\" stroke={1.5} aria-hidden />\n <span className=\"min-w-0\">\n {title} holds a value this {kind} editor can't read, so it is kept as it is:{\" \"}\n <span className=\"block max-h-24 overflow-auto whitespace-pre-wrap break-all font-kit-mono text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;GACvB,UAAA;EACA,CAAA,IACD,IACD;;CAET,OACE,oBAAC,iBAAD;EACE,MAAK;EACD;EACJ,OAAO,MAAM;EACb,aAAa,MAAM,eAAe,KAAA;EAClC,MAAM,KAAK;EACX,UAAU,KAAK;EACf,WAAW,MAAM;EACP;EACD;EACT,SAAS,OAAO,SAAS;GACvB,MAAM,MAAM,QAAQ,KAAK;GACzB,IAAI,KAAK,OAAO;GAChB,MAAM,OAAO,UAAU,MAAM,OAAO,IAAI;GACxC,IAAI,UAAU,KAAK,SAAS,QAAQ,SAAS,KAAK,YAAY,KAAK,SAAS,IAAI;GAChF,OAAO;EACT;CACD,CAAA;AAEL;;AAGA,SAAgB,gBAAgB,EAAE,IAAI,OAAO,MAAM,SAAsE;CACvH,IAAI;CACJ,IAAI;EACF,MAAM,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,OAAO,MAAM,CAAC;CACzE,QAAQ;EACN,MAAM,OAAO,KAAK;CACpB;CACA,OACE,qBAAC,UAAD;EACM;EACJ,UAAU;EACV,aAAW,GAAG,KAAK;EACnB,WAAU;EAJZ,UAAA,CAME,oBAAC,mBAAD;GAAmB,WAAU;GAA+C,QAAQ;GAAK,eAAA;EAAa,CAAA,GACtG,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA;IACG;IAAM;IAAqB;IAAK;IAA4C;IAC7E,oBAAC,QAAD;KAAM,WAAU;KAAwF,UAAA;IAAU,CAAA;GAC9G;EACA,CAAA,CAAA;;AAEZ"}
@@ -7,6 +7,11 @@
7
7
  * stores the URL string, like the classic panel's codec="url")
8
8
  * { url, … } an uploaded icon stored as an image value: shown and kept until replaced
9
9
  * null no icon ("No icon"; the backend skips an empty value)
10
+ * { source: pack | library | upload, …, label? } D65: a field with `icons` (V2 FieldSchema.icons) opts in to the
11
+ * project's icon library, media uploads by id and an accessible label
12
+ *
13
+ * A field without `icons` draws and stores exactly what it always did. One with `icons` gets V2's source tabs (Icons ·
14
+ * Library · Upload), the library from the host (KitServices.iconLibrary) and "Describe this icon" when it asks.
10
15
  *
11
16
  * The grid offers the BetterCMS set, the one prod accepts. Search also matches a name's Tabler twin through the
12
17
  * Tabler ↔ dock adapter (adapters/icons.ts), so "map" finds earth-americas. A stored name outside the set (a stale
@@ -27,8 +32,31 @@ declare module "../context" {
27
32
  name: string;
28
33
  className?: string;
29
34
  }>;
35
+ /**
36
+ * The project's icon library (V2 D65, the brand kit's icons): each with its resolved url and whether it follows the
37
+ * text colour, and the sets. Absent → an icon field offers no Library tab.
38
+ */
39
+ iconLibrary?: () => {
40
+ icons: KitLibraryIcon[];
41
+ sets: Array<{
42
+ key: string;
43
+ name: string;
44
+ }>;
45
+ };
30
46
  }
31
47
  }
48
+ export type KitLibraryIcon = {
49
+ key: string;
50
+ name: string;
51
+ set?: string;
52
+ followsText: boolean;
53
+ url: string;
54
+ };
55
+ /** Any icon value as its glyph: a set name drawn by the host, a text-coloured library icon as a mask, else an image. */
56
+ export declare function IconValueGlyph({ value, className }: {
57
+ value: unknown;
58
+ className?: string;
59
+ }): import("react/jsx-runtime").JSX.Element | null;
32
60
  /** The picker: search, Recent, then the whole set ("No icon" first). Search spans the name and its Tabler twin.
33
61
  * `field`: the icon field's popover (V2 IconFieldPicker, a 22rem list); otherwise the app-UI grid (V2 IconPickerGrid, max-h-56). */
34
62
  export declare function IconPicker({ value, onPick, onChooseMedia, field }: {