@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.20.2 → 4.21.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 (134) hide show
  1. package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
  2. package/dpr/components/_charts/chart/Chart.js +2 -0
  3. package/dpr/components/_charts/chart/Chart.js.map +7 -0
  4. package/dpr/components/_charts/chart/Chart.ts +89 -0
  5. package/dpr/components/_charts/chart/ChartColours.js +2 -0
  6. package/dpr/components/_charts/chart/ChartColours.js.map +7 -0
  7. package/dpr/components/_charts/chart/ChartColours.ts +36 -0
  8. package/dpr/components/_charts/chart/ChartTimeseries.js +2 -0
  9. package/dpr/components/_charts/chart/ChartTimeseries.js.map +7 -0
  10. package/dpr/components/_charts/chart/ChartTimeseries.ts +95 -0
  11. package/dpr/components/_charts/chart/bar/BarChart.js +2 -0
  12. package/dpr/components/_charts/chart/bar/BarChart.js.map +7 -0
  13. package/dpr/components/_charts/chart/bar/BarChart.ts +204 -0
  14. package/dpr/components/_charts/chart/bar/clientClass.mjs +0 -58
  15. package/dpr/components/_charts/chart/bar/types.js +2 -0
  16. package/dpr/components/_charts/chart/bar/types.js.map +7 -0
  17. package/dpr/components/_charts/chart/bar/types.ts +6 -0
  18. package/dpr/components/_charts/chart/bar/validate.js +2 -0
  19. package/dpr/components/_charts/chart/bar/validate.js.map +7 -0
  20. package/dpr/components/_charts/chart/bar/validate.ts +59 -0
  21. package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.js +2 -0
  22. package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.js.map +7 -0
  23. package/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.ts +57 -0
  24. package/dpr/components/_charts/chart/bar-timeseries/types.js +2 -0
  25. package/dpr/components/_charts/chart/bar-timeseries/types.js.map +7 -0
  26. package/dpr/components/_charts/chart/bar-timeseries/types.ts +5 -0
  27. package/dpr/components/_charts/chart/bar-timeseries/validate.js +2 -0
  28. package/dpr/components/_charts/chart/bar-timeseries/validate.js.map +7 -0
  29. package/dpr/components/_charts/chart/bar-timeseries/validate.ts +30 -0
  30. package/dpr/components/_charts/chart/buckets/Buckets.js +2 -0
  31. package/dpr/components/_charts/chart/buckets/Buckets.js.map +7 -0
  32. package/dpr/components/_charts/chart/{Buckets.ts → buckets/Buckets.ts} +18 -14
  33. package/dpr/components/_charts/chart/buckets/types.js +2 -0
  34. package/dpr/components/_charts/chart/buckets/types.js.map +7 -0
  35. package/dpr/components/_charts/chart/buckets/types.ts +4 -0
  36. package/dpr/components/_charts/chart/buckets/validate.js +2 -0
  37. package/dpr/components/_charts/chart/buckets/validate.js.map +7 -0
  38. package/dpr/components/_charts/chart/buckets/validate.ts +15 -0
  39. package/dpr/components/_charts/chart/chart-config.js +2 -0
  40. package/dpr/components/_charts/chart/chart-config.js.map +7 -0
  41. package/dpr/components/_charts/chart/chart-config.ts +108 -0
  42. package/dpr/components/_charts/chart/clientClass.mjs +28 -106
  43. package/dpr/components/_charts/chart/doughnut/DoughnutChart.js +2 -0
  44. package/dpr/components/_charts/chart/doughnut/DoughnutChart.js.map +7 -0
  45. package/dpr/components/_charts/chart/doughnut/DoughnutChart.ts +77 -0
  46. package/dpr/components/_charts/chart/doughnut/clientClass.mjs +0 -45
  47. package/dpr/components/_charts/chart/doughnut/types.js +2 -0
  48. package/dpr/components/_charts/chart/doughnut/types.js.map +7 -0
  49. package/dpr/components/_charts/chart/doughnut/types.ts +5 -0
  50. package/dpr/components/_charts/chart/doughnut/validate.js +2 -0
  51. package/dpr/components/_charts/chart/doughnut/validate.js.map +7 -0
  52. package/dpr/components/_charts/chart/doughnut/validate.ts +30 -0
  53. package/dpr/components/_charts/chart/heatmap/HeatmapChart.js +1 -1
  54. package/dpr/components/_charts/chart/heatmap/HeatmapChart.js.map +3 -3
  55. package/dpr/components/_charts/chart/heatmap/HeatmapChart.ts +122 -44
  56. package/dpr/components/_charts/chart/heatmap/clientClass.mjs +7 -89
  57. package/dpr/components/_charts/chart/heatmap/types.js +1 -1
  58. package/dpr/components/_charts/chart/heatmap/types.js.map +1 -1
  59. package/dpr/components/_charts/chart/heatmap/types.ts +5 -0
  60. package/dpr/components/_charts/chart/heatmap/validate.js +2 -0
  61. package/dpr/components/_charts/chart/heatmap/validate.js.map +7 -0
  62. package/dpr/components/_charts/chart/heatmap/validate.ts +25 -0
  63. package/dpr/components/_charts/chart/line/LineChart.js +2 -0
  64. package/dpr/components/_charts/chart/line/LineChart.js.map +7 -0
  65. package/dpr/components/_charts/chart/line/LineChart.ts +89 -0
  66. package/dpr/components/_charts/chart/line/clientClass.mjs +5 -36
  67. package/dpr/components/_charts/chart/line/types.js +2 -0
  68. package/dpr/components/_charts/chart/line/types.js.map +7 -0
  69. package/dpr/components/_charts/chart/line/types.ts +5 -0
  70. package/dpr/components/_charts/chart/line/validate.js +2 -0
  71. package/dpr/components/_charts/chart/line/validate.js.map +7 -0
  72. package/dpr/components/_charts/chart/line/validate.ts +30 -0
  73. package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.js +2 -0
  74. package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.js.map +7 -0
  75. package/dpr/components/_charts/chart/line-timeseries/LineTimeseriesChart.ts +57 -0
  76. package/dpr/components/_charts/chart/line-timeseries/types.js +2 -0
  77. package/dpr/components/_charts/chart/line-timeseries/types.js.map +7 -0
  78. package/dpr/components/_charts/chart/line-timeseries/types.ts +5 -0
  79. package/dpr/components/_charts/chart/line-timeseries/validate.js +2 -0
  80. package/dpr/components/_charts/chart/line-timeseries/validate.js.map +7 -0
  81. package/dpr/components/_charts/chart/line-timeseries/validate.ts +30 -0
  82. package/dpr/components/_charts/chart/view.njk +8 -1
  83. package/dpr/components/_charts/chart-tabs/view.njk +15 -14
  84. package/dpr/components/_charts/utils.js +1 -1
  85. package/dpr/components/_charts/utils.js.map +3 -3
  86. package/dpr/components/_charts/utils.test.ts +9 -3
  87. package/dpr/components/_charts/utils.ts +59 -193
  88. package/dpr/components/_dashboards/dashboard-list/types.js +2 -0
  89. package/dpr/components/_dashboards/dashboard-list/types.js.map +7 -0
  90. package/dpr/components/_dashboards/dashboard-list/types.ts +4 -0
  91. package/dpr/components/_dashboards/dashboard-list/validate.js +2 -0
  92. package/dpr/components/_dashboards/dashboard-list/validate.js.map +7 -0
  93. package/dpr/components/_dashboards/dashboard-list/validate.ts +28 -0
  94. package/dpr/components/_dashboards/dashboard-visualisation/Validate.js +2 -0
  95. package/dpr/components/_dashboards/dashboard-visualisation/Validate.js.map +7 -0
  96. package/dpr/components/_dashboards/dashboard-visualisation/Validate.ts +71 -0
  97. package/dpr/components/_dashboards/dashboard-visualisation/types.js +1 -1
  98. package/dpr/components/_dashboards/dashboard-visualisation/types.js.map +2 -2
  99. package/dpr/components/_dashboards/dashboard-visualisation/types.ts +32 -2
  100. package/dpr/components/_dashboards/scorecard/Scorecard.js +1 -1
  101. package/dpr/components/_dashboards/scorecard/Scorecard.js.map +3 -3
  102. package/dpr/components/_dashboards/scorecard/Scorecard.ts +82 -213
  103. package/dpr/components/_dashboards/scorecard/types.js +1 -1
  104. package/dpr/components/_dashboards/scorecard/types.js.map +1 -1
  105. package/dpr/components/_dashboards/scorecard/types.ts +11 -1
  106. package/dpr/components/_dashboards/scorecard/validate.js +2 -0
  107. package/dpr/components/_dashboards/scorecard/validate.js.map +7 -0
  108. package/dpr/components/_dashboards/scorecard/validate.ts +36 -0
  109. package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.js +2 -0
  110. package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.js.map +7 -0
  111. package/dpr/components/_dashboards/scorecard-group/ScorecardGroup.ts +228 -0
  112. package/dpr/components/_dashboards/scorecard-group/types.js +2 -0
  113. package/dpr/components/_dashboards/scorecard-group/types.js.map +7 -0
  114. package/dpr/components/_dashboards/scorecard-group/types.ts +5 -0
  115. package/dpr/components/_dashboards/scorecard-group/validate.js +2 -0
  116. package/dpr/components/_dashboards/scorecard-group/validate.js.map +7 -0
  117. package/dpr/components/_dashboards/scorecard-group/validate.ts +37 -0
  118. package/dpr/components/_filters/types.d.js.map +1 -1
  119. package/dpr/components/_filters/types.d.ts +6 -4
  120. package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
  121. package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +3 -3
  122. package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +22 -10
  123. package/dpr/routes/journeys/view-report/controller.js +1 -1
  124. package/dpr/routes/journeys/view-report/controller.js.map +3 -3
  125. package/dpr/routes/journeys/view-report/controller.ts +3 -1
  126. package/dpr/utils/ErrorHandler.js +1 -1
  127. package/dpr/utils/ErrorHandler.js.map +3 -3
  128. package/dpr/utils/ErrorHandler.ts +16 -0
  129. package/package.json +1 -1
  130. package/dpr/components/_charts/chart/Buckets.js +0 -2
  131. package/dpr/components/_charts/chart/Buckets.js.map +0 -7
  132. package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js +0 -2
  133. package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.js.map +0 -7
  134. package/dpr/components/_dashboards/dashboard-visualisation/DashboardVisualisation.ts +0 -40
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod'
2
+ import { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'
3
+
4
+ const BarMeasureShema = z.object({
5
+ id: z.string(),
6
+ display: z.string().optional(),
7
+ unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),
8
+ axis: z.enum(['x', 'y']).optional(),
9
+ })
10
+
11
+ const BarOptionsSchema = z.object({
12
+ showLatest: z.boolean().default(true),
13
+ horizontal: z.boolean().default(false),
14
+ xStacked: z.boolean().default(false),
15
+ yStacked: z.boolean().default(false),
16
+ })
17
+
18
+ const BarSchema = z.object({
19
+ ...DashboardVisualisationSchema.shape,
20
+ type: z.literal('bar'),
21
+ display: z.string(),
22
+ options: z.object(BarOptionsSchema.shape).optional(),
23
+ columns: z.object({
24
+ ...DashboardColumns.shape,
25
+ measures: z
26
+ .array(BarMeasureShema)
27
+ .refine(
28
+ (measures) => {
29
+ const xAxis = measures.find((m) => m.axis === 'x')
30
+ const yAxis = measures.find((m) => m.axis === 'y')
31
+
32
+ let valid = true
33
+ if ((xAxis !== undefined && !yAxis) || (yAxis !== undefined && !xAxis)) {
34
+ valid = false
35
+ }
36
+ return valid
37
+ },
38
+ { error: 'X and Y axis must be defined in measure' },
39
+ )
40
+ .refine(
41
+ (measures) => {
42
+ const xAxis = measures.find((m) => m.axis === 'x')
43
+ const yAxis = measures.find((m) => m.axis === 'y')
44
+ let valid = true
45
+ if (xAxis !== undefined && yAxis !== undefined && measures.length > 2) valid = false
46
+ return valid
47
+ },
48
+ { error: 'Measure must contain only 2 items when axis is specified' },
49
+ ),
50
+ }),
51
+ })
52
+
53
+ const BarChartSchemas = {
54
+ BarSchema,
55
+ BarMeasureShema,
56
+ BarOptionsSchema,
57
+ }
58
+
59
+ export default BarChartSchemas
@@ -0,0 +1,2 @@
1
+ "use strict";var u=Object.create;var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var C=(i,t)=>{for(var s in t)r(i,s,{get:t[s],enumerable:!0})},h=(i,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of B(t))!c.call(i,e)&&e!==s&&r(i,e,{get:()=>t[e],enumerable:!(a=f(t,e))||a.enumerable});return i};var o=(i,t,s)=>(s=i!=null?u(D(i)):{},h(t||!i||!i.__esModule?r(s,"default",{value:i,enumerable:!0}):s,i)),b=i=>h(r({},"__esModule",{value:!0}),i);var y={};C(y,{BarTimeseriesChart:()=>n,default:()=>T});module.exports=b(y);var m=require("../../../_dashboards/dashboard-visualisation/types"),d=o(require("./validate")),p=o(require("../ChartTimeseries")),l=o(require("../bar/BarChart"));class n extends p.default{constructor(){super(...arguments);this.BarChartBuilder=new l.default;this.withDefinition=s=>(this.definition=d.default.BarTimeseriesSchema.parse(s),this.initFromDefinition(this.definition),this);this.build=()=>(this.buildDatasets(),this.setStyles(),this.datasets=this.BarChartBuilder.augmentDataset(this.datasets),this.BarChartBuilder.setBespokeOptions(),{type:m.DashboardVisualisationType.BAR,options:{unit:this.unit,timeseries:!0},data:{labels:this.labels,datasets:this.datasets,config:this.config}});this.setStyles=()=>{this.datasets=this.datasets.map((s,a)=>{const e=this.hexColours[a];return{...s,backgroundColor:e,borderColor:e}})}}}var T=n;0&&(module.exports={BarTimeseriesChart});
2
+ //# sourceMappingURL=BarTimeseriesChart.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/bar-timeseries/BarTimeseriesChart.ts"],
4
+ "sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport {\n DashboardVisualisationType,\n DashboardVisualisationData,\n} from '../../../_dashboards/dashboard-visualisation/types'\nimport { components } from '../../../../types/api'\nimport { BarTimeseriesDefinitionType } from './types'\nimport BarTimeseriesChartSchemas from './validate'\nimport TimeseriesChart from '../ChartTimeseries'\nimport BarChart from '../bar/BarChart'\n\nclass BarTimeseriesChart extends TimeseriesChart {\n private definition!: BarTimeseriesDefinitionType\n\n private BarChartBuilder: BarChart = new BarChart()\n\n withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {\n this.definition = BarTimeseriesChartSchemas.BarTimeseriesSchema.parse(definition)\n this.initFromDefinition(this.definition)\n\n return this\n }\n\n build = (): DashboardVisualisationData => {\n this.buildDatasets()\n this.setStyles()\n this.datasets = this.BarChartBuilder.augmentDataset(this.datasets)\n this.BarChartBuilder.setBespokeOptions()\n\n return {\n type: DashboardVisualisationType.BAR,\n options: {\n unit: this.unit,\n timeseries: true,\n },\n data: {\n labels: this.labels,\n datasets: this.datasets,\n config: this.config,\n },\n }\n }\n\n private setStyles = () => {\n this.datasets = this.datasets.map((set, datasetIndex) => {\n const colour = this.hexColours[datasetIndex]\n return {\n ...set,\n backgroundColor: colour,\n borderColor: colour,\n }\n })\n }\n}\n\nexport { BarTimeseriesChart }\nexport default BarTimeseriesChart\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAGO,8DAGPC,EAAsC,yBACtCC,EAA4B,iCAC5BC,EAAqB,8BAErB,MAAMN,UAA2B,EAAAO,OAAgB,CAAjD,kCAGE,KAAQ,gBAA4B,IAAI,EAAAC,QAExC,oBAAkBC,IAChB,KAAK,WAAa,EAAAC,QAA0B,oBAAoB,MAAMD,CAAU,EAChF,KAAK,mBAAmB,KAAK,UAAU,EAEhC,MAGT,WAAQ,KACN,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,SAAW,KAAK,gBAAgB,eAAe,KAAK,QAAQ,EACjE,KAAK,gBAAgB,kBAAkB,EAEhC,CACL,KAAM,6BAA2B,IACjC,QAAS,CACP,KAAM,KAAK,KACX,WAAY,EACd,EACA,KAAM,CACJ,OAAQ,KAAK,OACb,SAAU,KAAK,SACf,OAAQ,KAAK,MACf,CACF,GAGF,KAAQ,UAAY,IAAM,CACxB,KAAK,SAAW,KAAK,SAAS,IAAI,CAACE,EAAKC,IAAiB,CACvD,MAAMC,EAAS,KAAK,WAAWD,CAAY,EAC3C,MAAO,CACL,GAAGD,EACH,gBAAiBE,EACjB,YAAaA,CACf,CACF,CAAC,CACH,EACF,CAGA,IAAOZ,EAAQD",
6
+ "names": ["BarTimeseriesChart_exports", "__export", "BarTimeseriesChart", "BarTimeseriesChart_default", "__toCommonJS", "import_types", "import_validate", "import_ChartTimeseries", "import_BarChart", "TimeseriesChart", "BarChart", "definition", "BarTimeseriesChartSchemas", "set", "datasetIndex", "colour"]
7
+ }
@@ -0,0 +1,57 @@
1
+ /* eslint-disable prefer-destructuring */
2
+ import {
3
+ DashboardVisualisationType,
4
+ DashboardVisualisationData,
5
+ } from '../../../_dashboards/dashboard-visualisation/types'
6
+ import { components } from '../../../../types/api'
7
+ import { BarTimeseriesDefinitionType } from './types'
8
+ import BarTimeseriesChartSchemas from './validate'
9
+ import TimeseriesChart from '../ChartTimeseries'
10
+ import BarChart from '../bar/BarChart'
11
+
12
+ class BarTimeseriesChart extends TimeseriesChart {
13
+ private definition!: BarTimeseriesDefinitionType
14
+
15
+ private BarChartBuilder: BarChart = new BarChart()
16
+
17
+ withDefinition = (definition: components['schemas']['DashboardVisualisationDefinition']) => {
18
+ this.definition = BarTimeseriesChartSchemas.BarTimeseriesSchema.parse(definition)
19
+ this.initFromDefinition(this.definition)
20
+
21
+ return this
22
+ }
23
+
24
+ build = (): DashboardVisualisationData => {
25
+ this.buildDatasets()
26
+ this.setStyles()
27
+ this.datasets = this.BarChartBuilder.augmentDataset(this.datasets)
28
+ this.BarChartBuilder.setBespokeOptions()
29
+
30
+ return {
31
+ type: DashboardVisualisationType.BAR,
32
+ options: {
33
+ unit: this.unit,
34
+ timeseries: true,
35
+ },
36
+ data: {
37
+ labels: this.labels,
38
+ datasets: this.datasets,
39
+ config: this.config,
40
+ },
41
+ }
42
+ }
43
+
44
+ private setStyles = () => {
45
+ this.datasets = this.datasets.map((set, datasetIndex) => {
46
+ const colour = this.hexColours[datasetIndex]
47
+ return {
48
+ ...set,
49
+ backgroundColor: colour,
50
+ borderColor: colour,
51
+ }
52
+ })
53
+ }
54
+ }
55
+
56
+ export { BarTimeseriesChart }
57
+ export default BarTimeseriesChart
@@ -0,0 +1,2 @@
1
+ "use strict";var a=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var f=(r,e,m,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of o(e))!p.call(r,i)&&i!==m&&a(r,i,{get:()=>e[i],enumerable:!(s=t(e,i))||s.enumerable});return r};var h=r=>f(a({},"__esModule",{value:!0}),r);var T={};module.exports=h(T);
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/bar-timeseries/types.ts"],
4
+ "sourcesContent": ["import z from 'zod'\nimport BarTimeseriesChartSchemas from './validate'\n\nexport type BarTimeseriesDefinitionType = z.infer<typeof BarTimeseriesChartSchemas.BarTimeseriesSchema>\nexport type BarTimeseriesDefinitionMeasure = z.infer<typeof BarTimeseriesChartSchemas.BarTimeseriesMeasureSchema>\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["types_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,5 @@
1
+ import z from 'zod'
2
+ import BarTimeseriesChartSchemas from './validate'
3
+
4
+ export type BarTimeseriesDefinitionType = z.infer<typeof BarTimeseriesChartSchemas.BarTimeseriesSchema>
5
+ export type BarTimeseriesDefinitionMeasure = z.infer<typeof BarTimeseriesChartSchemas.BarTimeseriesMeasureSchema>
@@ -0,0 +1,2 @@
1
+ "use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var h=(a,s)=>{for(var i in s)r(a,i,{get:s[i],enumerable:!0})},u=(a,s,i,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of l(s))!p.call(a,t)&&t!==i&&r(a,t,{get:()=>s[t],enumerable:!(n=c(s,t))||n.enumerable});return a};var b=a=>u(r({},"__esModule",{value:!0}),a);var f={};h(f,{default:()=>T});module.exports=b(f);var e=require("zod"),o=require("../../../_dashboards/dashboard-visualisation/Validate");const m=e.z.object({id:e.z.string(),display:e.z.string().optional(),unit:e.z.enum(["NUMBER","PERCENTAGE"]).optional()}),d=e.z.object({showLatest:e.z.literal(!1)}),j=e.z.object({...o.DashboardVisualisationSchema.shape,display:e.z.string(),type:e.z.literal("bar-timeseries"),options:e.z.object(d.shape).optional(),columns:e.z.object({...o.DashboardColumns.shape,measures:e.z.array(m).min(1,"Measure must contain at least one item")})}),B={BarTimeseriesMeasureSchema:m,BarTimeseriesSchema:j};var T=B;
2
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/bar-timeseries/validate.ts"],
4
+ "sourcesContent": ["import { z } from 'zod'\nimport { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'\n\nconst BarTimeseriesMeasureSchema = z.object({\n id: z.string(),\n display: z.string().optional(),\n unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),\n})\n\nconst BarTimeseriesOptions = z.object({\n showLatest: z.literal(false),\n})\n\nconst BarTimeseriesSchema = z.object({\n ...DashboardVisualisationSchema.shape,\n display: z.string(),\n type: z.literal('bar-timeseries'),\n options: z.object(BarTimeseriesOptions.shape).optional(),\n columns: z.object({\n ...DashboardColumns.shape,\n measures: z.array(BarTimeseriesMeasureSchema).min(1, 'Measure must contain at least one item'),\n }),\n})\n\nconst BarTimeseriesChartSchemas = {\n BarTimeseriesMeasureSchema,\n BarTimeseriesSchema,\n}\n\nexport default BarTimeseriesChartSchemas\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAkB,eAClBC,EAA+D,iEAE/D,MAAMC,EAA6B,IAAE,OAAO,CAC1C,GAAI,IAAE,OAAO,EACb,QAAS,IAAE,OAAO,EAAE,SAAS,EAC7B,KAAM,IAAE,KAAK,CAAC,SAAU,YAAY,CAAC,EAAE,SAAS,CAClD,CAAC,EAEKC,EAAuB,IAAE,OAAO,CACpC,WAAY,IAAE,QAAQ,EAAK,CAC7B,CAAC,EAEKC,EAAsB,IAAE,OAAO,CACnC,GAAG,+BAA6B,MAChC,QAAS,IAAE,OAAO,EAClB,KAAM,IAAE,QAAQ,gBAAgB,EAChC,QAAS,IAAE,OAAOD,EAAqB,KAAK,EAAE,SAAS,EACvD,QAAS,IAAE,OAAO,CAChB,GAAG,mBAAiB,MACpB,SAAU,IAAE,MAAMD,CAA0B,EAAE,IAAI,EAAG,wCAAwC,CAC/F,CAAC,CACH,CAAC,EAEKG,EAA4B,CAChC,2BAAAH,EACA,oBAAAE,CACF,EAEA,IAAON,EAAQO",
6
+ "names": ["validate_exports", "__export", "validate_default", "__toCommonJS", "import_zod", "import_Validate", "BarTimeseriesMeasureSchema", "BarTimeseriesOptions", "BarTimeseriesSchema", "BarTimeseriesChartSchemas"]
7
+ }
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod'
2
+ import { DashboardVisualisationSchema, DashboardColumns } from '../../../_dashboards/dashboard-visualisation/Validate'
3
+
4
+ const BarTimeseriesMeasureSchema = z.object({
5
+ id: z.string(),
6
+ display: z.string().optional(),
7
+ unit: z.enum(['NUMBER', 'PERCENTAGE']).optional(),
8
+ })
9
+
10
+ const BarTimeseriesOptions = z.object({
11
+ showLatest: z.literal(false),
12
+ })
13
+
14
+ const BarTimeseriesSchema = z.object({
15
+ ...DashboardVisualisationSchema.shape,
16
+ display: z.string(),
17
+ type: z.literal('bar-timeseries'),
18
+ options: z.object(BarTimeseriesOptions.shape).optional(),
19
+ columns: z.object({
20
+ ...DashboardColumns.shape,
21
+ measures: z.array(BarTimeseriesMeasureSchema).min(1, 'Measure must contain at least one item'),
22
+ }),
23
+ })
24
+
25
+ const BarTimeseriesChartSchemas = {
26
+ BarTimeseriesMeasureSchema,
27
+ BarTimeseriesSchema,
28
+ }
29
+
30
+ export default BarTimeseriesChartSchemas
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.create;var h=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var g=(o,t)=>{for(var e in t)h(o,e,{get:t[e],enumerable:!0})},l=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of b(t))!d.call(o,i)&&i!==e&&h(o,i,{get:()=>t[i],enumerable:!(s=f(t,i))||s.enumerable});return o};var B=(o,t,e)=>(e=o!=null?m(C(o)):{},l(t||!o||!o.__esModule?h(e,"default",{value:o,enumerable:!0}):e,o)),D=o=>l(h({},"__esModule",{value:!0}),o);var y={};g(y,{Buckets:()=>c,default:()=>v});module.exports=D(y);var p=require("with-alpha-hex"),k=B(require("./validate"));class c{constructor(t,e,s,i,r){this.baseColour="#1d70b8";this.ragColours=["#00703c","#ffdd00","#d4351c"];this.buckets=[];this.useRagColour=!1;this.bucketCount=0;this.onlyBucketColoursDefined=!1;this.autoBucketing=!1;this.hasRagScore=!1;this.initFromOptions=t=>{this.options=k.default.parse(t.options),this.baseColour=this.options?.baseColour||this.baseColour,this.useRagColour=this.options?.useRagColour||!1,this.onlyBucketColoursDefined=this.options&&this.options.buckets?this.options?.buckets?.every(e=>!e.max&&!e.min&&e.hexColour!==void 0):!1};this.initBuckets=()=>{const{buckets:t}=this.options;this.setBucketCount(),this.initBucketColours(),t&&t.length?this.hasRagScore?this.onlyBucketColoursDefined&&(this.buckets=t):!this.hasRagScore&&this.onlyBucketColoursDefined&&this.autoBucketing?this.initAutomaticThresholdBucket():this.initCustomThresholdBuckets():!this.hasRagScore&&this.autoBucketing&&this.initAutomaticThresholdBucket()};this.initCustomThresholdBuckets=()=>{this.buckets=this.options.buckets?this.options.buckets.map((t,e)=>({...this.buckets[e],...t})):[]};this.initAutomaticThresholdBucket=()=>{const{min:t,max:e,bucketSize:s}=this.setAutomaticThresholdSize();let i=0;this.buckets=this.buckets.map((r,u)=>{let n=t;return u!==0&&(n=i+1),i=s*(u+1)+t,u===this.buckets.length-1&&(i=e),{hexColour:this.options?.buckets&&this.options?.buckets.length?this.options.buckets[u]?.hexColour:r.hexColour,min:n,max:i}})};this.initBucketColours=()=>{if(this.useRagColour&&this.bucketCount===3)this.buckets=Array.from(new Array(this.bucketCount)).map((t,e)=>({hexColour:this.ragColours[e]}));else{const t=1/this.bucketCount;this.buckets=Array.from(new Array(this.bucketCount)).map((e,s)=>{const i=t*(s+1);return{hexColour:(0,p.withAlphaHex)(this.baseColour,i)}})}};this.setAutomaticThresholdSize=()=>{const t=this.responseData.map(r=>Number(r[this.valueKey].raw)),e=Math.min(...t),s=Math.max(...t),i=Math.ceil((s-e)/this.bucketCount);return{min:e,max:s,bucketSize:i}};this.setBucketCount=()=>{const{buckets:t}=this.options;if(this.hasRagScore)if(this.useRagColour)this.bucketCount=3;else{const e=this.responseData.reduce((s,i)=>(i[this.valueKey].rag!==void 0&&s.push(i[this.valueKey].rag),s),[]);this.bucketCount=Math.max(...e)+1}else t&&t.length?this.bucketCount=t.length:this.bucketCount=3};this.getBucketForValue=(t,e)=>{let s="",i=0;return e!==void 0?{colour:this.buckets[e].hexColour||s,score:e}:(this.buckets.forEach((r,u)=>{const{min:n,max:a}=r;!n&&a&&t<=a&&(s=r.hexColour||s,i=u),n&&t>=n&&a&&t<=a&&(s=r.hexColour||s,i=u),n&&!a&&t>=n&&(s=r.hexColour||s,i=u)}),{colour:s,score:i})};this.getBuckets=()=>this.buckets;this.responseData=t,this.initFromOptions(e),this.valueKey=s,this.hasRagScore=t[0][this.valueKey].rag!==void 0,this.autoBucketing=!!i,r&&(this.ragColours=r),this.initBuckets()}}var v=c;0&&(module.exports={Buckets});
2
+ //# sourceMappingURL=Buckets.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/buckets/Buckets.ts"],
4
+ "sourcesContent": ["/* eslint-disable prefer-destructuring */\nimport { withAlphaHex } from 'with-alpha-hex'\nimport { ScorecardDefinitionType } from '../../../_dashboards/scorecard/types'\nimport { ScorecardGroupDefinitionType } from '../../../_dashboards/scorecard-group/types'\nimport { DashboardDataResponse } from '../../../../types/Metrics'\nimport { DashboardVisualisationBucket } from '../../../_dashboards/dashboard-visualisation/types'\nimport { MatrixTimeseriesDefinitionType } from '../heatmap/types'\nimport BucketOptionsSchema from './validate'\nimport { BucketOptionsDefinition } from './types'\n\ntype DefinitionsWithBuckets = MatrixTimeseriesDefinitionType | ScorecardGroupDefinitionType | ScorecardDefinitionType\n\nclass Buckets {\n private baseColour = '#1d70b8'\n\n private ragColours: string[] = ['#00703c', '#ffdd00', '#d4351c']\n\n private buckets: DashboardVisualisationBucket[] = []\n\n private useRagColour = false\n\n private bucketCount = 0\n\n private onlyBucketColoursDefined = false\n\n private autoBucketing = false\n\n private hasRagScore = false\n\n private valueKey: string\n\n private options!: BucketOptionsDefinition\n\n responseData: DashboardDataResponse[]\n\n constructor(\n responseData: DashboardDataResponse[],\n definition: DefinitionsWithBuckets,\n valueKey: string,\n autoBucketing?: boolean,\n ragColours?: string[],\n ) {\n this.responseData = responseData\n this.initFromOptions(definition)\n this.valueKey = valueKey\n this.hasRagScore = responseData[0][this.valueKey].rag !== undefined\n this.autoBucketing = Boolean(autoBucketing)\n if (ragColours) this.ragColours = ragColours\n this.initBuckets()\n }\n\n private initFromOptions = (definition: DefinitionsWithBuckets) => {\n this.options = BucketOptionsSchema.parse(definition.options)\n this.baseColour = this.options?.baseColour || this.baseColour\n this.useRagColour = this.options?.useRagColour || false\n this.onlyBucketColoursDefined =\n this.options && this.options.buckets\n ? this.options?.buckets?.every((bucket) => !bucket.max && !bucket.min && bucket.hexColour !== undefined)\n : false\n }\n\n private initBuckets = () => {\n const { buckets } = this.options\n\n this.setBucketCount()\n this.initBucketColours()\n\n if (buckets && buckets.length) {\n if (this.hasRagScore) {\n if (this.onlyBucketColoursDefined) {\n this.buckets = buckets\n }\n } else if (!this.hasRagScore && this.onlyBucketColoursDefined && this.autoBucketing) {\n this.initAutomaticThresholdBucket()\n } else {\n this.initCustomThresholdBuckets()\n }\n } else if (!this.hasRagScore && this.autoBucketing) {\n this.initAutomaticThresholdBucket()\n }\n }\n\n private initCustomThresholdBuckets = () => {\n this.buckets = this.options.buckets\n ? this.options.buckets.map((bucket, i) => {\n return {\n ...this.buckets[i],\n ...bucket,\n }\n })\n : []\n }\n\n /**\n * Initialises the bucket thresholds by defining the range between the min and max\n * and dividing into 3 equal parts\n */\n private initAutomaticThresholdBucket = () => {\n const { min, max, bucketSize } = this.setAutomaticThresholdSize()\n let maxValue = 0\n this.buckets = this.buckets.map((bucket, i) => {\n let minValue = min\n if (i !== 0) minValue = maxValue + 1\n maxValue = bucketSize * (i + 1) + min\n if (i === this.buckets.length - 1) maxValue = max\n\n return {\n hexColour:\n this.options?.buckets && this.options?.buckets.length ? this.options.buckets[i]?.hexColour : bucket.hexColour,\n min: minValue,\n max: maxValue,\n }\n })\n }\n\n private initBucketColours = () => {\n if (this.useRagColour && this.bucketCount === 3) {\n this.buckets = Array.from(new Array(this.bucketCount)).map((_d, i) => {\n return {\n hexColour: this.ragColours[i],\n }\n })\n } else {\n const alphaDivision = 1 / this.bucketCount\n this.buckets = Array.from(new Array(this.bucketCount)).map((_d, i) => {\n const division = alphaDivision * (i + 1)\n return {\n hexColour: withAlphaHex(this.baseColour, division),\n }\n })\n }\n }\n\n private setAutomaticThresholdSize = () => {\n const values = this.responseData.map((resData) => Number(resData[this.valueKey].raw))\n const min = Math.min(...values)\n const max = Math.max(...values)\n const bucketSize = Math.ceil((max - min) / this.bucketCount)\n\n return {\n min,\n max,\n bucketSize,\n }\n }\n\n private setBucketCount = () => {\n const { buckets } = this.options\n if (this.hasRagScore) {\n if (this.useRagColour) {\n this.bucketCount = 3\n } else {\n const allRags: number[] = this.responseData.reduce((acc: number[], resData: DashboardDataResponse) => {\n if (resData[this.valueKey].rag !== undefined) {\n acc.push(<number>resData[this.valueKey].rag)\n }\n return acc\n }, [])\n this.bucketCount = Math.max(...allRags) + 1\n }\n } else if (buckets && buckets.length) {\n this.bucketCount = buckets.length\n } else {\n this.bucketCount = 3\n }\n }\n\n getBucketForValue = (value: number, ragScore?: number): { colour: string; score: number } => {\n let colour = ''\n let score = 0\n\n if (ragScore !== undefined) {\n return {\n colour: this.buckets[ragScore].hexColour || colour,\n score: ragScore,\n }\n }\n\n this.buckets.forEach((bucket, index) => {\n const { min, max } = bucket\n // First bucket\n if (!min && max && value <= max) {\n colour = bucket.hexColour || colour\n score = index\n }\n // middle buckets\n if (min && value >= min && max && value <= max) {\n colour = bucket.hexColour || colour\n score = index\n }\n // last bucket\n if (min && !max && value >= min) {\n colour = bucket.hexColour || colour\n score = index\n }\n })\n\n return {\n colour,\n score,\n }\n }\n\n getBuckets = () => {\n return this.buckets\n }\n}\n\nexport { Buckets }\nexport default Buckets\n"],
5
+ "mappings": "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",
6
+ "names": ["Buckets_exports", "__export", "Buckets", "Buckets_default", "__toCommonJS", "import_with_alpha_hex", "import_validate", "responseData", "definition", "valueKey", "autoBucketing", "ragColours", "BucketOptionsSchema", "bucket", "buckets", "i", "min", "max", "bucketSize", "maxValue", "minValue", "_d", "alphaDivision", "division", "values", "resData", "allRags", "acc", "value", "ragScore", "colour", "score", "index"]
7
+ }
@@ -1,11 +1,14 @@
1
1
  /* eslint-disable prefer-destructuring */
