@ramathibodi/nuxt-commons 0.1.33 → 0.1.34

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.1.33",
7
+ "version": "0.1.34",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.3",
10
10
  "unbuild": "2.0.0"
@@ -1,5 +1,4 @@
1
1
  <script lang="ts" setup>
2
- import {ref} from 'vue'
3
2
  import {VTabs} from 'vuetify/components'
4
3
 
5
4
  interface Props extends /* @vue-ignore */ InstanceType<typeof VTabs['$props']> {
@@ -11,7 +10,7 @@ defineOptions({
11
10
  })
12
11
 
13
12
  const props = defineProps<Props>()
14
- const currentTab = ref<string | number>()
13
+ const currentTab = defineModel<string|number>()
15
14
  </script>
16
15
 
17
16
  <template>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import {computed, defineOptions, nextTick, ref, useAttrs, useSlots, watch} from 'vue'
2
+ import {computed, defineExpose, defineOptions, nextTick, ref, useAttrs, useSlots, watch} from 'vue'
3
3
  import {omit} from 'lodash-es'
4
4
  import type {FormDialogCallback} from '../../types/formDialog'
5
5
  import {VDataIterator} from "vuetify/components/VDataIterator";
@@ -20,6 +20,7 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataIterator['$pr
20
20
  importable?: boolean
21
21
  exportable?: boolean
22
22
  insertable?: boolean
23
+ searchable?: boolean
23
24
 
24
25
  viewSwitch?: boolean
25
26
  viewSwitchMultiple?: boolean
@@ -41,6 +42,7 @@ const props = withDefaults(defineProps<Props>(), {
41
42
  importable: true,
42
43
  exportable: true,
43
44
  insertable: true,
45
+ searchable: true,
44
46
 
45
47
  viewSwitch: false,
46
48
  viewSwitchMultiple:false,
@@ -72,6 +74,10 @@ const items = ref<Record<string, any>[]>([])
72
74
  const search = ref<string>()
73
75
  const currentItem = ref<Record<string, any> | undefined>(undefined)
74
76
 
77
+ function setSearch(keyword: string) {
78
+ search.value = keyword
79
+ }
80
+
75
81
  const isDialogOpen = ref<boolean>(false)
76
82
 
77
83
  watch(() => props.modelValue, (newValue) => {
@@ -189,7 +195,9 @@ function openDialog(item?: object) {
189
195
  })
190
196
  }
191
197
 
192
- const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem,moveToItem })
198
+ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem,moveToItem,setSearch })
199
+
200
+ defineExpose({operation})
193
201
  </script>
194
202
 
195
203
  <template>
@@ -278,7 +286,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
278
286
  </VToolbarTitle>
279
287
  </v-col>
280
288
  <v-col cols="5">
281
- <slot name="search">
289
+ <slot name="search" :items="items" :operation="operation" v-if="props.searchable">
282
290
  <VTextField
283
291
  v-model="search"
284
292
  class="justify-end w-100"
@@ -293,7 +301,7 @@ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpIt
293
301
  </v-row>
294
302
 
295
303
  <VToolbarItems>
296
- <slot name="toolbarItems" />
304
+ <slot name="toolbarItems" :items="items" :operation="operation"/>
297
305
  <ImportCSV
298
306
  v-if="props.importable"
299
307
  icon="mdi:mdi-file-upload"
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import {VDataTable} from 'vuetify/components/VDataTable'
3
- import {computed, defineOptions, nextTick, ref, useAttrs, watch} from 'vue'
3
+ import {computed, defineOptions,defineExpose, nextTick, ref, useAttrs, watch} from 'vue'
4
4
  import {omit} from 'lodash-es'
5
5
  import type {FormDialogCallback} from '../../types/formDialog'
6
6
 
@@ -19,6 +19,7 @@ interface Props extends /* @vue-ignore */ InstanceType<typeof VDataTable['$props
19
19
  importable?: boolean
20
20
  exportable?: boolean
21
21
  insertable?: boolean
22
+ searchable?: boolean
22
23
  }
23
24
 
