@mixd-id/web-scaffold 0.1.230406339 → 0.1.230406341

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 (29) hide show
  1. package/package.json +2 -2
  2. package/src/components/Button.vue +105 -71
  3. package/src/components/Switch.vue +3 -0
  4. package/src/components/VirtualTable.vue +4 -4
  5. package/src/index.js +1 -1
  6. package/src/utils/helpers.mjs +15 -0
  7. package/src/widgets/Dashboard/BarChart.vue +29 -121
  8. package/src/widgets/Dashboard/BarChartSetting.vue +32 -22
  9. package/src/widgets/Dashboard/DatasourceCreator.vue +197 -0
  10. package/src/widgets/Dashboard/DatasourceSelector.vue +63 -20
  11. package/src/widgets/Dashboard/Doughnut.vue +7 -45
  12. package/src/widgets/Dashboard/DoughnutSetting.vue +37 -33
  13. package/src/widgets/Dashboard/Metric.vue +13 -37
  14. package/src/widgets/Dashboard/MetricSetting.vue +52 -19
  15. package/src/widgets/Dashboard/Pie.vue +7 -45
  16. package/src/widgets/Dashboard/PieSetting.vue +37 -33
  17. package/src/widgets/Dashboard/PolarArea.vue +7 -45
  18. package/src/widgets/Dashboard/PolarAreaSetting.vue +37 -33
  19. package/src/widgets/Dashboard/SharingModal.vue +112 -0
  20. package/src/widgets/Dashboard/ViewSelector.vue +10 -12
  21. package/src/widgets/Dashboard/VirtualTableSetting.vue +85 -36
  22. package/src/widgets/Dashboard.vue +646 -78
  23. package/src/widgets/WebPageBuilder4/GridSetting.vue +45 -8
  24. package/src/widgets/WebPageBuilder4/HeightSetting.vue +4 -1
  25. package/src/widgets/WebPageBuilder4/MarginSetting.vue +10 -1
  26. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +12 -4
  27. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +4 -0
  28. package/src/widgets/WebPageBuilder4/TreeView.vue +2 -0
  29. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +3 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406339",
4
+ "version": "0.1.230406341",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -53,7 +53,7 @@
53
53
  "lodash": "^4.17.21",
54
54
  "md5": "^2.3.0",
55
55
  "nprogress": "^0.2.0",
56
- "pinia": "^2.0.14",
56
+ "pinia": "^2.0.2",
57
57
  "prismjs": "^1.28.0",
58
58
  "redis": "^4.6.13",
59
59
  "serve-static": "^1.15.0",
@@ -45,9 +45,9 @@ export default{
45
45
 
46
46
  },
47
47
 