2
2
  import { withAlphaHex } from 'with-alpha-hex'
3
- import { DashboardDataResponse } from '../../../types/Metrics'
4
- import {
5
- DashboardVisualisationBucket,
6
- BucketDashboardVisualisationOptions,
7
- } from '../../_dashboards/dashboard-visualisation/types'
8
- import { components } from '../../../types/api'
3
+ import { ScorecardDefinitionType } from '../../../_dashboards/scorecard/types'
4
+ import { ScorecardGroupDefinitionType } from '../../../_dashboards/scorecard-group/types'
5
+ import { DashboardDataResponse } from '../../../../types/Metrics'
6
+ import { DashboardVisualisationBucket } from '../../../_dashboards/dashboard-visualisation/types'
7
+ import { MatrixTimeseriesDefinitionType } from '../heatmap/types'
8
+ import BucketOptionsSchema from './validate'
9
+ import { BucketOptionsDefinition } from './types'
10
+
11
+ type DefinitionsWithBuckets = MatrixTimeseriesDefinitionType | ScorecardGroupDefinitionType | ScorecardDefinitionType
9
12
 
10
13
  class Buckets {
11
14
  private baseColour = '#1d70b8'
@@ -26,13 +29,13 @@ class Buckets {
26
29
 
27
30
  private valueKey: string
28
31
 
29
- private options: BucketDashboardVisualisationOptions = {}
32
+ private options!: BucketOptionsDefinition
30
33
 
31
34
  responseData: DashboardDataResponse[]
32
35
 
33
36
  constructor(
34
37
  responseData: DashboardDataResponse[],
35
- definition: components['schemas']['DashboardVisualisationDefinition'],
38
+ definition: DefinitionsWithBuckets,
36
39
  valueKey: string,
37
40
  autoBucketing?: boolean,
38
41
  ragColours?: string[],
@@ -46,8 +49,8 @@ class Buckets {
46
49
  this.initBuckets()
47
50
  }
48
51
 
49
- private initFromOptions = (definition: components['schemas']['DashboardVisualisationDefinition']) => {
50
- this.options = <BucketDashboardVisualisationOptions>definition.options || {}
52
+ private initFromOptions = (definition: DefinitionsWithBuckets) => {
53
+ this.options = BucketOptionsSchema.parse(definition.options)
51
54
  this.baseColour = this.options?.baseColour || this.baseColour
52
55
  this.useRagColour = this.options?.useRagColour || false
53
56
  this.onlyBucketColoursDefined =
@@ -62,7 +65,7 @@ class Buckets {
62
65
  this.setBucketCount()
63
66
  this.initBucketColours()
64
67
 
65
- if (buckets) {
68
+ if (buckets && buckets.length) {
66
69
  if (this.hasRagScore) {
67
70
  if (this.onlyBucketColoursDefined) {
68
71
  this.buckets = buckets
@@ -72,7 +75,7 @@ class Buckets {
72
75
  } else {
73
76
  this.initCustomThresholdBuckets()
74
77
  }
75
- } else if (!buckets && !this.hasRagScore && this.autoBucketing) {
78
+ } else if (!this.hasRagScore && this.autoBucketing) {
76
79
  this.initAutomaticThresholdBucket()
77
80
  }
78
81
  }
@@ -102,7 +105,8 @@ class Buckets {
102
105
  if (i === this.buckets.length - 1) maxValue = max
103
106
 
104
107
  return {
105
- hexColour: this.options?.buckets ? this.options.buckets[i]?.hexColour : bucket.hexColour,
108
+ hexColour:
109
+ this.options?.buckets && this.options?.buckets.length ? this.options.buckets[i]?.hexColour : bucket.hexColour,
106
110
  min: minValue,
107
111
  max: maxValue,
108
112
  }
@@ -154,7 +158,7 @@ class Buckets {
154
158
  }, [])
155
159
  this.bucketCount = Math.max(...allRags) + 1
156
160
  }
157
- } else if (buckets) {
161
+ } else if (buckets && buckets.length) {
158
162
  this.bucketCount = buckets.length
159
163
  } else {
160
164
  this.bucketCount = 3
@@ -0,0 +1,2 @@
1
+ "use strict";var p=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(e,t,m,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of r(t))!c.call(e,o)&&o!==m&&p(e,o,{get:()=>t[o],enumerable:!(i=n(t,o))||i.enumerable});return e};var k=e=>f(p({},"__esModule",{value:!0}),e);var s={};module.exports=k(s);
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/buckets/types.ts"],
4
+ "sourcesContent": ["import z from 'zod'\nimport BucketOptionsSchema from './validate'\n\nexport type BucketOptionsDefinition = z.infer<typeof BucketOptionsSchema>\n"],
5
+ "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["types_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,4 @@
1
+ import z from 'zod'
2
+ import BucketOptionsSchema from './validate'
3
+
4
+ export type BucketOptionsDefinition = z.infer<typeof BucketOptionsSchema>
@@ -0,0 +1,2 @@
1
+ "use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(t,o)=>{for(var r in o)n(t,r,{get:o[r],enumerable:!0})},p=(t,o,r,l)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of i(o))!b.call(t,a)&&a!==r&&n(t,a,{get:()=>o[a],enumerable:!(l=s(o,a))||l.enumerable});return t};var m=t=>p(n({},"__esModule",{value:!0}),t);var f={};c(f,{BucketOptionsSchema:()=>u,default:()=>d});module.exports=m(f);var e=require("zod");const x=e.z.object({min:e.z.number().optional(),max:e.z.number().optional(),hexColour:e.z.string().regex(/^#/).optional()}),u=e.z.object({useRagColour:e.z.boolean().default(!1),buckets:e.z.array(x).default([]),baseColour:e.z.string().regex(/^#/).optional()});var d=u;0&&(module.exports={BucketOptionsSchema});
2
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/dpr/components/_charts/chart/buckets/validate.ts"],
4
+ "sourcesContent": ["import { z } from 'zod'\n\nconst dashboardBucket = z.object({\n min: z.number().optional(),\n max: z.number().optional(),\n hexColour: z.string().regex(/^#/).optional(),\n})\n\nexport const BucketOptionsSchema = z.object({\n useRagColour: z.boolean().default(false),\n buckets: z.array(dashboardBucket).default([]),\n baseColour: z.string().regex(/^#/).optional(),\n})\n\nexport default BucketOptionsSchema\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkB,eAElB,MAAMC,EAAkB,IAAE,OAAO,CAC/B,IAAK,IAAE,OAAO,EAAE,SAAS,EACzB,IAAK,IAAE,OAAO,EAAE,SAAS,EACzB,UAAW,IAAE,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,CAC7C,CAAC,EAEYJ,EAAsB,IAAE,OAAO,CAC1C,aAAc,IAAE,QAAQ,EAAE,QAAQ,EAAK,EACvC,QAAS,IAAE,MAAMI,CAAe,EAAE,QAAQ,CAAC,CAAC,EAC5C,WAAY,IAAE,OAAO,EAAE,MAAM,IAAI,EAAE,SAAS,CAC9C,CAAC,EAED,IAAOH,EAAQD",
6
+ "names": ["validate_exports", "__export", "BucketOptionsSchema", "validate_default", "__toCommonJS", "import_zod", "dashboardBucket"]
7
+ }
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod'
2
+
3
+ const dashboardBucket = z.object({
4
+ min: z.number().optional(),
5
+ max: z.number().optional(),
6
+ hexColour: z.string().regex(/^#/).optional(),
7
+ })
8
+
9
+ export const BucketOptionsSchema = z.object({
10
+ useRagColour: z.boolean().default(false),
11
+ buckets: z.array(dashboardBucket).default([]),
12
+ baseColour: z.string().regex(/^#/).optional(),
13
+ })
14
+
15
+ export default BucketOptionsSchema
@@ -0,0 +1,2 @@
1
+ "use strict";var e=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(t,o)=>{for(var n in o)e(t,n,{get:o[n],enumerable:!0})},b=(t,o,n,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of s(o))!l.call(t,i)&&i!==n&&e(t,i,{get:()=>o[i],enumerable:!(r=a(o,i))||r.enumerable});return t};var d=t=>b(e({},"__esModule",{value:!0}),t);var y={};p(y,{default:()=>g});module.exports=d(y);const u={backgroundColor:"#FFF",bodyColor:"#000",titleFont:{size:16},bodyFont:{size:16},titleColor:"#000",displayColors:!1,borderWidth:1,borderColor:"#b1b4b6",cornerRadius:0,padding:20,footerFont:{weight:"bold"},animation:{duration:0}},m={responsive:!0,maintainAspectRatio:!1,animation:{duration:0},hover:{animationDuration:0},plugins:{legend:{position:"bottom"},tooltip:u}};var g=m;
2
+ //# sourceMappingURL=chart-config.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/dpr/components/_charts/chart/chart-config.ts"],
4
+ "sourcesContent": ["const tooltip: ChartTooltipType = {\n backgroundColor: '#FFF',\n bodyColor: '#000',\n titleFont: {\n size: 16,\n },\n bodyFont: {\n size: 16,\n },\n titleColor: '#000',\n displayColors: false,\n borderWidth: 1,\n borderColor: '#b1b4b6',\n cornerRadius: 0,\n padding: 20,\n footerFont: {\n weight: 'bold',\n },\n animation: {\n duration: 0,\n },\n}\n\nconst chartConfig: ChartOptionsType = {\n responsive: true,\n maintainAspectRatio: false,\n animation: {\n duration: 0,\n },\n hover: {\n animationDuration: 0,\n },\n plugins: {\n legend: {\n position: 'bottom',\n },\n tooltip,\n },\n}\n\ntype ChartTooltipType = {\n backgroundColor: string\n bodyColor: string\n titleFont: {\n size: number\n }\n bodyFont: {\n size: number\n }\n titleColor: string\n displayColors: false\n borderWidth: number\n borderColor: string\n cornerRadius: number\n padding: number\n footerFont: {\n weight: string\n }\n animation: {\n duration: number\n }\n}\n\nexport type ChartOptionsType = {\n responsive: boolean\n maintainAspectRatio: boolean\n animation: {\n duration: number\n }\n hover: {\n animationDuration: number\n }\n plugins: {\n legend: {\n position: string\n }\n tooltip: ChartTooltipType\n }\n indexAxis?: string\n cutout?: string\n scales?: ChartScalesType\n}\n\ntype ChartScalesType = {\n y?: ChartScaleAxis\n x?: ChartScaleAxis\n}\n\ntype ChartScaleAxis = {\n stacked?: boolean\n position?: string\n type?: string\n min?: number\n offset?: boolean\n labels?: Array<string | number>\n grid?: {\n display: boolean\n drawBorder: boolean\n }\n ticks?: {\n fontSize?: number\n padding?: number\n maxRotation?: number\n stepSize?: number\n }\n}\n\nexport default chartConfig\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,MAAMI,EAA4B,CAChC,gBAAiB,OACjB,UAAW,OACX,UAAW,CACT,KAAM,EACR,EACA,SAAU,CACR,KAAM,EACR,EACA,WAAY,OACZ,cAAe,GACf,YAAa,EACb,YAAa,UACb,aAAc,EACd,QAAS,GACT,WAAY,CACV,OAAQ,MACV,EACA,UAAW,CACT,SAAU,CACZ,CACF,EAEMC,EAAgC,CACpC,WAAY,GACZ,oBAAqB,GACrB,UAAW,CACT,SAAU,CACZ,EACA,MAAO,CACL,kBAAmB,CACrB,EACA,QAAS,CACP,OAAQ,CACN,SAAU,QACZ,EACA,QAAAD,CACF,CACF,EAqEA,IAAOF,EAAQG",
6
+ "names": ["chart_config_exports", "__export", "chart_config_default", "__toCommonJS", "tooltip", "chartConfig"]
7
+ }
@@ -0,0 +1,108 @@
1
+ const tooltip: ChartTooltipType = {
2
+ backgroundColor: '#FFF',
3
+ bodyColor: '#000',
4
+ titleFont: {
5
+ size: 16,
6
+ },
7
+ bodyFont: {
8
+ size: 16,
9
+ },
10
+ titleColor: '#000',
11
+ displayColors: false,
12
+ borderWidth: 1,
13
+ borderColor: '#b1b4b6',
14
+ cornerRadius: 0,
15
+ padding: 20,
16
+ footerFont: {
17
+ weight: 'bold',
18
+ },
19
+ animation: {
20
+ duration: 0,
21
+ },
22
+ }
23
+
24
+ const chartConfig: ChartOptionsType = {
25
+ responsive: true,
26
+ maintainAspectRatio: false,
27
+ animation: {
28
+ duration: 0,
29
+ },
30
+ hover: {
31
+ animationDuration: 0,
32
+ },
33
+ plugins: {
34
+ legend: {
35
+ position: 'bottom',
36
+ },
37
+ tooltip,
38
+ },
39
+ }
40
+
41
+ type ChartTooltipType = {
42
+ backgroundColor: string
43
+ bodyColor: string
44
+ titleFont: {
45
+ size: number
46
+ }
47
+ bodyFont: {
48
+ size: number
49
+ }
50
+ titleColor: string
51
+ displayColors: false
52
+ borderWidth: number
53
+ borderColor: string
54
+ cornerRadius: number
55
+ padding: number
56
+ footerFont: {
57
+ weight: string
58
+ }
59
+ animation: {
60
+ duration: number
61
+ }
62
+ }
63
+
64
+ export type ChartOptionsType = {
65
+ responsive: boolean
66
+ maintainAspectRatio: boolean
67
+ animation: {
68
+ duration: number
69
+ }
70
+ hover: {
71
+ animationDuration: number
72
+ }
73
+ plugins: {
74
+ legend: {
75
+ position: string
76
+ }
77
+ tooltip: ChartTooltipType
78
+ }
79
+ indexAxis?: string
80
+ cutout?: string
81
+ scales?: ChartScalesType
82
+ }
83
+
84
+ type ChartScalesType = {
85
+ y?: ChartScaleAxis
86
+ x?: ChartScaleAxis
87
+ }
88
+
89
+ type ChartScaleAxis = {
90
+ stacked?: boolean
91
+ position?: string
92
+ type?: string
93
+ min?: number
94
+ offset?: boolean
95
+ labels?: Array<string | number>
96
+ grid?: {
97
+ display: boolean
98
+ drawBorder: boolean
99
+ }
100
+ ticks?: {
101
+ fontSize?: number
102
+ padding?: number
103
+ maxRotation?: number
104
+ stepSize?: number
105
+ }
106
+ }
107
+
108
+ export default chartConfig