@aiaiai-pt/design-system 0.55.2 → 0.56.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.
@@ -45,6 +45,7 @@
45
45
  isRelationshipParam,
46
46
  normalizeRelIds,
47
47
  relationshipTypeCode,
48
+ relationshipDisplayName,
48
49
  } from "./action-form-renderer-relationships";
49
50
  // #36/#37 — widget-first dispatch (field summaries carry render intent in
50
51
  // `widget`; derived-action params in `ui_schema.widget`; legacy params fall
@@ -141,6 +142,12 @@
141
142
  * in submit modes. */
142
143
  captcha?: Snippet;
143
144
  submitLabel?: string;
145
+ /** Consumer-provided placeholder builder for relationship pickers.
146
+ * Receives the target type's display name (or type code as fallback);
147
+ * returns the full placeholder string. The consumer owns the translation
148
+ * (e.g. `(name) => t('Search {0}...', name)`); the DS provides the
149
+ * English default. Consistent with the `submitLabel` pattern. */
150
+ searchPlaceholder?: (displayName: string) => string;
144
151
  /** Forwarded VERBATIM to every `geo` parameter's MapPicker (the renderer
145
152
  * stays generic — boundary/overlay semantics live in the consumer):
146
153
  * `boundary` draws the dashed tenant-boundary overlay and arms the
@@ -185,6 +192,7 @@
185
192
  fieldErrors = undefined,
186
193
  captcha = undefined,
187
194
  submitLabel = "Submit",
195
+ searchPlaceholder = (name: string) => name ? `Search ${name}...` : "Search...",
188
196
  boundary = undefined,
189
197
  layers = [],
190
198
  onoutofbounds = undefined,
@@ -907,9 +915,7 @@
907
915
  value: id,
908
916
  label: relLabel(key, id),
909
917
  }))}
910
- placeholder={relationshipTypeCode(parameter)
911
- ? `Search ${relationshipTypeCode(parameter)}...`
912
- : "Search..."}
918
+ placeholder={searchPlaceholder(relationshipDisplayName(parameter))}
913
919
  disabled={!searchEntities || !editable || fieldDisabled}
914
920
  loading={(referenceLoading[key] ?? false) || parameter.loading === true}
915
921
  error={fieldError}
@@ -922,9 +928,7 @@
922
928
  label={String(parameter.label ?? key)}
923
929
  items={relComboItems(parameter)}
924
930
  value={String(values[key] ?? "")}
925
- placeholder={relationshipTypeCode(parameter)
926
- ? `Search ${relationshipTypeCode(parameter)}...`
927
- : "Search..."}
931
+ placeholder={searchPlaceholder(relationshipDisplayName(parameter))}
928
932
  disabled={!searchEntities || !editable || fieldDisabled}
929
933
  loading={(referenceLoading[key] ?? false) || parameter.loading === true}
930
934
  error={fieldError}
@@ -84,6 +84,12 @@ interface Props {
84
84
  * in submit modes. */
85
85
  captcha?: Snippet;
86
86
  submitLabel?: string;
87
+ /** Consumer-provided placeholder builder for relationship pickers.
88
+ * Receives the target type's display name (or type code as fallback);
89
+ * returns the full placeholder string. The consumer owns the translation
90
+ * (e.g. `(name) => t('Search {0}...', name)`); the DS provides the
91
+ * English default. Consistent with the `submitLabel` pattern. */
92
+ searchPlaceholder?: (displayName: string) => string;
87
93
  /** Forwarded VERBATIM to every `geo` parameter's MapPicker (the renderer
88
94
  * stays generic — boundary/overlay semantics live in the consumer):
89
95
  * `boundary` draws the dashed tenant-boundary overlay and arms the
@@ -1,6 +1,11 @@
1
1
  export type RelationshipMeta = {
2
2
  relCode?: string;
3
3
  targetTypeCode: string;
4
+ /** Human display name for the target type (e.g. "Pessoa Vulneravel" instead
5
+ * of "vulnerable_person"). Consumers pass it from the ontology schema; the
6
+ * renderer prefers it for the picker placeholder. Falls back to
7
+ * `targetTypeCode` when absent (backward-compatible). */
8
+ targetDisplayName?: string;
4
9
  cardinality?: string;
5
10
  };
6
11
  type Entity = Record<string, unknown>;
@@ -15,6 +20,11 @@ export declare function isRelationshipParam(parameter: Entity): boolean;
15
20
  export declare function isMultiRelationship(parameter: Entity): boolean;
16
21
  /** The entity type code the picker searches/hydrates against. */
17
22
  export declare function relationshipTypeCode(parameter: Entity): string;
23
+ /** Human display name for the relationship target, for use in the picker
24
+ * placeholder. Prefers `targetDisplayName` from the relationship metadata
25
+ * (populated by the consumer from the ontology schema); falls back to the
26
+ * raw type code so existing consumers without the display name are unchanged. */
27
+ export declare function relationshipDisplayName(parameter: Entity): string;
18
28
  /** Normalize a rel value-bag entry onto the ID-list wire shape. */
19
29
  export declare function normalizeRelIds(value: unknown): string[];
20
30
  export {};
@@ -10,6 +10,11 @@
10
10
  export type RelationshipMeta = {
11
11
  relCode?: string;
12
12
  targetTypeCode: string;
13
+ /** Human display name for the target type (e.g. "Pessoa Vulneravel" instead
14
+ * of "vulnerable_person"). Consumers pass it from the ontology schema; the
15
+ * renderer prefers it for the picker placeholder. Falls back to
16
+ * `targetTypeCode` when absent (backward-compatible). */
17
+ targetDisplayName?: string;
13
18
  cardinality?: string;
14
19
  };
15
20
 
@@ -34,9 +39,14 @@ export function relationshipMeta(parameter: Entity): RelationshipMeta | null {
34
39
  if (!targetTypeCode) return null;
35
40
  const relCode = carrier.relCode ?? carrier.rel_code;
36
41
  const cardinality = carrier.cardinality;
42
+ const targetDisplayName =
43
+ carrier.targetDisplayName ?? carrier.target_display_name;
37
44
  return {
38
45
  relCode: relCode ? String(relCode) : undefined,
39
46
  targetTypeCode,
47
+ ...(targetDisplayName
48
+ ? { targetDisplayName: String(targetDisplayName) }
49
+ : {}),
40
50
  cardinality: cardinality ? String(cardinality) : undefined,
41
51
  };
42
52
  }
@@ -67,6 +77,19 @@ export function relationshipTypeCode(parameter: Entity): string {
67
77
  );
68
78
  }
69
79
 
80
+ /** Human display name for the relationship target, for use in the picker
81
+ * placeholder. Prefers `targetDisplayName` from the relationship metadata
82
+ * (populated by the consumer from the ontology schema); falls back to the
83
+ * raw type code so existing consumers without the display name are unchanged. */
84
+ export function relationshipDisplayName(parameter: Entity): string {
85
+ const meta = relationshipMeta(parameter);
86
+ return (
87
+ meta?.targetDisplayName ??
88
+ meta?.targetTypeCode ??
89
+ String(parameter.object_type ?? "")
90
+ );
91
+ }
92
+
70
93
  /** Normalize a rel value-bag entry onto the ID-list wire shape. */
71
94
  export function normalizeRelIds(value: unknown): string[] {
72
95
  if (Array.isArray(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/design-system",
3
- "version": "0.55.2",
3
+ "version": "0.56.0",
4
4
  "description": "Design system tokens and Svelte components for aiaiai products",
5
5
  "license": "MIT",
6
6
  "type": "module",