@blokkli/editor 2.0.0-alpha.35 → 2.0.0-alpha.36

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 (199) hide show
  1. package/dist/global/types/blockOptions.d.ts +9 -2
  2. package/dist/global/types/definitions.d.ts +12 -5
  3. package/dist/module.d.mts +2 -2
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +56 -4
  6. package/dist/modules/agent/index.d.mts +1 -1
  7. package/dist/modules/agent/index.mjs +38 -20
  8. package/dist/modules/agent/runtime/app/composables/agentProvider.d.ts +2 -2
  9. package/dist/modules/agent/runtime/app/composables/agentProvider.js +3 -3
  10. package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +34 -60
  11. package/dist/modules/agent/runtime/app/features/agent/Transcript/index.d.vue.ts +8 -0
  12. package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue +138 -0
  13. package/dist/modules/agent/runtime/app/features/agent/Transcript/index.vue.d.ts +8 -0
  14. package/dist/modules/agent/runtime/app/features/agent/index.vue +5 -1
  15. package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +175 -0
  16. package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +5 -0
  17. package/dist/modules/agent/runtime/app/tools/schemas.d.ts +10 -1
  18. package/dist/modules/agent/runtime/app/tools/schemas.js +36 -23
  19. package/dist/modules/agent/runtime/server/Session.d.ts +4 -2
  20. package/dist/modules/agent/runtime/server/Session.js +61 -57
  21. package/dist/modules/agent/runtime/server/agentPrompt.d.ts +9 -1
  22. package/dist/modules/agent/runtime/server/agentPrompt.js +26 -0
  23. package/dist/modules/agent/runtime/shared/types.d.ts +35 -1
  24. package/dist/modules/charts/index.d.mts +35 -0
  25. package/dist/modules/charts/index.mjs +43 -0
  26. package/dist/modules/charts/runtime/blokkli/skills/charts.d.ts +2 -0
  27. package/dist/modules/charts/runtime/blokkli/skills/charts.js +42 -0
  28. package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +63 -0
  29. package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +98 -0
  30. package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.d.ts +2 -0
  31. package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +86 -0
  32. package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.d.ts +2 -0
  33. package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +74 -0
  34. package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.d.ts +2 -0
  35. package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +42 -0
  36. package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.d.ts +2 -0
  37. package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +101 -0
  38. package/dist/modules/charts/runtime/chartTypes/area.d.ts +2 -0
  39. package/dist/modules/charts/runtime/chartTypes/area.js +68 -0
  40. package/dist/modules/charts/runtime/chartTypes/bar.d.ts +2 -0
  41. package/dist/modules/charts/runtime/chartTypes/bar.js +76 -0
  42. package/dist/modules/charts/runtime/chartTypes/define.d.ts +2 -0
  43. package/dist/modules/charts/runtime/chartTypes/define.js +3 -0
  44. package/dist/modules/charts/runtime/chartTypes/donut.d.ts +2 -0
  45. package/dist/modules/charts/runtime/chartTypes/donut.js +45 -0
  46. package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +2 -0
  47. package/dist/modules/charts/runtime/chartTypes/heatmap.js +54 -0
  48. package/dist/modules/charts/runtime/chartTypes/index.d.ts +21 -0
  49. package/dist/modules/charts/runtime/chartTypes/index.js +47 -0
  50. package/dist/modules/charts/runtime/chartTypes/line.d.ts +2 -0
  51. package/dist/modules/charts/runtime/chartTypes/line.js +68 -0
  52. package/dist/modules/charts/runtime/chartTypes/pie.d.ts +2 -0
  53. package/dist/modules/charts/runtime/chartTypes/pie.js +28 -0
  54. package/dist/modules/charts/runtime/chartTypes/radar.d.ts +2 -0
  55. package/dist/modules/charts/runtime/chartTypes/radar.js +52 -0
  56. package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +2 -0
  57. package/dist/modules/charts/runtime/chartTypes/radialBar.js +44 -0
  58. package/dist/modules/charts/runtime/chartTypes/shared.d.ts +52 -0
  59. package/dist/modules/charts/runtime/chartTypes/shared.js +103 -0
  60. package/dist/modules/charts/runtime/chartTypes/types.d.ts +29 -0
  61. package/dist/modules/charts/runtime/chartTypes/types.js +0 -0
  62. package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +4 -0
  63. package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +120 -0
  64. package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +4 -0
  65. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.d.vue.ts +3 -0
  66. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue +29 -0
  67. package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue.d.ts +3 -0
  68. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +15 -0
  69. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue +97 -0
  70. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +15 -0
  71. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.d.vue.ts +11 -0
  72. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue +34 -0
  73. package/dist/modules/charts/runtime/features/charts/Editor/ChartTypePicker/index.vue.d.ts +11 -0
  74. package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.d.vue.ts +12 -0
  75. package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue +49 -0
  76. package/dist/modules/charts/runtime/features/charts/Editor/ColorDropdown/index.vue.d.ts +12 -0
  77. package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.d.vue.ts +19 -0
  78. package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +90 -0
  79. package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue.d.ts +19 -0
  80. package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.d.vue.ts +23 -0
  81. package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue +224 -0
  82. package/dist/modules/charts/runtime/features/charts/Editor/DataTable/index.vue.d.ts +23 -0
  83. package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.d.vue.ts +10 -0
  84. package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +61 -0
  85. package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue.d.ts +10 -0
  86. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +8 -0
  87. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +23 -0
  88. package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +8 -0
  89. package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +10 -0
  90. package/dist/modules/charts/runtime/features/charts/Editor/index.vue +243 -0
  91. package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +10 -0
  92. package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.d.ts +17 -0
  93. package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +90 -0
  94. package/dist/modules/charts/runtime/features/charts/index.d.vue.ts +3 -0
  95. package/dist/modules/charts/runtime/features/charts/index.vue +72 -0
  96. package/dist/modules/charts/runtime/features/charts/index.vue.d.ts +3 -0
  97. package/dist/modules/charts/runtime/helpers/index.d.ts +1 -0
  98. package/dist/modules/charts/runtime/helpers/index.js +17 -0
  99. package/dist/modules/charts/runtime/types.d.ts +51 -0
  100. package/dist/modules/charts/runtime/types.js +64 -0
  101. package/dist/modules/drupal/graphql/features/fragments.graphql +2 -0
  102. package/dist/modules/drupal/index.d.mts +1 -1
  103. package/dist/modules/drupal/runtime/adapter/index.js +12 -8
  104. package/dist/modules/table-of-contents/index.d.mts +11 -0
  105. package/dist/modules/table-of-contents/index.mjs +24 -0
  106. package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.d.vue.ts +44 -0
  107. package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue +43 -0
  108. package/dist/modules/table-of-contents/runtime/components/BlokkliTableOfContents/index.vue.d.ts +44 -0
  109. package/dist/modules/table-of-contents/runtime/types/index.d.ts +4 -0
  110. package/dist/modules/table-of-contents/runtime/types/index.js +0 -0
  111. package/dist/runtime/components/Blocks/Fragment/index.vue +6 -2
  112. package/dist/runtime/components/BlokkliItem.vue +8 -3
  113. package/dist/runtime/components/BlokkliProvider.d.vue.ts +7 -0
  114. package/dist/runtime/components/BlokkliProvider.vue +7 -1
  115. package/dist/runtime/components/BlokkliProvider.vue.d.ts +7 -0
  116. package/dist/runtime/composables/useBlokkliHelper.js +4 -2
  117. package/dist/runtime/editor/components/AnimationCanvas/index.vue +4 -20
  118. package/dist/runtime/editor/components/Banner/index.d.vue.ts +12 -2
  119. package/dist/runtime/editor/components/Banner/index.vue +4 -2
  120. package/dist/runtime/editor/components/Banner/index.vue.d.ts +12 -2
  121. package/dist/runtime/editor/components/Dropdown/index.d.vue.ts +27 -0
  122. package/dist/runtime/editor/components/Dropdown/index.vue +107 -0
  123. package/dist/runtime/editor/components/Dropdown/index.vue.d.ts +27 -0
  124. package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue +1 -1
  125. package/dist/runtime/editor/components/EditProvider.d.vue.ts +2 -0
  126. package/dist/runtime/editor/components/EditProvider.vue +4 -3
  127. package/dist/runtime/editor/components/EditProvider.vue.d.ts +2 -0
  128. package/dist/runtime/editor/components/Form/Radio/index.d.vue.ts +1 -0
  129. package/dist/runtime/editor/components/Form/Radio/index.vue +3 -2
  130. package/dist/runtime/editor/components/Form/Radio/index.vue.d.ts +1 -0
  131. package/dist/runtime/editor/components/ItemIcon/index.vue +10 -2
  132. package/dist/runtime/editor/components/NestedEditorOverlay/index.d.vue.ts +13 -3
  133. package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +15 -7
  134. package/dist/runtime/editor/components/NestedEditorOverlay/index.vue.d.ts +13 -3
  135. package/dist/runtime/editor/components/PreviewProvider.d.vue.ts +2 -0
  136. package/dist/runtime/editor/components/PreviewProvider.vue +3 -2
  137. package/dist/runtime/editor/components/PreviewProvider.vue.d.ts +2 -0
  138. package/dist/runtime/editor/components/ShortcutIndicator/index.vue +1 -1
  139. package/dist/runtime/editor/components/index.d.ts +3 -1
  140. package/dist/runtime/editor/components/index.js +4 -0
  141. package/dist/runtime/editor/composables/onElementResize.js +0 -1
  142. package/dist/runtime/editor/composables/useEditableFieldOverride.js +4 -5
  143. package/dist/runtime/editor/css/output.css +1 -1
  144. package/dist/runtime/editor/events/index.d.ts +7 -0
  145. package/dist/runtime/editor/features/add-list/Help/Item.vue +5 -2
  146. package/dist/runtime/editor/features/artboard/Renderer.vue +1 -1
  147. package/dist/runtime/editor/features/clipboard/index.vue +1 -1
  148. package/dist/runtime/editor/features/debug/index.vue +1 -1
  149. package/dist/runtime/editor/features/dev-mode/index.vue +86 -2
  150. package/dist/runtime/editor/features/edit/index.vue +20 -0
  151. package/dist/runtime/editor/features/fragments/types.d.ts +1 -0
  152. package/dist/runtime/editor/features/hover/Renderer/index.vue +30 -3
  153. package/dist/runtime/editor/features/hover/index.vue +1 -1
  154. package/dist/runtime/editor/features/options/Form/Checkbox/index.d.vue.ts +2 -2
  155. package/dist/runtime/editor/features/options/Form/Checkbox/index.vue +3 -3
  156. package/dist/runtime/editor/features/options/Form/Checkbox/index.vue.d.ts +2 -2
  157. package/dist/runtime/editor/features/options/Form/Checkboxes/index.d.vue.ts +2 -2
  158. package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue +5 -5
  159. package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue.d.ts +2 -2
  160. package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +2 -2
  161. package/dist/runtime/editor/features/options/Form/Item.vue +14 -48
  162. package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +2 -2
  163. package/dist/runtime/editor/features/options/Form/Number/index.d.vue.ts +3 -3
  164. package/dist/runtime/editor/features/options/Form/Number/index.vue +7 -17
  165. package/dist/runtime/editor/features/options/Form/Number/index.vue.d.ts +3 -3
  166. package/dist/runtime/editor/features/options/Form/Range/index.d.vue.ts +2 -2
  167. package/dist/runtime/editor/features/options/Form/Range/index.vue +4 -4
  168. package/dist/runtime/editor/features/options/Form/Range/index.vue.d.ts +2 -2
  169. package/dist/runtime/editor/features/options/Form/index.vue +10 -5
  170. package/dist/runtime/editor/features/selection/index.vue +2 -2
  171. package/dist/runtime/editor/features/transform/index.vue +1 -3
  172. package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +1 -1
  173. package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +1 -1
  174. package/dist/runtime/editor/providers/definition.d.ts +2 -2
  175. package/dist/runtime/editor/providers/definition.js +7 -1
  176. package/dist/runtime/editor/providers/dom.d.ts +5 -0
  177. package/dist/runtime/editor/providers/dom.js +11 -2
  178. package/dist/runtime/editor/providers/fields.d.ts +19 -1
  179. package/dist/runtime/editor/providers/fields.js +54 -2
  180. package/dist/runtime/editor/translations/de.json +269 -1
  181. package/dist/runtime/editor/translations/fr.json +269 -1
  182. package/dist/runtime/editor/translations/gsw_CH.json +269 -1
  183. package/dist/runtime/editor/translations/it.json +269 -1
  184. package/dist/runtime/helpers/imports/index.d.ts +8 -1
  185. package/dist/runtime/helpers/imports/index.js +15 -6
  186. package/dist/runtime/helpers/injections.d.ts +5 -1
  187. package/dist/runtime/helpers/injections.js +3 -0
  188. package/dist/runtime/helpers/runtimeHelpers/index.js +14 -0
  189. package/dist/runtime/types/definitions.d.ts +8 -5
  190. package/dist/runtime/types/provider.d.ts +2 -0
  191. package/dist/shared/editor.6D5vApr0.mjs +30 -0
  192. package/dist/shared/{editor.DMFfaLVE.mjs → editor.BFIzNSQM.mjs} +1 -30
  193. package/dist/shared/{editor.Iax3GCvt.d.mts → editor.CWQIFIEQ.d.mts} +22 -0
  194. package/dist/types.d.mts +1 -1
  195. package/package.json +17 -1
  196. package/dist/modules/agent/runtime/app/tools/get_available_bundles/index.js +0 -104
  197. /package/dist/modules/agent/runtime/app/tools/{get_available_bundles → get_bundle_info}/index.d.ts +0 -0
  198. /package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.d.vue.ts +0 -0
  199. /package/dist/{modules/agent/runtime/app/features/agent/Panel/Input/Actions → runtime/editor/components}/DropdownItem/index.vue.d.ts +0 -0
