@mixd-id/web-scaffold 0.2.240702 → 0.2.240704

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 (95) hide show
  1. package/docs/schema/user-action.json +266 -0
  2. package/package.json +6 -2
  3. package/public/assets/dashboard/bar.png +0 -0
  4. package/public/assets/dashboard/doughnut.png +0 -0
  5. package/public/assets/dashboard/metric.png +0 -0
  6. package/public/assets/dashboard/pie.png +0 -0
  7. package/public/assets/dashboard/polar-area.png +0 -0
  8. package/public/assets/dashboard/virtual-table.png +0 -0
  9. package/public/static/dashboard/bar.png +0 -0
  10. package/public/static/dashboard/doughnut.png +0 -0
  11. package/public/static/dashboard/metric.png +0 -0
  12. package/public/static/dashboard/pie.png +0 -0
  13. package/public/static/dashboard/polar-area.png +0 -0
  14. package/public/static/dashboard/virtual-table.png +0 -0
  15. package/src/components/Button.vue +179 -160
  16. package/src/components/Checkbox.vue +0 -1
  17. package/src/components/Datepicker.vue +8 -6
  18. package/src/components/GHeatMaps.vue +317 -0
  19. package/src/components/GmapsDirection.vue +191 -0
  20. package/src/components/Grid.vue +2 -0
  21. package/src/components/HTMLEditor.vue +2 -2
  22. package/src/components/List.vue +384 -308
  23. package/src/components/Modal.vue +2 -3
  24. package/src/components/PresetSelectorFilterItem.vue +15 -2
  25. package/src/components/Switch.vue +3 -0
  26. package/src/components/Tabs.vue +1 -1
  27. package/src/components/TextWithTag.vue +67 -25
  28. package/src/components/Textbox.vue +5 -0
  29. package/src/components/VirtualGrid.vue +224 -228
  30. package/src/components/VirtualTable.vue +46 -28
  31. package/src/configs/dashboard/bar.js +10 -0
  32. package/src/configs/dashboard/collection-1.js +5 -0
  33. package/src/configs/dashboard/doughnut.js +7 -0
  34. package/src/configs/dashboard/gheatmaps.js +9 -0
  35. package/src/configs/dashboard/grid-2.js +34 -0
  36. package/src/configs/dashboard/grid-3.js +34 -0
  37. package/src/configs/dashboard/grid-4.js +34 -0
  38. package/src/configs/dashboard/grid.js +15 -0
  39. package/src/configs/dashboard/metric.js +10 -0
  40. package/src/configs/dashboard/pie.js +7 -0
  41. package/src/configs/dashboard/polar-area.js +7 -0
  42. package/src/configs/dashboard/virtual-table.js +9 -0
  43. package/src/defs/dashboard-preset.js +22 -0
  44. package/src/index.js +37 -23
  45. package/src/mixin/ready-state.js +37 -0
  46. package/src/stores/datasource.js +11 -0
  47. package/src/themes/default/index.js +1 -1
  48. package/src/utils/dashboard.js +1080 -0
  49. package/src/utils/event-bus.js +8 -0
  50. package/src/utils/helpers.js +56 -8
  51. package/src/utils/helpers.mjs +35 -1
  52. package/src/utils/preset-selector.js +5 -2
  53. package/src/utils/preset-selector.mjs +23 -13
  54. package/src/widgets/BotEditor/BotEditorActions.vue +162 -0
  55. package/src/widgets/BotEditor.vue +228 -0
  56. package/src/widgets/Dashboard/BarChart.vue +330 -0
  57. package/src/widgets/Dashboard/BarChartSetting.vue +317 -0
  58. package/src/widgets/Dashboard/DatasourceFilterSharing.vue +93 -0
  59. package/src/widgets/Dashboard/DatasourcePreview.vue +93 -0
  60. package/src/widgets/Dashboard/DatasourceSelector.vue +122 -0
  61. package/src/widgets/Dashboard/Doughnut.vue +157 -0
  62. package/src/widgets/Dashboard/DoughnutSetting.vue +196 -0
  63. package/src/widgets/Dashboard/GHeatMapsSetting.vue +108 -0
  64. package/src/widgets/Dashboard/InteractionEdit.vue +228 -0
  65. package/src/widgets/Dashboard/Metric.vue +76 -0
  66. package/src/widgets/Dashboard/MetricSetting.vue +174 -0
  67. package/src/widgets/Dashboard/Pie.vue +139 -0
  68. package/src/widgets/Dashboard/PieSetting.vue +247 -0
  69. package/src/widgets/Dashboard/PolarArea.vue +159 -0
  70. package/src/widgets/Dashboard/PolarAreaSetting.vue +195 -0
  71. package/src/widgets/Dashboard/SharingModal.vue +116 -0
  72. package/src/widgets/Dashboard/ViewSelector.vue +183 -0
  73. package/src/widgets/Dashboard/VirtualColumnEdit.vue +97 -0
  74. package/src/widgets/Dashboard/VirtualTableSetting.vue +234 -0
  75. package/src/widgets/Dashboard.vue +1773 -0
  76. package/src/widgets/PresetBar.vue +136 -175
  77. package/src/widgets/PresetBarPivot.vue +186 -0
  78. package/src/widgets/PresetSelector.vue +2 -2
  79. package/src/widgets/UserActionBuilder/UserActionCondition.vue +99 -0
  80. package/src/widgets/UserActionBuilder/UserActionConsole.vue +77 -0
  81. package/src/widgets/UserActionBuilder/UserActionItem.vue +166 -58
  82. package/src/widgets/UserActionBuilder/UserActionOutput.vue +35 -9
  83. package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +27 -0
  84. package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +28 -0
  85. package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +135 -0
  86. package/src/widgets/UserActionBuilder/UserActionProps.vue +213 -0
  87. package/src/widgets/UserActionBuilder.vue +68 -199
  88. package/src/widgets/WebPageBuilder4/GridSetting.vue +123 -73
  89. package/src/widgets/WebPageBuilder4/HeightSetting.vue +14 -11
  90. package/src/widgets/WebPageBuilder4/MarginSetting.vue +4 -1
  91. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +12 -4
  92. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +4 -0
  93. package/src/widgets/WebPageBuilder4/TreeView.vue +6 -3
  94. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +32 -58
  95. package/tailwind.config.js +2 -2