24
25
  const props = withDefaults(defineProps<Props>(), {
@@ -29,6 +30,7 @@ const props = withDefaults(defineProps<Props>(), {
29
30
  importable: true,
30
31
  exportable: true,
31
32
  insertable: true,
33
+ searchable: true,
32
34
  })
33
35
 
34
36
  const emit = defineEmits(['update:modelValue'])
@@ -42,6 +44,10 @@ const items = ref<Record<string, any>[]>([])
42
44
  const search = ref<string>()
43
45
  const currentItem = ref<Record<string, any> | undefined>(undefined)
44
46
 
47
+ function setSearch(keyword: string) {
48
+ search.value = keyword
49
+ }
50
+
45
51
  const isDialogOpen = ref<boolean>(false)
46
52
 
47
53
  watch(() => props.modelValue, (newValue) => {
@@ -153,69 +159,77 @@ function openDialog(item?: object) {
153
159
  })
154
160
  }
155
161
 
156
- const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem,moveToItem })
162
+ const operation = ref({ openDialog, createItem, updateItem, deleteItem, moveUpItem, moveDownItem,moveToItem,setSearch })
163
+
164
+ defineExpose({operation})
157
165
  </script>
158
166
 
159
167
  <template>
160
168
  <v-card>
161
- <VToolbar :color="toolbarColor">
162
- <v-row
163
- justify="end"
164
- class="ma-1"
165
- dense
166
- no-gutters
167
- align="center"
168
- >
169
- <v-col cols="7">
170
- <VToolbarTitle class="pl-3">
171
- <slot name="title">
172
- {{ title }}
173
- </slot>
174
- </VToolbarTitle>
175
- </v-col>
176
- <v-col cols="5">
177
- <slot name="search">
178
- <VTextField
179
- v-model="search"
180
- class="justify-end w-100"
181
- density="compact"
182
- hide-details
183
- placeholder="ค้นหา"
184
- clearable
185
- variant="solo"
186
- />
187
- </slot>
188
- </v-col>
189
- </v-row>
190
-
191
- <VToolbarItems>
192
- <slot name="toolbarItems" />
193
- <ImportCSV
194
- v-if="props.importable"
195
- icon="mdi:mdi-file-upload"
196
- variant="flat"
197
- @import="importItems"
198
- :color="toolbarColor"
199
- />
200
- <ExportCSV
201
- v-if="props.exportable && items.length"
202
- icon="mdi:mdi-file-download"
203
- variant="flat"
204
- :file-name="title"
205
- :model-value="items"
206
- :color="toolbarColor"
207
- />
208
- <VBtn
209
- v-if="props.insertable"
210
- :color="toolbarColor"
211
- prepend-icon="mdi:mdi-plus"
212
- variant="flat"
213
- @click="openDialog()"
169
+ <slot
170
+ name="header"
171
+ :items="items"
172
+ :operation="operation"
173
+ >
174
+ <VToolbar :color="toolbarColor">
175
+ <v-row
176
+ justify="end"
177
+ class="ma-1"
178
+ dense
179
+ no-gutters
180
+ align="center"
214
181
  >
215
- add
216
- </VBtn>
217
- </VToolbarItems>
218
- </VToolbar>
182
+ <v-col cols="7">
183
+ <VToolbarTitle class="pl-3">
184
+ <slot name="title">
185
+ {{ title }}
186
+ </slot>
187
+ </VToolbarTitle>
188
+ </v-col>
189
+ <v-col cols="5">
190
+ <slot name="search" :items="items" :operation="operation" v-if="props.searchable">
191
+ <VTextField
192
+ v-model="search"
193
+ class="justify-end w-100"
194
+ density="compact"
195
+ hide-details
196
+ placeholder="ค้นหา"
197
+ clearable
198
+ variant="solo"
199
+ />
200
+ </slot>
201
+ </v-col>
202
+ </v-row>
203
+
204
+ <VToolbarItems>
205
+ <slot name="toolbarItems" :items="items" :operation="operation"/>
206
+ <ImportCSV
207
+ v-if="props.importable"
208
+ icon="mdi:mdi-file-upload"
209
+ variant="flat"
210
+ @import="importItems"
211
+ :color="toolbarColor"
212
+ />
213
+ <ExportCSV
214
+ v-if="props.exportable && items.length"
215
+ icon="mdi:mdi-file-download"
216
+ variant="flat"
217
+ :file-name="title"
218
+ :model-value="items"
219
+ :color="toolbarColor"
220
+ />
221
+ <VBtn
222
+ v-if="props.insertable"
223
+ :color="toolbarColor"
224
+ prepend-icon="mdi:mdi-plus"
225
+ variant="flat"
226
+ @click="openDialog()"
227
+ >
228
+ add
229
+ </VBtn>
230
+ </VToolbarItems>
231
+ </VToolbar>
232
+ </slot>
219
233
  <v-data-table
