@aircall/blocks 0.10.0 → 0.11.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/index.d.ts CHANGED
@@ -121,6 +121,33 @@ declare function ChatbotResponseBlock({
121
121
  className
122
122
  }: ChatbotResponseBlockProps): react_jsx_runtime0.JSX.Element;
123
123
  //#endregion
124
+ //#region src/components/chatbot-response-loading.d.ts
125
+ interface ChatbotResponseLoadingProps {
126
+ /**
127
+ * Text shown next to the animation while the response is being generated.
128
+ * Defaults to the i18n translation of "Thinking...".
129
+ */
130
+ text?: string;
131
+ className?: string;
132
+ }
133
+ /**
134
+ * Loading indicator rendered inside `ChatbotPageConversation` while the backend
135
+ * is still streaming a response. Shows the Aircall animated logo next to a
136
+ * customisable shimmer text label.
137
+ *
138
+ * @example
139
+ * ```tsx
140
+ * <ChatbotPageConversation>
141
+ * <ChatbotUserMessage>How do I set my phone line?</ChatbotUserMessage>
142
+ * {isLoading && <ChatbotResponseLoading text="Thinking..." />}
143
+ * </ChatbotPageConversation>
144
+ * ```
145
+ */
146
+ declare function ChatbotResponseLoading({
147
+ text,
148
+ className
149
+ }: ChatbotResponseLoadingProps): react_jsx_runtime0.JSX.Element;
150
+ //#endregion
124
151
  //#region src/components/chatbot-page.d.ts
125
152
  declare const ChatbotPage: React$1.ForwardRefExoticComponent<ChatbotPageProps & React$1.RefAttributes<HTMLDivElement>>;
