@stonecrop/stonecrop 0.4.0 → 0.4.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/stonecrop",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "schema helper",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,9 +52,9 @@
52
52
  "eslint-plugin-vue": "^9.11.1",
53
53
  "typescript": "~5.6.3",
54
54
  "vite": "^5.4.5",
55
- "@stonecrop/aform": "0.4.0",
56
- "@stonecrop/atable": "0.4.0",
57
- "stonecrop-rig": "0.2.22"
55
+ "@stonecrop/aform": "0.4.1",
56
+ "stonecrop-rig": "0.2.22",
57
+ "@stonecrop/atable": "0.4.1"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
package/src/composable.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { inject, onBeforeMount, Ref, ref } from 'vue'
1
+ import { inject, onMounted, Ref, ref } from 'vue'
2
2
 
3
3
  import Registry from './registry'
4
4
  import { Stonecrop } from './stonecrop'
@@ -9,8 +9,7 @@ import { useDataStore } from './stores/data'
9
9
  * @public
10
10
  */
11
11
  export type StonecropReturn = {
12
- stonecrop: Ref<Stonecrop>
13
- isReady: Ref<boolean>
12
+ stonecrop: Ref<Stonecrop | undefined>
14
13
  }
15
14
 
16
15
  /**
@@ -21,22 +20,23 @@ export type StonecropReturn = {
21
20
  * @public
22
21
  */
23
22
  export function useStonecrop(registry?: Registry): StonecropReturn {
24
- if (!registry) {
25
- registry = inject<Registry>('$registry')
26
- }
23
+ const stonecrop = ref<Stonecrop>()
27
24
 
28
- let store: ReturnType<typeof useDataStore>
29
- try {
30
- store = useDataStore()
31
- } catch (e) {
32
- throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable')
33
- }
25
+ onMounted(async () => {
26
+ if (!registry) {
27
+ registry = inject<Registry>('$registry')
28
+ }
29
+
30
+ let store: ReturnType<typeof useDataStore>
31
+ try {
32
+ store = useDataStore()
33
+ } catch (e) {
34
+ throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable')
35
+ }
34
36
 
35
- // @ts-expect-error TODO: handle empty registry passed to Stonecrop
36
- const stonecrop = ref(new Stonecrop(registry, store))
37
- const isReady = ref(false)
37
+ // @ts-expect-error TODO: handle empty registry passed to Stonecrop
38
+ stonecrop.value = new Stonecrop(registry, store)
38
39
 
39
- onBeforeMount(async () => {
40
40
  if (!registry || !registry.router) return
41
41
 
42
42
  const route = registry.router.currentRoute.value
@@ -64,10 +64,7 @@ export function useStonecrop(registry?: Registry): StonecropReturn {
64
64
 
65
65
  stonecrop.value.runAction(doctype, 'LOAD', recordId ? [recordId] : undefined)
66
66
  }
67
-
68
- isReady.value = true
69
67
  })
70
68
 
71
- // @ts-expect-error TODO: fix the type mismatch
72
- return { stonecrop, isReady }
69
+ return { stonecrop }
73
70
  }