@stonecrop/desktop 0.12.3 → 0.12.5

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/desktop",
3
- "version": "0.12.3",
3
+ "version": "0.12.5",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -32,11 +32,11 @@
32
32
  "**/*.css"
33
33
  ],
34
34
  "dependencies": {
35
- "@stonecrop/schema": "0.12.3",
36
- "@stonecrop/atable": "0.12.3",
37
- "@stonecrop/stonecrop": "0.12.3",
38
- "@stonecrop/themes": "0.12.3",
39
- "@stonecrop/aform": "0.12.3"
35
+ "@stonecrop/aform": "0.12.5",
36
+ "@stonecrop/schema": "0.12.5",
37
+ "@stonecrop/stonecrop": "0.12.5",
38
+ "@stonecrop/atable": "0.12.5",
39
+ "@stonecrop/themes": "0.12.5"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "vue": "^3.5.33"
@@ -32,7 +32,7 @@
32
32
 
33
33
  <script setup lang="ts">
34
34
  import { useStonecrop } from '@stonecrop/stonecrop'
35
- import { AForm, type SchemaTypes } from '@stonecrop/aform'
35
+ import { AForm, type AFormLinkNavigator, type SchemaTypes } from '@stonecrop/aform'
36
36
  import type { ColumnSchema } from '@stonecrop/schema'
37
37
  import { computed, onMounted, provide, ref, unref, watch } from 'vue'
38
38
 
@@ -740,6 +740,34 @@ const desktopMethods = {
740
740
 
741
741
  provide('desktopMethods', desktopMethods)
742
742
 
743
+ // Provide a navigator for AFormLink so the arrow button navigates to the linked record.
744
+ provide('aformLinkNavigator', {
745
+ navigate: (doctype: string, id: string | number) => {
746
+ void doNavigate({ view: 'record', doctype, recordId: String(id) })
747
+ },
748
+ } satisfies AFormLinkNavigator)
749
+
750
+ // Provide a resolver for AFormLink to look up display text by doctype + id.
751
+ // Checks HST first (sync); falls back to an async client fetch if not cached.
752
+ provide('aformLinkResolver', async (doctypeSlug: string, id: string): Promise<string | undefined> => {
753
+ if (!stonecrop.value) return undefined
754
+ try {
755
+ const toDisplayString = (rec: Record<string, unknown> | undefined): string | undefined => {
756
+ if (!rec) return undefined
757
+ const val = rec.name ?? rec.title ?? rec.displayText
758
+ return typeof val === 'string' || typeof val === 'number' ? String(val) : undefined
759
+ }
760
+ const cached = stonecrop.value.getRecordById(doctypeSlug, id)?.get('') as Record<string, unknown> | undefined
761
+ const cachedDisplay = toDisplayString(cached)
762
+ if (cachedDisplay != null) return cachedDisplay
763
+ await stonecrop.value.getRecord(doctypeSlug, id)
764
+ const fetched = stonecrop.value.getRecordById(doctypeSlug, id)?.get('') as Record<string, unknown> | undefined
765
+ return toDisplayString(fetched)
766
+ } catch {
767
+ return undefined
768
+ }
769
+ })
770
+
743
771
  onMounted(() => {
744
772
  // Add keyboard shortcuts
745
773
  const handleKeydown = (event: KeyboardEvent) => {