126
153
  interface ChatbotPageProps {
@@ -224,7 +251,12 @@ declare namespace ChatbotPageFooter {
224
251
  * ```
225
252
  */
226
253
  declare const ChatbotPageConversation: React$1.ForwardRefExoticComponent<Omit<ChatbotPageConversationProps, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
227
- interface ChatbotPageConversationProps extends React$1.ComponentProps<'div'> {}
254
+ interface ChatbotPageConversationProps extends React$1.ComponentProps<'div'> {
255
+ /** When true, renders the animated loading indicator after the last message. */
256
+ loading?: boolean;
257
+ /** Label shown next to the loading animation. Defaults to "Thinking…". */
258
+ loadingText?: string;
259
+ }
228
260
  declare namespace ChatbotPageConversation {
229
261
  type Props = ChatbotPageConversationProps;
230
262
  }
@@ -627,8 +659,11 @@ type ChatbotPanelProps = Omit<React$1.ComponentProps<'div'>, 'title' | 'onSubmit
627
659
  inputValue?: string; /** Fires as the composer value changes. */
628
660
  onInputValueChange?: (value: string) => void; /** Fires when the composer is submitted (Enter or send button). */
629
661
  onSubmit?: (value: string) => void; /** Fires when the stop button is pressed while `loading`. */
630
- onStop?: () => void; /** Shows the stop button instead of send. */
631
- loading?: boolean; /** Composer placeholder. */
662
+ onStop?: () => void;
663
+ /** Shows the stop button instead of send and renders the loading indicator
664
+ * at the bottom of the active conversation. */
665
+ loading?: boolean; /** Label shown next to the loading animation. Defaults to "Thinking…". */
666
+ loadingText?: string; /** Composer placeholder. */
632
667
  placeholder?: string;
633
668
  /**
634
669
  * Focus the composer when the panel mounts. Use this when the panel is
@@ -662,6 +697,7 @@ declare function ChatbotPanel({
662
697
  onSubmit,
663
698
  onStop,
664
699
  loading,
700
+ loadingText,
665
701
  placeholder,
666
702
  autoFocus,
667
703
  disclaimer,
@@ -1327,6 +1363,18 @@ declare const withForm: <TFormData, TOnMount extends _tanstack_react_form0.FormV
1327
1363
  declare const fieldContext: React$1.Context<_tanstack_react_form0.AnyFieldApi>, formContext: React$1.Context<_tanstack_react_form0.AnyFormApi>, useFieldContext: <TData>() => _tanstack_react_form0.FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>, useFormContext: () => _tanstack_react_form0.ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>;
1328
1364
  //#endregion
1329
1365
  //#region src/components/form-field.d.ts
1366
+ type FormFieldShellProps = {
1367
+ label?: string;
1368
+ description?: string;
1369
+ necessityIndicator?: 'required' | 'optional';
1370
+ children: React$1.ReactNode;
1371
+ };
1372
+ declare function FormFieldShell({
1373
+ label,
1374
+ description,
1375
+ necessityIndicator,
1376
+ children
1377
+ }: FormFieldShellProps): react_jsx_runtime0.JSX.Element;
1330
1378
  /**
1331
1379
  * Precisely-typed view of the bound field handed to a wrapper's `children`.
1332
1380
  * `TData` is `DeepValue<TFormData, TName>` — so `value` and `handleChange` are the field's
@@ -1380,12 +1428,11 @@ type FormFieldValidators<TFormData, TName> = TName extends DeepKeys<TFormData> ?
1380
1428
  * The full `AppField` binding surface every wrapper forwards, typed against the field's value.
1381
1429
  *
1382
1430
  * This is the **single source of truth** for which `form.AppField` props the `Form*Field` wrappers
1383
- * pass through — spread it into each wrapper's props so the set can't drift per-wrapper. The
1384
- * `app-field-coverage` type test asserts this stays in sync with `AppField`'s real prop surface:
1385
- * every `AppField` prop must be forwarded here or appear in that test's explicit omission list.
1431
+ * pass through — spread it into each wrapper's props so the set can't drift per-wrapper.
1386
1432
  *
1387
1433
  * Forwarded: `validators`, `listeners`, `defaultValue`, `asyncDebounceMs`, `asyncAlways`.
1388
- * Deliberately omitted (see the coverage test): `name`/`children` (owned by the wrapper),
1434
+ * Deliberately omitted: `name`/`children` (owned by the wrapper), `mode` (owned by `FormArrayField`,
1435
+ * which is the only wrapper that drives an `AppField` in `mode="array"`), and
1389
1436
  * `defaultMeta`/`disableErrorFlat` (advanced escape hatches that fight the shared shell).
1390
1437
  */
1391
1438
  type FieldBindingProps<TFormData, TName> = TName extends DeepKeys<TFormData> ? {
@@ -1396,13 +1443,13 @@ type FieldBindingProps<TFormData, TName> = TName extends DeepKeys<TFormData> ? {
1396
1443
  asyncAlways?: boolean;
1397
1444
  } : never;
1398
1445
  /**
1399
- * Presentational necessity props every wrapper exposes, forwarded to the DS `FieldLabel` to mark a
1400
- * field required/optional in the label. Enforcement stays in `validators` — this is label-only.
1401
- * Shared so the set can't drift per-wrapper.
1446
+ * Presentational necessity prop every wrapper exposes, forwarded to the DS `FieldLabel`. Follows
1447
+ * the "mark the exceptions" convention: tag only the minority necessity in a form (`'optional'` in
1448
+ * a mostly-mandatory form, `'required'` in a mostly-optional one), never both. Label-only —
1449
+ * enforcement stays in `validators`. Shared so the set can't drift per-wrapper.
1402
1450
  */
1403
1451
  type NecessityProps = {
1404
- required?: boolean;
1405
- necessityIndicator?: 'icon' | 'label';
1452
+ necessityIndicator?: 'required' | 'optional';
1406
1453
  };
1407
1454
  type FormFieldBaseProps<TData, TControl> = {
1408
1455
  form: Pick<BoundForm, 'AppField'>;
@@ -1414,8 +1461,7 @@ type FormFieldBaseProps<TData, TControl> = {
1414
1461
  asyncAlways?: boolean;
1415
1462
  label?: string;
1416
1463
  description?: string;
1417
- required?: boolean;
1418
- necessityIndicator?: 'icon' | 'label'; /** Builds the primitive-specific wiring bundle handed to `children`. */
1464
+ necessityIndicator?: 'required' | 'optional'; /** Builds the primitive-specific wiring bundle handed to `children`. */
1419
1465
  buildControl: (field: TypedField<TData>) => TControl;
1420
1466
  children: (field: TypedField<TData>, control: TControl) => React$1.ReactNode;
1421
1467
  };
@@ -1584,6 +1630,80 @@ type FormMultiComboboxFieldProps<TForm extends BoundForm, TName extends DeepKeys
1584
1630
  */
1585
1631
  declare function FormMultiComboboxField<TForm extends BoundForm, TName extends DeepKeysOfType<TForm['state']['values'], string[]>>(props: FormMultiComboboxFieldProps<TForm, TName>): react_jsx_runtime0.JSX.Element;
1586
1632
  //#endregion
1633
+ //#region src/components/form-array-field.d.ts
1634
+ /**
1635
+ * The element type of the bound array field — `DeepValue<TFormData, TName>` unwrapped one level.
1636
+ * `contacts: { label: string; value: string }[]` ⇒ `{ label: string; value: string }`.
1637
+ */
1638
+ type ArrayItem<TFormData, TName> = DeepValue<TFormData, TName> extends ReadonlyArray<infer TItem> ? TItem : never;
1639
+ /**
1640
+ * Precisely-typed view of an array-mode field handed to a `FormArrayField` child.
1641
+ *
1642
+ * Unlike the single-control `TypedField`, this exposes TanStack's array mutators (kept under their
1643
+ * native names so it's a transparent pass-through of `form.AppField` in `mode="array"`). The
1644
+ * `options?` argument each mutator also accepts upstream is intentionally elided — the common path
1645
+ * is index/value only; reach for `form.AppField` directly if you need it.
1646
+ *
1647
+ * Children read `state.value` to map over the rows and render nested `Form*Field`s with **indexed**
1648
+ * names (`contacts[${i}].label`), and call the mutators from add/remove/reorder controls.
1649
+ */
1650
+ type ArrayField<TItem> = {
1651
+ state: {
1652
+ value: TItem[];
1653
+ meta: {
1654
+ errors: readonly unknown[];
1655
+ isTouched: boolean;
1656
+ };
1657
+ }; /** Append `value` to the end of the array. */
1658
+ pushValue: (value: TItem) => void; /** Insert `value` at `index`, shifting later items right. */
1659
+ insertValue: (index: number, value: TItem) => void; /** Replace the item at `index` in place. */
1660
+ replaceValue: (index: number, value: TItem) => void; /** Remove the item at `index`, shifting later items left. */
1661
+ removeValue: (index: number) => void; /** Swap the items at `aIndex` and `bIndex`. */
1662
+ swapValues: (aIndex: number, bIndex: number) => void; /** Move the item at `aIndex` to `bIndex`, shifting the rest to fill. */
1663
+ moveValue: (aIndex: number, bIndex: number) => void; /** Remove every item. */
1664
+ clearValues: () => void; /** Mark the array field touched (e.g. on blur of the whole group). */
1665
+ handleBlur: () => void;
1666
+ };
1667
+ type FormArrayFieldProps<TForm extends BoundForm, TName extends DeepKeysOfType<TForm['state']['values'], unknown[]>> = {
1668
+ /** The form instance from `useForm()` — threaded as a prop so `name`/`validators` are typed. */form: TForm;
1669
+ name: TName;
1670
+ label?: string;
1671
+ description?: string;
1672
+ /**
1673
+ * Render the list. Map over `field.state.value`, render a nested `Form*Field` per row (same
1674
+ * `form`, indexed `name`), and wire add/remove/reorder controls to the array mutators.
1675
+ */
1676
+ children: (field: ArrayField<ArrayItem<TForm['state']['values'], TName>>) => React$1.ReactNode;
1677
+ } & FieldBindingProps<TForm['state']['values'], TName> & NecessityProps;
1678
+ /**
1679
+ * Array field wrapper — drives a `form.AppField` in `mode="array"` and owns the shared
1680
+ * `Field/Label/Description/Error` shell, so an array-level validator (e.g. "add at least one")
1681
+ * surfaces under the list. `name` is restricted to the form's **array** fields, and the child's
1682
+ * `field` is typed to the element type, with TanStack's array mutators (`pushValue`, `removeValue`,
1683
+ * `moveValue`, …) exposed for add/remove/reorder.
1684
+ *
1685
+ * It deliberately has **no control bundle**: an array is a container of rows, not a single input.
1686
+ * Each row is composed from the existing single-control wrappers with an indexed `name`.
1687
+ *
1688
+ * @example
1689
+ * <FormArrayField form={form} name="webhooks" label="Webhooks" description="Endpoints to notify">
1690
+ * {field => (
1691
+ * <>
1692
+ * {field.state.value.map((_row, i) => (
1693
+ * <div key={i} className="flex items-end gap-2">
1694
+ * <FormInputField form={form} name={`webhooks[${i}].url`} label="URL">
1695
+ * {(_f, { inputProps }) => <Input {...inputProps} placeholder="https://…" />}
1696
+ * </FormInputField>
1697
+ * <Button variant="ghost" onClick={() => field.removeValue(i)}>Remove</Button>
1698
+ * </div>
1699
+ * ))}
1700
+ * <Button variant="outline" onClick={() => field.pushValue({ url: '' })}>Add webhook</Button>
1701
+ * </>
1702
+ * )}
1703
+ * </FormArrayField>
1704
+ */
1705
+ declare function FormArrayField<TForm extends BoundForm, TName extends DeepKeysOfType<TForm['state']['values'], unknown[]>>(props: FormArrayFieldProps<TForm, TName>): react_jsx_runtime0.JSX.Element;
1706
+ //#endregion
1587
1707
  //#region src/components/form-textarea-field.d.ts
1588
1708
  /**
1589
1709
  * Wiring bundle handed to a `FormTextareaField` child. Spread `textareaProps` onto a DS
@@ -2047,4 +2167,4 @@ declare namespace DashboardSidebarSubmenuSeparator {
2047
2167
  type Props = DashboardSidebarSubmenuSeparatorProps;
2048
2168
  }
2049
2169
  //#endregion
2050
- export { BetaBadge, type BoundForm, CardSaveBar, type CardSaveBarProps, ChatbotExpandSuggestion, type ChatbotExpandSuggestionProps, ChatbotInput, type ChatbotInputProps, ChatbotPage, ChatbotPageBody, type ChatbotPageBodyProps, ChatbotPageContent, type ChatbotPageContentProps, ChatbotPageConversation, type ChatbotPageConversationProps, ChatbotPageFooter, type ChatbotPageFooterProps, ChatbotPageHeading, type ChatbotPageHeadingProps, ChatbotPageInputBar, type ChatbotPageInputBarProps, type ChatbotPageProps, ChatbotPanel, ChatbotPanelHeader, type ChatbotPanelHeaderProps, type ChatbotPanelProps, ChatbotPanelSuggestion, type ChatbotPanelSuggestionItem, type ChatbotPanelSuggestionProps, ChatbotPanelTrigger, type ChatbotPanelTriggerProps, ChatbotResponseBlock, type ChatbotResponseBlockFeedback, type ChatbotResponseBlockProps, ChatbotSidebar, type ChatbotSidebarConversation, ChatbotUserMessage, type ChatbotUserMessageProps, type ComboboxControl, ComingSoonDescription, ComingSoonEmptyState, ComingSoonMedia, ComingSoonTitle, CommonForm, CopyButton, CopyButtonIcon, CopyButtonLabel, DashboardPage, DashboardPageBanner, DashboardPageContent, DashboardPageHeader, DashboardPageHeaderAction, DashboardPageHeaderActions, DashboardPageHeaderDescription, DashboardPageHeaderNav, DashboardPageHeaderNavBack, DashboardPageHeaderPrefix, DashboardPageHeaderSubtitle, DashboardPageHeaderTitle, DashboardPageHeaderTitleGroup, DashboardPageMain, DashboardPageTabs, DashboardSidebar, DashboardSidebarContent, DashboardSidebarFooter, DashboardSidebarGroup, DashboardSidebarGroupLabel, DashboardSidebarHeader, DashboardSidebarMenu, DashboardSidebarMenuBadge, DashboardSidebarMenuButton, DashboardSidebarMenuItem, DashboardSidebarNav, type DashboardSidebarNavGroup, type DashboardSidebarNavItem, type DashboardSidebarNavItemAction, type DashboardSidebarNavItemLink, type DashboardSidebarNavItemSubmenu, type DashboardSidebarNavSubmenuItem, DashboardSidebarProvider, DashboardSidebarSubmenu, DashboardSidebarSubmenuItem, DashboardSidebarSubmenuSeparator, DashboardSidebarTrigger, DashboardStandalonePage, DashboardStandalonePageAction, DashboardStandalonePageActions, DashboardStandalonePageContent, DashboardStandalonePageHeader, DashboardStandalonePageTitle, DeprecatedBadge, EmptyState, EmptyStateActions, EmptyStateButton, EmptyStateDescription, EmptyStateExternalLink, EmptyStateHeader, EmptyStateMedia, EmptyStateTitle, type FieldBindingProps, FormComboboxField, type FormComboboxFieldProps, FormFieldBase, type FormFieldValidators, FormInputField, type FormInputFieldProps, FormMultiComboboxField, type FormMultiComboboxFieldProps, FormNumericField, type FormNumericFieldProps, FormOTPField, type FormOTPFieldProps, FormRadioGroupField, type FormRadioGroupFieldProps, FormSelectField, type FormSelectFieldProps, FormSliderField, type FormSliderFieldProps, FormSwitchField, type FormSwitchFieldProps, FormTextareaField, type FormTextareaFieldProps, FormToggleGroupField, type FormToggleGroupFieldProps, type InputControl, type MultiComboboxControl, type NecessityProps, NewBadge, NoDataDescription, NoDataEmptyState, NoDataMedia, NoDataTitle, NoSupportDescription, NoSupportEmptyState, NoSupportMedia, NoSupportTitle, NotFoundDescription, NotFoundEmptyState, NotFoundMedia, NotFoundTitle, type NumericControl, type OTPControl, ProfessionalBadge, type RadioGroupControl, RestrictedAccessDescription, RestrictedAccessEmptyState, RestrictedAccessMedia, RestrictedAccessTitle, RoleBadge, type RoleBadgeRole, SaveBar, type SaveBarProps, type SelectControl, type SliderControl, SubmitButton, type SubmitButtonProps, type SwitchControl, type TextareaControl, type ToggleGroupControl, TrialBadge, type TypedField, UnknownErrorDescription, UnknownErrorEmptyState, UnknownErrorMedia, UnknownErrorTitle, fieldContext, formContext, toFieldErrors, useCopyToClipboard, useSidebar as useDashboardSidebar, useFieldContext, useForm, useFormContext, withFieldGroup, withForm };
2170
+ export { type ArrayField, type ArrayItem, BetaBadge, type BoundForm, CardSaveBar, type CardSaveBarProps, ChatbotExpandSuggestion, type ChatbotExpandSuggestionProps, ChatbotInput, type ChatbotInputProps, ChatbotPage, ChatbotPageBody, type ChatbotPageBodyProps, ChatbotPageContent, type ChatbotPageContentProps, ChatbotPageConversation, type ChatbotPageConversationProps, ChatbotPageFooter, type ChatbotPageFooterProps, ChatbotPageHeading, type ChatbotPageHeadingProps, ChatbotPageInputBar, type ChatbotPageInputBarProps, type ChatbotPageProps, ChatbotPanel, ChatbotPanelHeader, type ChatbotPanelHeaderProps, type ChatbotPanelProps, ChatbotPanelSuggestion, type ChatbotPanelSuggestionItem, type ChatbotPanelSuggestionProps, ChatbotPanelTrigger, type ChatbotPanelTriggerProps, ChatbotResponseBlock, type ChatbotResponseBlockFeedback, type ChatbotResponseBlockProps, ChatbotResponseLoading, type ChatbotResponseLoadingProps, ChatbotSidebar, type ChatbotSidebarConversation, ChatbotUserMessage, type ChatbotUserMessageProps, type ComboboxControl, ComingSoonDescription, ComingSoonEmptyState, ComingSoonMedia, ComingSoonTitle, CommonForm, CopyButton, CopyButtonIcon, CopyButtonLabel, DashboardPage, DashboardPageBanner, DashboardPageContent, DashboardPageHeader, DashboardPageHeaderAction, DashboardPageHeaderActions, DashboardPageHeaderDescription, DashboardPageHeaderNav, DashboardPageHeaderNavBack, DashboardPageHeaderPrefix, DashboardPageHeaderSubtitle, DashboardPageHeaderTitle, DashboardPageHeaderTitleGroup, DashboardPageMain, DashboardPageTabs, DashboardSidebar, DashboardSidebarContent, DashboardSidebarFooter, DashboardSidebarGroup, DashboardSidebarGroupLabel, DashboardSidebarHeader, DashboardSidebarMenu, DashboardSidebarMenuBadge, DashboardSidebarMenuButton, DashboardSidebarMenuItem, DashboardSidebarNav, type DashboardSidebarNavGroup, type DashboardSidebarNavItem, type DashboardSidebarNavItemAction, type DashboardSidebarNavItemLink, type DashboardSidebarNavItemSubmenu, type DashboardSidebarNavSubmenuItem, DashboardSidebarProvider, DashboardSidebarSubmenu, DashboardSidebarSubmenuItem, DashboardSidebarSubmenuSeparator, DashboardSidebarTrigger, DashboardStandalonePage, DashboardStandalonePageAction, DashboardStandalonePageActions, DashboardStandalonePageContent, DashboardStandalonePageHeader, DashboardStandalonePageTitle, DeprecatedBadge, EmptyState, EmptyStateActions, EmptyStateButton, EmptyStateDescription, EmptyStateExternalLink, EmptyStateHeader, EmptyStateMedia, EmptyStateTitle, type FieldBindingProps, FormArrayField, type FormArrayFieldProps, FormComboboxField, type FormComboboxFieldProps, FormFieldBase, FormFieldShell, type FormFieldShellProps, type FormFieldValidators, FormInputField, type FormInputFieldProps, FormMultiComboboxField, type FormMultiComboboxFieldProps, FormNumericField, type FormNumericFieldProps, FormOTPField, type FormOTPFieldProps, FormRadioGroupField, type FormRadioGroupFieldProps, FormSelectField, type FormSelectFieldProps, FormSliderField, type FormSliderFieldProps, FormSwitchField, type FormSwitchFieldProps, FormTextareaField, type FormTextareaFieldProps, FormToggleGroupField, type FormToggleGroupFieldProps, type InputControl, type MultiComboboxControl, type NecessityProps, NewBadge, NoDataDescription, NoDataEmptyState, NoDataMedia, NoDataTitle, NoSupportDescription, NoSupportEmptyState, NoSupportMedia, NoSupportTitle, NotFoundDescription, NotFoundEmptyState, NotFoundMedia, NotFoundTitle, type NumericControl, type OTPControl, ProfessionalBadge, type RadioGroupControl, RestrictedAccessDescription, RestrictedAccessEmptyState, RestrictedAccessMedia, RestrictedAccessTitle, RoleBadge, type RoleBadgeRole, SaveBar, type SaveBarProps, type SelectControl, type SliderControl, SubmitButton, type SubmitButtonProps, type SwitchControl, type TextareaControl, type ToggleGroupControl, TrialBadge, type TypedField, UnknownErrorDescription, UnknownErrorEmptyState, UnknownErrorMedia, UnknownErrorTitle, fieldContext, formContext, toFieldErrors, useCopyToClipboard, useSidebar as useDashboardSidebar, useFieldContext, useForm, useFormContext, withFieldGroup, withForm };