@cloudscape-design/chat-components 1.0.97 → 1.0.99
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/internal/api-docs/components/support-prompt-group.js +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/support-prompt-group/interfaces.d.ts +11 -0
- package/support-prompt-group/interfaces.js.map +1 -1
- package/support-prompt-group/internal.js +1 -1
- package/support-prompt-group/internal.js.map +1 -1
- package/support-prompt-group/prompt.d.ts +6 -0
- package/support-prompt-group/prompt.js +13 -4
- package/support-prompt-group/prompt.js.map +1 -1
- package/support-prompt-group/styles.css.js +8 -3
- package/support-prompt-group/styles.scoped.css +29 -8
- package/support-prompt-group/styles.selectors.js +8 -3
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
|
41
41
|
"name": "items",
|
|
42
42
|
"type": "ReadonlyArray<SupportPromptGroupProps.Item>",
|
|
43
43
|
"optional": false,
|
|
44
|
-
"description": "An array of objects representing support prompts.\nEach item has the following properties:\n - text: The text of the support prompt.\n - id: The ID of the support prompt."
|
|
44
|
+
"description": "An array of objects representing support prompts.\nEach item has the following properties:\n - text: The text of the support prompt.\n - id: The ID of the support prompt.\n - iconName (optional): The name of a built-in icon to display.\n - iconSvg (optional): A custom SVG icon to display. Takes precedence over iconName.\n - iconPosition (optional): Position of the icon relative to text. Can be \"left\" (default) or \"right\".\n - iconVerticalAlignment (optional): Vertical alignment of the icon. Can be \"center\", \"start\" (default), or \"end\".\n - ariaLabel (optional): Custom accessible label for the prompt."
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
"events": [
|
package/internal/environment.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export var PACKAGE_SOURCE = "chat-components";
|
|
2
|
-
export var PACKAGE_VERSION = "1.0.0 (
|
|
2
|
+
export var PACKAGE_VERSION = "1.0.0 (ec1bfdd8)";
|
|
3
3
|
export var THEME = "open-source-visual-refresh";
|
|
4
4
|
export var SYSTEM = "core";
|
|
5
5
|
export var ALWAYS_VISUAL_REFRESH = true;
|
package/internal/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconProps } from "@cloudscape-design/components/icon";
|
|
1
2
|
import { ClickDetail as _ClickDetail, NonCancelableEventHandler } from "../internal/events";
|
|
2
3
|
export interface SupportPromptGroupProps {
|
|
3
4
|
/**
|
|
@@ -9,6 +10,11 @@ export interface SupportPromptGroupProps {
|
|
|
9
10
|
* Each item has the following properties:
|
|
10
11
|
* - text: The text of the support prompt.
|
|
11
12
|
* - id: The ID of the support prompt.
|
|
13
|
+
* - iconName (optional): The name of a built-in icon to display.
|
|
14
|
+
* - iconSvg (optional): A custom SVG icon to display. Takes precedence over iconName.
|
|
15
|
+
* - iconPosition (optional): Position of the icon relative to text. Can be "left" (default) or "right".
|
|
16
|
+
* - iconVerticalAlignment (optional): Vertical alignment of the icon. Can be "center", "start" (default), or "end".
|
|
17
|
+
* - ariaLabel (optional): Custom accessible label for the prompt.
|
|
12
18
|
**/
|
|
13
19
|
items: ReadonlyArray<SupportPromptGroupProps.Item>;
|
|
14
20
|
/**
|
|
@@ -26,6 +32,11 @@ export declare namespace SupportPromptGroupProps {
|
|
|
26
32
|
interface Item {
|
|
27
33
|
text: string;
|
|
28
34
|
id: string;
|
|
35
|
+
iconName?: IconProps.Name;
|
|
36
|
+
iconSvg?: React.ReactNode;
|
|
37
|
+
iconPosition?: "left" | "right";
|
|
38
|
+
iconVerticalAlignment?: "center" | "start" | "end";
|
|
39
|
+
ariaLabel?: string;
|
|
29
40
|
}
|
|
30
41
|
interface ItemClickDetail extends _ClickDetail {
|
|
31
42
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/support-prompt-group/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ClickDetail as _ClickDetail, NonCancelableEventHandler } from \"../internal/events\";\n\nexport interface SupportPromptGroupProps {\n /**\n * Alignment of the prompts. Defaults to `vertical`.\n **/\n alignment?: SupportPromptGroupProps.Alignment;\n\n /**\n * An array of objects representing support prompts.\n * Each item has the following properties:\n * - text: The text of the support prompt.\n * - id: The ID of the support prompt.\n **/\n items: ReadonlyArray<SupportPromptGroupProps.Item>;\n\n /**\n * Called when the user clicks on a support prompt. The event detail object contains the ID of the clicked item.\n */\n onItemClick: NonCancelableEventHandler<SupportPromptGroupProps.ItemClickDetail>;\n\n /**\n * Adds an aria label to the support prompt group.\n * Use this to provide a unique accessible name for each support prompt group on the page.\n */\n ariaLabel: string;\n}\n\nexport namespace SupportPromptGroupProps {\n export type Alignment = \"vertical\" | \"horizontal\";\n\n export interface Item {\n text: string;\n id: string;\n }\n\n export interface ItemClickDetail extends _ClickDetail {\n id: string;\n }\n\n export interface Ref {\n /**\n * Focuses support prompt group item by ID.\n */\n focus(itemId: string): void;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/support-prompt-group/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { IconProps } from \"@cloudscape-design/components/icon\";\n\nimport { ClickDetail as _ClickDetail, NonCancelableEventHandler } from \"../internal/events\";\n\nexport interface SupportPromptGroupProps {\n /**\n * Alignment of the prompts. Defaults to `vertical`.\n **/\n alignment?: SupportPromptGroupProps.Alignment;\n\n /**\n * An array of objects representing support prompts.\n * Each item has the following properties:\n * - text: The text of the support prompt.\n * - id: The ID of the support prompt.\n * - iconName (optional): The name of a built-in icon to display.\n * - iconSvg (optional): A custom SVG icon to display. Takes precedence over iconName.\n * - iconPosition (optional): Position of the icon relative to text. Can be \"left\" (default) or \"right\".\n * - iconVerticalAlignment (optional): Vertical alignment of the icon. Can be \"center\", \"start\" (default), or \"end\".\n * - ariaLabel (optional): Custom accessible label for the prompt.\n **/\n items: ReadonlyArray<SupportPromptGroupProps.Item>;\n\n /**\n * Called when the user clicks on a support prompt. The event detail object contains the ID of the clicked item.\n */\n onItemClick: NonCancelableEventHandler<SupportPromptGroupProps.ItemClickDetail>;\n\n /**\n * Adds an aria label to the support prompt group.\n * Use this to provide a unique accessible name for each support prompt group on the page.\n */\n ariaLabel: string;\n}\n\nexport namespace SupportPromptGroupProps {\n export type Alignment = \"vertical\" | \"horizontal\";\n\n export interface Item {\n text: string;\n id: string;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n iconPosition?: \"left\" | \"right\";\n iconVerticalAlignment?: \"center\" | \"start\" | \"end\";\n ariaLabel?: string;\n }\n\n export interface ItemClickDetail extends _ClickDetail {\n id: string;\n }\n\n export interface Ref {\n /**\n * Focuses support prompt group item by ID.\n */\n focus(itemId: string): void;\n }\n}\n"]}
|
|
@@ -96,7 +96,7 @@ export const InternalSupportPromptGroup = forwardRef(({ alignment = "vertical",
|
|
|
96
96
|
return _jsx("div", {});
|
|
97
97
|
}
|
|
98
98
|
return (_jsx("div", { ...getDataAttributes(rest), role: "menubar", className: clsx(styles.root, { [styles.vertical]: alignment !== "horizontal" }), "aria-label": ariaLabel, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, ref: mergedRef, children: _jsx(SingleTabStopNavigationProvider, { ref: navigationAPI, navigationActive: true, getNextFocusTarget: () => getNextFocusTarget(containerObjectRef, focusedIdRef), onUnregisterActive: (element) => onUnregisterActive(element, navigationAPI), children: items.map((item, index) => {
|
|
99
|
-
return (_jsx(Prompt, { onClick: (event) => handleClick(event, item.id), id: item.id, ref: (element) => (itemsRef.current[item.id] = element), children: item.text }, index));
|
|
99
|
+
return (_jsx(Prompt, { onClick: (event) => handleClick(event, item.id), id: item.id, ref: (element) => (itemsRef.current[item.id] = element), iconName: item.iconName, iconSvg: item.iconSvg, iconPosition: item.iconPosition, iconVerticalAlignment: item.iconVerticalAlignment, ariaLabel: item.ariaLabel, children: item.text }, index));
|
|
100
100
|
}) }) }));
|
|
101
101
|
});
|
|
102
102
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/support-prompt-group/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,OAAO,EAEP,+BAA+B,EAC/B,YAAY,EACZ,QAAQ,GACT,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAClD,CACE,EACE,SAAS,GAAG,UAAU,EACtB,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,GAAG,IAAI,EAC8C,EACvD,GAAqC,EACrC,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,MAAM,CAA6B,IAAI,CAAC,CAAC;IAC/D,MAAM,kBAAkB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,Q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ChB;IAED,OAAO,CACL,iBACM,iBAAiB,CAAC,IAAI,CAAC,EAC3B,IAAI,EAAC,SAAS,EACd,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,KAAK,YAAY,EAAE,CAAC,gBACnE,SAAS,EACrB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,SAAS,YAEd,KAAC,+BAA+B,IAC9B,GAAG,EAAE,aAAa,EAClB,gBAAgB,EAAE,IAAI,EACtB,kBAAkB,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,YAAY,CAAC,EAC9E,kBAAkB,EAAE,CAAC,OAAoB,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,YAEvF,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBACzB,OAAO,CACL,KAAC,MAAM,IAEL,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,EAC/C,EAAE,EAAE,IAAI,CAAC,EAAE,EACX,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,YAEtD,IAAI,CAAC,IAAI,IALL,KAAK,CAMH,CACV,CAAC;YACJ,CAAC,CAAC,GAC8B,GAC9B,CACP,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { forwardRef, Ref, useEffect, useImperativeHandle, useRef } from \"react\";\nimport clsx from \"clsx\";\n\nimport {\n circleIndex,\n getAllFocusables,\n handleKey,\n KeyCode,\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n useMergeRefs,\n warnOnce,\n} from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { getNextFocusTarget, onUnregisterActive } from \"./focus-helpers\";\nimport { SupportPromptGroupProps } from \"./interfaces\";\nimport { Prompt } from \"./prompt\";\n\nimport styles from \"./styles.css.js\";\n\nexport const InternalSupportPromptGroup = forwardRef(\n (\n {\n alignment = \"vertical\",\n onItemClick,\n items,\n __internalRootRef,\n ariaLabel,\n ...rest\n }: SupportPromptGroupProps & InternalBaseComponentProps,\n ref: Ref<SupportPromptGroupProps.Ref>,\n ) => {\n const focusedIdRef = useRef<null | string>(null);\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const containerObjectRef = useRef<HTMLDivElement>(null);\n const itemsRef = useRef<Record<string, any | null>>({});\n\n const mergedRef = useMergeRefs(containerObjectRef, __internalRootRef);\n\n useImperativeHandle(ref, () => ({\n focus: (id) => {\n if (!itemsRef.current[id]) {\n warnOnce(\"SupportPromptGroup\", \"No matching ID found to focus.\");\n }\n itemsRef.current[id]?.focus();\n },\n }));\n\n const handleClick = (event: React.MouseEvent, id: string) => {\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n\n fireNonCancelableEvent(onItemClick, { id, altKey, button, ctrlKey, metaKey, shiftKey });\n };\n\n useEffect(() => {\n navigationAPI.current?.updateFocusTarget();\n });\n\n function onFocus(event: React.FocusEvent) {\n if (event.target instanceof HTMLElement && event.target.dataset.itemid) {\n focusedIdRef.current = event.target.dataset.itemid;\n }\n\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onBlur() {\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onKeyDown(event: React.KeyboardEvent) {\n const focusTarget = navigationAPI.current?.getFocusTarget();\n const specialKeys = [\n KeyCode.right,\n KeyCode.left,\n KeyCode.up,\n KeyCode.down,\n KeyCode.end,\n KeyCode.home,\n KeyCode.pageUp,\n KeyCode.pageDown,\n ];\n\n const hasModifierKeys = (event: React.MouseEvent | React.KeyboardEvent) => {\n return event.ctrlKey || event.altKey || event.shiftKey || event.metaKey;\n };\n\n if (hasModifierKeys(event) || !specialKeys.includes(event.keyCode)) {\n return;\n }\n if (!containerObjectRef.current || !focusTarget) {\n return;\n }\n // Ignore navigation when the focused element is not an item.\n if (document.activeElement && !document.activeElement.matches(`.${styles[\"support-prompt\"]}`)) {\n return;\n }\n event.preventDefault();\n\n const focusables = getFocusablesFrom(containerObjectRef.current);\n const activeIndex = focusables.indexOf(focusTarget);\n handleKey(event as any, {\n onHome: () => focusElement(focusables[0]),\n onEnd: () => focusElement(focusables[focusables.length - 1]),\n onInlineStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onInlineEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n onBlockStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onBlockEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n });\n }\n\n function focusElement(element: HTMLElement) {\n element.focus();\n }\n\n // List all non-disabled and registered focusables: those are eligible for keyboard navigation.\n function getFocusablesFrom(target: HTMLElement) {\n function isElementRegistered(element: HTMLElement) {\n return navigationAPI.current?.isRegistered(element) ?? false;\n }\n\n return getAllFocusables(target).filter((el) => isElementRegistered(el));\n }\n\n if (!items || items.length === 0) {\n return <div />;\n }\n\n return (\n <div\n {...getDataAttributes(rest)}\n role=\"menubar\"\n className={clsx(styles.root, { [styles.vertical]: alignment !== \"horizontal\" })}\n aria-label={ariaLabel}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n ref={mergedRef}\n >\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={() => getNextFocusTarget(containerObjectRef, focusedIdRef)}\n onUnregisterActive={(element: HTMLElement) => onUnregisterActive(element, navigationAPI)}\n >\n {items.map((item, index) => {\n return (\n <Prompt\n key={index}\n onClick={(event) => handleClick(event, item.id)}\n id={item.id}\n ref={(element) => (itemsRef.current[item.id] = element)}\n >\n {item.text}\n </Prompt>\n );\n })}\n </SingleTabStopNavigationProvider>\n </div>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/support-prompt-group/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAChF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,OAAO,EAEP,+BAA+B,EAC/B,YAAY,EACZ,QAAQ,GACT,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAClD,CACE,EACE,SAAS,GAAG,UAAU,EACtB,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,GAAG,IAAI,EAC8C,EACvD,GAAqC,EACrC,EAAE;IACF,MAAM,YAAY,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACjD,MAAM,aAAa,GAAG,MAAM,CAA6B,IAAI,CAAC,CAAC;IAC/D,MAAM,kBAAkB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,QAA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.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { forwardRef, Ref, useEffect, useImperativeHandle, useRef } from \"react\";\nimport clsx from \"clsx\";\n\nimport {\n circleIndex,\n getAllFocusables,\n handleKey,\n KeyCode,\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n useMergeRefs,\n warnOnce,\n} from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { getNextFocusTarget, onUnregisterActive } from \"./focus-helpers\";\nimport { SupportPromptGroupProps } from \"./interfaces\";\nimport { Prompt } from \"./prompt\";\n\nimport styles from \"./styles.css.js\";\n\nexport const InternalSupportPromptGroup = forwardRef(\n (\n {\n alignment = \"vertical\",\n onItemClick,\n items,\n __internalRootRef,\n ariaLabel,\n ...rest\n }: SupportPromptGroupProps & InternalBaseComponentProps,\n ref: Ref<SupportPromptGroupProps.Ref>,\n ) => {\n const focusedIdRef = useRef<null | string>(null);\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const containerObjectRef = useRef<HTMLDivElement>(null);\n const itemsRef = useRef<Record<string, any | null>>({});\n\n const mergedRef = useMergeRefs(containerObjectRef, __internalRootRef);\n\n useImperativeHandle(ref, () => ({\n focus: (id) => {\n if (!itemsRef.current[id]) {\n warnOnce(\"SupportPromptGroup\", \"No matching ID found to focus.\");\n }\n itemsRef.current[id]?.focus();\n },\n }));\n\n const handleClick = (event: React.MouseEvent, id: string) => {\n const { altKey, button, ctrlKey, metaKey, shiftKey } = event;\n\n fireNonCancelableEvent(onItemClick, { id, altKey, button, ctrlKey, metaKey, shiftKey });\n };\n\n useEffect(() => {\n navigationAPI.current?.updateFocusTarget();\n });\n\n function onFocus(event: React.FocusEvent) {\n if (event.target instanceof HTMLElement && event.target.dataset.itemid) {\n focusedIdRef.current = event.target.dataset.itemid;\n }\n\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onBlur() {\n navigationAPI.current?.updateFocusTarget();\n }\n\n function onKeyDown(event: React.KeyboardEvent) {\n const focusTarget = navigationAPI.current?.getFocusTarget();\n const specialKeys = [\n KeyCode.right,\n KeyCode.left,\n KeyCode.up,\n KeyCode.down,\n KeyCode.end,\n KeyCode.home,\n KeyCode.pageUp,\n KeyCode.pageDown,\n ];\n\n const hasModifierKeys = (event: React.MouseEvent | React.KeyboardEvent) => {\n return event.ctrlKey || event.altKey || event.shiftKey || event.metaKey;\n };\n\n if (hasModifierKeys(event) || !specialKeys.includes(event.keyCode)) {\n return;\n }\n if (!containerObjectRef.current || !focusTarget) {\n return;\n }\n // Ignore navigation when the focused element is not an item.\n if (document.activeElement && !document.activeElement.matches(`.${styles[\"support-prompt\"]}`)) {\n return;\n }\n event.preventDefault();\n\n const focusables = getFocusablesFrom(containerObjectRef.current);\n const activeIndex = focusables.indexOf(focusTarget);\n handleKey(event as any, {\n onHome: () => focusElement(focusables[0]),\n onEnd: () => focusElement(focusables[focusables.length - 1]),\n onInlineStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onInlineEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n onBlockStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),\n onBlockEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),\n });\n }\n\n function focusElement(element: HTMLElement) {\n element.focus();\n }\n\n // List all non-disabled and registered focusables: those are eligible for keyboard navigation.\n function getFocusablesFrom(target: HTMLElement) {\n function isElementRegistered(element: HTMLElement) {\n return navigationAPI.current?.isRegistered(element) ?? false;\n }\n\n return getAllFocusables(target).filter((el) => isElementRegistered(el));\n }\n\n if (!items || items.length === 0) {\n return <div />;\n }\n\n return (\n <div\n {...getDataAttributes(rest)}\n role=\"menubar\"\n className={clsx(styles.root, { [styles.vertical]: alignment !== \"horizontal\" })}\n aria-label={ariaLabel}\n onFocus={onFocus}\n onBlur={onBlur}\n onKeyDown={onKeyDown}\n ref={mergedRef}\n >\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={true}\n getNextFocusTarget={() => getNextFocusTarget(containerObjectRef, focusedIdRef)}\n onUnregisterActive={(element: HTMLElement) => onUnregisterActive(element, navigationAPI)}\n >\n {items.map((item, index) => {\n return (\n <Prompt\n key={index}\n onClick={(event) => handleClick(event, item.id)}\n id={item.id}\n ref={(element) => (itemsRef.current[item.id] = element)}\n iconName={item.iconName}\n iconSvg={item.iconSvg}\n iconPosition={item.iconPosition}\n iconVerticalAlignment={item.iconVerticalAlignment}\n ariaLabel={item.ariaLabel}\n >\n {item.text}\n </Prompt>\n );\n })}\n </SingleTabStopNavigationProvider>\n </div>\n );\n },\n);\n"]}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { IconProps } from "@cloudscape-design/components/icon";
|
|
1
2
|
export interface PromptProps {
|
|
2
3
|
children: string;
|
|
3
4
|
id: string;
|
|
4
5
|
onClick: (event: React.MouseEvent, id: string) => void;
|
|
6
|
+
iconName?: IconProps.Name;
|
|
7
|
+
iconSvg?: React.ReactNode;
|
|
8
|
+
iconPosition?: "left" | "right";
|
|
9
|
+
iconVerticalAlignment?: "center" | "start" | "end";
|
|
10
|
+
ariaLabel?: string;
|
|
5
11
|
}
|
|
6
12
|
export declare const Prompt: import("react").ForwardRefExoticComponent<PromptProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import { forwardRef, useRef } from "react";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { useSingleTabStopNavigation } from "@cloudscape-design/component-toolkit/internal";
|
|
7
|
+
import Icon from "@cloudscape-design/components/icon";
|
|
7
8
|
import useForwardFocus from "../internal/utils/use-forward-focus";
|
|
8
9
|
import styles from "./styles.css.js";
|
|
9
|
-
export const Prompt = forwardRef(({ children, id, onClick }, ref) => {
|
|
10
|
+
export const Prompt = forwardRef(({ children, id, onClick, iconName, iconSvg, iconPosition = "left", iconVerticalAlignment = "start", ariaLabel, }, ref) => {
|
|
10
11
|
const buttonRef = useRef(null);
|
|
11
12
|
useForwardFocus(ref, buttonRef);
|
|
12
13
|
const { tabIndex } = useSingleTabStopNavigation(buttonRef);
|
|
13
|
-
|
|
14
|
+
// Helper function to conditionally render the icon
|
|
15
|
+
// iconSvg takes precedence over iconName
|
|
16
|
+
const renderIcon = () => {
|
|
17
|
+
if (!iconSvg && !iconName) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("span", { className: clsx(styles["support-prompt-icon"], styles[`icon-align-${iconVerticalAlignment}`]), children: _jsx(Icon, { name: iconName, svg: iconSvg, size: "inherit" }) }));
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("button", { role: "menuitem", tabIndex: tabIndex, ref: buttonRef, onClick: (event) => {
|
|
14
23
|
onClick(event, id);
|
|
15
|
-
}, id: id, "data-testid": id, "data-itemid": id, className: clsx(styles["support-prompt"]), children: children }));
|
|
24
|
+
}, id: id, "data-testid": id, "data-itemid": id, className: clsx(styles["support-prompt"]), "aria-label": ariaLabel, children: [iconPosition !== "right" && renderIcon(), _jsx("span", { className: styles["support-prompt-text"], children: children }), iconPosition === "right" && renderIcon()] }));
|
|
16
25
|
});
|
|
17
26
|
//# sourceMappingURL=prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/support-prompt-group/prompt.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,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AAE,IAAI,EAAC,SAAS,GAAG,GAChD,CACR,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CACL,kBACE,IAAI,EAAC,UAAU,EACf,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACrB,CAAC,EACD,EAAE,EAAE,EAAE,iBACO,EAAE,iBACF,EAAE,EACf,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,gBAC7B,SAAS,aAEpB,YAAY,KAAK,OAAO,IAAI,UAAU,EAAE,EACzC,eAAM,SAAS,EAAE,MAAM,CAAC,qBAAqB,CAAC,YAAG,QAAQ,GAAQ,EAChE,YAAY,KAAK,OAAO,IAAI,UAAU,EAAE,IAClC,CACV,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { forwardRef, Ref, useRef } from \"react\";\nimport clsx from \"clsx\";\n\nimport { useSingleTabStopNavigation } from \"@cloudscape-design/component-toolkit/internal\";\nimport Icon, { IconProps } from \"@cloudscape-design/components/icon\";\n\nimport useForwardFocus from \"../internal/utils/use-forward-focus\";\n\nimport styles from \"./styles.css.js\";\n\nexport interface PromptProps {\n children: string;\n id: string;\n onClick: (event: React.MouseEvent, id: string) => void;\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n iconPosition?: \"left\" | \"right\";\n iconVerticalAlignment?: \"center\" | \"start\" | \"end\";\n ariaLabel?: string;\n}\n\nexport const Prompt = forwardRef(\n (\n {\n children,\n id,\n onClick,\n iconName,\n iconSvg,\n iconPosition = \"left\",\n iconVerticalAlignment = \"start\",\n ariaLabel,\n }: PromptProps,\n ref: Ref<HTMLButtonElement | null>,\n ) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\n\n // Helper function to conditionally render the icon\n // iconSvg takes precedence over iconName\n const renderIcon = () => {\n if (!iconSvg && !iconName) {\n return null;\n }\n\n return (\n <span className={clsx(styles[\"support-prompt-icon\"], styles[`icon-align-${iconVerticalAlignment}`])}>\n <Icon name={iconName} svg={iconSvg} size=\"inherit\" />\n </span>\n );\n };\n\n return (\n <button\n role=\"menuitem\"\n tabIndex={tabIndex}\n ref={buttonRef}\n onClick={(event) => {\n onClick(event, id);\n }}\n id={id}\n data-testid={id}\n data-itemid={id}\n className={clsx(styles[\"support-prompt\"])}\n aria-label={ariaLabel}\n >\n {iconPosition !== \"right\" && renderIcon()}\n <span className={styles[\"support-prompt-text\"]}>{children}</span>\n {iconPosition === \"right\" && renderIcon()}\n </button>\n );\n },\n);\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"root": "
|
|
5
|
-
"vertical": "
|
|
6
|
-
"support-prompt": "awsui_support-
|
|
4
|
+
"root": "awsui_root_1wevk_fboqd_11",
|
|
5
|
+
"vertical": "awsui_vertical_1wevk_fboqd_41",
|
|
6
|
+
"support-prompt": "awsui_support-prompt_1wevk_fboqd_45",
|
|
7
|
+
"support-prompt-icon": "awsui_support-prompt-icon_1wevk_fboqd_102",
|
|
8
|
+
"icon-align-center": "awsui_icon-align-center_1wevk_fboqd_106",
|
|
9
|
+
"icon-align-start": "awsui_icon-align-start_1wevk_fboqd_109",
|
|
10
|
+
"icon-align-end": "awsui_icon-align-end_1wevk_fboqd_112",
|
|
11
|
+
"support-prompt-text": "awsui_support-prompt-text_1wevk_fboqd_116"
|
|
7
12
|
};
|
|
8
13
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
/* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
10
10
|
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
11
|
-
.
|
|
11
|
+
.awsui_root_1wevk_fboqd_11:not(#\9) {
|
|
12
12
|
border-collapse: separate;
|
|
13
13
|
border-spacing: 0;
|
|
14
14
|
box-sizing: border-box;
|
|
@@ -38,12 +38,15 @@
|
|
|
38
38
|
flex-wrap: wrap;
|
|
39
39
|
gap: var(--space-scaled-xs-xwoogq, 8px);
|
|
40
40
|
}
|
|
41
|
-
.
|
|
41
|
+
.awsui_root_1wevk_fboqd_11.awsui_vertical_1wevk_fboqd_41:not(#\9) {
|
|
42
42
|
flex-direction: column;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.awsui_support-
|
|
45
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9) {
|
|
46
46
|
cursor: pointer;
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: var(--space-scaled-xs-xwoogq, 8px);
|
|
47
50
|
font-family: var(--font-family-base-gmnpzl, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
|
|
48
51
|
font-size: var(--font-size-body-m-a7nh2n, 14px);
|
|
49
52
|
line-height: var(--line-height-heading-m-uoaqdh, 22px);
|
|
@@ -60,26 +63,26 @@
|
|
|
60
63
|
border-end-end-radius: var(--space-static-xs-gnm0mz, 8px);
|
|
61
64
|
inline-size: fit-content;
|
|
62
65
|
}
|
|
63
|
-
.awsui_support-
|
|
66
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9):hover {
|
|
64
67
|
color: var(--color-text-button-normal-hover-gusgyv, #002b66);
|
|
65
68
|
background: var(--color-background-button-normal-hover-53op9s, #f0fbff);
|
|
66
69
|
border-color: var(--color-border-button-normal-hover-6a2tdq, #002b66);
|
|
67
70
|
}
|
|
68
|
-
.awsui_support-
|
|
71
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9):active {
|
|
69
72
|
color: var(--color-text-button-normal-active-vihsxh, #002b66);
|
|
70
73
|
background: var(--color-background-button-normal-active-5imwxd, #d1f1ff);
|
|
71
74
|
border-color: var(--color-border-button-normal-active-ru7yhb, #002b66);
|
|
72
75
|
}
|
|
73
|
-
.awsui_support-
|
|
76
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9):focus {
|
|
74
77
|
outline: none;
|
|
75
78
|
}
|
|
76
|
-
.awsui_support-
|
|
79
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9):focus-visible {
|
|
77
80
|
position: relative;
|
|
78
81
|
box-sizing: border-box;
|
|
79
82
|
outline: 2px dotted transparent;
|
|
80
83
|
outline-offset: 5px;
|
|
81
84
|
}
|
|
82
|
-
.awsui_support-
|
|
85
|
+
.awsui_support-prompt_1wevk_fboqd_45:not(#\9):focus-visible::before {
|
|
83
86
|
content: " ";
|
|
84
87
|
display: block;
|
|
85
88
|
position: absolute;
|
|
@@ -94,4 +97,22 @@
|
|
|
94
97
|
border-end-end-radius: 6px;
|
|
95
98
|
border-block: 2px solid var(--color-border-item-focused-uk47pl, #006ce0);
|
|
96
99
|
border-inline: 2px solid var(--color-border-item-focused-uk47pl, #006ce0);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.awsui_support-prompt-icon_1wevk_fboqd_102:not(#\9) {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
flex-shrink: 0;
|
|
105
|
+
}
|
|
106
|
+
.awsui_support-prompt-icon_1wevk_fboqd_102.awsui_icon-align-center_1wevk_fboqd_106:not(#\9) {
|
|
107
|
+
align-self: center;
|
|
108
|
+
}
|
|
109
|
+
.awsui_support-prompt-icon_1wevk_fboqd_102.awsui_icon-align-start_1wevk_fboqd_109:not(#\9) {
|
|
110
|
+
align-self: flex-start;
|
|
111
|
+
}
|
|
112
|
+
.awsui_support-prompt-icon_1wevk_fboqd_102.awsui_icon-align-end_1wevk_fboqd_112:not(#\9) {
|
|
113
|
+
align-self: flex-end;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.awsui_support-prompt-text_1wevk_fboqd_116:not(#\9) {
|
|
117
|
+
display: inline-flex;
|
|
97
118
|
}
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
// es-module interop with Babel and Typescript
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
module.exports.default = {
|
|
5
|
-
"root": "
|
|
6
|
-
"vertical": "
|
|
7
|
-
"support-prompt": "awsui_support-
|
|
5
|
+
"root": "awsui_root_1wevk_fboqd_11",
|
|
6
|
+
"vertical": "awsui_vertical_1wevk_fboqd_41",
|
|
7
|
+
"support-prompt": "awsui_support-prompt_1wevk_fboqd_45",
|
|
8
|
+
"support-prompt-icon": "awsui_support-prompt-icon_1wevk_fboqd_102",
|
|
9
|
+
"icon-align-center": "awsui_icon-align-center_1wevk_fboqd_106",
|
|
10
|
+
"icon-align-start": "awsui_icon-align-start_1wevk_fboqd_109",
|
|
11
|
+
"icon-align-end": "awsui_icon-align-end_1wevk_fboqd_112",
|
|
12
|
+
"support-prompt-text": "awsui_support-prompt-text_1wevk_fboqd_116"
|
|
8
13
|
};
|
|
9
14
|
|