minerva-design 1.17.2 → 1.19.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 (98) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/custom-elements.json +10 -6
  3. package/dist/angular/fesm2022/minerva-angular.mjs +173 -70
  4. package/dist/angular/fesm2022/minerva-angular.mjs.map +1 -1
  5. package/dist/angular/types/minerva-angular.d.ts +33 -21
  6. package/dist/charts/core.cjs +1 -1
  7. package/dist/charts/core.d.cts +1 -0
  8. package/dist/charts/core.d.ts +1 -0
  9. package/dist/charts/core.js +22 -21
  10. package/dist/charts/engine/chart.cjs +1 -1
  11. package/dist/charts/engine/chart.cjs.map +1 -1
  12. package/dist/charts/engine/chart.js +414 -376
  13. package/dist/charts/engine/chart.js.map +1 -1
  14. package/dist/charts/engine/overlay.cjs +1 -1
  15. package/dist/charts/engine/overlay.cjs.map +1 -1
  16. package/dist/charts/engine/overlay.d.cts +5 -0
  17. package/dist/charts/engine/overlay.d.ts +5 -0
  18. package/dist/charts/engine/overlay.js +94 -69
  19. package/dist/charts/engine/overlay.js.map +1 -1
  20. package/dist/charts/engine/quadrant-card.cjs +2 -0
  21. package/dist/charts/engine/quadrant-card.cjs.map +1 -0
  22. package/dist/charts/engine/quadrant-card.d.cts +83 -0
  23. package/dist/charts/engine/quadrant-card.d.ts +83 -0
  24. package/dist/charts/engine/quadrant-card.js +154 -0
  25. package/dist/charts/engine/quadrant-card.js.map +1 -0
  26. package/dist/charts/engine/scene.cjs +1 -1
  27. package/dist/charts/engine/scene.cjs.map +1 -1
  28. package/dist/charts/engine/scene.d.cts +5 -0
  29. package/dist/charts/engine/scene.d.ts +5 -0
  30. package/dist/charts/engine/scene.js +32 -32
  31. package/dist/charts/engine/scene.js.map +1 -1
  32. package/dist/charts/engine/types.d.cts +14 -0
  33. package/dist/charts/engine/types.d.ts +14 -0
  34. package/dist/charts/index.cjs +1 -1
  35. package/dist/charts/index.js +28 -27
  36. package/dist/charts/react/Chart.cjs +1 -1
  37. package/dist/charts/react/Chart.cjs.map +1 -1
  38. package/dist/charts/react/Chart.d.cts +4 -2
  39. package/dist/charts/react/Chart.d.ts +4 -2
  40. package/dist/charts/react/Chart.js +42 -42
  41. package/dist/charts/react/Chart.js.map +1 -1
  42. package/dist/charts/react/charts.cjs +1 -1
  43. package/dist/charts/react/charts.cjs.map +1 -1
  44. package/dist/charts/react/charts.js +395 -391
  45. package/dist/charts/react/charts.js.map +1 -1
  46. package/dist/charts/react/types.d.cts +8 -2
  47. package/dist/charts/react/types.d.ts +8 -2
  48. package/dist/core/contracts.cjs +1 -1
  49. package/dist/core/contracts.cjs.map +1 -1
  50. package/dist/core/contracts.js +1 -1
  51. package/dist/core/contracts.js.map +1 -1
  52. package/dist/native/charts/src/engine/overlay.cjs +1 -1
  53. package/dist/native/charts/src/engine/overlay.cjs.map +1 -1
  54. package/dist/native/charts/src/engine/overlay.js +89 -65
  55. package/dist/native/charts/src/engine/overlay.js.map +1 -1
  56. package/dist/native/charts/src/engine/scene.cjs +1 -1
  57. package/dist/native/charts/src/engine/scene.cjs.map +1 -1
  58. package/dist/native/charts/src/engine/scene.js +32 -32
  59. package/dist/native/charts/src/engine/scene.js.map +1 -1
  60. package/dist/react/components/QuadrantTaskBoard/QuadrantTaskBoard.cjs +1 -1
  61. package/dist/react/components/QuadrantTaskBoard/QuadrantTaskBoard.cjs.map +1 -1
  62. package/dist/react/components/QuadrantTaskBoard/QuadrantTaskBoard.js +14 -8
  63. package/dist/react/components/QuadrantTaskBoard/QuadrantTaskBoard.js.map +1 -1
  64. package/dist/react/components/QuadrantTaskBoard/quadrantTaskBoard.module.scss.cjs +1 -1
  65. package/dist/react/components/QuadrantTaskBoard/quadrantTaskBoard.module.scss.cjs.map +1 -1
  66. package/dist/react/components/QuadrantTaskBoard/quadrantTaskBoard.module.scss.js +16 -15
  67. package/dist/react/components/QuadrantTaskBoard/quadrantTaskBoard.module.scss.js.map +1 -1
  68. package/dist/react/style.css +1 -1
  69. package/dist/react/styles/quadrant-task-board.css +1 -1
  70. package/dist/taro/index.js +1521 -1496
  71. package/dist/taro/style.css +22 -0
  72. package/dist/uni/manifest.d.ts +34 -34
  73. package/dist/uni/manifest.js +34 -39
  74. package/dist/uni/style.css +22 -0
  75. package/dist/vue/components/Chart/QuadrantChart.vue.d.ts +4 -3
  76. package/dist/vue/components/Chart/QuadrantChart.vue.js.map +1 -1
  77. package/dist/vue/components/Chart/QuadrantChart.vue_vue_type_script_setup_true_lang.js +186 -142
  78. package/dist/vue/components/Chart/QuadrantChart.vue_vue_type_script_setup_true_lang.js.map +1 -1
  79. package/dist/vue/components/Chart/cartesian.d.ts +5 -1
  80. package/dist/vue/components/Chart/cartesian.js +2 -0
  81. package/dist/vue/components/Chart/cartesian.js.map +1 -1
  82. package/dist/vue/components/QuadrantTaskBoard/QuadrantTaskBoard.vue.js.map +1 -1
  83. package/dist/vue/components/QuadrantTaskBoard/QuadrantTaskBoard.vue_vue_type_script_setup_true_lang.js +18 -12
  84. package/dist/vue/components/QuadrantTaskBoard/QuadrantTaskBoard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  85. package/dist/weapp/charts/canvas.js +48 -11
  86. package/dist/weapp/controls.wxss +22 -0
  87. package/dist/web-components/components/chart/chart.d.ts +4 -1
  88. package/dist/web-components/components/chart/chart.js +3 -1
  89. package/dist/web-components/components/chart/chart.js.map +1 -1
  90. package/dist/web-components/components/chart/charts.d.ts +34 -14
  91. package/dist/web-components/components/chart/charts.js +145 -98
  92. package/dist/web-components/components/chart/charts.js.map +1 -1
  93. package/dist/web-components/components/quadrant-task-board/quadrant-task-board.d.ts +8 -8
  94. package/dist/web-components/components/quadrant-task-board/quadrant-task-board.js +16 -12
  95. package/dist/web-components/components/quadrant-task-board/quadrant-task-board.js.map +1 -1
  96. package/dist/web-components/styles/QuadrantTaskBoard/quadrantTaskBoard.css.js +1 -1
  97. package/dist/web-components/styles/QuadrantTaskBoard/quadrantTaskBoard.css.js.map +1 -1
  98. package/package.json +1 -1
@@ -2439,6 +2439,28 @@
2439
2439
  height: 16px;
2440
2440
  flex: none;
2441
2441
  }
