@globalbrain/sefirot 3.28.1 → 3.29.0

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.
@@ -1,5 +1,6 @@
1
- import { type Ref, ref } from 'vue'
1
+ import { type Ref, type WatchSource, ref, watch } from 'vue'
2
2
  import { Http } from '../http/Http'
3
+ import { tryOnMounted } from './Utils'
3
4
 
4
5
  export interface Query<Data = any> {
5
6
  loading: Ref<boolean>
@@ -13,6 +14,10 @@ export interface UseQueryOptions {
13
14
  * @default true
14
15
  */
15
16
  immediate?: boolean
17
+ /**
18
+ * watch the given source(s) and re-execute the query
19
+ */
20
+ watch?: WatchSource | WatchSource[]
16
21
  }
17
22
 
18
23
  export interface Mutation<Data = any, Args extends any[] = any[]> {
@@ -30,8 +35,12 @@ export function useQuery<Data = any>(
30
35
  const loading = ref(false)
31
36
  const data = ref<Data | undefined>()
32
37
 
33
- if (options.immediate !== false && !import.meta.env.SSR) {
34
- execute()
38
+ if (options.immediate !== false) {
39
+ tryOnMounted(execute)
40
+ }
41
+
42
+ if (options.watch) {
43
+ watch(options.watch, execute, { deep: true })
35
44
  }
36
45
 
37
46
  async function execute(): Promise<Data> {
@@ -1,4 +1,4 @@
1
- import { type ComputedRef, type MaybeRefOrGetter, computed, toValue, useSlots } from 'vue'
1
+ import { type ComputedRef, type MaybeRefOrGetter, computed, getCurrentInstance, onMounted, toValue, useSlots } from 'vue'
2
2
  import { isArray, isString } from '../support/Utils'
3
3
 
4
4
  export type WhenCondition<T> = MaybeRefOrGetter<T>
@@ -61,3 +61,11 @@ export function useSlotValue(name = 'default'): ComputedRef<string | null> {
61
61
  return v !== '' ? v : null
62
62
  })
63
63
  }
64
+
65
+ export function tryOnMounted(fn: () => void): void {
66
+ if (getCurrentInstance()) {
67
+ onMounted(fn)
68
+ } else if (!import.meta.env.SSR) {
69
+ fn()
70
+ }
71
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@globalbrain/sefirot",
3
- "version": "3.28.1",
4
- "packageManager": "pnpm@8.14.3",
3
+ "version": "3.29.0",
4
+ "packageManager": "pnpm@8.15.1",
5
5
  "description": "Vue Components for Global Brain Design System.",
6
6
  "author": "Kia Ishii <ka.ishii@globalbrains.com>",
7
7
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "markdown-it": "^14.0.0",
54
54
  "normalize.css": "^8.0.1",
55
55
  "pinia": "^2.1.7",
56
- "postcss": "^8.4.33",
56
+ "postcss": "^8.4.34",
57
57
  "postcss-nested": "^6.0.1",
58
58
  "v-calendar": "^3.1.2",
59
59
  "vue": "^3.4.15",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "devDependencies": {
74
74
  "@globalbrain/eslint-config": "^1.5.2",
75
- "@histoire/plugin-vue": "^0.17.8",
75
+ "@histoire/plugin-vue": "^0.17.9",
76
76
  "@iconify-icons/ph": "^1.2.5",
77
77
  "@iconify-icons/ri": "^1.2.10",
78
78
  "@iconify/vue": "^4.1.1",
@@ -80,31 +80,31 @@
80
80
  "@types/body-scroll-lock": "^3.1.2",
81
81
  "@types/lodash-es": "^4.17.12",
82
82
  "@types/markdown-it": "^13.0.7",
83
- "@types/node": "^20.11.6",
83
+ "@types/node": "^20.11.16",
84
84
  "@vitejs/plugin-vue": "^5.0.3",
85
- "@vitest/coverage-v8": "^1.2.1",
86
- "@vue/test-utils": "^2.4.3",
85
+ "@vitest/coverage-v8": "^1.2.2",
86
+ "@vue/test-utils": "^2.4.4",
87
87
  "@vuelidate/core": "^2.0.3",
88
88
  "@vuelidate/validators": "^2.0.4",
89
89
  "@vueuse/core": "^10.7.2",
90
90
  "body-scroll-lock": "4.0.0-beta.0",
91
91
  "eslint": "^8.56.0",
92
92
  "fuse.js": "^7.0.0",
93
- "happy-dom": "^13.3.1",
94
- "histoire": "^0.17.8",
93
+ "happy-dom": "^13.3.8",
94
+ "histoire": "^0.17.9",
95
95
  "lodash-es": "^4.17.21",
96
96
  "markdown-it": "^14.0.0",
97
97
  "normalize.css": "^8.0.1",
98
98
  "pinia": "^2.1.7",
99
- "postcss": "^8.4.33",
99
+ "postcss": "^8.4.34",
100
100
  "postcss-nested": "^6.0.1",
101
101
  "punycode": "^2.3.1",
102
102
  "release-it": "^17.0.3",
103
103
  "typescript": "~5.3.3",
104
104
  "v-calendar": "^3.1.2",
105
105
  "vite": "^5.0.12",
106
- "vitepress": "1.0.0-rc.40",
107
- "vitest": "^1.2.1",
106
+ "vitepress": "1.0.0-rc.41",
107
+ "vitest": "^1.2.2",
108
108
  "vue": "^3.4.15",
109
109
  "vue-router": "^4.2.5",
110
110
  "vue-tsc": "^1.8.27"