@mixd-id/web-scaffold 0.1.230406367 → 0.1.230406369

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.
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.230406367",
4
+ "version": "0.1.230406369",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -55,7 +55,7 @@
55
55
  "md5": "^2.3.0",
56
56
  "mitt": "^3.0.1",
57
57
  "nprogress": "^0.2.0",
58
- "pinia": "^2.0.2",
58
+ "pinia": "^2.3.0",
59
59
  "prismjs": "^1.28.0",
60
60
  "redis": "^4.6.13",
61
61
  "serve-static": "^1.15.0",
@@ -41,7 +41,7 @@ export default{
41
41
 
42
42
  mixins: [ componentMixin ],
43
43
 
44
- emits: [ 'change' ],
44
+ emits: [ 'click', 'change' ],
45
45
 
46
46
  props:{
47
47
 
@@ -256,10 +256,12 @@ export default{
256
256
  }
257
257
  },
258
258
 
259
- onClick(){
259
+ onClick(e){
260
260
  if(!this.moved && this.target){
261
261
  this.$router.push(this.target)
262
262
  }
263
+
264
+ this.$emit('click', e, this)
263
265
  },
264
266
 
265
267
  onMouseDown(){
@@ -1,21 +1,23 @@
1
1
  <template>
2
- <div :class="$style.comp">
3
-
4
- <div class="flex flex-row items-start">
5
- <span contenteditable="true" spellcheck="false"
6
- ref="html"
7
- v-html="html"
8
- :class="`${$style.content}${itemClass ? ' ' + itemClass : ''}`"
9
- @blur="saveSelection($refs.html)"
10
- @paste="onPaste"
11
- @input="onInput"></span>
12
-
13
- <button v-if="variant === 'minimal'" type="button" class="p-3" @click="$refs.modal.open()">
14
- <svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"/></svg>
15
- </button>
2
+ <div :class="$style.comp">
3
+
4
+ <div class="flex flex-row items-start">
5
+ <span :contenteditable="!readonly" spellcheck="false"
6
+ ref="html"
7
+ v-html="html"
8
+ :class="`${$style.content}${itemClass ? ' ' + itemClass : ''}`"
9
+ @blur="onBlur"
10
+ @paste="onPaste"
11
+ @input="onInput"></span>
12
+
13
+ <slot name="end" :comp="this">
14
+ <button v-if="variant === 'minimal' && !readonly" type="button" class="p-3" @click="$refs.modal.open()">
15
+ <svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"/></svg>
16
+ </button>
17
+ </slot>
16
18
  </div>
17
19
 
18
- <div v-if="variant !== 'minimal'" class="flex flex-row bg-base-300" @dblclick.alt="log(JSON.stringify(modelValue))">
20
+ <div v-if="variant !== 'minimal' && !readonly" class="flex flex-row bg-base-300" @dblclick.alt="log(JSON.stringify(modelValue))">
19
21
  <div class="flex-1 flex flex-row gap-2 overflow-x-auto p-1" :class="$style.noScrollbar">
20
22
  <button type="button" v-for="item in viewedItems" :class="$style.tag2" class="text-xs" @click="add(item)">{{ item.text ?? item.value }}</button>
21
23
  </div>
@@ -57,7 +59,7 @@
57
59
 
58
60
  </div>
59
61
  </Modal>
60
- </div>
62
+ </div>
61
63
  </template>
62
64
 
63
65
  <script>
@@ -66,7 +68,7 @@ import {restoreSelection, saveSelection} from "../utils/selection";
66
68
 
67
69
  export default{
68
70
 
69
- emits: [ 'update:modelValue' ],
71
+ emits: [ 'blur', 'update:modelValue' ],
70
72
 
71
73
  props:{
72
74
 
@@ -78,6 +80,8 @@ export default{
78
80
 
79
81
  items: Array,
80
82
 
83
+ readonly: Boolean,
84
+
81
85
  variant: String,
82
86
 
83
87
  itemClass: String,
@@ -118,7 +122,7 @@ export default{
118
122
 
119
123
  let range = selection.getRangeAt(0);
120
124
  if(range.commonAncestorContainer.parentNode !== this.$refs.html &&
121
- range.commonAncestorContainer !== this.$refs.html) return
125
+ range.commonAncestorContainer !== this.$refs.html) return
122
126
 
123
127
  let currentNode = range.startContainer;
124
128
 
@@ -146,6 +150,10 @@ export default{
146
150
 
147
151
  this.insertElement(el)
148
152
  this.onInput()
153
+
154
+ const itemExists = this.items.find(_ => _.value === item.value)
155
+ if(!itemExists)
156
+ this.items.push(item)
149
157
  },
150
158
 
151
159
  add(item){
@@ -174,6 +182,11 @@ export default{
174
182
  e.target.parentNode.removeChild(e.target)
175
183
  },
176
184
 
185
+ onBlur(e){
186
+ this.saveSelection(this.$refs.html)
187
+ this.$emit('blur')
188
+ },
189
+
177
190
  onPaste(e){
178
191
  e.preventDefault()
179
192
  const text = e.clipboardData.getData('text/plain')
@@ -205,8 +218,8 @@ export default{
205
218
 
206
219
  modelValue: {
207
220
  immediate: true,
208
- handler(val){
209
- if(this.isInternal){
221
+ handler(val) {
222
+ if (this.isInternal) {
210
223
  this.isInternal = false
211
224
  return
212
225
  }
@@ -214,7 +227,7 @@ export default{
214
227
  let html = val ?? ''
215
228
 
216
229
  let customItems = []
217
- if(typeof this.itemFn === 'function'){
230
+ if (typeof this.itemFn === 'function') {
218
231
  customItems = this.itemFn(html)
219
232
  }
220
233
 
@@ -223,7 +236,7 @@ export default{
223
236
  ...customItems
224
237
  ]
225
238
 
226
- for(let item of items){
239
+ for (let item of items) {
227
240
  html = html.replaceAll(item.value, `<span title="${item.value.replaceAll('"', '')}" class="${this.$style.tag}" contenteditable="false" data-value="${item.value}">${item.text ?? item.value}</span>`, 'gi')
228
241
  }
229
242
 
@@ -239,28 +252,28 @@ export default{
239
252
 
240
253
  <style module>
241
254
 
242
- .comp{
255
+ .comp {
243
256
  @apply border-[1px] border-text-200 bg-base-50 rounded-lg min-w-[100px];
244
257
  @apply flex flex-col gap-2;
245
258
  @apply overflow-hidden;
246
259
  @apply divide-y divide-text-100;
247
260
  }
248
261
 
249
- .content{
262
+ .content {
250
263
  @apply flex-1 whitespace-pre-line outline-none p-2;
251
264
  }
252
265
 
253
- .comp .tag{
266
+ .comp .tag {
254
267
  @apply bg-text-100 p-1 rounded-lg whitespace-nowrap relative top-[-1px];
255
268
  @apply font-mono text-sm;
256
269
  }
257
270
 
258
- .tag2{
271
+ .tag2 {
259
272
  @apply bg-text-50 p-1 rounded-lg px-2 cursor-pointer whitespace-nowrap;
260
273
  @apply hover:bg-text-100 hover:text-white;
261
274
  }
262
275
 
263
- .noScrollbar::-webkit-scrollbar{
276
+ .noScrollbar::-webkit-scrollbar {
264
277
  display: none;
265
278
  }
266
279
 
package/src/index.js CHANGED
@@ -618,7 +618,7 @@ export default{
618
618
  app.component('Header1', defineAsyncComponent(() => import("./widgets/Header1.vue")))
619
619
  app.component('Header2', defineAsyncComponent(() => import("./widgets/Header2.vue")))
620
620
  app.component('HeaderSetting', defineAsyncComponent(() => import("./widgets/HeaderSetting.vue")))
621
- app.component('Header1Setting', defineAsyncComponent(() => import("./widgets/Header1Setting.vue")))
621
+ //app.component('Header1Setting', defineAsyncComponent(() => import("./widgets/Header1Setting.vue")))
622
622
  app.component('Header2Setting', defineAsyncComponent(() => import("./widgets/Header2Setting.vue")))
623
623
  app.component('IconList', defineAsyncComponent(() => import("./widgets/IconList.vue")))
624
624
  app.component('IconListSetting', defineAsyncComponent(() => import("./widgets/IconListSetting.vue")))
@@ -525,11 +525,22 @@ const dayTimeRange = (params, value) => {
525
525
  }
526
526
 
527
527
  function capitalize(str) {
528
- return (str ?? '')
529
- .toString()
530
- .split(' ')
531
- .map(_ => _.charAt(0).toUpperCase() + _.slice(1).toLowerCase())
532
- .join(' ')
528
+ return (str ?? '').toLowerCase().replace(/\b\w/g, function(char) {
529
+ return char.toUpperCase();
530
+ });
531
+ }
532
+
533
+ const removeUnderscoredKey = (obj) => {
534
+ if(typeof obj === 'object' && obj !== null){
535
+ for(let key in obj){
536
+ if(key.startsWith('_')){
537
+ delete obj[key]
538
+ }
539
+ else if(Array.isArray(obj[key])){
540
+ obj[key].forEach(_ => removeUnderscoredKey(_))
541
+ }
542
+ }
543
+ }
533
544
  }
534
545
 
535
546
  module.exports = {
@@ -561,4 +572,5 @@ module.exports = {
561
572
  datasourceGet,
562
573
  datasourceLoad,
563
574
  dayTimeRange,
575
+ removeUnderscoredKey
564
576
  }
@@ -361,7 +361,7 @@ function applyDatasourceReplacer(value, datasource){
361
361
  }
362
362
 
363
363
  function capitalize(str) {
364
- return str.replace(/\b\w/g, function(char) {
364
+ return (str ?? '').toLowerCase().replace(/\b\w/g, function(char) {
365
365
  return char.toUpperCase();
366
366
  });
367
367
  }
@@ -24,13 +24,34 @@ const sortsFn = function(a, b, sorts, index){
24
24
  const pickColumns = function(columns, keys){
25
25
  if(!Array.isArray(columns)) return []
26
26
 
27
- const picked = JSON.parse(JSON.stringify(columns))
27
+ columns = JSON.parse(JSON.stringify(columns))
28
28
 
29
- for(let idx in picked){
30
- picked[idx].visible = keys.includes(picked[idx].key)
29
+ columns = columns.reduce((cur, obj) => {
30
+ cur[obj.key] = obj
31
+ return cur
32
+ }, {})
33
+
34
+ const res = []
35
+
36
+ for(let key of keys){
37
+ if(typeof key === 'string'){
38
+ if(columns[key]){
39
+ columns[key].visible = true
40
+ res.push(columns[key])
41
+ delete columns[key]
42
+ }
43
+ }
44
+ else if(typeof key === 'object' && key !== null && key.key){
45
+ if(columns[key.key]){
46
+ res.push(Object.assign(columns[key.key], key, { visible:true }))
47
+ delete columns[key.key]
48
+ }
49
+ }
31
50
  }
32
51
 
33
- return picked
52
+ res.push(...Object.values(columns))
53
+
54
+ return res
34
55
  }
35
56
 
36
57
  const setupConfig = (config) => {
@@ -73,6 +73,11 @@
73
73
  </VirtualGrid>
74
74
 
75
75
  </div>
76
+
77
+ <div v-else-if="value.tabIndex === 3" class="flex-1 flex flex-col gap-5 p-6">
78
+
79
+ </div>
80
+
76
81
  </div>
77
82
 
78
83
  </div>
@@ -119,6 +124,9 @@ export default{
119
124
  return [
120
125
  { text:'General', value:1 },
121
126
  this.value.props.datasourceUid ? { text:'Columns', value:2 } : null,
127
+ this.value.props.datasourceUid ? { text:'Filters', value:3 } : null,
128
+ this.value.props.datasourceUid ? { text:'Sorts', value:4 } : null,
129
+ this.value.props.datasourceUid ? { text:'Pivot', value:5 } : null,
122
130
  ]
123
131
  .filter(_ => _)
124
132
  },
@@ -53,7 +53,7 @@
53
53
 
54
54
  <div v-if="mode === 'select'" class="flex-1 flex flex-col">
55
55
  <div class="flex flex-col bg-base-300 border-t-[1px] border-b-[1px] border-text-50 divide-y divide-text-50">
56
- <button v-for="(preset, idx) in config.presets" type="button"
56
+ <div v-for="(preset, idx) in config.presets"
57
57
  class="px-6 text-left hover:bg-primary-200 hover:text-white flex flex-row items-center">
58
58
  <div class="flex-1 py-4" @click="select(idx)">
59
59
  {{ preset.name }}
@@ -64,7 +64,7 @@
64
64
  @click="$refs.contextMenu.open($refs.btn[idx], { idx })">
65
65
  <svg width="16" height="16" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><path d="M64 208c26.5 0 48 21.5 48 48s-21.5 48-48 48-48-21.5-48-48 21.5-48 48-48zM16 104c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48zm0 304c0 26.5 21.5 48 48 48s48-21.5 48-48-21.5-48-48-48-48 21.5-48 48z"/></svg>
66
66
  </button>
67
- </button>
67
+ </div>
68
68
  </div>
69
69
 
70
70
  <ContextMenu ref="contextMenu" position="bottom-right">