@tylertech/forge-ai-react 0.2.0 → 0.3.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.
@@ -42,7 +42,7 @@ export interface ForgeAiActionsToolbarProps
42
42
 
43
43
  /** Fired when an action button is clicked. The detail contains the action type. */
44
44
  onForgeAiActionsToolbarAction?: (
45
- event: CustomEvent<CustomEvent<AiActionsToolbarActionEventData>>,
45
+ event: CustomEvent<CustomEvent<ForgeAiActionsToolbarActionEventData>>,
46
46
  ) => void;
47
47
  }
48
48
 
@@ -47,7 +47,7 @@ export interface ForgeAiChatInterfaceProps
47
47
  *
48
48
  *
49
49
  * ### **Methods:**
50
- * - **scrollMessagesToBottom(): _void_** - Scrolls the messages container to the bottom only if user hasn't scrolled up
50
+ * - **scrollToBottom(): _void_** - Scrolls the messages container to the bottom with smooth animation
51
51
  *
52
52
  * ### **Slots:**
53
53
  * - _default_ - Default slot for messages
@@ -54,7 +54,7 @@ export interface ForgeAiFilePickerProps
54
54
 
55
55
  /** Fired when a file is selected via click or drag & drop. The event detail contains the selected file and timestamp. */
56
56
  onForgeAiFilePickerChange?: (
57
- event: CustomEvent<CustomEvent<AiFilePickerChangeEventData>>,
57
+ event: CustomEvent<CustomEvent<ForgeAiFilePickerChangeEventData>>,
58
58
  ) => void;
59
59
  }
60
60
 
@@ -19,10 +19,25 @@ export interface ForgeAiPromptProps
19
19
  | "onFocus"
20
20
  | "onBlur"
21
21
  > {
22
- /** Placeholder text for the input field */
22
+ /** Whether the send button is disabled */
23
+ sendDisabled?: boolean;
24
+
25
+ /** Whether to autofocus the textarea field when the component renders */
26
+ autofocus?: boolean;
27
+
28
+ /** Whether the textarea field is disabled */
29
+ inputDisabled?: boolean;
30
+
31
+ /** Whether to dispatch escape events when Escape key is pressed */
32
+ cancelOnEscape?: boolean;
33
+
34
+ /** Whether the component is in running state (shows stop button instead of send button) */
35
+ running?: boolean;
36
+
37
+ /** Placeholder text for the textarea field */
23
38
  placeholder?: ForgeAiPromptElement["placeholder"];
24
39
 
25
- /** Current value of the input field */
40
+ /** Current value of the textarea field */
26
41
  value?: ForgeAiPromptElement["value"];
27
42
 
28
43
  /** Layout variant for the prompt component */
@@ -49,10 +64,21 @@ export interface ForgeAiPromptProps
49
64
  /** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
50
65
  tabIndex?: number;
51
66
 
52
- /** Fired when the send button is clicked or Enter is pressed. */
67
+ /** Fired when the send button is clicked or Enter is pressed (without Shift). Cancelable - if cancelled, running state is not set and input is not cleared. */
53
68
  onForgeAiPromptSend?: (
54
- event: CustomEvent<CustomEvent<AiPromptSendEventData>>,
69
+ event: CustomEvent<CustomEvent<ForgeAiPromptSendEventData>>,
55
70
  ) => void;
71
+
72
+ /** Fired when the Escape key is pressed (if cancelOnEscape is true). */
73
+ onForgeAiPromptCancel?: (event: CustomEvent<CustomEvent<void>>) => void;
74
+
75
+ /** Fired when files are pasted into the textarea. */
76
+ onForgeAiPromptAttachment?: (
77
+ event: CustomEvent<CustomEvent<ForgeAiPromptAttachmentEventData>>,
78
+ ) => void;
79
+
80
+ /** Fired when the stop button is clicked. Cancelable - if cancelled, running state remains true. */
81
+ onForgeAiPromptStop?: (event: CustomEvent<CustomEvent<void>>) => void;
56
82
  }