220
234
  v-bind="plainAttrs"
221
235
  color="primary"
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed,watch, nextTick, ref, useAttrs } from 'vue'
3
3
  import { VDataTable } from 'vuetify/components/VDataTable'
4
- import { omit } from 'lodash-es'
4
+ import { clone } from 'lodash-es'
5
5
  import type { GraphqlModelProps } from '../../composables/graphqlModel'
6
6
  import { useGraphqlModel } from '../../composables/graphqlModel'
7
7
 
@@ -37,7 +37,7 @@ const props = withDefaults(defineProps<Props & GraphqlModelProps>(), {
37
37
 
38
38
  const attrs = useAttrs()
39
39
  const plainAttrs = computed(() => {
40
- const returnAttrs = omit(attrs, ['modelValue', 'onUpdate:modelValue'])
40
+ const returnAttrs = clone(attrs)
41
41
  if (props.headers) returnAttrs['headers'] = props.headers
42
42
  return returnAttrs
43
43
  })
@@ -68,7 +68,7 @@ watch(()=>props.search,()=>{
68
68
  search.value = props.search
69
69
  },{immediate:true})
70
70
 
71
- defineExpose({ reload })
71
+ defineExpose({ reload,operation })
72
72
  </script>
73
73
 
74
74
  <template>
@@ -102,8 +102,8 @@ defineExpose({ reload })
102
102
  </slot>
103
103
  </VToolbarTitle>
104
104
  </v-col>
105
- <v-col cols="5" v-if="props.searchable">
106
- <slot name="search">
105
+ <v-col cols="5">
106
+ <slot name="search" :items="items" :operation="operation" v-if="props.searchable">
107
107
  <VTextField
108
108
  v-model="search"
109
109
  class="justify-end w-100"
@@ -118,7 +118,7 @@ defineExpose({ reload })
118
118
  </v-row>
119
119
 
120
120
  <VToolbarItems>
121
- <slot name="toolbarItems" />
121
+ <slot name="toolbarItems" :items="items" :operation="operation"/>
122
122
  <ImportCSV
123
123
  v-if="props.importable && canCreate && props.insertable"
124
124
  icon="mdi mdi-file-upload"
@@ -128,7 +128,7 @@ watch(()=>props.search,()=>{
128
128
  search.value = props.search
129
129
  },{immediate:true})
130
130
 
131
- defineExpose({ reload })
131
+ defineExpose({ reload,operation })
132
132
  </script>
133
133
 
134
134
  <template>
@@ -227,8 +227,8 @@ defineExpose({ reload })
227
227
  </slot>
228
228
  </VToolbarTitle>
229
229
  </v-col>
230
- <v-col cols="5" v-if="props.searchable">
231
- <slot name="search">
230
+ <v-col cols="5">
231
+ <slot name="search" :items="items" :operation="operation" v-if="props.searchable">
232
232
  <VTextField
233
233
  v-model="search"
234
234
  class="justify-end w-100"
@@ -243,7 +243,7 @@ defineExpose({ reload })
243
243
  </v-row>
244
244
 
245
245
  <VToolbarItems>
246
- <slot name="toolbarItems" />
246
+ <slot name="toolbarItems" :items="items" :operation="operation"/>
247
247
  <ImportCSV
248
248
  v-if="props.importable && canCreate && props.insertable"
249
249
  icon="mdi mdi-file-upload"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -115,5 +115,5 @@
115
115
  "vitest": "^1.6.0",
116
116
  "vue-tsc": "2.0.29"
117
117
  },
118
- "packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
118
+ "packageManager": "pnpm@9.13.2+sha512.88c9c3864450350e65a33587ab801acf946d7c814ed1134da4a924f6df5a2120fd36b46aab68f7cd1d413149112d53c7db3a4136624cfd00ff1846a0c6cef48a"
119
119
  }