@mixd-id/web-scaffold 0.1.230406021 → 0.1.230406025

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.230406021",
4
+ "version": "0.1.230406025",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -25,7 +25,7 @@
25
25
  </Textbox>
26
26
  </div>
27
27
  <div class="hidden md:block">
28
- <slot name="lp-tabspace" :preset="preset"/>
28
+ <slot name="lp-tabspace" :preset="preset" :extra="extra"/>
29
29
  </div>
30
30
  <div :class="$style.optArea">
31
31
  <Dropdown class="w-[150px]" :value="preset.name" mode="custom" position="bottom-right">
@@ -859,6 +859,8 @@ export default{
859
859
  presetTab: 'column'
860
860
  },
861
861
 
862
+ extra: {},
863
+
862
864
  mapApiKey: null,
863
865
 
864
866
  selectedColumn: null,
@@ -936,6 +938,7 @@ export default{
936
938
  this.isLoading = this.isSummaryLoading = false
937
939
 
938
940
  Object.assign(this.configs, data.configs)
941
+ Object.assign(this.extra, data.extra ?? {})
939
942
  this.mapApiKey = data.mapApiKey
940
943
  this.patchPresets()
941
944
  this.$nextTick(() => {
@@ -5,14 +5,7 @@
5
5
  :placeholder="placeholder" :maxlength="maxlength" ref="input" autocomplete="new-password"
6
6
  :value="displayedValue" @input="onInput" :readonly="Boolean(readonly)"
7
7
  @keydown="onKeyDown"/>
8
- <div v-if="!!(errors)">
9
- <svg :class="$style.svg" width="24" height="24" class="fill-red-500" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
10
- <path fill-rule="evenodd" clip-rule="evenodd" d="M12 13.75C12.4142 13.75 12.75 13.4142 12.75 13V8.00001C12.75 7.5858 12.4142 7.25001 12 7.25001C11.5858 7.25001 11.25 7.5858 11.25 8.00001V13C11.25 13.4142 11.5858 13.75 12 13.75Z"/>
11
- <path d="M13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16C11 15.4477 11.4477 15 12 15C12.5523 15 13 15.4477 13 16Z"/>
12
- <path fill-rule="evenodd" clip-rule="evenodd" d="M12 20.5C16.6944 20.5 20.5 16.6944 20.5 12C20.5 7.30558 16.6944 3.5 12 3.5C7.30558 3.5 3.5 7.30558 3.5 12C3.5 16.6944 7.30558 20.5 12 20.5ZM12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"/>
13
- </svg>
14
- </div>
15
- <button class="mr-2" v-if="[ '1', 1, true, 'true' ].includes(clearable) && state >= 1 && modelValue" type="button" @click="$emit('clear')">
8
+ <button class="mr-2" v-if="Boolean(clearable) && !Boolean(readonly) && state >= 1 && modelValue" type="button" @click="$emit('clear')">
16
9
  <svg :class="$style.svg" width="19" height="19" viewBox="0 0 24 24" class="fill-text-200" xmlns="http://www.w3.org/2000/svg">
17
10
  <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"/>
18
11
  </svg>
@@ -35,8 +28,6 @@ export default{
35
28
 
36
29
  clearable: [ Boolean, String, Number ],
37
30
 
38
- customClass: String,
39
-
40
31
  state: {
41
32
  type: Number,
42
33
  default: 1 // 1:normal, -1:disabled, -2:error
@@ -52,11 +43,6 @@ export default{
52
43
  default: ''
53
44
  },
54
45
 
55
- errors:{
56
- type: [ String, Array ],
57
- default: ''
58
- },
59
-
60
46
  modelValue: [ String, Number ],
61
47
 
62
48
  value: String,
@@ -68,28 +54,14 @@ export default{
68
54
 
69
55
  },
70
56
 
71
- watch:{
72
-
73
- modelValue(to, from){
74
- this.$emit('update:modelValue', to)
75
- this.$emit('change', to)
76
- }
77
-
78
- },
79
-
80
57
  computed: {
81
58
 
82
59
  computedState(){
83
- if(this.errors){
84
- return -2
85
- }
86
- else{
87
- return this.state
88
- }
60
+ return this.state
89
61
  },
90
62
 
91
63
  computedClass(){
92
- return this.customClass ?? [
64
+ return [
93
65
  this.$style.textbox,
94
66
  this.$style['state-' + this.computedState],
95
67
  this.isActive && !this.readonly ? this.$style.active : '',
@@ -134,10 +106,6 @@ export default{
134
106
 
135
107
  },
136
108
 
137
- mounted() {
138
- this.$refs.input.addEventListener('keyup', this.onKeyUp)
139
- },
140
-
141
109
  data(){
142
110
  return {
143
111
  isActive: false
@@ -150,30 +118,21 @@ export default{
150
118
  this.$refs.input.select()
151
119
  },
152
120
 
153
- onKeyUp(e){
154
- if(e.keyCode === 13){
155
- this.$emit('submit')
156
- }
157
- else if(e.keyCode === 27 && this.clearable){
158
- this.$emit('clear')
159
- }
160
- },
161
-
162
121
  onInput(e){
163
122
  this.$emit('update:modelValue', e.target.value)
164
- this.$emit('change', e.target.value)
165
123
  },
166
124
 
167
125
  onBlur(e){
168
126
  this.isActive = false
169
- this.$emit('blur', e.target.value)
127
+ this.$emit('blur', e)
170
128
  },
171
129
 
172
130
  onKeyDown(e){
173
131
  if([ 'number', 'tel' ].includes(this.type)){
174
132
  if(((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105) ||
175
- [ 8, 13 ].includes(e.keyCode)) && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey);
133
+ [ 8, 9, 13, 27, 37, 38, 39, 40, 46 ].includes(e.keyCode)) && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey);
176
134
  else if(e.keyCode === 65 && (e.ctrlKey || e.metaKey));
135
+ else if(e.keyCode === 82 && (e.ctrlKey || e.metaKey));
177
136
  else{
178
137
  e.preventDefault()
179
138
  }
@@ -73,6 +73,7 @@
73
73
 
74
74
  import throttle from "lodash/throttle";
75
75
  import dayjs from "dayjs";
76
+ import {accessNestedObject} from "../utils/helpers.mjs";
76
77
 
77
78
  const _DEFAULT_COLUMN_WIDTH = '100px'
78
79
 
@@ -322,16 +323,7 @@ export default{
322
323
 
323
324
  let value
324
325
  if((column.key ?? '').toString().indexOf('.') > -1){
325
- const columnKeys = column.key.split('.')
326
- const columnAs = columnKeys[0]
327
- const columnKey = columnKeys[1]
328
-
329
- let columnValue = [];
330
- (item[columnAs] ?? []).forEach((item) => {
331
- columnValue.push(item[columnKey])
332
- })
333
-
334
- value = columnValue.join(',')
326
+ value = accessNestedObject(item, column.key)
335
327
  }
336
328
  else{
337
329
  value = item[column.key ?? ''] ?? ''
@@ -125,6 +125,22 @@ const uid = function(prefix){
125
125
  return (prefix ?? '') + __uid++;
126
126
  }
127
127
 
128
+ const accessNestedObject = function(obj, path) {
129
+ const keys = path.split('.');
130
+ let nestedObj = obj;
131
+
132
+ for (let key of keys) {
133
+ if (nestedObj.hasOwnProperty(key)) {
134
+ nestedObj = nestedObj[key];
135
+ } else {
136
+ // Return undefined if any key in the path is missing
137
+ return undefined;
138
+ }
139
+ }
140
+
141
+ return nestedObj;
142
+ }
143
+
128
144
  export {
129
145
  downsizeImage,
130
146
  uid,
@@ -132,7 +148,8 @@ export {
132
148
  csvToArray,
133
149
  parseBoolean,
134
150
  urlQuery,
135
- getQueryString
151
+ getQueryString,
152
+ accessNestedObject
136
153
  }
137
154
 
138
155
  function observeInit(){
@@ -78,10 +78,13 @@ let ListPage1 = {
78
78
 
79
79
  const mapApiKey = this.getMapApiKey ? this.getMapApiKey() : undefined
80
80
 
81
+ let extra = this.patchExtra ? await this.patchExtra() : {}
82
+
81
83
  return {
82
84
  configs: currentPreset,
83
85
  mapApiKey,
84
- ...data
86
+ ...data,
87
+ extra
85
88
  }
86
89
  },
87
90
 
@@ -449,7 +452,7 @@ let ListPage1 = {
449
452
 
450
453
  let includes
451
454
  if(this.getModelIncludes){
452
- includes = this.getModelIncludes(preset)
455
+ includes = await this.getModelIncludes(preset)
453
456
  }
454
457
 
455
458
  let attributes = { id:1, updatedAt:1 }
@@ -475,6 +478,12 @@ let ListPage1 = {
475
478
  }
476
479
  })
477
480
  }
481
+ if(typeof this.extraAttributes === 'function'){
482
+ attributes = {
483
+ ...attributes,
484
+ ...((await this.extraAttributes(preset)) ?? {})
485
+ }
486
+ }
478
487
  attributes = Object.keys(attributes)
479
488
 
480
489
  if(preset.filters){