57
83
 
58
84
  /**
@@ -61,7 +87,13 @@ export interface ForgeAiPromptProps
61
87
  *
62
88
  *
63
89
  * ### **Events:**
64
- * - **forge-ai-prompt-send** - Fired when the send button is clicked or Enter is pressed.
90
+ * - **forge-ai-prompt-send** - Fired when the send button is clicked or Enter is pressed (without Shift). Cancelable - if cancelled, running state is not set and input is not cleared.
91
+ * - **forge-ai-prompt-cancel** - Fired when the Escape key is pressed (if cancelOnEscape is true).
92
+ * - **forge-ai-prompt-attachment** - Fired when files are pasted into the textarea.
93
+ * - **forge-ai-prompt-stop** - Fired when the stop button is clicked. Cancelable - if cancelled, running state remains true.
94
+ *
95
+ * ### **Methods:**
96
+ * - **focus(): _void_** - Focuses the textarea element
65
97
  *
66
98
  * ### **Slots:**
67
99
  * - **actions** - Slot for action components that are hidden in inline mode (voice input, file picker, model selectors, web search, etc.)
@@ -4,10 +4,27 @@ import { useEventListener } from "./react-utils.js";
4
4
 
5
5
  export const ForgeAiPrompt = forwardRef((props, forwardedRef) => {
6
6
  const ref = useRef(null);
7
- const { placeholder, value, variant, ...filteredProps } = props;
7
+ const {
8
+ sendDisabled,
9
+ autofocus,
10
+ inputDisabled,
11
+ cancelOnEscape,
12
+ running,
13
+ placeholder,
14
+ value,
15
+ variant,
16
+ ...filteredProps
17
+ } = props;
8
18
 
9
19
  /** Event listeners - run once */
10
20
  useEventListener(ref, "forge-ai-prompt-send", props.onForgeAiPromptSend);
21
+ useEventListener(ref, "forge-ai-prompt-cancel", props.onForgeAiPromptCancel);
22
+ useEventListener(
23
+ ref,
24
+ "forge-ai-prompt-attachment",
25
+ props.onForgeAiPromptAttachment,
26
+ );
27
+ useEventListener(ref, "forge-ai-prompt-stop", props.onForgeAiPromptStop);
11
28
 
