@uipath/apollo-wind 2.55.0 → 2.57.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/dist/components/ui/combobox.cjs +33 -15
- package/dist/components/ui/combobox.js +33 -15
- package/dist/components/ui/date-picker.cjs +62 -26
- package/dist/components/ui/date-picker.js +62 -26
- package/dist/components/ui/datetime-picker.cjs +29 -12
- package/dist/components/ui/datetime-picker.js +29 -12
- package/dist/components/ui/dropdown-menu.cjs +12 -8
- package/dist/components/ui/dropdown-menu.js +12 -8
- package/dist/components/ui/field-actions/ai-assist-action.cjs +121 -0
- package/dist/components/ui/field-actions/ai-assist-action.d.ts +21 -0
- package/dist/components/ui/field-actions/ai-assist-action.js +84 -0
- package/dist/components/ui/field-actions/collapse.cjs +44 -0
- package/dist/components/ui/field-actions/collapse.d.ts +6 -0
- package/dist/components/ui/field-actions/collapse.js +4 -0
- package/dist/components/ui/field-actions/index.cjs +46 -0
- package/dist/components/ui/field-actions/index.d.ts +2 -0
- package/dist/components/ui/field-actions/index.js +3 -0
- package/dist/components/ui/field-actions/insert-variable-action.cjs +94 -0
- package/dist/components/ui/field-actions/insert-variable-action.d.ts +22 -0
- package/dist/components/ui/field-actions/insert-variable-action.js +57 -0
- package/dist/components/ui/field-addons/index.cjs +50 -0
- package/dist/components/ui/field-addons/index.d.ts +3 -0
- package/dist/components/ui/field-addons/index.js +4 -0
- package/dist/components/ui/field-addons/value-mode-indicator.cjs +57 -0
- package/dist/components/ui/field-addons/value-mode-indicator.d.ts +13 -0
- package/dist/components/ui/field-addons/value-mode-indicator.js +23 -0
- package/dist/components/ui/field-addons/value-mode-menu.cjs +149 -0
- package/dist/components/ui/field-addons/value-mode-menu.d.ts +69 -0
- package/dist/components/ui/field-addons/value-mode-menu.js +112 -0
- package/dist/components/ui/field-addons/value-mode-strings.cjs +69 -0
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +32 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +29 -0
- package/dist/components/ui/form-field.cjs +42 -5
- package/dist/components/ui/form-field.d.ts +21 -1
- package/dist/components/ui/form-field.js +36 -2
- package/dist/components/ui/index.cjs +156 -126
- package/dist/components/ui/index.d.ts +3 -0
- package/dist/components/ui/index.js +3 -0
- package/dist/components/ui/input-group-context.cjs +91 -0
- package/dist/components/ui/input-group-context.d.ts +69 -0
- package/dist/components/ui/input-group-context.js +42 -0
- package/dist/components/ui/input-group.cjs +303 -56
- package/dist/components/ui/input-group.d.ts +70 -3
- package/dist/components/ui/input-group.js +285 -56
- package/dist/components/ui/input.cjs +28 -17
- package/dist/components/ui/input.js +28 -17
- package/dist/components/ui/lockable-value-field/components/field-header.cjs +16 -114
- package/dist/components/ui/lockable-value-field/components/field-header.js +14 -112
- package/dist/components/ui/lockable-value-field/lockable-value-field.cjs +4 -12
- package/dist/components/ui/lockable-value-field/lockable-value-field.js +4 -12
- package/dist/components/ui/model-picker/ModelPicker.cjs +495 -0
- package/dist/components/ui/model-picker/ModelPicker.d.ts +304 -0
- package/dist/components/ui/model-picker/ModelPicker.js +451 -0
- package/dist/components/ui/model-picker/ModelTagChip.cjs +101 -0
- package/dist/components/ui/model-picker/ModelTagChip.d.ts +29 -0
- package/dist/components/ui/model-picker/ModelTagChip.js +67 -0
- package/dist/components/ui/model-picker/badges.cjs +52 -0
- package/dist/components/ui/model-picker/badges.d.ts +41 -0
- package/dist/components/ui/model-picker/badges.js +18 -0
- package/dist/components/ui/model-picker/index.cjs +117 -0
- package/dist/components/ui/model-picker/index.d.ts +27 -0
- package/dist/components/ui/model-picker/index.js +14 -0
- package/dist/components/ui/model-picker/labels.cjs +107 -0
- package/dist/components/ui/model-picker/labels.d.ts +81 -0
- package/dist/components/ui/model-picker/labels.js +67 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.cjs +108 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.d.ts +38 -0
- package/dist/components/ui/model-picker/primitives/FolderSwitcher.js +74 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.cjs +84 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.d.ts +64 -0
- package/dist/components/ui/model-picker/primitives/GroupHeader.js +50 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.cjs +178 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.d.ts +95 -0
- package/dist/components/ui/model-picker/primitives/ModelOptionRow.js +135 -0
- package/dist/components/ui/model-picker/primitives/OptionList.cjs +295 -0
- package/dist/components/ui/model-picker/primitives/OptionList.d.ts +87 -0
- package/dist/components/ui/model-picker/primitives/OptionList.js +242 -0
- package/dist/components/ui/{lockable-value-field/components/mode-menu-item.cjs → model-picker/primitives/PickerPopup.cjs} +25 -24
- package/dist/components/ui/model-picker/primitives/PickerPopup.d.ts +39 -0
- package/dist/components/ui/model-picker/primitives/PickerPopup.js +30 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.cjs +77 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.d.ts +43 -0
- package/dist/components/ui/model-picker/primitives/PickerSearchInput.js +43 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.cjs +112 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.d.ts +73 -0
- package/dist/components/ui/model-picker/primitives/PickerTrigger.js +78 -0
- package/dist/components/ui/model-picker/types.cjs +18 -0
- package/dist/components/ui/model-picker/types.d.ts +154 -0
- package/dist/components/ui/model-picker/types.js +0 -0
- package/dist/components/ui/model-picker/useModelPickerState.cjs +250 -0
- package/dist/components/ui/model-picker/useModelPickerState.d.ts +135 -0
- package/dist/components/ui/model-picker/useModelPickerState.js +216 -0
- package/dist/components/ui/model-picker/utils.cjs +327 -0
- package/dist/components/ui/model-picker/utils.d.ts +121 -0
- package/dist/components/ui/model-picker/utils.js +272 -0
- package/dist/components/ui/multi-select.cjs +82 -58
- package/dist/components/ui/multi-select.js +84 -60
- package/dist/components/ui/popover.cjs +13 -9
- package/dist/components/ui/popover.js +13 -9
- package/dist/components/ui/select.cjs +89 -27
- package/dist/components/ui/select.d.ts +4 -0
- package/dist/components/ui/select.js +90 -28
- package/dist/components/ui/textarea.cjs +16 -11
- package/dist/components/ui/textarea.js +16 -11
- package/dist/index.cjs +144 -21
- package/dist/index.d.ts +10 -4
- package/dist/index.js +6 -3
- package/dist/styles.css +350 -5
- package/package.json +2 -1
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.d.ts +0 -9
- package/dist/components/ui/lockable-value-field/components/mode-menu-item.js +0 -29
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type ModelBadgeKind } from './badges';
|
|
2
|
+
import type { ModelPickerLabels } from './labels';
|
|
3
|
+
import type { CostTier, DiscoveryModel, ModelGroup, ModelTag } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Context passed to `deriveModelTags`. Carries the `labels` object,
|
|
6
|
+
* region info, test-only Recommended/Preview overrides, and the
|
|
7
|
+
* product's badge hooks.
|
|
8
|
+
*/
|
|
9
|
+
export interface DeriveModelTagsContext {
|
|
10
|
+
/**
|
|
11
|
+
* Strings for the built-in tag labels and tooltips. When omitted they
|
|
12
|
+
* fall back to `DEFAULT_MODEL_PICKER_LABELS` (English) — useful for
|
|
13
|
+
* tests and standalone primitive composition.
|
|
14
|
+
*/
|
|
15
|
+
labels?: ModelPickerLabels;
|
|
16
|
+
/** User's home region — used to flag out-of-region models. */
|
|
17
|
+
homeRegion?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Test/storybook override for the `recommended` signal. In
|
|
20
|
+
* production the signal arrives ON the DTO (`model.isRecommended`),
|
|
21
|
+
* merged into the Discovery response from Model_hub configs in
|
|
22
|
+
* `gitops-centralized-cluster` — products should not set this.
|
|
23
|
+
* When provided (even as an empty array), only listed models get the
|
|
24
|
+
* chip. Entries match `modelId` OR `modelName`, so a list authored
|
|
25
|
+
* from Model Hub config (which carries names) works as-is.
|
|
26
|
+
*/
|
|
27
|
+
recommendedModelIds?: readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* Test/storybook override for the `preview` signal. Production
|
|
30
|
+
* sources it from the DTO's `isPreview`. Matches by `modelId` or
|
|
31
|
+
* `modelName`, same as `recommendedModelIds`.
|
|
32
|
+
*/
|
|
33
|
+
previewModelIds?: readonly string[];
|
|
34
|
+
/**
|
|
35
|
+
* Stamp badges from the Apollo badge pool (see `MODEL_BADGES` in
|
|
36
|
+
* badges.ts). Products return pool kinds per model; the pool owns the
|
|
37
|
+
* label, tooltip, variant, and localization, so the same badge reads
|
|
38
|
+
* identically in every product. Pool badges render after the built-in
|
|
39
|
+
* derived chips (Recommended → Preview → Substituted → Deprecating →
|
|
40
|
+
* Custom → Out-of-region) and before any `customTagsFor` extras.
|
|
41
|
+
* Unknown kinds are ignored.
|
|
42
|
+
*/
|
|
43
|
+
badgesFor?: (model: DiscoveryModel) => readonly ModelBadgeKind[];
|
|
44
|
+
/**
|
|
45
|
+
* Escape hatch: free-form product chips, appended last. Prefer
|
|
46
|
+
* `badgesFor` — anything worth shipping belongs in the shared badge
|
|
47
|
+
* pool so labels and colors stay consistent across products. Use this
|
|
48
|
+
* only for experiments or one-offs pending a pool addition, and
|
|
49
|
+
* register colors for new kinds via `customTagVariants`.
|
|
50
|
+
*/
|
|
51
|
+
customTagsFor?: (model: DiscoveryModel) => readonly ModelTag[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A model is BYO when it is served through a customer-configured
|
|
55
|
+
* connection: flagged by the Discovery subscription type, or by
|
|
56
|
+
* connection metadata (`byomDetails`, host-hydrated
|
|
57
|
+
* `byoConnectionLabel`) for catalogs whose subscription field says
|
|
58
|
+
* otherwise. Drives the BYO section and the chips that only make sense
|
|
59
|
+
* for UiPath-hosted models (Preview, Out-of-region).
|
|
60
|
+
*/
|
|
61
|
+
export declare const isByoModel: (m: DiscoveryModel) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Ready-made `filter` predicate for products that only offer text-generation
|
|
64
|
+
* models: drops embeddings (by API flavor — `OpenAiEmbeddings`,
|
|
65
|
+
* `GeminiEmbeddings`) and realtime (by `modelType`).
|
|
66
|
+
*
|
|
67
|
+
* The picker does NOT apply this itself: which modalities to offer is a
|
|
68
|
+
* per-product decision — an indexing or context-grounding surface picks
|
|
69
|
+
* embeddings from the same catalog. Opt in with
|
|
70
|
+
* `filter={isTextGenerationModel}`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isTextGenerationModel(m: DiscoveryModel): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Resolves the `homeRegion` prop to a Discovery geography code. Accepts a
|
|
75
|
+
* geography code (`'EU'`) or a raw OMS region name (`'UnitedStates'`,
|
|
76
|
+
* case-insensitive, separators ignored) so hosts pass
|
|
77
|
+
* `organization.region` straight through instead of each maintaining a
|
|
78
|
+
* mapping. Unknown values resolve to `undefined` — no out-of-region chips.
|
|
79
|
+
* So does `'GLOBAL'`: it is a model routing target, not a place an org
|
|
80
|
+
* lives, and taking it as one would flag every regional model.
|
|
81
|
+
*/
|
|
82
|
+
export declare function resolveHomeGeography(homeRegion: string | undefined): string | undefined;
|
|
83
|
+
export declare function deriveModelTags(model: DiscoveryModel, context?: DeriveModelTagsContext): ModelTag[];
|
|
84
|
+
export declare function defaultCostTier(model: DiscoveryModel): CostTier | null;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the model identifier the gateway is *actually* routing to,
|
|
87
|
+
* if it differs from the user's stored selection. Used to surface
|
|
88
|
+
* silent substitutions (e.g., a retired model whose traffic is being
|
|
89
|
+
* routed to a replacement via a gateway rule) so the user understands
|
|
90
|
+
* what their workflow is really running against.
|
|
91
|
+
*
|
|
92
|
+
* Falls back through three sources, in order of trust:
|
|
93
|
+
* 1. `deprecationDetails.replacedBy` — the explicit replacement name.
|
|
94
|
+
* Prefer this because it's the friendly identifier the migration
|
|
95
|
+
* rule was authored with.
|
|
96
|
+
* 2. `effectiveModel` from the Discovery DTO — the actual upstream
|
|
97
|
+
* model name being invoked.
|
|
98
|
+
* 3. `routingDetails.model` — the routed model when no other signal
|
|
99
|
+
* is set.
|
|
100
|
+
*
|
|
101
|
+
* Returns null when there's no substitution.
|
|
102
|
+
*/
|
|
103
|
+
export declare function getSubstitutionTarget(model: DiscoveryModel): string | null;
|
|
104
|
+
export type GroupStrategy = 'subscription' | 'vendor' | 'flat';
|
|
105
|
+
/**
|
|
106
|
+
* Optional context for `groupModels` — lets the host override the
|
|
107
|
+
* Recommended/Preview heuristic with Model_hub-sourced lists so that
|
|
108
|
+
* grouping and chip rendering agree, and supply the `labels` object so
|
|
109
|
+
* group labels render in the host's locale.
|
|
110
|
+
*/
|
|
111
|
+
export interface GroupModelsContext {
|
|
112
|
+
recommendedModelIds?: readonly string[];
|
|
113
|
+
previewModelIds?: readonly string[];
|
|
114
|
+
/**
|
|
115
|
+
* Strings for group labels and hints. When omitted they fall back to
|
|
116
|
+
* `DEFAULT_MODEL_PICKER_LABELS` (English).
|
|
117
|
+
*/
|
|
118
|
+
labels?: ModelPickerLabels;
|
|
119
|
+
}
|
|
120
|
+
export declare function groupModels(models: DiscoveryModel[], strategy?: GroupStrategy, context?: GroupModelsContext): ModelGroup[];
|
|
121
|
+
export declare function filterModels(models: DiscoveryModel[], query: string): DiscoveryModel[];
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { MODEL_BADGES } from "./badges.js";
|
|
2
|
+
import { DEFAULT_MODEL_PICKER_LABELS } from "./labels.js";
|
|
3
|
+
const RECOMMENDED_SUBSCRIPTION = 'UiPathOwned';
|
|
4
|
+
const isByoModel = (m)=>'BYOMAdded' === m.modelSubscriptionType || 'BYOMReplacedAlternative' === m.modelSubscriptionType || 'BYOMReplacedLikeForLike' === m.modelSubscriptionType || !!m.byomDetails || !!m.byoConnectionLabel;
|
|
5
|
+
function isTextGenerationModel(m) {
|
|
6
|
+
if ('Realtime' === m.modelType) return false;
|
|
7
|
+
return !(m.apiFlavor ?? '').includes('Embeddings');
|
|
8
|
+
}
|
|
9
|
+
const OMS_REGION_TO_GEOGRAPHY = {
|
|
10
|
+
europe: 'EU',
|
|
11
|
+
unitedstates: 'US',
|
|
12
|
+
japan: 'JA',
|
|
13
|
+
canada: 'CA',
|
|
14
|
+
australia: 'AU',
|
|
15
|
+
india: 'IN',
|
|
16
|
+
unitedkingdom: 'UK',
|
|
17
|
+
singapore: 'SI',
|
|
18
|
+
switzerland: 'CH',
|
|
19
|
+
unitedarabemirates: 'UAE',
|
|
20
|
+
southkorea: 'SK'
|
|
21
|
+
};
|
|
22
|
+
const GEOGRAPHY_CODES = new Set([
|
|
23
|
+
'EU',
|
|
24
|
+
'CA',
|
|
25
|
+
'US',
|
|
26
|
+
'SI',
|
|
27
|
+
'JA',
|
|
28
|
+
'AU',
|
|
29
|
+
'IN',
|
|
30
|
+
'UK',
|
|
31
|
+
'CH',
|
|
32
|
+
'UAE',
|
|
33
|
+
'SK',
|
|
34
|
+
'GLOBAL'
|
|
35
|
+
]);
|
|
36
|
+
function resolveHomeGeography(homeRegion) {
|
|
37
|
+
const raw = homeRegion?.trim();
|
|
38
|
+
if (!raw) return;
|
|
39
|
+
const upper = raw.toUpperCase();
|
|
40
|
+
if ('GLOBAL' === upper) return;
|
|
41
|
+
if (GEOGRAPHY_CODES.has(upper)) return upper;
|
|
42
|
+
return OMS_REGION_TO_GEOGRAPHY[raw.toLowerCase().replace(/[\s_-]/g, '')];
|
|
43
|
+
}
|
|
44
|
+
function listMatchesModel(ids, model) {
|
|
45
|
+
return ids.includes(model.modelId) || ids.includes(model.modelName);
|
|
46
|
+
}
|
|
47
|
+
function deriveModelTags(model, context = {}) {
|
|
48
|
+
const tags = [];
|
|
49
|
+
const labels = context.labels ?? DEFAULT_MODEL_PICKER_LABELS;
|
|
50
|
+
const isByo = isByoModel(model);
|
|
51
|
+
const isRecommended = void 0 !== context.recommendedModelIds ? listMatchesModel(context.recommendedModelIds, model) : model.isRecommended ?? (model.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !model.isPreview && !model.deprecationDetails?.usageEndDate);
|
|
52
|
+
if (isRecommended) tags.push({
|
|
53
|
+
kind: 'recommended',
|
|
54
|
+
label: labels.recommendedTag,
|
|
55
|
+
tooltip: labels.recommendedTagTooltip
|
|
56
|
+
});
|
|
57
|
+
const isPreview = void 0 !== context.previewModelIds ? listMatchesModel(context.previewModelIds, model) : !!model.isPreview;
|
|
58
|
+
if (!isByo && isPreview) tags.push({
|
|
59
|
+
kind: 'preview',
|
|
60
|
+
label: labels.previewTag
|
|
61
|
+
});
|
|
62
|
+
const substitutionTarget = getSubstitutionTarget(model);
|
|
63
|
+
if (substitutionTarget) tags.push({
|
|
64
|
+
kind: 'substituted',
|
|
65
|
+
label: labels.substitutedTag(substitutionTarget),
|
|
66
|
+
tooltip: labels.substitutedTagTooltip(substitutionTarget)
|
|
67
|
+
});
|
|
68
|
+
else if (model.deprecationDetails?.usageEndDate) {
|
|
69
|
+
const date = formatDate(model.deprecationDetails.usageEndDate);
|
|
70
|
+
tags.push({
|
|
71
|
+
kind: 'deprecating',
|
|
72
|
+
label: labels.deprecatingTag(date),
|
|
73
|
+
tooltip: model.deprecationDetails.replacedBy ? labels.deprecatingTagTooltip(model.deprecationDetails.replacedBy) : void 0
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (isByo) tags.push({
|
|
77
|
+
kind: 'custom',
|
|
78
|
+
label: labels.customTag
|
|
79
|
+
});
|
|
80
|
+
if (!isByo) {
|
|
81
|
+
const geo = model.routingDetails?.geography;
|
|
82
|
+
const home = 'GLOBAL' === context.homeRegion ? void 0 : context.homeRegion;
|
|
83
|
+
if (geo && home && 'GLOBAL' !== geo && geo !== home) tags.push({
|
|
84
|
+
kind: 'out-of-region',
|
|
85
|
+
label: labels.outOfRegionTag(geo),
|
|
86
|
+
tooltip: labels.outOfRegionTagTooltip(home)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const poolBadges = context.badgesFor?.(model) ?? (()=>{
|
|
90
|
+
const tier = defaultCostTier(model);
|
|
91
|
+
return tier ? [
|
|
92
|
+
`cost-${tier}`
|
|
93
|
+
] : [];
|
|
94
|
+
})();
|
|
95
|
+
for (const kind of poolBadges){
|
|
96
|
+
const def = MODEL_BADGES[kind];
|
|
97
|
+
if (def) tags.push({
|
|
98
|
+
kind,
|
|
99
|
+
label: labels[def.label],
|
|
100
|
+
tooltip: def.tooltip ? labels[def.tooltip] : void 0,
|
|
101
|
+
variant: def.variant
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (context.customTagsFor) {
|
|
105
|
+
const extra = context.customTagsFor(model);
|
|
106
|
+
if (extra?.length) tags.push(...extra);
|
|
107
|
+
}
|
|
108
|
+
return tags;
|
|
109
|
+
}
|
|
110
|
+
const DEFAULT_BASIC_THRESHOLD = 100;
|
|
111
|
+
const DEFAULT_PREMIUM_THRESHOLD = 500;
|
|
112
|
+
function defaultCostTier(model) {
|
|
113
|
+
const costDetails = model.modelDetails?.costDetails;
|
|
114
|
+
const inputCost = costDetails?.flatCosts?.inputTokenCost ?? costDetails?.tieredCosts?.[0]?.inputTokenCost;
|
|
115
|
+
if (null == inputCost) return null;
|
|
116
|
+
if (inputCost < DEFAULT_BASIC_THRESHOLD) return 'basic';
|
|
117
|
+
if (inputCost < DEFAULT_PREMIUM_THRESHOLD) return 'standard';
|
|
118
|
+
return 'premium';
|
|
119
|
+
}
|
|
120
|
+
function getSubstitutionTarget(model) {
|
|
121
|
+
const effective = model.effectiveModel;
|
|
122
|
+
if (effective && effective !== model.modelName && effective !== model.modelId) return model.deprecationDetails?.replacedBy ?? effective;
|
|
123
|
+
const routed = model.routingDetails?.model;
|
|
124
|
+
if (routed && routed !== model.modelName && routed !== model.modelId) return model.deprecationDetails?.replacedBy ?? routed;
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const VENDOR_LABELS = {
|
|
128
|
+
AnthropicClaude: 'Anthropic',
|
|
129
|
+
OpenAi: 'OpenAI',
|
|
130
|
+
AzureOpenAi: 'Azure OpenAI',
|
|
131
|
+
VertexAi: 'Google Vertex',
|
|
132
|
+
AwsBedrock: 'AWS Bedrock'
|
|
133
|
+
};
|
|
134
|
+
function vendorLabel(vendor) {
|
|
135
|
+
return VENDOR_LABELS[vendor] ?? vendor;
|
|
136
|
+
}
|
|
137
|
+
function formatDate(iso) {
|
|
138
|
+
const date = new Date(iso);
|
|
139
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
140
|
+
const dateOnly = /^\d{4}-\d{2}-\d{2}$/.test(iso);
|
|
141
|
+
return date.toLocaleDateString(void 0, {
|
|
142
|
+
month: 'short',
|
|
143
|
+
year: 'numeric',
|
|
144
|
+
...dateOnly ? {
|
|
145
|
+
timeZone: 'UTC'
|
|
146
|
+
} : {}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function buildSubscriptionMatchers(ctx) {
|
|
150
|
+
const isRecommended = (m)=>void 0 !== ctx.recommendedModelIds ? listMatchesModel(ctx.recommendedModelIds, m) : m.isRecommended ?? (m.modelSubscriptionType === RECOMMENDED_SUBSCRIPTION && !m.isPreview && !m.deprecationDetails?.usageEndDate);
|
|
151
|
+
const isPreview = (m)=>void 0 !== ctx.previewModelIds ? listMatchesModel(ctx.previewModelIds, m) : !!m.isPreview;
|
|
152
|
+
const labels = ctx.labels ?? DEFAULT_MODEL_PICKER_LABELS;
|
|
153
|
+
return [
|
|
154
|
+
{
|
|
155
|
+
key: 'byo',
|
|
156
|
+
label: labels.byoGroup,
|
|
157
|
+
hint: labels.byoGroupHint,
|
|
158
|
+
match: (m)=>isByoModel(m)
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: 'recommended',
|
|
162
|
+
label: labels.recommendedGroup,
|
|
163
|
+
hint: labels.recommendedGroupHint,
|
|
164
|
+
match: (m)=>isRecommended(m) && !m.deprecationDetails?.usageEndDate
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: 'preview',
|
|
168
|
+
label: labels.previewGroup,
|
|
169
|
+
hint: labels.previewGroupHint,
|
|
170
|
+
match: (m)=>isPreview(m) && !isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
key: 'more',
|
|
174
|
+
label: labels.moreGroup,
|
|
175
|
+
hint: labels.moreGroupHint,
|
|
176
|
+
match: (m)=>!isByoModel(m) && !m.deprecationDetails?.usageEndDate
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
key: 'deprecating',
|
|
180
|
+
label: labels.deprecatingGroup,
|
|
181
|
+
hint: labels.deprecatingGroupHint,
|
|
182
|
+
match: (m)=>!!m.deprecationDetails?.usageEndDate
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: 'shared',
|
|
186
|
+
label: labels.otherGroup,
|
|
187
|
+
match: ()=>true
|
|
188
|
+
}
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
function groupModels(models, strategy = "subscription", context = {}) {
|
|
192
|
+
const labels = context.labels ?? DEFAULT_MODEL_PICKER_LABELS;
|
|
193
|
+
if ('flat' === strategy) return [
|
|
194
|
+
{
|
|
195
|
+
key: 'all',
|
|
196
|
+
label: labels.allModelsGroup,
|
|
197
|
+
models
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
if ('vendor' === strategy) {
|
|
201
|
+
const byVendor = new Map();
|
|
202
|
+
const byo = [];
|
|
203
|
+
for (const m of models){
|
|
204
|
+
if (isByoModel(m)) {
|
|
205
|
+
byo.push(m);
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
const k = m.vendor || 'Other';
|
|
209
|
+
if (!byVendor.has(k)) byVendor.set(k, []);
|
|
210
|
+
byVendor.get(k).push(m);
|
|
211
|
+
}
|
|
212
|
+
const groups = [];
|
|
213
|
+
if (byo.length) groups.push({
|
|
214
|
+
key: 'byo',
|
|
215
|
+
label: labels.byoGroup,
|
|
216
|
+
models: byo
|
|
217
|
+
});
|
|
218
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
219
|
+
const ranks = new Map();
|
|
220
|
+
const lifecycleRank = (m)=>{
|
|
221
|
+
let r = ranks.get(m);
|
|
222
|
+
if (void 0 === r) {
|
|
223
|
+
const i = matchers.findIndex((g)=>g.match(m));
|
|
224
|
+
r = -1 === i ? matchers.length : i;
|
|
225
|
+
ranks.set(m, r);
|
|
226
|
+
}
|
|
227
|
+
return r;
|
|
228
|
+
};
|
|
229
|
+
for (const [key, list] of byVendor.entries())groups.push({
|
|
230
|
+
key,
|
|
231
|
+
label: vendorLabel(key),
|
|
232
|
+
models: list.sort((a, b)=>lifecycleRank(a) - lifecycleRank(b))
|
|
233
|
+
});
|
|
234
|
+
return groups;
|
|
235
|
+
}
|
|
236
|
+
const matchers = buildSubscriptionMatchers(context);
|
|
237
|
+
const buckets = {};
|
|
238
|
+
for (const m of models){
|
|
239
|
+
const bucket = matchers.find((g)=>g.match(m));
|
|
240
|
+
if (!bucket) continue;
|
|
241
|
+
const list = buckets[bucket.key] ?? (buckets[bucket.key] = []);
|
|
242
|
+
list.push(m);
|
|
243
|
+
}
|
|
244
|
+
const out = [];
|
|
245
|
+
for (const g of matchers){
|
|
246
|
+
const list = buckets[g.key];
|
|
247
|
+
if (list?.length) out.push({
|
|
248
|
+
key: g.key,
|
|
249
|
+
label: g.label,
|
|
250
|
+
hint: g.hint,
|
|
251
|
+
models: list
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
function filterModels(models, query) {
|
|
257
|
+
const q = query.trim().toLowerCase();
|
|
258
|
+
if (!q) return models;
|
|
259
|
+
return models.filter((m)=>{
|
|
260
|
+
const haystack = [
|
|
261
|
+
m.modelName,
|
|
262
|
+
m.displayName,
|
|
263
|
+
m.modelId,
|
|
264
|
+
m.vendor,
|
|
265
|
+
m.modelFamily,
|
|
266
|
+
m.effectiveModel,
|
|
267
|
+
m.byoConnectionLabel
|
|
268
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
269
|
+
return haystack.includes(q);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
export { defaultCostTier, deriveModelTags, filterModels, getSubstitutionTarget, groupModels, isByoModel, isTextGenerationModel, resolveHomeGeography };
|
|
@@ -33,17 +33,18 @@ const external_badge_cjs_namespaceObject = require("./badge.cjs");
|
|
|
33
33
|
const external_button_cjs_namespaceObject = require("./button.cjs");
|
|
34
34
|
const external_checkbox_cjs_namespaceObject = require("./checkbox.cjs");
|
|
35
35
|
const external_command_cjs_namespaceObject = require("./command.cjs");
|
|
36
|
+
const external_input_group_cjs_namespaceObject = require("./input-group.cjs");
|
|
36
37
|
const external_popover_cjs_namespaceObject = require("./popover.cjs");
|
|
37
38
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
38
39
|
const external_form_field_cjs_namespaceObject = require("./form-field.cjs");
|
|
40
|
+
const external_input_group_context_cjs_namespaceObject = require("./input-group-context.cjs");
|
|
39
41
|
const MultiSelect = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ id, options, selected, onChange, placeholder = 'Select items...', emptyMessage = 'No items found.', className, maxSelected, disabled = false, searchPlaceholder = 'Search...', clearAllText, onBlur, error, errorId, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref)=>{
|
|
40
42
|
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
43
|
+
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
44
|
+
const groupAnchor = group.anchor;
|
|
45
|
+
const grouped = group.inGroup;
|
|
41
46
|
const generatedId = external_react_namespaceObject.useId();
|
|
42
47
|
const validationId = errorId ?? `${id ?? `multi-select-${generatedId.replace(/:/g, '')}`}-error`;
|
|
43
|
-
const describedBy = [
|
|
44
|
-
ariaDescribedBy,
|
|
45
|
-
error ? validationId : void 0
|
|
46
|
-
].filter(Boolean).join(' ');
|
|
47
48
|
const handleUnselect = (value)=>{
|
|
48
49
|
onChange(selected.filter((s)=>s !== value));
|
|
49
50
|
};
|
|
@@ -60,10 +61,74 @@ const MultiSelect = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ i
|
|
|
60
61
|
const handleClearAll = ()=>{
|
|
61
62
|
onChange([]);
|
|
62
63
|
};
|
|
64
|
+
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
65
|
+
error,
|
|
66
|
+
errorId: validationId,
|
|
67
|
+
'aria-invalid': ariaInvalid,
|
|
68
|
+
'aria-describedby': ariaDescribedBy,
|
|
69
|
+
'aria-errormessage': ariaErrorMessage
|
|
70
|
+
});
|
|
71
|
+
const triggerProps = {
|
|
72
|
+
id,
|
|
73
|
+
role: 'combobox',
|
|
74
|
+
'aria-expanded': open,
|
|
75
|
+
...validation.aria,
|
|
76
|
+
'aria-label': id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
77
|
+
disabled: disabled || group.disabled
|
|
78
|
+
};
|
|
79
|
+
const triggerContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
82
|
+
className: (0, index_cjs_namespaceObject.cn)('flex flex-wrap gap-1 flex-1', grouped && 'min-h-6.5 items-center py-0.5 future:min-h-6 future:py-px'),
|
|
83
|
+
children: 0 === selected.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
84
|
+
className: "text-foreground-muted",
|
|
85
|
+
children: placeholder
|
|
86
|
+
}) : selected.map((value)=>{
|
|
87
|
+
const option = options.find((opt)=>opt.value === value);
|
|
88
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_badge_cjs_namespaceObject.Badge, {
|
|
89
|
+
variant: "secondary",
|
|
90
|
+
className: "mr-1 future:bg-surface-raised future:hover:bg-surface-raised",
|
|
91
|
+
onClick: (e)=>{
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
handleUnselect(value);
|
|
94
|
+
},
|
|
95
|
+
children: [
|
|
96
|
+
option?.label,
|
|
97
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
98
|
+
type: "button",
|
|
99
|
+
"aria-label": `Remove ${option?.label}`,
|
|
100
|
+
className: "ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer bg-transparent border-0 p-0 inline-flex items-center",
|
|
101
|
+
onMouseDown: (e)=>{
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
},
|
|
105
|
+
onClick: (e)=>{
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
handleUnselect(value);
|
|
109
|
+
},
|
|
110
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
111
|
+
className: "h-3 w-3 text-muted-foreground hover:text-foreground"
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
}, value);
|
|
116
|
+
})
|
|
117
|
+
}),
|
|
118
|
+
grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
119
|
+
className: "flex h-6.5 shrink-0 items-center self-start future:h-6",
|
|
120
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronsUpDown, {
|
|
121
|
+
className: "h-4 w-4 opacity-50"
|
|
122
|
+
})
|
|
123
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronsUpDown, {
|
|
124
|
+
className: "h-4 w-4 shrink-0 opacity-50"
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
});
|
|
63
128
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
64
129
|
ref: ref,
|
|
65
130
|
"data-slot": "multi-select",
|
|
66
|
-
className: (0, index_cjs_namespaceObject.cn)('relative', className),
|
|
131
|
+
className: (0, index_cjs_namespaceObject.cn)('relative', grouped && 'min-w-0 flex-1', className),
|
|
67
132
|
children: [
|
|
68
133
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.Popover, {
|
|
69
134
|
open: open,
|
|
@@ -74,63 +139,22 @@ const MultiSelect = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ i
|
|
|
74
139
|
children: [
|
|
75
140
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
76
141
|
asChild: true,
|
|
77
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
78
|
-
|
|
142
|
+
children: grouped ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_input_group_cjs_namespaceObject.InputGroupTrigger, {
|
|
143
|
+
...triggerProps,
|
|
144
|
+
className: (0, index_cjs_namespaceObject.cn)('items-start', selected.length > 0 && 'h-auto'),
|
|
145
|
+
children: triggerContent
|
|
146
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
|
|
79
147
|
variant: "outline",
|
|
80
|
-
|
|
81
|
-
"aria-expanded": open,
|
|
82
|
-
"aria-invalid": error ? true : ariaInvalid,
|
|
83
|
-
"aria-describedby": describedBy || void 0,
|
|
84
|
-
"aria-errormessage": error ? validationId : ariaErrorMessage,
|
|
85
|
-
"aria-label": id ? void 0 : selected.length > 0 ? `${selected.length} ${1 === selected.length ? 'item' : 'items'} selected` : placeholder,
|
|
148
|
+
...triggerProps,
|
|
86
149
|
className: (0, index_cjs_namespaceObject.cn)('w-full justify-between future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:hover:bg-surface-hover future:font-normal future:text-foreground future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', selected.length > 0 ? 'h-auto min-h-10' : 'h-10'),
|
|
87
|
-
|
|
88
|
-
children: [
|
|
89
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
90
|
-
className: "flex flex-wrap gap-1 flex-1",
|
|
91
|
-
children: 0 === selected.length ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
92
|
-
className: "text-foreground-muted",
|
|
93
|
-
children: placeholder
|
|
94
|
-
}) : selected.map((value)=>{
|
|
95
|
-
const option = options.find((opt)=>opt.value === value);
|
|
96
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_badge_cjs_namespaceObject.Badge, {
|
|
97
|
-
variant: "secondary",
|
|
98
|
-
className: "mr-1 future:bg-surface-raised future:hover:bg-surface-raised",
|
|
99
|
-
onClick: (e)=>{
|
|
100
|
-
e.stopPropagation();
|
|
101
|
-
handleUnselect(value);
|
|
102
|
-
},
|
|
103
|
-
children: [
|
|
104
|
-
option?.label,
|
|
105
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
106
|
-
type: "button",
|
|
107
|
-
"aria-label": `Remove ${option?.label}`,
|
|
108
|
-
className: "ml-1 rounded-full outline-none ring-offset-background focus:ring-2 focus:ring-ring focus:ring-offset-2 cursor-pointer bg-transparent border-0 p-0 inline-flex items-center",
|
|
109
|
-
onMouseDown: (e)=>{
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
e.stopPropagation();
|
|
112
|
-
},
|
|
113
|
-
onClick: (e)=>{
|
|
114
|
-
e.preventDefault();
|
|
115
|
-
e.stopPropagation();
|
|
116
|
-
handleUnselect(value);
|
|
117
|
-
},
|
|
118
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.X, {
|
|
119
|
-
className: "h-3 w-3 text-muted-foreground hover:text-foreground"
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
]
|
|
123
|
-
}, value);
|
|
124
|
-
})
|
|
125
|
-
}),
|
|
126
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronsUpDown, {
|
|
127
|
-
className: "h-4 w-4 shrink-0 opacity-50"
|
|
128
|
-
})
|
|
129
|
-
]
|
|
150
|
+
children: triggerContent
|
|
130
151
|
})
|
|
131
152
|
}),
|
|
153
|
+
groupAnchor && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverAnchor, {
|
|
154
|
+
virtualRef: groupAnchor
|
|
155
|
+
}),
|
|
132
156
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_popover_cjs_namespaceObject.PopoverContent, {
|
|
133
|
-
className: "w-
|
|
157
|
+
className: "w-(--radix-popover-trigger-width) p-0",
|
|
134
158
|
align: "start",
|
|
135
159
|
children: [
|
|
136
160
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_command_cjs_namespaceObject.Command, {
|
|
@@ -184,7 +208,7 @@ const MultiSelect = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ i
|
|
|
184
208
|
})
|
|
185
209
|
]
|
|
186
210
|
}),
|
|
187
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
211
|
+
validation.ownMessage && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_cjs_namespaceObject.FormFieldError, {
|
|
188
212
|
id: validationId,
|
|
189
213
|
children: error
|
|
190
214
|
})
|