@cloudscape-design/chat-components 1.0.20 → 1.0.22

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.
Files changed (47) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +1 -0
  3. package/index.js.map +1 -1
  4. package/internal/api-docs/components/index.js +2 -1
  5. package/internal/api-docs/components/support-prompt-group.js +90 -0
  6. package/internal/api-docs/test-utils-doc/dom.js +1 -1
  7. package/internal/api-docs/test-utils-doc/selectors.js +1 -1
  8. package/internal/environment.js +1 -1
  9. package/internal/environment.json +1 -1
  10. package/internal/events/index.d.ts +23 -0
  11. package/internal/events/index.js +39 -0
  12. package/internal/events/index.js.map +1 -0
  13. package/internal/manifest.json +1 -1
  14. package/internal/utils/use-forward-focus.d.ts +7 -0
  15. package/internal/utils/use-forward-focus.js +12 -0
  16. package/internal/utils/use-forward-focus.js.map +1 -0
  17. package/package.json +2 -1
  18. package/support-prompt-group/focus-helpers.d.ts +5 -0
  19. package/support-prompt-group/focus-helpers.js +25 -0
  20. package/support-prompt-group/focus-helpers.js.map +1 -0
  21. package/support-prompt-group/index.d.ts +5 -0
  22. package/support-prompt-group/index.js +14 -0
  23. package/support-prompt-group/index.js.map +1 -0
  24. package/support-prompt-group/interfaces.d.ts +39 -0
  25. package/support-prompt-group/interfaces.js +4 -0
  26. package/support-prompt-group/interfaces.js.map +1 -0
  27. package/support-prompt-group/internal.d.ts +4 -0
  28. package/support-prompt-group/internal.js +105 -0
  29. package/support-prompt-group/internal.js.map +1 -0
  30. package/support-prompt-group/prompt.d.ts +7 -0
  31. package/support-prompt-group/prompt.js +17 -0
  32. package/support-prompt-group/prompt.js.map +1 -0
  33. package/support-prompt-group/styles.css.js +8 -0
  34. package/support-prompt-group/styles.scoped.css +94 -0
  35. package/support-prompt-group/styles.selectors.js +9 -0
  36. package/test-utils/dom/index.d.ts +20 -0
  37. package/test-utils/dom/index.js +12 -1
  38. package/test-utils/dom/index.js.map +1 -1
  39. package/test-utils/dom/support-prompt-group/index.d.ts +15 -0
  40. package/test-utils/dom/support-prompt-group/index.js +30 -0
  41. package/test-utils/dom/support-prompt-group/index.js.map +1 -0
  42. package/test-utils/selectors/index.d.ts +18 -0
  43. package/test-utils/selectors/index.js +12 -1
  44. package/test-utils/selectors/index.js.map +1 -1
  45. package/test-utils/selectors/support-prompt-group/index.d.ts +15 -0
  46. package/test-utils/selectors/support-prompt-group/index.js +30 -0
  47. package/test-utils/selectors/support-prompt-group/index.js.map +1 -0
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
3
+ import { SupportPromptGroupProps } from "./interfaces";
4
+ export declare const InternalSupportPromptGroup: import("react").ForwardRefExoticComponent<SupportPromptGroupProps & InternalBaseComponentProps & import("react").RefAttributes<SupportPromptGroupProps.Ref>>;
@@ -0,0 +1,105 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
5
+ import clsx from "clsx";
6
+ import { circleIndex, getAllFocusables, handleKey, KeyCode, SingleTabStopNavigationProvider, warnOnce, } from "@cloudscape-design/component-toolkit/internal";
7
+ import { getDataAttributes } from "../internal/base-component/get-data-attributes";
8
+ import { fireNonCancelableEvent } from "../internal/events";
9
+ import { useMergeRefs } from "../internal/utils/use-merge-refs";
10
+ import { getNextFocusTarget, onUnregisterActive } from "./focus-helpers";
11
+ import { Prompt } from "./prompt";
12
+ import styles from "./styles.css.js";
13
+ export const InternalSupportPromptGroup = forwardRef(({ alignment = "vertical", onItemClick, items, __internalRootRef, ariaLabel, ...rest }, ref) => {
14
+ const focusedIdRef = useRef(null);
15
+ const navigationAPI = useRef(null);
16
+ const containerObjectRef = useRef(null);
17
+ const itemsRef = useRef({});
18
+ const mergedRef = useMergeRefs(containerObjectRef, __internalRootRef);
19
+ useImperativeHandle(ref, () => ({
20
+ focus: (id) => {
21
+ var _a;
22
+ if (!itemsRef.current[id]) {
23
+ warnOnce("SupportPromptGroup", "No matching ID found to focus.");
24
+ }
25
+ (_a = itemsRef.current[id]) === null || _a === void 0 ? void 0 : _a.focus();
26
+ },
27
+ }));
28
+ const handleClick = (event, id) => {
29
+ const { altKey, button, ctrlKey, metaKey, shiftKey } = event;
30
+ fireNonCancelableEvent(onItemClick, { id, altKey, button, ctrlKey, metaKey, shiftKey });
31
+ };
32
+ useEffect(() => {
33
+ var _a;
34
+ (_a = navigationAPI.current) === null || _a === void 0 ? void 0 : _a.updateFocusTarget();
35
+ });
36
+ function onFocus(event) {
37
+ var _a;
38
+ if (event.target instanceof HTMLElement && event.target.dataset.itemid) {
39
+ focusedIdRef.current = event.target.dataset.itemid;
40
+ }
41
+ (_a = navigationAPI.current) === null || _a === void 0 ? void 0 : _a.updateFocusTarget();
42
+ }
43
+ function onBlur() {
44
+ var _a;
45
+ (_a = navigationAPI.current) === null || _a === void 0 ? void 0 : _a.updateFocusTarget();
46
+ }
47
+ function onKeyDown(event) {
48
+ var _a;
49
+ const focusTarget = (_a = navigationAPI.current) === null || _a === void 0 ? void 0 : _a.getFocusTarget();
50
+ const specialKeys = [
51
+ KeyCode.right,
52
+ KeyCode.left,
53
+ KeyCode.up,
54
+ KeyCode.down,
55
+ KeyCode.end,
56
+ KeyCode.home,
57
+ KeyCode.pageUp,
58
+ KeyCode.pageDown,
59
+ ];
60
+ const hasModifierKeys = (event) => {
61
+ return event.ctrlKey || event.altKey || event.shiftKey || event.metaKey;
62
+ };
63
+ if (hasModifierKeys(event) || !specialKeys.includes(event.keyCode)) {
64
+ return;
65
+ }
66
+ if (!containerObjectRef.current || !focusTarget) {
67
+ return;
68
+ }
69
+ // Ignore navigation when the focused element is not an item.
70
+ if (document.activeElement && !document.activeElement.matches(`.${styles["support-prompt"]}`)) {
71
+ return;
72
+ }
73
+ event.preventDefault();
74
+ const focusables = getFocusablesFrom(containerObjectRef.current);
75
+ const activeIndex = focusables.indexOf(focusTarget);
76
+ handleKey(event, {
77
+ onHome: () => focusElement(focusables[0]),
78
+ onEnd: () => focusElement(focusables[focusables.length - 1]),
79
+ onInlineStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),
80
+ onInlineEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),
81
+ onBlockStart: () => focusElement(focusables[circleIndex(activeIndex - 1, [0, focusables.length - 1])]),
82
+ onBlockEnd: () => focusElement(focusables[circleIndex(activeIndex + 1, [0, focusables.length - 1])]),
83
+ });
84
+ }
85
+ function focusElement(element) {
86
+ element.focus();
87
+ }
88
+ // List all non-disabled and registered focusables: those are eligible for keyboard navigation.
89
+ function getFocusablesFrom(target) {
90
+ function isElementRegistered(element) {
91
+ var _a, _b;
92
+ return (_b = (_a = navigationAPI.current) === null || _a === void 0 ? void 0 : _a.isRegistered(element)) !== null && _b !== void 0 ? _b : false;
93
+ }
94
+ return getAllFocusables(target).filter((el) => isElementRegistered(el));
95
+ }
96
+ if (!items || items.length === 0) {
97
+ return _jsx("div", {});
98
+ }
99
+ return (_jsx("div", { ...getDataAttributes(rest), role: "menubar", className: clsx(styles.root, {
100
+ [styles.vertical]: alignment !== "horizontal",
101
+ }), "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) => {
102
+ return (_jsx(Prompt, { onClick: (event) => handleClick(event, item.id), id: item.id, ref: (element) => (itemsRef.current[item.id] = element), children: item.text }, index));
103
+ }) }) }));
104
+ });
105
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../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,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 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 { useMergeRefs } from \"../internal/utils/use-merge-refs\";\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, {\n [styles.vertical]: alignment !== \"horizontal\",\n })}\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"]}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface PromptProps {
3
+ children: string;
4
+ id: string;
5
+ onClick: (event: React.MouseEvent, id: string) => void;
6
+ }
7
+ export declare const Prompt: import("react").ForwardRefExoticComponent<PromptProps & import("react").RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { forwardRef, useRef } from "react";
5
+ import clsx from "clsx";
6
+ import { useSingleTabStopNavigation } from "@cloudscape-design/component-toolkit/internal";
7
+ import useForwardFocus from "../internal/utils/use-forward-focus";
8
+ import styles from "./styles.css.js";
9
+ export const Prompt = forwardRef(({ children, id, onClick }, ref) => {
10
+ const buttonRef = useRef(null);
11
+ useForwardFocus(ref, buttonRef);
12
+ const { tabIndex } = useSingleTabStopNavigation(buttonRef);
13
+ return (_jsx("button", { role: "menuitem", tabIndex: tabIndex, ref: buttonRef, onClick: (event) => {
14
+ onClick(event, id);
15
+ }, id: id, "data-testid": id, "data-itemid": id, className: clsx(styles["support-prompt"]), children: children }));
16
+ });
17
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/support-prompt-group/prompt.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,UAAU,EAAO,MAAM,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAE3F,OAAO,eAAe,MAAM,qCAAqC,CAAC;AAElE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAe,EAAE,GAAkC,EAAE,EAAE;IAC9G,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAClD,eAAe,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAEhC,MAAM,EAAE,QAAQ,EAAE,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IAE3D,OAAO,CACL,iBACE,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,YAExC,QAAQ,GACF,CACV,CAAC;AACJ,CAAC,CAAC,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\";\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}\n\nexport const Prompt = forwardRef(({ children, id, onClick }: PromptProps, ref: Ref<HTMLButtonElement | null>) => {\n const buttonRef = useRef<HTMLButtonElement>(null);\n useForwardFocus(ref, buttonRef);\n\n const { tabIndex } = useSingleTabStopNavigation(buttonRef);\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 >\n {children}\n </button>\n );\n});\n"]}
@@ -0,0 +1,8 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1wevk_1hy7e_11",
5
+ "vertical": "awsui_vertical_1wevk_1hy7e_41",
6
+ "support-prompt": "awsui_support-prompt_1wevk_1hy7e_45"
7
+ };
8
+
@@ -0,0 +1,94 @@
1
+ /*
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ /*
6
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
7
+ SPDX-License-Identifier: Apache-2.0
8
+ */
9
+ /* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
10
+ /* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
11
+ .awsui_root_1wevk_1hy7e_11:not(#\9) {
12
+ border-collapse: separate;
13
+ border-spacing: 0;
14
+ box-sizing: border-box;
15
+ caption-side: top;
16
+ cursor: auto;
17
+ direction: inherit;
18
+ empty-cells: show;
19
+ font-family: serif;
20
+ font-size: medium;
21
+ font-style: normal;
22
+ font-variant: normal;
23
+ font-weight: 400;
24
+ font-stretch: normal;
25
+ line-height: normal;
26
+ -webkit-hyphens: none;
27
+ hyphens: none;
28
+ letter-spacing: normal;
29
+ list-style: disc outside none;
30
+ tab-size: 8;
31
+ text-align: start;
32
+ text-indent: 0;
33
+ text-shadow: none;
34
+ text-transform: none;
35
+ visibility: visible;
36
+ white-space: normal;
37
+ word-spacing: normal;
38
+ display: flex;
39
+ flex-wrap: wrap;
40
+ gap: var(--space-scaled-xs-26e2du, 8px);
41
+ }
42
+ .awsui_root_1wevk_1hy7e_11.awsui_vertical_1wevk_1hy7e_41:not(#\9) {
43
+ flex-direction: column;
44
+ }
45
+
46
+ .awsui_support-prompt_1wevk_1hy7e_45:not(#\9) {
47
+ cursor: pointer;
48
+ font-family: var(--font-family-base-dnvic8, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
49
+ font-size: var(--font-size-body-m-x4okxb, 14px);
50
+ line-height: var(--line-height-heading-m-50evfk, 22px);
51
+ text-align: start;
52
+ padding-block: var(--space-scaled-xs-26e2du, 8px);
53
+ padding-inline: var(--space-static-s-n2eb28, 12px);
54
+ color: var(--color-text-button-normal-default-476t5h, #006ce0);
55
+ background: var(--color-background-button-normal-default-zr63bz, #ffffff);
56
+ border: 1px solid var(--color-border-button-normal-default-uzqi0v, #006ce0);
57
+ border-start-start-radius: var(--space-static-xs-7sfb63, 8px);
58
+ border-start-end-radius: var(--space-static-xs-7sfb63, 8px);
59
+ border-end-start-radius: var(--space-static-xs-7sfb63, 8px);
60
+ border-end-end-radius: var(--space-static-xs-7sfb63, 8px);
61
+ inline-size: -moz-fit-content;
62
+ inline-size: fit-content;
63
+ }
64
+ .awsui_support-prompt_1wevk_1hy7e_45:not(#\9):hover {
65
+ color: var(--color-text-button-normal-hover-e3tg09, #002b66);
66
+ background: var(--color-background-button-normal-hover-eqpcl2, #f0fbff);
67
+ border-color: var(--color-border-button-normal-hover-2d2g0m, #002b66);
68
+ }
69
+ .awsui_support-prompt_1wevk_1hy7e_45:not(#\9):active {
70
+ color: var(--color-text-button-normal-active-fdnwsh, #002b66);
71
+ background: var(--color-background-button-normal-active-udb472, #d1f1ff);
72
+ border-color: var(--color-border-button-normal-active-mn0ayd, #002b66);
73
+ }
74
+ .awsui_support-prompt_1wevk_1hy7e_45:not(#\9):focus {
75
+ outline: none;
76
+ }
77
+ body[data-awsui-focus-visible=true] .awsui_support-prompt_1wevk_1hy7e_45:not(#\9):focus:focus {
78
+ position: relative;
79
+ box-sizing: border-box;
80
+ outline: 2px dotted transparent;
81
+ outline-offset: 5px;
82
+ }
83
+ body[data-awsui-focus-visible=true] .awsui_support-prompt_1wevk_1hy7e_45:not(#\9):focus:focus::before {
84
+ content: " ";
85
+ display: block;
86
+ position: absolute;
87
+ box-sizing: border-box;
88
+ inset-inline-start: calc(-1 * 6px);
89
+ inset-block-start: calc(-1 * 6px);
90
+ inline-size: calc(100% + 2 * 6px);
91
+ block-size: calc(100% + 2 * 6px);
92
+ border-radius: 6px;
93
+ border: 2px solid var(--color-border-item-focused-nv6mhz, #006ce0);
94
+ }
@@ -0,0 +1,9 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_1wevk_1hy7e_11",
6
+ "vertical": "awsui_vertical_1wevk_1hy7e_41",
7
+ "support-prompt": "awsui_support-prompt_1wevk_1hy7e_45"
8
+ };
9
+
@@ -3,9 +3,11 @@ export { ElementWrapper };
3
3
  import AvatarWrapper from './avatar';
4
4
  import ChatBubbleWrapper from './chat-bubble';
5
5
  import LoadingBarWrapper from './loading-bar';
6
+ import SupportPromptGroupWrapper from './support-prompt-group';
6
7
  export { AvatarWrapper };
7
8
  export { ChatBubbleWrapper };
8
9
  export { LoadingBarWrapper };
10
+ export { SupportPromptGroupWrapper };
9
11
  declare module '@cloudscape-design/test-utils-core/dist/dom' {
10
12
  interface ElementWrapper {
11
13
  /**
@@ -62,6 +64,24 @@ declare module '@cloudscape-design/test-utils-core/dist/dom' {
62
64
  * @returns {Array<LoadingBarWrapper>}
63
65
  */
