@uipath/apollo-wind 2.54.1 → 2.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.
Files changed (59) hide show
  1. package/dist/components/ui/index.cjs +117 -107
  2. package/dist/components/ui/index.d.ts +1 -0
  3. package/dist/components/ui/index.js +1 -0
  4. package/dist/components/ui/model-picker/ModelPicker.cjs +495 -0
  5. package/dist/components/ui/model-picker/ModelPicker.d.ts +304 -0
  6. package/dist/components/ui/model-picker/ModelPicker.js +451 -0
  7. package/dist/components/ui/model-picker/ModelTagChip.cjs +101 -0
  8. package/dist/components/ui/model-picker/ModelTagChip.d.ts +29 -0
  9. package/dist/components/ui/model-picker/ModelTagChip.js +67 -0
  10. package/dist/components/ui/model-picker/badges.cjs +52 -0
  11. package/dist/components/ui/model-picker/badges.d.ts +41 -0
  12. package/dist/components/ui/model-picker/badges.js +18 -0
  13. package/dist/components/ui/model-picker/index.cjs +117 -0
  14. package/dist/components/ui/model-picker/index.d.ts +27 -0
  15. package/dist/components/ui/model-picker/index.js +14 -0
  16. package/dist/components/ui/model-picker/labels.cjs +107 -0
  17. package/dist/components/ui/model-picker/labels.d.ts +81 -0
  18. package/dist/components/ui/model-picker/labels.js +67 -0
  19. package/dist/components/ui/model-picker/primitives/FolderSwitcher.cjs +108 -0
  20. package/dist/components/ui/model-picker/primitives/FolderSwitcher.d.ts +38 -0
  21. package/dist/components/ui/model-picker/primitives/FolderSwitcher.js +74 -0
  22. package/dist/components/ui/model-picker/primitives/GroupHeader.cjs +84 -0
  23. package/dist/components/ui/model-picker/primitives/GroupHeader.d.ts +64 -0
  24. package/dist/components/ui/model-picker/primitives/GroupHeader.js +50 -0
  25. package/dist/components/ui/model-picker/primitives/ModelOptionRow.cjs +178 -0
  26. package/dist/components/ui/model-picker/primitives/ModelOptionRow.d.ts +95 -0
  27. package/dist/components/ui/model-picker/primitives/ModelOptionRow.js +135 -0
  28. package/dist/components/ui/model-picker/primitives/OptionList.cjs +295 -0
  29. package/dist/components/ui/model-picker/primitives/OptionList.d.ts +87 -0
  30. package/dist/components/ui/model-picker/primitives/OptionList.js +242 -0
  31. package/dist/components/ui/model-picker/primitives/PickerPopup.cjs +64 -0
  32. package/dist/components/ui/model-picker/primitives/PickerPopup.d.ts +39 -0
  33. package/dist/components/ui/model-picker/primitives/PickerPopup.js +30 -0
  34. package/dist/components/ui/model-picker/primitives/PickerSearchInput.cjs +77 -0
  35. package/dist/components/ui/model-picker/primitives/PickerSearchInput.d.ts +43 -0
  36. package/dist/components/ui/model-picker/primitives/PickerSearchInput.js +43 -0
  37. package/dist/components/ui/model-picker/primitives/PickerTrigger.cjs +112 -0
  38. package/dist/components/ui/model-picker/primitives/PickerTrigger.d.ts +73 -0
  39. package/dist/components/ui/model-picker/primitives/PickerTrigger.js +78 -0
  40. package/dist/components/ui/model-picker/types.cjs +18 -0
  41. package/dist/components/ui/model-picker/types.d.ts +154 -0
  42. package/dist/components/ui/model-picker/types.js +0 -0
  43. package/dist/components/ui/model-picker/useModelPickerState.cjs +250 -0
  44. package/dist/components/ui/model-picker/useModelPickerState.d.ts +135 -0
  45. package/dist/components/ui/model-picker/useModelPickerState.js +216 -0
  46. package/dist/components/ui/model-picker/utils.cjs +327 -0
  47. package/dist/components/ui/model-picker/utils.d.ts +121 -0
  48. package/dist/components/ui/model-picker/utils.js +272 -0
  49. package/dist/editor-themes/codemirror.cjs +27 -27
  50. package/dist/editor-themes/codemirror.d.ts +3 -2
  51. package/dist/editor-themes/codemirror.js +27 -27
  52. package/dist/editor-themes/monaco.cjs +157 -91
  53. package/dist/editor-themes/monaco.d.ts +130 -64
  54. package/dist/editor-themes/monaco.js +157 -91
  55. package/dist/index.cjs +83 -10
  56. package/dist/index.d.ts +2 -0
  57. package/dist/index.js +2 -1
  58. package/dist/styles.css +121 -14
  59. package/package.json +2 -1