@@ -0,0 +1,330 @@
1
+ <template>
2
+ <div :class="$style.comp" :style="cStyle">
3
+
4
+ <div v-if="readyState === 2" class="flex-1 flex items-center justify-center">
5
+ <label class="text-text-300">Loading...</label>
6
+ </div>
7
+
8
+ <div v-else-if="isError" class="flex-1 flex">
9
+ <div :style="barStyles" class="flex-1 flex items-center justify-center">
10
+ <p class="text-text-300">{{ value.message }}</p>
11
+ </div>
12
+ </div>
13
+
14
+ <div v-else class="flex flex-col gap-3">
15
+ <div class="flex flex-row items-center gap-4">
16
+ <label class="text-text-400 text-ellipsis overflow-hidden whitespace-nowrap flex-1">{{ label }}</label>
17
+ </div>
18
+
19
+ <div class="flex-1">
20
+ <Bar :style="barStyles"
21
+ :options="chartOptions"
22
+ :data="chartData"/>
23
+ </div>
24
+
25
+ <div v-if="yAxeMultiple && yLegends?.length > 0" class="flex flex-row items-center flex-wrap justify-center gap-1">
26
+ <div v-for="yLegend in showedYLegends"
27
+ @click="toggleExcludes(yLegend)"
28
+ class="p-0.5 px-1 rounded-full text-black cursor-default text-xs min-w-[50px] max-w-[60px] text-center text-ellipsis overflow-hidden whitespace-nowrap capitalize"
29
+ :class="excluded.includes(yLegend.key) ? 'bg-text-200' : ''"
30
+ :style="{ backgroundColor:excluded.includes(yLegend.key) ? '' : yLegend.color }">
31
+ {{ yLegend.key }}
32
+ </div>
33
+ <button v-if="yLegends.length > showedYLegends.length" @click="$refs.legendModal.open()"
34
+ class="bg-text-200 hover:bg-primary-600 w-[21px] h-[21px] rounded-full flex items-center justify-center">
35
+ <svg width="14" height="14" class="fill-white opacity-70" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M64 192C28.61 192 0 220.6 0 256s28.61 64 64 64s64-28.62 64-64S99.39 192 64 192zM256 192C220.6 192 192 220.6 192 256s28.61 64 64 64s64-28.62 64-64S291.4 192 256 192zM448 192c-35.39 0-64 28.62-64 64s28.61 64 64 64s64-28.62 64-64S483.4 192 448 192z"/></svg>
36
+ </button>
37
+ </div>
38
+
39
+ <Modal ref="legendModal" width="320" height="360" :dismissable="true" @dismiss="$refs.legendModal.close()">
40
+ <template v-slot:head>
41
+ <div class="relative p-5">
42
+ <h3>Legend</h3>
43
+ <div class="absolute top-0 right-0 p-2">
44
+ <button type="button" class="p-2" @click="$refs.legendModal.close()">
45
+ <svg width="24" height="24" viewBox="0 0 24 24" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg">
46
+ <path d="M6.53034 5.46965C6.23745 5.17676 5.76257 5.17676 5.46968 5.46965C5.17679 5.76255 5.17679 6.23742 5.46968 6.53031L10.9393 12L5.46967 17.4697C5.17678 17.7626 5.17678 18.2374 5.46967 18.5303C5.76256 18.8232 6.23744 18.8232 6.53033 18.5303L12 13.0606L17.4697 18.5303C17.7626 18.8232 18.2375 18.8232 18.5303 18.5303C18.8232 18.2374 18.8232 17.7626 18.5303 17.4697L13.0607 12L18.5303 6.53032C18.8232 6.23743 18.8232 5.76256 18.5303 5.46966C18.2374 5.17677 17.7626 5.17677 17.4697 5.46966L12 10.9393L6.53034 5.46965Z"/>
47
+ </svg>
48
+ </button>
49
+ </div>
50
+ </div>
51
+ </template>
52
+ <div class="flex-1 p-5 pt-0">
53
+
54
+ <div class="flex flex-col divide-y divide-text-50">
55
+ <div v-for="yLegend in yLegends" class="flex flex-row items-center gap-2 py-2">
56
+ <div class="w-[19px] h-[19px] rounded-full" :style="{ backgroundColor:yLegend.color }"></div>
57
+ <div class="flex-1 text-ellipsis whitespace-nowrap overflow-hidden">{{ yLegend.key }}</div>
58
+ <Checkbox :value="!excluded.includes(yLegend.key)" @click.prevent="toggleExcludes(yLegend)" />
59
+ </div>
60
+ </div>
61
+
62
+ <br />
63
+
64
+ </div>
65
+ </Modal>
66
+ </div>
67
+
68
+ </div>
69
+ </template>
70
+
71
+ <script>
72
+
73
+ import {Bar} from 'vue-chartjs'
74
+ import {color} from 'chart.js/helpers'
75
+ import {strVars} from "../../utils/helpers.mjs";
76
+ import {readyStateMixin} from "../../mixin/ready-state";
77
+
78
+ export default{
79
+
80
+ components: {
81
+ Bar
82
+ },
83
+
84
+ computed: {
85
+
86
+ barStyles(){
87
+ return {
88
+ position: "relative",
89
+ height: `${this.barHeight}px`
90
+ }
91
+ },
92
+
93
+ cStyle(){
94
+ return {
95
+ minHeight: this.height
96
+ }
97
+ },
98
+
99
+ chartData(){
100
+ if(!this.value?.datasets)
101
+ return { labels:[], datasets:[] }
102
+
103
+ return {
104
+ labels: this.value?.labels ?? [],
105
+ datasets: this.value.datasets
106
+ .filter(_ => !this.excluded.includes(_.label))
107
+ .map(_ => {
108
+ return {
109
+ ..._,
110
+ borderWidth: 0,
111
+ borderColor: function(context, options) {
112
+ const hex = options.color;
113
+ return color(hex).darken(0.5).rgbString()
114
+ }
115
+ }
116
+ })
117
+ }
118
+ },
119
+
120
+ chartOptions(){
121
+ return {
122
+ responsive: true,
123
+ maintainAspectRatio: false,
124
+ borderRadius: 4,
125
+ plugins: {
126
+ legend: {
127
+ display: false // This hides the legend
128
+ },
129
+ tooltip: {
130
+ callbacks: {
131
+ title: function(tooltipItems) {
132
+ return `${tooltipItems[0].label}`;
133
+ },
134
+ label: (tooltipItem) => {
135
+ if(this.yAxeMultiple && this.usePercentage)
136
+ return `${tooltipItem.dataset.label}: ${tooltipItem.dataset.data0[tooltipItem.dataIndex]} (${tooltipItem.raw}%)`
137
+ else{
138
+ if(this.stacked){
139
+ const total = this.value.datasets.reduce((acc, cur) => acc + cur.data[tooltipItem.dataIndex], 0)
140
+ const percentage = ((tooltipItem.raw / total) * 100).toFixed(1)
141
+
142
+ return `${tooltipItem.dataset.label}: ${tooltipItem.raw} (${percentage}%)`;
143
+ }
144
+ return `${tooltipItem.dataset.label}: ${tooltipItem.raw}`;
145
+ }
146
+ }
147
+ },
148
+ }
149
+ },
150
+ scales: {
151
+ x: {
152
+ grid: {
153
+ display: true,
154
+ color: function(context){
155
+ return `rgba(255,255,255, .1)`
156
+ }
157
+ },
158
+ ticks: {
159
+ callback: function(value) {
160
+ const label = this.getLabelForValue(value) ?? '';
161
+ return label.length > 10 ? label.slice(0, 30) + '...' : label;
162
+ },
163
+ minRotation: 0,
164
+ maxRotation: 0,
165
+ font: {
166
+ size: 11
167
+ }
168
+ },
169
+ stacked: !!this.stacked,
170
+ },
171
+ y: {
172
+ beginAtZero: true,
173
+ ticks: {
174
+ display: true,
175
+ font: {
176
+ size: 11,
177
+ },
178
+ callback: (value, index, ticks) => {
179
+ if(this.usePercentage)
180
+ return Math.round(index / (ticks.length - 1) * 100) + '%'
181
+ return value
182
+ },
183
+ },
184
+ grid: {
185
+ display: true,
186
+ color: function(context){
187
+ return `rgba(255,255,255, .1)`
188
+ }
189
+ },
190
+ stacked: !!this.stacked
191
+ }
192
+ },
193
+ onClick: this.onClick
194
+ }
195
+ },
196
+
197
+ isError(){
198
+ return this.value?.error === 1
199
+ },
200
+
201
+ yLegends(){
202
+ return this.value?.yLegends ?? []
203
+ },
204
+
205
+ showedYLegends(){
206
+ return this.yLegends.slice(0, 5)
207
+ },
208
+
209
+ },
210
+
211
+ data(){
212
+ return {
213
+ backgroundColors: [
214
+ '#5D9CEC',
215
+ '#A0D468',
216
+ '#FFCE54',
217
+ '#FC6E51',
218
+ '#48CFAD',
219
+ '#AC92EC',
220
+ '#4FC1E9',
221
+ '#FFCE54',
222
+ '#ED5565',
223
+ '#EC87C0'
224
+ ],
225
+
226
+ height: '',
227
+ datasets: null
228
+ }
229
+ },
230
+
231
+ inject: [ 'selectPreset' ],
232
+
233
+ methods: {
234
+
235
+ onClick(e, segments){
236
+
237
+ const clickInteractions = (this.interactions ?? []).filter(_ => _.event === 'click')
238
+ const segment = segments[0]
239
+ if(!segment) return
240
+
241
+ const dataset = this.value.datasets[segment.datasetIndex]
242
+ const obj = {
243
+ segment: this.value.labels[segment.index],
244
+ key: dataset.label,
245
+ value: dataset.data[segment.index]
246
+ }
247
+
248
+ for(let click of clickInteractions){
249
+ const { action, presetUid, filters } = click
250
+
251
+ const params = filters.reduce((res, cur) => {
252
+ res[cur.datasourceUid + '.filters.' + cur.key + '.' + cur.operator] = strVars(cur.value, obj)
253
+ return res
254
+ }, {})
255
+
256
+ switch(action){
257
+
258
+ case 'openDashboardPreset':
259
+ if(typeof this.selectPreset === 'function')
260
+ this.selectPreset(presetUid, params)
261
+ break
262
+ }
263
+ }
264
+
265
+ },
266
+
267
+ toggleExcludes(yLegend){
268
+ if(this.excluded.includes(yLegend.key))
269
+ this.excluded.splice(this.excluded.indexOf(yLegend.key), 1)
270
+ else
271
+ this.excluded.push(yLegend.key)
272
+ }
273
+
274
+ },
275
+
276
+ mounted() {
277
+ this.height = this.$el.clientHeight + 'px'
278
+ },
279
+
280
+ mixins: [ readyStateMixin ],
281
+
282
+ props: {
283
+
284
+ datasourceUid: String,
285
+
286
+ usePercentage: [ Boolean, Number ],
287
+ stacked: [ Boolean, Number ],
288
+
289
+ barHeight: {
290
+ type: Number,
291
+ default: 200
292
+ },
293
+
294
+ label: String,
295
+
296
+ xAxes: Array,
297
+ yAxes: Array,
298
+ xAxeMultiple: Boolean,
299
+ yAxeMultiple: Boolean,
300
+
301
+ excluded: {
302
+ type: Array,
303
+ default: []
304
+ },
305
+
306
+ segments: Array,
307
+ xAxesGroup: String,
308
+
309
+ yAxeOnClick: Array,
310
+
311
+ value: Object,
312
+
313
+ interactions: Array,
314
+
315
+ uid: String
316
+
317
+ },
318
+
319
+ }
320
+
321
+ </script>
322
+
323
+ <style module>
324
+
325
+ .comp{
326
+ @apply border-[1px] border-text-50 bg-base-500 rounded-lg;
327
+ @apply p-3 flex flex-col min-h-[200px];
328
+ }
329
+
330
+ </style>
@@ -0,0 +1,317 @@
1
+ <template>
2
+ <div class="flex flex-col gap-5 p-6">
3
+
4
+ <div class="flex flex-row items-center">
5
+ <label class="flex-1">Active</label>
6
+ <Switch v-model="value.props.enabled" :readonly="readonly" />
7
+ </div>
8
+
9
+ <div class="flex flex-col gap-1">
10
+ <div class="flex flex-row gap-2">
11
+ <label class="flex-1">Datasource</label>
12
+ <button type="button" class="text-primary"
13
+ @click="previewDatasource(selectedDatasource)">Preview</button>
14
+ </div>
15
+ <Dropdown class="min-w-[150px]"
16
+ :readonly="readonly"
17
+ v-model="value.props.datasourceUid"
18
+ @change="delete value.props.columns">
19
+ <option v-for="obj in datasource"
20
+ :value="obj.uid">
21
+ {{ obj.name }}
22
+ </option>
23
+ </Dropdown>
24
+ </div>
25
+
26
+ <div class="flex flex-col gap-1">
27
+ <label class="flex-1">Label</label>
28
+ <Textbox v-model="value.props.label" maxlength="50" placeholder="Label" :readonly="readonly" />
29
+ </div>
30
+
31
+ <div v-if="value.props.datasourceUid" class="flex flex-col gap-5">
32
+
33
+ <div class="flex flex-col">
34
+ <div class="flex flex-row items-center gap-3">
35
+ <div class="flex-1">
36
+ <label class="text-primary cursor-pointer"
37
+ ref="xAxis"
38
+ @click="!readonly ? $refs.context1.open($refs.xAxis) : null">
39
+ {{ value.props.xAxeMultiple ? 'X Axes' : 'X Axis' }}
40
+ <svg v-if="!readonly" class="fill-primary inline relative top-[-1px]" width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M310.6 246.6l-127.1 128C176.4 380.9 168.2 384 160 384s-16.38-3.125-22.63-9.375l-127.1-128C.2244 237.5-2.516 223.7 2.438 211.8S19.07 192 32 192h255.1c12.94 0 24.62 7.781 29.58 19.75S319.8 237.5 310.6 246.6z"/></svg>
41
+ </label>
42
+ <ContextMenu ref="context1">
43
+ <div class="flex flex-col min-w-[100px]">
44
+
45
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
46
+ @click="value.props.xAxeMultiple = false;$emit('change')">
47
+ Single
48
+ </button>
49
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
50
+ @click="value.props.xAxeMultiple = true;$emit('change')">
51
+ Multiple
52
+ </button>
53
+ </div>
54
+ </ContextMenu>
55
+ </div>
56
+ <button v-if="value.props.xAxeMultiple && !readonly" type="button" class="text-primary" @click="xAxes.push({})">
57
+ <svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M432 256c0 17.69-14.33 32.01-32 32.01H256v144c0 17.69-14.33 31.99-32 31.99s-32-14.3-32-31.99v-144H48c-17.67 0-32-14.32-32-32.01s14.33-31.99 32-31.99H192v-144c0-17.69 14.33-32.01 32-32.01s32 14.32 32 32.01v144h144C417.7 224 432 238.3 432 256z"/></svg>
58
+ </button>
59
+ </div>
60
+
61
+ <ListItem :items="cXAxes" class="mt-2 bg-transparent" container-class="flex flex-col gap-1"
62
+ @reorder="(from, to) => { cXAxes.splice(to, 0, cXAxes.splice(from, 1)[0]); $emit('change') }">
63
+ <template v-slot="{ item, index }">
64
+ <div class="flex flex-row items-center gap-2">
65
+ <div data-reorder v-if="cXAxes.length > 1 && !readonly">
66
+ <svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
67
+ </div>
68
+ <div class="flex-1 flex flex-row gap-2">
69
+ <Dropdown v-model="item.key" :readonly="readonly" class="flex-1">
70
+ <option v-for="column in selectedDatasourceColumns"
71
+ :value="column.key">
72
+ {{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
73
+ </option>
74
+ </Dropdown>
75
+
76
+ <Dropdown v-if="!value.props.xAxeMultiple" v-model="item.modifier" :readonly="readonly" class="w-[100px]">
77
+ <option value="">-</option>
78
+ <option value="lowercase">Lower</option>
79
+ <option value="capitalize">Capitalize</option>
80
+ <option value="uppercase">Upper</option>
81
+ <option disabled>-----</option>
82
+ <option value="date">Date</option>
83
+ <option value="month">Month</option>
84
+ <option value="year">Year</option>
85
+ <option value="hour">Hour</option>
86
+ <option value="minute">Minute</option>
87
+ <option value="last60Minutes">Last 60 Minutes</option>
88
+ <option value="last12Hours">Last 12 Hours</option>
89
+ <option value="last24Hours">Last 24 Hours</option>
90
+ </Dropdown>
91
+ </div>
92
+ <button v-if="cXAxes.length > 1 && !readonly" type="button" @click="cXAxes.splice(index, 1)">
93
+ <svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"/></svg>
94
+ </button>
95
+ </div>
96
+ </template>
97
+ </ListItem>
98
+ </div>
99
+
100
+ <div class="flex flex-col">
101
+ <div class="flex flex-row items-center gap-3">
102
+ <div class="flex-1">
103
+ <label class="text-primary cursor-pointer"
104
+ ref="yAxis"
105
+ @click="!readonly ? $refs.context2.open($refs.yAxis) : null">
106
+ {{ value.props.yAxeMultiple ? 'Y Axes' : 'Y Axis' }}
107
+ <svg v-if="!readonly" class="fill-primary inline relative top-[-1px]" width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M310.6 246.6l-127.1 128C176.4 380.9 168.2 384 160 384s-16.38-3.125-22.63-9.375l-127.1-128C.2244 237.5-2.516 223.7 2.438 211.8S19.07 192 32 192h255.1c12.94 0 24.62 7.781 29.58 19.75S319.8 237.5 310.6 246.6z"/></svg>
108
+ </label>
109
+ <ContextMenu ref="context2">
110
+ <div class="flex flex-col min-w-[100px]">
111
+
112
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
113
+ @click="value.props.yAxeMultiple = false;$emit('change')">
114
+ Single
115
+ </button>
116
+ <button class="w-full p-3 text-left flex flex-row" :class="appStyle.menuItem"
117
+ @click="value.props.yAxeMultiple = true;$emit('change')">
118
+ Multiple
119
+ </button>
120
+ </div>
121
+ </ContextMenu>
122
+ </div>
123
+ <button v-if="false" type="button" class="text-primary" @click="yAxes.push({})">
124
+ <svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M432 256c0 17.69-14.33 32.01-32 32.01H256v144c0 17.69-14.33 31.99-32 31.99s-32-14.3-32-31.99v-144H48c-17.67 0-32-14.32-32-32.01s14.33-31.99 32-31.99H192v-144c0-17.69 14.33-32.01 32-32.01s32 14.32 32 32.01v144h144C417.7 224 432 238.3 432 256z"/></svg>
125
+ </button>
126
+ </div>
127
+
128
+ <ListItem :items="cYAxes" class="mt-2 bg-transparent" container-class="flex flex-col gap-1"
129
+ @reorder="(from, to) => { cYAxes.splice(to, 0, cYAxes.splice(from, 1)[0]); $emit('change') }">
130
+ <template v-slot="{ item, index }">
131
+ <div class="flex flex-row items-center gap-2">
132
+ <div data-reorder v-if="cYAxes.length > 1">
133
+ <svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
134
+ </div>
135
+ <div class="flex-1 flex flex-row gap-2">
136
+ <Dropdown v-model="item.key" :readonly="readonly" class="flex-1" @change="clearExcluded">
137
+ <option v-for="column in selectedDatasourceColumns"
138
+ :value="column.key">
139
+ {{ selectedDatasource.pivot?.enabled ? column.key : column.label }}
140
+ </option>
141
+ </Dropdown>
142
+
143
+ <Dropdown v-model="item.modifier" :readonly="readonly" class="w-[100px]">
144
+ <option value="">-</option>
145
+ <option value="count">Count</option>
146
+ <option value="countDistinct">Unique Count</option>
147
+ <option value="sum">Sum</option>
148
+ <option value="avg">Avg</option>
149
+ <option value="min">Min</option>
150
+ <option value="max">Max</option>
151
+ </Dropdown>
152
+ </div>
153
+ <button v-if="cYAxes.length > 1 && !readonly" type="button" @click="cYAxes.splice(index, 1)">
154
+ <svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"/></svg>
155
+ </button>
156
+ </div>
157
+ </template>
158
+ </ListItem>
159
+ </div>
160
+
161
+ <div class="flex justify-center" v-if="!readonly">
162
+ <button type="button" class="text-primary p-3 flex flex-row items-center gap-2"
163
+ @click="swap">
164
+ <svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M449.9 39.96l-48.5 48.53C362.5 53.19 311.4 32 256 32C161.5 32 78.59 92.34 49.58 182.2c-5.438 16.81 3.797 34.88 20.61 40.28c16.97 5.5 34.86-3.812 40.3-20.59C130.9 138.5 189.4 96 256 96c37.96 0 73 14.18 100.2 37.8L311.1 178C295.1 194.8 306.8 223.4 330.4 224h146.9C487.7 223.7 496 215.3 496 204.9V59.04C496 34.99 466.9 22.95 449.9 39.96zM441.8 289.6c-16.94-5.438-34.88 3.812-40.3 20.59C381.1 373.5 322.6 416 256 416c-37.96 0-73-14.18-100.2-37.8L200 334C216.9 317.2 205.2 288.6 181.6 288H34.66C24.32 288.3 16 296.7 16 307.1v145.9c0 24.04 29.07 36.08 46.07 19.07l48.5-48.53C149.5 458.8 200.6 480 255.1 480c94.45 0 177.4-60.34 206.4-150.2C467.9 313 458.6 294.1 441.8 289.6z"/></svg>
165
+ Swap X and Y Axis
166
+ </button>
167
+ </div>
168
+
169
+ <div v-if="value.props.yAxeMultiple" class="flex flex-row items-center gap-2">
170
+ <label class="flex-1">Use Percentage</label>
171
+ <Switch v-model="value.props.usePercentage" :readonly="readonly" />
172
+ </div>
173
+
174
+ <div v-if="value.props.yAxeMultiple" class="flex flex-row items-center gap-2">
175
+ <label class="flex-1">Stacked</label>
176
+ <Switch v-model="value.props.stacked" :readonly="readonly" />
177
+ </div>
178
+
179
+ <div>
180
+ <div class="flex flex-row gap-2">
181
+ <label class="text-text-400 flex-1">Interactions</label>
182
+ <button type="button" class="text-primary" @click="$refs.interactionEdit.create()">
183
+ <svg width="14" height="14" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.0.0-alpha3 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M432 256c0 17.69-14.33 32.01-32 32.01H256v144c0 17.69-14.33 31.99-32 31.99s-32-14.3-32-31.99v-144H48c-17.67 0-32-14.32-32-32.01s14.33-31.99 32-31.99H192v-144c0-17.69 14.33-32.01 32-32.01s32 14.32 32 32.01v144h144C417.7 224 432 238.3 432 256z"/></svg>
184
+ </button>
185
+ </div>
186
+ <div class="mt-1">
187
+ <ListItem :items="interactions"
188
+ class="rounded-xl"
189
+ container-class="flex flex-col divide-y divide-text-50"
190
+ @reorder="(from, to) => { interactions.splice(to, 0, interactions.splice(from, 1)[0]); }">
191
+ <template v-slot="{ item, index }">
192
+ <div class="flex flex-row items-center gap-3 px-3">
193
+ <div data-reorder v-if="interactions.length > 1">
194
+ <svg width="14" height="14" class="fill-text-300" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M496 288H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-128H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h480c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16z"/></svg>
195
+ </div>
196
+ <div class="flex-1 p-3 cursor-pointer" @click="$refs.interactionEdit.open(item)">
197
+ {{ item.event }}
198
+ {{ item.eventModifier ? item.eventModifier : '' }}
199
+ </div>
200
+ <button type="button" @click="interactions.splice(index, 1)">
201
+ <svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"/></svg>
202
+ </button>
203
+ </div>
204
+ </template>
205
+ </ListItem>
206
+
207
+ <InteractionEdit ref="interactionEdit" @save="addInteraction" />
208
+ </div>
209
+ </div>
210
+
211
+ </div>
212
+
213
+
214
+ </div>
215
+ </template>
216
+
217
+ <script>
218
+
219
+ import InteractionEdit from "./InteractionEdit.vue";
220
+
221
+ export default{
222
+ components: {InteractionEdit},
223
+
224
+ computed: {
225
+
226
+ interactions(){
227
+ if(!Array.isArray(this.value.props.interactions))
228
+ this.value.props.interactions = []
229
+ return this.value.props.interactions
230
+ },
231
+
232
+ selectedDatasource(){
233
+ return this.datasource.find(d => d.uid === this.value.props.datasourceUid)
234
+ },
235
+
236
+ selectedDatasourceColumns(){
237
+ if(!this.selectedDatasource) return []
238
+
239
+ return this.selectedDatasource.pivot?.enabled ?
240
+ this.selectedDatasource.pivot.columns :
241
+ [
242
+ ...(this.selectedDatasource.computedColumns ?? []),
243
+ ...this.selectedDatasource.columns
244
+ ]
245
+ },
246
+
247
+ xAxes(){
248
+ if(!Array.isArray(this.value.props.xAxes))
249
+ this.value.props.xAxes = [{ key:"" }]
250
+
251
+ return this.value.props.xAxes
252
+ },
253
+
254
+ cXAxes(){
255
+ return this.value.props.xAxeMultiple ? this.xAxes : [this.xAxes[0]]
256
+ },
257
+
258
+ yAxes(){
259
+ if(!Array.isArray(this.value.props.yAxes))
260
+ this.value.props.yAxes = [{ key:"" }]
261
+
262
+ return this.value.props.yAxes
263
+ },
264
+
265
+ cYAxes(){
266
+ return [this.yAxes[0]]
267
+ }
268
+
269
+ },
270
+
271
+ inject: [ 'appStyle', 'previewDatasource' ],
272
+
273
+ methods: {
274
+
275
+ addInteraction(obj){
276
+ this.$util.push(this.interactions, obj)
277
+ },
278
+
279
+ clearExcluded(){
280
+ this.value.props.excluded = []
281
+ },
282
+
283
+ swap(){
284
+ const yAxes = this.value.props.yAxes
285
+ const xAxes = this.value.props.xAxes
286
+
287
+ Object.assign(this.value.props, {
288
+ xAxes: yAxes,
289
+ yAxes: xAxes
290
+ })
291
+
292
+ this.$emit('change')
293
+ }
294
+
295
+ },
296
+
297
+ props: {
298
+
299
+ datasource: Object,
300
+
301
+ readonly: [ Boolean, Number ],
302
+
303
+ value: Object
304
+
305
+ }
306
+
307
+ }
308
+
309
+ </script>
310
+
311
+ <style module>
312
+
313
+ .comp{
314
+
315
+ }
316
+
317
+ </style>