@cloudscape-design/chat-components 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +2 -0
  3. package/README.md +20 -0
  4. package/avatar/index.d.ts +3 -0
  5. package/avatar/index.js +12 -0
  6. package/avatar/index.js.map +1 -0
  7. package/avatar/interfaces.d.ts +62 -0
  8. package/avatar/interfaces.js +4 -0
  9. package/avatar/interfaces.js.map +1 -0
  10. package/avatar/internal.d.ts +5 -0
  11. package/avatar/internal.js +56 -0
  12. package/avatar/internal.js.map +1 -0
  13. package/avatar/loading-dots/index.d.ts +5 -0
  14. package/avatar/loading-dots/index.js +11 -0
  15. package/avatar/loading-dots/index.js.map +1 -0
  16. package/avatar/loading-dots/styles.css.js +12 -0
  17. package/avatar/loading-dots/styles.scoped.css +187 -0
  18. package/avatar/loading-dots/styles.selectors.js +13 -0
  19. package/avatar/styles.css.js +10 -0
  20. package/avatar/styles.scoped.css +88 -0
  21. package/avatar/styles.selectors.js +11 -0
  22. package/index.d.ts +4 -0
  23. package/index.js +5 -0
  24. package/index.js.map +1 -0
  25. package/internal/api-docs/components/avatar.js +172 -0
  26. package/internal/api-docs/components/index.js +4 -0
  27. package/internal/api-docs/components/loading-bar.js +23 -0
  28. package/internal/api-docs/test-utils-doc/dom.js +4 -0
  29. package/internal/api-docs/test-utils-doc/selectors.js +4 -0
  30. package/internal/base-component/get-data-attributes.d.ts +1 -0
  31. package/internal/base-component/get-data-attributes.js +12 -0
  32. package/internal/base-component/get-data-attributes.js.map +1 -0
  33. package/internal/base-component/use-base-component.d.ts +13 -0
  34. package/internal/base-component/use-base-component.js +19 -0
  35. package/internal/base-component/use-base-component.js.map +1 -0
  36. package/internal/base-component/use-telemetry.d.ts +2 -0
  37. package/internal/base-component/use-telemetry.js +10 -0
  38. package/internal/base-component/use-telemetry.js.map +1 -0
  39. package/internal/base-component/use-visual-refresh.d.ts +1 -0
  40. package/internal/base-component/use-visual-refresh.js +6 -0
  41. package/internal/base-component/use-visual-refresh.js.map +1 -0
  42. package/internal/environment.d.ts +4 -0
  43. package/internal/environment.js +4 -0
  44. package/internal/environment.json +6 -0
  45. package/internal/keycode.d.ts +19 -0
  46. package/internal/keycode.js +26 -0
  47. package/internal/keycode.js.map +1 -0
  48. package/internal/manifest.json +3 -0
  49. package/internal/utils/apply-display-name.d.ts +1 -0
  50. package/internal/utils/apply-display-name.js +6 -0
  51. package/internal/utils/apply-display-name.js.map +1 -0
  52. package/internal/utils/focus-visible.d.ts +2 -0
  53. package/internal/utils/focus-visible.js +49 -0
  54. package/internal/utils/focus-visible.js.map +1 -0
  55. package/internal/utils/use-merge-refs.d.ts +9 -0
  56. package/internal/utils/use-merge-refs.js +30 -0
  57. package/internal/utils/use-merge-refs.js.map +1 -0
  58. package/loading-bar/index.d.ts +3 -0
  59. package/loading-bar/index.js +12 -0
  60. package/loading-bar/index.js.map +1 -0
  61. package/loading-bar/interfaces.d.ts +11 -0
  62. package/loading-bar/interfaces.js +4 -0
  63. package/loading-bar/interfaces.js.map +1 -0
  64. package/loading-bar/internal.d.ts +3 -0
  65. package/loading-bar/internal.js +10 -0
  66. package/loading-bar/internal.js.map +1 -0
  67. package/loading-bar/styles.css.js +10 -0
  68. package/loading-bar/styles.scoped.css +87 -0
  69. package/loading-bar/styles.selectors.js +11 -0
  70. package/package.json +30 -0
  71. package/test-utils/dom/avatar/index.d.ts +6 -0
  72. package/test-utils/dom/avatar/index.js +16 -0
  73. package/test-utils/dom/avatar/index.js.map +1 -0
  74. package/test-utils/dom/index.d.ts +13 -0
  75. package/test-utils/dom/index.js +25 -0
  76. package/test-utils/dom/index.js.map +1 -0
  77. package/test-utils/dom/loading-bar/index.d.ts +4 -0
  78. package/test-utils/dom/loading-bar/index.js +11 -0
  79. package/test-utils/dom/loading-bar/index.js.map +1 -0
  80. package/test-utils/selectors/avatar/index.d.ts +6 -0
  81. package/test-utils/selectors/avatar/index.js +16 -0
  82. package/test-utils/selectors/avatar/index.js.map +1 -0
  83. package/test-utils/selectors/index.d.ts +13 -0
  84. package/test-utils/selectors/index.js +25 -0
  85. package/test-utils/selectors/index.js.map +1 -0
  86. package/test-utils/selectors/loading-bar/index.d.ts +4 -0
  87. package/test-utils/selectors/loading-bar/index.js +11 -0
  88. package/test-utils/selectors/loading-bar/index.js.map +1 -0