48
- computed:{
48
+ computed: {
49
49
 
50
- compClass(){
50
+ compClass() {
51
51
 
52
52
  return [
53
53
  this.$style.button,
@@ -60,20 +60,20 @@ export default{
60
60
  .join(' ')
61
61
  },
62
62
 
63
- isDisabled(){
63
+ isDisabled() {
64
64
  return parseInt(this.computedState) !== 1
65
65
  },
66
66
 
67
- isLoading(){
67
+ isLoading() {
68
68
  return parseInt(this.computedState) === 2
69
69
  },
70
70
 
71
- computedState(){
71
+ computedState() {
72
72
  return this._state ?? this.state
73
73
  },
74
74
 
75
- widths(){
76
- if(!Array.isArray(this.width)) return [ '', '' ]
75
+ widths() {
76
+ if (!Array.isArray(this.width)) return ['', '']
77
77
 
78
78
  return [
79
79
  this.width[0] ?? '',
@@ -83,59 +83,56 @@ export default{
83
83
 
84
84
  },
85
85
 
86
- data(){
86
+ data() {
87
87
  return {
88
88
  _state: null
89
89
  }
90
90
  },
91
91
 
92
- methods:{
92
+ methods: {
93
93
 
94
- focus(){
94
+ focus() {
95
95
  this.$el.focus()
96
96
  },
97
97
 
98
- setState(state, percentage){
98
+ setState(state, percentage) {
99
99
  this._state = state
100
100
  },
101
101
 
102
- resetState(){
102
+ resetState() {
103
103
  this._state = null
104
104
  },
105
105
 
106
- onClick(){
107
- if('edit-mode' in this.$route.query) return
106
+ onClick() {
107
+ if ('edit-mode' in this.$route.query) return
108
108
 
109
- if(this.isDisabled){
109
+ if (this.isDisabled) {
110
110
  this.$emit('disabled-click')
111
- }
112
- else{
113
- if(this.target){
114
- switch(this.targetType){
111
+ } else {
112
+ if (this.target) {
113
+ switch (this.targetType) {
115
114
 
116
115
  case 'section':
117
116
  this.scrollTo(this.target)
118
117
  break
119
118
 
120
119
  default:
121
- if(this.target.indexOf('://') >= 0){
120
+ if (this.target.indexOf('://') >= 0) {
122
121
  window.location = this.target
123
- }
124
- else{
122
+ } else {
125
123
  this.$router.push(this.target)
126
124
  }
127
125
  break
128
126
  }
129
- }
130
- else{
127
+ } else {
131
128
  this.$emit('click')
132
129
  }
133
130
  }
134
131
  },
135
132
 
136
- scrollTo(exp){
133
+ scrollTo(exp) {
137
134
  const el = document.querySelector('._' + exp.substring(0, 4))
138
- if(el){
135
+ if (el) {
139
136
  window.scrollTo({
140
137
  top: el.offsetTop - 100,
141
138
  behavior: 'smooth'
@@ -151,165 +148,202 @@ export default{
151
148
 
152
149
  <style module>
153
150
 
154
- .button{
151
+ .button {
155
152
  @apply p-2;
156
153
  @apply relative flex items-center justify-center;
157
154
  @apply whitespace-nowrap text-ellipsis overflow-hidden;
158
155
  @apply rounded-lg appearance-none;
159
156
  }
160
- .button>*:first-child{
157
+
158
+ .button > *:first-child {
161
159
  @apply flex items-center justify-center
162
160
  }
163
- .button-disabled{
161
+
162
+ .button-disabled {
164
163
  @apply text-opacity-50;
165
164
  }
166
- .button:active{
165
+
166
+ .button:active {
167
167
  @apply top-[1px] left-[1px] relative;
168
168
  }
169
169
 
170
- .button-primary{
170
+ .button-primary {
171
171
  @apply bg-primary-500 text-white rounded-lg;
172
172
  box-shadow: 0 2px 1px rgba(0, 0, 0, .05);
173
173
  border: solid 1px rgb(var(--primary-500));
174
174
  }
175
- .button-primary:focus{
175
+
176
+ .button-primary:focus {
176
177
  border-color: rgb(var(--primary-600));
177
178
  }
178
- .button-primary:hover{
179
+
180
+ .button-primary:hover {
179
181
  @apply bg-primary-600;
180
182
  }
183
+
181
184
  .button-primary-disabled,
182
- .button-primary-disabled:hover{
185
+ .button-primary-disabled:hover {
183
186
  @apply bg-primary-500 top-0 left-0 cursor-not-allowed text-opacity-50;
184
187
  @apply top-0 left-0;
185
188
  }
186
- .button-primary *{
189
+
190
+ .button-primary * {
187
191
  @apply text-white fill-white;
188
192
  }
189
- .button-primary.loading *{
193
+
194
+ .button-primary.loading * {
190
195
  @apply fill-transparent
191
196
  }
192
- .button-primary .svgBg{
197
+
198
+ .button-primary .svgBg {
193
199
  stroke: #fff;
194
200
  stroke-opacity: 25%;
195
201
  }
196
- .button-primary .svgHg{
202
+
203
+ .button-primary .svgHg {
197
204
  fill: #fff;
198
205
  fill-opacity: 75%;
199
206
  }
200
207
 
201
- .button-outline{
208
+ .button-outline {
202
209
  @apply bg-transparent text-primary-500 border-[1px] border-primary;
203
210
  }
204
- .button-outline:hover{
211
+
212
+ .button-outline:hover {
205
213
  }
214
+
206
215
  .button-outline-disabled,
207
- .button-outline-disabled:hover{
216
+ .button-outline-disabled:hover {
208
217
  @apply top-0 left-0 cursor-not-allowed;
209
218
  @apply text-text border-primary-500 text-opacity-50;
210
219
  }
211
- .button-outline *{
220
+
221
+ .button-outline * {
212
222
  @apply text-primary-500 fill-primary-500;
213
223
  }
214
- .button-outline.loading *{
224
+
225
+ .button-outline.loading * {
215
226
  @apply fill-transparent
216
227
  }
217
- .button-outline .svgBg{
228
+
229
+ .button-outline .svgBg {
218
230
  stroke: rgb(var(--primary-600));
219
231
  stroke-opacity: 50%;
220
232
  }
221
- .button-outline .svgHg{
233
+
234
+ .button-outline .svgHg {
222
235
  fill: rgb(var(--primary-500));
223
236
  fill-opacity: 100%;
224
237
  }
225
238
 
226
- .button-secondary{
239
+ .button-secondary {
227
240
  @apply bg-secondary-500 border-secondary-500 text-primary-700 rounded-lg text-white;
228
241
  border: solid 1px rgb(var(--secondary-500));
229
242
  }
230
- .button-secondary:hover{
243
+
244
+ .button-secondary:hover {
231
245
  @apply bg-secondary-600 border-secondary-600;
232
246
  }
247
+
233
248
  .button-secondary-disabled,
234
- .button-secondary-disabled:hover{
249
+ .button-secondary-disabled:hover {
235
250
  @apply bg-secondary-400 border-secondary-400 cursor-not-allowed text-opacity-50;
236
251
  }
237
- .button-secondary *{
252
+
253
+ .button-secondary * {
238
254
  @apply text-text-500 fill-white;
239
255
  }
240
- .button-secondary.loading *{
256
+
257
+ .button-secondary.loading * {
241
258
  @apply fill-transparent
242
259
  }
243
- .button-secondary .svgBg{
260
+
261
+ .button-secondary .svgBg {
244
262
  stroke: rgb(var(--text-400));
245
263
  stroke-opacity: 25%;
246
264
  }
247
- .button-secondary .svgHg{
265
+
266
+ .button-secondary .svgHg {
248
267
  fill: rgb(var(--text-500));
249
268
  fill-opacity: 75%;
250
269
  }
251
270
 
252
- .button-red{
271
+ .button-red {
253
272
  @apply bg-red-500 text-white rounded-md border-[2px] border-red-500;
254
273
  }
255
- .button-red:hover{
274
+
275
+ .button-red:hover {
256
276
  @apply bg-red-600 border-red-600;
257
277
  }
278
+
258
279
  .button-red-disabled,
259
- .button-red-disabled:hover{
280
+ .button-red-disabled:hover {
260
281
  @apply bg-red-500 border-red-500 top-0 left-0 cursor-not-allowed text-opacity-50;
261
282
  }
262
- .button-red *{
283
+
284
+ .button-red * {
263
285
  @apply text-white fill-white;
264
286
  }
265
- .button-red.loading *{
287
+
288
+ .button-red.loading * {
266
289
  @apply fill-transparent
267
290
  }
268
- .button-red .svgBg{
291
+
292
+ .button-red .svgBg {
269
293
  @apply stroke-red-400;
270
294
  stroke-opacity: 50%;
271
295
  }
272
- .button-red .svgHg{
296
+
297
+ .button-red .svgHg {
273
298
  @apply fill-text-500;
274
299
  fill-opacity: 100%;
275
300
  }
276
301
 
277
- .button-minimal{
302
+ .button-minimal {
278
303
  @apply border-[2px] border-transparent;
279
304
  }
280
- .button-minimal:hover{
305
+
306
+ .button-minimal:hover {
281
307
  }
282
- .button-minimal .svgBg{
308
+
309
+ .button-minimal .svgBg {
283
310
  stroke: rgb(var(--text-500));
284
311
  stroke-opacity: 25%;
285
312
  }
286
- .button-minimal .svgHg{
313
+
314
+ .button-minimal .svgHg {
287
315
  fill: rgb(var(--text));
288
316
  fill-opacity: 75%;
289
317
  }
290
318
 
291
- .loadingPane{
319
+ .loadingPane {
292
320
  @apply absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center pl-1;
293
321
  }
294
- .loading{
322
+
323
+ .loading {
295
324
  color: transparent;
296
325
  }
297
- .loading>*:first-child{
326
+
327
+ .loading > *:first-child {
298
328
  @apply opacity-0
299
329
  }
300
- .loading:hover{
330
+
331
+ .loading:hover {
301
332
  }
302
- .loading:active{
333
+
334
+ .loading:active {
303
335
  @apply top-0 left-0;
304
336
  }
305
- .loading>*{
337
+
338
+ .loading > * {
306
339
  opacity: 0;
307
340
  }
308
- .loading .loadingPane{
341
+
342
+ .loading .loadingPane {
309
343
  opacity: 1;
310
344
  }
311
345
 
312
- .spinner{
346
+ .spinner {
313
347
  @apply animate-spin h-5 w-5;
314
348
  }
315
349
 
@@ -91,6 +91,9 @@ export default{
91
91
  .switch>input:checked + label>span{
92
92
  @apply ml-[1.3rem] border-base bg-white
93
93
  }
94
+ .switch>input:checked:disabled + label{
95
+ @apply bg-text-50;
96
+ }
94
97
 
95
98
  .switch>input:checked + label + *,
96
99
  .switch>input:not(:checked) + label + * + *{
@@ -132,7 +132,9 @@ export default{
132
132
  default: {}
133
133
  },
134
134
 
135
- type: String
135
+ type: String,
136
+
137
+ value: Object,
136
138
  },
137
139
 
138
140
  data(){
@@ -154,9 +156,7 @@ export default{
154
156
  },
155
157
 
156
158
  cItems(){
157
- return this.datasourceUid ?
158
- this.datasource.keys[this.datasourceUid]?.items :
159
- this.items
159
+ return this.value?.items ?? this.items
160
160
  },
161
161
 
162
162
  visibleStartIndex(){
package/src/index.js CHANGED
@@ -208,7 +208,7 @@ const util = {
208
208
  window.addEventListener('mouseup', onMouseUp)
209
209
  },
210
210
 
211
- push: (arr, items, opt = { key:'uid', update:true }) => {
211
+ push: (arr, items, opt = { update:true }) => {
212
212
  if(!Array.isArray(arr)) return
213
213
  if(!Array.isArray(items)) items = [ items ]
214
214
  if(!opt.key){
@@ -360,7 +360,22 @@ function applyDatasourceReplacer(value, datasource){
360
360
  return value
361
361
  }
362
362
 
363
+ function capitalize(str) {
364
+ return str.replace(/\b\w/g, function(char) {
365
+ return char.toUpperCase();
366
+ });
367
+ }
368
+
369
+ const round = (num, precision = 0) => {
370
+ var p = Math.pow(10, precision)
371
+ var n = (num * p) * (1 + Number.EPSILON)
372
+ return Math.round(n) / p
373
+ }
374
+
375
+
363
376
  export {
377
+ capitalize,
378
+ round,
364
379
  downsizeImage,
365
380
  hexToRgb,
366
381
  rgbToHex,
@@ -1,5 +1,13 @@
1
1
  <template>
2
- <div :class="$style.comp" class="flex flex-col gap-5">
2
+ <div :class="$style.comp" class="flex flex-col gap-3">
3
+
4
+ <label class="text-text-400 text-ellipsis overflow-hidden whitespace-nowrap">{{ label }}</label>
5
+
6
+ <div class="flex-1">
7
+ <Bar :style="barStyles"
8
+ :options="chartOptions"
9
+ :data="chartData"/>
10
+ </div>
3
11
 
4
12
  <div v-if="yAxeMultiple" class="flex flex-row justify-center gap-1">
5
13
  <div v-for="(yLegend, idx) in yLegends"
@@ -9,12 +17,6 @@
9
17
  </div>
10
18
  </div>
11
19
 
12
- <div class="flex-1">
13
- <Bar :style="barStyles"
14
- :options="chartOptions"
15
- :data="chartData" />
16
- </div>
17
-
18
20
  </div>
19
21
  </template>
20
22
 
@@ -40,115 +42,7 @@ export default{
40
42
  },
41
43
 
42
44
  chartData(){
43
- if(!this.xAxes || !this.cValue?.items)
44
- return { labels:[], datasets:[] }
45
-
46
- let labels = []
47
- let datasets = [
48
- /*{
49
- data:[ 1, 2, 3, 4, 5 ]
50
- },
51
- {
52
- data:[ 2, 3, 4, 5, 6 ]
53
- }*/
54
- ]
55
-
56
- let xAxes
57
- if(this.xAxeMultiple){
58
- xAxes = this.xAxes
59
- }
60
- else{
61
- const xAxesKey = this.xAxes[0].key
62
- const reduced = this.cValue.items.reduce((acc, item) => {
63
- const key = item[xAxesKey]
64
- acc[key] = { key, parentKey:xAxesKey }
65
- return acc
66
- }, {})
67
-
68
- xAxes = Object.values(reduced)
69
- }
70
-
71
- let yAxes
72
- if(this.yAxeMultiple){
73
- const yAxesKey = this.yAxes[0].key
74
- const reduced = this.cValue.items.reduce((acc, item) => {
75
- const key = item[yAxesKey]
76
- acc[key] = { key, parentKey:yAxesKey }
77
- return acc
78
- }, {})
79
-
80
- yAxes = Object.values(reduced)
81
- }
82
- else{
83
- yAxes = [ this.yAxes[0] ]
84
- }
85
-
86
- let idx = 0
87
- const yLegends = []
88
- for(let yAxe of yAxes){
89
-
90
- let data
91
-
92
- let items
93
- if(this.yAxeMultiple){
94
- items = this.cValue.items.filter(_ => _[yAxe.parentKey] === yAxe.key)
95
- }
96
- else{
97
- items = this.cValue.items
98
- }
99
-
100
- if(this.xAxeMultiple){
101
- data = xAxes.map(_ => {
102
- return items.reduce((acc, item) => {
103
- return acc + item[_.key]
104
- }, 0)
105
- })
106
- }
107
- else{
108
- data = xAxes.map(_ => {
109
- const curItems = items.filter(__ => __[_.parentKey] === _.key)
110
-
111
- return curItems.reduce((acc, item) => {
112
- return acc + item[yAxe.key]
113
- }, 0)
114
- })
115
- }
116
-
117
- datasets.push({
118
- label: this.yAxeMultiple ? yAxe.key : 'All',
119
- data,
120
- backgroundColor: yAxes.length > 1 ?
121
- [ this.backgroundColors[idx % this.backgroundColors.length] ]:
122
- this.backgroundColors,
123
- borderColor: yAxes.length > 1 ?
124
- [ this.backgroundColors[idx % this.backgroundColors.length] ]:
125
- this.backgroundColors,
126
- borderWidth: 1
127
- })
128
-
129
- yLegends.push(yAxe.key)
130
-
131
- idx++
132
- }
133
-
134
- labels = xAxes.map(_ => _.key)
135
-
136
- this.yLegends = yLegends
137
-
138
- if(this.relativeValue){
139
-
140
-
141
- }
142
-
143
- console.log('chartData', {
144
- labels,
145
- datasets
146
- })
147
-
148
- return {
149
- labels,
150
- datasets
151
- }
45
+ return this.value ?? { labels:[], datasets:[] }
152
46
  },
153
47
 
154
48
  chartOptions(){
@@ -170,7 +64,7 @@ export default{
170
64
  },
171
65
  ticks: {
172
66
  callback: function(value) {
173
- const label = this.getLabelForValue(value);
67
+ const label = this.getLabelForValue(value) ?? '';
174
68
  return label.length > 10 ? label.slice(0, 10) + '...' : label;
175
69
  },
176
70
  minRotation: 0,
@@ -180,7 +74,7 @@ export default{
180
74
  y: {
181
75
  beginAtZero: true,
182
76
  ticks: {
183
- display: false,
77
+ display: !this.yAxeMultiple || this.usePercentage,
184
78
  },
185
79
  grid: {
186
80
  display: true,
@@ -189,6 +83,10 @@ export default{
189
83
  }
190
84
  },
191
85
  }
86
+ },
87
+ onClick: function(evt, evt2) {
88
+ console.log(evt);
89
+ console.log(evt2);
192
90
  }
193
91
  }
194
92
  },
@@ -197,6 +95,10 @@ export default{
197
95
  return this.datasourceUid && this.datasource ?
198
96
  this.datasource.keys[this.datasourceUid] :
199
97
  this.value
98
+ },
99
+
100
+ yLegends(){
101
+ return this.value.yLegends ?? []
200
102
  }
201
103
 
202
104
  },
@@ -216,7 +118,7 @@ export default{
216
118
  '#EC87C0'
217
119
  ],
218
120
 
219
- yLegends: []
121
+ datasets: null,
220
122
  }
221
123
  },
222
124
 
@@ -224,8 +126,8 @@ export default{
224
126
 
225
127
  datasourceUid: String,
226
128
 
227
- relativeValue: {
228
- type: Boolean,
129
+ usePercentage: {
130
+ type: Number,
229
131
  default: false
230
132
  },
231
133
 
@@ -234,6 +136,8 @@ export default{
234
136
  default: 200
235
137
  },
236
138
 
139
+ label: String,
140
+
237
141
  xAxes: Array,
238
142
  yAxes: Array,
239
143
  xAxeMultiple: Boolean,
@@ -242,6 +146,10 @@ export default{
242
146
  segments: Array,
243
147
  xAxesGroup: String,
244
148
 
149
+ yAxeOnClick: Array,
150
+
151
+ value: Object
152
+
245
153
  },
246
154
 
247
155
  setup(){