@tylertech/forge-ai-react 0.1.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/LICENSE +202 -0
- package/README.md +19 -0
- package/dist/ForgeAiActionsToolbar.d.ts +57 -0
- package/dist/ForgeAiActionsToolbar.js +36 -0
- package/dist/ForgeAiArtifact.d.ts +57 -0
- package/dist/ForgeAiArtifact.js +18 -0
- package/dist/ForgeAiButton.d.ts +55 -0
- package/dist/ForgeAiButton.js +21 -0
- package/dist/ForgeAiChainOfThought.d.ts +52 -0
- package/dist/ForgeAiChainOfThought.js +21 -0
- package/dist/ForgeAiChatHeader.d.ts +85 -0
- package/dist/ForgeAiChatHeader.js +62 -0
- package/dist/ForgeAiChatInterface.d.ts +66 -0
- package/dist/ForgeAiChatInterface.js +30 -0
- package/dist/ForgeAiDialog.d.ts +80 -0
- package/dist/ForgeAiDialog.js +43 -0
- package/dist/ForgeAiDropdownMenu.d.ts +99 -0
- package/dist/ForgeAiDropdownMenu.js +44 -0
- package/dist/ForgeAiDropdownMenuItem.d.ts +89 -0
- package/dist/ForgeAiDropdownMenuItem.js +52 -0
- package/dist/ForgeAiDropdownMenuItemGroup.d.ts +53 -0
- package/dist/ForgeAiDropdownMenuItemGroup.js +20 -0
- package/dist/ForgeAiDropdownMenuSeparator.d.ts +49 -0
- package/dist/ForgeAiDropdownMenuSeparator.js +20 -0
- package/dist/ForgeAiEmbeddedChat.d.ts +76 -0
- package/dist/ForgeAiEmbeddedChat.js +44 -0
- package/dist/ForgeAiEmptyState.d.ts +53 -0
- package/dist/ForgeAiEmptyState.js +18 -0
- package/dist/ForgeAiFab.d.ts +58 -0
- package/dist/ForgeAiFab.js +22 -0
- package/dist/ForgeAiFilePicker.d.ts +77 -0
- package/dist/ForgeAiFilePicker.js +41 -0
- package/dist/ForgeAiFloatingChat.d.ts +87 -0
- package/dist/ForgeAiFloatingChat.js +54 -0
- package/dist/ForgeAiGradientContainer.d.ts +55 -0
- package/dist/ForgeAiGradientContainer.js +21 -0
- package/dist/ForgeAiIcon.d.ts +52 -0
- package/dist/ForgeAiIcon.js +21 -0
- package/dist/ForgeAiModal.d.ts +79 -0
- package/dist/ForgeAiModal.js +41 -0
- package/dist/ForgeAiOverlay.d.ts +73 -0
- package/dist/ForgeAiOverlay.js +25 -0
- package/dist/ForgeAiPopover.d.ts +73 -0
- package/dist/ForgeAiPopover.js +25 -0
- package/dist/ForgeAiPrompt.d.ts +69 -0
- package/dist/ForgeAiPrompt.js +36 -0
- package/dist/ForgeAiReasoning.d.ts +52 -0
- package/dist/ForgeAiReasoning.js +21 -0
- package/dist/ForgeAiReasoningContent.d.ts +49 -0
- package/dist/ForgeAiReasoningContent.js +18 -0
- package/dist/ForgeAiReasoningHeader.d.ts +65 -0
- package/dist/ForgeAiReasoningHeader.js +35 -0
- package/dist/ForgeAiResponseMessage.d.ts +57 -0
- package/dist/ForgeAiResponseMessage.js +36 -0
- package/dist/ForgeAiSidebar.d.ts +70 -0
- package/dist/ForgeAiSidebar.js +35 -0
- package/dist/ForgeAiSidebarChat.d.ts +87 -0
- package/dist/ForgeAiSidebarChat.js +54 -0
- package/dist/ForgeAiSuggestions.d.ts +63 -0
- package/dist/ForgeAiSuggestions.js +39 -0
- package/dist/ForgeAiThoughtBase.d.ts +57 -0
- package/dist/ForgeAiThoughtBase.js +21 -0
- package/dist/ForgeAiThoughtDetail.d.ts +49 -0
- package/dist/ForgeAiThoughtDetail.js +18 -0
- package/dist/ForgeAiThoughtImage.d.ts +52 -0
- package/dist/ForgeAiThoughtImage.js +21 -0
- package/dist/ForgeAiThoughtSearchResult.d.ts +55 -0
- package/dist/ForgeAiThoughtSearchResult.js +22 -0
- package/dist/ForgeAiThreads.d.ts +71 -0
- package/dist/ForgeAiThreads.js +48 -0
- package/dist/ForgeAiTooltip.d.ts +79 -0
- package/dist/ForgeAiTooltip.js +27 -0
- package/dist/ForgeAiUserMessage.d.ts +49 -0
- package/dist/ForgeAiUserMessage.js +18 -0
- package/dist/ForgeAiVoiceInput.d.ts +57 -0
- package/dist/ForgeAiVoiceInput.js +36 -0
- package/dist/ForgePromptButton.d.ts +52 -0
- package/dist/ForgePromptButton.js +21 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +38 -0
- package/dist/react-utils.js +34 -0
- package/package.json +62 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-chat-header";
|
|
3
|
+
import { useEventListener } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const ForgeAiChatHeader = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
showExpandButton,
|
|
9
|
+
showMinimizeButton,
|
|
10
|
+
expanded,
|
|
11
|
+
minimizeIcon,
|
|
12
|
+
...filteredProps
|
|
13
|
+
} = props;
|
|
14
|
+
|
|
15
|
+
/** Event listeners - run once */
|
|
16
|
+
useEventListener(
|
|
17
|
+
ref,
|
|
18
|
+
"forge-ai-chat-header-clear",
|
|
19
|
+
props.onForgeAiChatHeaderClear,
|
|
20
|
+
);
|
|
21
|
+
useEventListener(
|
|
22
|
+
ref,
|
|
23
|
+
"forge-ai-chat-header-info",
|
|
24
|
+
props.onForgeAiChatHeaderInfo,
|
|
25
|
+
);
|
|
26
|
+
useEventListener(
|
|
27
|
+
ref,
|
|
28
|
+
"forge-ai-chat-header-expand",
|
|
29
|
+
props.onForgeAiChatHeaderExpand,
|
|
30
|
+
);
|
|
31
|
+
useEventListener(
|
|
32
|
+
ref,
|
|
33
|
+
"forge-ai-chat-header-minimize",
|
|
34
|
+
props.onForgeAiChatHeaderMinimize,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return React.createElement(
|
|
38
|
+
"forge-ai-chat-header",
|
|
39
|
+
{
|
|
40
|
+
ref: (node) => {
|
|
41
|
+
ref.current = node;
|
|
42
|
+
if (typeof forwardedRef === "function") {
|
|
43
|
+
forwardedRef(node);
|
|
44
|
+
} else if (forwardedRef) {
|
|
45
|
+
forwardedRef.current = node;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
...filteredProps,
|
|
49
|
+
"minimize-icon": props.minimizeIcon || props["minimize-icon"],
|
|
50
|
+
class: props.className,
|
|
51
|
+
exportparts: props.exportparts,
|
|
52
|
+
for: props.htmlFor,
|
|
53
|
+
part: props.part,
|
|
54
|
+
tabindex: props.tabIndex,
|
|
55
|
+
"show-expand-button": props.showExpandButton ? true : undefined,
|
|
56
|
+
"show-minimize-button": props.showMinimizeButton ? true : undefined,
|
|
57
|
+
expanded: props.expanded ? true : undefined,
|
|
58
|
+
style: { ...props.style },
|
|
59
|
+
},
|
|
60
|
+
props.children,
|
|
61
|
+
);
|
|
62
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ForgeAiChatInterface as ForgeAiChatInterfaceElement } from "@tylertech/forge-ai/ai-chat-interface";
|
|
3
|
+
|
|
4
|
+
export type { ForgeAiChatInterfaceElement };
|
|
5
|
+
|
|
6
|
+
export interface ForgeAiChatInterfaceProps
|
|
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
|
+
/** Controls whether the expand button is visible in the header */
|
|
23
|
+
showExpandButton?: boolean;
|
|
24
|
+
|
|
25
|
+
/** Controls whether the minimize button is visible in the header */
|
|
26
|
+
showMinimizeButton?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Indicates the current expanded state for displaying the appropriate expand/collapse icon */
|
|
29
|
+
expanded?: boolean;
|
|
30
|
+
|
|
31
|
+
/** Controls which minimize icon to display in the header */
|
|
32
|
+
minimizeIcon?: ForgeAiChatInterfaceElement["minimizeIcon"];
|
|
33
|
+
|
|
34
|
+
/** 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()`. */
|
|
35
|
+
className?: string;
|
|
36
|
+
|
|
37
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
38
|
+
exportparts?: string;
|
|
39
|
+
|
|
40
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
41
|
+
htmlFor?: string;
|
|
42
|
+
|
|
43
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
44
|
+
key?: number | string;
|
|
45
|
+
|
|
46
|
+
/** 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. */
|
|
47
|
+
part?: string;
|
|
48
|
+
|
|
49
|
+
/** 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. */
|
|
50
|
+
ref?: any;
|
|
51
|
+
|
|
52
|
+
/** 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. */
|
|
53
|
+
tabIndex?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
* ---
|
|
59
|
+
*
|
|
60
|
+
*
|
|
61
|
+
* ### **Slots:**
|
|
62
|
+
* - _default_ - Default slot for messages
|
|
63
|
+
* - **suggestions** - Slot for AI suggestions component
|
|
64
|
+
* - **prompt** - Slot for AI prompt component
|
|
65
|
+
*/
|
|
66
|
+
export const ForgeAiChatInterface: React.ForwardRefExoticComponent<ForgeAiChatInterfaceProps>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-chat-interface";
|
|
3
|
+
|
|
4
|
+
export const ForgeAiChatInterface = forwardRef((props, forwardedRef) => {
|
|
5
|
+
const {
|
|
6
|
+
showExpandButton,
|
|
7
|
+
showMinimizeButton,
|
|
8
|
+
expanded,
|
|
9
|
+
minimizeIcon,
|
|
10
|
+
...filteredProps
|
|
11
|
+
} = props;
|
|
12
|
+
|
|
13
|
+
return React.createElement(
|
|
14
|
+
"forge-ai-chat-interface",
|
|
15
|
+
{
|
|
16
|
+
...filteredProps,
|
|
17
|
+
"minimize-icon": props.minimizeIcon || props["minimize-icon"],
|
|
18
|
+
class: props.className,
|
|
19
|
+
exportparts: props.exportparts,
|
|
20
|
+
for: props.htmlFor,
|
|
21
|
+
part: props.part,
|
|
22
|
+
tabindex: props.tabIndex,
|
|
23
|
+
"show-expand-button": props.showExpandButton ? true : undefined,
|
|
24
|
+
"show-minimize-button": props.showMinimizeButton ? true : undefined,
|
|
25
|
+
expanded: props.expanded ? true : undefined,
|
|
26
|
+
style: { ...props.style },
|
|
27
|
+
},
|
|
28
|
+
props.children,
|
|
29
|
+
);
|
|
30
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ForgeAiDialog as ForgeAiDialogElement } from "@tylertech/forge-ai/ai-dialog";
|
|
3
|
+
|
|
4
|
+
export type { ForgeAiDialogElement };
|
|
5
|
+
|
|
6
|
+
export interface ForgeAiDialogProps
|
|
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
|
+
/** Indicates whether the dialog is open. */
|
|
23
|
+
open?: boolean;
|
|
24
|
+
|
|
25
|
+
/** Controls the dialog's positioning and size behavior.
|
|
26
|
+
When true, the dialog will have an expanded width and be centered on the screen.
|
|
27
|
+
When false, the dialog will be positioned at the bottom-right corner with a fixed width. */
|
|
28
|
+
expanded?: boolean;
|
|
29
|
+
|
|
30
|
+
/** 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()`. */
|
|
31
|
+
className?: string;
|
|
32
|
+
|
|
33
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
34
|
+
exportparts?: string;
|
|
35
|
+
|
|
36
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
37
|
+
htmlFor?: string;
|
|
38
|
+
|
|
39
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
40
|
+
key?: number | string;
|
|
41
|
+
|
|
42
|
+
/** 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. */
|
|
43
|
+
part?: string;
|
|
44
|
+
|
|
45
|
+
/** 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. */
|
|
46
|
+
ref?: any;
|
|
47
|
+
|
|
48
|
+
/** 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. */
|
|
49
|
+
tabIndex?: number;
|
|
50
|
+
|
|
51
|
+
/** Gets the current fullscreen state (readonly) */
|
|
52
|
+
isFullscreen?: ForgeAiDialogElement["isFullscreen"];
|
|
53
|
+
|
|
54
|
+
/** Fired when the fullscreen state changes due to viewport size */
|
|
55
|
+
onForgeAiDialogFullscreenChange?: (
|
|
56
|
+
event: CustomEvent<CustomEvent<{ isFullscreen: boolean }>>,
|
|
57
|
+
) => void;
|
|
58
|
+
|
|
59
|
+
/** Fired when the dialog is closed */
|
|
60
|
+
onForgeAiDialogClose?: (event: CustomEvent<CustomEvent<void>>) => void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* ---
|
|
66
|
+
*
|
|
67
|
+
*
|
|
68
|
+
* ### **Events:**
|
|
69
|
+
* - **forge-ai-dialog-fullscreen-change** - Fired when the fullscreen state changes due to viewport size
|
|
70
|
+
* - **forge-ai-dialog-close** - Fired when the dialog is closed
|
|
71
|
+
*
|
|
72
|
+
* ### **Methods:**
|
|
73
|
+
* - **show(): _void_** - Opens the dialog.
|
|
74
|
+
* - **close(): _void_** - Closes the dialog.
|
|
75
|
+
* - **toggle(): _void_** - Toggles the dialog open state.
|
|
76
|
+
*
|
|
77
|
+
* ### **Slots:**
|
|
78
|
+
* - _default_ - Default slot for dialog content (typically ai-chat-interface)
|
|
79
|
+
*/
|
|
80
|
+
export const ForgeAiDialog: React.ForwardRefExoticComponent<ForgeAiDialogProps>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-dialog";
|
|
3
|
+
import { useEventListener, useProperties } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const ForgeAiDialog = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { open, expanded, isFullscreen, ...filteredProps } = props;
|
|
8
|
+
|
|
9
|
+
/** Event listeners - run once */
|
|
10
|
+
useEventListener(
|
|
11
|
+
ref,
|
|
12
|
+
"forge-ai-dialog-fullscreen-change",
|
|
13
|
+
props.onForgeAiDialogFullscreenChange,
|
|
14
|
+
);
|
|
15
|
+
useEventListener(ref, "forge-ai-dialog-close", props.onForgeAiDialogClose);
|
|
16
|
+
|
|
17
|
+
/** Properties - run whenever a property has changed */
|
|
18
|
+
useProperties(ref, "isFullscreen", props.isFullscreen);
|
|
19
|
+
|
|
20
|
+
return React.createElement(
|
|
21
|
+
"forge-ai-dialog",
|
|
22
|
+
{
|
|
23
|
+
ref: (node) => {
|
|
24
|
+
ref.current = node;
|
|
25
|
+
if (typeof forwardedRef === "function") {
|
|
26
|
+
forwardedRef(node);
|
|
27
|
+
} else if (forwardedRef) {
|
|
28
|
+
forwardedRef.current = node;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
...filteredProps,
|
|
32
|
+
class: props.className,
|
|
33
|
+
exportparts: props.exportparts,
|
|
34
|
+
for: props.htmlFor,
|
|
35
|
+
part: props.part,
|
|
36
|
+
tabindex: props.tabIndex,
|
|
37
|
+
open: props.open ? true : undefined,
|
|
38
|
+
expanded: props.expanded ? true : undefined,
|
|
39
|
+
style: { ...props.style },
|
|
40
|
+
},
|
|
41
|
+
props.children,
|
|
42
|
+
);
|
|
43
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
ForgeAiDropdownMenu as ForgeAiDropdownMenuElement,
|
|
4
|
+
CustomEvent,
|
|
5
|
+
} from "@tylertech/forge-ai/ai-dropdown-menu";
|
|
6
|
+
|
|
7
|
+
export type { ForgeAiDropdownMenuElement, CustomEvent };
|
|
8
|
+
|
|
9
|
+
export interface ForgeAiDropdownMenuProps
|
|
10
|
+
extends Pick<
|
|
11
|
+
React.AllHTMLAttributes<HTMLElement>,
|
|
12
|
+
| "children"
|
|
13
|
+
| "dir"
|
|
14
|
+
| "hidden"
|
|
15
|
+
| "id"
|
|
16
|
+
| "lang"
|
|
17
|
+
| "slot"
|
|
18
|
+
| "style"
|
|
19
|
+
| "title"
|
|
20
|
+
| "translate"
|
|
21
|
+
| "onClick"
|
|
22
|
+
| "onFocus"
|
|
23
|
+
| "onBlur"
|
|
24
|
+
> {
|
|
25
|
+
/** Whether the dropdown is open. */
|
|
26
|
+
open?: boolean;
|
|
27
|
+
|
|
28
|
+
/** Whether the dropdown menu is disabled. */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
|
|
31
|
+
/** The variant of the dropdown menu trigger button. */
|
|
32
|
+
variant?: ForgeAiDropdownMenuElement["variant"];
|
|
33
|
+
|
|
34
|
+
/** The selection mode for the dropdown menu.
|
|
35
|
+
- 'none': No selection state, items act as actions only
|
|
36
|
+
- 'single': Single selection with radio button behavior
|
|
37
|
+
- 'multi': Multiple selection with checkbox behavior */
|
|
38
|
+
selectionMode?: ForgeAiDropdownMenuElement["selectionMode"];
|
|
39
|
+
|
|
40
|
+
/** The currently selected value(s).
|
|
41
|
+
For single selection: string or null
|
|
42
|
+
For multi selection: string array
|
|
43
|
+
For none mode: null */
|
|
44
|
+
value?: ForgeAiDropdownMenuElement["value"];
|
|
45
|
+
|
|
46
|
+
/** 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()`. */
|
|
47
|
+
className?: string;
|
|
48
|
+
|
|
49
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
50
|
+
exportparts?: string;
|
|
51
|
+
|
|
52
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
53
|
+
htmlFor?: string;
|
|
54
|
+
|
|
55
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
56
|
+
key?: number | string;
|
|
57
|
+
|
|
58
|
+
/** 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. */
|
|
59
|
+
part?: string;
|
|
60
|
+
|
|
61
|
+
/** 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. */
|
|
62
|
+
ref?: any;
|
|
63
|
+
|
|
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. */
|
|
65
|
+
tabIndex?: number;
|
|
66
|
+
|
|
67
|
+
/** undefined */
|
|
68
|
+
onForgeAiDropdownMenuChange?: (event: CustomEvent) => void;
|
|
69
|
+
|
|
70
|
+
/** undefined */
|
|
71
|
+
onEventName?: (event: CustomEvent) => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* An AI dropdown menu component with advanced selection modes and submenu support.
|
|
76
|
+
* ---
|
|
77
|
+
*
|
|
78
|
+
*
|
|
79
|
+
* ### **Events:**
|
|
80
|
+
* - **forge-ai-dropdown-menu-change**
|
|
81
|
+
* - **eventName**
|
|
82
|
+
*
|
|
83
|
+
* ### **Slots:**
|
|
84
|
+
* - _default_ - The default slot for dropdown menu items, item groups, and separators.
|
|
85
|
+
* - **header** - The header content displayed at the top of the dropdown menu.
|
|
86
|
+
* - **trigger-content** - The content of the trigger button (text or icon) when no selection is made.
|
|
87
|
+
* - **selected-text** - Custom content for the trigger button when selections are made (overrides default selection text).
|
|
88
|
+
* - **start** - The start icon slot for additional trigger button content.
|
|
89
|
+
* - **end** - The end icon slot for additional trigger button content.
|
|
90
|
+
*
|
|
91
|
+
* ### **CSS Properties:**
|
|
92
|
+
* - **--ai-dropdown-menu-min-width** - Minimum width of the dropdown menu. _(default: undefined)_
|
|
93
|
+
* - **--ai-dropdown-menu-max-width** - Maximum width of the dropdown menu. _(default: undefined)_
|
|
94
|
+
* - **--ai-dropdown-menu-max-height** - Maximum height of the dropdown menu. _(default: undefined)_
|
|
95
|
+
* - **--ai-dropdown-menu-padding** - Padding inside the dropdown menu. _(default: undefined)_
|
|
96
|
+
* - **--ai-dropdown-menu-trigger-width** - The width of the trigger button. _(default: undefined)_
|
|
97
|
+
* - **--ai-dropdown-menu-trigger-height** - The height of the trigger button. _(default: undefined)_
|
|
98
|
+
*/
|
|
99
|
+
export const ForgeAiDropdownMenu: React.ForwardRefExoticComponent<ForgeAiDropdownMenuProps>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-dropdown-menu";
|
|
3
|
+
import { useEventListener } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const ForgeAiDropdownMenu = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { open, disabled, variant, selectionMode, value, ...filteredProps } =
|
|
8
|
+
props;
|
|
9
|
+
|
|
10
|
+
/** Event listeners - run once */
|
|
11
|
+
useEventListener(
|
|
12
|
+
ref,
|
|
13
|
+
"forge-ai-dropdown-menu-change",
|
|
14
|
+
props.onForgeAiDropdownMenuChange,
|
|
15
|
+
);
|
|
16
|
+
useEventListener(ref, "eventName", props.onEventName);
|
|
17
|
+
|
|
18
|
+
return React.createElement(
|
|
19
|
+
"forge-ai-dropdown-menu",
|
|
20
|
+
{
|
|
21
|
+
ref: (node) => {
|
|
22
|
+
ref.current = node;
|
|
23
|
+
if (typeof forwardedRef === "function") {
|
|
24
|
+
forwardedRef(node);
|
|
25
|
+
} else if (forwardedRef) {
|
|
26
|
+
forwardedRef.current = node;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
...filteredProps,
|
|
30
|
+
variant: props.variant,
|
|
31
|
+
"selection-mode": props.selectionMode || props["selection-mode"],
|
|
32
|
+
value: props.value,
|
|
33
|
+
class: props.className,
|
|
34
|
+
exportparts: props.exportparts,
|
|
35
|
+
for: props.htmlFor,
|
|
36
|
+
part: props.part,
|
|
37
|
+
tabindex: props.tabIndex,
|
|
38
|
+
open: props.open ? true : undefined,
|
|
39
|
+
disabled: props.disabled ? true : undefined,
|
|
40
|
+
style: { ...props.style },
|
|
41
|
+
},
|
|
42
|
+
props.children,
|
|
43
|
+
);
|
|
44
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ForgeAiDropdownMenuItem as ForgeAiDropdownMenuItemElement } from "@tylertech/forge-ai/ai-dropdown-menu";
|
|
3
|
+
|
|
4
|
+
export type { ForgeAiDropdownMenuItemElement };
|
|
5
|
+
|
|
6
|
+
export interface ForgeAiDropdownMenuItemProps
|
|
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
|
+
/** Whether this menu item is selected. */
|
|
23
|
+
selected?: boolean;
|
|
24
|
+
|
|
25
|
+
/** Whether this menu item is disabled. */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
|
|
28
|
+
/** The value associated with this menu item. */
|
|
29
|
+
value?: ForgeAiDropdownMenuItemElement["value"];
|
|
30
|
+
|
|
31
|
+
/** The selection mode for this menu item.
|
|
32
|
+
This is typically set by the parent dropdown menu component. */
|
|
33
|
+
selectionMode?: ForgeAiDropdownMenuItemElement["selectionMode"];
|
|
34
|
+
|
|
35
|
+
/** The trigger behavior for submenu opening.
|
|
36
|
+
- 'hover': Opens on mouse hover (default)
|
|
37
|
+
- 'click': Opens on click
|
|
38
|
+
- 'both': Opens on both hover and click */
|
|
39
|
+
submenuTrigger?: ForgeAiDropdownMenuItemElement["submenuTrigger"];
|
|
40
|
+
|
|
41
|
+
/** The delay in milliseconds before opening a submenu on hover. */
|
|
42
|
+
submenuOpenDelay?: ForgeAiDropdownMenuItemElement["submenuOpenDelay"];
|
|
43
|
+
|
|
44
|
+
/** The delay in milliseconds before closing a submenu when mouse leaves. */
|
|
45
|
+
submenuCloseDelay?: ForgeAiDropdownMenuItemElement["submenuCloseDelay"];
|
|
46
|
+
|
|
47
|
+
/** 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()`. */
|
|
48
|
+
className?: string;
|
|
49
|
+
|
|
50
|
+
/** Contains a space-separated list of the part names of the element that should be exposed on the host element. */
|
|
51
|
+
exportparts?: string;
|
|
52
|
+
|
|
53
|
+
/** Used for labels to link them with their inputs (using input id). */
|
|
54
|
+
htmlFor?: string;
|
|
55
|
+
|
|
56
|
+
/** Used to help React identify which items have changed, are added, or are removed within a list. */
|
|
57
|
+
key?: number | string;
|
|
58
|
+
|
|
59
|
+
/** 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. */
|
|
60
|
+
part?: string;
|
|
61
|
+
|
|
62
|
+
/** 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. */
|
|
63
|
+
ref?: any;
|
|
64
|
+
|
|
65
|
+
/** 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. */
|
|
66
|
+
tabIndex?: number;
|
|
67
|
+
|
|
68
|
+
/** Gets the text content from the default slot (label text only). */
|
|
69
|
+
labelText?: ForgeAiDropdownMenuItemElement["labelText"];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* An item component for use within ai-dropdown-menu with submenu support.
|
|
74
|
+
* ---
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* ### **Slots:**
|
|
78
|
+
* - _default_ - The default slot for item text content.
|
|
79
|
+
* - **description** - The description slot for additional item details.
|
|
80
|
+
* - **start** - The start icon slot.
|
|
81
|
+
* - **end** - The end icon slot.
|
|
82
|
+
* - **submenu** - The slot for nested dropdown menu components.
|
|
83
|
+
*
|
|
84
|
+
* ### **CSS Properties:**
|
|
85
|
+
* - **--ai-dropdown-menu-item-submenu-open-delay** - Delay before opening submenu on hover. _(default: undefined)_
|
|
86
|
+
* - **--ai-dropdown-menu-item-submenu-close-delay** - Delay before closing submenu when mouse leaves. _(default: undefined)_
|
|
87
|
+
* - **--ai-dropdown-menu-item-selection-icon-size** - Size of selection and submenu icons. _(default: undefined)_
|
|
88
|
+
*/
|
|
89
|
+
export const ForgeAiDropdownMenuItem: React.ForwardRefExoticComponent<ForgeAiDropdownMenuItemProps>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { forwardRef, useRef, useEffect } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-dropdown-menu";
|
|
3
|
+
import { useProperties } from "./react-utils.js";
|
|
4
|
+
|
|
5
|
+
export const ForgeAiDropdownMenuItem = forwardRef((props, forwardedRef) => {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const {
|
|
8
|
+
selected,
|
|
9
|
+
disabled,
|
|
10
|
+
value,
|
|
11
|
+
selectionMode,
|
|
12
|
+
submenuTrigger,
|
|
13
|
+
submenuOpenDelay,
|
|
14
|
+
submenuCloseDelay,
|
|
15
|
+
labelText,
|
|
16
|
+
...filteredProps
|
|
17
|
+
} = props;
|
|
18
|
+
|
|
19
|
+
/** Properties - run whenever a property has changed */
|
|
20
|
+
useProperties(ref, "labelText", props.labelText);
|
|
21
|
+
|
|
22
|
+
return React.createElement(
|
|
23
|
+
"forge-ai-dropdown-menu-item",
|
|
24
|
+
{
|
|
25
|
+
ref: (node) => {
|
|
26
|
+
ref.current = node;
|
|
27
|
+
if (typeof forwardedRef === "function") {
|
|
28
|
+
forwardedRef(node);
|
|
29
|
+
} else if (forwardedRef) {
|
|
30
|
+
forwardedRef.current = node;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
...filteredProps,
|
|
34
|
+
value: props.value,
|
|
35
|
+
"selection-mode": props.selectionMode || props["selection-mode"],
|
|
36
|
+
"submenu-trigger": props.submenuTrigger || props["submenu-trigger"],
|
|
37
|
+
"submenu-open-delay":
|
|
38
|
+
props.submenuOpenDelay || props["submenu-open-delay"],
|
|
39
|
+
"submenu-close-delay":
|
|
40
|
+
props.submenuCloseDelay || props["submenu-close-delay"],
|
|
41
|
+
class: props.className,
|
|
42
|
+
exportparts: props.exportparts,
|
|
43
|
+
for: props.htmlFor,
|
|
44
|
+
part: props.part,
|
|
45
|
+
tabindex: props.tabIndex,
|
|
46
|
+
selected: props.selected ? true : undefined,
|
|
47
|
+
disabled: props.disabled ? true : undefined,
|
|
48
|
+
style: { ...props.style },
|
|
49
|
+
},
|
|
50
|
+
props.children,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ForgeAiDropdownMenuItemGroup as ForgeAiDropdownMenuItemGroupElement } from "@tylertech/forge-ai/ai-dropdown-menu";
|
|
3
|
+
|
|
4
|
+
export type { ForgeAiDropdownMenuItemGroupElement };
|
|
5
|
+
|
|
6
|
+
export interface ForgeAiDropdownMenuItemGroupProps
|
|
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 group component for organizing items within ai-dropdown-menu.
|
|
46
|
+
* ---
|
|
47
|
+
*
|
|
48
|
+
*
|
|
49
|
+
* ### **Slots:**
|
|
50
|
+
* - _default_ - The default slot for dropdown menu items.
|
|
51
|
+
* - **label** - The label slot for the group heading text.
|
|
52
|
+
*/
|
|
53
|
+
export const ForgeAiDropdownMenuItemGroup: React.ForwardRefExoticComponent<ForgeAiDropdownMenuItemGroupProps>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import "@tylertech/forge-ai/ai-dropdown-menu";
|
|
3
|
+
|
|
4
|
+
export const ForgeAiDropdownMenuItemGroup = forwardRef(
|
|
5
|
+
(props, forwardedRef) => {
|
|
6
|
+
return React.createElement(
|
|
7
|
+
"forge-ai-dropdown-menu-item-group",
|
|
8
|
+
{
|
|
9
|
+
...props,
|
|
10
|
+
class: props.className,
|
|
11
|
+
exportparts: props.exportparts,
|
|
12
|
+
for: props.htmlFor,
|
|
13
|
+
part: props.part,
|
|
14
|
+
tabindex: props.tabIndex,
|
|
15
|
+
style: { ...props.style },
|
|
16
|
+
},
|
|
17
|
+
props.children,
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
);
|