@@ -0,0 +1,10 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "root": "awsui_root_1qkal_1izux_11",
5
+ "avatar-color-default": "awsui_avatar-color-default_1qkal_1izux_46",
6
+ "avatar-color-gen-ai": "awsui_avatar-color-gen-ai_1qkal_1izux_49",
7
+ "initials": "awsui_initials_1qkal_1izux_52",
8
+ "content": "awsui_content_1qkal_1izux_80"
9
+ };
10
+
@@ -0,0 +1,88 @@
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_1qkal_1izux_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
+ color: var(--color-text-avatar-jddpvm, #ffffff);
39
+ block-size: 28px;
40
+ inline-size: 28px;
41
+ position: relative;
42
+ border-start-start-radius: 50%;
43
+ border-start-end-radius: 50%;
44
+ border-end-start-radius: 50%;
45
+ border-end-end-radius: 50%;
46
+ }
47
+ .awsui_root_1qkal_1izux_11.awsui_avatar-color-default_1qkal_1izux_46:not(#\9) {
48
+ background-color: var(--color-background-avatar-default-vm4u8g, #414d5c);
49
+ }
50
+ .awsui_root_1qkal_1izux_11.awsui_avatar-color-gen-ai_1qkal_1izux_49:not(#\9) {
51
+ background: var(--color-background-avatar-gen-ai-i9hcw6, radial-gradient(circle farthest-corner at top left, rgb(0, 150, 250) -25%, rgba(0, 150, 250, 0) 55%), radial-gradient(circle farthest-corner at top right, rgb(216, 178, 255) -10%, rgb(115, 0, 229) 50%));
52
+ }
53
+ .awsui_root_1qkal_1izux_11.awsui_initials_1qkal_1izux_52:not(#\9) {
54
+ font-family: var(--font-family-base-dnvic8, "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif);
55
+ font-size: var(--font-size-body-s-asqx2i, 12px);
56
+ line-height: var(--line-height-body-s-7zv1j5, 16px);
57
+ font-weight: var(--font-weight-heading-l-f8711v, 700);
58
+ }
59
+ .awsui_root_1qkal_1izux_11:not(#\9):focus {
60
+ outline: none;
61
+ }
62
+ body[data-awsui-focus-visible=true] .awsui_root_1qkal_1izux_11:not(#\9):focus:focus {
63
+ position: relative;
64
+ box-sizing: border-box;
65
+ outline: 2px dotted transparent;
66
+ outline-offset: 0px;
67
+ }
68
+ body[data-awsui-focus-visible=true] .awsui_root_1qkal_1izux_11:not(#\9):focus:focus::before {
69
+ content: " ";
70
+ display: block;
71
+ position: absolute;
72
+ box-sizing: border-box;
73
+ inset-inline-start: calc(-1 * 1px);
74
+ inset-block-start: calc(-1 * 1px);
75
+ inline-size: calc(100% + 2 * 1px);
76
+ block-size: calc(100% + 2 * 1px);
77
+ border-radius: 50%;
78
+ border: 2px solid var(--color-border-item-focused-b2ntyl, #0972d3);
79
+ }
80
+
81
+ .awsui_content_1qkal_1izux_80:not(#\9) {
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ block-size: inherit;
86
+ inline-size: inherit;
87
+ overflow: hidden;
88
+ }
@@ -0,0 +1,11 @@
1
+
2
+ // es-module interop with Babel and Typescript
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ module.exports.default = {
5
+ "root": "awsui_root_1qkal_1izux_11",
6
+ "avatar-color-default": "awsui_avatar-color-default_1qkal_1izux_46",
7
+ "avatar-color-gen-ai": "awsui_avatar-color-gen-ai_1qkal_1izux_49",
8
+ "initials": "awsui_initials_1qkal_1izux_52",
9
+ "content": "awsui_content_1qkal_1izux_80"
10
+ };
11
+
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { default as Avatar } from "./avatar";
2
+ export type { AvatarProps } from "./avatar";
3
+ export { default as LoadingBar } from "./loading-bar";
4
+ export type { LoadingBarProps } from "./loading-bar";
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export { default as Avatar } from "./avatar";
4
+ export { default as LoadingBar } from "./loading-bar";
5
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { default as Avatar } from \"./avatar\";\nexport type { AvatarProps } from \"./avatar\";\n\nexport { default as LoadingBar } from \"./loading-bar\";\nexport type { LoadingBarProps } from \"./loading-bar\";\n"]}
@@ -0,0 +1,172 @@
1
+ module.exports = {
2
+ "name": "Avatar",
3
+ "releaseStatus": "stable",
4
+ "regions": [
5
+ {
6
+ "name": "iconSvg",
7
+ "description": "Specifies the SVG of a custom icon.\nUse this property if the icon you want isn't available.\nIf you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n",
8
+ "isDefault": false
9
+ }
10
+ ],
11
+ "functions": [],
12
+ "properties": [
13
+ {
14
+ "name": "ariaLabel",
15
+ "type": "string",
16
+ "optional": false,
17
+ "description": "Text to describe the avatar for assistive technology.\nWhen more than one avatar is used, provide a unique label for each.\nFor example, \"User avatar\" and \"AI assistant avatar\" or \"Your avatar\" and \"User avatar for John Doe\".\nIf `tooltipText` or `initials` are used make sure to include them in the `ariaLabel`.\n"
18
+ },
19
+ {
20
+ "name": "color",
21
+ "type": "string",
22
+ "inlineType": {
23
+ "name": "AvatarProps.Color",
24
+ "type": "union",
25
+ "values": [
26
+ "default",
27
+ "gen-ai"
28
+ ]
29
+ },
30
+ "optional": true,
31
+ "description": "Determines the color of the avatar.\nUse `gen-ai` for AI assistants and `default` otherwise.",
32
+ "defaultValue": "\"default\""
33
+ },
34
+ {
35
+ "name": "iconName",
36
+ "type": "string",
37
+ "inlineType": {
38
+ "name": "IconProps.Name",
39
+ "type": "union",
40
+ "values": [
41
+ "add-plus",
42
+ "anchor-link",
43
+ "angle-left-double",
44
+ "angle-left",
45
+ "angle-right-double",
46
+ "angle-right",
47
+ "angle-up",
48
+ "angle-down",
49
+ "arrow-left",
50
+ "arrow-right",
51
+ "audio-full",
52
+ "audio-half",
53
+ "audio-off",
54
+ "bug",
55
+ "call",
56
+ "calendar",
57
+ "caret-down-filled",
58
+ "caret-down",
59
+ "caret-left-filled",
60
+ "caret-right-filled",
61
+ "caret-up-filled",
62
+ "caret-up",
63
+ "check",
64
+ "contact",
65
+ "close",
66
+ "copy",
67
+ "delete-marker",
68
+ "download",
69
+ "drag-indicator",
70
+ "edit",
71
+ "ellipsis",
72
+ "envelope",
73
+ "expand",
74
+ "external",
75
+ "file-open",
76
+ "file",
77
+ "filter",
78
+ "flag",
79
+ "folder-open",
80
+ "folder",
81
+ "gen-ai",
82
+ "group-active",
83
+ "group",
84
+ "heart",
85
+ "heart-filled",
86
+ "insert-row",
87
+ "key",
88
+ "keyboard",
89
+ "lock-private",
90
+ "menu",
91
+ "microphone",
92
+ "microphone-off",
93
+ "multiscreen",
94
+ "notification",
95
+ "redo",
96
+ "refresh",
97
+ "remove",
98
+ "resize-area",
99
+ "script",
100
+ "search",
101
+ "security",
102
+ "settings",
103
+ "send",
104
+ "share",
105
+ "shrink",
106
+ "star-filled",
107
+ "star-half",
108
+ "star",
109
+ "status-in-progress",
110
+ "status-info",
111
+ "status-negative",
112
+ "status-pending",
113
+ "status-positive",
114
+ "status-stopped",
115
+ "status-warning",
116
+ "subtract-minus",
117
+ "suggestions",
118
+ "thumbs-down-filled",
119
+ "thumbs-down",
120
+ "thumbs-up-filled",
121
+ "thumbs-up",
122
+ "ticket",
123
+ "treeview-collapse",
124
+ "treeview-expand",
125
+ "undo",
126
+ "unlocked",
127
+ "upload-download",
128
+ "upload",
129
+ "user-profile-active",
130
+ "user-profile",
131
+ "video-off",
132
+ "video-on",
133
+ "video-unavailable",
134
+ "view-full",
135
+ "view-horizontal",
136
+ "view-vertical",
137
+ "zoom-in",
138
+ "zoom-out",
139
+ "zoom-to-fit"
140
+ ]
141
+ },
142
+ "optional": true,
143
+ "description": "Specifies the icon to be displayed as Avatar.\nUse `gen-ai` icon for AI assistants. By default `user-profile` icon is used.\nIf you set both `iconName` and `initials`, `initials` will take precedence.\n",
144
+ "defaultValue": "\"user-profile\""
145
+ },
146
+ {
147
+ "name": "iconUrl",
148
+ "type": "string",
149
+ "optional": true,
150
+ "description": "Specifies the URL of a custom icon. Use this property if the icon you want isn't available, and your custom icon can't be an SVG.\nFor SVG icons, use the `iconSvg` slot instead.\nIf you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n"
151
+ },
152
+ {
153
+ "name": "initials",
154
+ "type": "string",
155
+ "optional": true,
156
+ "description": "The text content shown directly in the avatar's body.\nCan be 1 or 2 symbols long, every subsequent symbol is ignored.\nUse it to define initials that uniquely identify the avatar's owner.\nWhen you use this property, make sure to include it in the `ariaLabel`.\n"
157
+ },
158
+ {
159
+ "name": "loading",
160
+ "type": "boolean",
161
+ "optional": true,
162
+ "description": "When set to true, a loading indicator is shown in avatar."
163
+ },
164
+ {
165
+ "name": "tooltipText",
166
+ "type": "string",
167
+ "optional": true,
168
+ "description": "The text content shown in the avatar's tooltip.\nWhen you use this property, make sure to include it in the `ariaLabel`.\n"
169
+ }
170
+ ],
171
+ "events": []
172
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ "avatar":require('./avatar'),
3
+ "loading-bar":require('./loading-bar')
4
+ }
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ "name": "LoadingBar",
3
+ "releaseStatus": "stable",
4
+ "regions": [],
5
+ "functions": [],
6
+ "properties": [
7
+ {
8
+ "name": "variant",
9
+ "type": "string",
10
+ "inlineType": {
11
+ "name": "LoadingBarProps.Variant",
12
+ "type": "union",
13
+ "values": [
14
+ "gen-ai",
15
+ "gen-ai-masked"
16
+ ]
17
+ },
18
+ "optional": false,
19
+ "description": "Specifies the variant of the loading bar. Use `gen-ai` to indicate an ongoing generative AI process.\nUse `gen-ai-masked` for generative AI processes where the bar is displayed at the edge of an element\nwith rounded corners."
20
+ }
21
+ ],
22
+ "events": []
23
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ classes: [{"name":"AvatarWrapper","methods":[{"name":"blur","returnType":{"name":"void","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.blur"}},{"name":"click","description":"Performs a click by triggering a mouse event.\nNote that programmatic events ignore disabled attribute and will trigger listeners even if the element is disabled.","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"params","typeName":"MouseEventInit","flags":{"isOptional":true}}],"inheritedFrom":{"name":"AbstractWrapper.click"}},{"name":"find","returnType":{"name":"ElementWrapper | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.find"}},{"name":"findAll","returnType":{"name":"array","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAll"}},{"name":"findAllByClassName","returnType":{"name":"array","type":"reference"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAllByClassName"}},{"name":"findByClassName","returnType":{"name":"ElementWrapper | null","type":"union"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findByClassName"}},{"name":"findComponent","returnType":{"name":"Wrapper | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}},{"name":"ComponentClass","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findComponent"}},{"name":"findTooltip","returnType":{"name":"TooltipWrapper | null","type":"union"},"parameters":[]},{"name":"fireEvent","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"event","typeName":"Event","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.fireEvent"}},{"name":"focus","returnType":{"name":"void","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.focus"}},{"name":"getElement","returnType":{"name":"HTMLElement","type":"reference"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.getElement"}},{"name":"keydown","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keydown"}},{"name":"keypress","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keypress"}},{"name":"keyup","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keyup"}},{"name":"matches","returnType":{"name":"this | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.matches"}}]},{"name":"LoadingBarWrapper","methods":[{"name":"blur","returnType":{"name":"void","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.blur"}},{"name":"click","description":"Performs a click by triggering a mouse event.\nNote that programmatic events ignore disabled attribute and will trigger listeners even if the element is disabled.","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"params","typeName":"MouseEventInit","flags":{"isOptional":true}}],"inheritedFrom":{"name":"AbstractWrapper.click"}},{"name":"find","returnType":{"name":"ElementWrapper | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.find"}},{"name":"findAll","returnType":{"name":"array","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAll"}},{"name":"findAllByClassName","returnType":{"name":"array","type":"reference"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAllByClassName"}},{"name":"findByClassName","returnType":{"name":"ElementWrapper | null","type":"union"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findByClassName"}},{"name":"findComponent","returnType":{"name":"Wrapper | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}},{"name":"ComponentClass","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findComponent"}},{"name":"fireEvent","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"event","typeName":"Event","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.fireEvent"}},{"name":"focus","returnType":{"name":"void","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.focus"}},{"name":"getElement","returnType":{"name":"HTMLElement","type":"reference"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.getElement"}},{"name":"keydown","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keydown"}},{"name":"keypress","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keypress"}},{"name":"keyup","returnType":{"name":"void","type":"intrinsic"},"parameters":[{"name":"keyCode","typeName":"KeyCode","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.keyup"}},{"name":"matches","returnType":{"name":"this | null","type":"union"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.matches"}}]}]
3
+ }
4
+
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ classes: [{"name":"AvatarWrapper","methods":[{"name":"find","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.find"}},{"name":"findAll","returnType":{"name":"MultiElementWrapper","type":"reference","typeArguments":[{"name":"ElementWrapper","type":"reference"}]},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAll"}},{"name":"findAllByClassName","returnType":{"name":"MultiElementWrapper","type":"reference","typeArguments":[{"name":"ElementWrapper","type":"reference"}]},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAllByClassName"}},{"name":"findByClassName","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findByClassName"}},{"name":"findComponent","returnType":{"name":"Wrapper","type":"typeParameter"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}},{"name":"ComponentClass","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findComponent"}},{"name":"findTooltip","returnType":{"name":"TooltipWrapper","type":"reference","typeArguments":[]},"parameters":[]},{"name":"getElement","returnType":{"name":"string","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.getElement"}},{"name":"matches","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.matches"}},{"name":"toSelector","returnType":{"name":"string","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.toSelector"}}]},{"name":"LoadingBarWrapper","methods":[{"name":"find","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.find"}},{"name":"findAll","returnType":{"name":"MultiElementWrapper","type":"reference","typeArguments":[{"name":"ElementWrapper","type":"reference"}]},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAll"}},{"name":"findAllByClassName","returnType":{"name":"MultiElementWrapper","type":"reference","typeArguments":[{"name":"ElementWrapper","type":"reference"}]},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findAllByClassName"}},{"name":"findByClassName","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"className","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findByClassName"}},{"name":"findComponent","returnType":{"name":"Wrapper","type":"typeParameter"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}},{"name":"ComponentClass","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.findComponent"}},{"name":"getElement","returnType":{"name":"string","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.getElement"}},{"name":"matches","returnType":{"name":"ElementWrapper","type":"reference"},"parameters":[{"name":"selector","typeName":"string","flags":{"isOptional":false}}],"inheritedFrom":{"name":"AbstractWrapper.matches"}},{"name":"toSelector","returnType":{"name":"string","type":"intrinsic"},"parameters":[],"inheritedFrom":{"name":"AbstractWrapper.toSelector"}}]}]
3
+ }
4
+
@@ -0,0 +1 @@
1
+ export declare function getDataAttributes(props: Record<string, string>): Record<string, any>;
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export function getDataAttributes(props) {
4
+ const result = {};
5
+ Object.keys(props).forEach((prop) => {
6
+ if (prop.startsWith("data-")) {
7
+ result[prop] = props[prop];
8
+ }
9
+ });
10
+ return result;
11
+ }
12
+ //# sourceMappingURL=get-data-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-data-attributes.js","sourceRoot":"","sources":["../../../../src/internal/base-component/get-data-attributes.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;SAC5B;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getDataAttributes(props: Record<string, string>) {\n const result: Record<string, any> = {};\n Object.keys(props).forEach((prop) => {\n if (prop.startsWith(\"data-\")) {\n result[prop] = props[prop];\n }\n });\n return result;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { ComponentConfiguration } from "@cloudscape-design/component-toolkit/internal";
2
+ import { MutableRefObject } from "react";
3
+ export interface InternalBaseComponentProps {
4
+ __internalRootRef?: MutableRefObject<any> | null;
5
+ }
6
+ /**
7
+ * This hook is used for components which are exported to customers. The returned __internalRootRef needs to be
8
+ * attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
9
+ * root DOM node and emits the telemetry for this component.
10
+ */
11
+ export default function useBaseComponent<T = any>(componentName: string, config?: ComponentConfiguration): {
12
+ __internalRootRef: import("react").RefObject<T>;
13
+ };
@@ -0,0 +1,19 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { initAwsUiVersions, useComponentMetadata, } from "@cloudscape-design/component-toolkit/internal";
4
+ import { PACKAGE_SOURCE, PACKAGE_VERSION } from "../environment";
5
+ import useFocusVisible from "../utils/focus-visible";
6
+ import { useTelemetry } from "./use-telemetry";
7
+ initAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);
8
+ /**
9
+ * This hook is used for components which are exported to customers. The returned __internalRootRef needs to be
10
+ * attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
11
+ * root DOM node and emits the telemetry for this component.
12
+ */
13
+ export default function useBaseComponent(componentName, config) {
14
+ useTelemetry(componentName, config);
15
+ useFocusVisible();
16
+ const elementRef = useComponentMetadata(componentName, PACKAGE_VERSION);
17
+ return { __internalRootRef: elementRef };
18
+ }
19
+ //# sourceMappingURL=use-base-component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-base-component.js","sourceRoot":"","sources":["../../../../src/internal/base-component/use-base-component.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAEL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,eAAe,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,iBAAiB,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAMnD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAU,aAAqB,EAAE,MAA+B;IACtG,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACpC,eAAe,EAAE,CAAC;IAClB,MAAM,UAAU,GAAG,oBAAoB,CAAI,aAAa,EAAE,eAAe,CAAC,CAAC;IAC3E,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ComponentConfiguration,\n initAwsUiVersions,\n useComponentMetadata,\n} from \"@cloudscape-design/component-toolkit/internal\";\nimport { MutableRefObject } from \"react\";\nimport { PACKAGE_SOURCE, PACKAGE_VERSION } from \"../environment\";\nimport useFocusVisible from \"../utils/focus-visible\";\nimport { useTelemetry } from \"./use-telemetry\";\n\ninitAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);\n\nexport interface InternalBaseComponentProps {\n __internalRootRef?: MutableRefObject<any> | null;\n}\n\n/**\n * This hook is used for components which are exported to customers. The returned __internalRootRef needs to be\n * attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this\n * root DOM node and emits the telemetry for this component.\n */\nexport default function useBaseComponent<T = any>(componentName: string, config?: ComponentConfiguration) {\n useTelemetry(componentName, config);\n useFocusVisible();\n const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);\n return { __internalRootRef: elementRef };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentConfiguration } from "@cloudscape-design/component-toolkit/internal";
2
+ export declare function useTelemetry(componentName: string, config?: ComponentConfiguration): void;
@@ -0,0 +1,10 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useComponentMetrics } from "@cloudscape-design/component-toolkit/internal";
4
+ import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from "../environment";
5
+ import { useVisualRefresh } from "./use-visual-refresh";
6
+ export function useTelemetry(componentName, config) {
7
+ const theme = useVisualRefresh() ? "vr" : THEME;
8
+ useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
9
+ }
10
+ //# sourceMappingURL=use-telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-telemetry.js","sourceRoot":"","sources":["../../../../src/internal/base-component/use-telemetry.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAA0B,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAC5G,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,UAAU,YAAY,CAAC,aAAqB,EAAE,MAA+B;IACjF,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAChD,mBAAmB,CAAC,aAAa,EAAE,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;AACxH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ComponentConfiguration, useComponentMetrics } from \"@cloudscape-design/component-toolkit/internal\";\nimport { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from \"../environment\";\nimport { useVisualRefresh } from \"./use-visual-refresh\";\n\nexport function useTelemetry(componentName: string, config?: ComponentConfiguration) {\n const theme = useVisualRefresh() ? \"vr\" : THEME;\n useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const useVisualRefresh: () => boolean;
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useRuntimeVisualRefresh } from "@cloudscape-design/component-toolkit/internal";
4
+ import { ALWAYS_VISUAL_REFRESH } from "../environment";
5
+ export const useVisualRefresh = ALWAYS_VISUAL_REFRESH ? () => true : useRuntimeVisualRefresh;
6
+ //# sourceMappingURL=use-visual-refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-visual-refresh.js","sourceRoot":"","sources":["../../../../src/internal/base-component/use-visual-refresh.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useRuntimeVisualRefresh } from \"@cloudscape-design/component-toolkit/internal\";\nimport { ALWAYS_VISUAL_REFRESH } from \"../environment\";\n\nexport const useVisualRefresh = ALWAYS_VISUAL_REFRESH ? () => true : useRuntimeVisualRefresh;\n"]}
@@ -0,0 +1,4 @@
1
+ export const PACKAGE_SOURCE: string;
2
+ export const PACKAGE_VERSION: string;
3
+ export const THEME: string;
4
+ export const ALWAYS_VISUAL_REFRESH: string;
@@ -0,0 +1,4 @@
1
+ export var PACKAGE_SOURCE = "chat-components";
2
+ export var PACKAGE_VERSION = "1.0.0 (2ebe8163)";
3
+ export var THEME = "open-source-visual-refresh";
4
+ export var ALWAYS_VISUAL_REFRESH = true;
@@ -0,0 +1,6 @@
1
+ {
2
+ "PACKAGE_SOURCE": "chat-components",
3
+ "PACKAGE_VERSION": "1.0.0 (2ebe8163)",
4
+ "THEME": "open-source-visual-refresh",
5
+ "ALWAYS_VISUAL_REFRESH": true
6
+ }
@@ -0,0 +1,19 @@
1
+ export declare enum KeyCode {
2
+ pageUp = 33,
3
+ pageDown = 34,
4
+ end = 35,
5
+ home = 36,
6
+ backspace = 8,
7
+ space = 32,
8
+ down = 40,
9
+ left = 37,
10
+ right = 39,
11
+ up = 38,
12
+ escape = 27,
13
+ enter = 13,
14
+ tab = 9,
15
+ shift = 16,
16
+ control = 17,
17
+ alt = 18,
18
+ meta = 91
19
+ }
@@ -0,0 +1,26 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // When updating the list of key codes, don't forget
4
+ // to modify corresponding list in test-utils
5
+ // to avoid failing unit tests
6
+ export var KeyCode;
7
+ (function (KeyCode) {
8
+ KeyCode[KeyCode["pageUp"] = 33] = "pageUp";
9
+ KeyCode[KeyCode["pageDown"] = 34] = "pageDown";
10
+ KeyCode[KeyCode["end"] = 35] = "end";
11
+ KeyCode[KeyCode["home"] = 36] = "home";
12
+ KeyCode[KeyCode["backspace"] = 8] = "backspace";
13
+ KeyCode[KeyCode["space"] = 32] = "space";
14
+ KeyCode[KeyCode["down"] = 40] = "down";
15
+ KeyCode[KeyCode["left"] = 37] = "left";
16
+ KeyCode[KeyCode["right"] = 39] = "right";
17
+ KeyCode[KeyCode["up"] = 38] = "up";
18
+ KeyCode[KeyCode["escape"] = 27] = "escape";
19
+ KeyCode[KeyCode["enter"] = 13] = "enter";
20
+ KeyCode[KeyCode["tab"] = 9] = "tab";
21
+ KeyCode[KeyCode["shift"] = 16] = "shift";
22
+ KeyCode[KeyCode["control"] = 17] = "control";
23
+ KeyCode[KeyCode["alt"] = 18] = "alt";
24
+ KeyCode[KeyCode["meta"] = 91] = "meta";
25
+ })(KeyCode || (KeyCode = {}));
26
+ //# sourceMappingURL=keycode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keycode.js","sourceRoot":"","sources":["../../../src/internal/keycode.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,oDAAoD;AACpD,6CAA6C;AAC7C,8BAA8B;AAC9B,MAAM,CAAN,IAAY,OAkBX;AAlBD,WAAY,OAAO;IACjB,0CAAW,CAAA;IACX,8CAAa,CAAA;IACb,oCAAQ,CAAA;IACR,sCAAS,CAAA;IACT,+CAAa,CAAA;IACb,wCAAU,CAAA;IACV,sCAAS,CAAA;IACT,sCAAS,CAAA;IACT,wCAAU,CAAA;IACV,kCAAO,CAAA;IACP,0CAAW,CAAA;IACX,wCAAU,CAAA;IACV,mCAAO,CAAA;IACP,wCAAU,CAAA;IACV,4CAAY,CAAA;IACZ,oCAAQ,CAAA;IACR,sCAAS,CAAA;AACX,CAAC,EAlBW,OAAO,KAAP,OAAO,QAkBlB","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n// When updating the list of key codes, don't forget\n// to modify corresponding list in test-utils\n// to avoid failing unit tests\nexport enum KeyCode {\n pageUp = 33,\n pageDown = 34,\n end = 35,\n home = 36,\n backspace = 8,\n space = 32,\n down = 40,\n left = 37,\n right = 39,\n up = 38,\n escape = 27,\n enter = 13,\n tab = 9,\n shift = 16,\n control = 17,\n alt = 18,\n meta = 91,\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "commit": "2ebe8163ceaa3bbce65fe1f9e183d2ef9bfc1f1e"
3
+ }
@@ -0,0 +1 @@
1
+ export declare function applyDisplayName<T>(component: T, displayName: string): void;
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export function applyDisplayName(component, displayName) {
4
+ component.displayName = displayName;
5
+ }
6
+ //# sourceMappingURL=apply-display-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-display-name.js","sourceRoot":"","sources":["../../../../src/internal/utils/apply-display-name.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,gBAAgB,CAAI,SAAY,EAAE,WAAmB;IAClE,SAAiB,CAAC,WAAW,GAAG,WAAW,CAAC;AAC/C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function applyDisplayName<T>(component: T, displayName: string): void {\n (component as any).displayName = displayName;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function isModifierKey(event: KeyboardEvent): boolean;
2
+ export default function useFocusVisible(): void;
@@ -0,0 +1,49 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { useEffect } from "react";
4
+ import { KeyCode } from "../keycode";
5
+ export function isModifierKey(event) {
6
+ // we do not want to highlight focused element
7
+ // when special keys are pressed
8
+ return [KeyCode.shift, KeyCode.alt, KeyCode.control, KeyCode.meta].indexOf(event.keyCode) > -1;
9
+ }
10
+ function setIsKeyboard(active) {
11
+ if (active) {
12
+ document.body.setAttribute("data-awsui-focus-visible", "true");
13
+ }
14
+ else {
15
+ document.body.removeAttribute("data-awsui-focus-visible");
16
+ }
17
+ }
18
+ function handleMousedown() {
19
+ return setIsKeyboard(false);
20
+ }
21
+ function handleKeydown(event) {
22
+ if (!isModifierKey(event)) {
23
+ setIsKeyboard(true);
24
+ }
25
+ }
26
+ let componentsCount = 0;
27
+ function addListeners() {
28
+ document.addEventListener("mousedown", handleMousedown);
29
+ document.addEventListener("keydown", handleKeydown);
30
+ }
31
+ function removeListeners() {
32
+ document.removeEventListener("mousedown", handleMousedown);
33
+ document.removeEventListener("keydown", handleKeydown);
34
+ }
35
+ export default function useFocusVisible() {
36
+ useEffect(() => {
37
+ if (componentsCount === 0) {
38
+ addListeners();
39
+ }
40
+ componentsCount++;
41
+ return () => {
42
+ componentsCount--;
43
+ if (componentsCount === 0) {
44
+ removeListeners();
45
+ }
46
+ };
47
+ }, []);
48
+ }
49
+ //# sourceMappingURL=focus-visible.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-visible.js","sourceRoot":"","sources":["../../../../src/internal/utils/focus-visible.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,UAAU,aAAa,CAAC,KAAoB;IAChD,8CAA8C;IAC9C,gCAAgC;IAChC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACjG,CAAC;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,MAAM,EAAE;QACV,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;KAChE;SAAM;QACL,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,0BAA0B,CAAC,CAAC;KAC3D;AACH,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,aAAa,CAAC,KAAoB;IACzC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;QACzB,aAAa,CAAC,IAAI,CAAC,CAAC;KACrB;AACH,CAAC;AAED,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,SAAS,YAAY;IACnB,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IACxD,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,eAAe;IACtB,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3D,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,eAAe;IACrC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,eAAe,KAAK,CAAC,EAAE;YACzB,YAAY,EAAE,CAAC;SAChB;QACD,eAAe,EAAE,CAAC;QAClB,OAAO,GAAG,EAAE;YACV,eAAe,EAAE,CAAC;YAClB,IAAI,eAAe,KAAK,CAAC,EAAE;gBACzB,eAAe,EAAE,CAAC;aACnB;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect } from \"react\";\nimport { KeyCode } from \"../keycode\";\n\nexport function isModifierKey(event: KeyboardEvent) {\n // we do not want to highlight focused element\n // when special keys are pressed\n return [KeyCode.shift, KeyCode.alt, KeyCode.control, KeyCode.meta].indexOf(event.keyCode) > -1;\n}\n\nfunction setIsKeyboard(active: boolean) {\n if (active) {\n document.body.setAttribute(\"data-awsui-focus-visible\", \"true\");\n } else {\n document.body.removeAttribute(\"data-awsui-focus-visible\");\n }\n}\n\nfunction handleMousedown() {\n return setIsKeyboard(false);\n}\n\nfunction handleKeydown(event: KeyboardEvent) {\n if (!isModifierKey(event)) {\n setIsKeyboard(true);\n }\n}\n\nlet componentsCount = 0;\n\nfunction addListeners() {\n document.addEventListener(\"mousedown\", handleMousedown);\n document.addEventListener(\"keydown\", handleKeydown);\n}\n\nfunction removeListeners() {\n document.removeEventListener(\"mousedown\", handleMousedown);\n document.removeEventListener(\"keydown\", handleKeydown);\n}\n\nexport default function useFocusVisible() {\n useEffect(() => {\n if (componentsCount === 0) {\n addListeners();\n }\n componentsCount++;\n return () => {\n componentsCount--;\n if (componentsCount === 0) {\n removeListeners();\n }\n };\n }, []);\n}\n"]}