@uipath/apollo-wind 2.69.0 → 2.71.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/custom/demo-composer.cjs +80 -0
- package/dist/components/custom/demo-composer.d.ts +11 -0
- package/dist/components/custom/demo-composer.js +46 -0
- package/dist/components/custom/panel-flow.cjs +2 -2
- package/dist/components/custom/panel-flow.js +2 -2
- package/dist/components/forms/field-control.cjs +3 -2
- package/dist/components/forms/field-control.js +3 -2
- package/dist/components/forms/validation-converter.cjs +14 -5
- package/dist/components/forms/validation-converter.js +14 -5
- package/dist/components/ui/chat-composer.cjs +429 -0
- package/dist/components/ui/chat-composer.d.ts +157 -0
- package/dist/components/ui/chat-composer.js +359 -0
- package/dist/components/ui/chat-hero.cjs +244 -0
- package/dist/components/ui/chat-hero.d.ts +51 -0
- package/dist/components/ui/chat-hero.js +189 -0
- package/dist/components/ui/citation.cjs +188 -0
- package/dist/components/ui/citation.d.ts +42 -0
- package/dist/components/ui/citation.js +148 -0
- package/dist/components/ui/date-picker.cjs +6 -5
- package/dist/components/ui/date-picker.js +7 -6
- package/dist/components/ui/datetime-picker.cjs +7 -10
- package/dist/components/ui/datetime-picker.js +8 -11
- package/dist/components/ui/dropzone-overlay.cjs +142 -0
- package/dist/components/ui/dropzone-overlay.d.ts +27 -0
- package/dist/components/ui/dropzone-overlay.js +105 -0
- package/dist/components/ui/file-upload.cjs +5 -29
- package/dist/components/ui/file-upload.js +2 -26
- package/dist/components/ui/file-validation.cjs +91 -0
- package/dist/components/ui/file-validation.d.ts +24 -0
- package/dist/components/ui/file-validation.js +51 -0
- package/dist/components/ui/hover-card.cjs +15 -8
- package/dist/components/ui/hover-card.d.ts +4 -1
- package/dist/components/ui/hover-card.js +16 -9
- package/dist/components/ui/index.cjs +304 -216
- package/dist/components/ui/index.d.ts +8 -0
- package/dist/components/ui/index.js +8 -0
- package/dist/components/ui/input-group.cjs +1 -1
- package/dist/components/ui/input-group.d.ts +2 -1
- package/dist/components/ui/input-group.js +1 -1
- package/dist/components/ui/message-actions.cjs +302 -0
- package/dist/components/ui/message-actions.d.ts +102 -0
- package/dist/components/ui/message-actions.js +241 -0
- package/dist/components/ui/message.cjs +1 -1
- package/dist/components/ui/message.d.ts +2 -0
- package/dist/components/ui/message.js +1 -1
- package/dist/components/ui/prompt-suggestions.cjs +133 -0
- package/dist/components/ui/prompt-suggestions.d.ts +52 -0
- package/dist/components/ui/prompt-suggestions.js +90 -0
- package/dist/components/ui/quick-form-field/components/field-header.cjs +9 -4
- package/dist/components/ui/quick-form-field/components/field-header.d.ts +4 -1
- package/dist/components/ui/quick-form-field/components/field-header.js +9 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.cjs +2 -2
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.d.ts +5 -4
- package/dist/components/ui/quick-form-field/components/lock-toggle-button.js +2 -2
- package/dist/components/ui/quick-form-field/index.d.ts +1 -1
- package/dist/components/ui/quick-form-field/quick-form-field.cjs +158 -222
- package/dist/components/ui/quick-form-field/quick-form-field.d.ts +6 -4
- package/dist/components/ui/quick-form-field/quick-form-field.js +159 -223
- package/dist/components/ui/quick-form-field/types.cjs +2 -2
- package/dist/components/ui/quick-form-field/types.d.ts +39 -32
- package/dist/components/ui/quick-form-field/types.js +2 -2
- package/dist/components/ui/quick-form-field/utils.cjs +5 -59
- package/dist/components/ui/quick-form-field/utils.d.ts +2 -24
- package/dist/components/ui/quick-form-field/utils.js +3 -48
- package/dist/components/ui/sources.cjs +175 -0
- package/dist/components/ui/sources.d.ts +44 -0
- package/dist/components/ui/sources.js +132 -0
- package/dist/index.cjs +156 -7
- package/dist/index.d.ts +17 -1
- package/dist/index.js +9 -1
- package/dist/lib/date-value.cjs +46 -0
- package/dist/lib/date-value.d.ts +8 -0
- package/dist/lib/date-value.js +12 -0
- package/dist/lib/index.cjs +8 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -1
- package/dist/lib/url.cjs +54 -0
- package/dist/lib/url.d.ts +8 -0
- package/dist/lib/url.js +17 -0
- package/dist/styles.css +239 -78
- package/dist/tailwind.utilities.css +15 -0
- package/package.json +1 -1
- package/dist/components/custom/chat-composer.cjs +0 -134
- package/dist/components/custom/chat-composer.d.ts +0 -14
- package/dist/components/custom/chat-composer.js +0 -100
- package/dist/components/custom/chat-first-experience.cjs +0 -87
- package/dist/components/custom/chat-first-experience.d.ts +0 -24
- package/dist/components/custom/chat-first-experience.js +0 -53
- package/dist/components/custom/chat-prompt-suggestions.cjs +0 -49
- package/dist/components/custom/chat-prompt-suggestions.d.ts +0 -18
- package/dist/components/custom/chat-prompt-suggestions.js +0 -15
|
@@ -24,14 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
formatDateTimeValue: ()=>formatDateTimeValue,
|
|
29
|
-
formatDateValue: ()=>formatDateValue,
|
|
30
|
-
getLockedDisplayValue: ()=>getLockedDisplayValue,
|
|
31
|
-
parseDateValue: ()=>parseDateValue,
|
|
27
|
+
toDateOnlyString: ()=>toDateOnlyString,
|
|
32
28
|
parseListValue: ()=>parseListValue,
|
|
33
|
-
|
|
29
|
+
DEFAULT_SELECT_OPTIONS: ()=>DEFAULT_SELECT_OPTIONS,
|
|
30
|
+
formatDateValue: ()=>formatDateValue
|
|
34
31
|
});
|
|
32
|
+
const date_value_cjs_namespaceObject = require("../../../lib/date-value.cjs");
|
|
35
33
|
const DEFAULT_SELECT_OPTIONS = [
|
|
36
34
|
{
|
|
37
35
|
label: 'Option 1',
|
|
@@ -54,17 +52,6 @@ function parseListValue(value) {
|
|
|
54
52
|
return [];
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
|
-
const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
58
|
-
function parseDateValue(value) {
|
|
59
|
-
if (DATE_ONLY_PATTERN.test(value)) {
|
|
60
|
-
const [year, month, day] = value.split('-').map(Number);
|
|
61
|
-
const date = new Date(year, month - 1, day);
|
|
62
|
-
const isValid = !Number.isNaN(date.getTime()) && date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
|
63
|
-
return isValid ? date : void 0;
|
|
64
|
-
}
|
|
65
|
-
const date = new Date(value);
|
|
66
|
-
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
67
|
-
}
|
|
68
55
|
function toDateOnlyString(date) {
|
|
69
56
|
const year = date.getFullYear();
|
|
70
57
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
@@ -72,61 +59,20 @@ function toDateOnlyString(date) {
|
|
|
72
59
|
return `${year}-${month}-${day}`;
|
|
73
60
|
}
|
|
74
61
|
function formatDateValue(value) {
|
|
75
|
-
const date =
|
|
62
|
+
const date = (0, date_value_cjs_namespaceObject.toDateValue)(value);
|
|
76
63
|
return date ? date.toLocaleDateString(void 0, {
|
|
77
64
|
year: 'numeric',
|
|
78
65
|
month: 'long',
|
|
79
66
|
day: 'numeric'
|
|
80
67
|
}) : value;
|
|
81
68
|
}
|
|
82
|
-
function formatDateTimeValue(value) {
|
|
83
|
-
const date = parseDateValue(value);
|
|
84
|
-
return date ? date.toLocaleString(void 0, {
|
|
85
|
-
year: 'numeric',
|
|
86
|
-
month: 'long',
|
|
87
|
-
day: 'numeric',
|
|
88
|
-
hour: 'numeric',
|
|
89
|
-
minute: '2-digit'
|
|
90
|
-
}) : value;
|
|
91
|
-
}
|
|
92
|
-
function getLockedDisplayValue(fieldType, value, options, booleanLabels = {
|
|
93
|
-
trueLabel: 'True',
|
|
94
|
-
falseLabel: 'False'
|
|
95
|
-
}) {
|
|
96
|
-
switch(fieldType){
|
|
97
|
-
case 'boolean':
|
|
98
|
-
if ('true' === value) return booleanLabels.trueLabel;
|
|
99
|
-
if ('false' === value) return booleanLabels.falseLabel;
|
|
100
|
-
return '';
|
|
101
|
-
case 'date':
|
|
102
|
-
return value ? formatDateValue(value) : '';
|
|
103
|
-
case 'datetime':
|
|
104
|
-
return value ? formatDateTimeValue(value) : '';
|
|
105
|
-
case 'single-select':
|
|
106
|
-
return options.find((option)=>option.value === value)?.label ?? value;
|
|
107
|
-
case 'multi-select':
|
|
108
|
-
{
|
|
109
|
-
const parsed = parseListValue(value);
|
|
110
|
-
if (0 === parsed.length && value && '[]' !== value) return value;
|
|
111
|
-
return parsed.map((v)=>options.find((option)=>option.value === v)?.label ?? v).join(', ');
|
|
112
|
-
}
|
|
113
|
-
default:
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
69
|
exports.DEFAULT_SELECT_OPTIONS = __webpack_exports__.DEFAULT_SELECT_OPTIONS;
|
|
118
|
-
exports.formatDateTimeValue = __webpack_exports__.formatDateTimeValue;
|
|
119
70
|
exports.formatDateValue = __webpack_exports__.formatDateValue;
|
|
120
|
-
exports.getLockedDisplayValue = __webpack_exports__.getLockedDisplayValue;
|
|
121
|
-
exports.parseDateValue = __webpack_exports__.parseDateValue;
|
|
122
71
|
exports.parseListValue = __webpack_exports__.parseListValue;
|
|
123
72
|
exports.toDateOnlyString = __webpack_exports__.toDateOnlyString;
|
|
124
73
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
125
74
|
"DEFAULT_SELECT_OPTIONS",
|
|
126
|
-
"formatDateTimeValue",
|
|
127
75
|
"formatDateValue",
|
|
128
|
-
"getLockedDisplayValue",
|
|
129
|
-
"parseDateValue",
|
|
130
76
|
"parseListValue",
|
|
131
77
|
"toDateOnlyString"
|
|
132
78
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -1,29 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { QuickFormFieldOption } from './types';
|
|
2
2
|
export declare const DEFAULT_SELECT_OPTIONS: QuickFormFieldOption[];
|
|
3
3
|
export declare function parseListValue(value: string): string[];
|
|
4
|
-
/**
|
|
5
|
-
* Parses a date field's stored value, returning undefined for empty or invalid input.
|
|
6
|
-
*
|
|
7
|
-
* Date-only strings (`YYYY-MM-DD`) are parsed as a local date instead of going through
|
|
8
|
-
* `new Date(string)` directly -- the latter treats date-only strings as UTC midnight,
|
|
9
|
-
* which rolls over to the previous day once formatted in a negative-UTC-offset
|
|
10
|
-
* timezone. Full ISO timestamps (which already carry explicit time/zone info) go
|
|
11
|
-
* through `new Date` as-is.
|
|
12
|
-
*/
|
|
13
|
-
export declare function parseDateValue(value: string): Date | undefined;
|
|
14
|
-
/** Formats a Date as a local `YYYY-MM-DD` string, the inverse of parseDateValue's date-only path. */
|
|
4
|
+
/** Formats a Date as a local `YYYY-MM-DD` string, which `toDateValue` reads back as a local date. */
|
|
15
5
|
export declare function toDateOnlyString(date: Date): string;
|
|
16
6
|
/** Formats a date field's value for display, falling back to the raw value if it isn't a valid date. */
|
|
17
7
|
export declare function formatDateValue(value: string): string;
|
|
18
|
-
/** Formats a datetime field's value, falling back to the raw value when unparseable. */
|
|
19
|
-
export declare function formatDateTimeValue(value: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Computes the plain-text shown in place of the real control once a field is locked.
|
|
22
|
-
* Boolean/single-select/multi-select resolve their stored value to a display label;
|
|
23
|
-
* everything else (including an invalid date, so the component never throws on
|
|
24
|
-
* external input) falls back to the raw value.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getLockedDisplayValue(fieldType: QuickFieldType, value: string, options: QuickFormFieldOption[], booleanLabels?: {
|
|
27
|
-
trueLabel: string;
|
|
28
|
-
falseLabel: string;
|
|
29
|
-
}): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toDateValue } from "../../../lib/date-value.js";
|
|
1
2
|
const DEFAULT_SELECT_OPTIONS = [
|
|
2
3
|
{
|
|
3
4
|
label: 'Option 1',
|
|
@@ -20,17 +21,6 @@ function parseListValue(value) {
|
|
|
20
21
|
return [];
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
24
|
-
function parseDateValue(value) {
|
|
25
|
-
if (DATE_ONLY_PATTERN.test(value)) {
|
|
26
|
-
const [year, month, day] = value.split('-').map(Number);
|
|
27
|
-
const date = new Date(year, month - 1, day);
|
|
28
|
-
const isValid = !Number.isNaN(date.getTime()) && date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
|
29
|
-
return isValid ? date : void 0;
|
|
30
|
-
}
|
|
31
|
-
const date = new Date(value);
|
|
32
|
-
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
33
|
-
}
|
|
34
24
|
function toDateOnlyString(date) {
|
|
35
25
|
const year = date.getFullYear();
|
|
36
26
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
@@ -38,46 +28,11 @@ function toDateOnlyString(date) {
|
|
|
38
28
|
return `${year}-${month}-${day}`;
|
|
39
29
|
}
|
|
40
30
|
function formatDateValue(value) {
|
|
41
|
-
const date =
|
|
31
|
+
const date = toDateValue(value);
|
|
42
32
|
return date ? date.toLocaleDateString(void 0, {
|
|
43
33
|
year: 'numeric',
|
|
44
34
|
month: 'long',
|
|
45
35
|
day: 'numeric'
|
|
46
36
|
}) : value;
|
|
47
37
|
}
|
|
48
|
-
|
|
49
|
-
const date = parseDateValue(value);
|
|
50
|
-
return date ? date.toLocaleString(void 0, {
|
|
51
|
-
year: 'numeric',
|
|
52
|
-
month: 'long',
|
|
53
|
-
day: 'numeric',
|
|
54
|
-
hour: 'numeric',
|
|
55
|
-
minute: '2-digit'
|
|
56
|
-
}) : value;
|
|
57
|
-
}
|
|
58
|
-
function getLockedDisplayValue(fieldType, value, options, booleanLabels = {
|
|
59
|
-
trueLabel: 'True',
|
|
60
|
-
falseLabel: 'False'
|
|
61
|
-
}) {
|
|
62
|
-
switch(fieldType){
|
|
63
|
-
case 'boolean':
|
|
64
|
-
if ('true' === value) return booleanLabels.trueLabel;
|
|
65
|
-
if ('false' === value) return booleanLabels.falseLabel;
|
|
66
|
-
return '';
|
|
67
|
-
case 'date':
|
|
68
|
-
return value ? formatDateValue(value) : '';
|
|
69
|
-
case 'datetime':
|
|
70
|
-
return value ? formatDateTimeValue(value) : '';
|
|
71
|
-
case 'single-select':
|
|
72
|
-
return options.find((option)=>option.value === value)?.label ?? value;
|
|
73
|
-
case 'multi-select':
|
|
74
|
-
{
|
|
75
|
-
const parsed = parseListValue(value);
|
|
76
|
-
if (0 === parsed.length && value && '[]' !== value) return value;
|
|
77
|
-
return parsed.map((v)=>options.find((option)=>option.value === v)?.label ?? v).join(', ');
|
|
78
|
-
}
|
|
79
|
-
default:
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
export { DEFAULT_SELECT_OPTIONS, formatDateTimeValue, formatDateValue, getLockedDisplayValue, parseDateValue, parseListValue, toDateOnlyString };
|
|
38
|
+
export { DEFAULT_SELECT_OPTIONS, formatDateValue, parseListValue, toDateOnlyString };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
6
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: definition[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.r = (exports1)=>{
|
|
17
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
18
|
+
value: 'Module'
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
21
|
+
value: true
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
var __webpack_exports__ = {};
|
|
26
|
+
__webpack_require__.r(__webpack_exports__);
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
SourcesList: ()=>SourcesList,
|
|
29
|
+
DEFAULT_SOURCES_STRINGS: ()=>DEFAULT_SOURCES_STRINGS,
|
|
30
|
+
SourceItem: ()=>SourceItem,
|
|
31
|
+
Sources: ()=>Sources
|
|
32
|
+
});
|
|
33
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
34
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
35
|
+
const external_react_namespaceObject = require("react");
|
|
36
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
37
|
+
const external_collapsible_cjs_namespaceObject = require("./collapsible.cjs");
|
|
38
|
+
const DEFAULT_SOURCES_STRINGS = {
|
|
39
|
+
sourceCount: (count)=>1 === count ? '1 source' : `${count} sources`,
|
|
40
|
+
opensInNewTab: '(opens in a new tab)'
|
|
41
|
+
};
|
|
42
|
+
const SourcesStringsContext = /*#__PURE__*/ external_react_namespaceObject.createContext(DEFAULT_SOURCES_STRINGS);
|
|
43
|
+
const Sources = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, count, strings, children, ...props }, ref)=>{
|
|
44
|
+
const text = {
|
|
45
|
+
...DEFAULT_SOURCES_STRINGS,
|
|
46
|
+
...strings
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SourcesStringsContext.Provider, {
|
|
49
|
+
value: text,
|
|
50
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_collapsible_cjs_namespaceObject.Collapsible, {
|
|
51
|
+
ref: ref,
|
|
52
|
+
"data-slot": "sources",
|
|
53
|
+
className: (0, index_cjs_namespaceObject.cn)('group/sources flex w-full min-w-0 flex-col gap-2', className),
|
|
54
|
+
...props,
|
|
55
|
+
children: [
|
|
56
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_collapsible_cjs_namespaceObject.CollapsibleTrigger, {
|
|
57
|
+
"data-slot": "sources-trigger",
|
|
58
|
+
className: "inline-flex h-7 w-fit cursor-pointer items-center gap-1.5 rounded-lg border border-border-subtle px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-surface-overlay hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
59
|
+
children: [
|
|
60
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Link2, {
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}),
|
|
63
|
+
text.sourceCount(count),
|
|
64
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ChevronDown, {
|
|
65
|
+
"aria-hidden": "true",
|
|
66
|
+
className: "transition-transform group-data-[state=open]/sources:rotate-180"
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
}),
|
|
70
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_collapsible_cjs_namespaceObject.CollapsibleContent, {
|
|
71
|
+
"data-slot": "sources-content",
|
|
72
|
+
className: "overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",
|
|
73
|
+
children: children
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
Sources.displayName = 'Sources';
|
|
80
|
+
const SourcesList = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("ol", {
|
|
81
|
+
ref: ref,
|
|
82
|
+
"data-slot": "sources-list",
|
|
83
|
+
className: (0, index_cjs_namespaceObject.cn)('flex flex-col gap-0.5 rounded-xl border border-border-subtle bg-card p-1', className),
|
|
84
|
+
...props
|
|
85
|
+
}));
|
|
86
|
+
SourcesList.displayName = 'SourcesList';
|
|
87
|
+
const SourceItem = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, index, title, source, snippet, href, icon, onSelect, onClick, target = '_blank', rel, ...props }, ref)=>{
|
|
88
|
+
const text = external_react_namespaceObject.useContext(SourcesStringsContext);
|
|
89
|
+
const linkHref = (0, index_cjs_namespaceObject.safeHref)(href);
|
|
90
|
+
const handleClick = (event)=>{
|
|
91
|
+
onClick?.(event);
|
|
92
|
+
if (!event.defaultPrevented) onSelect?.({
|
|
93
|
+
index,
|
|
94
|
+
title,
|
|
95
|
+
source,
|
|
96
|
+
snippet,
|
|
97
|
+
href: linkHref
|
|
98
|
+
}, event);
|
|
99
|
+
};
|
|
100
|
+
const itemClassName = (0, index_cjs_namespaceObject.cn)('flex w-full min-w-0 cursor-pointer items-start gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm transition-colors hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', className);
|
|
101
|
+
const newTab = '_blank' === target;
|
|
102
|
+
const body = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
103
|
+
children: [
|
|
104
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
105
|
+
"data-slot": "source-index",
|
|
106
|
+
className: "mt-0.5 flex h-4.5 min-w-4.5 shrink-0 items-center justify-center rounded-full bg-muted px-1 text-[11px] font-medium leading-none text-muted-foreground tabular-nums",
|
|
107
|
+
children: index
|
|
108
|
+
}),
|
|
109
|
+
icon && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
110
|
+
"data-slot": "source-icon",
|
|
111
|
+
className: "mt-0.5 flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_img]:size-4 [&_img]:rounded-sm [&_svg]:size-4",
|
|
112
|
+
children: icon
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
|
|
115
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
118
|
+
"data-slot": "source-title",
|
|
119
|
+
className: "truncate font-medium text-foreground",
|
|
120
|
+
children: title
|
|
121
|
+
}),
|
|
122
|
+
source && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
123
|
+
"data-slot": "source-source",
|
|
124
|
+
className: "truncate text-xs text-muted-foreground",
|
|
125
|
+
children: source
|
|
126
|
+
}),
|
|
127
|
+
snippet && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
128
|
+
"data-slot": "source-snippet",
|
|
129
|
+
className: "line-clamp-2 text-xs leading-relaxed text-muted-foreground",
|
|
130
|
+
children: snippet
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
}),
|
|
134
|
+
linkHref && newTab && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
135
|
+
className: "sr-only",
|
|
136
|
+
children: text.opensInNewTab
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("li", {
|
|
141
|
+
"data-slot": "source-item",
|
|
142
|
+
className: "min-w-0",
|
|
143
|
+
children: linkHref ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
|
|
144
|
+
ref: ref,
|
|
145
|
+
href: linkHref,
|
|
146
|
+
target: target,
|
|
147
|
+
rel: rel ?? (newTab ? 'noopener noreferrer' : void 0),
|
|
148
|
+
className: itemClassName,
|
|
149
|
+
onClick: handleClick,
|
|
150
|
+
...props,
|
|
151
|
+
children: body
|
|
152
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
153
|
+
ref: ref,
|
|
154
|
+
type: "button",
|
|
155
|
+
className: itemClassName,
|
|
156
|
+
onClick: handleClick,
|
|
157
|
+
...props,
|
|
158
|
+
children: body
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
SourceItem.displayName = 'SourceItem';
|
|
163
|
+
exports.DEFAULT_SOURCES_STRINGS = __webpack_exports__.DEFAULT_SOURCES_STRINGS;
|
|
164
|
+
exports.SourceItem = __webpack_exports__.SourceItem;
|
|
165
|
+
exports.Sources = __webpack_exports__.Sources;
|
|
166
|
+
exports.SourcesList = __webpack_exports__.SourcesList;
|
|
167
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
168
|
+
"DEFAULT_SOURCES_STRINGS",
|
|
169
|
+
"SourceItem",
|
|
170
|
+
"Sources",
|
|
171
|
+
"SourcesList"
|
|
172
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
173
|
+
Object.defineProperty(exports, '__esModule', {
|
|
174
|
+
value: true
|
|
175
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Collapsible } from './collapsible';
|
|
3
|
+
/**
|
|
4
|
+
* The list of sources behind an assistant answer, collapsed behind a count. `Sources` owns the
|
|
5
|
+
* trigger; put a `SourcesList` of `SourceItem`s inside. Items do not navigate on their own unless
|
|
6
|
+
* given `href`; `onSelect` receives the item and the event, so a host can run its `citation-click`
|
|
7
|
+
* pre-hook and call `event.preventDefault()` to stop a link. The payload drops an `href` that is
|
|
8
|
+
* not http(s), mailto, tel or relative, so it is safe to open.
|
|
9
|
+
*/
|
|
10
|
+
export interface SourcesStrings {
|
|
11
|
+
/** Trigger text. A function so a host can apply its own plural rules. */
|
|
12
|
+
sourceCount: (count: number) => string;
|
|
13
|
+
/** Screen reader hint on links that open a new tab. */
|
|
14
|
+
opensInNewTab: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_SOURCES_STRINGS: SourcesStrings;
|
|
17
|
+
export interface SourcesProps extends React.ComponentPropsWithoutRef<typeof Collapsible> {
|
|
18
|
+
/** Number of sources, shown in the trigger. */
|
|
19
|
+
count: number;
|
|
20
|
+
/** Overrides for any subset of the English strings. Also read by the `SourceItem`s inside. */
|
|
21
|
+
strings?: Partial<SourcesStrings>;
|
|
22
|
+
}
|
|
23
|
+
declare const Sources: React.ForwardRefExoticComponent<SourcesProps & React.RefAttributes<HTMLDivElement>>;
|
|
24
|
+
declare const SourcesList: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLOListElement> & React.RefAttributes<HTMLOListElement>>;
|
|
25
|
+
export interface SourceData {
|
|
26
|
+
index: number | string;
|
|
27
|
+
title: string;
|
|
28
|
+
source?: string;
|
|
29
|
+
snippet?: string;
|
|
30
|
+
href?: string;
|
|
31
|
+
}
|
|
32
|
+
type SourceItemElementProps = Omit<React.AnchorHTMLAttributes<HTMLAnchorElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, 'onSelect' | 'title' | 'type'>;
|
|
33
|
+
export interface SourceItemProps extends SourceItemElementProps, SourceData {
|
|
34
|
+
/** Leading icon, such as a favicon or file type. */
|
|
35
|
+
icon?: React.ReactNode;
|
|
36
|
+
onSelect?: (source: SourceData, event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One source. A link when `href` is set and uses a safe protocol (new tab by default), otherwise a
|
|
40
|
+
* button for `onSelect`.
|
|
41
|
+
* The ref and extra props go to that link or button, not the wrapping `li`.
|
|
42
|
+
*/
|
|
43
|
+
declare const SourceItem: React.ForwardRefExoticComponent<SourceItemProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
44
|
+
export { Sources, SourcesList, SourceItem };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronDown, Link2 } from "lucide-react";
|
|
4
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
5
|
+
import { cn, safeHref } from "../../lib/index.js";
|
|
6
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "./collapsible.js";
|
|
7
|
+
const DEFAULT_SOURCES_STRINGS = {
|
|
8
|
+
sourceCount: (count)=>1 === count ? '1 source' : `${count} sources`,
|
|
9
|
+
opensInNewTab: '(opens in a new tab)'
|
|
10
|
+
};
|
|
11
|
+
const SourcesStringsContext = /*#__PURE__*/ createContext(DEFAULT_SOURCES_STRINGS);
|
|
12
|
+
const Sources = /*#__PURE__*/ forwardRef(({ className, count, strings, children, ...props }, ref)=>{
|
|
13
|
+
const text = {
|
|
14
|
+
...DEFAULT_SOURCES_STRINGS,
|
|
15
|
+
...strings
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/ jsx(SourcesStringsContext.Provider, {
|
|
18
|
+
value: text,
|
|
19
|
+
children: /*#__PURE__*/ jsxs(Collapsible, {
|
|
20
|
+
ref: ref,
|
|
21
|
+
"data-slot": "sources",
|
|
22
|
+
className: cn('group/sources flex w-full min-w-0 flex-col gap-2', className),
|
|
23
|
+
...props,
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
26
|
+
"data-slot": "sources-trigger",
|
|
27
|
+
className: "inline-flex h-7 w-fit cursor-pointer items-center gap-1.5 rounded-lg border border-border-subtle px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-surface-overlay hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5 [&_svg]:shrink-0",
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ jsx(Link2, {
|
|
30
|
+
"aria-hidden": "true"
|
|
31
|
+
}),
|
|
32
|
+
text.sourceCount(count),
|
|
33
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
className: "transition-transform group-data-[state=open]/sources:rotate-180"
|
|
36
|
+
})
|
|
37
|
+
]
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ jsx(CollapsibleContent, {
|
|
40
|
+
"data-slot": "sources-content",
|
|
41
|
+
className: "overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",
|
|
42
|
+
children: children
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
Sources.displayName = 'Sources';
|
|
49
|
+
const SourcesList = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("ol", {
|
|
50
|
+
ref: ref,
|
|
51
|
+
"data-slot": "sources-list",
|
|
52
|
+
className: cn('flex flex-col gap-0.5 rounded-xl border border-border-subtle bg-card p-1', className),
|
|
53
|
+
...props
|
|
54
|
+
}));
|
|
55
|
+
SourcesList.displayName = 'SourcesList';
|
|
56
|
+
const SourceItem = /*#__PURE__*/ forwardRef(({ className, index, title, source, snippet, href, icon, onSelect, onClick, target = '_blank', rel, ...props }, ref)=>{
|
|
57
|
+
const text = useContext(SourcesStringsContext);
|
|
58
|
+
const linkHref = safeHref(href);
|
|
59
|
+
const handleClick = (event)=>{
|
|
60
|
+
onClick?.(event);
|
|
61
|
+
if (!event.defaultPrevented) onSelect?.({
|
|
62
|
+
index,
|
|
63
|
+
title,
|
|
64
|
+
source,
|
|
65
|
+
snippet,
|
|
66
|
+
href: linkHref
|
|
67
|
+
}, event);
|
|
68
|
+
};
|
|
69
|
+
const itemClassName = cn('flex w-full min-w-0 cursor-pointer items-start gap-2.5 rounded-lg px-2 py-1.5 text-left text-sm transition-colors hover:bg-surface-overlay focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', className);
|
|
70
|
+
const newTab = '_blank' === target;
|
|
71
|
+
const body = /*#__PURE__*/ jsxs(Fragment, {
|
|
72
|
+
children: [
|
|
73
|
+
/*#__PURE__*/ jsx("span", {
|
|
74
|
+
"data-slot": "source-index",
|
|
75
|
+
className: "mt-0.5 flex h-4.5 min-w-4.5 shrink-0 items-center justify-center rounded-full bg-muted px-1 text-[11px] font-medium leading-none text-muted-foreground tabular-nums",
|
|
76
|
+
children: index
|
|
77
|
+
}),
|
|
78
|
+
icon && /*#__PURE__*/ jsx("span", {
|
|
79
|
+
"data-slot": "source-icon",
|
|
80
|
+
className: "mt-0.5 flex size-4 shrink-0 items-center justify-center text-muted-foreground [&_img]:size-4 [&_img]:rounded-sm [&_svg]:size-4",
|
|
81
|
+
children: icon
|
|
82
|
+
}),
|
|
83
|
+
/*#__PURE__*/ jsxs("span", {
|
|
84
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsx("span", {
|
|
87
|
+
"data-slot": "source-title",
|
|
88
|
+
className: "truncate font-medium text-foreground",
|
|
89
|
+
children: title
|
|
90
|
+
}),
|
|
91
|
+
source && /*#__PURE__*/ jsx("span", {
|
|
92
|
+
"data-slot": "source-source",
|
|
93
|
+
className: "truncate text-xs text-muted-foreground",
|
|
94
|
+
children: source
|
|
95
|
+
}),
|
|
96
|
+
snippet && /*#__PURE__*/ jsx("span", {
|
|
97
|
+
"data-slot": "source-snippet",
|
|
98
|
+
className: "line-clamp-2 text-xs leading-relaxed text-muted-foreground",
|
|
99
|
+
children: snippet
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
}),
|
|
103
|
+
linkHref && newTab && /*#__PURE__*/ jsx("span", {
|
|
104
|
+
className: "sr-only",
|
|
105
|
+
children: text.opensInNewTab
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
return /*#__PURE__*/ jsx("li", {
|
|
110
|
+
"data-slot": "source-item",
|
|
111
|
+
className: "min-w-0",
|
|
112
|
+
children: linkHref ? /*#__PURE__*/ jsx("a", {
|
|
113
|
+
ref: ref,
|
|
114
|
+
href: linkHref,
|
|
115
|
+
target: target,
|
|
116
|
+
rel: rel ?? (newTab ? 'noopener noreferrer' : void 0),
|
|
117
|
+
className: itemClassName,
|
|
118
|
+
onClick: handleClick,
|
|
119
|
+
...props,
|
|
120
|
+
children: body
|
|
121
|
+
}) : /*#__PURE__*/ jsx("button", {
|
|
122
|
+
ref: ref,
|
|
123
|
+
type: "button",
|
|
124
|
+
className: itemClassName,
|
|
125
|
+
onClick: handleClick,
|
|
126
|
+
...props,
|
|
127
|
+
children: body
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
SourceItem.displayName = 'SourceItem';
|
|
132
|
+
export { DEFAULT_SOURCES_STRINGS, SourceItem, Sources, SourcesList };
|