@aircall/blocks 0.12.0 → 0.13.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/globals.css +1 -1
- package/dist/index.d.ts +221 -122
- package/dist/index.js +129 -48
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Anchor, Badge, Button, CounterBadge, DropdownMenu, DropdownMenuAddon, D
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { AircallLoader, AircallLogo, AircallMark, ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, Copy, Ellipsis, ExternalLink, FileText, LockKeyhole, Menu, MessageSquare, Minus, PanelLeft, PanelLeftClose, PanelLeftOpen, Plus, Search, Settings, Sprout, Square, SquareArrowOutUpRight, ThumbsDown, ThumbsDownFilled, ThumbsUp, ThumbsUpFilled, TriangleAlert } from "@aircall/react-icons";
|
|
5
|
+
import { AircallLoader, AircallLogo, AircallMark, ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, Copy, Ellipsis, ExternalLink, FileText, History, LockKeyhole, Menu, MessageSquare, Minus, PanelLeft, PanelLeftClose, PanelLeftOpen, Plus, Search, Settings, Sprout, Square, SquareArrowOutUpRight, ThumbsDown, ThumbsDownFilled, ThumbsUp, ThumbsUpFilled, TriangleAlert } from "@aircall/react-icons";
|
|
6
6
|
import ReactMarkdown from "react-markdown";
|
|
7
7
|
import remarkGfm from "remark-gfm";
|
|
8
8
|
import { useCallbackRef, useControllableState, useIsMounted, useUnmount } from "@aircall/hooks";
|
|
@@ -29,6 +29,9 @@ const de = {
|
|
|
29
29
|
"chatbotInput.messageLabel": "Nachricht",
|
|
30
30
|
"chatbotInput.stopGenerating": "Generierung stoppen",
|
|
31
31
|
"chatbotInput.sendMessage": "Nachricht senden",
|
|
32
|
+
"chatbotInput.conversationHistory": "Gesprächsverlauf",
|
|
33
|
+
"chatbotInput.noConversations": "Keine vergangenen Gespräche",
|
|
34
|
+
"chatbotInput.recentChatHistory": "Letzter Chatverlauf",
|
|
32
35
|
"productBadge.beta": "Beta",
|
|
33
36
|
"productBadge.new": "Neu",
|
|
34
37
|
"productBadge.deprecated": "Veraltet",
|
|
@@ -85,6 +88,9 @@ const en = {
|
|
|
85
88
|
"chatbotInput.messageLabel": "Message",
|
|
86
89
|
"chatbotInput.stopGenerating": "Stop generating",
|
|
87
90
|
"chatbotInput.sendMessage": "Send message",
|
|
91
|
+
"chatbotInput.conversationHistory": "Conversation history",
|
|
92
|
+
"chatbotInput.noConversations": "No past conversations",
|
|
93
|
+
"chatbotInput.recentChatHistory": "Recent chat history",
|
|
88
94
|
"productBadge.beta": "Beta",
|
|
89
95
|
"productBadge.new": "New",
|
|
90
96
|
"productBadge.deprecated": "Deprecated",
|
|
@@ -141,6 +147,9 @@ const es = {
|
|
|
141
147
|
"chatbotInput.messageLabel": "Mensaje",
|
|
142
148
|
"chatbotInput.stopGenerating": "Detener la generación",
|
|
143
149
|
"chatbotInput.sendMessage": "Enviar mensaje",
|
|
150
|
+
"chatbotInput.conversationHistory": "Historial de conversaciones",
|
|
151
|
+
"chatbotInput.noConversations": "No hay conversaciones pasadas",
|
|
152
|
+
"chatbotInput.recentChatHistory": "Historial de chats recientes",
|
|
144
153
|
"productBadge.beta": "Beta",
|
|
145
154
|
"productBadge.new": "Nuevo",
|
|
146
155
|
"productBadge.deprecated": "Obsoleto",
|
|
@@ -197,6 +206,9 @@ const fr = {
|
|
|
197
206
|
"chatbotInput.messageLabel": "Message",
|
|
198
207
|
"chatbotInput.stopGenerating": "Arrêter la génération",
|
|
199
208
|
"chatbotInput.sendMessage": "Envoyer un message",
|
|
209
|
+
"chatbotInput.conversationHistory": "Historique des conversations",
|
|
210
|
+
"chatbotInput.noConversations": "Aucune conversation passée",
|
|
211
|
+
"chatbotInput.recentChatHistory": "Historique récent des chats",
|
|
200
212
|
"productBadge.beta": "Bêta",
|
|
201
213
|
"productBadge.new": "Nouveau",
|
|
202
214
|
"productBadge.deprecated": "Obsolète",
|
|
@@ -253,6 +265,9 @@ const it = {
|
|
|
253
265
|
"chatbotInput.messageLabel": "Messaggio",
|
|
254
266
|
"chatbotInput.stopGenerating": "Interrompi la generazione",
|
|
255
267
|
"chatbotInput.sendMessage": "Invia messaggio",
|
|
268
|
+
"chatbotInput.conversationHistory": "Cronologia conversazioni",
|
|
269
|
+
"chatbotInput.noConversations": "Nessuna conversazione passata",
|
|
270
|
+
"chatbotInput.recentChatHistory": "Cronologia recente delle chat",
|
|
256
271
|
"productBadge.beta": "Beta",
|
|
257
272
|
"productBadge.new": "Nuovo",
|
|
258
273
|
"productBadge.deprecated": "Obsoleto",
|
|
@@ -1445,7 +1460,7 @@ function ChatbotPanelHeader({ title = "Ask Aircall", onMenu, menuContent, menuOp
|
|
|
1445
1460
|
const SIDEBAR_MIN_WIDTH = 140;
|
|
1446
1461
|
const SIDEBAR_MAX_WIDTH = 480;
|
|
1447
1462
|
const ChatbotSidebar = React.forwardRef((componentProps, forwardRef) => {
|
|
1448
|
-
const { conversations, activeConversationId, onNewChat, onSelectConversation, renderConversationMenuContent, recentLabel = "Recent", popup = false, className } = componentProps;
|
|
1463
|
+
const { conversations, activeConversationId, onNewChat, onSelectConversation, renderConversationMenuContent, recentLabel = "Recent", showNewChat = true, popup = false, className } = componentProps;
|
|
1449
1464
|
const t = useDsTranslation("blocks");
|
|
1450
1465
|
const isNewChatActive = !activeConversationId || !conversations.some((c) => c.id === activeConversationId);
|
|
1451
1466
|
const sidebarInternalRef = React.useRef(null);
|
|
@@ -1478,7 +1493,7 @@ const ChatbotSidebar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1478
1493
|
const scrollableContent = /* @__PURE__ */ jsxs("div", {
|
|
1479
1494
|
"data-slot": "sidebar-content",
|
|
1480
1495
|
className: cn("flex min-h-0 flex-1 flex-col gap-2 overflow-auto", "[scrollbar-width:thin] [scrollbar-color:transparent_transparent] hover:[scrollbar-color:rgba(0,0,0,0.15)_transparent]", "[&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full", "[&::-webkit-scrollbar-thumb]:bg-transparent [&:hover::-webkit-scrollbar-thumb]:bg-black/20"),
|
|
1481
|
-
children: [/* @__PURE__ */ jsx(SidebarGroup, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(SidebarMenuButton, {
|
|
1496
|
+
children: [showNewChat && /* @__PURE__ */ jsx(SidebarGroup, { children: /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(SidebarMenuButton, {
|
|
1482
1497
|
isActive: isNewChatActive,
|
|
1483
1498
|
onClick: onNewChat,
|
|
1484
1499
|
children: [/* @__PURE__ */ jsx(Plus, {}), /* @__PURE__ */ jsx("span", { children: t("chatbotSidebar.newChat") })]
|
|
@@ -1533,6 +1548,17 @@ const ChatbotSidebar = React.forwardRef((componentProps, forwardRef) => {
|
|
|
1533
1548
|
});
|
|
1534
1549
|
ChatbotSidebar.displayName = "ChatbotSidebar";
|
|
1535
1550
|
|
|
1551
|
+
//#endregion
|
|
1552
|
+
//#region src/components/chatbot-panel-suggestion.tsx
|
|
1553
|
+
function ChatbotPanelSuggestion({ className, ...props }) {
|
|
1554
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
1555
|
+
"data-slot": "chatbot-panel-suggestion",
|
|
1556
|
+
variant: "ghost",
|
|
1557
|
+
className: cn("h-auto max-w-[280px] text-left rounded-[18px] border border-primary px-3 py-1.5", "bg-background text-primary whitespace-normal", "hover:bg-[color-mix(in_srgb,#5BF1B2_20%,var(--background))] hover:text-primary", className),
|
|
1558
|
+
...props
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1536
1562
|
//#endregion
|
|
1537
1563
|
//#region src/components/chatbot-input.tsx
|
|
1538
1564
|
const textareaVariants = cva([
|
|
@@ -1556,13 +1582,14 @@ const textareaVariants = cva([
|
|
|
1556
1582
|
expanded: false
|
|
1557
1583
|
}
|
|
1558
1584
|
});
|
|
1559
|
-
function ChatbotInput({ className, value, onValueChange, onSubmit, onStop, placeholder, loading = false, size = "default", expanded = false, disabled, ...textareaProps }) {
|
|
1585
|
+
function ChatbotInput({ className, value, onValueChange, onSubmit, onStop, placeholder, loading = false, size = "default", expanded = false, disabled, suggestions, onSuggestionClick, conversations, activeConversationId, onSelectConversation, ...textareaProps }) {
|
|
1560
1586
|
const t = useDsTranslation("blocks");
|
|
1561
1587
|
const [currentValue = "", setCurrentValue] = useControllableState({
|
|
1562
1588
|
prop: value,
|
|
1563
1589
|
defaultProp: "",
|
|
1564
1590
|
onChange: onValueChange
|
|
1565
1591
|
});
|
|
1592
|
+
const [historyOpen, setHistoryOpen] = React.useState(false);
|
|
1566
1593
|
const hasValue = currentValue.trim().length > 0;
|
|
1567
1594
|
const handleChange = (event) => {
|
|
1568
1595
|
setCurrentValue(event.target.value);
|
|
@@ -1579,10 +1606,63 @@ function ChatbotInput({ className, value, onValueChange, onSubmit, onStop, place
|
|
|
1579
1606
|
}
|
|
1580
1607
|
textareaProps.onKeyDown?.(event);
|
|
1581
1608
|
};
|
|
1609
|
+
const hasSuggestions = suggestions && suggestions.length > 0;
|
|
1610
|
+
const hasBottomRow = hasSuggestions || conversations !== void 0;
|
|
1611
|
+
const sendStopButton = loading ? /* @__PURE__ */ jsx(InputGroupButton, {
|
|
1612
|
+
variant: "secondary",
|
|
1613
|
+
size: "icon",
|
|
1614
|
+
className: "rounded-full",
|
|
1615
|
+
"aria-label": t("chatbotInput.stopGenerating"),
|
|
1616
|
+
disabled,
|
|
1617
|
+
onClick: onStop,
|
|
1618
|
+
children: /* @__PURE__ */ jsx(Square, {})
|
|
1619
|
+
}) : /* @__PURE__ */ jsx(InputGroupButton, {
|
|
1620
|
+
variant: hasValue ? "default" : "ghost",
|
|
1621
|
+
size: "icon",
|
|
1622
|
+
className: "rounded-full",
|
|
1623
|
+
"aria-label": t("chatbotInput.sendMessage"),
|
|
1624
|
+
disabled: disabled || !hasValue,
|
|
1625
|
+
onClick: submit,
|
|
1626
|
+
children: /* @__PURE__ */ jsx(ArrowUp, {})
|
|
1627
|
+
});
|
|
1628
|
+
const historyButton = conversations !== void 0 ? /* @__PURE__ */ jsxs(Popover, {
|
|
1629
|
+
open: historyOpen,
|
|
1630
|
+
onOpenChange: setHistoryOpen,
|
|
1631
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, { render: /* @__PURE__ */ jsx(Button, {
|
|
1632
|
+
variant: "ghost",
|
|
1633
|
+
size: "icon",
|
|
1634
|
+
disabled,
|
|
1635
|
+
"aria-label": t("chatbotInput.conversationHistory"),
|
|
1636
|
+
children: /* @__PURE__ */ jsx(History, {})
|
|
1637
|
+
}) }), /* @__PURE__ */ jsx(PopoverContent, {
|
|
1638
|
+
align: "end",
|
|
1639
|
+
sideOffset: 4,
|
|
1640
|
+
className: "w-80 gap-0 p-0",
|
|
1641
|
+
children: conversations.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
1642
|
+
className: "px-4 py-6 text-center text-sm text-muted-foreground",
|
|
1643
|
+
children: t("chatbotInput.noConversations")
|
|
1644
|
+
}) : /* @__PURE__ */ jsx(SidebarProvider, {
|
|
1645
|
+
className: "!min-h-0",
|
|
1646
|
+
style: { "--sidebar-width": "20rem" },
|
|
1647
|
+
children: /* @__PURE__ */ jsx(ChatbotSidebar, {
|
|
1648
|
+
popup: true,
|
|
1649
|
+
showNewChat: false,
|
|
1650
|
+
recentLabel: t("chatbotInput.recentChatHistory"),
|
|
1651
|
+
className: "bg-sidebar [&_[data-slot=sidebar-content]]:gap-0 [&_[data-slot=sidebar-content]]:max-h-[280px]",
|
|
1652
|
+
conversations,
|
|
1653
|
+
activeConversationId,
|
|
1654
|
+
onSelectConversation: (id) => {
|
|
1655
|
+
onSelectConversation?.(id);
|
|
1656
|
+
setHistoryOpen(false);
|
|
1657
|
+
}
|
|
1658
|
+
})
|
|
1659
|
+
})
|
|
1660
|
+
})]
|
|
1661
|
+
}) : null;
|
|
1582
1662
|
return /* @__PURE__ */ jsxs(InputGroup, {
|
|
1583
1663
|
"data-slot": "chatbot-input",
|
|
1584
1664
|
"data-loading": loading || void 0,
|
|
1585
|
-
className: cn("h-auto
|
|
1665
|
+
className: cn("h-auto gap-2 overflow-clip rounded-3xl bg-background py-2 pr-2 pl-6", hasBottomRow ? "w-fit flex-col items-stretch" : "items-end", "shadow-[0px_0px_8px_0px_var(--input)]", "hover:shadow-[0px_0px_8px_0px_var(--ring)]", "has-[[data-slot=input-group-control]:focus-visible]:border-green-400", "has-[[data-slot=input-group-control]:focus-visible]:ring-0", "has-[[data-slot=input-group-control]:focus-visible]:shadow-[0px_0px_8px_0px_var(--ring)]", className),
|
|
1586
1666
|
"aria-disabled": disabled || void 0,
|
|
1587
1667
|
children: [/* @__PURE__ */ jsx(InputGroupTextarea, {
|
|
1588
1668
|
rows: 1,
|
|
@@ -1597,40 +1677,27 @@ function ChatbotInput({ className, value, onValueChange, onSubmit, onStop, place
|
|
|
1597
1677
|
size,
|
|
1598
1678
|
expanded
|
|
1599
1679
|
}))
|
|
1600
|
-
}), /* @__PURE__ */
|
|
1680
|
+
}), hasBottomRow ? /* @__PURE__ */ jsxs("div", {
|
|
1681
|
+
className: "flex items-center justify-between gap-2",
|
|
1682
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1683
|
+
className: "flex gap-2",
|
|
1684
|
+
children: hasSuggestions && suggestions.map((s) => /* @__PURE__ */ jsx(ChatbotPanelSuggestion, {
|
|
1685
|
+
className: "max-w-none shrink-0 whitespace-nowrap",
|
|
1686
|
+
disabled,
|
|
1687
|
+
onClick: () => onSuggestionClick?.(s),
|
|
1688
|
+
children: s.label
|
|
1689
|
+
}, s.id))
|
|
1690
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1691
|
+
className: "flex items-center gap-2",
|
|
1692
|
+
children: [historyButton, sendStopButton]
|
|
1693
|
+
})]
|
|
1694
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
1601
1695
|
className: "flex shrink-0 items-center gap-2",
|
|
1602
|
-
children:
|
|
1603
|
-
variant: "secondary",
|
|
1604
|
-
size: "icon",
|
|
1605
|
-
className: "rounded-full",
|
|
1606
|
-
"aria-label": t("chatbotInput.stopGenerating"),
|
|
1607
|
-
disabled,
|
|
1608
|
-
onClick: onStop,
|
|
1609
|
-
children: /* @__PURE__ */ jsx(Square, {})
|
|
1610
|
-
}) : /* @__PURE__ */ jsx(InputGroupButton, {
|
|
1611
|
-
variant: hasValue ? "default" : "ghost",
|
|
1612
|
-
size: "icon",
|
|
1613
|
-
className: "rounded-full",
|
|
1614
|
-
"aria-label": t("chatbotInput.sendMessage"),
|
|
1615
|
-
disabled: disabled || !hasValue,
|
|
1616
|
-
onClick: submit,
|
|
1617
|
-
children: /* @__PURE__ */ jsx(ArrowUp, {})
|
|
1618
|
-
})
|
|
1696
|
+
children: sendStopButton
|
|
1619
1697
|
})]
|
|
1620
1698
|
});
|
|
1621
1699
|
}
|
|
1622
1700
|
|
|
1623
|
-
//#endregion
|
|
1624
|
-
//#region src/components/chatbot-panel-suggestion.tsx
|
|
1625
|
-
function ChatbotPanelSuggestion({ className, ...props }) {
|
|
1626
|
-
return /* @__PURE__ */ jsx(Button, {
|
|
1627
|
-
"data-slot": "chatbot-panel-suggestion",
|
|
1628
|
-
variant: "ghost",
|
|
1629
|
-
className: cn("h-auto max-w-[280px] text-left rounded-[18px] border border-primary px-3 py-1.5", "bg-background text-primary whitespace-normal", "hover:bg-[color-mix(in_srgb,#5BF1B2_20%,var(--background))] hover:text-primary", className),
|
|
1630
|
-
...props
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
1701
|
//#endregion
|
|
1635
1702
|
//#region src/components/chatbot-user-message.tsx
|
|
1636
1703
|
function ChatbotUserMessage({ className, children, ...props }) {
|
|
@@ -2366,7 +2433,7 @@ function toFieldErrors(errors) {
|
|
|
2366
2433
|
|
|
2367
2434
|
//#endregion
|
|
2368
2435
|
//#region src/components/form-field.tsx
|
|
2369
|
-
function FormFieldShell({ label, description, necessityIndicator, children }) {
|
|
2436
|
+
function FormFieldShell({ label, description, necessityIndicator, id, children }) {
|
|
2370
2437
|
const errors = useFieldContext().state.meta.errors;
|
|
2371
2438
|
const labelContent = typeof label === "string" ? label : label?.content;
|
|
2372
2439
|
const labelInfo = typeof label === "object" ? label.info : void 0;
|
|
@@ -2376,6 +2443,7 @@ function FormFieldShell({ label, description, necessityIndicator, children }) {
|
|
|
2376
2443
|
const descriptionVariant = (typeof description === "object" ? description.variant : void 0) ?? "instructional";
|
|
2377
2444
|
const labelNode = labelContent !== void 0 && /* @__PURE__ */ jsx(FieldLabel, {
|
|
2378
2445
|
necessityIndicator,
|
|
2446
|
+
htmlFor: id,
|
|
2379
2447
|
children: labelContent
|
|
2380
2448
|
});
|
|
2381
2449
|
const labelRow = labelContent !== void 0 && (hasAddons ? /* @__PURE__ */ jsxs(FieldLabelRow, { children: [
|
|
@@ -2405,6 +2473,7 @@ function FormFieldShell({ label, description, necessityIndicator, children }) {
|
|
|
2405
2473
|
*/
|
|
2406
2474
|
function FormFieldBase(props) {
|
|
2407
2475
|
const { form, name, validators, listeners, defaultValue, asyncDebounceMs, asyncAlways, label, description, necessityIndicator, buildControl, children } = props;
|
|
2476
|
+
const id = `${React.useId()}-${name}`;
|
|
2408
2477
|
const AppField = form.AppField;
|
|
2409
2478
|
return /* @__PURE__ */ jsx(AppField, {
|
|
2410
2479
|
name,
|
|
@@ -2417,20 +2486,22 @@ function FormFieldBase(props) {
|
|
|
2417
2486
|
label,
|
|
2418
2487
|
description,
|
|
2419
2488
|
necessityIndicator,
|
|
2420
|
-
|
|
2489
|
+
id,
|
|
2490
|
+
children: children(field, buildControl(field, id))
|
|
2421
2491
|
})
|
|
2422
2492
|
});
|
|
2423
2493
|
}
|
|
2424
2494
|
|
|
2425
2495
|
//#endregion
|
|
2426
2496
|
//#region src/components/form-select-field.tsx
|
|
2427
|
-
function selectControl(field) {
|
|
2497
|
+
function selectControl(field, id) {
|
|
2428
2498
|
return {
|
|
2429
2499
|
selectProps: {
|
|
2430
2500
|
value: field.state.value || null,
|
|
2431
2501
|
onValueChange: (value) => field.handleChange(value ?? "")
|
|
2432
2502
|
},
|
|
2433
2503
|
selectTriggerProps: {
|
|
2504
|
+
id,
|
|
2434
2505
|
onBlur: field.handleBlur,
|
|
2435
2506
|
"aria-invalid": field.state.meta.errors.length > 0 ? true : void 0
|
|
2436
2507
|
}
|
|
@@ -2463,8 +2534,9 @@ function FormSelectField(props) {
|
|
|
2463
2534
|
|
|
2464
2535
|
//#endregion
|
|
2465
2536
|
//#region src/components/form-input-field.tsx
|
|
2466
|
-
function inputControl(field) {
|
|
2537
|
+
function inputControl(field, id) {
|
|
2467
2538
|
return { inputProps: {
|
|
2539
|
+
id,
|
|
2468
2540
|
value: field.state.value ?? "",
|
|
2469
2541
|
onChange: (event) => field.handleChange(event.target.value),
|
|
2470
2542
|
onBlur: field.handleBlur,
|
|
@@ -2490,13 +2562,14 @@ function FormInputField(props) {
|
|
|
2490
2562
|
|
|
2491
2563
|
//#endregion
|
|
2492
2564
|
//#region src/components/form-combobox-field.tsx
|
|
2493
|
-
function comboboxControl(field) {
|
|
2565
|
+
function comboboxControl(field, id) {
|
|
2494
2566
|
return {
|
|
2495
2567
|
comboboxProps: {
|
|
2496
2568
|
value: field.state.value || null,
|
|
2497
2569
|
onValueChange: (value) => field.handleChange(value ?? "")
|
|
2498
2570
|
},
|
|
2499
2571
|
comboboxInputProps: {
|
|
2572
|
+
id,
|
|
2500
2573
|
onBlur: field.handleBlur,
|
|
2501
2574
|
"aria-invalid": field.state.meta.errors.length > 0 ? true : void 0
|
|
2502
2575
|
}
|
|
@@ -2530,13 +2603,14 @@ function FormComboboxField(props) {
|
|
|
2530
2603
|
|
|
2531
2604
|
//#endregion
|
|
2532
2605
|
//#region src/components/form-multi-combobox-field.tsx
|
|
2533
|
-
function multiComboboxControl(field) {
|
|
2606
|
+
function multiComboboxControl(field, id) {
|
|
2534
2607
|
return {
|
|
2535
2608
|
comboboxProps: {
|
|
2536
2609
|
value: field.state.value ?? [],
|
|
2537
2610
|
onValueChange: (values) => field.handleChange(values)
|
|
2538
2611
|
},
|
|
2539
2612
|
comboboxInputProps: {
|
|
2613
|
+
id,
|
|
2540
2614
|
onBlur: field.handleBlur,
|
|
2541
2615
|
"aria-invalid": field.state.meta.errors.length > 0 ? true : void 0
|
|
2542
2616
|
}
|
|
@@ -2594,6 +2668,7 @@ function FormMultiComboboxField(props) {
|
|
|
2594
2668
|
*/
|
|
2595
2669
|
function FormArrayField(props) {
|
|
2596
2670
|
const { form, name, validators, listeners, defaultValue, asyncDebounceMs, asyncAlways, label, description, necessityIndicator, children } = props;
|
|
2671
|
+
const id = `${React.useId()}-${name}`;
|
|
2597
2672
|
const AppField = form.AppField;
|
|
2598
2673
|
return /* @__PURE__ */ jsx(AppField, {
|
|
2599
2674
|
name,
|
|
@@ -2607,6 +2682,7 @@ function FormArrayField(props) {
|
|
|
2607
2682
|
label,
|
|
2608
2683
|
description,
|
|
2609
2684
|
necessityIndicator,
|
|
2685
|
+
id,
|
|
2610
2686
|
children: children(field)
|
|
2611
2687
|
})
|
|
2612
2688
|
});
|
|
@@ -2614,8 +2690,9 @@ function FormArrayField(props) {
|
|
|
2614
2690
|
|
|
2615
2691
|
//#endregion
|
|
2616
2692
|
//#region src/components/form-textarea-field.tsx
|
|
2617
|
-
function textareaControl(field) {
|
|
2693
|
+
function textareaControl(field, id) {
|
|
2618
2694
|
return { textareaProps: {
|
|
2695
|
+
id,
|
|
2619
2696
|
value: field.state.value ?? "",
|
|
2620
2697
|
onChange: (event) => field.handleChange(event.target.value),
|
|
2621
2698
|
onBlur: field.handleBlur,
|
|
@@ -2641,7 +2718,7 @@ function FormTextareaField(props) {
|
|
|
2641
2718
|
|
|
2642
2719
|
//#endregion
|
|
2643
2720
|
//#region src/components/form-radio-group-field.tsx
|
|
2644
|
-
function radioGroupControl(field) {
|
|
2721
|
+
function radioGroupControl(field, _id) {
|
|
2645
2722
|
return { radioGroupProps: {
|
|
2646
2723
|
value: field.state.value || null,
|
|
2647
2724
|
onValueChange: (value) => field.handleChange(value ?? ""),
|
|
@@ -2672,8 +2749,9 @@ function FormRadioGroupField(props) {
|
|
|
2672
2749
|
|
|
2673
2750
|
//#endregion
|
|
2674
2751
|
//#region src/components/form-otp-field.tsx
|
|
2675
|
-
function otpControl(field) {
|
|
2752
|
+
function otpControl(field, id) {
|
|
2676
2753
|
return { otpProps: {
|
|
2754
|
+
id,
|
|
2677
2755
|
value: field.state.value ?? "",
|
|
2678
2756
|
onChange: (value) => field.handleChange(value),
|
|
2679
2757
|
onBlur: field.handleBlur,
|
|
@@ -2699,8 +2777,9 @@ function FormOTPField(props) {
|
|
|
2699
2777
|
|
|
2700
2778
|
//#endregion
|
|
2701
2779
|
//#region src/components/form-switch-field.tsx
|
|
2702
|
-
function switchControl(field) {
|
|
2780
|
+
function switchControl(field, id) {
|
|
2703
2781
|
return { switchProps: {
|
|
2782
|
+
id,
|
|
2704
2783
|
checked: field.state.value,
|
|
2705
2784
|
onCheckedChange: (checked) => field.handleChange(checked),
|
|
2706
2785
|
onBlur: field.handleBlur,
|
|
@@ -2726,8 +2805,9 @@ function FormSwitchField(props) {
|
|
|
2726
2805
|
|
|
2727
2806
|
//#endregion
|
|
2728
2807
|
//#region src/components/form-numeric-field.tsx
|
|
2729
|
-
function numericControl(field) {
|
|
2808
|
+
function numericControl(field, id) {
|
|
2730
2809
|
return { numericProps: {
|
|
2810
|
+
id,
|
|
2731
2811
|
value: field.state.value,
|
|
2732
2812
|
onValueChange: (value) => field.handleChange(value ?? 0),
|
|
2733
2813
|
onBlur: field.handleBlur,
|
|
@@ -2753,10 +2833,11 @@ function FormNumericField(props) {
|
|
|
2753
2833
|
|
|
2754
2834
|
//#endregion
|
|
2755
2835
|
//#region src/components/form-slider-field.tsx
|
|
2756
|
-
function sliderControl(field) {
|
|
2836
|
+
function sliderControl(field, id) {
|
|
2757
2837
|
return { sliderProps: {
|
|
2838
|
+
id,
|
|
2758
2839
|
value: [field.state.value],
|
|
2759
|
-
onValueChange: (
|
|
2840
|
+
onValueChange: (value) => field.handleChange(Array.isArray(value) ? value[0] ?? 0 : value),
|
|
2760
2841
|
onBlur: field.handleBlur
|
|
2761
2842
|
} };
|
|
2762
2843
|
}
|
|
@@ -2779,7 +2860,7 @@ function FormSliderField(props) {
|
|
|
2779
2860
|
|
|
2780
2861
|
//#endregion
|
|
2781
2862
|
//#region src/components/form-toggle-group-field.tsx
|
|
2782
|
-
function toggleGroupControl(field) {
|
|
2863
|
+
function toggleGroupControl(field, _id) {
|
|
2783
2864
|
return { toggleGroupProps: {
|
|
2784
2865
|
value: field.state.value ? [field.state.value] : [],
|
|
2785
2866
|
onValueChange: (values) => field.handleChange(values[values.length - 1] ?? null),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aircall/blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": [
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"vite": "7.3.1",
|
|
82
82
|
"vitest": "4.0.17",
|
|
83
83
|
"zod": "4.4.3",
|
|
84
|
-
"@aircall/ds": "0.
|
|
84
|
+
"@aircall/ds": "0.19.0",
|
|
85
85
|
"@aircall/hooks": "0.5.1"
|
|
86
86
|
},
|
|
87
87
|
"keywords": [
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"build:js": "tsdown --config ./tsdown.config.ts",
|
|
98
98
|
"build:css": "tailwindcss -i ./src/styles/globals.css -o ./dist/globals.css --minify",
|
|
99
99
|
"build:package": "pnpm run build:js && pnpm run build:css",
|
|
100
|
-
"typecheck": "tsc --noEmit",
|
|
100
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.strict.json",
|
|
101
101
|
"lint": "eslint . --max-warnings 0",
|
|
102
102
|
"sb:dev": "storybook dev -p 6009",
|
|
103
103
|
"sb:build": "storybook build",
|