@@ -0,0 +1,52 @@
1
+ import { defineChartType } from "./define.js";
2
+ import {
3
+ dataLabelsOptions,
4
+ buildDataLabelsOptions,
5
+ legendOptions,
6
+ buildLegendOptions,
7
+ mergeShared
8
+ } from "./shared.js";
9
+ export default defineChartType(($t) => {
10
+ const shared = mergeShared(dataLabelsOptions($t), legendOptions($t));
11
+ return {
12
+ id: "radar",
13
+ hasMultipleSeries: true,
14
+ hasSeriesColors: true,
15
+ hasCategoryColors: false,
16
+ buildChartOptions(ctx) {
17
+ return {
18
+ xaxis: { categories: ctx.categories },
19
+ markers: { size: ctx.typeOptions.markers ? 5 : 0 },
20
+ fill: { opacity: Number(ctx.typeOptions.fillOpacity) || 0.2 },
21
+ ...buildDataLabelsOptions(ctx.typeOptions),
22
+ ...buildLegendOptions(ctx.typeOptions)
23
+ };
24
+ },
25
+ buildSeries(ctx) {
26
+ return ctx.series.map((s) => ({ name: s.name, data: s.data }));
27
+ },
28
+ editor: {
29
+ label: $t("chartsTypeRadar", "Radar"),
30
+ icon: "bk_mdi_radar",
31
+ options: {
32
+ markers: {
33
+ type: "checkbox",
34
+ label: $t("chartsRadarMarkers", "Show markers"),
35
+ default: false,
36
+ group: "display"
37
+ },
38
+ fillOpacity: {
39
+ type: "radios",
40
+ label: $t("chartsRadarFillOpacity", "Fill opacity"),
41
+ default: "0.2",
42
+ options: {
43
+ "0.2": $t("chartsOpacityTransparent", "Transparent"),
44
+ "0.4": $t("chartsOpacityLight", "Light"),
45
+ "0.8": $t("chartsOpacitySolid", "Solid")
46
+ }
47
+ },
48
+ ...shared.options
49
+ }
50
+ }
51
+ };
52
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("./types.js").ChartTypeFactory;
2
+ export default _default;
@@ -0,0 +1,44 @@
1
+ import { defineChartType } from "./define.js";
2
+ export default defineChartType(($t) => ({
3
+ id: "radialBar",
4
+ hasMultipleSeries: false,
5
+ hasSeriesColors: false,
6
+ hasCategoryColors: true,
7
+ buildChartOptions(ctx) {
8
+ const showLabels = !!ctx.typeOptions.showLabels;
9
+ const showTotal = !!ctx.typeOptions.showTotal;
10
+ return {
11
+ labels: ctx.categories,
12
+ plotOptions: {
13
+ radialBar: {
14
+ dataLabels: {
15
+ name: { show: showLabels },
16
+ value: { show: showLabels },
17
+ total: { show: showTotal }
18
+ }
19
+ }
20
+ }
21
+ };
22
+ },
23
+ buildSeries(ctx) {
24
+ return ctx.series[0]?.data || [];
25
+ },
26
+ editor: {
27
+ label: $t("chartsTypeRadialBar", "Radial Bar"),
28
+ icon: "bk_mdi_track_changes",
29
+ options: {
30
+ showLabels: {
31
+ type: "checkbox",
32
+ label: $t("chartsRadialBarShowLabels", "Show labels"),
33
+ default: true,
34
+ group: "labels"
35
+ },
36
+ showTotal: {
37
+ type: "checkbox",
38
+ label: $t("chartsRadialBarShowTotal", "Show total"),
39
+ default: false,
40
+ group: "display"
41
+ }
42
+ }
43
+ }
44
+ }));
@@ -0,0 +1,52 @@
1
+ import type { BlokkliIcon } from '#blokkli-build/icons';
2
+ import type { BlockOptionDefinitionBase } from '../../../../global/types/blockOptions.js';
3
+ import type { TranslateFunction } from './types.js';
4
+ type SharedOptions = {
5
+ options: Record<string, BlockOptionDefinitionBase<BlokkliIcon>>;
6
+ };
7
+ /**
8
+ * Shared x-axis label options for chart types that display an x-axis.
9
+ */
10
+ export declare function xAxisOptions($t: TranslateFunction): SharedOptions;
11
+ /**
12
+ * Build x-axis label config from type options.
13
+ * Returns properties to merge into the xaxis config object.
14
+ */
15
+ export declare function buildXAxisLabelOptions(typeOptions: Record<string, unknown>): Record<string, any>;
16
+ /**
17
+ * Data labels option — show values directly on chart elements.
18
+ */
19
+ export declare function dataLabelsOptions($t: TranslateFunction): SharedOptions;
20
+ /**
21
+ * Build data labels config from type options.
22
+ */
23
+ export declare function buildDataLabelsOptions(typeOptions: Record<string, unknown>): Record<string, any>;
24
+ /**
25
+ * Legend position option for multi-series chart types.
26
+ */
27
+ export declare function legendOptions($t: TranslateFunction): SharedOptions;
28
+ /**
29
+ * Build legend config from type options.
30
+ */
31
+ export declare function buildLegendOptions(typeOptions: Record<string, unknown>): Record<string, any>;
32
+ /**
33
+ * Grid lines option for chart types with axes.
34
+ */
35
+ export declare function gridOptions($t: TranslateFunction): SharedOptions;
36
+ /**
37
+ * Build grid config from type options.
38
+ */
39
+ export declare function buildGridOptions(typeOptions: Record<string, unknown>): Record<string, any>;
40
+ /**
41
+ * Stroke width option for line-based chart types.
42
+ */
43
+ export declare function strokeWidthOptions($t: TranslateFunction): SharedOptions;
44
+ /**
45
+ * Build stroke width config from type options.
46
+ */
47
+ export declare function buildStrokeWidthOptions(typeOptions: Record<string, unknown>): Record<string, any>;
48
+ /**
49
+ * Merge multiple shared option sets into one.
50
+ */
51
+ export declare function mergeShared(...sets: SharedOptions[]): SharedOptions;
52
+ export {};
@@ -0,0 +1,103 @@
1
+ export function xAxisOptions($t) {
2
+ return {
3
+ options: {
4
+ xaxisRotation: {
5
+ type: "radios",
6
+ label: $t("chartsXAxisRotation", "Label rotation"),
7
+ default: "auto",
8
+ options: {
9
+ auto: $t("chartsRotationAuto", "Auto"),
10
+ "-45": "-45\xB0",
11
+ "-90": "-90\xB0"
12
+ }
13
+ }
14
+ }
15
+ };
16
+ }
17
+ export function buildXAxisLabelOptions(typeOptions) {
18
+ const rotation = typeOptions.xaxisRotation;
19
+ if (rotation && rotation !== "auto") {
20
+ return {
21
+ labels: {
22
+ rotate: Number(rotation),
23
+ rotateAlways: true
24
+ }
25
+ };
26
+ }
27
+ return {};
28
+ }
29
+ export function dataLabelsOptions($t) {
30
+ return {
31
+ options: {
32
+ dataLabels: {
33
+ type: "checkbox",
34
+ label: $t("chartsDataLabels", "Data labels"),
35
+ default: false,
36
+ group: "labels"
37
+ }
38
+ }
39
+ };
40
+ }
41
+ export function buildDataLabelsOptions(typeOptions) {
42
+ return { dataLabels: { enabled: !!typeOptions.dataLabels } };
43
+ }
44
+ export function legendOptions($t) {
45
+ return {
46
+ options: {
47
+ legendPosition: {
48
+ type: "radios",
49
+ label: $t("chartsLegendPosition", "Legend position"),
50
+ default: "bottom",
51
+ options: {
52
+ bottom: $t("chartsPositionBottom", "Bottom"),
53
+ top: $t("chartsPositionTop", "Top"),
54
+ right: $t("chartsPositionRight", "Right")
55
+ }
56
+ }
57
+ }
58
+ };
59
+ }
60
+ export function buildLegendOptions(typeOptions) {
61
+ return { legend: { position: typeOptions.legendPosition || "bottom" } };
62
+ }
63
+ export function gridOptions($t) {
64
+ return {
65
+ options: {
66
+ gridLines: {
67
+ type: "checkbox",
68
+ label: $t("chartsGridLines", "Grid lines"),
69
+ default: true,
70
+ group: "display"
71
+ }
72
+ }
73
+ };
74
+ }
75
+ export function buildGridOptions(typeOptions) {
76
+ return { grid: { show: !!typeOptions.gridLines } };
77
+ }
78
+ export function strokeWidthOptions($t) {
79
+ return {
80
+ options: {
81
+ strokeWidth: {
82
+ type: "radios",
83
+ label: $t("chartsStrokeWidth", "Line thickness"),
84
+ default: "2",
85
+ options: {
86
+ "2": $t("chartsStrokeThin", "Thin"),
87
+ "4": $t("chartsStrokeMedium", "Medium"),
88
+ "6": $t("chartsStrokeThick", "Thick")
89
+ }
90
+ }
91
+ }
92
+ };
93
+ }
94
+ export function buildStrokeWidthOptions(typeOptions) {
95
+ return { stroke: { width: Number(typeOptions.strokeWidth) || 2 } };
96
+ }
97
+ export function mergeShared(...sets) {
98
+ const options = {};
99
+ for (const set of sets) {
100
+ Object.assign(options, set.options);
101
+ }
102
+ return { options };
103
+ }
@@ -0,0 +1,29 @@
1
+ import type { BlokkliIcon } from '#blokkli-build/icons';
2
+ import type { BlockOptionDefinitionBase } from '../../../../global/types/blockOptions.js';
3
+ export type TranslateFunction = (key: string, fallback: string) => string;
4
+ export type ChartBuildContext = {
5
+ title: string;
6
+ categories: string[];
7
+ series: Array<{
8
+ name: string;
9
+ color: string;
10
+ data: number[];
11
+ }>;
12
+ seriesColors: string[];
13
+ categoryColors: string[];
14
+ typeOptions: Record<string, unknown>;
15
+ };
16
+ export type ChartTypeDefinition = {
17
+ id: string;
18
+ hasMultipleSeries: boolean;
19
+ hasSeriesColors: boolean;
20
+ hasCategoryColors: boolean;
21
+ buildChartOptions: (ctx: ChartBuildContext) => Record<string, any>;
22
+ buildSeries: (ctx: ChartBuildContext) => any;
23
+ editor: {
24
+ label: string;
25
+ icon: BlokkliIcon;
26
+ options: Record<string, BlockOptionDefinitionBase<BlokkliIcon>>;
27
+ };
28
+ };
29
+ export type ChartTypeFactory = ($t: TranslateFunction) => ChartTypeDefinition;
@@ -0,0 +1,4 @@
1
+ import type { BlokkliChartData } from '../../types.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<BlokkliChartData, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<BlokkliChartData> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
@@ -0,0 +1,120 @@
1
+ <template>
2
+ <div ref="rootEl">
3
+ <component
4
+ :is="ApexChart"
5
+ v-if="ApexChart"
6
+ :type="type"
7
+ :options="chartOptions"
8
+ :series="chartSeries"
9
+ height="350"
10
+ />
11
+ <ol v-if="footnotes?.length" class="bk-chart-footnotes">
12
+ <li v-for="(note, i) in footnotes" :key="i">
13
+ <span class="bk-chart-footnote-marker">{{
14
+ superscriptFor(i + 1)
15
+ }}</span>
16
+ {{ note }}
17
+ </li>
18
+ </ol>
19
+ </div>
20
+ </template>
21
+
22
+ <script setup>
23
+ import { computed, defineAsyncComponent, useTemplateRef } from "#imports";
24
+ import { resolveChartColor, applyFootnotes, SUPERSCRIPTS } from "../../types";
25
+ import { getChartTypeRuntime, getDefaultTypeOptions } from "../../chartTypes";
26
+ import { COLORS } from "#blokkli-build/charts-config";
27
+ const ApexChart = defineAsyncComponent(() => import("vue3-apexcharts"));
28
+ const props = defineProps({
29
+ title: { type: String, required: true },
30
+ type: { type: String, required: true },
31
+ categories: { type: Array, required: true },
32
+ series: { type: Array, required: true },
33
+ categoryColors: { type: Array, required: true },
34
+ footnotes: { type: Array, required: true },
35
+ typeOptions: { type: Object, required: false }
36
+ });
37
+ const rootEl = useTemplateRef("rootEl");
38
+ const chartDef = computed(() => getChartTypeRuntime(props.type));
39
+ function superscriptFor(n) {
40
+ return String(n).split("").map((d) => SUPERSCRIPTS[d] || d).join("");
41
+ }
42
+ function deepMerge(target, source) {
43
+ const result = { ...target };
44
+ for (const key of Object.keys(source)) {
45
+ if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key]) && typeof source[key] === "object" && !Array.isArray(source[key])) {
46
+ result[key] = deepMerge(result[key], source[key]);
47
+ } else {
48
+ result[key] = source[key];
49
+ }
50
+ }
51
+ return result;
52
+ }
53
+ const resolvedColors = computed(() => {
54
+ const def = chartDef.value;
55
+ if (!def) return [];
56
+ if (def.hasCategoryColors) {
57
+ return props.categoryColors.map(
58
+ (id) => resolveChartColor(id, COLORS, rootEl.value)
59
+ );
60
+ }
61
+ if (def.hasSeriesColors) {
62
+ return props.series.map(
63
+ (s) => resolveChartColor(s.color, COLORS, rootEl.value)
64
+ );
65
+ }
66
+ return [];
67
+ });
68
+ const chartOptions = computed(() => {
69
+ const def = chartDef.value;
70
+ if (!def) return {};
71
+ const base = {
72
+ chart: {
73
+ toolbar: { show: false }
74
+ }
75
+ };
76
+ if (resolvedColors.value.length) {
77
+ base.colors = resolvedColors.value;
78
+ }
79
+ if (props.title) {
80
+ base.title = { text: applyFootnotes(props.title), align: "left" };
81
+ }
82
+ const ctx = {
83
+ title: props.title,
84
+ categories: props.categories.map(applyFootnotes),
85
+ series: props.series.map((s) => ({
86
+ name: applyFootnotes(s.name),
87
+ color: s.color,
88
+ data: s.data
89
+ })),
90
+ seriesColors: resolvedColors.value,
91
+ categoryColors: resolvedColors.value,
92
+ typeOptions: {
93
+ ...getDefaultTypeOptions(props.type),
94
+ ...props.typeOptions
95
+ }
96
+ };
97
+ const typeOpts = def.buildChartOptions(ctx);
98
+ return deepMerge(base, typeOpts);
99
+ });
100
+ const chartSeries = computed(() => {
101
+ const def = chartDef.value;
102
+ if (!def) return [];
103
+ const ctx = {
104
+ title: props.title,
105
+ categories: props.categories.map(applyFootnotes),
106
+ series: props.series.map((s) => ({
107
+ name: applyFootnotes(s.name),
108
+ color: s.color,
109
+ data: s.data
110
+ })),
111
+ seriesColors: resolvedColors.value,
112
+ categoryColors: resolvedColors.value,
113
+ typeOptions: {
114
+ ...getDefaultTypeOptions(props.type),
115
+ ...props.typeOptions
116
+ }
117
+ };
118
+ return def.buildSeries(ctx);
119
+ });
120
+ </script>
@@ -0,0 +1,4 @@
1
+ import type { BlokkliChartData } from '../../types.js';
2
+ declare const __VLS_export: import("vue").DefineComponent<BlokkliChartData, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<BlokkliChartData> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
3
+ declare const _default: typeof __VLS_export;
4
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,29 @@
1
+ <template>
2
+ <div class="blokkli-fragment-chart">
3
+ <ChartRenderer v-if="data && data.series?.length > 0" v-bind="data" />
4
+ <div v-else>Missing chart data.</div>
5
+ </div>
6
+ </template>
7
+
8
+ <script setup>
9
+ import { defineBlokkliFragment, computed } from "#imports";
10
+ import ChartRenderer from "./../ChartRenderer/index.vue";
11
+ const { options } = defineBlokkliFragment({
12
+ name: "blokkli_chart",
13
+ label: "Chart",
14
+ description: "Create interactive charts.",
15
+ editor: {
16
+ previewWidth: 1200
17
+ },
18
+ options: {
19
+ data: {
20
+ type: "json",
21
+ label: "The chart data.",
22
+ default: "{}"
23
+ }
24
+ }
25
+ });
26
+ const data = computed(() => {
27
+ return options.value.data;
28
+ });
29
+ </script>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { BlockOptionDefinition } from '#blokkli/types/blockOptions';
2
+ type __VLS_Props = {
3
+ title: string;
4
+ options: Record<string, BlockOptionDefinition>;
5
+ typeOptions: Record<string, unknown>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ "update:title": (value: unknown) => any;
9
+ "update:typeOptions": (value: Record<string, unknown>) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:title"?: ((value: unknown) => any) | undefined;
12
+ "onUpdate:typeOptions"?: ((value: Record<string, unknown>) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <div class="bk-chart-type-options">
3
+ <OptionsFormItem
4
+ :option="titleOption"
5
+ property="title"
6
+ :mutated-value="title"
7
+ @update="$emit('update:title', $event)"
8
+ />
9
+
10
+ <OptionsFormItem
11
+ v-for="item in ungroupedOptions"
12
+ :key="item.key"
13
+ :option="item.option"
14
+ :property="item.key"
15
+ :mutated-value="typeOptions[item.key] ?? item.option.default"
16
+ @update="updateOption(item.key, $event)"
17
+ />
18
+
19
+ <OptionsFormGroup
20
+ v-for="group in groups"
21
+ :key="'group_' + group.label"
22
+ :label="group.label"
23
+ :is-active="group.label === activeGroup"
24
+ @toggle="onToggleGroup(group.label)"
25
+ >
26
+ <OptionsFormItem
27
+ v-for="item in group.options"
28
+ :key="item.key"
29
+ :option="item.option"
30
+ :property="item.key"
31
+ :mutated-value="typeOptions[item.key] ?? item.option.default"
32
+ is-grouped
33
+ @update="updateOption(item.key, $event)"
34
+ />
35
+ </OptionsFormGroup>
36
+ </div>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { computed, ref, useBlokkli } from "#imports";
41
+ import OptionsFormItem from "#blokkli/editor/features/options/Form/Item.vue";
42
+ import OptionsFormGroup from "#blokkli/editor/features/options/Form/Group.vue";
43
+ const { $t } = useBlokkli();
44
+ const props = defineProps({
45
+ title: { type: String, required: true },
46
+ options: { type: Object, required: true },
47
+ typeOptions: { type: Object, required: true }
48
+ });
49
+ const emit = defineEmits(["update:title", "update:typeOptions"]);
50
+ const titleOption = {
51
+ type: "text",
52
+ label: $t("chartsTitle", "Title"),
53
+ default: ""
54
+ };
55
+ const activeGroup = ref("");
56
+ function onToggleGroup(label) {
57
+ if (activeGroup.value === label) {
58
+ activeGroup.value = "";
59
+ } else {
60
+ activeGroup.value = label;
61
+ }
62
+ }
63
+ const allOptions = computed(
64
+ () => Object.entries(props.options).map(([key, option]) => ({ key, option }))
65
+ );
66
+ const ungroupedOptions = computed(
67
+ () => allOptions.value.filter((v) => !v.option.group)
68
+ );
69
+ function getGroupLabel(group) {
70
+ if (group === "display") {
71
+ return $t("chartsOptionGroupDisplay", "Display");
72
+ } else if (group === "labels") {
73
+ return $t("chartsOptionGroupLabels", "Labels");
74
+ }
75
+ return group;
76
+ }
77
+ const groups = computed(() => {
78
+ return Object.values(
79
+ allOptions.value.reduce((acc, entry) => {
80
+ if (entry.option.group) {
81
+ if (!acc[entry.option.group]) {
82
+ acc[entry.option.group] = {
83
+ label: getGroupLabel(entry.option.group),
84
+ options: [entry]
85
+ };
86
+ } else {
87
+ acc[entry.option.group].options.push(entry);
88
+ }
89
+ }
90
+ return acc;
91
+ }, {})
92
+ );
93
+ });
94
+ function updateOption(key, value) {
95
+ emit("update:typeOptions", { ...props.typeOptions, [key]: value });
96
+ }
97
+ </script>
@@ -0,0 +1,15 @@
1
+ import type { BlockOptionDefinition } from '#blokkli/types/blockOptions';
2
+ type __VLS_Props = {
3
+ title: string;
4
+ options: Record<string, BlockOptionDefinition>;
5
+ typeOptions: Record<string, unknown>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ "update:title": (value: unknown) => any;
9
+ "update:typeOptions": (value: Record<string, unknown>) => any;
10
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
11
+ "onUpdate:title"?: ((value: unknown) => any) | undefined;
12
+ "onUpdate:typeOptions"?: ((value: Record<string, unknown>) => any) | undefined;
13
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ declare const _default: typeof __VLS_export;
15
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import type { ChartType } from '../../../../types.js';
2
+ type __VLS_Props = {
3
+ modelValue: ChartType;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: ChartType) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: ChartType) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div class="bk-chart-type-picker">
3
+ <button
4
+ v-for="option in chartTypes"
5
+ :key="option.value"
6
+ type="button"
7
+ :class="{ 'is-active': modelValue === option.value }"
8
+ @click="emit('update:modelValue', option.value)"
9
+ >
10
+ <div>
11
+ <Icon :name="option.icon" />
12
+ <span>{{ option.label }}</span>
13
+ </div>
14
+ </button>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { computed, useBlokkli } from "#imports";
20
+ import { getChartTypes } from "../../../../chartTypes";
21
+ import { Icon } from "#blokkli/editor/components";
22
+ defineProps({
23
+ modelValue: { type: String, required: true }
24
+ });
25
+ const emit = defineEmits(["update:modelValue"]);
26
+ const { $t } = useBlokkli();
27
+ const chartTypes = computed(
28
+ () => getChartTypes($t).map((def) => ({
29
+ value: def.id,
30
+ label: def.editor.label,
31
+ icon: def.editor.icon
32
+ }))
33
+ );
34
+ </script>
@@ -0,0 +1,11 @@
1
+ import type { ChartType } from '../../../../types.js';
2
+ type __VLS_Props = {
3
+ modelValue: ChartType;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ "update:modelValue": (value: ChartType) => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ "onUpdate:modelValue"?: ((value: ChartType) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import type { ChartColor } from '../../../../types.js';
2
+ type __VLS_Props = {
3
+ colorId: string;
4
+ colors: Record<string, ChartColor>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ select: (colorId: string) => any;
8
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
9
+ onSelect?: ((colorId: string) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;