@object-ui/react 11.2.0 → 11.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @object-ui/react
2
2
 
3
+ ## 11.4.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8bf6295]
8
+ - Updated dependencies [1948c5b]
9
+ - Updated dependencies [9cd9be1]
10
+ - Updated dependencies [c38d107]
11
+ - Updated dependencies [790558b]
12
+ - Updated dependencies [c0164ad]
13
+ - @object-ui/types@11.4.0
14
+ - @object-ui/i18n@11.4.0
15
+ - @object-ui/data-objectstack@11.4.0
16
+ - @object-ui/core@11.4.0
17
+
18
+ ## 11.3.0
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [d88c8ec]
23
+ - Updated dependencies [d23d6eb]
24
+ - @object-ui/i18n@11.3.0
25
+ - @object-ui/core@11.3.0
26
+ - @object-ui/data-objectstack@11.3.0
27
+ - @object-ui/types@11.3.0
28
+
3
29
  ## 11.2.0
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,96 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * RelatedRecordActionsContext — host-provided CRUD + action handlers for the
10
+ * child collections ("related lists") rendered on a record DETAIL page.
11
+ *
12
+ * The `record:related_list` renderer (in `@object-ui/plugin-detail`) knows the
13
+ * child object name, the FK back to the parent, and the parent id — but it
14
+ * lives in a low-level package with no access to the console's SPA router, the
15
+ * create/edit form routes, or the per-object CRUD affordances / permissions.
16
+ * Those all live in the app shell.
17
+ *
18
+ * So the host (e.g. `RecordDetailView`) provides this context; the renderer
19
+ * calls {@link RelatedRecordActionsValue.resolve} for its child object and
20
+ * wires whatever handlers come back onto the `RelatedList` (New / Edit / Delete
21
+ * / row-click-to-open, plus the child object's own row actions). A handler that
22
+ * is OMITTED means the capability is unavailable (permission or lifecycle
23
+ * affordance denied, or no host routing) — the related list simply hides that
24
+ * affordance. When no provider is present at all (e.g. the Studio designer, or
25
+ * a standalone embedded renderer) the related list stays read-only, which is
26
+ * the correct graceful fallback.
27
+ */
28
+ import React from 'react';
29
+ /** A child-object action surfaced in a related list's row menu. */
30
+ export interface RelatedRowActionDef {
31
+ /** Stable action name (matches the object's action metadata). */
32
+ name: string;
33
+ /** Display label (already localized by the host). */
34
+ label?: string;
35
+ /** Lucide icon name (kebab-case). */
36
+ icon?: string;
37
+ /** Visual emphasis for the menu item. */
38
+ variant?: 'primary' | 'secondary' | 'danger' | 'ghost' | 'link';
39
+ /** Confirmation prompt shown before the action runs. */
40
+ confirmText?: string;
41
+ /** Any remaining action metadata (target, params, …) is preserved. */
42
+ [k: string]: unknown;
43
+ }
44
+ /**
45
+ * CRUD + action handlers for a single related list's child object, resolved by
46
+ * the host for a specific child object + parent relationship. Every handler is
47
+ * optional: an omitted handler hides its affordance in the list.
48
+ */
49
+ export interface RelatedRecordHandlers {
50
+ /** Open the child record's detail page (查看详情). */
51
+ onView?: (recordId: string | number, record?: unknown) => void;
52
+ /**
53
+ * Open a create form for a new child record. The host pre-links it to the
54
+ * parent (via the relationship field + parent id passed to `resolve`), so no
55
+ * argument is needed here (增).
56
+ */
57
+ onCreate?: () => void;
58
+ /** Open an edit form for an existing child record (改). */
59
+ onEdit?: (recordId: string | number, record?: unknown) => void;
60
+ /**
61
+ * Delete a child record (删). Returns a promise so the list can refresh once
62
+ * the deletion resolves.
63
+ */
64
+ onDelete?: (recordId: string | number, record?: unknown) => void | Promise<void>;
65
+ /** Child object row-level actions (`locations: ['list_item']`), localized. */
66
+ rowActions?: RelatedRowActionDef[];
67
+ /** Execute one of {@link rowActions} against a specific child row. */
68
+ onRowAction?: (action: RelatedRowActionDef, record: unknown) => void | Promise<void>;
69
+ }
70
+ /** Input to {@link RelatedRecordActionsValue.resolve}. */
71
+ export interface ResolveRelatedRecordActionsInput {
72
+ /** Child object machine name (the related list's `api`). */
73
+ objectName: string;
74
+ /** FK field on the child pointing back at the parent record. */
75
+ relationshipField?: string;
76
+ /** Primary-key value of the parent record (used to pre-link new children). */
77
+ parentId?: string | number | null;
78
+ }
79
+ export interface RelatedRecordActionsValue {
80
+ /**
81
+ * Resolve the CRUD + action handlers for a child object. Implementations
82
+ * should be stable (memoized) so consumers can safely depend on the returned
83
+ * identity.
84
+ */
85
+ resolve: (input: ResolveRelatedRecordActionsInput) => RelatedRecordHandlers;
86
+ }
87
+ export declare const RelatedRecordActionsProvider: React.FC<{
88
+ value: RelatedRecordActionsValue;
89
+ children: React.ReactNode;
90
+ }>;
91
+ /**
92
+ * Consume the host-provided related-record actions. Returns `null` when no
93
+ * host wired the provider (embedded / designer contexts) — callers must treat
94
+ * that as "read-only related list".
95
+ */
96
+ export declare function useRelatedRecordActions(): RelatedRecordActionsValue | null;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * ObjectUI
4
+ * Copyright (c) 2024-present ObjectStack Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ /**
10
+ * RelatedRecordActionsContext — host-provided CRUD + action handlers for the
11
+ * child collections ("related lists") rendered on a record DETAIL page.
12
+ *
13
+ * The `record:related_list` renderer (in `@object-ui/plugin-detail`) knows the
14
+ * child object name, the FK back to the parent, and the parent id — but it
15
+ * lives in a low-level package with no access to the console's SPA router, the
16
+ * create/edit form routes, or the per-object CRUD affordances / permissions.
17
+ * Those all live in the app shell.
18
+ *
19
+ * So the host (e.g. `RecordDetailView`) provides this context; the renderer
20
+ * calls {@link RelatedRecordActionsValue.resolve} for its child object and
21
+ * wires whatever handlers come back onto the `RelatedList` (New / Edit / Delete
22
+ * / row-click-to-open, plus the child object's own row actions). A handler that
23
+ * is OMITTED means the capability is unavailable (permission or lifecycle
24
+ * affordance denied, or no host routing) — the related list simply hides that
25
+ * affordance. When no provider is present at all (e.g. the Studio designer, or
26
+ * a standalone embedded renderer) the related list stays read-only, which is
27
+ * the correct graceful fallback.
28
+ */
29
+ import { createContext, useContext } from 'react';
30
+ const RelatedRecordActionsContext = createContext(null);
31
+ export const RelatedRecordActionsProvider = ({ value, children }) => (_jsx(RelatedRecordActionsContext.Provider, { value: value, children: children }));
32
+ /**
33
+ * Consume the host-provided related-record actions. Returns `null` when no
34
+ * host wired the provider (embedded / designer contexts) — callers must treat
35
+ * that as "read-only related list".
36
+ */
37
+ export function useRelatedRecordActions() {
38
+ return useContext(RelatedRecordActionsContext);
39
+ }
@@ -8,3 +8,4 @@ export * from './AppShellContext';
8
8
  export * from './RecordContext';
9
9
  export * from './DiscussionContext';
10
10
  export * from './DrillNavigationContext';
11
+ export * from './RelatedRecordActionsContext';
@@ -8,3 +8,4 @@ export * from './AppShellContext';
8
8
  export * from './RecordContext';
9
9
  export * from './DiscussionContext';
10
10
  export * from './DrillNavigationContext';
11
+ export * from './RelatedRecordActionsContext';
@@ -6,32 +6,12 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  import { useEffect, useMemo, useRef, useState } from 'react';
9
- /**
10
- * Local copy of the display-name resolver used by app-shell. Kept in
11
- * `@object-ui/react` so hooks can derive a record's visible label without
12
- * pulling in the shell. Mirrors `app-shell/src/utils#getRecordDisplayName`;
13
- * the two should stay in sync.
14
- */
15
- function defaultDisplayName(objectDef, record) {
16
- const fmt = objectDef?.titleFormat;
17
- if (fmt && typeof fmt === 'string') {
18
- const rendered = fmt.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (_m, path) => {
19
- const v = path.split('.').reduce((acc, k) => (acc == null ? acc : acc[k]), record);
20
- return v == null ? '' : String(v);
21
- }).trim();
22
- if (rendered.length > 0)
23
- return rendered;
24
- }
25
- return (record?.name ||
26
- record?.full_name ||
27
- record?.fullName ||
28
- record?.title ||
29
- record?.label ||
30
- record?.subject ||
31
- record?.id ||
32
- record?._id ||
33
- 'Untitled');
34
- }
9
+ import { getRecordDisplayName as defaultDisplayName } from '@object-ui/core';
10
+ // ADR-0079: the global-search default display-name resolver is now the ONE
11
+ // shared `getRecordDisplayName` from `@object-ui/core` (honors titleFormat →
12
+ // `displayNameField` → type-aware derivation → `Record #<id>`). Callers can
13
+ // still pass an explicit `getDisplayName` (app-shell's CommandPalette passes
14
+ // the same shared resolver re-exported via `@object-ui/app-shell`).
35
15
  /**
36
16
  * Relevance score for a single record hit against the query. Higher wins.
37
17
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/react",
3
- "version": "11.2.0",
3
+ "version": "11.4.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "React bindings and SchemaRenderer component for Object UI",
@@ -24,12 +24,12 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@objectstack/spec": "^11.0.0",
27
+ "@objectstack/spec": "^11.7.0",
28
28
  "react-hook-form": "^7.80.0",
29
- "@object-ui/core": "11.2.0",
30
- "@object-ui/data-objectstack": "11.2.0",
31
- "@object-ui/i18n": "11.2.0",
32
- "@object-ui/types": "11.2.0"
29
+ "@object-ui/core": "11.4.0",
30
+ "@object-ui/data-objectstack": "11.4.0",
31
+ "@object-ui/i18n": "11.4.0",
32
+ "@object-ui/types": "11.4.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",