12
29
  return React.createElement(
13
30
  "forge-ai-prompt",
@@ -29,6 +46,11 @@ export const ForgeAiPrompt = forwardRef((props, forwardedRef) => {
29
46
  for: props.htmlFor,
30
47
  part: props.part,
31
48
  tabindex: props.tabIndex,
49
+ "send-disabled": props.sendDisabled ? true : undefined,
50
+ autofocus: props.autofocus ? true : undefined,
51
+ "input-disabled": props.inputDisabled ? true : undefined,
52
+ "cancel-on-escape": props.cancelOnEscape ? true : undefined,
53
+ running: props.running ? true : undefined,
32
54
  style: { ...props.style },
33
55
  },
34
56
  props.children,
@@ -42,7 +42,7 @@ export interface ForgeAiResponseMessageProps
42
42
 
43
43
  /** Fired when an action button is clicked. */
44
44
  onForgeAiResponseMessageAction?: (
45
- event: CustomEvent<CustomEvent<AiResponseMessageActionEventData>>,
45
+ event: CustomEvent<CustomEvent<ForgeAiResponseMessageActionEventData>>,
46
46
  ) => void;
47
47
  }
48
48
 
@@ -19,9 +19,6 @@ export interface ForgeAiSuggestionsProps
19
19
  | "onFocus"
20
20
  | "onBlur"
21
21
  > {
22
- /** Array of suggestion objects to display */
23
- suggestions?: ForgeAiSuggestionsElement["suggestions"];
24
-
25
22
  /** Display variant for suggestions layout */
26
23
  variant?: ForgeAiSuggestionsElement["variant"];
27
24
 
@@ -46,9 +43,12 @@ export interface ForgeAiSuggestionsProps
46
43
  /** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
47
44
  tabIndex?: number;
48
45
 
46
+ /** Array of suggestion objects to display */
47
+ suggestions?: ForgeAiSuggestionsElement["suggestions"];
48
+
49
49
  /** Fired when a suggestion is selected. */
50
50
  onForgeAiSuggestionsSelect?: (
51
- event: CustomEvent<CustomEvent<AiSuggestionsEventData>>,
51
+ event: CustomEvent<CustomEvent<ForgeAiSuggestionsEventData>>,
52
52
  ) => void;
53
53
  }
54
54
 
@@ -1,10 +1,10 @@
1
1
  import React, { forwardRef, useRef, useEffect } from "react";
2
2
  import "@tylertech/forge-ai/ai-suggestions";
3
- import { useEventListener } from "./react-utils.js";
3
+ import { useEventListener, useProperties } from "./react-utils.js";
4
4
 
5
5
  export const ForgeAiSuggestions = forwardRef((props, forwardedRef) => {
6
6
  const ref = useRef(null);
7
- const { suggestions, variant, ...filteredProps } = props;
7
+ const { variant, suggestions, ...filteredProps } = props;
8
8
 
9
9
  /** Event listeners - run once */
10
10
  useEventListener(
@@ -13,6 +13,9 @@ export const ForgeAiSuggestions = forwardRef((props, forwardedRef) => {
13
13
  props.onForgeAiSuggestionsSelect,
14
14
  );
15
15
 
16
+ /** Properties - run whenever a property has changed */
17
+ useProperties(ref, "suggestions", props.suggestions);
18
+
16
19
  return React.createElement(
17
20
  "forge-ai-suggestions",
18
21
  {
@@ -25,7 +28,6 @@ export const ForgeAiSuggestions = forwardRef((props, forwardedRef) => {
25
28
  }
26
29
  },
27
30
  ...filteredProps,
28
- suggestions: props.suggestions,
29
31
  variant: props.variant,
30
32
  class: props.className,
31
33
  exportparts: props.exportparts,
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import { ForgeAiThinkingIndicator as ForgeAiThinkingIndicatorElement } from "@tylertech/forge-ai/ai-thinking-indicator";
3
+
4
+ export type { ForgeAiThinkingIndicatorElement };
5
+
6
+ export interface ForgeAiThinkingIndicatorProps
7
+ extends Pick<
8
+ React.AllHTMLAttributes<HTMLElement>,
9
+ | "children"
10
+ | "dir"
11
+ | "hidden"
12
+ | "id"
13
+ | "lang"
14
+ | "slot"
15
+ | "style"
16
+ | "title"
17
+ | "translate"
18
+ | "onClick"
19
+ | "onFocus"
20
+ | "onBlur"
21
+ > {
22
+ /** A space-separated list of the classes of the element. Classes allows CSS and JavaScript to select and access specific elements via the class selectors or functions like the method `Document.getElementsByClassName()`. */
23
+ className?: string;
24
+
25
+ /** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
26
+ exportparts?: string;
27
+
28
+ /** Used for labels to link them with their inputs (using input id). */
29
+ htmlFor?: string;
30
+
31
+ /** Used to help React identify which items have changed, are added, or are removed within a list. */
32
+ key?: number | string;
33
+
34
+ /** Contains a space-separated list of the part names of the element. Part names allows CSS to select and style specific elements in a shadow tree via the ::part pseudo-element. */
35
+ part?: string;
36
+
37
+ /** A mutable ref object whose `.current` property is initialized to the passed argument (`initialValue`). The returned object will persist for the full lifetime of the component. */
38
+ ref?: any;
39
+
40
+ /** Allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the `Tab` key, hence the name) and determine their relative ordering for sequential focus navigation. */
41
+ tabIndex?: number;
42
+ }
43
+
44
+ /**
45
+ * A thinking indicator component that displays three animated dots to show that the system is processing or awaiting a response.
46
+ * ---
47
+ *
48
+ */
49
+ export const ForgeAiThinkingIndicator: React.ForwardRefExoticComponent<ForgeAiThinkingIndicatorProps>;
@@ -0,0 +1,18 @@
1
+ import React, { forwardRef } from "react";
2
+ import "@tylertech/forge-ai/ai-thinking-indicator";
3
+
4
+ export const ForgeAiThinkingIndicator = forwardRef((props, forwardedRef) => {
5
+ return React.createElement(
6
+ "forge-ai-thinking-indicator",
7
+ {
8
+ ...props,
9
+ class: props.className,
10
+ exportparts: props.exportparts,
11
+ for: props.htmlFor,
12
+ part: props.part,
13
+ tabindex: props.tabIndex,
14
+ style: { ...props.style },
15
+ },
16
+ props.children,
17
+ );
18
+ });
@@ -48,7 +48,7 @@ export interface ForgeAiThreadsProps
48
48
 
49
49
  /** Fired when a thread is selected. */
50
50
  onForgeAiThreadsSelect?: (
51
- event: CustomEvent<CustomEvent<AiThreadsSelectEventData>>,
51
+ event: CustomEvent<CustomEvent<ForgeAiThreadsSelectEventData>>,
52
52
  ) => void;
53
53
 
54
54
  /** Fired when the new chat button is clicked. */
package/dist/index.d.ts CHANGED
@@ -24,8 +24,9 @@ export * from "./ForgeAiResponseMessage.js";
24
24
  export * from "./ForgeAiSidebar.js";
25
25
  export * from "./ForgeAiSidebarChat.js";
26
26
  export * from "./ForgeAiSuggestions.js";
27
- export * from "./ForgeAiThreads.js";
27
+ export * from "./ForgeAiThinkingIndicator.js";
28
28
  export * from "./ForgeAiUserMessage.js";
29
+ export * from "./ForgeAiThreads.js";
29
30
  export * from "./ForgeAiVoiceInput.js";
30
31
  export * from "./ForgeAiThoughtBase.js";
31
32
  export * from "./ForgeAiThoughtDetail.js";
package/dist/index.js CHANGED
@@ -24,8 +24,9 @@ export * from "./ForgeAiResponseMessage.js";
24
24
  export * from "./ForgeAiSidebar.js";
25
25
  export * from "./ForgeAiSidebarChat.js";
26
26
  export * from "./ForgeAiSuggestions.js";
27
- export * from "./ForgeAiThreads.js";
27
+ export * from "./ForgeAiThinkingIndicator.js";
28
28
  export * from "./ForgeAiUserMessage.js";
29
+ export * from "./ForgeAiThreads.js";
29
30
  export * from "./ForgeAiVoiceInput.js";
30
31
  export * from "./ForgeAiThoughtBase.js";
31
32
  export * from "./ForgeAiThoughtDetail.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tylertech/forge-ai-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A React adapter for Tyler Forge™ AI Web Components.",
5
5
  "repository": "tyler-technologies-oss/forge-ai",
6
6
  "author": "Tyler Technologies, Inc.",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=17.0.0",
19
- "@tylertech/forge-ai": "^0.2.0"
19
+ "@tylertech/forge-ai": "^0.3.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@repo/prettier-config": "",
@@ -44,7 +44,7 @@
44
44
  "typescript": "~5.8.3",
45
45
  "vite": "7.1.10",
46
46
  "vite-tsconfig-paths": "5.1.4",
47
- "@tylertech/forge-ai": "^0.2.0"
47
+ "@tylertech/forge-ai": "^0.3.0"
48
48
  },
49
49
  "scripts": {
50
50
  "predev": "pnpm run build",