@@ -0,0 +1,304 @@
1
+ import React from 'react';
2
+ import type { ModelBadgeKind } from './badges';
3
+ import { type ModelPickerLabels } from './labels';
4
+ import { type FolderSwitcherFolder } from './primitives/FolderSwitcher';
5
+ import { type PickerPopupProps } from './primitives/PickerPopup';
6
+ import type { DiscoveryModel, ModelTag } from './types';
7
+ import type { GroupStrategy } from './utils';
8
+ export type ModelPickerVariant = 'searchable' | 'virtualized';
9
+ /**
10
+ * Selection callback. The picker calls `onChange(model)` with the full
11
+ * Discovery DTO — read `model.modelId` for the id.
12
+ */
13
+ export type ModelPickerChangeHandler = (model: DiscoveryModel) => void;
14
+ /**
15
+ * Context handed to footer-type slots (`listFooter`, `popupFooter`).
16
+ * `close()` dismisses the popup — call it before navigating away so
17
+ * the picker doesn't linger over the next screen.
18
+ */
19
+ export interface ModelPickerSlotContext {
20
+ selected: DiscoveryModel | null;
21
+ close: () => void;
22
+ }
23
+ export interface ModelPickerSlots {
24
+ /**
25
+ * Extra content rendered to the right of the model name in the trigger,
26
+ * before the caret. Example: a small "effort" badge.
27
+ */
28
+ triggerExtra?: (model: DiscoveryModel | null) => React.ReactNode;
29
+ /**
30
+ * Rendered above the search input in the popup. Use for a sticky CTA
31
+ * or a banner that spans the full width. Default: nothing.
32
+ *
33
+ * NOTE: for compact inline controls like a folder picker, prefer
34
+ * `searchLeading` — it puts the control on the same row as the search
35
+ * field, sharing chrome instead of stacking a separate banner.
36
+ */
37
+ popupHeader?: () => React.ReactNode;
38
+ /**
39
+ * Rendered to the left of the search field, inline with it. Use for a
40
+ * folder scope picker, a "filter by tag" pill, or any control that
41
+ * scopes the visible options.
42
+ */
43
+ searchLeading?: () => React.ReactNode;
44
+ /**
45
+ * Rendered directly under the option list, flush against the last row
46
+ * but inside the popup's main scroll/content region — *above* any
47
+ * `popupFooter`. Use for inline calls-to-action that should read as
48
+ * part of the list rather than a separate footer band (e.g.,
49
+ * `+ Add custom model` styled like a list row).
50
+ */
51
+ listFooter?: (ctx: ModelPickerSlotContext) => React.ReactNode;
52
+ /**
53
+ * Rendered below the option list in the popup, in its own banded
54
+ * footer with a top border + secondary background. Use for an effort
55
+ * picker, "Show all models" toggle, etc.
56
+ *
57
+ * When `canManageByo` is true and this slot is unset, the picker
58
+ * renders the default "Use custom model" CTA wired to
59
+ * `onUseCustomModel`. Pass a function here to replace the default
60
+ * footer, or `null` to suppress it entirely.
61
+ */
62
+ popupFooter?: null | ((ctx: ModelPickerSlotContext) => React.ReactNode);
63
+ /**
64
+ * Per-row meta column (renders after the model name + chips, before
65
+ * row actions). Use for cost bars, context window indicators, etc.
66
+ */
67
+ optionMeta?: (model: DiscoveryModel) => React.ReactNode;
68
+ /**
69
+ * Per-row right-aligned actions. The default renders edit/delete on BYO
70
+ * rows when `canManageByo` is true and the matching handler is wired.
71
+ * Pass null to suppress.
72
+ */
73
+ optionActions?: (model: DiscoveryModel) => React.ReactNode;
74
+ }
75
+ export interface ModelPickerProps {
76
+ /**
77
+ * The catalog to render, typically the rows the LLM Gateway Discovery API
78
+ * returns. The picker fetches nothing; how the host loads them is its own
79
+ * business.
80
+ */
81
+ models: DiscoveryModel[];
82
+ /** Selected `modelId`, or `null`/`undefined` for no selection. */
83
+ value?: string | null;
84
+ /**
85
+ * Connection id of the selected BYO model. Two BYO configurations can
86
+ * serve the same model name under different connections; `value` alone
87
+ * matches the first, so the wrong row highlights. When provided,
88
+ * selection also requires `byomDetails.integrationServiceConnectionId`
89
+ * to match. Omit for non-BYO selections.
90
+ */
91
+ valueConnectionId?: string | null;
92
+ /**
93
+ * Selection callback — receives the picked `DiscoveryModel`. See
94
+ * `ModelPickerChangeHandler` above for the migration note from the
95
+ * legacy `(modelId, model)` shape.
96
+ */
97
+ onChange?: ModelPickerChangeHandler;
98
+ /**
99
+ * Field label above the trigger. Defaults to a localized "Model".
100
+ *
101
+ * Pass `null` when the host already labels the field — a parameter row, a
102
+ * table cell — and a second label would be duplicate chrome. The visible
103
+ * label is then dropped and the trigger keeps an accessible name from
104
+ * `ariaLabel` (falling back to the default "Model"), so suppressing the
105
+ * label never costs the field its name.
106
+ */
107
+ label?: string | null;
108
+ /**
109
+ * Accessible name for the trigger when `label` is `null`. Ignored when a
110
+ * visible label renders — that label names the field.
111
+ */
112
+ ariaLabel?: string;
113
+ /**
114
+ * Marks the field required: a visual asterisk on the label, plus
115
+ * `aria-required` on the trigger, which is a `combobox` and so announces
116
+ * it. The search field inside the popup carries no `aria-required`.
117
+ */
118
+ required?: boolean;
119
+ /**
120
+ * Trigger text when nothing is selected. Defaults to a localized
121
+ * "Select a model".
122
+ */
123
+ placeholder?: string;
124
+ /** Disables the trigger. */
125
+ disabled?: boolean;
126
+ /** Paints the trigger border error-red and sets `aria-invalid`. */
127
+ invalid?: boolean;
128
+ /**
129
+ * Error message under the trigger (`role="alert"`, associated to the
130
+ * trigger via `aria-describedby`).
131
+ */
132
+ errorText?: string;
133
+ /**
134
+ * Which option-list renderer to use. Default: `searchable`, which
135
+ * renders every row but automatically switches to the virtualized
136
+ * renderer when more than 120 options are visible. Pass
137
+ * `virtualized` to force virtualization regardless of count.
138
+ */
139
+ variant?: ModelPickerVariant;
140
+ /**
141
+ * Grouping strategy. The picker holds this as internal state so the
142
+ * in-popup view toggle (see `allowGroupingChange`) can update it without
143
+ * lifting state to the host; passing a different value later resets the
144
+ * view to it. Default: `subscription`.
145
+ */
146
+ groupBy?: GroupStrategy;
147
+ /**
148
+ * Show the in-popup grouping pill (Category ⇆ Provider) on the
149
+ * toolbar. Default: `true`.
150
+ */
151
+ allowGroupingChange?: boolean;
152
+ /**
153
+ * User's home region — used to flag out-of-region models. Accepts a
154
+ * Discovery geography code (`'EU'`) or the raw OMS organization region
155
+ * exactly as PortalShell serves it (`'UnitedStates'`, `'Japan'`, …);
156
+ * the picker owns the OMS→geography mapping so hosts don't each
157
+ * maintain one. Unknown values disable out-of-region chips.
158
+ */
159
+ homeRegion?: string;
160
+ /**
161
+ * Test/storybook override for the Recommended signal. In production
162
+ * the signal arrives ON the Discovery DTO (`model.isRecommended`) —
163
+ * the backend merges `Model_hub/<product>.yaml` from
164
+ * `gitops-centralized-cluster` into the response, so products do NOT
165
+ * fetch Model_hub or pass this prop. When set (even as an empty
166
+ * array), only listed ids count as Recommended.
167
+ */
168
+ recommendedModelIds?: readonly string[];
169
+ /**
170
+ * Test/storybook override for the Preview signal. Production sources
171
+ * it from the DTO's `isPreview`.
172
+ */
173
+ previewModelIds?: readonly string[];
174
+ /**
175
+ * Per-product filter applied to the catalog *before* grouping and
176
+ * search. The most common per-product control: an FPS team scopes
177
+ * the picker to (e.g.) only models that match a given operation
178
+ * code, or only the ones the current user has access to. Pass a
179
+ * stable reference if `models` is large.
180
+ */
181
+ filter?: (model: DiscoveryModel) => boolean;
182
+ /**
183
+ * Stamp badges from the Apollo badge pool per model (e.g.
184
+ * `['cost-premium']`). The pool (`MODEL_BADGES` in badges.ts) owns
185
+ * labels, tooltips, variants, and localization so the same badge
186
+ * reads identically in every product; new badges are added to the
187
+ * pool by design-system PR, not invented per product. Pool badges
188
+ * render after the built-in derived tags (Recommended, Preview,
189
+ * Custom, Deprecating, Out-of-region, Substituted).
190
+ */
191
+ badgesFor?: (model: DiscoveryModel) => readonly ModelBadgeKind[];
192
+ /**
193
+ * Escape hatch: free-form chips appended after pool badges. Prefer
194
+ * `badgesFor` — use this only for experiments or one-offs pending a
195
+ * badge-pool addition.
196
+ */
197
+ customTagsFor?: (model: DiscoveryModel) => readonly ModelTag[];
198
+ /**
199
+ * Chip variant lookup for *new* tag kinds the host
200
+ * introduces via `customTagsFor`. Built-in kinds keep their existing
201
+ * variant. Pass to color custom tags without forking ModelTagChip,
202
+ * e.g. `customTagVariants={{ multimodal: 'info-mini' }}`.
203
+ */
204
+ customTagVariants?: Record<string, string>;
205
+ /**
206
+ * Whether to show the BYO management affordances (row actions +
207
+ * "Use custom model" footer CTA).
208
+ *
209
+ * Your authorization model decides — the platform's own rule is
210
+ * organization administrator, the same signal the portal uses to gate the
211
+ * AI Trust Layer admin pages, but the picker does not check it. Defaults to
212
+ * false, so the affordances stay hidden until a host opts in.
213
+ *
214
+ * A product that wants different actions can still override via
215
+ * `slots.optionActions`; a different footer can replace the default
216
+ * via `slots.popupFooter` (or `null` to suppress it).
217
+ */
218
+ canManageByo?: boolean;
219
+ /**
220
+ * Activation for the "Use custom model" footer CTA. There is no default
221
+ * destination; the AI Trust Layer add form is the usual one. Without this
222
+ * the CTA still renders, as a disabled hint, so the affordance stays
223
+ * discoverable. The picker closes itself before calling.
224
+ */
225
+ onUseCustomModel?: () => void;
226
+ /**
227
+ * Folders for the toolbar scope switcher, which renders when this is
228
+ * non-empty — typically the user's Orchestrator folders, fetched by the
229
+ * host. Ids are opaque to the picker: it reports the chosen one through
230
+ * `onFolderChange` and the host refetches.
231
+ */
232
+ folders?: readonly FolderSwitcherFolder[];
233
+ /**
234
+ * Selected folder id. `null` means the "All folders" sentinel. Leave
235
+ * undefined to let the picker own the selection (uncontrolled), which
236
+ * is useful when the folder only drives a client-side `filter`.
237
+ */
238
+ folder?: string | null;
239
+ /**
240
+ * Folder change callback. Optional when uncontrolled; required to refetch
241
+ * a folder-scoped catalog, since the picker fetches nothing itself.
242
+ */
243
+ onFolderChange?: (next: string | null) => void;
244
+ /** Label for the "All folders" sentinel. Default: `'All folders'`. */
245
+ allFoldersLabel?: string;
246
+ /** Shows a spinner in the popup while the catalog loads. */
247
+ loading?: boolean;
248
+ /**
249
+ * Catalog fetch error. Renders the message in the popup
250
+ * (`role="alert"`) and paints the trigger invalid.
251
+ */
252
+ error?: Error | null;
253
+ /**
254
+ * Show section header rows (`CUSTOM MODELS (BYO)` / `RECOMMENDED` /
255
+ * `PREVIEW` / `DEPRECATING SOON`) between groups. Default: `true`.
256
+ *
257
+ * Regardless of this setting, models stay ordered by group — BYO
258
+ * first, then Recommended, Preview, More, Deprecating.
259
+ */
260
+ showGroupHeaders?: boolean;
261
+ /**
262
+ * Portal target for the dropdown popup. Hosts that mount the picker inside a
263
+ * shadow root or a webview should pass their root element so the popup
264
+ * resolves the CSS variables scoped to it. Defaults to the nearest
265
+ * `PortalContainerProvider`, then `document.body`.
266
+ *
267
+ * There is deliberately no `disablePortal`: mounting a
268
+ * `PortalContainerProvider` around the host tree solves the same problem
269
+ * for every overlay at once, and is the apollo-wind convention.
270
+ */
271
+ popupContainer?: PickerPopupProps['container'];
272
+ /**
273
+ * Delete request for a BYO row. Rendered only when `canManageByo` is true;
274
+ * omit it and no delete action appears.
275
+ *
276
+ * The picker issues no request of its own. It shows a confirmation dialog
277
+ * naming the configuration, then calls this and awaits it — a rejection
278
+ * surfaces in the picker's own error region rather than going unhandled.
279
+ * **Refreshing `models` afterwards is the host's job**; the deleted row
280
+ * stays on screen until a new list arrives.
281
+ */
282
+ onDeleteModel?: (model: DiscoveryModel) => void | Promise<void>;
283
+ /**
284
+ * Edit activation for a BYO row. Rendered only when `canManageByo` is true.
285
+ * The host decides where it leads; the AI Trust Layer edit page is the
286
+ * usual destination.
287
+ */
288
+ onEditModel?: (model: DiscoveryModel) => void;
289
+ /**
290
+ * Overrides for the strings the picker renders. Anything omitted falls back
291
+ * to `DEFAULT_MODEL_PICKER_LABELS`, so an unlocalized host still shows real
292
+ * English rather than raw keys.
293
+ */
294
+ labels?: Partial<ModelPickerLabels>;
295
+ /** Extensibility slots. See `ModelPickerSlots`. */
296
+ slots?: ModelPickerSlots;
297
+ /** Rendered as `data-testid` on the picker's root element. */
298
+ testId?: string;
299
+ }
300
+ /**
301
+ * The forwarded ref points at the trigger button, so hosts can focus
302
+ * the picker programmatically (e.g. after a validation failure).
303
+ */
304
+ export declare const ModelPicker: React.ForwardRefExoticComponent<ModelPickerProps & React.RefAttributes<HTMLButtonElement>>;