2442
+ /* Narrow phones (320px wide): the title comes first. The badge gives way
2443
+ (the 2 x 2 grid already places the quadrants) and the chips get tighter */
2444
+ @media (max-width: 360px) {
2445
+ .mn-quadrant-task-board__headers {
2446
+ gap: 4px;
2447
+ }
2448
+ .mn-quadrant-task-board__header {
2449
+ gap: 2px;
2450
+ padding-left: 8px;
2451
+ }
2452
+ .mn-quadrant-task-board__badge {
2453
+ display: none;
2454
+ }
2455
+ .mn-quadrant-task-board__title,
2456
+ .mn-quadrant-task-board__badge + .mn-quadrant-task-board__title {
2457
+ padding-left: 0;
2458
+ }
2459
+ .mn-quadrant-task-board__count {
2460
+ min-width: 16px;
2461
+ padding: 0 4px;
2462
+ }
2463
+ }
2442
2464
  .mn-quadrant-task-board__panel {
2443
2465
  position: relative;
2444
2466
  z-index: 1;
@@ -2,9 +2,10 @@ import { ChartHoverEvent, ChartRendererKind, ChartView, QuadrantCorner, Quadrant
2
2
  import { QuadrantDropTarget, QuadrantHeaderInfo } from './types.js';
3
3
  type __VLS_Slots = {
4
4
  /**
5
- * Content shown next to the active point (hovered, focused or
6
- * `selectedIndex`), outside the canvas hit region (e.g. edit / delete
7
- * buttons); it receives pointer events
5
+ * Actions of a point (e.g. compact edit / delete buttons), shown in the
6
+ * point card of the hovered or focused point, else of the `selectedIndex`
7
+ * point (with this slot, the selected point keeps its card); they receive
8
+ * pointer events
8
9
  */
9
10
  "point-actions"?: (props: {
10
11
  point: QuadrantPoint;
@@ -1 +1 @@
1
- {"version":3,"file":"QuadrantChart.vue.js","names":["_sfc_main","QuadrantChart_vue_vue_type_script_setup_true_lang_default","QuadrantChart_default"],"sources":["../../../../../vue/src/components/Chart/QuadrantChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n ref,\n useSlots,\n watch,\n type CSSProperties,\n} from \"vue\";\nimport {\n QUADRANT_CORNERS,\n createQuadrantPointLayer,\n quadrantChartOptions,\n quadrantGroups,\n quadrantOf,\n type ChartDragEvent,\n type ChartHoverEvent,\n type ChartRect,\n type ChartRendererKind,\n type ChartView,\n type QuadrantCorner,\n type QuadrantPoint,\n type QuadrantPointLayer,\n type QuadrantPointLayerOptions,\n} from \"minerva-design/charts/core\";\nimport { engineOptions, useCartesianChart } from \"./cartesian\";\nimport { raw } from \"./engine\";\nimport { quadrantChartProps } from \"./props\";\nimport type { QuadrantDropTarget, QuadrantHeaderInfo } from \"./types\";\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels. Dots can be dragged to another quadrant.\n */\ndefineOptions({ name: \"QuadrantChart\" });\nconst props = defineProps(quadrantChartProps);\nconst emit = defineEmits<{\n /** The hovered (or keyboard-focused) point changed (`null`: none) */\n hover: [event: ChartHoverEvent | null];\n /** A point was clicked */\n pointClick: [point: QuadrantPoint, index: number];\n /** The same point was clicked twice in quick succession */\n pointDoubleClick: [point: QuadrantPoint, index: number];\n /** A point is being dragged (on every move, with the quadrant under the pointer) */\n pointDrag: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The empty area of a quadrant was clicked */\n quadrantClick: [quadrant: QuadrantCorner, position: { x: number; y: number }];\n /** A dragged point was released (the chart does not move it: update `points`) */\n pointDrop: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The user zoomed or panned */\n zoom: [view: ChartView];\n /** The backend is ready (or fell back after a GPU loss) */\n rendererChange: [renderer: ChartRendererKind];\n}>();\ndefineSlots<{\n /**\n * Content shown next to the active point (hovered, focused or\n * `selectedIndex`), outside the canvas hit region (e.g. edit / delete\n * buttons); it receives pointer events\n */\n \"point-actions\"?: (props: { point: QuadrantPoint; index: number }) => unknown;\n /**\n * Header of each quadrant, in its outer corner (top edge for the top\n * quadrants, bottom edge for the bottom ones, aligned to the outer side);\n * replaces the drawn title, badge, description and count. The header\n * receives pointer events (e.g. an add button)\n */\n \"quadrant-header\"?: (props: {\n corner: QuadrantCorner;\n info: QuadrantHeaderInfo;\n }) => unknown;\n}>();\nconst slots = useSlots();\nconst vnode = getCurrentInstance()?.vnode;\n/** Two clicks on the same point within this delay count as a double click */\nconst DOUBLE_CLICK_MS = 400;\nlet lastClick: { index: number; time: number } | null = null;\nconst geometry = () => ({\n xDomain: raw(props.xDomain),\n yDomain: raw(props.yDomain),\n xSplit: props.xSplit,\n ySplit: props.ySplit,\n reverseX: props.reverseX,\n});\nconst dropAt = (event: ChartDragEvent): QuadrantDropTarget => ({\n x: event.x,\n y: event.y,\n quadrant: quadrantOf(geometry(), event.x, event.y),\n});\n// keyboard-focused point of the accessible layer (drawn with a focus ring)\nconst focusedIndex = ref<number | null>(null);\nconst root = ref<HTMLElement | null>(null);\n// plot area (overlay of the slots) and hovered point (active point actions)\nconst plot = ref<ChartRect | null>(null);\nconst hoveredIndex = ref<number | null>(null);\nconst build = () => {\n const headers = !!slots[\"quadrant-header\"];\n const options = quadrantChartOptions(\n {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n axisLabels: raw(props.axisLabels),\n showTicks: props.showTicks,\n showLabels: props.showLabels,\n pointSize: props.pointSize,\n name: props.name,\n draggable:\n props.draggable ??\n !!(vnode?.props?.onPointDrop || vnode?.props?.onPointDrag),\n showCounts: headers ? undefined : props.showCounts,\n selectedIndex: props.selectedIndex,\n selectedIndices: raw(props.selectedIndices),\n },\n (({ series: _series, ...rest }) => rest)(engineOptions(props, [])),\n { focusedIndex: props.accessiblePoints ? focusedIndex.value : null },\n );\n if (headers)\n // the slot headers replace the drawn titles (the first four areas)\n options.annotations = options.annotations?.map((a, i) =>\n i < 4 && a.type === \"rect\"\n ? {\n ...a,\n label: undefined,\n badge: undefined,\n description: undefined,\n detail: undefined,\n }\n : a,\n );\n return options;\n};\nconst { setContainer, rootStyle, handle } = useCartesianChart(props, build, {\n hover: (event) => {\n hoveredIndex.value = event?.items?.[0]?.index ?? null;\n emit(\"hover\", event);\n },\n click: (event) => {\n const index = event.items[0]?.index;\n const point = index === undefined ? undefined : props.points[index];\n if (!point || index === undefined) return;\n const now = Date.now();\n const double =\n lastClick?.index === index && now - lastClick.time < DOUBLE_CLICK_MS;\n lastClick = double ? null : { index, time: now };\n emit(\"pointClick\", point, index);\n if (double) emit(\"pointDoubleClick\", point, index);\n },\n plotClick: (at) =>\n emit(\"quadrantClick\", quadrantOf(geometry(), at.x, at.y), {\n x: at.x,\n y: at.y,\n }),\n drag: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrag\", point, event.item.index, dropAt(event));\n },\n drop: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrop\", point, event.item.index, dropAt(event));\n },\n zoom: (view) => emit(\"zoom\", view),\n renderer: (renderer) => emit(\"rendererChange\", renderer),\n layout: (rect) => {\n plot.value = rect;\n },\n});\n\n// the slots, over the plot area (same DOM as the React renderer)\nconst overlaid = computed(\n () => !!(slots[\"point-actions\"] || slots[\"quadrant-header\"]),\n);\nconst px = (value: number) => `${value}px`;\nconst fraction = (v: number, a: number, b: number) => (v - a) / (b - a || 1);\nconst domains = () => ({\n x: props.xDomain ?? [0, 10],\n y: props.yDomain ?? [0, 10],\n});\n/** Position of a data point in the plot, in fractions of its size */\nconst visual = (x: number, y: number) => {\n const d = domains();\n const fx = fraction(x, d.x[0], d.x[1]);\n return {\n x: props.reverseX ? 1 - fx : fx,\n y: 1 - fraction(y, d.y[0], d.y[1]),\n };\n};\nconst overlayStyle = computed<CSSProperties>(() => {\n const rect = plot.value;\n return rect\n ? {\n position: \"absolute\",\n left: px(rect.x),\n top: px(rect.y),\n width: px(rect.width),\n height: px(rect.height),\n pointerEvents: \"none\",\n }\n : { display: \"none\" };\n});\nconst cornerStyle = (corner: QuadrantCorner): CSSProperties => {\n const rect = plot.value ?? { width: 0, height: 0 };\n const d = domains();\n const split = visual(\n props.xSplit ?? (d.x[0] + d.x[1]) / 2,\n props.ySplit ?? (d.y[0] + d.y[1]) / 2,\n );\n const sx = rect.width * split.x;\n const sy = rect.height * split.y;\n const left = corner.endsWith(\"Left\");\n const top = corner.startsWith(\"top\");\n return {\n position: \"absolute\",\n left: px(left ? 0 : sx),\n top: px(top ? 0 : sy),\n width: px(left ? sx : rect.width - sx),\n height: px(top ? sy : rect.height - sy),\n pointerEvents: \"none\",\n };\n};\nconst headerStyle = (corner: QuadrantCorner): CSSProperties => {\n const top = corner.startsWith(\"top\");\n const left = corner.endsWith(\"Left\");\n return {\n position: \"absolute\",\n [top ? \"top\" : \"bottom\"]: 0,\n [left ? \"left\" : \"right\"]: 0,\n maxWidth: \"100%\",\n boxSizing: \"border-box\",\n padding: \"8px\",\n display: \"flex\",\n justifyContent: left ? \"flex-start\" : \"flex-end\",\n pointerEvents: \"auto\",\n };\n};\nconst groups = computed(() =>\n quadrantGroups({ ...geometry(), points: raw(props.points).map(raw) }),\n);\nconst headerInfo = (corner: QuadrantCorner): QuadrantHeaderInfo => ({\n count: groups.value[corner].points.length,\n points: groups.value[corner].points,\n indices: groups.value[corner].indices,\n region: props.quadrants?.[corner],\n});\n/** Point showing the `point-actions` slot */\nconst active = computed(() => {\n const index =\n hoveredIndex.value ?? focusedIndex.value ?? props.selectedIndex ?? null;\n const point = index === null ? undefined : props.points[index];\n if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y))\n return null;\n const at = visual(point.x, point.y);\n return {\n index: index!,\n point,\n style: {\n position: \"absolute\",\n left: `${100 * at.x}%`,\n top: `${100 * at.y}%`,\n width: 0,\n height: 0,\n pointerEvents: \"none\",\n } satisfies CSSProperties,\n };\n});\n\n// the accessible point layer (shared with the other DOM renderers)\nlet layer: QuadrantPointLayer | null = null;\nconst layerOptions = (): QuadrantPointLayerOptions => ({\n config: {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n name: props.name,\n },\n locale: props.locale,\n movable: !!vnode?.props?.onPointDrop && props.draggable !== false,\n selected: [\n ...(props.selectedIndices ?? []),\n ...(props.selectedIndex !== undefined && props.selectedIndex !== null\n ? [props.selectedIndex]\n : []),\n ],\n onFocusChange: (index, hover) => {\n focusedIndex.value = index;\n emit(\"hover\", hover);\n },\n onClick: (index) => {\n const point = props.points[index];\n if (point) emit(\"pointClick\", point, index);\n },\n onMove: (index, target) => {\n const point = props.points[index];\n if (point) emit(\"pointDrop\", point, index, target);\n },\n});\nconst syncLayer = () => {\n if (!props.accessiblePoints) {\n layer?.destroy();\n layer = null;\n focusedIndex.value = null;\n } else if (layer) layer.update(layerOptions());\n else if (root.value)\n layer = createQuadrantPointLayer(root.value, layerOptions());\n};\nonMounted(syncLayer);\nwatch(() => ({ ...props }), syncLayer, { flush: \"post\" });\n// the focus ring is not a prop: redraw on its own\nwatch(focusedIndex, () => handle.getInstance()?.setOptions(build()));\nonBeforeUnmount(() => {\n layer?.destroy();\n layer = null;\n});\ndefineExpose(handle);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"mn-chart mn-quadrant-chart\"\n data-minerva=\"chart\"\n :style=\"rootStyle\"\n >\n <div :ref=\"setContainer\" style=\"position: absolute; inset: 0\"></div>\n <div v-if=\"overlaid\" class=\"minerva-chart-overlay\" :style=\"overlayStyle\">\n <template v-if=\"slots['quadrant-header'] && plot\">\n <div\n v-for=\"corner in QUADRANT_CORNERS\"\n :key=\"corner\"\n :style=\"cornerStyle(corner)\"\n >\n <div\n :class=\"`minerva-chart-quadrant-header minerva-chart-quadrant-header-${corner}`\"\n :style=\"headerStyle(corner)\"\n >\n <slot\n name=\"quadrant-header\"\n :corner=\"corner\"\n :info=\"headerInfo(corner)\"\n />\n </div>\n </div>\n </template>\n <div\n v-if=\"slots['point-actions'] && plot && active\"\n :key=\"`point-${active.index}`\"\n class=\"minerva-chart-quadrant-point\"\n :data-point-index=\"active.index\"\n :data-label=\"active.point.label\"\n :style=\"active.style\"\n >\n <slot\n name=\"point-actions\"\n :point=\"active.point\"\n :index=\"active.index\"\n />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"QuadrantChart.vue.js","names":["_sfc_main","QuadrantChart_vue_vue_type_script_setup_true_lang_default","QuadrantChart_default"],"sources":["../../../../../vue/src/components/Chart/QuadrantChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useSlots,\n watch,\n type CSSProperties,\n} from \"vue\";\nimport {\n QUADRANT_CORNERS,\n createQuadrantPointCard,\n createQuadrantPointLayer,\n quadrantChartOptions,\n quadrantGroups,\n quadrantOf,\n withQuadrantCard,\n type ChartDragEvent,\n type ChartHoverEvent,\n type ChartRect,\n type ChartRendererKind,\n type ChartView,\n type QuadrantAccessibleConfig,\n type QuadrantCorner,\n type QuadrantPoint,\n type QuadrantPointCard,\n type QuadrantPointCardOptions,\n type QuadrantPointLayer,\n type QuadrantPointLayerOptions,\n} from \"minerva-design/charts/core\";\nimport { engineOptions, useCartesianChart } from \"./cartesian\";\nimport { raw } from \"./engine\";\nimport { quadrantChartProps } from \"./props\";\nimport type { QuadrantDropTarget, QuadrantHeaderInfo } from \"./types\";\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels. Dots can be dragged to another quadrant.\n */\ndefineOptions({ name: \"QuadrantChart\" });\nconst props = defineProps(quadrantChartProps);\nconst emit = defineEmits<{\n /** The hovered (or keyboard-focused) point changed (`null`: none) */\n hover: [event: ChartHoverEvent | null];\n /** A point was clicked */\n pointClick: [point: QuadrantPoint, index: number];\n /** The same point was clicked twice in quick succession */\n pointDoubleClick: [point: QuadrantPoint, index: number];\n /** A point is being dragged (on every move, with the quadrant under the pointer) */\n pointDrag: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The empty area of a quadrant was clicked */\n quadrantClick: [quadrant: QuadrantCorner, position: { x: number; y: number }];\n /** A dragged point was released (the chart does not move it: update `points`) */\n pointDrop: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The user zoomed or panned */\n zoom: [view: ChartView];\n /** The backend is ready (or fell back after a GPU loss) */\n rendererChange: [renderer: ChartRendererKind];\n}>();\ndefineSlots<{\n /**\n * Actions of a point (e.g. compact edit / delete buttons), shown in the\n * point card of the hovered or focused point, else of the `selectedIndex`\n * point (with this slot, the selected point keeps its card); they receive\n * pointer events\n */\n \"point-actions\"?: (props: { point: QuadrantPoint; index: number }) => unknown;\n /**\n * Header of each quadrant, in its outer corner (top edge for the top\n * quadrants, bottom edge for the bottom ones, aligned to the outer side);\n * replaces the drawn title, badge, description and count. The header\n * receives pointer events (e.g. an add button)\n */\n \"quadrant-header\"?: (props: {\n corner: QuadrantCorner;\n info: QuadrantHeaderInfo;\n }) => unknown;\n}>();\nconst slots = useSlots();\nconst vnode = getCurrentInstance()?.vnode;\n/** Two clicks on the same point within this delay count as a double click */\nconst DOUBLE_CLICK_MS = 400;\nlet lastClick: { index: number; time: number } | null = null;\nconst geometry = () => ({\n xDomain: raw(props.xDomain),\n yDomain: raw(props.yDomain),\n xSplit: props.xSplit,\n ySplit: props.ySplit,\n reverseX: props.reverseX,\n});\nconst dropAt = (event: ChartDragEvent): QuadrantDropTarget => ({\n x: event.x,\n y: event.y,\n quadrant: quadrantOf(geometry(), event.x, event.y),\n});\n// keyboard-focused point of the accessible layer (drawn with a focus ring)\nconst focusedIndex = ref<number | null>(null);\nconst root = ref<HTMLElement | null>(null);\n// plot area (overlay of the slots and of the point card)\nconst plot = ref<ChartRect | null>(null);\n// the point card is DOM of its own (shared with the other renderers): hover,\n// focus and drag moves render nothing here; only the `point-actions` slot is\n// rendered again (teleported into the card) when another point shows it\nconst cardHost = ref<HTMLElement | null>(null);\nconst card = shallowRef<QuadrantPointCard | null>(null);\nconst cardIndex = ref<number | null>(null);\n// before the engine is destroyed: the card gives the drawn label back to it\nonBeforeUnmount(() => {\n card.value?.destroy();\n card.value = null;\n});\nconst build = () => {\n const headers = !!slots[\"quadrant-header\"];\n // the point card names the hovered, focused, selected or dragged point: no\n // tooltip, no label chip and no drag pill of the engine beside it\n const options = withQuadrantCard(\n quadrantChartOptions(\n {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n axisLabels: raw(props.axisLabels),\n showTicks: props.showTicks,\n showLabels: props.showLabels,\n pointSize: props.pointSize,\n name: props.name,\n draggable:\n props.draggable ??\n !!(vnode?.props?.onPointDrop || vnode?.props?.onPointDrag),\n showCounts: headers ? undefined : props.showCounts,\n selectedIndex: props.selectedIndex,\n selectedIndices: raw(props.selectedIndices),\n },\n (({ series: _series, ...rest }) => rest)(engineOptions(props, [])),\n { focusedIndex: props.accessiblePoints ? focusedIndex.value : null },\n ),\n );\n if (headers)\n // the slot headers replace the drawn titles (the first four areas)\n options.annotations = options.annotations?.map((a, i) =>\n i < 4 && a.type === \"rect\"\n ? {\n ...a,\n label: undefined,\n badge: undefined,\n description: undefined,\n detail: undefined,\n }\n : a,\n );\n return options;\n};\n// a click on a dot or on the name in its card; two quick ones in a row\n// count as a double click\nconst clickPoint = (index: number) => {\n const point = props.points[index];\n if (!point) return;\n const now = Date.now();\n const double =\n lastClick?.index === index && now - lastClick.time < DOUBLE_CLICK_MS;\n lastClick = double ? null : { index, time: now };\n emit(\"pointClick\", point, index);\n if (double) emit(\"pointDoubleClick\", point, index);\n};\nconst { setContainer, rootStyle, handle } = useCartesianChart(props, build, {\n hover: (event) => {\n card.value?.hover(event?.items?.[0]?.index ?? null);\n emit(\"hover\", event);\n },\n click: (event) => {\n const index = event.items[0]?.index;\n if (index !== undefined) clickPoint(index);\n },\n plotClick: (at) =>\n emit(\"quadrantClick\", quadrantOf(geometry(), at.x, at.y), {\n x: at.x,\n y: at.y,\n }),\n dragStart: (event) =>\n card.value?.drag(event.item.index, { x: event.x, y: event.y }),\n drag: (event) => {\n card.value?.move({ x: event.x, y: event.y });\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrag\", point, event.item.index, dropAt(event));\n },\n dragEnd: () => card.value?.drag(null),\n drop: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrop\", point, event.item.index, dropAt(event));\n },\n zoom: (view) => emit(\"zoom\", view),\n renderer: (renderer) => emit(\"rendererChange\", renderer),\n layout: (rect) => {\n plot.value = rect;\n },\n});\n\n// the slots and the point card, over the plot area (same DOM as the React\n// renderer)\nconst px = (value: number) => `${value}px`;\nconst fraction = (v: number, a: number, b: number) => (v - a) / (b - a || 1);\nconst domains = () => ({\n x: props.xDomain ?? [0, 10],\n y: props.yDomain ?? [0, 10],\n});\n/** Position of a data point in the plot, in fractions of its size */\nconst visual = (x: number, y: number) => {\n const d = domains();\n const fx = fraction(x, d.x[0], d.x[1]);\n return {\n x: props.reverseX ? 1 - fx : fx,\n y: 1 - fraction(y, d.y[0], d.y[1]),\n };\n};\nconst overlayStyle = computed<CSSProperties>(() => {\n const rect = plot.value;\n return rect\n ? {\n position: \"absolute\",\n left: px(rect.x),\n top: px(rect.y),\n width: px(rect.width),\n height: px(rect.height),\n pointerEvents: \"none\",\n }\n : { display: \"none\" };\n});\n/** The box of the point card: the plot, in pixels (the card reads its size) */\nconst cardHostStyle = computed<CSSProperties>(() => ({\n position: \"absolute\",\n left: 0,\n top: 0,\n width: px(plot.value?.width ?? 0),\n height: px(plot.value?.height ?? 0),\n pointerEvents: \"none\",\n}));\nconst cornerStyle = (corner: QuadrantCorner): CSSProperties => {\n const rect = plot.value ?? { width: 0, height: 0 };\n const d = domains();\n const split = visual(\n props.xSplit ?? (d.x[0] + d.x[1]) / 2,\n props.ySplit ?? (d.y[0] + d.y[1]) / 2,\n );\n const sx = rect.width * split.x;\n const sy = rect.height * split.y;\n const left = corner.endsWith(\"Left\");\n const top = corner.startsWith(\"top\");\n return {\n position: \"absolute\",\n left: px(left ? 0 : sx),\n top: px(top ? 0 : sy),\n width: px(left ? sx : rect.width - sx),\n height: px(top ? sy : rect.height - sy),\n pointerEvents: \"none\",\n };\n};\nconst headerStyle = (corner: QuadrantCorner): CSSProperties => {\n const top = corner.startsWith(\"top\");\n const left = corner.endsWith(\"Left\");\n return {\n position: \"absolute\",\n [top ? \"top\" : \"bottom\"]: 0,\n [left ? \"left\" : \"right\"]: 0,\n maxWidth: \"100%\",\n boxSizing: \"border-box\",\n padding: \"8px\",\n display: \"flex\",\n justifyContent: left ? \"flex-start\" : \"flex-end\",\n pointerEvents: \"auto\",\n };\n};\nconst groups = computed(() =>\n quadrantGroups({ ...geometry(), points: raw(props.points).map(raw) }),\n);\nconst headerInfo = (corner: QuadrantCorner): QuadrantHeaderInfo => ({\n count: groups.value[corner].points.length,\n points: groups.value[corner].points,\n indices: groups.value[corner].indices,\n region: props.quadrants?.[corner],\n});\n/** Point of the card whose actions the `point-actions` slot renders */\nconst cardPoint = computed(() => {\n const index = cardIndex.value;\n const point = index === null ? undefined : props.points[index];\n return point && index !== null ? { index, point } : null;\n});\n\n/** The points and the geometry, for the accessible layer and the card */\nconst pointConfig = (): QuadrantAccessibleConfig => ({\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n name: props.name,\n});\n\nconst cardOptions = (): QuadrantPointCardOptions => ({\n config: pointConfig(),\n locale: props.locale,\n pointSize: props.pointSize,\n // the hovered point shows its card unless the tooltip is off\n hover: props.tooltip !== false,\n selectedIndex: props.selectedIndex,\n // a plain chart rings its selected point; a board keeps its card (the\n // actions of the point stay at hand)\n showSelected: !!slots[\"point-actions\"],\n hasActions: () => !!slots[\"point-actions\"],\n chart: handle.getInstance(),\n onClick: clickPoint,\n onChange: (index) => {\n cardIndex.value = index;\n },\n});\n// the box of the card is rendered once the plot is laid out\nwatch(\n [cardHost, () => handle.getInstance()],\n ([host, chart]) => {\n card.value?.destroy();\n card.value = null;\n cardIndex.value = null;\n if (host && chart)\n card.value = createQuadrantPointCard(host, cardOptions());\n },\n { flush: \"post\" },\n);\nconst syncCard = () => card.value?.update(cardOptions());\n// new slots (re-rendered by the parent), and the actions rendered in the\n// card: its size and place follow\nonUpdated(syncCard);\n// the focused point button, named again by the new points\nwatch(\n [card, focusedIndex, () => props.points, () => props.accessiblePoints],\n () => card.value?.focus(props.accessiblePoints ? focusedIndex.value : null),\n { flush: \"post\" },\n);\n\n// the accessible point layer (shared with the other DOM renderers)\nlet layer: QuadrantPointLayer | null = null;\nconst layerOptions = (): QuadrantPointLayerOptions => ({\n config: pointConfig(),\n locale: props.locale,\n movable: !!vnode?.props?.onPointDrop && props.draggable !== false,\n selected: [\n ...(props.selectedIndices ?? []),\n ...(props.selectedIndex !== undefined && props.selectedIndex !== null\n ? [props.selectedIndex]\n : []),\n ],\n onFocusChange: (index, hover) => {\n focusedIndex.value = index;\n emit(\"hover\", hover);\n },\n onClick: (index) => {\n const point = props.points[index];\n if (point) emit(\"pointClick\", point, index);\n },\n onMove: (index, target) => {\n const point = props.points[index];\n if (point) emit(\"pointDrop\", point, index, target);\n },\n});\nconst syncLayer = () => {\n if (!props.accessiblePoints) {\n layer?.destroy();\n layer = null;\n focusedIndex.value = null;\n } else if (layer) layer.update(layerOptions());\n else if (root.value)\n layer = createQuadrantPointLayer(root.value, layerOptions());\n};\nonMounted(syncLayer);\nwatch(\n () => ({ ...props }),\n () => {\n syncLayer();\n syncCard();\n },\n { flush: \"post\" },\n);\n// the focus ring is not a prop: redraw on its own\nwatch(focusedIndex, () => handle.getInstance()?.setOptions(build()));\nonBeforeUnmount(() => {\n layer?.destroy();\n layer = null;\n});\ndefineExpose(handle);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"mn-chart mn-quadrant-chart\"\n data-minerva=\"chart\"\n :style=\"rootStyle\"\n >\n <div :ref=\"setContainer\" style=\"position: absolute; inset: 0\"></div>\n <div v-if=\"plot\" class=\"minerva-chart-overlay\" :style=\"overlayStyle\">\n <template v-if=\"slots['quadrant-header']\">\n <div\n v-for=\"corner in QUADRANT_CORNERS\"\n :key=\"corner\"\n :style=\"cornerStyle(corner)\"\n >\n <div\n :class=\"`minerva-chart-quadrant-header minerva-chart-quadrant-header-${corner}`\"\n :style=\"headerStyle(corner)\"\n >\n <slot\n name=\"quadrant-header\"\n :corner=\"corner\"\n :info=\"headerInfo(corner)\"\n />\n </div>\n </div>\n </template>\n <!-- the box of the point card (DOM of its own, filled by the card) -->\n <div ref=\"cardHost\" :style=\"cardHostStyle\"></div>\n </div>\n <Teleport v-if=\"card && cardPoint\" :to=\"card.actions\">\n <slot\n name=\"point-actions\"\n :point=\"cardPoint.point\"\n :index=\"cardPoint.index\"\n />\n </Teleport>\n </div>\n</template>\n"],"mappings":""}
@@ -1,10 +1,10 @@
1
1
  import { raw as e } from "./engine.js";
2
2
  import { engineOptions as t, useCartesianChart as n } from "./cartesian.js";
3
3
  import { quadrantChartProps as r } from "./props.js";
4
- import { Fragment as i, computed as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, defineComponent as l, getCurrentInstance as ee, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderList as g, renderSlot as _, unref as v, useSlots as te, watch as y } from "vue";
5
- import { QUADRANT_CORNERS as b, createQuadrantPointLayer as x, quadrantChartOptions as ne, quadrantGroups as re, quadrantOf as S } from "../../../charts/core.js";
4
+ import { Fragment as i, Teleport as a, computed as o, createBlock as s, createCommentVNode as c, createElementBlock as l, createElementVNode as u, defineComponent as d, getCurrentInstance as f, normalizeClass as ee, normalizeStyle as p, onBeforeUnmount as m, onMounted as h, onUpdated as te, openBlock as g, ref as _, renderList as ne, renderSlot as v, shallowRef as y, unref as b, useSlots as re, watch as x } from "vue";
5
+ import { QUADRANT_CORNERS as ie, createQuadrantPointCard as ae, createQuadrantPointLayer as oe, quadrantChartOptions as se, quadrantGroups as ce, quadrantOf as S, withQuadrantCard as le } from "../../../charts/core.js";
6
6
  //#region src/components/Chart/QuadrantChart.vue?vue&type=script&setup=true&lang.ts
7
- var C = ["data-point-index", "data-label"], ie = 400, w = /*@__PURE__*/ l({
7
+ var ue = 400, C = /*@__PURE__*/ d({
8
8
  name: "QuadrantChart",
9
9
  __name: "QuadrantChart",
10
10
  props: r,
@@ -18,34 +18,38 @@ var C = ["data-point-index", "data-label"], ie = 400, w = /*@__PURE__*/ l({
18
18
  "zoom",
19
19
  "rendererChange"
20
20
  ],
21
- setup(r, { expose: l, emit: w }) {
22
- let T = r, E = w, D = te(), O = ee()?.vnode, k = null, A = () => ({
23
- xDomain: e(T.xDomain),
24
- yDomain: e(T.yDomain),
25
- xSplit: T.xSplit,
26
- ySplit: T.ySplit,
27
- reverseX: T.reverseX
28
- }), j = (e) => ({
21
+ setup(r, { expose: d, emit: C }) {
22
+ let w = r, T = C, E = re(), D = f()?.vnode, O = null, k = () => ({
23
+ xDomain: e(w.xDomain),
24
+ yDomain: e(w.yDomain),
25
+ xSplit: w.xSplit,
26
+ ySplit: w.ySplit,
27
+ reverseX: w.reverseX
28
+ }), A = (e) => ({
29
29
  x: e.x,
30
30
  y: e.y,
31
- quadrant: S(A(), e.x, e.y)
32
- }), M = h(null), N = h(null), P = h(null), F = h(null), I = () => {
33
- let n = !!D["quadrant-header"], r = ne({
34
- ...A(),
35
- points: e(T.points).map(e),
36
- quadrants: e(T.quadrants),
37
- xLabel: T.xLabel,
38
- yLabel: T.yLabel,
39
- axisLabels: e(T.axisLabels),
40
- showTicks: T.showTicks,
41
- showLabels: T.showLabels,
42
- pointSize: T.pointSize,
43
- name: T.name,
44
- draggable: T.draggable ?? !!(O?.props?.onPointDrop || O?.props?.onPointDrag),
45
- showCounts: n ? void 0 : T.showCounts,
46
- selectedIndex: T.selectedIndex,
47
- selectedIndices: e(T.selectedIndices)
48
- }, (({ series: e, ...t }) => t)(t(T, [])), { focusedIndex: T.accessiblePoints ? M.value : null });
31
+ quadrant: S(k(), e.x, e.y)
32
+ }), j = _(null), M = _(null), N = _(null), P = _(null), F = y(null), I = _(null);
33
+ m(() => {
34
+ F.value?.destroy(), F.value = null;
35
+ });
36
+ let L = () => {
37
+ let n = !!E["quadrant-header"], r = le(se({
38
+ ...k(),
39
+ points: e(w.points).map(e),
40
+ quadrants: e(w.quadrants),
41
+ xLabel: w.xLabel,
42
+ yLabel: w.yLabel,
43
+ axisLabels: e(w.axisLabels),
44
+ showTicks: w.showTicks,
45
+ showLabels: w.showLabels,
46
+ pointSize: w.pointSize,
47
+ name: w.name,
48
+ draggable: w.draggable ?? !!(D?.props?.onPointDrop || D?.props?.onPointDrag),
49
+ showCounts: n ? void 0 : w.showCounts,
50
+ selectedIndex: w.selectedIndex,
51
+ selectedIndices: e(w.selectedIndices)
52
+ }, (({ series: e, ...t }) => t)(t(w, [])), { focusedIndex: w.accessiblePoints ? j.value : null }));
49
53
  return n && (r.annotations = r.annotations?.map((e, t) => t < 4 && e.type === "rect" ? {
50
54
  ...e,
51
55
  label: void 0,
@@ -53,69 +57,88 @@ var C = ["data-point-index", "data-label"], ie = 400, w = /*@__PURE__*/ l({
53
57
  description: void 0,
54
58
  detail: void 0
55
59
  } : e)), r;
56
- }, { setContainer: L, rootStyle: R, handle: z } = n(T, I, {
60
+ }, R = (e) => {
61
+ let t = w.points[e];
62
+ if (!t) return;
63
+ let n = Date.now(), r = O?.index === e && n - O.time < ue;
64
+ O = r ? null : {
65
+ index: e,
66
+ time: n
67
+ }, T("pointClick", t, e), r && T("pointDoubleClick", t, e);
68
+ }, { setContainer: z, rootStyle: B, handle: V } = n(w, L, {
57
69
  hover: (e) => {
58
- F.value = e?.items?.[0]?.index ?? null, E("hover", e);
70
+ F.value?.hover(e?.items?.[0]?.index ?? null), T("hover", e);
59
71
  },
60
72
  click: (e) => {
61
- let t = e.items[0]?.index, n = t === void 0 ? void 0 : T.points[t];
62
- if (!n || t === void 0) return;
63
- let r = Date.now(), i = k?.index === t && r - k.time < ie;
64
- k = i ? null : {
65
- index: t,
66
- time: r
67
- }, E("pointClick", n, t), i && E("pointDoubleClick", n, t);
73
+ let t = e.items[0]?.index;
74
+ t !== void 0 && R(t);
68
75
  },
69
- plotClick: (e) => E("quadrantClick", S(A(), e.x, e.y), {
76
+ plotClick: (e) => T("quadrantClick", S(k(), e.x, e.y), {
77
+ x: e.x,
78
+ y: e.y
79
+ }),
80
+ dragStart: (e) => F.value?.drag(e.item.index, {
70
81
  x: e.x,
71
82
  y: e.y
72
83
  }),
73
84
  drag: (e) => {
74
- let t = T.points[e.item.index];
75
- t && E("pointDrag", t, e.item.index, j(e));
85
+ F.value?.move({
86
+ x: e.x,
87
+ y: e.y
88
+ });
89
+ let t = w.points[e.item.index];
90
+ t && T("pointDrag", t, e.item.index, A(e));
76
91
  },
92
+ dragEnd: () => F.value?.drag(null),
77
93
  drop: (e) => {
78
- let t = T.points[e.item.index];
79
- t && E("pointDrop", t, e.item.index, j(e));
94
+ let t = w.points[e.item.index];
95
+ t && T("pointDrop", t, e.item.index, A(e));
80
96
  },
81
- zoom: (e) => E("zoom", e),
82
- renderer: (e) => E("rendererChange", e),
97
+ zoom: (e) => T("zoom", e),
98
+ renderer: (e) => T("rendererChange", e),
83
99
  layout: (e) => {
84
- P.value = e;
100
+ N.value = e;
85
101
  }
86
- }), B = a(() => !!(D["point-actions"] || D["quadrant-header"])), V = (e) => `${e}px`, H = (e, t, n) => (e - t) / (n - t || 1), U = () => ({
87
- x: T.xDomain ?? [0, 10],
88
- y: T.yDomain ?? [0, 10]
89
- }), W = (e, t) => {
90
- let n = U(), r = H(e, n.x[0], n.x[1]);
102
+ }), H = (e) => `${e}px`, U = (e, t, n) => (e - t) / (n - t || 1), W = () => ({
103
+ x: w.xDomain ?? [0, 10],
104
+ y: w.yDomain ?? [0, 10]
105
+ }), de = (e, t) => {
106
+ let n = W(), r = U(e, n.x[0], n.x[1]);
91
107
  return {
92
- x: T.reverseX ? 1 - r : r,
93
- y: 1 - H(t, n.y[0], n.y[1])
108
+ x: w.reverseX ? 1 - r : r,
109
+ y: 1 - U(t, n.y[0], n.y[1])
94
110
  };
95
- }, G = a(() => {
96
- let e = P.value;
111
+ }, fe = o(() => {
112
+ let e = N.value;
97
113
  return e ? {
98
114
  position: "absolute",
99
- left: V(e.x),
100
- top: V(e.y),
101
- width: V(e.width),
102
- height: V(e.height),
115
+ left: H(e.x),
116
+ top: H(e.y),
117
+ width: H(e.width),
118
+ height: H(e.height),
103
119
  pointerEvents: "none"
104
120
  } : { display: "none" };
105
- }), K = (e) => {
106
- let t = P.value ?? {
121
+ }), pe = o(() => ({
122
+ position: "absolute",
123
+ left: 0,
124
+ top: 0,
125
+ width: H(N.value?.width ?? 0),
126
+ height: H(N.value?.height ?? 0),
127
+ pointerEvents: "none"
128
+ })), G = (e) => {
129
+ let t = N.value ?? {
107
130
  width: 0,
108
131
  height: 0
109
- }, n = U(), r = W(T.xSplit ?? (n.x[0] + n.x[1]) / 2, T.ySplit ?? (n.y[0] + n.y[1]) / 2), i = t.width * r.x, a = t.height * r.y, o = e.endsWith("Left"), s = e.startsWith("top");
132
+ }, n = W(), r = de(w.xSplit ?? (n.x[0] + n.x[1]) / 2, w.ySplit ?? (n.y[0] + n.y[1]) / 2), i = t.width * r.x, a = t.height * r.y, o = e.endsWith("Left"), s = e.startsWith("top");
110
133
  return {
111
134
  position: "absolute",
112
- left: V(o ? 0 : i),
113
- top: V(s ? 0 : a),
114
- width: V(o ? i : t.width - i),
115
- height: V(s ? a : t.height - a),
135
+ left: H(o ? 0 : i),
136
+ top: H(s ? 0 : a),
137
+ width: H(o ? i : t.width - i),
138
+ height: H(s ? a : t.height - a),
116
139
  pointerEvents: "none"
117
140
  };
118
- }, q = (e) => {
141
+ }, me = (e) => {
119
142
  let t = e.startsWith("top"), n = e.endsWith("Left");
120
143
  return {
121
144
  position: "absolute",
@@ -128,96 +151,117 @@ var C = ["data-point-index", "data-label"], ie = 400, w = /*@__PURE__*/ l({
128
151
  justifyContent: n ? "flex-start" : "flex-end",
129
152
  pointerEvents: "auto"
130
153
  };
131
- }, J = a(() => re({
132
- ...A(),
133
- points: e(T.points).map(e)
134
- })), Y = (e) => ({
135
- count: J.value[e].points.length,
136
- points: J.value[e].points,
137
- indices: J.value[e].indices,
138
- region: T.quadrants?.[e]
139
- }), X = a(() => {
140
- let e = F.value ?? M.value ?? T.selectedIndex ?? null, t = e === null ? void 0 : T.points[e];
141
- if (!t || !Number.isFinite(t.x) || !Number.isFinite(t.y)) return null;
142
- let n = W(t.x, t.y);
143
- return {
154
+ }, K = o(() => ce({
155
+ ...k(),
156
+ points: e(w.points).map(e)
157
+ })), he = (e) => ({
158
+ count: K.value[e].points.length,
159
+ points: K.value[e].points,
160
+ indices: K.value[e].indices,
161
+ region: w.quadrants?.[e]
162
+ }), q = o(() => {
163
+ let e = I.value, t = e === null ? void 0 : w.points[e];
164
+ return t && e !== null ? {
144
165
  index: e,
145
- point: t,
146
- style: {
147
- position: "absolute",
148
- left: `${100 * n.x}%`,
149
- top: `${100 * n.y}%`,
150
- width: 0,
151
- height: 0,
152
- pointerEvents: "none"
153
- }
154
- };
155
- }), Z = null, Q = () => ({
156
- config: {
157
- ...A(),
158
- points: e(T.points).map(e),
159
- quadrants: e(T.quadrants),
160
- xLabel: T.xLabel,
161
- yLabel: T.yLabel,
162
- name: T.name
163
- },
164
- locale: T.locale,
165
- movable: !!O?.props?.onPointDrop && T.draggable !== !1,
166
- selected: [...T.selectedIndices ?? [], ...T.selectedIndex !== void 0 && T.selectedIndex !== null ? [T.selectedIndex] : []],
166
+ point: t
167
+ } : null;
168
+ }), J = () => ({
169
+ ...k(),
170
+ points: e(w.points).map(e),
171
+ quadrants: e(w.quadrants),
172
+ xLabel: w.xLabel,
173
+ yLabel: w.yLabel,
174
+ name: w.name
175
+ }), Y = () => ({
176
+ config: J(),
177
+ locale: w.locale,
178
+ pointSize: w.pointSize,
179
+ hover: w.tooltip !== !1,
180
+ selectedIndex: w.selectedIndex,
181
+ showSelected: !!E["point-actions"],
182
+ hasActions: () => !!E["point-actions"],
183
+ chart: V.getInstance(),
184
+ onClick: R,
185
+ onChange: (e) => {
186
+ I.value = e;
187
+ }
188
+ });
189
+ x([P, () => V.getInstance()], ([e, t]) => {
190
+ F.value?.destroy(), F.value = null, I.value = null, e && t && (F.value = ae(e, Y()));
191
+ }, { flush: "post" });
192
+ let X = () => F.value?.update(Y());
193
+ te(X), x([
194
+ F,
195
+ j,
196
+ () => w.points,
197
+ () => w.accessiblePoints
198
+ ], () => F.value?.focus(w.accessiblePoints ? j.value : null), { flush: "post" });
199
+ let Z = null, Q = () => ({
200
+ config: J(),
201
+ locale: w.locale,
202
+ movable: !!D?.props?.onPointDrop && w.draggable !== !1,
203
+ selected: [...w.selectedIndices ?? [], ...w.selectedIndex !== void 0 && w.selectedIndex !== null ? [w.selectedIndex] : []],
167
204
  onFocusChange: (e, t) => {
168
- M.value = e, E("hover", t);
205
+ j.value = e, T("hover", t);
169
206
  },
170
207
  onClick: (e) => {
171
- let t = T.points[e];
172
- t && E("pointClick", t, e);
208
+ let t = w.points[e];
209
+ t && T("pointClick", t, e);
173
210
  },
174
211
  onMove: (e, t) => {
175
- let n = T.points[e];
176
- n && E("pointDrop", n, e, t);
212
+ let n = w.points[e];
213
+ n && T("pointDrop", n, e, t);
177
214
  }
178
215
  }), $ = () => {
179
- T.accessiblePoints ? Z ? Z.update(Q()) : N.value && (Z = x(N.value, Q())) : (Z?.destroy(), Z = null, M.value = null);
216
+ w.accessiblePoints ? Z ? Z.update(Q()) : M.value && (Z = oe(M.value, Q())) : (Z?.destroy(), Z = null, j.value = null);
180
217
  };
181
- return p($), y(() => ({ ...T }), $, { flush: "post" }), y(M, () => z.getInstance()?.setOptions(I())), f(() => {
218
+ return h($), x(() => ({ ...w }), () => {
219
+ $(), X();
220
+ }, { flush: "post" }), x(j, () => V.getInstance()?.setOptions(L())), m(() => {
182
221
  Z?.destroy(), Z = null;
183
- }), l(z), (e, t) => (m(), s("div", {
222
+ }), d(V), (e, t) => (g(), l("div", {
184
223
  ref_key: "root",
185
- ref: N,
224
+ ref: M,
186
225
  class: "mn-chart mn-quadrant-chart",
187
226
  "data-minerva": "chart",
188
- style: d(v(R))
189
- }, [c("div", {
190
- ref: v(L),
191
- style: {
192
- position: "absolute",
193
- inset: "0"
194
- }
195
- }, null, 512), B.value ? (m(), s("div", {
196
- key: 0,
197
- class: "minerva-chart-overlay",
198
- style: d(G.value)
199
- }, [v(D)["quadrant-header"] && P.value ? (m(!0), s(i, { key: 0 }, g(v(b), (t) => (m(), s("div", {
200
- key: t,
201
- style: d(K(t))
202
- }, [c("div", {
203
- class: u(`minerva-chart-quadrant-header minerva-chart-quadrant-header-${t}`),
204
- style: d(q(t))
205
- }, [_(e.$slots, "quadrant-header", {
206
- corner: t,
207
- info: Y(t)
208
- })], 6)], 4))), 128)) : o("", !0), v(D)["point-actions"] && P.value && X.value ? (m(), s("div", {
209
- key: `point-${X.value.index}`,
210
- class: "minerva-chart-quadrant-point",
211
- "data-point-index": X.value.index,
212
- "data-label": X.value.point.label,
213
- style: d(X.value.style)
214
- }, [_(e.$slots, "point-actions", {
215
- point: X.value.point,
216
- index: X.value.index
217
- })], 12, C)) : o("", !0)], 4)) : o("", !0)], 4));
227
+ style: p(b(B))
228
+ }, [
229
+ u("div", {
230
+ ref: b(z),
231
+ style: {
232
+ position: "absolute",
233
+ inset: "0"
234
+ }
235
+ }, null, 512),
236
+ N.value ? (g(), l("div", {
237
+ key: 0,
238
+ class: "minerva-chart-overlay",
239
+ style: p(fe.value)
240
+ }, [b(E)["quadrant-header"] ? (g(!0), l(i, { key: 0 }, ne(b(ie), (t) => (g(), l("div", {
241
+ key: t,
242
+ style: p(G(t))
243
+ }, [u("div", {
244
+ class: ee(`minerva-chart-quadrant-header minerva-chart-quadrant-header-${t}`),
245
+ style: p(me(t))
246
+ }, [v(e.$slots, "quadrant-header", {
247
+ corner: t,
248
+ info: he(t)
249
+ })], 6)], 4))), 128)) : c("", !0), u("div", {
250
+ ref_key: "cardHost",
251
+ ref: P,
252
+ style: p(pe.value)
253
+ }, null, 4)], 4)) : c("", !0),
254
+ F.value && q.value ? (g(), s(a, {
255
+ key: 1,
256
+ to: F.value.actions
257
+ }, [v(e.$slots, "point-actions", {
258
+ point: q.value.point,
259
+ index: q.value.index
260
+ })], 8, ["to"])) : c("", !0)
261
+ ], 4));
218
262
  }
219
263
  });
220
264
  //#endregion
221
- export { w as default };
265
+ export { C as default };
222
266
 
223
267
  //# sourceMappingURL=QuadrantChart.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuadrantChart.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeStyle","_unref","_createElementVNode","_Fragment","_renderList","_normalizeClass","_renderSlot","_createCommentVNode","_hoisted_1","DOUBLE_CLICK_MS","QuadrantChart_vue_vue_type_script_setup_true_lang_default","quadrantChartProps","__expose","__emit","props","__props","emit","slots","useSlots","vnode","getCurrentInstance","lastClick","geometry","raw","dropAt","event","quadrantOf","focusedIndex","ref","root","plot","hoveredIndex","build","headers","options","quadrantChartOptions","_series","rest","engineOptions","i","a","useCartesianChart","index","point","now","double","at","view","renderer","rect","overlaid","computed","px","value","fraction","v","b","domains","visual","d","fx","x","y","overlayStyle","cornerStyle","split","sx","sy","left","corner","top","headerStyle","groups","quadrantGroups","headerInfo","active","layer","layerOptions","hover","target","syncLayer","createQuadrantPointLayer","onMounted","watch","handle","onBeforeUnmount","openBlock","createElementBlock","normalizeStyle","unref","rootStyle","createElementVNode","setContainer","\"position\"","\"inset\"","Fragment","renderList","QUADRANT_CORNERS","normalizeClass","renderSlot","_ctx","createCommentVNode"],"sources":["../../../../../vue/src/components/Chart/QuadrantChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n ref,\n useSlots,\n watch,\n type CSSProperties,\n} from \"vue\";\nimport {\n QUADRANT_CORNERS,\n createQuadrantPointLayer,\n quadrantChartOptions,\n quadrantGroups,\n quadrantOf,\n type ChartDragEvent,\n type ChartHoverEvent,\n type ChartRect,\n type ChartRendererKind,\n type ChartView,\n type QuadrantCorner,\n type QuadrantPoint,\n type QuadrantPointLayer,\n type QuadrantPointLayerOptions,\n} from \"minerva-design/charts/core\";\nimport { engineOptions, useCartesianChart } from \"./cartesian\";\nimport { raw } from \"./engine\";\nimport { quadrantChartProps } from \"./props\";\nimport type { QuadrantDropTarget, QuadrantHeaderInfo } from \"./types\";\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels. Dots can be dragged to another quadrant.\n */\ndefineOptions({ name: \"QuadrantChart\" });\nconst props = defineProps(quadrantChartProps);\nconst emit = defineEmits<{\n /** The hovered (or keyboard-focused) point changed (`null`: none) */\n hover: [event: ChartHoverEvent | null];\n /** A point was clicked */\n pointClick: [point: QuadrantPoint, index: number];\n /** The same point was clicked twice in quick succession */\n pointDoubleClick: [point: QuadrantPoint, index: number];\n /** A point is being dragged (on every move, with the quadrant under the pointer) */\n pointDrag: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The empty area of a quadrant was clicked */\n quadrantClick: [quadrant: QuadrantCorner, position: { x: number; y: number }];\n /** A dragged point was released (the chart does not move it: update `points`) */\n pointDrop: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The user zoomed or panned */\n zoom: [view: ChartView];\n /** The backend is ready (or fell back after a GPU loss) */\n rendererChange: [renderer: ChartRendererKind];\n}>();\ndefineSlots<{\n /**\n * Content shown next to the active point (hovered, focused or\n * `selectedIndex`), outside the canvas hit region (e.g. edit / delete\n * buttons); it receives pointer events\n */\n \"point-actions\"?: (props: { point: QuadrantPoint; index: number }) => unknown;\n /**\n * Header of each quadrant, in its outer corner (top edge for the top\n * quadrants, bottom edge for the bottom ones, aligned to the outer side);\n * replaces the drawn title, badge, description and count. The header\n * receives pointer events (e.g. an add button)\n */\n \"quadrant-header\"?: (props: {\n corner: QuadrantCorner;\n info: QuadrantHeaderInfo;\n }) => unknown;\n}>();\nconst slots = useSlots();\nconst vnode = getCurrentInstance()?.vnode;\n/** Two clicks on the same point within this delay count as a double click */\nconst DOUBLE_CLICK_MS = 400;\nlet lastClick: { index: number; time: number } | null = null;\nconst geometry = () => ({\n xDomain: raw(props.xDomain),\n yDomain: raw(props.yDomain),\n xSplit: props.xSplit,\n ySplit: props.ySplit,\n reverseX: props.reverseX,\n});\nconst dropAt = (event: ChartDragEvent): QuadrantDropTarget => ({\n x: event.x,\n y: event.y,\n quadrant: quadrantOf(geometry(), event.x, event.y),\n});\n// keyboard-focused point of the accessible layer (drawn with a focus ring)\nconst focusedIndex = ref<number | null>(null);\nconst root = ref<HTMLElement | null>(null);\n// plot area (overlay of the slots) and hovered point (active point actions)\nconst plot = ref<ChartRect | null>(null);\nconst hoveredIndex = ref<number | null>(null);\nconst build = () => {\n const headers = !!slots[\"quadrant-header\"];\n const options = quadrantChartOptions(\n {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n axisLabels: raw(props.axisLabels),\n showTicks: props.showTicks,\n showLabels: props.showLabels,\n pointSize: props.pointSize,\n name: props.name,\n draggable:\n props.draggable ??\n !!(vnode?.props?.onPointDrop || vnode?.props?.onPointDrag),\n showCounts: headers ? undefined : props.showCounts,\n selectedIndex: props.selectedIndex,\n selectedIndices: raw(props.selectedIndices),\n },\n (({ series: _series, ...rest }) => rest)(engineOptions(props, [])),\n { focusedIndex: props.accessiblePoints ? focusedIndex.value : null },\n );\n if (headers)\n // the slot headers replace the drawn titles (the first four areas)\n options.annotations = options.annotations?.map((a, i) =>\n i < 4 && a.type === \"rect\"\n ? {\n ...a,\n label: undefined,\n badge: undefined,\n description: undefined,\n detail: undefined,\n }\n : a,\n );\n return options;\n};\nconst { setContainer, rootStyle, handle } = useCartesianChart(props, build, {\n hover: (event) => {\n hoveredIndex.value = event?.items?.[0]?.index ?? null;\n emit(\"hover\", event);\n },\n click: (event) => {\n const index = event.items[0]?.index;\n const point = index === undefined ? undefined : props.points[index];\n if (!point || index === undefined) return;\n const now = Date.now();\n const double =\n lastClick?.index === index && now - lastClick.time < DOUBLE_CLICK_MS;\n lastClick = double ? null : { index, time: now };\n emit(\"pointClick\", point, index);\n if (double) emit(\"pointDoubleClick\", point, index);\n },\n plotClick: (at) =>\n emit(\"quadrantClick\", quadrantOf(geometry(), at.x, at.y), {\n x: at.x,\n y: at.y,\n }),\n drag: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrag\", point, event.item.index, dropAt(event));\n },\n drop: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrop\", point, event.item.index, dropAt(event));\n },\n zoom: (view) => emit(\"zoom\", view),\n renderer: (renderer) => emit(\"rendererChange\", renderer),\n layout: (rect) => {\n plot.value = rect;\n },\n});\n\n// the slots, over the plot area (same DOM as the React renderer)\nconst overlaid = computed(\n () => !!(slots[\"point-actions\"] || slots[\"quadrant-header\"]),\n);\nconst px = (value: number) => `${value}px`;\nconst fraction = (v: number, a: number, b: number) => (v - a) / (b - a || 1);\nconst domains = () => ({\n x: props.xDomain ?? [0, 10],\n y: props.yDomain ?? [0, 10],\n});\n/** Position of a data point in the plot, in fractions of its size */\nconst visual = (x: number, y: number) => {\n const d = domains();\n const fx = fraction(x, d.x[0], d.x[1]);\n return {\n x: props.reverseX ? 1 - fx : fx,\n y: 1 - fraction(y, d.y[0], d.y[1]),\n };\n};\nconst overlayStyle = computed<CSSProperties>(() => {\n const rect = plot.value;\n return rect\n ? {\n position: \"absolute\",\n left: px(rect.x),\n top: px(rect.y),\n width: px(rect.width),\n height: px(rect.height),\n pointerEvents: \"none\",\n }\n : { display: \"none\" };\n});\nconst cornerStyle = (corner: QuadrantCorner): CSSProperties => {\n const rect = plot.value ?? { width: 0, height: 0 };\n const d = domains();\n const split = visual(\n props.xSplit ?? (d.x[0] + d.x[1]) / 2,\n props.ySplit ?? (d.y[0] + d.y[1]) / 2,\n );\n const sx = rect.width * split.x;\n const sy = rect.height * split.y;\n const left = corner.endsWith(\"Left\");\n const top = corner.startsWith(\"top\");\n return {\n position: \"absolute\",\n left: px(left ? 0 : sx),\n top: px(top ? 0 : sy),\n width: px(left ? sx : rect.width - sx),\n height: px(top ? sy : rect.height - sy),\n pointerEvents: \"none\",\n };\n};\nconst headerStyle = (corner: QuadrantCorner): CSSProperties => {\n const top = corner.startsWith(\"top\");\n const left = corner.endsWith(\"Left\");\n return {\n position: \"absolute\",\n [top ? \"top\" : \"bottom\"]: 0,\n [left ? \"left\" : \"right\"]: 0,\n maxWidth: \"100%\",\n boxSizing: \"border-box\",\n padding: \"8px\",\n display: \"flex\",\n justifyContent: left ? \"flex-start\" : \"flex-end\",\n pointerEvents: \"auto\",\n };\n};\nconst groups = computed(() =>\n quadrantGroups({ ...geometry(), points: raw(props.points).map(raw) }),\n);\nconst headerInfo = (corner: QuadrantCorner): QuadrantHeaderInfo => ({\n count: groups.value[corner].points.length,\n points: groups.value[corner].points,\n indices: groups.value[corner].indices,\n region: props.quadrants?.[corner],\n});\n/** Point showing the `point-actions` slot */\nconst active = computed(() => {\n const index =\n hoveredIndex.value ?? focusedIndex.value ?? props.selectedIndex ?? null;\n const point = index === null ? undefined : props.points[index];\n if (!point || !Number.isFinite(point.x) || !Number.isFinite(point.y))\n return null;\n const at = visual(point.x, point.y);\n return {\n index: index!,\n point,\n style: {\n position: \"absolute\",\n left: `${100 * at.x}%`,\n top: `${100 * at.y}%`,\n width: 0,\n height: 0,\n pointerEvents: \"none\",\n } satisfies CSSProperties,\n };\n});\n\n// the accessible point layer (shared with the other DOM renderers)\nlet layer: QuadrantPointLayer | null = null;\nconst layerOptions = (): QuadrantPointLayerOptions => ({\n config: {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n name: props.name,\n },\n locale: props.locale,\n movable: !!vnode?.props?.onPointDrop && props.draggable !== false,\n selected: [\n ...(props.selectedIndices ?? []),\n ...(props.selectedIndex !== undefined && props.selectedIndex !== null\n ? [props.selectedIndex]\n : []),\n ],\n onFocusChange: (index, hover) => {\n focusedIndex.value = index;\n emit(\"hover\", hover);\n },\n onClick: (index) => {\n const point = props.points[index];\n if (point) emit(\"pointClick\", point, index);\n },\n onMove: (index, target) => {\n const point = props.points[index];\n if (point) emit(\"pointDrop\", point, index, target);\n },\n});\nconst syncLayer = () => {\n if (!props.accessiblePoints) {\n layer?.destroy();\n layer = null;\n focusedIndex.value = null;\n } else if (layer) layer.update(layerOptions());\n else if (root.value)\n layer = createQuadrantPointLayer(root.value, layerOptions());\n};\nonMounted(syncLayer);\nwatch(() => ({ ...props }), syncLayer, { flush: \"post\" });\n// the focus ring is not a prop: redraw on its own\nwatch(focusedIndex, () => handle.getInstance()?.setOptions(build()));\nonBeforeUnmount(() => {\n layer?.destroy();\n layer = null;\n});\ndefineExpose(handle);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"mn-chart mn-quadrant-chart\"\n data-minerva=\"chart\"\n :style=\"rootStyle\"\n >\n <div :ref=\"setContainer\" style=\"position: absolute; inset: 0\"></div>\n <div v-if=\"overlaid\" class=\"minerva-chart-overlay\" :style=\"overlayStyle\">\n <template v-if=\"slots['quadrant-header'] && plot\">\n <div\n v-for=\"corner in QUADRANT_CORNERS\"\n :key=\"corner\"\n :style=\"cornerStyle(corner)\"\n >\n <div\n :class=\"`minerva-chart-quadrant-header minerva-chart-quadrant-header-${corner}`\"\n :style=\"headerStyle(corner)\"\n >\n <slot\n name=\"quadrant-header\"\n :corner=\"corner\"\n :info=\"headerInfo(corner)\"\n />\n </div>\n </div>\n </template>\n <div\n v-if=\"slots['point-actions'] && plot && active\"\n :key=\"`point-${active.index}`\"\n class=\"minerva-chart-quadrant-point\"\n :data-point-index=\"active.index\"\n :data-label=\"active.point.label\"\n :style=\"active.style\"\n >\n <slot\n name=\"point-actions\"\n :point=\"active.point\"\n :index=\"active.index\"\n />\n </div>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;4CA8EMW,KAAkB;;;;;;;;;;;;;;;EAxCxB,IAAMK,IAAQC,GACRC,IAAOH,GAoCPI,IAAQC,GAAS,GACjBC,IAAQC,GAAmB,CAAC,EAAE,OAGhCC,IAAoD,MAClDC,WAAkB;GACtB,SAASC,EAAIT,EAAM,OAAO;GAC1B,SAASS,EAAIT,EAAM,OAAO;GAC1B,QAAQA,EAAM;GACd,QAAQA,EAAM;GACd,UAAUA,EAAM;EAClB,IACMU,KAAU,OAA+C;GAC7D,GAAGC,EAAM;GACT,GAAGA,EAAM;GACT,UAAUC,EAAWJ,EAAS,GAAGG,EAAM,GAAGA,EAAM,CAAC;EACnD,IAEME,IAAeC,EAAmB,IAAI,GACtCC,IAAOD,EAAwB,IAAI,GAEnCE,IAAOF,EAAsB,IAAI,GACjCG,IAAeH,EAAmB,IAAI,GACtCI,UAAc;GAClB,IAAMC,IAAU,CAAC,CAAChB,EAAM,oBAClBiB,IAAUC,GACd;IACE,GAAGb,EAAS;IACZ,QAAQC,EAAIT,EAAM,MAAM,CAAC,CAAC,IAAIS,CAAG;IACjC,WAAWA,EAAIT,EAAM,SAAS;IAC9B,QAAQA,EAAM;IACd,QAAQA,EAAM;IACd,YAAYS,EAAIT,EAAM,UAAU;IAChC,WAAWA,EAAM;IACjB,YAAYA,EAAM;IAClB,WAAWA,EAAM;IACjB,MAAMA,EAAM;IACZ,WACEA,EAAM,aACN,CAAC,EAAEK,GAAO,OAAO,eAAeA,GAAO,OAAO;IAChD,YAAYc,IAAU,KAAA,IAAYnB,EAAM;IACxC,eAAeA,EAAM;IACrB,iBAAiBS,EAAIT,EAAM,eAAe;GAC5C,KACE,EAAE,QAAQsB,GAAS,GAAGC,QAA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YA,EAAA,MAAO,MAAM;GACzB,OAAK3E,EAAE2E,EAAA,MAAO,KAAK;EAEpBrE,GAAAA,CAAAA,EAIE8F,EAAA,QAAA,iBAAA;GAFC,OAAOzB,EAAA,MAAO;GACd,OAAOA,EAAA,MAAO"}
1
+ {"version":3,"file":"QuadrantChart.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeStyle","_unref","_createElementVNode","_Fragment","_renderList","_normalizeClass","_renderSlot","_createCommentVNode","_createBlock","_Teleport","DOUBLE_CLICK_MS","QuadrantChart_vue_vue_type_script_setup_true_lang_default","quadrantChartProps","__expose","__emit","props","__props","emit","slots","useSlots","vnode","getCurrentInstance","lastClick","geometry","raw","dropAt","event","quadrantOf","focusedIndex","ref","root","plot","cardHost","card","shallowRef","cardIndex","build","headers","options","withQuadrantCard","quadrantChartOptions","_series","rest","engineOptions","i","a","clickPoint","point","index","now","double","useCartesianChart","at","view","renderer","rect","px","value","fraction","v","b","domains","visual","d","fx","x","y","overlayStyle","computed","cardHostStyle","cornerStyle","split","sx","sy","left","corner","top","headerStyle","groups","quadrantGroups","headerInfo","cardPoint","pointConfig","cardOptions","handle","host","chart","createQuadrantPointCard","syncCard","onUpdated","watch","layer","layerOptions","hover","target","syncLayer","createQuadrantPointLayer","onMounted","onBeforeUnmount","openBlock","createElementBlock","normalizeStyle","unref","rootStyle","createElementVNode","setContainer","\"position\"","\"inset\"","Fragment","renderList","QUADRANT_CORNERS","normalizeClass","renderSlot","_ctx","createCommentVNode","createBlock","Teleport"],"sources":["../../../../../vue/src/components/Chart/QuadrantChart.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n computed,\n getCurrentInstance,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useSlots,\n watch,\n type CSSProperties,\n} from \"vue\";\nimport {\n QUADRANT_CORNERS,\n createQuadrantPointCard,\n createQuadrantPointLayer,\n quadrantChartOptions,\n quadrantGroups,\n quadrantOf,\n withQuadrantCard,\n type ChartDragEvent,\n type ChartHoverEvent,\n type ChartRect,\n type ChartRendererKind,\n type ChartView,\n type QuadrantAccessibleConfig,\n type QuadrantCorner,\n type QuadrantPoint,\n type QuadrantPointCard,\n type QuadrantPointCardOptions,\n type QuadrantPointLayer,\n type QuadrantPointLayerOptions,\n} from \"minerva-design/charts/core\";\nimport { engineOptions, useCartesianChart } from \"./cartesian\";\nimport { raw } from \"./engine\";\nimport { quadrantChartProps } from \"./props\";\nimport type { QuadrantDropTarget, QuadrantHeaderInfo } from \"./types\";\n\n/**\n * Four-quadrant matrix (priority matrix, Eisenhower, BCG, ...): tinted\n * quadrants with titles, dividers, and labelled dots placed without\n * overlapping labels. Dots can be dragged to another quadrant.\n */\ndefineOptions({ name: \"QuadrantChart\" });\nconst props = defineProps(quadrantChartProps);\nconst emit = defineEmits<{\n /** The hovered (or keyboard-focused) point changed (`null`: none) */\n hover: [event: ChartHoverEvent | null];\n /** A point was clicked */\n pointClick: [point: QuadrantPoint, index: number];\n /** The same point was clicked twice in quick succession */\n pointDoubleClick: [point: QuadrantPoint, index: number];\n /** A point is being dragged (on every move, with the quadrant under the pointer) */\n pointDrag: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The empty area of a quadrant was clicked */\n quadrantClick: [quadrant: QuadrantCorner, position: { x: number; y: number }];\n /** A dragged point was released (the chart does not move it: update `points`) */\n pointDrop: [point: QuadrantPoint, index: number, target: QuadrantDropTarget];\n /** The user zoomed or panned */\n zoom: [view: ChartView];\n /** The backend is ready (or fell back after a GPU loss) */\n rendererChange: [renderer: ChartRendererKind];\n}>();\ndefineSlots<{\n /**\n * Actions of a point (e.g. compact edit / delete buttons), shown in the\n * point card of the hovered or focused point, else of the `selectedIndex`\n * point (with this slot, the selected point keeps its card); they receive\n * pointer events\n */\n \"point-actions\"?: (props: { point: QuadrantPoint; index: number }) => unknown;\n /**\n * Header of each quadrant, in its outer corner (top edge for the top\n * quadrants, bottom edge for the bottom ones, aligned to the outer side);\n * replaces the drawn title, badge, description and count. The header\n * receives pointer events (e.g. an add button)\n */\n \"quadrant-header\"?: (props: {\n corner: QuadrantCorner;\n info: QuadrantHeaderInfo;\n }) => unknown;\n}>();\nconst slots = useSlots();\nconst vnode = getCurrentInstance()?.vnode;\n/** Two clicks on the same point within this delay count as a double click */\nconst DOUBLE_CLICK_MS = 400;\nlet lastClick: { index: number; time: number } | null = null;\nconst geometry = () => ({\n xDomain: raw(props.xDomain),\n yDomain: raw(props.yDomain),\n xSplit: props.xSplit,\n ySplit: props.ySplit,\n reverseX: props.reverseX,\n});\nconst dropAt = (event: ChartDragEvent): QuadrantDropTarget => ({\n x: event.x,\n y: event.y,\n quadrant: quadrantOf(geometry(), event.x, event.y),\n});\n// keyboard-focused point of the accessible layer (drawn with a focus ring)\nconst focusedIndex = ref<number | null>(null);\nconst root = ref<HTMLElement | null>(null);\n// plot area (overlay of the slots and of the point card)\nconst plot = ref<ChartRect | null>(null);\n// the point card is DOM of its own (shared with the other renderers): hover,\n// focus and drag moves render nothing here; only the `point-actions` slot is\n// rendered again (teleported into the card) when another point shows it\nconst cardHost = ref<HTMLElement | null>(null);\nconst card = shallowRef<QuadrantPointCard | null>(null);\nconst cardIndex = ref<number | null>(null);\n// before the engine is destroyed: the card gives the drawn label back to it\nonBeforeUnmount(() => {\n card.value?.destroy();\n card.value = null;\n});\nconst build = () => {\n const headers = !!slots[\"quadrant-header\"];\n // the point card names the hovered, focused, selected or dragged point: no\n // tooltip, no label chip and no drag pill of the engine beside it\n const options = withQuadrantCard(\n quadrantChartOptions(\n {\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n axisLabels: raw(props.axisLabels),\n showTicks: props.showTicks,\n showLabels: props.showLabels,\n pointSize: props.pointSize,\n name: props.name,\n draggable:\n props.draggable ??\n !!(vnode?.props?.onPointDrop || vnode?.props?.onPointDrag),\n showCounts: headers ? undefined : props.showCounts,\n selectedIndex: props.selectedIndex,\n selectedIndices: raw(props.selectedIndices),\n },\n (({ series: _series, ...rest }) => rest)(engineOptions(props, [])),\n { focusedIndex: props.accessiblePoints ? focusedIndex.value : null },\n ),\n );\n if (headers)\n // the slot headers replace the drawn titles (the first four areas)\n options.annotations = options.annotations?.map((a, i) =>\n i < 4 && a.type === \"rect\"\n ? {\n ...a,\n label: undefined,\n badge: undefined,\n description: undefined,\n detail: undefined,\n }\n : a,\n );\n return options;\n};\n// a click on a dot or on the name in its card; two quick ones in a row\n// count as a double click\nconst clickPoint = (index: number) => {\n const point = props.points[index];\n if (!point) return;\n const now = Date.now();\n const double =\n lastClick?.index === index && now - lastClick.time < DOUBLE_CLICK_MS;\n lastClick = double ? null : { index, time: now };\n emit(\"pointClick\", point, index);\n if (double) emit(\"pointDoubleClick\", point, index);\n};\nconst { setContainer, rootStyle, handle } = useCartesianChart(props, build, {\n hover: (event) => {\n card.value?.hover(event?.items?.[0]?.index ?? null);\n emit(\"hover\", event);\n },\n click: (event) => {\n const index = event.items[0]?.index;\n if (index !== undefined) clickPoint(index);\n },\n plotClick: (at) =>\n emit(\"quadrantClick\", quadrantOf(geometry(), at.x, at.y), {\n x: at.x,\n y: at.y,\n }),\n dragStart: (event) =>\n card.value?.drag(event.item.index, { x: event.x, y: event.y }),\n drag: (event) => {\n card.value?.move({ x: event.x, y: event.y });\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrag\", point, event.item.index, dropAt(event));\n },\n dragEnd: () => card.value?.drag(null),\n drop: (event) => {\n const point = props.points[event.item.index];\n if (point) emit(\"pointDrop\", point, event.item.index, dropAt(event));\n },\n zoom: (view) => emit(\"zoom\", view),\n renderer: (renderer) => emit(\"rendererChange\", renderer),\n layout: (rect) => {\n plot.value = rect;\n },\n});\n\n// the slots and the point card, over the plot area (same DOM as the React\n// renderer)\nconst px = (value: number) => `${value}px`;\nconst fraction = (v: number, a: number, b: number) => (v - a) / (b - a || 1);\nconst domains = () => ({\n x: props.xDomain ?? [0, 10],\n y: props.yDomain ?? [0, 10],\n});\n/** Position of a data point in the plot, in fractions of its size */\nconst visual = (x: number, y: number) => {\n const d = domains();\n const fx = fraction(x, d.x[0], d.x[1]);\n return {\n x: props.reverseX ? 1 - fx : fx,\n y: 1 - fraction(y, d.y[0], d.y[1]),\n };\n};\nconst overlayStyle = computed<CSSProperties>(() => {\n const rect = plot.value;\n return rect\n ? {\n position: \"absolute\",\n left: px(rect.x),\n top: px(rect.y),\n width: px(rect.width),\n height: px(rect.height),\n pointerEvents: \"none\",\n }\n : { display: \"none\" };\n});\n/** The box of the point card: the plot, in pixels (the card reads its size) */\nconst cardHostStyle = computed<CSSProperties>(() => ({\n position: \"absolute\",\n left: 0,\n top: 0,\n width: px(plot.value?.width ?? 0),\n height: px(plot.value?.height ?? 0),\n pointerEvents: \"none\",\n}));\nconst cornerStyle = (corner: QuadrantCorner): CSSProperties => {\n const rect = plot.value ?? { width: 0, height: 0 };\n const d = domains();\n const split = visual(\n props.xSplit ?? (d.x[0] + d.x[1]) / 2,\n props.ySplit ?? (d.y[0] + d.y[1]) / 2,\n );\n const sx = rect.width * split.x;\n const sy = rect.height * split.y;\n const left = corner.endsWith(\"Left\");\n const top = corner.startsWith(\"top\");\n return {\n position: \"absolute\",\n left: px(left ? 0 : sx),\n top: px(top ? 0 : sy),\n width: px(left ? sx : rect.width - sx),\n height: px(top ? sy : rect.height - sy),\n pointerEvents: \"none\",\n };\n};\nconst headerStyle = (corner: QuadrantCorner): CSSProperties => {\n const top = corner.startsWith(\"top\");\n const left = corner.endsWith(\"Left\");\n return {\n position: \"absolute\",\n [top ? \"top\" : \"bottom\"]: 0,\n [left ? \"left\" : \"right\"]: 0,\n maxWidth: \"100%\",\n boxSizing: \"border-box\",\n padding: \"8px\",\n display: \"flex\",\n justifyContent: left ? \"flex-start\" : \"flex-end\",\n pointerEvents: \"auto\",\n };\n};\nconst groups = computed(() =>\n quadrantGroups({ ...geometry(), points: raw(props.points).map(raw) }),\n);\nconst headerInfo = (corner: QuadrantCorner): QuadrantHeaderInfo => ({\n count: groups.value[corner].points.length,\n points: groups.value[corner].points,\n indices: groups.value[corner].indices,\n region: props.quadrants?.[corner],\n});\n/** Point of the card whose actions the `point-actions` slot renders */\nconst cardPoint = computed(() => {\n const index = cardIndex.value;\n const point = index === null ? undefined : props.points[index];\n return point && index !== null ? { index, point } : null;\n});\n\n/** The points and the geometry, for the accessible layer and the card */\nconst pointConfig = (): QuadrantAccessibleConfig => ({\n ...geometry(),\n points: raw(props.points).map(raw),\n quadrants: raw(props.quadrants),\n xLabel: props.xLabel,\n yLabel: props.yLabel,\n name: props.name,\n});\n\nconst cardOptions = (): QuadrantPointCardOptions => ({\n config: pointConfig(),\n locale: props.locale,\n pointSize: props.pointSize,\n // the hovered point shows its card unless the tooltip is off\n hover: props.tooltip !== false,\n selectedIndex: props.selectedIndex,\n // a plain chart rings its selected point; a board keeps its card (the\n // actions of the point stay at hand)\n showSelected: !!slots[\"point-actions\"],\n hasActions: () => !!slots[\"point-actions\"],\n chart: handle.getInstance(),\n onClick: clickPoint,\n onChange: (index) => {\n cardIndex.value = index;\n },\n});\n// the box of the card is rendered once the plot is laid out\nwatch(\n [cardHost, () => handle.getInstance()],\n ([host, chart]) => {\n card.value?.destroy();\n card.value = null;\n cardIndex.value = null;\n if (host && chart)\n card.value = createQuadrantPointCard(host, cardOptions());\n },\n { flush: \"post\" },\n);\nconst syncCard = () => card.value?.update(cardOptions());\n// new slots (re-rendered by the parent), and the actions rendered in the\n// card: its size and place follow\nonUpdated(syncCard);\n// the focused point button, named again by the new points\nwatch(\n [card, focusedIndex, () => props.points, () => props.accessiblePoints],\n () => card.value?.focus(props.accessiblePoints ? focusedIndex.value : null),\n { flush: \"post\" },\n);\n\n// the accessible point layer (shared with the other DOM renderers)\nlet layer: QuadrantPointLayer | null = null;\nconst layerOptions = (): QuadrantPointLayerOptions => ({\n config: pointConfig(),\n locale: props.locale,\n movable: !!vnode?.props?.onPointDrop && props.draggable !== false,\n selected: [\n ...(props.selectedIndices ?? []),\n ...(props.selectedIndex !== undefined && props.selectedIndex !== null\n ? [props.selectedIndex]\n : []),\n ],\n onFocusChange: (index, hover) => {\n focusedIndex.value = index;\n emit(\"hover\", hover);\n },\n onClick: (index) => {\n const point = props.points[index];\n if (point) emit(\"pointClick\", point, index);\n },\n onMove: (index, target) => {\n const point = props.points[index];\n if (point) emit(\"pointDrop\", point, index, target);\n },\n});\nconst syncLayer = () => {\n if (!props.accessiblePoints) {\n layer?.destroy();\n layer = null;\n focusedIndex.value = null;\n } else if (layer) layer.update(layerOptions());\n else if (root.value)\n layer = createQuadrantPointLayer(root.value, layerOptions());\n};\nonMounted(syncLayer);\nwatch(\n () => ({ ...props }),\n () => {\n syncLayer();\n syncCard();\n },\n { flush: \"post\" },\n);\n// the focus ring is not a prop: redraw on its own\nwatch(focusedIndex, () => handle.getInstance()?.setOptions(build()));\nonBeforeUnmount(() => {\n layer?.destroy();\n layer = null;\n});\ndefineExpose(handle);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"mn-chart mn-quadrant-chart\"\n data-minerva=\"chart\"\n :style=\"rootStyle\"\n >\n <div :ref=\"setContainer\" style=\"position: absolute; inset: 0\"></div>\n <div v-if=\"plot\" class=\"minerva-chart-overlay\" :style=\"overlayStyle\">\n <template v-if=\"slots['quadrant-header']\">\n <div\n v-for=\"corner in QUADRANT_CORNERS\"\n :key=\"corner\"\n :style=\"cornerStyle(corner)\"\n >\n <div\n :class=\"`minerva-chart-quadrant-header minerva-chart-quadrant-header-${corner}`\"\n :style=\"headerStyle(corner)\"\n >\n <slot\n name=\"quadrant-header\"\n :corner=\"corner\"\n :info=\"headerInfo(corner)\"\n />\n </div>\n </div>\n </template>\n <!-- the box of the point card (DOM of its own, filled by the card) -->\n <div ref=\"cardHost\" :style=\"cardHostStyle\"></div>\n </div>\n <Teleport v-if=\"card && cardPoint\" :to=\"card.actions\">\n <slot\n name=\"point-actions\"\n :point=\"cardPoint.point\"\n :index=\"card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