64
66
  findAllLoadingBars(selector?: string): Array<LoadingBarWrapper>;
67
+ /**
68
+ * Returns the wrapper of the first SupportPromptGroup that matches the specified CSS selector.
69
+ * If no CSS selector is specified, returns the wrapper of the first SupportPromptGroup.
70
+ * If no matching SupportPromptGroup is found, returns `null`.
71
+ *
72
+ * @param {string} [selector] CSS Selector
73
+ * @returns {SupportPromptGroupWrapper | null}
74
+ */
75
+ findSupportPromptGroup(selector?: string): SupportPromptGroupWrapper | null;
76
+ /**
77
+ * Returns an array of SupportPromptGroup wrapper that matches the specified CSS selector.
78
+ * If no CSS selector is specified, returns all of the SupportPromptGroups inside the current wrapper.
79
+ * If no matching SupportPromptGroup is found, returns an empty array.
80
+ *
81
+ * @param {string} [selector] CSS Selector
82
+ * @returns {Array<SupportPromptGroupWrapper>}
83
+ */
84
+ findAllSupportPromptGroups(selector?: string): Array<SupportPromptGroupWrapper>;
65
85
  }
66
86
  }
67
87
  export default function wrapper(root?: Element): ElementWrapper<Element>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoadingBarWrapper = exports.ChatBubbleWrapper = exports.AvatarWrapper = exports.ElementWrapper = void 0;
