@blokkli/editor 2.0.0-alpha.13 → 2.0.0-alpha.15

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 (289) hide show
  1. package/dist/module.d.mts +1 -1
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +4873 -1167
  4. package/dist/modules/drupal/graphql/base/fragment.ParagraphsBlokkliConfigInput.graphql +31 -0
  5. package/dist/modules/drupal/graphql/base/fragment.blokkliProps.graphql +1 -0
  6. package/dist/modules/drupal/graphql/base/fragment.paragraphsBlokkliEditState.graphql +5 -0
  7. package/dist/modules/drupal/graphql/base/query.pbEntityConfig.graphql +5 -0
  8. package/dist/modules/drupal/graphql/features/publishNew.graphql +1 -4
  9. package/dist/modules/drupal/graphql/features/scheduler.graphql +31 -0
  10. package/dist/modules/drupal/graphql/features/transform.graphql +9 -1
  11. package/dist/modules/drupal/graphql/features/transform_host.graphql +38 -0
  12. package/dist/modules/drupal/graphql/mutations/update_host_options.graphql +15 -0
  13. package/dist/modules/drupal/index.d.mts +1 -1
  14. package/dist/modules/drupal/index.mjs +37 -7
  15. package/dist/modules/drupal/runtime/adapter/index.js +140 -5
  16. package/dist/runtime/adapter/index.d.ts +90 -1
  17. package/dist/runtime/blokkliPlugins/AddAction/index.vue +27 -3
  18. package/dist/runtime/blokkliPlugins/BlockIndicator/index.vue +65 -0
  19. package/dist/runtime/blokkliPlugins/BlockIndicator/index.vue.d.ts +26 -0
  20. package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +3 -0
  21. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue +3 -2
  22. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +3 -3
  23. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +49 -11
  24. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +29 -15
  25. package/dist/runtime/blokkliPlugins/MenuButton/index.vue.d.ts +2 -2
  26. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +6 -7
  27. package/dist/runtime/blokkliPlugins/Sidebar/index.vue +2 -9
  28. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +1 -1
  29. package/dist/runtime/blokkliPlugins/ViewOption/index.vue +6 -3
  30. package/dist/runtime/blokkliPlugins/index.d.ts +8 -7
  31. package/dist/runtime/blokkliPlugins/index.js +15 -13
  32. package/dist/runtime/components/Blocks/Fragment/icon.svg +1 -1
  33. package/dist/runtime/components/BlokkliProvider.vue +1 -0
  34. package/dist/runtime/components/BlokkliProvider.vue.d.ts +1 -0
  35. package/dist/runtime/components/Edit/Actions/index.vue +39 -67
  36. package/dist/runtime/components/Edit/AddListItem/index.vue +2 -5
  37. package/dist/runtime/components/Edit/AddListItem/index.vue.d.ts +1 -1
  38. package/dist/runtime/components/Edit/AddListItemIcon/index.vue +19 -0
  39. package/dist/runtime/components/Edit/AddListItemIcon/index.vue.d.ts +15 -0
  40. package/dist/runtime/components/Edit/AppMenu/index.vue +5 -5
  41. package/dist/runtime/components/Edit/Dialog/index.vue +5 -1
  42. package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +1 -1
  43. package/dist/runtime/components/Edit/DiffViewer/State.vue +276 -0
  44. package/dist/runtime/components/Edit/DiffViewer/State.vue.d.ts +16 -0
  45. package/dist/runtime/components/Edit/DragInteractions/index.vue +35 -6
  46. package/dist/runtime/components/Edit/EditProvider.vue +46 -35
  47. package/dist/runtime/components/Edit/Features/AddList/index.vue +15 -25
  48. package/dist/runtime/components/Edit/Features/Analyze/Overlay/fragment.glsl +58 -0
  49. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +168 -0
  50. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue.d.ts +9 -0
  51. package/dist/runtime/components/Edit/Features/Analyze/Overlay/vertex.glsl +72 -0
  52. package/dist/runtime/components/Edit/Features/Analyze/Renderer.vue +159 -0
  53. package/dist/runtime/components/Edit/Features/Analyze/Renderer.vue.d.ts +7 -0
  54. package/dist/runtime/components/Edit/Features/Analyze/Results/Results.vue +100 -0
  55. package/dist/runtime/components/Edit/Features/Analyze/Results/Results.vue.d.ts +6 -0
  56. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItem.vue +56 -0
  57. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItem.vue.d.ts +3 -0
  58. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodes.vue +87 -0
  59. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodes.vue.d.ts +7 -0
  60. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +101 -0
  61. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue.d.ts +8 -0
  62. package/dist/runtime/components/Edit/Features/Analyze/Results/Status.vue +18 -0
  63. package/dist/runtime/components/Edit/Features/Analyze/Results/Status.vue.d.ts +8 -0
  64. package/dist/runtime/components/Edit/Features/Analyze/Summary/Chart.vue +92 -0
  65. package/dist/runtime/components/Edit/Features/Analyze/Summary/Chart.vue.d.ts +17 -0
  66. package/dist/runtime/components/Edit/Features/Analyze/Summary/index.vue +77 -0
  67. package/dist/runtime/components/Edit/Features/Analyze/Summary/index.vue.d.ts +6 -0
  68. package/dist/runtime/components/Edit/Features/Analyze/analyzers/axe.d.ts +12 -0
  69. package/dist/runtime/components/Edit/Features/Analyze/analyzers/axe.js +75 -0
  70. package/dist/runtime/components/Edit/Features/Analyze/analyzers/defineAnalyzer.d.ts +4 -0
  71. package/dist/runtime/components/Edit/Features/Analyze/analyzers/defineAnalyzer.js +5 -0
  72. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/Context.d.ts +32 -0
  73. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/Context.js +45 -0
  74. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.d.ts +5 -0
  75. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.js +95 -0
  76. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/normalizeArray.d.ts +3 -0
  77. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/normalizeArray.js +13 -0
  78. package/dist/runtime/components/Edit/Features/Analyze/analyzers/index.d.ts +2 -0
  79. package/dist/runtime/components/Edit/Features/Analyze/analyzers/index.js +2 -0
  80. package/dist/runtime/components/Edit/Features/Analyze/analyzers/readability.d.ts +2 -0
  81. package/dist/runtime/components/Edit/Features/Analyze/analyzers/readability.js +165 -0
  82. package/dist/runtime/components/Edit/Features/Analyze/analyzers/types.d.ts +44 -0
  83. package/dist/runtime/components/Edit/Features/Analyze/analyzers/types.js +0 -0
  84. package/dist/runtime/components/Edit/Features/Analyze/helper.d.ts +5 -0
  85. package/dist/runtime/components/Edit/Features/Analyze/helper.js +28 -0
  86. package/dist/runtime/components/Edit/Features/Analyze/index.vue +44 -0
  87. package/dist/runtime/components/Edit/Features/Anchors/Renderer.vue +136 -0
  88. package/dist/runtime/components/Edit/Features/Anchors/index.vue +32 -0
  89. package/dist/runtime/components/Edit/Features/Anchors/index.vue.d.ts +2 -0
  90. package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue +25 -13
  91. package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +296 -0
  92. package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue.d.ts +7 -0
  93. package/dist/runtime/components/Edit/Features/Artboard/index.vue +10 -245
  94. package/dist/runtime/components/Edit/Features/Assistant/index.vue +3 -2
  95. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +4 -4
  96. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +161 -28
  97. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +16 -4
  98. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue.d.ts +0 -1
  99. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +4 -53
  100. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +3 -2
  101. package/dist/runtime/components/Edit/Features/Conversions/index.vue +12 -14
  102. package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue +14 -0
  103. package/dist/runtime/components/Edit/Features/Debug/index.vue +27 -24
  104. package/dist/runtime/components/Edit/Features/Diff/DiffView/index.vue +13 -190
  105. package/dist/runtime/components/Edit/Features/Diff/index.vue +2 -2
  106. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +4 -4
  107. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +1 -1
  108. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +35 -71
  109. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/vertex.glsl +1 -1
  110. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +62 -48
  111. package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue +3 -3
  112. package/dist/runtime/components/Edit/Features/EditForm/index.vue +3 -3
  113. package/dist/runtime/components/Edit/Features/EditableField/index.vue +6 -2
  114. package/dist/runtime/components/Edit/Features/EditableMask/index.vue +3 -20
  115. package/dist/runtime/components/Edit/Features/EntityTitle/index.vue +33 -1
  116. package/dist/runtime/components/Edit/Features/Fragments/index.vue +3 -2
  117. package/dist/runtime/components/Edit/Features/History/index.vue +35 -12
  118. package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue +6 -2
  119. package/dist/runtime/components/Edit/Features/ImportExisting/index.vue +3 -2
  120. package/dist/runtime/components/Edit/Features/Library/index.vue +11 -9
  121. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +5 -8
  122. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/fragment.glsl +1 -1
  123. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +9 -4
  124. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/vertex.glsl +1 -1
  125. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +8 -14
  126. package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue +3 -2
  127. package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue.d.ts +2 -0
  128. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +9 -3
  129. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue.d.ts +0 -1
  130. package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue +37 -19
  131. package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue.d.ts +8 -2
  132. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +81 -37
  133. package/dist/runtime/components/Edit/Features/Options/Form/index.vue.d.ts +5 -5
  134. package/dist/runtime/components/Edit/Features/Options/index.vue +30 -6
  135. package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue +3 -3
  136. package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue +41 -14
  137. package/dist/runtime/components/Edit/Features/Publish/Dialog/Item.vue.d.ts +2 -0
  138. package/dist/runtime/components/Edit/Features/Publish/Dialog/PublishOption.vue +47 -0
  139. package/dist/runtime/components/Edit/Features/Publish/Dialog/PublishOption.vue.d.ts +19 -0
  140. package/dist/runtime/components/Edit/Features/Publish/Dialog/ScheduleDate.vue +183 -0
  141. package/dist/runtime/components/Edit/Features/Publish/Dialog/ScheduleDate.vue.d.ts +13 -0
  142. package/dist/runtime/components/Edit/Features/Publish/Dialog/Summary.vue +83 -0
  143. package/dist/runtime/components/Edit/Features/Publish/Dialog/Summary.vue.d.ts +9 -0
  144. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +381 -128
  145. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue.d.ts +3 -14
  146. package/dist/runtime/components/Edit/Features/Publish/index.vue +37 -22
  147. package/dist/runtime/components/Edit/Features/Revert/index.vue +3 -3
  148. package/dist/runtime/components/Edit/Features/Search/index.vue +3 -2
  149. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue +54 -0
  150. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue.d.ts +14 -0
  151. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +120 -0
  152. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +15 -0
  153. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +459 -0
  154. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue.d.ts +6 -0
  155. package/dist/runtime/components/Edit/Features/Selection/Overlay/fragment.glsl +14 -9
  156. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +32 -11
  157. package/dist/runtime/components/Edit/Features/Selection/Overlay/vertex.glsl +1 -1
  158. package/dist/runtime/components/Edit/Features/Selection/index.vue +76 -7
  159. package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue +12 -17
  160. package/dist/runtime/components/Edit/Features/Settings/index.vue +11 -25
  161. package/dist/runtime/components/Edit/Features/Theme/Color/index.vue +5 -1
  162. package/dist/runtime/components/Edit/Features/Theme/index.vue +2 -1
  163. package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue +3 -2
  164. package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue +198 -0
  165. package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue.d.ts +13 -0
  166. package/dist/runtime/components/Edit/Features/Transform/index.vue +155 -44
  167. package/dist/runtime/components/Edit/Form/Datepicker/index.vue +198 -0
  168. package/dist/runtime/components/Edit/Form/Datepicker/index.vue.d.ts +15 -0
  169. package/dist/runtime/components/Edit/Form/Radio/index.vue +33 -0
  170. package/dist/runtime/components/Edit/Form/Radio/index.vue.d.ts +20 -0
  171. package/dist/runtime/components/Edit/Form/RadioTabs/index.vue +37 -0
  172. package/dist/runtime/components/Edit/Form/RadioTabs/index.vue.d.ts +22 -0
  173. package/dist/runtime/components/Edit/Form/Select/index.vue +29 -0
  174. package/dist/runtime/components/Edit/Form/Select/index.vue.d.ts +20 -0
  175. package/dist/runtime/components/Edit/Form/Text/index.vue +33 -0
  176. package/dist/runtime/components/Edit/Form/Text/index.vue.d.ts +19 -0
  177. package/dist/runtime/components/Edit/Form/Textarea/index.vue +13 -6
  178. package/dist/runtime/components/Edit/Form/Textarea/index.vue.d.ts +4 -0
  179. package/dist/runtime/components/Edit/FormOverlay/index.vue +1 -1
  180. package/dist/runtime/components/Edit/Indicators/index.vue +123 -0
  181. package/dist/runtime/components/Edit/Indicators/index.vue.d.ts +2 -0
  182. package/dist/runtime/components/Edit/ItemIcon/index.vue +2 -1
  183. package/dist/runtime/components/Edit/Konami/Game/PixelGrid.vue +66 -0
  184. package/dist/runtime/components/Edit/Konami/Game/PixelGrid.vue.d.ts +7 -0
  185. package/dist/runtime/components/Edit/Konami/Game/blokkli.png +0 -0
  186. package/dist/runtime/components/Edit/Konami/Game/charmap.d.ts +2 -0
  187. package/dist/runtime/components/Edit/Konami/Game/charmap.js +168 -0
  188. package/dist/runtime/components/Edit/Konami/Game/index.vue +752 -0
  189. package/dist/runtime/components/Edit/Konami/Game/index.vue.d.ts +6 -0
  190. package/dist/runtime/components/Edit/Konami/Game/textRendering.d.ts +8 -0
  191. package/dist/runtime/components/Edit/Konami/Game/textRendering.js +138 -0
  192. package/dist/runtime/components/Edit/Konami/Game/useIconRendering.d.ts +9 -0
  193. package/dist/runtime/components/Edit/Konami/Game/useIconRendering.js +130 -0
  194. package/dist/runtime/components/Edit/Konami/index.vue +44 -0
  195. package/dist/runtime/components/Edit/Konami/index.vue.d.ts +2 -0
  196. package/dist/runtime/components/Edit/Loading/index.vue +6 -2
  197. package/dist/runtime/components/Edit/Loading/index.vue.d.ts +2 -0
  198. package/dist/runtime/components/Edit/Messages/index.vue +8 -3
  199. package/dist/runtime/components/Edit/PluginConfigForm/Checkbox/index.vue +17 -0
  200. package/dist/runtime/components/Edit/PluginConfigForm/Checkbox/index.vue.d.ts +11 -0
  201. package/dist/runtime/components/Edit/PluginConfigForm/Options/index.vue +37 -0
  202. package/dist/runtime/components/Edit/PluginConfigForm/Options/index.vue.d.ts +11 -0
  203. package/dist/runtime/components/Edit/PluginConfigForm/Text/index.vue +43 -0
  204. package/dist/runtime/components/Edit/PluginConfigForm/Text/index.vue.d.ts +11 -0
  205. package/dist/runtime/components/Edit/PluginConfigForm/index.vue +57 -0
  206. package/dist/runtime/components/Edit/PluginConfigForm/index.vue.d.ts +16 -0
  207. package/dist/runtime/components/Edit/PreviewProvider.vue +3 -4
  208. package/dist/runtime/components/Edit/RelativeTime/index.vue +3 -2
  209. package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +8 -3
  210. package/dist/runtime/components/Edit/SystemRequirements/index.vue +3 -3
  211. package/dist/runtime/components/Edit/Toolbar/index.vue +3 -2
  212. package/dist/runtime/components/Edit/Transition/index.vue +41 -0
  213. package/dist/runtime/components/Edit/Transition/index.vue.d.ts +19 -0
  214. package/dist/runtime/components/Edit/index.d.ts +24 -15
  215. package/dist/runtime/components/Edit/index.js +46 -28
  216. package/dist/runtime/composables/defineBlokkli.js +7 -3
  217. package/dist/runtime/composables/defineBlokkliFeature.d.ts +4 -7
  218. package/dist/runtime/composables/defineBlokkliProvider.d.ts +11 -0
  219. package/dist/runtime/composables/defineBlokkliProvider.js +46 -0
  220. package/dist/runtime/composables/useBlokkliHelper.js +1 -1
  221. package/dist/runtime/constants/index.d.ts +3 -0
  222. package/dist/runtime/constants/index.js +3 -0
  223. package/dist/runtime/css/output.css +1 -1
  224. package/dist/runtime/helpers/addElementClasses.d.ts +2 -0
  225. package/dist/runtime/helpers/addElementClasses.js +24 -0
  226. package/dist/runtime/helpers/animationProvider.d.ts +4 -2
  227. package/dist/runtime/helpers/animationProvider.js +7 -2
  228. package/dist/runtime/helpers/bundles/index.d.ts +1 -0
  229. package/dist/runtime/helpers/bundles/index.js +4 -0
  230. package/dist/runtime/helpers/composables/useStickyToolbar.d.ts +20 -0
  231. package/dist/runtime/helpers/composables/useStickyToolbar.js +215 -0
  232. package/dist/runtime/helpers/definitionProvider.d.ts +2 -1
  233. package/dist/runtime/helpers/definitionProvider.js +17 -0
  234. package/dist/runtime/helpers/domProvider.d.ts +2 -1
  235. package/dist/runtime/helpers/domProvider.js +89 -43
  236. package/dist/runtime/helpers/dropTargets/index.d.ts +6 -0
  237. package/dist/runtime/helpers/dropTargets/index.js +49 -0
  238. package/dist/runtime/helpers/eventBus.d.ts +1 -1
  239. package/dist/runtime/helpers/eventBus.js +2 -2
  240. package/dist/runtime/helpers/index.d.ts +10 -1
  241. package/dist/runtime/helpers/index.js +57 -0
  242. package/dist/runtime/helpers/indicatorsProvider.d.ts +10 -0
  243. package/dist/runtime/helpers/indicatorsProvider.js +23 -0
  244. package/dist/runtime/helpers/keyboardProvider.d.ts +2 -0
  245. package/dist/runtime/helpers/keyboardProvider.js +17 -1
  246. package/dist/runtime/helpers/pluginProvider.d.ts +10 -0
  247. package/dist/runtime/helpers/pluginProvider.js +33 -0
  248. package/dist/runtime/helpers/renderCycle.d.ts +1 -0
  249. package/dist/runtime/helpers/renderCycle.js +10 -0
  250. package/dist/runtime/helpers/runtimeHelpers/index.js +14 -11
  251. package/dist/runtime/helpers/selectionProvider.d.ts +16 -0
  252. package/dist/runtime/helpers/selectionProvider.js +47 -35
  253. package/dist/runtime/helpers/stateProvider.d.ts +7 -2
  254. package/dist/runtime/helpers/stateProvider.js +89 -14
  255. package/dist/runtime/helpers/storageProvider.d.ts +4 -3
  256. package/dist/runtime/helpers/storageProvider.js +56 -3
  257. package/dist/runtime/helpers/symbols.d.ts +1 -0
  258. package/dist/runtime/helpers/symbols.js +1 -0
  259. package/dist/runtime/helpers/textProvider.js +6 -0
  260. package/dist/runtime/helpers/themeProvider.d.ts +2 -0
  261. package/dist/runtime/helpers/themeProvider.js +4 -1
  262. package/dist/runtime/helpers/transform.js +1 -3
  263. package/dist/runtime/helpers/uiProvider.d.ts +9 -2
  264. package/dist/runtime/helpers/uiProvider.js +72 -47
  265. package/dist/runtime/helpers/useTransitionedValue.d.ts +18 -0
  266. package/dist/runtime/helpers/useTransitionedValue.js +57 -0
  267. package/dist/runtime/icons/anchor.svg +1 -0
  268. package/dist/runtime/icons/arrow-left.svg +1 -1
  269. package/dist/runtime/icons/arrow-right.svg +1 -1
  270. package/dist/runtime/icons/arrow-top-right.svg +1 -0
  271. package/dist/runtime/icons/calendar-clock.svg +1 -0
  272. package/dist/runtime/icons/chart.svg +1 -0
  273. package/dist/runtime/icons/copy.svg +1 -0
  274. package/dist/runtime/icons/cursor-move.svg +1 -1
  275. package/dist/runtime/icons/diff.svg +1 -1
  276. package/dist/runtime/icons/eye-off.svg +1 -0
  277. package/dist/runtime/icons/eye.svg +1 -1
  278. package/dist/runtime/icons/info.svg +1 -1
  279. package/dist/runtime/icons/link.svg +1 -0
  280. package/dist/runtime/icons/speedometer.svg +1 -0
  281. package/dist/runtime/types/blokkOptions.d.ts +8 -0
  282. package/dist/runtime/types/index.d.ts +172 -6
  283. package/dist/runtime/types/theme.d.ts +2 -1
  284. package/dist/shared/{editor.gz_ac6uT.d.mts → editor.CKsrTpc1.d.mts} +1 -1
  285. package/package.json +20 -5
  286. package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue +0 -22
  287. package/dist/runtime/components/Edit/Features/FieldAreas/index.vue +0 -41
  288. /package/dist/runtime/components/Edit/Features/{FieldAreas/Overlay → Analyze}/index.vue.d.ts +0 -0
  289. /package/dist/runtime/components/Edit/Features/{FieldAreas/index.vue.d.ts → Anchors/Renderer.vue.d.ts} +0 -0
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <div class="bk bk-analyze">
3
+ <div class="bk-analyze-button">
4
+ <button
5
+ class="bk-button bk-is-primary"
6
+ :disabled="!isStale"
7
+ @click="onClick"
8
+ >
9
+ {{ $t("analyzeButtonLabel", "Analyze Page") }}
10
+ </button>
11
+
12
+ <p v-if="lastRun" class="bk-analyze-last-run">
13
+ <RelativeTime v-slot="{ formatted }" :timestamp="lastRun">
14
+ {{
15
+ $t("analyzeLastRun", "Last run: @time").replace("@time", formatted)
16
+ }}
17
+ </RelativeTime>
18
+ </p>
19
+ <p v-if="isStale && hasRunOnce" class="bk-message-info">
20
+ {{
21
+ $t(
22
+ "analyzeStaleMessage",
23
+ "The contents of the page have changed since last analyzing the page. Please run the analyzers again to get updated results."
24
+ )
25
+ }}
26
+ </p>
27
+ </div>
28
+
29
+ <div v-if="resultsFiltered.length" class="bk-analyze-wrapper">
30
+ <div class="bk-analyze-form">
31
+ <FormSelect
32
+ id="category"
33
+ v-model="selectedCategory"
34
+ :label="$t('analyzeCategory', 'Category')"
35
+ :options="categoryOptions"
36
+ />
37
+ </div>
38
+ <AnalyzeSummary :results="resultsFiltered" />
39
+ <Results :results="resultsFiltered" />
40
+ </div>
41
+ </div>
42
+ <Overlay
43
+ v-if="
44
+ resultsFiltered.length && gl && animation.webglEnabled.value && !isStale
45
+ "
46
+ :results="resultsFiltered"
47
+ :gl="gl"
48
+ />
49
+ </template>
50
+
51
+ <script setup>
52
+ import { computed, useBlokkli, useState, ref } from "#imports";
53
+ import Results from "./Results/Results.vue";
54
+ import AnalyzeSummary from "./Summary/index.vue";
55
+ import Overlay from "./Overlay/index.vue";
56
+ import { useAnalyzeHelper } from "./helper";
57
+ import { FormSelect, RelativeTime } from "#blokkli/components";
58
+ import { AnalyzerContext } from "./analyzers/helpers/Context";
59
+ import { normalizeToArray } from "./analyzers/helpers/normalizeArray";
60
+ import { falsy } from "#blokkli/helpers";
61
+ import { renderCycle } from "#blokkli/helpers/renderCycle";
62
+ const props = defineProps({
63
+ langcode: { type: String, required: true },
64
+ analyzers: { type: Array, required: true }
65
+ });
66
+ const ALL = "ALL";
67
+ const { $t, ui, state, animation } = useBlokkli();
68
+ const { getCategoryLabel } = useAnalyzeHelper();
69
+ const gl = animation.gl();
70
+ const currentPlugin = ref("readability");
71
+ const hasRunOnce = useState(() => false);
72
+ const results = useState("blokkli:analyze", () => []);
73
+ const isLoading = useState(() => false);
74
+ const lastRun = useState(() => 0);
75
+ const lastRunKey = useState(() => "");
76
+ const selectedCategory = useState(() => ALL);
77
+ const hasInitialized = useState(() => false);
78
+ const providerRootElement = ui.providerElement();
79
+ const resultsFiltered = computed(() => {
80
+ if (selectedCategory.value === ALL) {
81
+ return results.value;
82
+ }
83
+ return results.value.filter((v) => v.category === selectedCategory.value);
84
+ });
85
+ const isStale = computed(() => lastRunKey.value !== state.refreshKey.value);
86
+ function getContext() {
87
+ return new AnalyzerContext(
88
+ props.langcode,
89
+ ui.interfaceLanguage.value,
90
+ providerRootElement,
91
+ state,
92
+ $t
93
+ );
94
+ }
95
+ async function onClick() {
96
+ if (isLoading.value) {
97
+ return;
98
+ }
99
+ const requiresRawPage = props.analyzers.some(
100
+ (analyzer) => analyzer.requireRawPage
101
+ );
102
+ if (requiresRawPage) {
103
+ ui.isAnalyzing.value = true;
104
+ }
105
+ isLoading.value = true;
106
+ await renderCycle();
107
+ const context = getContext();
108
+ if (!hasInitialized.value) {
109
+ await Promise.all(
110
+ props.analyzers.map(async (analyzer) => {
111
+ if (analyzer.init) {
112
+ await analyzer.init(context);
113
+ }
114
+ })
115
+ );
116
+ }
117
+ hasInitialized.value = true;
118
+ const newResults = [];
119
+ for (let i = 0; i < props.analyzers.length; i++) {
120
+ const analyzer = props.analyzers[i];
121
+ currentPlugin.value = analyzer.id;
122
+ const result = await normalizeToArray(analyzer.run(context));
123
+ const mapped = result.filter(falsy).map((v) => {
124
+ return {
125
+ ...v,
126
+ plugin: analyzer.id
127
+ };
128
+ });
129
+ newResults.push(...mapped);
130
+ }
131
+ results.value = newResults;
132
+ isLoading.value = false;
133
+ hasRunOnce.value = true;
134
+ lastRun.value = Date.now() / 1e3;
135
+ lastRunKey.value = state.refreshKey.value;
136
+ if (requiresRawPage) {
137
+ ui.isAnalyzing.value = false;
138
+ }
139
+ }
140
+ const categoryOptions = computed(() => {
141
+ const set = results.value.reduce((acc, v) => {
142
+ acc.add(v.category);
143
+ return acc;
144
+ }, /* @__PURE__ */ new Set());
145
+ const categories = [...set.values()].map((value) => {
146
+ return {
147
+ value,
148
+ label: getCategoryLabel(value)
149
+ };
150
+ });
151
+ return [
152
+ {
153
+ value: ALL,
154
+ label: $t("all", "All")
155
+ },
156
+ ...categories
157
+ ];
158
+ });
159
+ </script>
@@ -0,0 +1,7 @@
1
+ import type { Analyzer } from './analyzers/types.js';
2
+ type __VLS_Props = {
3
+ langcode: string;
4
+ analyzers: Analyzer[];
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ export default _default;
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <div>
3
+ <details
4
+ v-for="group in grouped"
5
+ :key="group.group"
6
+ :open="group.open"
7
+ class="bk-analyze-results"
8
+ >
9
+ <summary v-show="!group.open">
10
+ <div>
11
+ <span>{{ group.label }}</span>
12
+ <div>
13
+ <span class="bk-pill">{{ group.results.length }}</span>
14
+ </div>
15
+ </div>
16
+ <Icon name="caret" />
17
+ </summary>
18
+ <ul
19
+ :class="{
20
+ 'bk-is-always-open': group.open
21
+ }"
22
+ >
23
+ <li>
24
+ <ResultsItem
25
+ v-for="result in group.results"
26
+ v-bind="result"
27
+ :key="group.group + result.id"
28
+ />
29
+ </li>
30
+ </ul>
31
+ </details>
32
+ </div>
33
+ </template>
34
+
35
+ <script setup>
36
+ import { computed, useBlokkli } from "#imports";
37
+ import ResultsItem from "./ResultsItem.vue";
38
+ import { Icon } from "#blokkli/components";
39
+ const props = defineProps({
40
+ results: { type: Array, required: true }
41
+ });
42
+ const { $t } = useBlokkli();
43
+ const groupOrder = {
44
+ problems: 1,
45
+ success: 2,
46
+ inapplicable: 3
47
+ };
48
+ const statusOrder = {
49
+ violation: 1,
50
+ incomplete: 2,
51
+ pass: 3,
52
+ inapplicable: 4
53
+ };
54
+ function getGroup(status) {
55
+ if (status === "violation" || status === "incomplete") {
56
+ return "problems";
57
+ } else if (status === "pass") {
58
+ return "success";
59
+ }
60
+ return "inapplicable";
61
+ }
62
+ function getGroupLabel(group) {
63
+ if (group === "problems") {
64
+ return "Problems";
65
+ } else if (group === "success") {
66
+ return $t("analyzeStatusPass", "Pass");
67
+ }
68
+ return $t("analyzeStatusInapplicable", "Inapplicable");
69
+ }
70
+ const grouped = computed(() => {
71
+ const map = props.results.reduce(
72
+ (acc, result) => {
73
+ const group = getGroup(result.status);
74
+ if (!acc[group]) {
75
+ acc[group] = [];
76
+ }
77
+ acc[group].push(result);
78
+ return acc;
79
+ },
80
+ {}
81
+ );
82
+ return Object.entries(map).map(([key, results]) => {
83
+ const group = key;
84
+ return {
85
+ group,
86
+ label: getGroupLabel(group),
87
+ open: group === "problems",
88
+ results: results.sort((a, b) => {
89
+ const statusDiff = statusOrder[a.status] - statusOrder[b.status];
90
+ if (statusDiff !== 0) {
91
+ return statusDiff;
92
+ }
93
+ return a.title.localeCompare(b.title);
94
+ })
95
+ };
96
+ }).sort((a, b) => {
97
+ return groupOrder[a.group] - groupOrder[b.group];
98
+ });
99
+ });
100
+ </script>
@@ -0,0 +1,6 @@
1
+ import type { AnalyzeResultMapped } from '../analyzers/types.js';
2
+ type __VLS_Props = {
3
+ results: AnalyzeResultMapped[];
4
+ };
5
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ export default _default;
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <div class="bk-analyze-results-item">
3
+ <div class="bk-analyze-results-item-tags">
4
+ <Status :status :title="key" />
5
+ <div class="bk-pill bk-is-mono">{{ categoryLabel }}</div>
6
+ <div class="bk-analyze-results-item-help">
7
+ <a v-if="link" :href="link" target="_blank" :title="link">
8
+ <span>{{ $t("analyzeMoreLink", "More") }}</span>
9
+ <Icon name="help" />
10
+ </a>
11
+ </div>
12
+ </div>
13
+ <h3>{{ title }}</h3>
14
+ <p v-if="descriptionMapped || link">
15
+ {{ descriptionMapped }}
16
+ </p>
17
+
18
+ <ResultsItemNodes :nodes :result-id="id" />
19
+ </div>
20
+ </template>
21
+
22
+ <script setup>
23
+ import { computed, useBlokkli } from "#imports";
24
+ import { Icon } from "#blokkli/components";
25
+ import Status from "./Status.vue";
26
+ import ResultsItemNodes from "./ResultsItemNodes.vue";
27
+ import { useAnalyzeHelper } from "../helper";
28
+ const props = defineProps({
29
+ id: { type: String, required: true },
30
+ title: { type: String, required: true },
31
+ category: { type: String, required: true },
32
+ description: { type: String, required: true },
33
+ link: { type: String, required: false },
34
+ status: { type: String, required: true },
35
+ nodes: { type: [Object, Array], required: true },
36
+ impact: { type: String, required: false },
37
+ scoreTargets: { type: Boolean, required: false },
38
+ plugin: { type: String, required: true }
39
+ });
40
+ const { getCategoryLabel } = useAnalyzeHelper();
41
+ const { $t } = useBlokkli();
42
+ const categoryLabel = computed(() => {
43
+ return getCategoryLabel(props.category);
44
+ });
45
+ const descriptionMapped = computed(() => {
46
+ if (!props.description) {
47
+ return "";
48
+ }
49
+ const punctuation = /[.!?]$/;
50
+ if (punctuation.test(props.description.trim())) {
51
+ return props.description;
52
+ }
53
+ return props.description + ".";
54
+ });
55
+ const key = computed(() => `${props.plugin}:${props.id}`);
56
+ </script>
@@ -0,0 +1,3 @@
1
+ import type { AnalyzeResultMapped } from '../analyzers/types.js';
2
+ declare const _default: import("vue").DefineComponent<AnalyzeResultMapped, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<AnalyzeResultMapped> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ export default _default;
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <details
3
+ v-if="mappedNodes.length"
4
+ class="bk-analyze-results-item-nodes"
5
+ :open="isSingle || isOpen"
6
+ @toggle="shouldRender = true"
7
+ >
8
+ <summary v-show="!isSingle">
9
+ <span>{{ $t("multipleItemsLabel", "Items") }}</span>
10
+ <Icon name="caret" />
11
+ </summary>
12
+
13
+ <div v-if="shouldRender" class="bk-analyze-results-item-nodes-list">
14
+ <ul v-for="(group, i) in grouped" :key="i">
15
+ <li>
16
+ <p
17
+ v-if="group.description && group.description !== 'NONE'"
18
+ :class="{
19
+ 'bk-is-single': isSingle
20
+ }"
21
+ v-html="group.description"
22
+ />
23
+ <ul>
24
+ <li v-for="(node, j) in group.nodes" :key="i + '_' + j">
25
+ <ResultsItemNodesTarget
26
+ v-for="(target, k) in node.targets"
27
+ :key="i + '_' + j + '_' + k"
28
+ :target="target"
29
+ :result-id
30
+ />
31
+ </li>
32
+ </ul>
33
+ </li>
34
+ </ul>
35
+ </div>
36
+ </details>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { computed, ref, useBlokkli } from "#imports";
41
+ import ResultsItemNodesTarget from "./ResultsItemNodesTarget.vue";
42
+ import { Icon } from "#blokkli/components";
43
+ import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
44
+ const props = defineProps({
45
+ resultId: { type: String, required: true },
46
+ nodes: { type: [Object, Array], required: true }
47
+ });
48
+ const shouldRender = ref(false);
49
+ const isOpen = ref(false);
50
+ const { $t } = useBlokkli();
51
+ const mappedNodes = computed(() => {
52
+ const nodes = Array.isArray(props.nodes) ? props.nodes : [props.nodes];
53
+ return nodes.map((node) => {
54
+ return {
55
+ ...node,
56
+ targets: Array.isArray(node.targets) ? node.targets : [node.targets]
57
+ };
58
+ });
59
+ });
60
+ const isSingle = computed(
61
+ () => mappedNodes.value.length === 1 && mappedNodes.value[0]?.targets.length === 1
62
+ );
63
+ const grouped = computed(() => {
64
+ const map = mappedNodes.value.reduce(
65
+ (acc, node) => {
66
+ const description = node.description ?? "NONE";
67
+ if (!acc[description]) {
68
+ acc[description] = [];
69
+ }
70
+ acc[description].push(node);
71
+ return acc;
72
+ },
73
+ {}
74
+ );
75
+ return Object.entries(map).map(([description, nodes]) => {
76
+ return {
77
+ description: description === "none" ? "" : description,
78
+ nodes
79
+ };
80
+ });
81
+ });
82
+ onBlokkliEvent("analyze:click-node", (e) => {
83
+ if (e.id === props.resultId) {
84
+ isOpen.value = true;
85
+ }
86
+ });
87
+ </script>
@@ -0,0 +1,7 @@
1
+ import type { AnalyzeNode } from '../analyzers/types.js';
2
+ type __VLS_Props = {
3
+ resultId: string;
4
+ nodes: AnalyzeNode | AnalyzeNode[];
5
+ };
6
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ export default _default;
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div
3
+ class="bk-analyze-results-item-nodes-target"
4
+ :class="{
5
+ 'bk-is-focused': isFocused
6
+ }"
7
+ >
8
+ <div>
9
+ <button ref="elButton" @click.prevent="onClick">
10
+ <Icon name="eye" />
11
+ <span>{{ getLabel() }}</span>
12
+ </button>
13
+ </div>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup>
18
+ import { Icon } from "#blokkli/components";
19
+ import { ref, useBlokkli, useTemplateRef } from "#imports";
20
+ import { renderCycle } from "#blokkli/helpers/renderCycle";
21
+ import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
22
+ const props = defineProps({
23
+ resultId: { type: String, required: true },
24
+ target: { type: null, required: true }
25
+ });
26
+ const { eventBus, dom } = useBlokkli();
27
+ const elButton = useTemplateRef("elButton");
28
+ const isFocused = ref(false);
29
+ let focusTimeout = null;
30
+ function getElement() {
31
+ if (props.target) {
32
+ if (typeof props.target === "string") {
33
+ return document.querySelector(props.target);
34
+ } else if (props.target instanceof HTMLElement) {
35
+ return props.target;
36
+ } else if (typeof props.target === "object" && "uuid" in props.target) {
37
+ const block = dom.findBlock(props.target.uuid);
38
+ if (block) {
39
+ return block.element();
40
+ }
41
+ }
42
+ }
43
+ return null;
44
+ }
45
+ function getLabel() {
46
+ if (props.target) {
47
+ if (typeof props.target === "string") {
48
+ return props.target;
49
+ } else if (props.target instanceof HTMLElement) {
50
+ return (props.target.textContent ?? "").slice(0, 50);
51
+ } else if (typeof props.target === "object" && "uuid" in props.target) {
52
+ return props.target.uuid;
53
+ }
54
+ }
55
+ }
56
+ function findClosestUuid(element) {
57
+ const closestBlock = element.closest("[data-uuid]");
58
+ if (closestBlock instanceof HTMLElement) {
59
+ const uuid = closestBlock.dataset.uuid;
60
+ if (uuid) {
61
+ return uuid;
62
+ }
63
+ }
64
+ }
65
+ async function onClick() {
66
+ const element = getElement();
67
+ if (!element) {
68
+ return;
69
+ }
70
+ const closestUuid = findClosestUuid(element);
71
+ if (closestUuid) {
72
+ eventBus.emit("select", closestUuid);
73
+ } else {
74
+ eventBus.emit("select:unselect");
75
+ }
76
+ await renderCycle();
77
+ eventBus.emit("scrollIntoView", {
78
+ element
79
+ });
80
+ }
81
+ onBlokkliEvent("analyze:click-node", (e) => {
82
+ isFocused.value = false;
83
+ if (focusTimeout) {
84
+ window.clearTimeout(focusTimeout);
85
+ }
86
+ if (e.id === props.resultId) {
87
+ const el = getElement();
88
+ if (el === e.target && elButton.value) {
89
+ elButton.value.scrollIntoView({
90
+ behavior: "smooth",
91
+ block: "center"
92
+ });
93
+ isFocused.value = true;
94
+ focusTimeout = window.setTimeout(() => {
95
+ isFocused.value = false;
96
+ }, 1e3);
97
+ return;
98
+ }
99
+ }
100
+ });
101
+ </script>
@@ -0,0 +1,8 @@
1
+ type __VLS_Props = {
2
+ resultId: string;
3
+ target: string | HTMLElement | {
4
+ uuid: string;
5
+ };
6
+ };
7
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ export default _default;
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <div
3
+ class="bk-pill bk-analyze-status"
4
+ :class="status === 'inapplicable' ? 'bk-is-mono' : 'bk-is-' + status"
5
+ >
6
+ {{ label }}
7
+ </div>
8
+ </template>
9
+
10
+ <script setup>
11
+ import { computed } from "#imports";
12
+ import { useAnalyzeHelper } from "../helper";
13
+ const props = defineProps({
14
+ status: { type: String, required: false, default: "inapplicable" }
15
+ });
16
+ const { getStatusLabel } = useAnalyzeHelper();
17
+ const label = computed(() => getStatusLabel(props.status ?? "inapplicable"));
18
+ </script>
@@ -0,0 +1,8 @@
1
+ import type { AnalyzeStatus } from '../analyzers/types.js';
2
+ type __VLS_Props = {
3
+ status?: AnalyzeStatus;
4
+ };
5
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ status: AnalyzeStatus;
7
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ export default _default;
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <svg :width="size" :height="size" :viewBox="`0 0 ${size} ${size}`">
3
+ <circle
4
+ v-if="data.length === 1"
5
+ :cx="radius"
6
+ :cy="radius"
7
+ :r="radius"
8
+ :fill="data[0]?.color"
9
+ />
10
+ <g v-else :transform="`translate(${radius}, ${radius})`">
11
+ <path
12
+ v-for="(segment, index) in segments"
13
+ :key="index"
14
+ :d="segment.path"
15
+ :fill="segment.color"
16
+ stroke-width="2"
17
+ stroke="white"
18
+ />
19
+ </g>
20
+ <circle :cx="radius" :cy="radius" :r="radius - thickness" fill="white" />
21
+ <text
22
+ v-if="percentage !== void 0"
23
+ x="50%"
24
+ y="50%"
25
+ dominant-baseline="middle"
26
+ text-anchor="middle"
27
+ fill="currentColor"
28
+ >
29
+ {{ percentage }}%
30
+ </text>
31
+ </svg>
32
+ </template>
33
+
34
+ <script setup>
35
+ import { computed } from "#imports";
36
+ const props = defineProps({
37
+ data: { type: Array, required: true },
38
+ radius: { type: Number, required: false, default: 34 },
39
+ thickness: { type: Number, required: false, default: 10 },
40
+ percentage: { type: Number, required: false, default: void 0 }
41
+ });
42
+ const size = computed(() => props.radius * 2);
43
+ const segments = computed(() => {
44
+ const total = props.data.reduce((sum, item) => sum + item.value, 0);
45
+ if (total === 0) return [];
46
+ let currentAngle = -90;
47
+ return props.data.map((item) => {
48
+ const percentage = item.value / total;
49
+ const angle = percentage * 360;
50
+ const startAngle = currentAngle;
51
+ const endAngle = currentAngle + angle;
52
+ const path = createPieSegment(
53
+ 0,
54
+ 0,
55
+ // center x, y
56
+ props.radius,
57
+ startAngle,
58
+ endAngle
59
+ );
60
+ currentAngle = endAngle;
61
+ return {
62
+ path,
63
+ color: item.color,
64
+ label: item.label,
65
+ value: item.value,
66
+ percentage
67
+ };
68
+ });
69
+ });
70
+ function createPieSegment(cx, cy, radius, startAngle, endAngle) {
71
+ const start = startAngle * Math.PI / 180;
72
+ const end = endAngle * Math.PI / 180;
73
+ const x1 = cx + radius * Math.cos(start);
74
+ const y1 = cy + radius * Math.sin(start);
75
+ const x2 = cx + radius * Math.cos(end);
76
+ const y2 = cy + radius * Math.sin(end);
77
+ const largeArc = endAngle - startAngle > 180 ? 1 : 0;
78
+ if (endAngle - startAngle >= 360) {
79
+ return `
80
+ M ${cx + radius} ${cy}
81
+ A ${radius} ${radius} 0 1 1 ${cx + radius} ${cy + 1e-3}
82
+ Z
83
+ `;
84
+ }
85
+ return `
86
+ M ${cx} ${cy}
87
+ L ${x1} ${y1}
88
+ A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}
89
+ Z
90
+ `;
91
+ }
92
+ </script>
@@ -0,0 +1,17 @@
1
+ interface DataItem {
2
+ label: string;
3
+ value: number;
4
+ color: string;
5
+ }
6
+ type __VLS_Props = {
7
+ data: DataItem[];
8
+ radius?: number;
9
+ thickness?: number;
10
+ percentage?: number;
11
+ };
12
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
13
+ radius: number;
14
+ thickness: number;
15
+ percentage: number;
16
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ export default _default;