@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { createContext, forwardRef, isValidElement, useContext, useMemo } from "react";
|
|
6
|
+
import { cn } from "../../lib/index.js";
|
|
7
|
+
const ChatHeroContext = /*#__PURE__*/ createContext({
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
density: 'comfortable'
|
|
10
|
+
});
|
|
11
|
+
const chatHeroVariants = cva('flex w-full min-w-0 flex-1 flex-col', {
|
|
12
|
+
variants: {
|
|
13
|
+
layout: {
|
|
14
|
+
centered: 'mx-auto max-w-[800px] items-center justify-center',
|
|
15
|
+
docked: 'justify-end gap-6 text-start'
|
|
16
|
+
},
|
|
17
|
+
density: {
|
|
18
|
+
comfortable: '',
|
|
19
|
+
compact: ''
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
compoundVariants: [
|
|
23
|
+
{
|
|
24
|
+
layout: 'centered',
|
|
25
|
+
density: 'comfortable',
|
|
26
|
+
className: 'gap-8'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
layout: 'centered',
|
|
30
|
+
density: 'compact',
|
|
31
|
+
className: 'gap-6'
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
defaultVariants: {
|
|
35
|
+
layout: 'centered',
|
|
36
|
+
density: 'comfortable'
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const ChatHero = /*#__PURE__*/ forwardRef(({ className, layout, density, ...props }, ref)=>{
|
|
40
|
+
const context = useMemo(()=>({
|
|
41
|
+
layout: layout ?? 'centered',
|
|
42
|
+
density: density ?? 'comfortable'
|
|
43
|
+
}), [
|
|
44
|
+
layout,
|
|
45
|
+
density
|
|
46
|
+
]);
|
|
47
|
+
return /*#__PURE__*/ jsx(ChatHeroContext.Provider, {
|
|
48
|
+
value: context,
|
|
49
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
50
|
+
ref: ref,
|
|
51
|
+
"data-slot": "chat-hero",
|
|
52
|
+
"data-layout": context.layout,
|
|
53
|
+
"data-density": context.density,
|
|
54
|
+
className: cn(chatHeroVariants({
|
|
55
|
+
layout: context.layout,
|
|
56
|
+
density: context.density
|
|
57
|
+
}), className),
|
|
58
|
+
...props
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
ChatHero.displayName = 'ChatHero';
|
|
63
|
+
const ChatHeroHeader = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>{
|
|
64
|
+
const { layout } = useContext(ChatHeroContext);
|
|
65
|
+
return /*#__PURE__*/ jsx("div", {
|
|
66
|
+
ref: ref,
|
|
67
|
+
"data-slot": "chat-hero-header",
|
|
68
|
+
className: cn('flex w-full min-w-0 flex-col empty:hidden', 'centered' === layout ? 'items-center gap-1 text-center' : 'items-start gap-2 text-start', className),
|
|
69
|
+
...props
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
ChatHeroHeader.displayName = 'ChatHeroHeader';
|
|
73
|
+
const ChatHeroLogo = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ jsx("div", {
|
|
74
|
+
ref: ref,
|
|
75
|
+
"data-slot": "chat-hero-logo",
|
|
76
|
+
className: cn('mb-3 flex shrink-0 items-center justify-center', className),
|
|
77
|
+
...props
|
|
78
|
+
}));
|
|
79
|
+
ChatHeroLogo.displayName = 'ChatHeroLogo';
|
|
80
|
+
function isEmptyContent(children) {
|
|
81
|
+
return null == children || false === children || '' === children;
|
|
82
|
+
}
|
|
83
|
+
function isEmptyTitle(children, asChild) {
|
|
84
|
+
if (isEmptyContent(children)) return true;
|
|
85
|
+
if (!asChild || !/*#__PURE__*/ isValidElement(children)) return false;
|
|
86
|
+
return isEmptyContent(children.props.children);
|
|
87
|
+
}
|
|
88
|
+
const chatHeroTitleVariants = cva('min-w-0 text-foreground', {
|
|
89
|
+
variants: {
|
|
90
|
+
layout: {
|
|
91
|
+
centered: 'font-bold tracking-tight',
|
|
92
|
+
docked: 'font-semibold tracking-tight'
|
|
93
|
+
},
|
|
94
|
+
density: {
|
|
95
|
+
comfortable: '',
|
|
96
|
+
compact: ''
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
compoundVariants: [
|
|
100
|
+
{
|
|
101
|
+
layout: 'centered',
|
|
102
|
+
density: 'comfortable',
|
|
103
|
+
className: 'text-4xl leading-10'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
layout: 'centered',
|
|
107
|
+
density: 'compact',
|
|
108
|
+
className: 'text-2xl leading-8'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
layout: 'docked',
|
|
112
|
+
className: 'text-xl leading-6'
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
layout: 'centered',
|
|
117
|
+
density: 'comfortable'
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const ChatHeroTitle = /*#__PURE__*/ forwardRef(({ className, asChild = false, children, ...props }, ref)=>{
|
|
121
|
+
const { layout, density } = useContext(ChatHeroContext);
|
|
122
|
+
if (isEmptyTitle(children, asChild)) return null;
|
|
123
|
+
const Comp = asChild ? Slot : 'h2';
|
|
124
|
+
return /*#__PURE__*/ jsx(Comp, {
|
|
125
|
+
ref: ref,
|
|
126
|
+
"data-slot": "chat-hero-title",
|
|
127
|
+
className: cn(chatHeroTitleVariants({
|
|
128
|
+
layout,
|
|
129
|
+
density
|
|
130
|
+
}), className),
|
|
131
|
+
...props,
|
|
132
|
+
children: children
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
ChatHeroTitle.displayName = 'ChatHeroTitle';
|
|
136
|
+
const chatHeroDescriptionVariants = cva('min-w-0 text-muted-foreground', {
|
|
137
|
+
variants: {
|
|
138
|
+
layout: {
|
|
139
|
+
centered: '',
|
|
140
|
+
docked: ''
|
|
141
|
+
},
|
|
142
|
+
density: {
|
|
143
|
+
comfortable: '',
|
|
144
|
+
compact: ''
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
compoundVariants: [
|
|
148
|
+
{
|
|
149
|
+
layout: 'centered',
|
|
150
|
+
density: 'comfortable',
|
|
151
|
+
className: 'text-base'
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
layout: 'centered',
|
|
155
|
+
density: 'compact',
|
|
156
|
+
className: 'text-sm'
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
layout: 'docked',
|
|
160
|
+
density: 'comfortable',
|
|
161
|
+
className: 'text-sm leading-5'
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
layout: 'docked',
|
|
165
|
+
density: 'compact',
|
|
166
|
+
className: 'text-xs leading-4'
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
defaultVariants: {
|
|
170
|
+
layout: 'centered',
|
|
171
|
+
density: 'comfortable'
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
const ChatHeroDescription = /*#__PURE__*/ forwardRef(({ className, children, ...props }, ref)=>{
|
|
175
|
+
const { layout, density } = useContext(ChatHeroContext);
|
|
176
|
+
if (isEmptyContent(children)) return null;
|
|
177
|
+
return /*#__PURE__*/ jsx("p", {
|
|
178
|
+
ref: ref,
|
|
179
|
+
"data-slot": "chat-hero-description",
|
|
180
|
+
className: cn(chatHeroDescriptionVariants({
|
|
181
|
+
layout,
|
|
182
|
+
density
|
|
183
|
+
}), className),
|
|
184
|
+
...props,
|
|
185
|
+
children: children
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
ChatHeroDescription.displayName = "ChatHeroDescription";
|
|
189
|
+
export { ChatHero, ChatHeroDescription, ChatHeroHeader, ChatHeroLogo, ChatHeroTitle, chatHeroDescriptionVariants, chatHeroTitleVariants, chatHeroVariants };
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
Citation: ()=>Citation,
|
|
29
|
+
citationVariants: ()=>citationVariants,
|
|
30
|
+
DEFAULT_CITATION_STRINGS: ()=>DEFAULT_CITATION_STRINGS
|
|
31
|
+
});
|
|
32
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
|
+
const external_class_variance_authority_namespaceObject = require("class-variance-authority");
|
|
34
|
+
const external_react_namespaceObject = require("react");
|
|
35
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
36
|
+
const external_hover_card_cjs_namespaceObject = require("./hover-card.cjs");
|
|
37
|
+
const DEFAULT_CITATION_STRINGS = {
|
|
38
|
+
label: (index, title)=>title ? `Citation ${index}: ${title}` : `Citation ${index}`
|
|
39
|
+
};
|
|
40
|
+
const citationVariants = (0, external_class_variance_authority_namespaceObject.cva)('mx-0.5 inline-flex cursor-pointer items-center justify-center rounded-full bg-muted align-text-top font-medium leading-none text-muted-foreground tabular-nums transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-accent-foreground', {
|
|
41
|
+
variants: {
|
|
42
|
+
size: {
|
|
43
|
+
default: 'h-4.5 min-w-4.5 px-1.5 text-[11px]',
|
|
44
|
+
sm: 'h-4 min-w-4 px-1 text-[10px]',
|
|
45
|
+
lg: 'h-5 min-w-5 px-1.5 text-xs'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
defaultVariants: {
|
|
49
|
+
size: 'default'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const Citation = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, size = 'default', index, title, snippet, source, href, onSelect, onClick, onFocus, onBlur, onPointerEnter, onPointerLeave, preview = true, previewSide = 'top', onActiveChange, strings, 'aria-label': ariaLabel, children, ...props }, ref)=>{
|
|
53
|
+
const text = {
|
|
54
|
+
...DEFAULT_CITATION_STRINGS,
|
|
55
|
+
...strings
|
|
56
|
+
};
|
|
57
|
+
const [open, setOpen] = external_react_namespaceObject.useState(false);
|
|
58
|
+
const activity = external_react_namespaceObject.useRef({
|
|
59
|
+
hovered: false,
|
|
60
|
+
focused: false,
|
|
61
|
+
previewOpen: false
|
|
62
|
+
});
|
|
63
|
+
const active = external_react_namespaceObject.useRef(false);
|
|
64
|
+
const onActiveChangeRef = external_react_namespaceObject.useRef(onActiveChange);
|
|
65
|
+
onActiveChangeRef.current = onActiveChange;
|
|
66
|
+
const updateActivity = (patch)=>{
|
|
67
|
+
Object.assign(activity.current, patch);
|
|
68
|
+
const { hovered, focused, previewOpen } = activity.current;
|
|
69
|
+
const next = hovered || focused || previewOpen;
|
|
70
|
+
if (next === active.current) return;
|
|
71
|
+
active.current = next;
|
|
72
|
+
onActiveChangeRef.current?.(next);
|
|
73
|
+
};
|
|
74
|
+
const dismissed = external_react_namespaceObject.useRef(false);
|
|
75
|
+
const setPreviewOpen = (next)=>{
|
|
76
|
+
if (next && dismissed.current) return;
|
|
77
|
+
setOpen(next);
|
|
78
|
+
updateActivity({
|
|
79
|
+
previewOpen: next
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
external_react_namespaceObject.useEffect(()=>()=>{
|
|
83
|
+
if (active.current) onActiveChangeRef.current?.(false);
|
|
84
|
+
}, []);
|
|
85
|
+
const name = ariaLabel ?? text.label(String(index), title || void 0);
|
|
86
|
+
const hasPreview = preview && Boolean(title || snippet || source);
|
|
87
|
+
const button = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("button", {
|
|
88
|
+
ref: ref,
|
|
89
|
+
type: "button",
|
|
90
|
+
"data-slot": "citation",
|
|
91
|
+
"data-size": size,
|
|
92
|
+
"aria-label": name,
|
|
93
|
+
className: (0, index_cjs_namespaceObject.cn)(citationVariants({
|
|
94
|
+
size
|
|
95
|
+
}), className),
|
|
96
|
+
onClick: (event)=>{
|
|
97
|
+
onClick?.(event);
|
|
98
|
+
if (hasPreview) {
|
|
99
|
+
dismissed.current = true;
|
|
100
|
+
setPreviewOpen(false);
|
|
101
|
+
}
|
|
102
|
+
if (!event.defaultPrevented) onSelect?.({
|
|
103
|
+
index,
|
|
104
|
+
title,
|
|
105
|
+
snippet,
|
|
106
|
+
source,
|
|
107
|
+
href: (0, index_cjs_namespaceObject.safeHref)(href)
|
|
108
|
+
}, event);
|
|
109
|
+
},
|
|
110
|
+
onFocus: (event)=>{
|
|
111
|
+
onFocus?.(event);
|
|
112
|
+
if (!event.currentTarget.matches(':focus-visible')) return;
|
|
113
|
+
updateActivity({
|
|
114
|
+
focused: true
|
|
115
|
+
});
|
|
116
|
+
if (hasPreview) setPreviewOpen(true);
|
|
117
|
+
},
|
|
118
|
+
onBlur: (event)=>{
|
|
119
|
+
onBlur?.(event);
|
|
120
|
+
dismissed.current = false;
|
|
121
|
+
updateActivity({
|
|
122
|
+
focused: false
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
onPointerEnter: (event)=>{
|
|
126
|
+
onPointerEnter?.(event);
|
|
127
|
+
updateActivity({
|
|
128
|
+
hovered: true
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
onPointerLeave: (event)=>{
|
|
132
|
+
onPointerLeave?.(event);
|
|
133
|
+
dismissed.current = false;
|
|
134
|
+
updateActivity({
|
|
135
|
+
hovered: false
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
...props,
|
|
139
|
+
children: children ?? index
|
|
140
|
+
});
|
|
141
|
+
if (!hasPreview) return button;
|
|
142
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_hover_card_cjs_namespaceObject.HoverCard, {
|
|
143
|
+
open: open,
|
|
144
|
+
onOpenChange: setPreviewOpen,
|
|
145
|
+
openDelay: 300,
|
|
146
|
+
closeDelay: 150,
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_hover_card_cjs_namespaceObject.HoverCardTrigger, {
|
|
149
|
+
asChild: true,
|
|
150
|
+
children: button
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_hover_card_cjs_namespaceObject.HoverCardContent, {
|
|
153
|
+
"data-slot": "citation-preview",
|
|
154
|
+
side: previewSide,
|
|
155
|
+
className: "flex w-72 flex-col gap-1 p-3 text-sm",
|
|
156
|
+
children: [
|
|
157
|
+
source && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
158
|
+
"data-slot": "citation-source",
|
|
159
|
+
className: "truncate text-xs text-muted-foreground",
|
|
160
|
+
children: source
|
|
161
|
+
}),
|
|
162
|
+
title && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
163
|
+
"data-slot": "citation-title",
|
|
164
|
+
className: "line-clamp-2 font-medium",
|
|
165
|
+
children: title
|
|
166
|
+
}),
|
|
167
|
+
snippet && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
168
|
+
"data-slot": "citation-snippet",
|
|
169
|
+
className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground",
|
|
170
|
+
children: snippet
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
})
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
Citation.displayName = 'Citation';
|
|
178
|
+
exports.Citation = __webpack_exports__.Citation;
|
|
179
|
+
exports.DEFAULT_CITATION_STRINGS = __webpack_exports__.DEFAULT_CITATION_STRINGS;
|
|
180
|
+
exports.citationVariants = __webpack_exports__.citationVariants;
|
|
181
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
182
|
+
"Citation",
|
|
183
|
+
"DEFAULT_CITATION_STRINGS",
|
|
184
|
+
"citationVariants"
|
|
185
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
186
|
+
Object.defineProperty(exports, '__esModule', {
|
|
187
|
+
value: true
|
|
188
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { HoverCardContent } from './hover-card';
|
|
4
|
+
/**
|
|
5
|
+
* An inline citation marker for chat prose, with a hover and focus preview of the source. It does
|
|
6
|
+
* not navigate on its own: `onSelect` receives the citation and the event, so a host can run its
|
|
7
|
+
* `citation-click` pre-hook and decide whether to open `href`. 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 CitationData {
|
|
11
|
+
/** The source number, usually 1-based. Shown in the pill unless `children` are given. */
|
|
12
|
+
index: number | string;
|
|
13
|
+
title?: string;
|
|
14
|
+
snippet?: string;
|
|
15
|
+
/** Where it came from: a domain, a file name or a page reference. */
|
|
16
|
+
source?: string;
|
|
17
|
+
href?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CitationStrings {
|
|
20
|
+
/** Accessible name of the pill. */
|
|
21
|
+
label: (index: string, title?: string) => string;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_CITATION_STRINGS: CitationStrings;
|
|
24
|
+
declare const citationVariants: (props?: ({
|
|
25
|
+
size?: "default" | "lg" | "sm" | null | undefined;
|
|
26
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
27
|
+
export interface CitationProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'onSelect' | 'title'>, CitationData, VariantProps<typeof citationVariants> {
|
|
28
|
+
onSelect?: (citation: CitationData, event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
29
|
+
/** Set false to skip the preview card even when there is content for it. */
|
|
30
|
+
preview?: boolean;
|
|
31
|
+
previewSide?: React.ComponentPropsWithoutRef<typeof HoverCardContent>['side'];
|
|
32
|
+
/**
|
|
33
|
+
* Called when the citation becomes active or inactive, so a host can mark the cited text. It
|
|
34
|
+
* activates at once on hover or keyboard focus, and deactivates once neither applies and its
|
|
35
|
+
* preview, if shown, has closed. The preview's close delay means one citation can deactivate after the next
|
|
36
|
+
* activates. Also called with `false` if it unmounts active.
|
|
37
|
+
*/
|
|
38
|
+
onActiveChange?: (active: boolean) => void;
|
|
39
|
+
strings?: Partial<CitationStrings>;
|
|
40
|
+
}
|
|
41
|
+
declare const Citation: React.ForwardRefExoticComponent<CitationProps & React.RefAttributes<HTMLButtonElement>>;
|
|
42
|
+
export { Citation, citationVariants };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
5
|
+
import { cn, safeHref } from "../../lib/index.js";
|
|
6
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from "./hover-card.js";
|
|
7
|
+
const DEFAULT_CITATION_STRINGS = {
|
|
8
|
+
label: (index, title)=>title ? `Citation ${index}: ${title}` : `Citation ${index}`
|
|
9
|
+
};
|
|
10
|
+
const citationVariants = cva('mx-0.5 inline-flex cursor-pointer items-center justify-center rounded-full bg-muted align-text-top font-medium leading-none text-muted-foreground tabular-nums transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-accent-foreground', {
|
|
11
|
+
variants: {
|
|
12
|
+
size: {
|
|
13
|
+
default: 'h-4.5 min-w-4.5 px-1.5 text-[11px]',
|
|
14
|
+
sm: 'h-4 min-w-4 px-1 text-[10px]',
|
|
15
|
+
lg: 'h-5 min-w-5 px-1.5 text-xs'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: {
|
|
19
|
+
size: 'default'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const Citation = /*#__PURE__*/ forwardRef(({ className, size = 'default', index, title, snippet, source, href, onSelect, onClick, onFocus, onBlur, onPointerEnter, onPointerLeave, preview = true, previewSide = 'top', onActiveChange, strings, 'aria-label': ariaLabel, children, ...props }, ref)=>{
|
|
23
|
+
const text = {
|
|
24
|
+
...DEFAULT_CITATION_STRINGS,
|
|
25
|
+
...strings
|
|
26
|
+
};
|
|
27
|
+
const [open, setOpen] = useState(false);
|
|
28
|
+
const activity = useRef({
|
|
29
|
+
hovered: false,
|
|
30
|
+
focused: false,
|
|
31
|
+
previewOpen: false
|
|
32
|
+
});
|
|
33
|
+
const active = useRef(false);
|
|
34
|
+
const onActiveChangeRef = useRef(onActiveChange);
|
|
35
|
+
onActiveChangeRef.current = onActiveChange;
|
|
36
|
+
const updateActivity = (patch)=>{
|
|
37
|
+
Object.assign(activity.current, patch);
|
|
38
|
+
const { hovered, focused, previewOpen } = activity.current;
|
|
39
|
+
const next = hovered || focused || previewOpen;
|
|
40
|
+
if (next === active.current) return;
|
|
41
|
+
active.current = next;
|
|
42
|
+
onActiveChangeRef.current?.(next);
|
|
43
|
+
};
|
|
44
|
+
const dismissed = useRef(false);
|
|
45
|
+
const setPreviewOpen = (next)=>{
|
|
46
|
+
if (next && dismissed.current) return;
|
|
47
|
+
setOpen(next);
|
|
48
|
+
updateActivity({
|
|
49
|
+
previewOpen: next
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
useEffect(()=>()=>{
|
|
53
|
+
if (active.current) onActiveChangeRef.current?.(false);
|
|
54
|
+
}, []);
|
|
55
|
+
const name = ariaLabel ?? text.label(String(index), title || void 0);
|
|
56
|
+
const hasPreview = preview && Boolean(title || snippet || source);
|
|
57
|
+
const button = /*#__PURE__*/ jsx("button", {
|
|
58
|
+
ref: ref,
|
|
59
|
+
type: "button",
|
|
60
|
+
"data-slot": "citation",
|
|
61
|
+
"data-size": size,
|
|
62
|
+
"aria-label": name,
|
|
63
|
+
className: cn(citationVariants({
|
|
64
|
+
size
|
|
65
|
+
}), className),
|
|
66
|
+
onClick: (event)=>{
|
|
67
|
+
onClick?.(event);
|
|
68
|
+
if (hasPreview) {
|
|
69
|
+
dismissed.current = true;
|
|
70
|
+
setPreviewOpen(false);
|
|
71
|
+
}
|
|
72
|
+
if (!event.defaultPrevented) onSelect?.({
|
|
73
|
+
index,
|
|
74
|
+
title,
|
|
75
|
+
snippet,
|
|
76
|
+
source,
|
|
77
|
+
href: safeHref(href)
|
|
78
|
+
}, event);
|
|
79
|
+
},
|
|
80
|
+
onFocus: (event)=>{
|
|
81
|
+
onFocus?.(event);
|
|
82
|
+
if (!event.currentTarget.matches(':focus-visible')) return;
|
|
83
|
+
updateActivity({
|
|
84
|
+
focused: true
|
|
85
|
+
});
|
|
86
|
+
if (hasPreview) setPreviewOpen(true);
|
|
87
|
+
},
|
|
88
|
+
onBlur: (event)=>{
|
|
89
|
+
onBlur?.(event);
|
|
90
|
+
dismissed.current = false;
|
|
91
|
+
updateActivity({
|
|
92
|
+
focused: false
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
onPointerEnter: (event)=>{
|
|
96
|
+
onPointerEnter?.(event);
|
|
97
|
+
updateActivity({
|
|
98
|
+
hovered: true
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
onPointerLeave: (event)=>{
|
|
102
|
+
onPointerLeave?.(event);
|
|
103
|
+
dismissed.current = false;
|
|
104
|
+
updateActivity({
|
|
105
|
+
hovered: false
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
...props,
|
|
109
|
+
children: children ?? index
|
|
110
|
+
});
|
|
111
|
+
if (!hasPreview) return button;
|
|
112
|
+
return /*#__PURE__*/ jsxs(HoverCard, {
|
|
113
|
+
open: open,
|
|
114
|
+
onOpenChange: setPreviewOpen,
|
|
115
|
+
openDelay: 300,
|
|
116
|
+
closeDelay: 150,
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ jsx(HoverCardTrigger, {
|
|
119
|
+
asChild: true,
|
|
120
|
+
children: button
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ jsxs(HoverCardContent, {
|
|
123
|
+
"data-slot": "citation-preview",
|
|
124
|
+
side: previewSide,
|
|
125
|
+
className: "flex w-72 flex-col gap-1 p-3 text-sm",
|
|
126
|
+
children: [
|
|
127
|
+
source && /*#__PURE__*/ jsx("span", {
|
|
128
|
+
"data-slot": "citation-source",
|
|
129
|
+
className: "truncate text-xs text-muted-foreground",
|
|
130
|
+
children: source
|
|
131
|
+
}),
|
|
132
|
+
title && /*#__PURE__*/ jsx("span", {
|
|
133
|
+
"data-slot": "citation-title",
|
|
134
|
+
className: "line-clamp-2 font-medium",
|
|
135
|
+
children: title
|
|
136
|
+
}),
|
|
137
|
+
snippet && /*#__PURE__*/ jsx("span", {
|
|
138
|
+
"data-slot": "citation-snippet",
|
|
139
|
+
className: "line-clamp-3 text-xs leading-relaxed text-muted-foreground",
|
|
140
|
+
children: snippet
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
Citation.displayName = 'Citation';
|
|
148
|
+
export { Citation, DEFAULT_CITATION_STRINGS, citationVariants };
|
|
@@ -42,6 +42,7 @@ const external_input_group_context_cjs_namespaceObject = require("./input-group-
|
|
|
42
42
|
const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
43
43
|
const generatedId = external_react_namespaceObject.useId();
|
|
44
44
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
45
|
+
const date = value instanceof Date && (0, external_date_fns_namespaceObject.isValid)(value) ? value : void 0;
|
|
45
46
|
const group = (0, external_input_group_context_cjs_namespaceObject.useInputGroup)();
|
|
46
47
|
const grouped = group.inGroup;
|
|
47
48
|
const validation = (0, external_input_group_context_cjs_namespaceObject.useControlValidation)(group, {
|
|
@@ -53,7 +54,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
53
54
|
});
|
|
54
55
|
const triggerProps = {
|
|
55
56
|
id,
|
|
56
|
-
'aria-label': id || ariaLabelledBy ? void 0 :
|
|
57
|
+
'aria-label': id || ariaLabelledBy ? void 0 : date ? `Selected date: ${(0, external_date_fns_namespaceObject.format)(date, 'PPP')}` : placeholder,
|
|
57
58
|
'aria-labelledby': ariaLabelledBy,
|
|
58
59
|
...validation.aria,
|
|
59
60
|
disabled: disabled || group.disabled
|
|
@@ -68,9 +69,9 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
68
69
|
...triggerProps,
|
|
69
70
|
className: className,
|
|
70
71
|
placeholder: placeholder,
|
|
71
|
-
children:
|
|
72
|
+
children: date && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
72
73
|
className: "truncate",
|
|
73
|
-
children: (0, external_date_fns_namespaceObject.format)(
|
|
74
|
+
children: (0, external_date_fns_namespaceObject.format)(date, 'PPP')
|
|
74
75
|
})
|
|
75
76
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_popover_cjs_namespaceObject.PopoverTrigger, {
|
|
76
77
|
asChild: true,
|
|
@@ -81,7 +82,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
81
82
|
className: (0, index_cjs_namespaceObject.cn)('w-full justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
82
83
|
children: [
|
|
83
84
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.CalendarIcon, {}),
|
|
84
|
-
|
|
85
|
+
date ? (0, external_date_fns_namespaceObject.format)(date, 'PPP') : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
85
86
|
className: "text-foreground-muted",
|
|
86
87
|
children: placeholder
|
|
87
88
|
})
|
|
@@ -93,7 +94,7 @@ const date_picker_DatePicker = /*#__PURE__*/ external_react_namespaceObject.forw
|
|
|
93
94
|
align: grouped ? 'start' : void 0,
|
|
94
95
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_calendar_cjs_namespaceObject.Calendar, {
|
|
95
96
|
mode: "single",
|
|
96
|
-
selected:
|
|
97
|
+
selected: date,
|
|
97
98
|
onSelect: onValueChange,
|
|
98
99
|
initialFocus: true,
|
|
99
100
|
...calendarProps
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { format } from "date-fns";
|
|
3
|
+
import { format, isValid } from "date-fns";
|
|
4
4
|
import { CalendarIcon } from "lucide-react";
|
|
5
5
|
import { forwardRef, useId } from "react";
|
|
6
6
|
import { Button } from "./button.js";
|
|
@@ -13,6 +13,7 @@ import { useControlValidation, useInputGroup } from "./input-group-context.js";
|
|
|
13
13
|
const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, onValueChange, disabled, placeholder = 'Pick a date', className, calendarProps, error, errorId, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage }, ref) {
|
|
14
14
|
const generatedId = useId();
|
|
15
15
|
const validationId = errorId ?? `${id ?? `date-picker-${generatedId.replace(/:/g, '')}`}-error`;
|
|
16
|
+
const date = value instanceof Date && isValid(value) ? value : void 0;
|
|
16
17
|
const group = useInputGroup();
|
|
17
18
|
const grouped = group.inGroup;
|
|
18
19
|
const validation = useControlValidation(group, {
|
|
@@ -24,7 +25,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
24
25
|
});
|
|
25
26
|
const triggerProps = {
|
|
26
27
|
id,
|
|
27
|
-
'aria-label': id || ariaLabelledBy ? void 0 :
|
|
28
|
+
'aria-label': id || ariaLabelledBy ? void 0 : date ? `Selected date: ${format(date, 'PPP')}` : placeholder,
|
|
28
29
|
'aria-labelledby': ariaLabelledBy,
|
|
29
30
|
...validation.aria,
|
|
30
31
|
disabled: disabled || group.disabled
|
|
@@ -39,9 +40,9 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
39
40
|
...triggerProps,
|
|
40
41
|
className: className,
|
|
41
42
|
placeholder: placeholder,
|
|
42
|
-
children:
|
|
43
|
+
children: date && /*#__PURE__*/ jsx("span", {
|
|
43
44
|
className: "truncate",
|
|
44
|
-
children: format(
|
|
45
|
+
children: format(date, 'PPP')
|
|
45
46
|
})
|
|
46
47
|
}) : /*#__PURE__*/ jsx(PopoverTrigger, {
|
|
47
48
|
asChild: true,
|
|
@@ -52,7 +53,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
52
53
|
className: cn('w-full justify-start text-left font-normal [&>svg]:text-foreground-muted hover:[&>svg]:text-accent-foreground', 'future:h-10 future:rounded-xl future:border-0 future:bg-surface-overlay future:px-4 future:gap-4 future:text-foreground future:hover:bg-surface-hover future:focus-visible:ring-offset-2 future:focus-visible:ring-offset-background', className),
|
|
53
54
|
children: [
|
|
54
55
|
/*#__PURE__*/ jsx(CalendarIcon, {}),
|
|
55
|
-
|
|
56
|
+
date ? format(date, 'PPP') : /*#__PURE__*/ jsx("span", {
|
|
56
57
|
className: "text-foreground-muted",
|
|
57
58
|
children: placeholder
|
|
58
59
|
})
|
|
@@ -64,7 +65,7 @@ const date_picker_DatePicker = /*#__PURE__*/ forwardRef(function({ id, value, on
|
|
|
64
65
|
align: grouped ? 'start' : void 0,
|
|
65
66
|
children: /*#__PURE__*/ jsx(Calendar, {
|
|
66
67
|
mode: "single",
|
|
67
|
-
selected:
|
|
68
|
+
selected: date,
|
|
68
69
|
onSelect: onValueChange,
|
|
69
70
|
initialFocus: true,
|
|
70
71
|
...calendarProps
|