3
+ exports.SupportPromptGroupWrapper = exports.LoadingBarWrapper = exports.ChatBubbleWrapper = exports.AvatarWrapper = exports.ElementWrapper = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  const dom_1 = require("@cloudscape-design/test-utils-core/dom");
@@ -12,6 +12,8 @@ const chat_bubble_1 = require("./chat-bubble");
12
12
  exports.ChatBubbleWrapper = chat_bubble_1.default;
13
13
  const loading_bar_1 = require("./loading-bar");
14
14
  exports.LoadingBarWrapper = loading_bar_1.default;
15
+ const support_prompt_group_1 = require("./support-prompt-group");
16
+ exports.SupportPromptGroupWrapper = support_prompt_group_1.default;
15
17
  dom_1.ElementWrapper.prototype.findAvatar = function (selector) {
16
18
  const rootSelector = `.${avatar_1.default.rootSelector}`;
17
19
  // casting to 'any' is needed to avoid this issue with generics
@@ -39,6 +41,15 @@ dom_1.ElementWrapper.prototype.findLoadingBar = function (selector) {
39
41
  dom_1.ElementWrapper.prototype.findAllLoadingBars = function (selector) {
40
42
  return this.findAllComponents(loading_bar_1.default, selector);
41
43
  };
44
+ dom_1.ElementWrapper.prototype.findSupportPromptGroup = function (selector) {
45
+ const rootSelector = `.${support_prompt_group_1.default.rootSelector}`;
46
+ // casting to 'any' is needed to avoid this issue with generics
47
+ // https://github.com/microsoft/TypeScript/issues/29132
48
+ return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, support_prompt_group_1.default);
49
+ };
50
+ dom_1.ElementWrapper.prototype.findAllSupportPromptGroups = function (selector) {
51
+ return this.findAllComponents(support_prompt_group_1.default, selector);
52
+ };
42
53
  function wrapper(root = document.body) {
43
54
  if (document && document.body && !document.body.contains(root)) {
44
55
  console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/dom/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,gEAAwE;AAG/D,+FAHA,oBAAc,OAGA;AAFvB,oEAA0E;AAI1E,qCAAqC;AAK5B,wBALF,gBAAa,CAKE;AAJtB,+CAA8C;AAKrC,4BALF,qBAAiB,CAKE;AAJ1B,+CAA8C;AAKrC,4BALF,qBAAiB,CAKE;AAkE1B,oBAAc,CAAC,SAAS,CAAC,UAAU,GAAG,UAAS,QAAQ;IACrD,MAAM,YAAY,GAAG,IAAI,gBAAa,CAAC,YAAY,EAAE,CAAC;IACtD,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,gBAAa,CAAC,CAAC;AACtH,CAAC,CAAC;AAEF,oBAAc,CAAC,SAAS,CAAC,cAAc,GAAG,UAAS,QAAQ;IACzD,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAa,EAAE,QAAQ,CAAC,CAAC;AACzD,CAAC,CAAC;AACF,oBAAc,CAAC,SAAS,CAAC,cAAc,GAAG,UAAS,QAAQ;IACzD,MAAM,YAAY,GAAG,IAAI,qBAAiB,CAAC,YAAY,EAAE,CAAC;IAC1D,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,qBAAiB,CAAC,CAAC;AAC1H,CAAC,CAAC;AAEF,oBAAc,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAS,QAAQ;IAC7D,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAiB,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC,CAAC;AACF,oBAAc,CAAC,SAAS,CAAC,cAAc,GAAG,UAAS,QAAQ;IACzD,MAAM,YAAY,GAAG,IAAI,qBAAiB,CAAC,YAAY,EAAE,CAAC;IAC1D,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,qBAAiB,CAAC,CAAC;AAC1H,CAAC,CAAC;AAEF,oBAAc,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAS,QAAQ;IAC7D,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAiB,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC,CAAC;AAGF,SAAwB,OAAO,CAAC,OAAgB,QAAQ,CAAC,IAAI;IAC3D,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAC9D,OAAO,CAAC,IAAI,CAAC,2GAA2G,CAAC,CAAA;KAC1H;IAAA,CAAC;IACF,OAAO,IAAI,oBAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AALD,0BAKC","sourcesContent":["\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ElementWrapper } from '@cloudscape-design/test-utils-core/dom';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport AvatarWrapper from './avatar';\nimport ChatBubbleWrapper from './chat-bubble';\nimport LoadingBarWrapper from './loading-bar';\n\n\nexport { AvatarWrapper };\nexport { ChatBubbleWrapper };\nexport { LoadingBarWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/dom' {\n interface ElementWrapper {\n \n/**\n * Returns the wrapper of the first Avatar that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first Avatar.\n * If no matching Avatar is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {AvatarWrapper | null}\n */\nfindAvatar(selector?: string): AvatarWrapper | null;\n\n/**\n * Returns an array of Avatar wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the Avatars inside the current wrapper.\n * If no matching Avatar is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<AvatarWrapper>}\n */\nfindAllAvatars(selector?: string): Array<AvatarWrapper>;\n/**\n * Returns the wrapper of the first ChatBubble that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first ChatBubble.\n * If no matching ChatBubble is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ChatBubbleWrapper | null}\n */\nfindChatBubble(selector?: string): ChatBubbleWrapper | null;\n\n/**\n * Returns an array of ChatBubble wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the ChatBubbles inside the current wrapper.\n * If no matching ChatBubble is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<ChatBubbleWrapper>}\n */\nfindAllChatBubbles(selector?: string): Array<ChatBubbleWrapper>;\n/**\n * Returns the wrapper of the first LoadingBar that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first LoadingBar.\n * If no matching LoadingBar is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {LoadingBarWrapper | null}\n */\nfindLoadingBar(selector?: string): LoadingBarWrapper | null;\n\n/**\n * Returns an array of LoadingBar wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the LoadingBars inside the current wrapper.\n * If no matching LoadingBar is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<LoadingBarWrapper>}\n */\nfindAllLoadingBars(selector?: string): Array<LoadingBarWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findAvatar = function(selector) {\n const rootSelector = `.${AvatarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);\n};\n\nElementWrapper.prototype.findAllAvatars = function(selector) {\n return this.findAllComponents(AvatarWrapper, selector);\n};\nElementWrapper.prototype.findChatBubble = function(selector) {\n const rootSelector = `.${ChatBubbleWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);\n};\n\nElementWrapper.prototype.findAllChatBubbles = function(selector) {\n return this.findAllComponents(ChatBubbleWrapper, selector);\n};\nElementWrapper.prototype.findLoadingBar = function(selector) {\n const rootSelector = `.${LoadingBarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);\n};\n\nElementWrapper.prototype.findAllLoadingBars = function(selector) {\n return this.findAllComponents(LoadingBarWrapper, selector);\n};\n\n\nexport default function wrapper(root: Element = document.body) {\n if (document && document.body && !document.body.contains(root)) {\n console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly')\n };\n return new ElementWrapper(root);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/dom/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,gEAAwE;AAG/D,+FAHA,oBAAc,OAGA;AAFvB,oEAA0E;AAI1E,qCAA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scape-design/test-utils-core/dom';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport AvatarWrapper from './avatar';\nimport ChatBubbleWrapper from './chat-bubble';\nimport LoadingBarWrapper from './loading-bar';\nimport SupportPromptGroupWrapper from './support-prompt-group';\n\n\nexport { AvatarWrapper };\nexport { ChatBubbleWrapper };\nexport { LoadingBarWrapper };\nexport { SupportPromptGroupWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/dom' {\n interface ElementWrapper {\n \n/**\n * Returns the wrapper of the first Avatar that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first Avatar.\n * If no matching Avatar is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {AvatarWrapper | null}\n */\nfindAvatar(selector?: string): AvatarWrapper | null;\n\n/**\n * Returns an array of Avatar wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the Avatars inside the current wrapper.\n * If no matching Avatar is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<AvatarWrapper>}\n */\nfindAllAvatars(selector?: string): Array<AvatarWrapper>;\n/**\n * Returns the wrapper of the first ChatBubble that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first ChatBubble.\n * If no matching ChatBubble is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ChatBubbleWrapper | null}\n */\nfindChatBubble(selector?: string): ChatBubbleWrapper | null;\n\n/**\n * Returns an array of ChatBubble wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the ChatBubbles inside the current wrapper.\n * If no matching ChatBubble is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<ChatBubbleWrapper>}\n */\nfindAllChatBubbles(selector?: string): Array<ChatBubbleWrapper>;\n/**\n * Returns the wrapper of the first LoadingBar that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first LoadingBar.\n * If no matching LoadingBar is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {LoadingBarWrapper | null}\n */\nfindLoadingBar(selector?: string): LoadingBarWrapper | null;\n\n/**\n * Returns an array of LoadingBar wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the LoadingBars inside the current wrapper.\n * If no matching LoadingBar is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<LoadingBarWrapper>}\n */\nfindAllLoadingBars(selector?: string): Array<LoadingBarWrapper>;\n/**\n * Returns the wrapper of the first SupportPromptGroup that matches the specified CSS selector.\n * If no CSS selector is specified, returns the wrapper of the first SupportPromptGroup.\n * If no matching SupportPromptGroup is found, returns `null`.\n *\n * @param {string} [selector] CSS Selector\n * @returns {SupportPromptGroupWrapper | null}\n */\nfindSupportPromptGroup(selector?: string): SupportPromptGroupWrapper | null;\n\n/**\n * Returns an array of SupportPromptGroup wrapper that matches the specified CSS selector.\n * If no CSS selector is specified, returns all of the SupportPromptGroups inside the current wrapper.\n * If no matching SupportPromptGroup is found, returns an empty array.\n *\n * @param {string} [selector] CSS Selector\n * @returns {Array<SupportPromptGroupWrapper>}\n */\nfindAllSupportPromptGroups(selector?: string): Array<SupportPromptGroupWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findAvatar = function(selector) {\n const rootSelector = `.${AvatarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);\n};\n\nElementWrapper.prototype.findAllAvatars = function(selector) {\n return this.findAllComponents(AvatarWrapper, selector);\n};\nElementWrapper.prototype.findChatBubble = function(selector) {\n const rootSelector = `.${ChatBubbleWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);\n};\n\nElementWrapper.prototype.findAllChatBubbles = function(selector) {\n return this.findAllComponents(ChatBubbleWrapper, selector);\n};\nElementWrapper.prototype.findLoadingBar = function(selector) {\n const rootSelector = `.${LoadingBarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);\n};\n\nElementWrapper.prototype.findAllLoadingBars = function(selector) {\n return this.findAllComponents(LoadingBarWrapper, selector);\n};\nElementWrapper.prototype.findSupportPromptGroup = function(selector) {\n const rootSelector = `.${SupportPromptGroupWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, SupportPromptGroupWrapper);\n};\n\nElementWrapper.prototype.findAllSupportPromptGroups = function(selector) {\n return this.findAllComponents(SupportPromptGroupWrapper, selector);\n};\n\n\nexport default function wrapper(root: Element = document.body) {\n if (document && document.body && !document.body.contains(root)) {\n console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly')\n };\n return new ElementWrapper(root);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { ComponentWrapper, ElementWrapper } from "@cloudscape-design/test-utils-core/dom";
2
+ export default class SupportPromptGroupWrapper extends ComponentWrapper {
3
+ static rootSelector: string;
4
+ /**
5
+ * Finds all items.
6
+ */
7
+ findItems(): Array<ElementWrapper>;
8
+ /**
9
+ * Finds a support prompt item by its id.
10
+ */
11
+ findItemById(id: string): null | SupportPromptWrapper;
12
+ }
13
+ export declare class SupportPromptWrapper extends ComponentWrapper<HTMLButtonElement> {
14
+ static rootSelector: string;
15
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SupportPromptWrapper = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const dom_1 = require("@cloudscape-design/test-utils-core/dom");
7
+ const styles_selectors_js_1 = require("../../../support-prompt-group/styles.selectors.js");
8
+ class SupportPromptGroupWrapper extends dom_1.ComponentWrapper {
9
+ /**
10
+ * Finds all items.
11
+ */
12
+ findItems() {
13
+ return this.findAllByClassName(styles_selectors_js_1.default["support-prompt"]);
14
+ }
15
+ /**
16
+ * Finds a support prompt item by its id.
17
+ */
18
+ findItemById(id) {
19
+ const itemSelector = `.${styles_selectors_js_1.default["support-prompt"]}[data-testid="${CSS.escape(id)}"]`;
20
+ const wrapper = this.find(itemSelector);
21
+ return wrapper && new SupportPromptWrapper(wrapper.getElement());
22
+ }
23
+ }
24
+ exports.default = SupportPromptGroupWrapper;
25
+ SupportPromptGroupWrapper.rootSelector = styles_selectors_js_1.default.root;
26
+ class SupportPromptWrapper extends dom_1.ComponentWrapper {
27
+ }
28
+ exports.SupportPromptWrapper = SupportPromptWrapper;
29
+ SupportPromptWrapper.rootSelector = styles_selectors_js_1.default["support-prompt"];
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/support-prompt-group/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,2FAAuE;AAEvE,MAAqB,yBAA0B,SAAQ,sBAAgB;IAGrE;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,kBAAkB,CAAC,6BAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,EAAU;QACrB,MAAM,YAAY,GAAG,IAAI,6BAAM,CAAC,gBAAgB,CAAC,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACrF,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAsC,CAAC;QAC7E,OAAO,OAAO,IAAI,IAAI,oBAAoB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACnE,CAAC;;AAjBH,4CAkBC;AAjBQ,sCAAY,GAAW,6BAAM,CAAC,IAAI,CAAC;AAmB5C,MAAa,oBAAqB,SAAQ,sBAAmC;;AAA7E,oDAEC;AADQ,iCAAY,GAAW,6BAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentWrapper, ElementWrapper } from \"@cloudscape-design/test-utils-core/dom\";\n\nimport styles from \"../../../support-prompt-group/styles.selectors.js\";\n\nexport default class SupportPromptGroupWrapper extends ComponentWrapper {\n static rootSelector: string = styles.root;\n\n /**\n * Finds all items.\n */\n findItems(): Array<ElementWrapper> {\n return this.findAllByClassName(styles[\"support-prompt\"]);\n }\n\n /**\n * Finds a support prompt item by its id.\n */\n findItemById(id: string): null | SupportPromptWrapper {\n const itemSelector = `.${styles[\"support-prompt\"]}[data-testid=\"${CSS.escape(id)}\"]`;\n const wrapper = this.find(itemSelector) as ElementWrapper<HTMLButtonElement>;\n return wrapper && new SupportPromptWrapper(wrapper.getElement());\n }\n}\n\nexport class SupportPromptWrapper extends ComponentWrapper<HTMLButtonElement> {\n static rootSelector: string = styles[\"support-prompt\"];\n}\n"]}
@@ -3,9 +3,11 @@ export { ElementWrapper };
3
3
  import AvatarWrapper from './avatar';
4
4
  import ChatBubbleWrapper from './chat-bubble';
5
5
  import LoadingBarWrapper from './loading-bar';
6
+ import SupportPromptGroupWrapper from './support-prompt-group';
6
7
  export { AvatarWrapper };
7
8
  export { ChatBubbleWrapper };
8
9
  export { LoadingBarWrapper };
10
+ export { SupportPromptGroupWrapper };
9
11
  declare module '@cloudscape-design/test-utils-core/dist/selectors' {
10
12
  interface ElementWrapper {
11
13
  /**
@@ -56,6 +58,22 @@ declare module '@cloudscape-design/test-utils-core/dist/selectors' {
56
58
  * @returns {MultiElementWrapper<LoadingBarWrapper>}
57
59
  */
58
60
  findAllLoadingBars(selector?: string): MultiElementWrapper<LoadingBarWrapper>;
61
+ /**
62
+ * Returns a wrapper that matches the SupportPromptGroups with the specified CSS selector.
63
+ * If no CSS selector is specified, returns a wrapper that matches SupportPromptGroups.
64
+ *
65
+ * @param {string} [selector] CSS Selector
66
+ * @returns {SupportPromptGroupWrapper}
67
+ */
68
+ findSupportPromptGroup(selector?: string): SupportPromptGroupWrapper;
69
+ /**
70
+ * Returns a multi-element wrapper that matches SupportPromptGroups with the specified CSS selector.
71
+ * If no CSS selector is specified, returns a multi-element wrapper that matches SupportPromptGroups.
72
+ *
73
+ * @param {string} [selector] CSS Selector
74
+ * @returns {MultiElementWrapper<SupportPromptGroupWrapper>}
75
+ */
76
+ findAllSupportPromptGroups(selector?: string): MultiElementWrapper<SupportPromptGroupWrapper>;
59
77
  }
60
78
  }
61
79
  export default function wrapper(root?: string): ElementWrapper;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoadingBarWrapper = exports.ChatBubbleWrapper = exports.AvatarWrapper = exports.ElementWrapper = void 0;
3
+ exports.SupportPromptGroupWrapper = exports.LoadingBarWrapper = exports.ChatBubbleWrapper = exports.AvatarWrapper = exports.ElementWrapper = void 0;
4
4
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
5
  // SPDX-License-Identifier: Apache-2.0
6
6
  const selectors_1 = require("@cloudscape-design/test-utils-core/selectors");
@@ -12,6 +12,8 @@ const chat_bubble_1 = require("./chat-bubble");
12
12
  exports.ChatBubbleWrapper = chat_bubble_1.default;
13
13
  const loading_bar_1 = require("./loading-bar");
14
14
  exports.LoadingBarWrapper = loading_bar_1.default;
15
+ const support_prompt_group_1 = require("./support-prompt-group");
16
+ exports.SupportPromptGroupWrapper = support_prompt_group_1.default;
15
17
  selectors_1.ElementWrapper.prototype.findAvatar = function (selector) {
16
18
  const rootSelector = `.${avatar_1.default.rootSelector}`;
17
19
  // casting to 'any' is needed to avoid this issue with generics
@@ -39,6 +41,15 @@ selectors_1.ElementWrapper.prototype.findLoadingBar = function (selector) {
39
41
  selectors_1.ElementWrapper.prototype.findAllLoadingBars = function (selector) {
40
42
  return this.findAllComponents(loading_bar_1.default, selector);
41
43
  };
44
+ selectors_1.ElementWrapper.prototype.findSupportPromptGroup = function (selector) {
45
+ const rootSelector = `.${support_prompt_group_1.default.rootSelector}`;
46
+ // casting to 'any' is needed to avoid this issue with generics
47
+ // https://github.com/microsoft/TypeScript/issues/29132
48
+ return this.findComponent(selector ? (0, utils_1.appendSelector)(selector, rootSelector) : rootSelector, support_prompt_group_1.default);
49
+ };
50
+ selectors_1.ElementWrapper.prototype.findAllSupportPromptGroups = function (selector) {
51
+ return this.findAllComponents(support_prompt_group_1.default, selector);
52
+ };
42
53
  function wrapper(root = 'body') {
43
54
  return new selectors_1.ElementWrapper(root);
44
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/selectors/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,4EAA8E;AAGrE,+FAHA,0BAAc,OAGA;AAFvB,oEAA0E;AAI1E,qCAAqC;AAK5B,wBALF,gBAAa,CAKE;AAJtB,+CAA8C;AAKrC,4BALF,qBAAiB,CAKE;AAJ1B,+CAA8C;AAKrC,4BALF,qBAAiB,CAKE;AA4D1B,0BAAc,CAAC,SAAS,CAAC,UAAU,GAAG,UAAS,QAAQ;IACrD,MAAM,YAAY,GAAG,IAAI,gBAAa,CAAC,YAAY,EAAE,CAAC;IACtD,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,gBAAa,CAAC,CAAC;AACtH,CAAC,CAAC;AAEF,0BAAc,CAAC,SAAS,CAAC,cAAc,GA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-License-Identifier: Apache-2.0\nimport { ElementWrapper } from '@cloudscape-design/test-utils-core/selectors';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport AvatarWrapper from './avatar';\nimport ChatBubbleWrapper from './chat-bubble';\nimport LoadingBarWrapper from './loading-bar';\n\n\nexport { AvatarWrapper };\nexport { ChatBubbleWrapper };\nexport { LoadingBarWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/selectors' {\n interface ElementWrapper {\n \n/**\n * Returns a wrapper that matches the Avatars with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches Avatars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {AvatarWrapper}\n */\nfindAvatar(selector?: string): AvatarWrapper;\n\n/**\n * Returns a multi-element wrapper that matches Avatars with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches Avatars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<AvatarWrapper>}\n */\nfindAllAvatars(selector?: string): MultiElementWrapper<AvatarWrapper>;\n/**\n * Returns a wrapper that matches the ChatBubbles with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches ChatBubbles.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ChatBubbleWrapper}\n */\nfindChatBubble(selector?: string): ChatBubbleWrapper;\n\n/**\n * Returns a multi-element wrapper that matches ChatBubbles with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches ChatBubbles.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<ChatBubbleWrapper>}\n */\nfindAllChatBubbles(selector?: string): MultiElementWrapper<ChatBubbleWrapper>;\n/**\n * Returns a wrapper that matches the LoadingBars with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches LoadingBars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {LoadingBarWrapper}\n */\nfindLoadingBar(selector?: string): LoadingBarWrapper;\n\n/**\n * Returns a multi-element wrapper that matches LoadingBars with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches LoadingBars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<LoadingBarWrapper>}\n */\nfindAllLoadingBars(selector?: string): MultiElementWrapper<LoadingBarWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findAvatar = function(selector) {\n const rootSelector = `.${AvatarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);\n};\n\nElementWrapper.prototype.findAllAvatars = function(selector) {\n return this.findAllComponents(AvatarWrapper, selector);\n};\nElementWrapper.prototype.findChatBubble = function(selector) {\n const rootSelector = `.${ChatBubbleWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);\n};\n\nElementWrapper.prototype.findAllChatBubbles = function(selector) {\n return this.findAllComponents(ChatBubbleWrapper, selector);\n};\nElementWrapper.prototype.findLoadingBar = function(selector) {\n const rootSelector = `.${LoadingBarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);\n};\n\nElementWrapper.prototype.findAllLoadingBars = function(selector) {\n return this.findAllComponents(LoadingBarWrapper, selector);\n};\n\n\nexport default function wrapper(root: string = 'body') {\n return new ElementWrapper(root);\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/test-utils/selectors/index.ts"],"names":[],"mappings":";;;AACA,qEAAqE;AACrE,sCAAsC;AACtC,4EAA8E;AAGrE,+FAHA,0BAAc,OAGA;AAFvB,oEAA0E;AAI1E,qCAAqC;AAM5B,wBANF,gBAAa,CAME;AALtB,+CA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CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,qBAAiB,CAAC,CAAC;AAC1H,CAAC,CAAC;AAEF,0BAAc,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAS,QAAQ;IAC7D,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAiB,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC,CAAC;AACF,0BAAc,CAAC,SAAS,CAAC,sBAAsB,GAAG,UAAS,QAAQ;IACjE,MAAM,YAAY,GAAG,IAAI,8BAAyB,CAAC,YAAY,EAAE,CAAC;IAClE,+DAA+D;IAC/D,uDAAuD;IACvD,OAAQ,IAAY,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,sBAAc,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,8BAAyB,CAAC,CAAC;AAClI,CAAC,CAAC;AAEF,0BAAc,CAAC,SAAS,CAAC,0BAA0B,GAAG,UAAS,QAAQ;IACrE,OAAO,IAAI,CAAC,iBAAiB,CAAC,8BAAyB,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC,CAAC;AAGF,SAAwB,OAAO,CAAC,OAAe,MAAM;IACnD,OAAO,IAAI,0BAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAFD,0BAEC","sourcesContent":["\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ElementWrapper } from '@cloudscape-design/test-utils-core/selectors';\nimport { appendSelector } from '@cloudscape-design/test-utils-core/utils';\n\nexport { ElementWrapper };\n\nimport AvatarWrapper from './avatar';\nimport ChatBubbleWrapper from './chat-bubble';\nimport LoadingBarWrapper from './loading-bar';\nimport SupportPromptGroupWrapper from './support-prompt-group';\n\n\nexport { AvatarWrapper };\nexport { ChatBubbleWrapper };\nexport { LoadingBarWrapper };\nexport { SupportPromptGroupWrapper };\n\ndeclare module '@cloudscape-design/test-utils-core/dist/selectors' {\n interface ElementWrapper {\n \n/**\n * Returns a wrapper that matches the Avatars with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches Avatars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {AvatarWrapper}\n */\nfindAvatar(selector?: string): AvatarWrapper;\n\n/**\n * Returns a multi-element wrapper that matches Avatars with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches Avatars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<AvatarWrapper>}\n */\nfindAllAvatars(selector?: string): MultiElementWrapper<AvatarWrapper>;\n/**\n * Returns a wrapper that matches the ChatBubbles with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches ChatBubbles.\n *\n * @param {string} [selector] CSS Selector\n * @returns {ChatBubbleWrapper}\n */\nfindChatBubble(selector?: string): ChatBubbleWrapper;\n\n/**\n * Returns a multi-element wrapper that matches ChatBubbles with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches ChatBubbles.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<ChatBubbleWrapper>}\n */\nfindAllChatBubbles(selector?: string): MultiElementWrapper<ChatBubbleWrapper>;\n/**\n * Returns a wrapper that matches the LoadingBars with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches LoadingBars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {LoadingBarWrapper}\n */\nfindLoadingBar(selector?: string): LoadingBarWrapper;\n\n/**\n * Returns a multi-element wrapper that matches LoadingBars with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches LoadingBars.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<LoadingBarWrapper>}\n */\nfindAllLoadingBars(selector?: string): MultiElementWrapper<LoadingBarWrapper>;\n/**\n * Returns a wrapper that matches the SupportPromptGroups with the specified CSS selector.\n * If no CSS selector is specified, returns a wrapper that matches SupportPromptGroups.\n *\n * @param {string} [selector] CSS Selector\n * @returns {SupportPromptGroupWrapper}\n */\nfindSupportPromptGroup(selector?: string): SupportPromptGroupWrapper;\n\n/**\n * Returns a multi-element wrapper that matches SupportPromptGroups with the specified CSS selector.\n * If no CSS selector is specified, returns a multi-element wrapper that matches SupportPromptGroups.\n *\n * @param {string} [selector] CSS Selector\n * @returns {MultiElementWrapper<SupportPromptGroupWrapper>}\n */\nfindAllSupportPromptGroups(selector?: string): MultiElementWrapper<SupportPromptGroupWrapper>;\n }\n}\n\n\nElementWrapper.prototype.findAvatar = function(selector) {\n const rootSelector = `.${AvatarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);\n};\n\nElementWrapper.prototype.findAllAvatars = function(selector) {\n return this.findAllComponents(AvatarWrapper, selector);\n};\nElementWrapper.prototype.findChatBubble = function(selector) {\n const rootSelector = `.${ChatBubbleWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);\n};\n\nElementWrapper.prototype.findAllChatBubbles = function(selector) {\n return this.findAllComponents(ChatBubbleWrapper, selector);\n};\nElementWrapper.prototype.findLoadingBar = function(selector) {\n const rootSelector = `.${LoadingBarWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);\n};\n\nElementWrapper.prototype.findAllLoadingBars = function(selector) {\n return this.findAllComponents(LoadingBarWrapper, selector);\n};\nElementWrapper.prototype.findSupportPromptGroup = function(selector) {\n const rootSelector = `.${SupportPromptGroupWrapper.rootSelector}`;\n // casting to 'any' is needed to avoid this issue with generics\n // https://github.com/microsoft/TypeScript/issues/29132\n return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, SupportPromptGroupWrapper);\n};\n\nElementWrapper.prototype.findAllSupportPromptGroups = function(selector) {\n return this.findAllComponents(SupportPromptGroupWrapper, selector);\n};\n\n\nexport default function wrapper(root: string = 'body') {\n return new ElementWrapper(root);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { ComponentWrapper, ElementWrapper } from "@cloudscape-design/test-utils-core/selectors";
2
+ export default class SupportPromptGroupWrapper extends ComponentWrapper {
3
+ static rootSelector: string;
4
+ /**
5
+ * Finds all items.
6
+ */
7
+ findItems(): import("@cloudscape-design/test-utils-core/selectors").MultiElementWrapper<ElementWrapper>;
8
+ /**
9
+ * Finds a support prompt item by its id.
10
+ */
11
+ findItemById(id: string): SupportPromptWrapper;
12
+ }
13
+ export declare class SupportPromptWrapper extends ComponentWrapper {
14
+ static rootSelector: string;
15
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SupportPromptWrapper = void 0;
4
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
+ // SPDX-License-Identifier: Apache-2.0
6
+ const selectors_1 = require("@cloudscape-design/test-utils-core/selectors");
7
+ const styles_selectors_js_1 = require("../../../support-prompt-group/styles.selectors.js");
8
+ class SupportPromptGroupWrapper extends selectors_1.ComponentWrapper {
9
+ /**
10
+ * Finds all items.
11
+ */
12
+ findItems() {
13
+ return this.findAllByClassName(styles_selectors_js_1.default["support-prompt"]);
14
+ }
15
+ /**
16
+ * Finds a support prompt item by its id.
17
+ */
18
+ findItemById(id) {
19
+ const itemSelector = `.${styles_selectors_js_1.default["support-prompt"]}[data-testid="${CSS.escape(id)}"]`;
20
+ const wrapper = this.find(itemSelector);
21
+ return wrapper && new SupportPromptWrapper(wrapper.getElement());
22
+ }
23
+ }
24
+ exports.default = SupportPromptGroupWrapper;
25
+ SupportPromptGroupWrapper.rootSelector = styles_selectors_js_1.default.root;
26
+ class SupportPromptWrapper extends selectors_1.ComponentWrapper {
27
+ }
28
+ exports.SupportPromptWrapper = SupportPromptWrapper;
29
+ SupportPromptWrapper.rootSelector = styles_selectors_js_1.default["support-prompt"];
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/selectors/support-prompt-group/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,4EAAgG;AAChG,2FAAuE;AACvE,MAAqB,yBAA0B,SAAQ,4BAAgB;IAGrE;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,kBAAkB,CAAC,6BAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,EAAU;QACrB,MAAM,YAAY,GAAG,IAAI,6BAAM,CAAC,gBAAgB,CAAC,iBAAiB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACrF,MAAM,OAAO,GAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAoB,CAAC;QAC5D,OAAO,OAAO,IAAI,IAAI,oBAAoB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACnE,CAAC;;AAjBH,4CAkBC;AAjBQ,sCAAY,GAAW,6BAAM,CAAC,IAAI,CAAC;AAkB5C,MAAa,oBAAqB,SAAQ,4BAAgB;;AAA1D,oDAEC;AADQ,iCAAY,GAAW,6BAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ComponentWrapper, ElementWrapper } from \"@cloudscape-design/test-utils-core/selectors\";\nimport styles from \"../../../support-prompt-group/styles.selectors.js\";\nexport default class SupportPromptGroupWrapper extends ComponentWrapper {\n static rootSelector: string = styles.root;\n\n /**\n * Finds all items.\n */\n findItems() {\n return this.findAllByClassName(styles[\"support-prompt\"]);\n }\n\n /**\n * Finds a support prompt item by its id.\n */\n findItemById(id: string) {\n const itemSelector = `.${styles[\"support-prompt\"]}[data-testid=\"${CSS.escape(id)}\"]`;\n const wrapper = (this.find(itemSelector) as ElementWrapper);\n return wrapper && new SupportPromptWrapper(wrapper.getElement());\n }\n}\nexport class SupportPromptWrapper extends ComponentWrapper {\n static rootSelector: string = styles[\"support-prompt\"];\n}"]}