@ramathibodi/nuxt-commons 0.1.71 → 0.1.72

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.71",
7
+ "version": "0.1.72",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
@@ -0,0 +1,27 @@
1
+ <script lang="ts" setup>
2
+ import Pad from './Pad.vue'
3
+ import { watch } from 'vue'
4
+ import { useGraphQlOperation } from '../../composables/graphqlOperation'
5
+
6
+ interface Props extends /* @vue-ignore */ InstanceType<typeof Pad['$props']> {
7
+ templateId: string;
8
+ cache?: boolean | number
9
+ }
10
+
11
+ const props = withDefaults(defineProps<Props>(),{
12
+ cache: false
13
+ })
14
+
15
+ const currentTemplate = ref<any>({})
16
+
17
+ watch(()=>props.templateId, (newValue) => {
18
+ useGraphQlOperation("Query","systemTemplateById",["template","templateScript"],{id: newValue},props.cache).then(result => {
19
+ currentTemplate.value = result
20
+ }).catch(_error => {
21
+ currentTemplate.value = {}
22
+ })
23
+ })
24
+ </script>
25
+ <template>
26
+ <FormPad v-bind="$attrs" :template="currentTemplate.template" :template-script="currentTemplate.templateScript" />
27
+ </template>
@@ -39,5 +39,9 @@ const computedItemTitle = computed(()=>{
39
39
  :not-found-text="computedNotFoundText"
40
40
  :placeholder="computedPlaceholder"
41
41
  :cache="props.cache"
42
- ></model-label>
42
+ >
43
+ <template v-for="(_, name, index) in ($slots as {})" :key="index" #[name]="slotData">
44
+ <slot :name="name" v-bind="((slotData || {}) as object)" />
45
+ </template>
46
+ </model-label>
43
47
  </template>
@@ -2,6 +2,7 @@
2
2
  import { computedAsync } from '@vueuse/core'
3
3
  import { useGraphQlOperation } from '../../composables/graphqlOperation'
4
4
  import { concat } from "lodash-es";
5
+ import { ref } from 'vue'
5
6
 
6
7
  interface Props {
7
8
  modelName: string
@@ -18,6 +19,8 @@ const props = withDefaults(defineProps<Props>(), {
18
19
  cache: false,
19
20
  })
20
21
 
22
+ const modelItem = ref<Record<string, any>>({})
23
+
21
24
  const modelItemValue = computedAsync<string>(async () => {
22
25
  if (props.modelName && props.itemTitle) {
23
26
  let fields: any[] = (typeof props.itemTitle === "string") ? [props.itemTitle] : []
@@ -28,6 +31,7 @@ const modelItemValue = computedAsync<string>(async () => {
28
31
 
29
32
  try {
30
33
  if (result) {
34
+ modelItem.value = result
31
35
  if (typeof props.itemTitle === "string") return result[props.itemTitle]
32
36
  else return props.itemTitle(result)
33
37
  }
@@ -40,5 +44,7 @@ const modelItemValue = computedAsync<string>(async () => {
40
44
  </script>
41
45
 
42
46
  <template>
43
- <span>{{ modelItemValue }}</span>
47
+ <slot name="default" :data="modelItem">
48
+ <span>{{ modelItemValue }}</span>
49
+ </slot>
44
50
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramathibodi/nuxt-commons",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "description": "Ramathibodi Nuxt modules for common components",
5
5
  "repository": {
6
6
  "type": "git",