@cloudscape-design/components 3.0.869 → 3.0.871
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app-layout/drawer/resizable-drawer.d.ts.map +1 -1
- package/app-layout/drawer/resizable-drawer.js +2 -3
- package/app-layout/drawer/resizable-drawer.js.map +1 -1
- package/app-layout/utils/use-focus-control.d.ts +1 -2
- package/app-layout/utils/use-focus-control.d.ts.map +1 -1
- package/app-layout/utils/use-focus-control.js +0 -2
- package/app-layout/utils/use-focus-control.js.map +1 -1
- package/app-layout/utils/use-resize.d.ts.map +1 -1
- package/app-layout/utils/use-resize.js +2 -3
- package/app-layout/utils/use-resize.js.map +1 -1
- package/app-layout/utils/use-split-panel-focus-control.d.ts +1 -2
- package/app-layout/utils/use-split-panel-focus-control.d.ts.map +1 -1
- package/app-layout/utils/use-split-panel-focus-control.js +0 -1
- package/app-layout/utils/use-split-panel-focus-control.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-drawer.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/global-drawer.js +2 -3
- package/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +2 -3
- package/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
- package/button-group/index.d.ts.map +1 -1
- package/button-group/index.js +22 -1
- package/button-group/index.js.map +1 -1
- package/button-group/interfaces.d.ts +2 -1
- package/button-group/interfaces.d.ts.map +1 -1
- package/button-group/interfaces.js.map +1 -1
- package/collection-preferences/content-display/index.d.ts.map +1 -1
- package/collection-preferences/content-display/index.js +8 -5
- package/collection-preferences/content-display/index.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +1 -5
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/styles.css.js +38 -38
- package/date-range-picker/styles.scoped.css +47 -51
- package/date-range-picker/styles.selectors.js +38 -38
- package/flashbar/internal/analytics.d.ts.map +1 -1
- package/flashbar/internal/analytics.js +1 -3
- package/flashbar/internal/analytics.js.map +1 -1
- package/internal/components/drag-handle/index.d.ts +2 -2
- package/internal/components/drag-handle/index.d.ts.map +1 -1
- package/internal/components/drag-handle/index.js +7 -3
- package/internal/components/drag-handle/index.js.map +1 -1
- package/internal/components/drag-handle/interfaces.d.ts +1 -1
- package/internal/components/drag-handle/interfaces.d.ts.map +1 -1
- package/internal/components/drag-handle/interfaces.js.map +1 -1
- package/internal/components/dropdown/styles.css.js +20 -20
- package/internal/components/dropdown/styles.scoped.css +37 -39
- package/internal/components/dropdown/styles.selectors.js +20 -20
- package/internal/components/options-list/styles.css.js +3 -3
- package/internal/components/options-list/styles.scoped.css +5 -3
- package/internal/components/options-list/styles.selectors.js +3 -3
- package/internal/components/panel-resize-handle/icon.d.ts +5 -0
- package/internal/components/panel-resize-handle/icon.d.ts.map +1 -0
- package/internal/components/panel-resize-handle/icon.js +9 -0
- package/internal/components/panel-resize-handle/icon.js.map +1 -0
- package/internal/components/panel-resize-handle/index.d.ts +2 -4
- package/internal/components/panel-resize-handle/index.d.ts.map +1 -1
- package/internal/components/panel-resize-handle/index.js +5 -8
- package/internal/components/panel-resize-handle/index.js.map +1 -1
- package/internal/components/panel-resize-handle/styles.css.js +5 -2
- package/internal/components/panel-resize-handle/styles.scoped.css +191 -3
- package/internal/components/panel-resize-handle/styles.selectors.js +5 -2
- package/internal/components/sortable-area/index.d.ts +6 -0
- package/internal/components/sortable-area/index.d.ts.map +1 -0
- package/internal/components/{dnd-area → sortable-area}/index.js +34 -25
- package/internal/components/sortable-area/index.js.map +1 -0
- package/internal/components/sortable-area/interfaces.d.ts +42 -0
- package/internal/components/sortable-area/interfaces.d.ts.map +1 -0
- package/internal/components/sortable-area/interfaces.js.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/defaults.d.ts.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/defaults.js.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/index.d.ts.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/index.js.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/events.d.ts.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/events.js.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/listeners.d.ts.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/listeners.js.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/scroll.d.ts.map +1 -0
- package/internal/components/sortable-area/keyboard-sensor/utilities/scroll.js.map +1 -0
- package/internal/components/sortable-area/styles.css.js +13 -0
- package/internal/components/{dnd-area → sortable-area}/styles.scoped.css +17 -17
- package/internal/components/sortable-area/styles.selectors.js +14 -0
- package/internal/components/{dnd-area → sortable-area}/use-drag-and-drop-reorder.d.ts +4 -3
- package/internal/components/sortable-area/use-drag-and-drop-reorder.d.ts.map +1 -0
- package/internal/components/{dnd-area → sortable-area}/use-drag-and-drop-reorder.js +4 -4
- package/internal/components/sortable-area/use-drag-and-drop-reorder.js.map +1 -0
- package/internal/components/sortable-area/use-live-announcements.d.ts +13 -0
- package/internal/components/sortable-area/use-live-announcements.d.ts.map +1 -0
- package/internal/components/{dnd-area → sortable-area}/use-live-announcements.js +6 -6
- package/internal/components/sortable-area/use-live-announcements.js.map +1 -0
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/manifest.json +1 -1
- package/internal/metrics.d.ts +3 -0
- package/internal/metrics.d.ts.map +1 -0
- package/internal/metrics.js +6 -0
- package/internal/metrics.js.map +1 -0
- package/internal/plugins/api.d.ts.map +1 -1
- package/internal/plugins/api.js +4 -0
- package/internal/plugins/api.js.map +1 -1
- package/internal/plugins/controllers/alert-flash-content.d.ts.map +1 -1
- package/internal/plugins/controllers/alert-flash-content.js +2 -1
- package/internal/plugins/controllers/alert-flash-content.js.map +1 -1
- package/internal/plugins/controllers/drawers.d.ts.map +1 -1
- package/internal/plugins/controllers/drawers.js +7 -3
- package/internal/plugins/controllers/drawers.js.map +1 -1
- package/internal/plugins/helpers/metrics.d.ts +3 -0
- package/internal/plugins/helpers/metrics.d.ts.map +1 -0
- package/internal/plugins/helpers/metrics.js +15 -0
- package/internal/plugins/helpers/metrics.js.map +1 -0
- package/internal/plugins/helpers/use-discovered-content.d.ts.map +1 -1
- package/internal/plugins/helpers/use-discovered-content.js +2 -1
- package/internal/plugins/helpers/use-discovered-content.js.map +1 -1
- package/package.json +1 -1
- package/split-panel/implementation.d.ts.map +1 -1
- package/split-panel/implementation.js +6 -7
- package/split-panel/implementation.js.map +1 -1
- package/table/table-role/utils.d.ts.map +1 -1
- package/table/table-role/utils.js +4 -5
- package/table/table-role/utils.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/exports.d.ts +0 -6
- package/app-layout/visual-refresh-toolbar/exports.d.ts.map +0 -1
- package/app-layout/visual-refresh-toolbar/exports.js +0 -8
- package/app-layout/visual-refresh-toolbar/exports.js.map +0 -1
- package/internal/components/dnd-area/index.d.ts +0 -4
- package/internal/components/dnd-area/index.d.ts.map +0 -1
- package/internal/components/dnd-area/index.js.map +0 -1
- package/internal/components/dnd-area/interfaces.d.ts +0 -39
- package/internal/components/dnd-area/interfaces.d.ts.map +0 -1
- package/internal/components/dnd-area/interfaces.js.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/defaults.d.ts.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/defaults.js.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/index.d.ts.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/index.js.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/events.d.ts.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/events.js.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/listeners.d.ts.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/listeners.js.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/scroll.d.ts.map +0 -1
- package/internal/components/dnd-area/keyboard-sensor/utilities/scroll.js.map +0 -1
- package/internal/components/dnd-area/styles.css.js +0 -13
- package/internal/components/dnd-area/styles.selectors.js +0 -14
- package/internal/components/dnd-area/use-drag-and-drop-reorder.d.ts.map +0 -1
- package/internal/components/dnd-area/use-drag-and-drop-reorder.js.map +0 -1
- package/internal/components/dnd-area/use-live-announcements.d.ts +0 -12
- package/internal/components/dnd-area/use-live-announcements.d.ts.map +0 -1
- package/internal/components/dnd-area/use-live-announcements.js.map +0 -1
- /package/internal/components/{dnd-area → sortable-area}/interfaces.js +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/defaults.d.ts +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/defaults.js +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/index.d.ts +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/index.js +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/events.d.ts +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/events.js +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/listeners.d.ts +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/listeners.js +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/scroll.d.ts +0 -0
- /package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/scroll.js +0 -0
|
@@ -142,23 +142,23 @@
|
|
|
142
142
|
*/
|
|
143
143
|
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
144
144
|
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
145
|
-
.awsui_drag-
|
|
145
|
+
.awsui_drag-overlay_1ksmw_lhzgl_145:not(#\9) {
|
|
146
146
|
box-shadow: var(--shadow-container-active-kl29x9, 0px 1px 1px 1px #e9ebed, 0px 6px 36px rgba(0, 7, 22, 0.1019607843));
|
|
147
147
|
}
|
|
148
|
-
.awsui_drag-overlay-
|
|
148
|
+
.awsui_drag-overlay-item_1ksmw_lhzgl_148:not(#\9) {
|
|
149
149
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
150
150
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
151
151
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
152
152
|
border-end-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
153
153
|
}
|
|
154
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
154
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-item_1ksmw_lhzgl_148:not(#\9) {
|
|
155
155
|
position: relative;
|
|
156
156
|
}
|
|
157
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
157
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-item_1ksmw_lhzgl_148:not(#\9) {
|
|
158
158
|
outline: 2px dotted transparent;
|
|
159
159
|
outline-offset: calc(0px - 1px);
|
|
160
160
|
}
|
|
161
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
161
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-item_1ksmw_lhzgl_148:not(#\9)::before {
|
|
162
162
|
content: " ";
|
|
163
163
|
display: block;
|
|
164
164
|
position: absolute;
|
|
@@ -172,20 +172,20 @@ body[data-awsui-focus-visible=true] .awsui_drag-overlay-item_1kgab_lhzgl_148:not
|
|
|
172
172
|
border-end-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
173
173
|
box-shadow: 0 0 0 2px var(--color-border-item-focused-nv6mhz, #006ce0);
|
|
174
174
|
}
|
|
175
|
-
.awsui_drag-overlay-
|
|
175
|
+
.awsui_drag-overlay-container_1ksmw_lhzgl_175:not(#\9) {
|
|
176
176
|
border-start-start-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
177
177
|
border-start-end-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
178
178
|
border-end-start-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
179
179
|
border-end-end-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
180
180
|
}
|
|
181
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
181
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-container_1ksmw_lhzgl_175:not(#\9) {
|
|
182
182
|
position: relative;
|
|
183
183
|
}
|
|
184
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
184
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-container_1ksmw_lhzgl_175:not(#\9) {
|
|
185
185
|
outline: 2px dotted transparent;
|
|
186
186
|
outline-offset: calc(0px - 1px);
|
|
187
187
|
}
|
|
188
|
-
body[data-awsui-focus-visible=true] .awsui_drag-overlay-
|
|
188
|
+
body[data-awsui-focus-visible=true] .awsui_drag-overlay-container_1ksmw_lhzgl_175:not(#\9)::before {
|
|
189
189
|
content: " ";
|
|
190
190
|
display: block;
|
|
191
191
|
position: absolute;
|
|
@@ -200,7 +200,7 @@ body[data-awsui-focus-visible=true] .awsui_drag-overlay-container_1kgab_lhzgl_17
|
|
|
200
200
|
box-shadow: 0 0 0 2px var(--color-border-item-focused-nv6mhz, #006ce0);
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
.
|
|
203
|
+
.awsui_active_1ksmw_lhzgl_203:not(#\9) {
|
|
204
204
|
font-size: var(--font-size-body-m-x4okxb, 14px);
|
|
205
205
|
line-height: var(--line-height-body-m-30ar75, 20px);
|
|
206
206
|
color: var(--color-text-body-default-7v1jfn, #0f141a);
|
|
@@ -210,38 +210,38 @@ body[data-awsui-focus-visible=true] .awsui_drag-overlay-container_1kgab_lhzgl_17
|
|
|
210
210
|
-moz-osx-font-smoothing: auto;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
.
|
|
213
|
+
.awsui_placeholder_1ksmw_lhzgl_213:not(#\9) {
|
|
214
214
|
position: relative;
|
|
215
215
|
}
|
|
216
|
-
.
|
|
216
|
+
.awsui_placeholder_1ksmw_lhzgl_213:not(#\9):after {
|
|
217
217
|
content: " ";
|
|
218
218
|
position: absolute;
|
|
219
219
|
inset: 0;
|
|
220
220
|
background: var(--color-drag-placeholder-hover-oikifl, #d1f1ff);
|
|
221
221
|
}
|
|
222
|
-
.awsui_placeholder-
|
|
222
|
+
.awsui_placeholder-item_1ksmw_lhzgl_222:not(#\9):after {
|
|
223
223
|
border-start-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
224
224
|
border-start-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
225
225
|
border-end-start-radius: var(--border-radius-item-05df9h, 8px);
|
|
226
226
|
border-end-end-radius: var(--border-radius-item-05df9h, 8px);
|
|
227
227
|
}
|
|
228
|
-
.awsui_placeholder-
|
|
228
|
+
.awsui_placeholder-container_1ksmw_lhzgl_228:not(#\9):after {
|
|
229
229
|
border-start-start-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
230
230
|
border-start-end-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
231
231
|
border-end-start-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
232
232
|
border-end-end-radius: var(--border-radius-container-wqv1zi, 16px);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
.
|
|
235
|
+
.awsui_sorting_1ksmw_lhzgl_235:not(#\9) {
|
|
236
236
|
transition: transform var(--motion-duration-transition-quick-6npj01, 90ms) var(--motion-easing-transition-quick-l9jfsx, linear);
|
|
237
237
|
}
|
|
238
238
|
@media (prefers-reduced-motion: reduce) {
|
|
239
|
-
.
|
|
239
|
+
.awsui_sorting_1ksmw_lhzgl_235:not(#\9) {
|
|
240
240
|
animation: none;
|
|
241
241
|
transition: none;
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
.awsui-motion-disabled .
|
|
244
|
+
.awsui-motion-disabled .awsui_sorting_1ksmw_lhzgl_235:not(#\9), .awsui-mode-entering .awsui_sorting_1ksmw_lhzgl_235:not(#\9) {
|
|
245
245
|
animation: none;
|
|
246
246
|
transition: none;
|
|
247
247
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
// es-module interop with Babel and Typescript
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
module.exports.default = {
|
|
5
|
+
"drag-overlay": "awsui_drag-overlay_1ksmw_lhzgl_145",
|
|
6
|
+
"drag-overlay-item": "awsui_drag-overlay-item_1ksmw_lhzgl_148",
|
|
7
|
+
"drag-overlay-container": "awsui_drag-overlay-container_1ksmw_lhzgl_175",
|
|
8
|
+
"active": "awsui_active_1ksmw_lhzgl_203",
|
|
9
|
+
"placeholder": "awsui_placeholder_1ksmw_lhzgl_213",
|
|
10
|
+
"placeholder-item": "awsui_placeholder-item_1ksmw_lhzgl_222",
|
|
11
|
+
"placeholder-container": "awsui_placeholder-container_1ksmw_lhzgl_228",
|
|
12
|
+
"sorting": "awsui_sorting_1ksmw_lhzgl_235"
|
|
13
|
+
};
|
|
14
|
+
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CollisionDetection, KeyboardCoordinateGetter, UniqueIdentifier } from '@dnd-kit/core';
|
|
3
|
-
import {
|
|
4
|
-
export default function useDragAndDropReorder<
|
|
5
|
-
items: readonly
|
|
3
|
+
import { SortableAreaProps } from './interfaces';
|
|
4
|
+
export default function useDragAndDropReorder<Item>({ items, itemDefinition, }: {
|
|
5
|
+
items: readonly Item[];
|
|
6
|
+
itemDefinition: SortableAreaProps.ItemDefinition<Item>;
|
|
6
7
|
}): {
|
|
7
8
|
activeItemId: UniqueIdentifier | null;
|
|
8
9
|
setActiveItemId: (id: UniqueIdentifier | null) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-and-drop-reorder.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/use-drag-and-drop-reorder.ts"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,EAGL,kBAAkB,EAElB,wBAAwB,EAExB,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA8BjD,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,IAAI,EAAE,EAClD,KAAK,EACL,cAAc,GACf,EAAE;IACD,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,cAAc,EAAE,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;CACxD;;0BAK4B,gBAAgB,GAAG,IAAI;;;2BAQpB,mBAAmB;;EAwGlD"}
|
|
@@ -27,7 +27,7 @@ var KeyboardCode;
|
|
|
27
27
|
// We let our collisionDetection and customCoordinateGetter use the same
|
|
28
28
|
// getClosestId function which takes its value from the current component
|
|
29
29
|
// state, to make sure they are always in sync.
|
|
30
|
-
export default function useDragAndDropReorder({ items }) {
|
|
30
|
+
export default function useDragAndDropReorder({ items, itemDefinition, }) {
|
|
31
31
|
const isKeyboard = useRef(false);
|
|
32
32
|
const positionDelta = useRef(0);
|
|
33
33
|
const [activeItemId, setActiveItemId] = useState(null);
|
|
@@ -40,7 +40,7 @@ export default function useDragAndDropReorder({ items }) {
|
|
|
40
40
|
};
|
|
41
41
|
const handleKeyDown = (event) => {
|
|
42
42
|
if (isKeyboard.current && activeItemId) {
|
|
43
|
-
const currentTargetIndex = items.findIndex(item =>
|
|
43
|
+
const currentTargetIndex = items.findIndex(item => itemDefinition.id(item) === activeItemId) + positionDelta.current;
|
|
44
44
|
if (event.key === 'ArrowDown' && currentTargetIndex < items.length - 1) {
|
|
45
45
|
positionDelta.current += 1;
|
|
46
46
|
}
|
|
@@ -57,9 +57,9 @@ export default function useDragAndDropReorder({ items }) {
|
|
|
57
57
|
if (positionDelta.current === 0) {
|
|
58
58
|
return active.id;
|
|
59
59
|
}
|
|
60
|
-
const currentIndex = items.findIndex(item =>
|
|
60
|
+
const currentIndex = items.findIndex(item => itemDefinition.id(item) === active.id);
|
|
61
61
|
const newIndex = Math.max(0, Math.min(items.length - 1, currentIndex + positionDelta.current));
|
|
62
|
-
return items[newIndex]
|
|
62
|
+
return itemDefinition.id(items[newIndex]);
|
|
63
63
|
};
|
|
64
64
|
const collisionDetection = ({ active, collisionRect, droppableContainers, droppableRects, pointerCoordinates, }) => {
|
|
65
65
|
if (isKeyboard.current) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-and-drop-reorder.js","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/use-drag-and-drop-reorder.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAEL,aAAa,EAIb,aAAa,EAEb,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,IAAK,YAQJ;AARD,WAAK,YAAY;IACf,+BAAe,CAAA;IACf,kCAAkB,CAAA;IAClB,oCAAoB,CAAA;IACpB,kCAAkB,CAAA;IAClB,8BAAc,CAAA;IACd,8BAAc,CAAA;IACd,+BAAe,CAAA;AACjB,CAAC,EARI,YAAY,KAAZ,YAAY,QAQhB;AAED,0EAA0E;AAC1E,8EAA8E;AAC9E,qBAAqB;AAErB,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,sBAAsB;AAEtB,0EAA0E;AAC1E,4EAA4E;AAC5E,yBAAyB;AAEzB,wEAAwE;AACxE,yEAAyE;AACzE,+CAA+C;AAE/C,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAO,EAClD,KAAK,EACL,cAAc,GAIf;IACC,M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CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,UAAU,CACxB,SAAS,CAAC,aAAa,CAAC,EACxB,SAAS,CAAC,cAAc,EAAE;QACxB,gBAAgB;QAChB,YAAY,EAAE,GAAG,EAAE;YACjB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,CAAC;KACF,CAAC,CACH,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,eAAe,EAAE,aAAa;QAC9B,kBAAkB;QAClB,gBAAgB;QAChB,aAAa;QACb,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,CAAqB,EAAE,CAAqB;IAC3D,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;AACnH,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,mBAAmB,GAKpB;IACC,IAAI,SAAS,KAAK,QAAQ,EAAE;QAC1B,OAAO;KACR;IACD,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAClF,IAAI,kBAAkB,EAAE;QACtB,OAAO;YACL,EAAE,EAAE,kBAAkB,CAAC,EAAE;YACzB,IAAI,EAAE;gBACJ,kBAAkB,EAAE,kBAAkB;gBACtC,KAAK,EAAE,CAAC;aACT;SACF,CAAC;KACH;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport {\n Active,\n closestCenter,\n CollisionDetection,\n DroppableContainer,\n KeyboardCoordinateGetter,\n PointerSensor,\n UniqueIdentifier,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { hasSortableData } from '@dnd-kit/sortable';\n\nimport { SortableAreaProps } from './interfaces';\nimport { KeyboardSensor } from './keyboard-sensor';\n\nenum KeyboardCode {\n Space = 'Space',\n Down = 'ArrowDown',\n Right = 'ArrowRight',\n Left = 'ArrowLeft',\n Up = 'ArrowUp',\n Esc = 'Escape',\n Enter = 'Enter',\n}\n\n// A custom collision detection algorithm is used when using a keyboard to\n// work around an unexpected behavior when reordering items of variable height\n// with the keyboard.\n\n// Neither closestCenter nor closestCorners work really well for this case,\n// because the center (or corners) of a tall rectangle might be so low that it\n// is detected as being closest to the rectangle below of the one it should\n// actually swap with.\n\n// Instead of relying on coordinates, the expected results are achieved by\n// moving X positions up or down in the initially sorted array, depending on\n// the desired direction.\n\n// We let our collisionDetection and customCoordinateGetter use the same\n// getClosestId function which takes its value from the current component\n// state, to make sure they are always in sync.\n\nexport default function useDragAndDropReorder<Item>({\n items,\n itemDefinition,\n}: {\n items: readonly Item[];\n itemDefinition: SortableAreaProps.ItemDefinition<Item>;\n}) {\n const isKeyboard = useRef(false);\n const positionDelta = useRef(0);\n const [activeItemId, setActiveItemId] = useState<UniqueIdentifier | null>(null);\n\n const setActiveItem = (id: UniqueIdentifier | null) => {\n setActiveItemId(id);\n if (!id) {\n isKeyboard.current = false;\n positionDelta.current = 0;\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isKeyboard.current && activeItemId) {\n const currentTargetIndex =\n items.findIndex(item => itemDefinition.id(item) === activeItemId) + positionDelta.current;\n if (event.key === 'ArrowDown' && currentTargetIndex < items.length - 1) {\n positionDelta.current += 1;\n } else if (event.key === 'ArrowUp' && currentTargetIndex > 0) {\n positionDelta.current -= 1;\n }\n }\n if (activeItemId && isEscape(event.key)) {\n // Prevent modal from closing when pressing Esc to cancel the dragging action\n event.stopPropagation();\n }\n };\n\n const getClosestId = (active: Active) => {\n if (positionDelta.current === 0) {\n return active.id;\n }\n const currentIndex = items.findIndex(item => itemDefinition.id(item) === active.id);\n const newIndex = Math.max(0, Math.min(items.length - 1, currentIndex + positionDelta.current));\n return itemDefinition.id(items[newIndex]);\n };\n\n const collisionDetection: CollisionDetection = ({\n active,\n collisionRect,\n droppableContainers,\n droppableRects,\n pointerCoordinates,\n }) => {\n if (isKeyboard.current) {\n // For keyboard interaction, determine the colliding container based on the movements made by the arrow keys,\n // via getClosestId\n const collidingContainer = getCollidingContainer({\n activeId: active.id,\n closestId: getClosestId(active),\n droppableContainers,\n });\n return collidingContainer ? [collidingContainer] : [];\n } else {\n // For mouse interaction, use the closest center algorithm\n return closestCenter({ active, collisionRect, droppableRects, droppableContainers, pointerCoordinates });\n }\n };\n\n const coordinateGetter: KeyboardCoordinateGetter = (\n event,\n { context: { active, collisionRect, droppableRects, droppableContainers } }\n ) => {\n if (event.code === KeyboardCode.Up || event.code === KeyboardCode.Down) {\n event.preventDefault();\n\n if (!active || !collisionRect) {\n return;\n }\n\n const closestId = getClosestId(active);\n\n if (closestId !== null) {\n const activeDroppable = droppableContainers.get(active.id);\n const newDroppable = droppableContainers.get(closestId);\n const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null;\n const newNode = newDroppable?.node.current;\n\n if (newNode && newRect && activeDroppable && newDroppable) {\n const isAfterActive = isAfter(activeDroppable, newDroppable);\n const offset = {\n x: isAfterActive ? collisionRect.width - newRect.width : 0,\n y: isAfterActive ? collisionRect.height - newRect.height : 0,\n };\n const rectCoordinates = {\n x: newRect.left,\n y: newRect.top,\n };\n\n return {\n x: rectCoordinates.x - offset.x,\n y: rectCoordinates.y - offset.y,\n };\n }\n }\n }\n };\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter,\n onActivation: () => {\n isKeyboard.current = true;\n },\n })\n );\n\n return {\n activeItemId,\n setActiveItemId: setActiveItem,\n collisionDetection,\n coordinateGetter,\n handleKeyDown,\n sensors,\n };\n}\n\nfunction isAfter(a: DroppableContainer, b: DroppableContainer) {\n return hasSortableData(a) && hasSortableData(b) && a.data.current.sortable.index < b.data.current.sortable.index;\n}\n\nfunction getCollidingContainer({\n activeId,\n closestId,\n droppableContainers,\n}: {\n activeId: UniqueIdentifier;\n closestId: UniqueIdentifier;\n droppableContainers: DroppableContainer[];\n}) {\n if (closestId === activeId) {\n return;\n }\n const collidingContainer = droppableContainers.find(({ id }) => id === closestId);\n if (collidingContainer) {\n return {\n id: collidingContainer.id,\n data: {\n droppableContainer: collidingContainer,\n value: 0,\n },\n };\n }\n}\n\nconst isEscape = (key: string) => key === 'Escape' || key === 'Esc';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';
|
|
2
|
+
import { SortableAreaProps } from './interfaces';
|
|
3
|
+
export default function useLiveAnnouncements<Item>({ items, itemDefinition, isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, }: {
|
|
4
|
+
items: readonly Item[];
|
|
5
|
+
itemDefinition: SortableAreaProps.ItemDefinition<Item>;
|
|
6
|
+
isDragging: boolean;
|
|
7
|
+
} & SortableAreaProps.DndAreaI18nStrings): {
|
|
8
|
+
onDragStart({ active }: DragStartEvent): string | undefined;
|
|
9
|
+
onDragOver({ active, over }: DragOverEvent): string | undefined;
|
|
10
|
+
onDragEnd({ active, over }: DragEndEvent): string | undefined;
|
|
11
|
+
onDragCancel(): string | undefined;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=use-live-announcements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-live-announcements.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/use-live-announcements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAAI,EAAE,EACjD,KAAK,EACL,cAAc,EACd,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,GAC7B,EAAE;IACD,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IACvB,cAAc,EAAE,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACvD,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,iBAAiB,CAAC,kBAAkB;4BAOZ,cAAc;iCAMT,aAAa;gCAcd,YAAY;;EAW3C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useRef } from 'react';
|
|
4
|
-
export default function useLiveAnnouncements({ items, isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, }) {
|
|
4
|
+
export default function useLiveAnnouncements({ items, itemDefinition, isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, }) {
|
|
5
5
|
const isFirstAnnouncement = useRef(true);
|
|
6
6
|
if (!isDragging) {
|
|
7
7
|
isFirstAnnouncement.current = true;
|
|
@@ -9,7 +9,7 @@ export default function useLiveAnnouncements({ items, isDragging, liveAnnounceme
|
|
|
9
9
|
return {
|
|
10
10
|
onDragStart({ active }) {
|
|
11
11
|
if (active && liveAnnouncementDndStarted) {
|
|
12
|
-
const index = items.findIndex(item =>
|
|
12
|
+
const index = items.findIndex(item => itemDefinition.id(item) === active.id);
|
|
13
13
|
return liveAnnouncementDndStarted(index + 1, items.length);
|
|
14
14
|
}
|
|
15
15
|
},
|
|
@@ -22,15 +22,15 @@ export default function useLiveAnnouncements({ items, isDragging, liveAnnounceme
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
const initialIndex = items.findIndex(item =>
|
|
26
|
-
const currentIdex = over ? items.findIndex(item =>
|
|
25
|
+
const initialIndex = items.findIndex(item => itemDefinition.id(item) === active.id);
|
|
26
|
+
const currentIdex = over ? items.findIndex(item => itemDefinition.id(item) === over.id) : initialIndex;
|
|
27
27
|
return liveAnnouncementDndItemReordered(initialIndex + 1, currentIdex + 1, items.length);
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
onDragEnd({ active, over }) {
|
|
31
31
|
if (liveAnnouncementDndItemCommitted) {
|
|
32
|
-
const initialIndex = items.findIndex(item =>
|
|
33
|
-
const finalIndex = over ? items.findIndex(item =>
|
|
32
|
+
const initialIndex = items.findIndex(item => itemDefinition.id(item) === active.id);
|
|
33
|
+
const finalIndex = over ? items.findIndex(item => itemDefinition.id(item) === over.id) : initialIndex;
|
|
34
34
|
return liveAnnouncementDndItemCommitted(initialIndex + 1, finalIndex + 1, items.length);
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-live-announcements.js","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/use-live-announcements.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAK/B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAO,EACjD,KAAK,EACL,cAAc,EACd,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,GAKU;IACtC,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,UAAU,EAAE;QACf,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;KACpC;IA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,EAAE,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBACpF,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;gBACtG,OAAO,gCAAgC,CAAC,YAAY,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;aACzF;QACH,CAAC;QACD,YAAY;YACV,OAAO,4BAA4B,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useRef } from 'react';\nimport { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';\n\nimport { SortableAreaProps } from './interfaces';\n\nexport default function useLiveAnnouncements<Item>({\n items,\n itemDefinition,\n isDragging,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n}: {\n items: readonly Item[];\n itemDefinition: SortableAreaProps.ItemDefinition<Item>;\n isDragging: boolean;\n} & SortableAreaProps.DndAreaI18nStrings) {\n const isFirstAnnouncement = useRef(true);\n if (!isDragging) {\n isFirstAnnouncement.current = true;\n }\n\n return {\n onDragStart({ active }: DragStartEvent) {\n if (active && liveAnnouncementDndStarted) {\n const index = items.findIndex(item => itemDefinition.id(item) === active.id);\n return liveAnnouncementDndStarted(index + 1, items.length);\n }\n },\n onDragOver({ active, over }: DragOverEvent) {\n if (liveAnnouncementDndItemReordered) {\n // Don't announce on the first dragOver because it's redundant with onDragStart.\n if (isFirstAnnouncement.current) {\n isFirstAnnouncement.current = false;\n if (!over || over.id === active.id) {\n return;\n }\n }\n const initialIndex = items.findIndex(item => itemDefinition.id(item) === active.id);\n const currentIdex = over ? items.findIndex(item => itemDefinition.id(item) === over.id) : initialIndex;\n return liveAnnouncementDndItemReordered(initialIndex + 1, currentIdex + 1, items.length);\n }\n },\n onDragEnd({ active, over }: DragEndEvent) {\n if (liveAnnouncementDndItemCommitted) {\n const initialIndex = items.findIndex(item => itemDefinition.id(item) === active.id);\n const finalIndex = over ? items.findIndex(item => itemDefinition.id(item) === over.id) : initialIndex;\n return liveAnnouncementDndItemCommitted(initialIndex + 1, finalIndex + 1, items.length);\n }\n },\n onDragCancel() {\n return liveAnnouncementDndDiscarded;\n },\n };\n}\n"]}
|
package/internal/environment.js
CHANGED
package/internal/manifest.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AAIxE,eAAO,MAAM,OAAO,SAA+C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Metrics } from '@cloudscape-design/component-toolkit/internal';
|
|
4
|
+
import { PACKAGE_SOURCE, PACKAGE_VERSION } from './environment';
|
|
5
|
+
export const metrics = new Metrics(PACKAGE_SOURCE, PACKAGE_VERSION);
|
|
6
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../src/internal/metrics.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Metrics } from '@cloudscape-design/component-toolkit/internal';\n\nimport { PACKAGE_SOURCE, PACKAGE_VERSION } from './environment';\n\nexport const metrics = new Metrics(PACKAGE_SOURCE, PACKAGE_VERSION);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/internal/plugins/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAA2B,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAE3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAA6B,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,sBAAsB,EAAyB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAuB,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/internal/plugins/api.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAA2B,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAE3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAA6B,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAAE,sBAAsB,EAAyB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAuB,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAK1G,UAAU,QAAQ;IAChB,YAAY,EAAE;QACZ,SAAS,EAAE,gBAAgB,CAAC;QAC5B,KAAK,EAAE,gBAAgB,CAAC;QACxB,YAAY,EAAE,0BAA0B,CAAC;QACzC,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,YAAY,EAAE,0BAA0B,CAAC;KAC1C,CAAC;IACF,oBAAoB,EAAE;QACpB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,eAAe,EAAE,0BAA0B,CAAC;QAC5C,KAAK,EAAE,kBAAkB,CAAC;QAC1B,YAAY,EAAE,4BAA4B,CAAC;QAC3C,QAAQ,EAAE,kBAAkB,CAAC;QAC7B,YAAY,EAAE,4BAA4B,CAAC;QAC3C,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;QAC1D,mBAAmB,EAAE,8BAA8B,CAAC;KACrD,CAAC;CACH;AAwBD,wBAAgB,OAAO,aAWtB;AAED,eAAO,MAAQ,YAAY;eArDZ,gBAAgB;WACpB,gBAAgB;kBACT,0BAA0B;cAC9B,gBAAgB;kBACZ,0BAA0B;GAiDf,oBAAoB;eA9ClC,kBAAkB;qBACZ,0BAA0B;WACpC,kBAAkB;kBACX,4BAA4B;cAChC,kBAAkB;kBACd,4BAA4B;iBAC7B,uBAAuB,oBAAoB,CAAC;yBACpC,8BAA8B;CAuCQ,CAAC"}
|
package/internal/plugins/api.js
CHANGED
|
@@ -4,6 +4,7 @@ import { AppLayoutWidgetController } from './controllers/app-layout-widget';
|
|
|
4
4
|
import { BreadcrumbsController } from './controllers/breadcrumbs';
|
|
5
5
|
import { DrawersController } from './controllers/drawers';
|
|
6
6
|
import { SharedReactContexts } from './controllers/shared-react-contexts';
|
|
7
|
+
import { reportRuntimeApiLoadMetric } from './helpers/metrics';
|
|
7
8
|
const storageKey = Symbol.for('awsui-plugin-api');
|
|
8
9
|
function findUpApi(currentWindow) {
|
|
9
10
|
try {
|
|
@@ -27,6 +28,9 @@ export function loadApi() {
|
|
|
27
28
|
}
|
|
28
29
|
const win = window;
|
|
29
30
|
const existingApi = findUpApi(win);
|
|
31
|
+
if (!existingApi) {
|
|
32
|
+
reportRuntimeApiLoadMetric();
|
|
33
|
+
}
|
|
30
34
|
win[storageKey] = installApi(existingApi !== null && existingApi !== void 0 ? existingApi : {});
|
|
31
35
|
return win[storageKey];
|
|
32
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/internal/plugins/api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAwC,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAGL,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAA8B,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAA0B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAwC,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAkC,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/internal/plugins/api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAwC,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAGL,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAA8B,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AACxG,OAAO,EAA0B,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAwC,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAkC,MAAM,qCAAqC,CAAC;AAC1G,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CA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,CAAC,QAAQ,GAAG,eAAe,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACrF,GAAG,CAAC,oBAAoB,CAAC,QAAQ,GAAG,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAEvG,MAAM,WAAW,GAAG,IAAI,qBAAqB,EAAwB,CAAC;IACtE,GAAG,CAAC,oBAAoB,CAAC,WAAW,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAEzG,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACtD,GAAG,CAAC,oBAAoB,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,eAAe,CAChF,GAAG,CAAC,oBAAoB,CAAC,mBAAmB,CAC7C,CAAC;IAEF,OAAO,GAAe,CAAC;AACzB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BreadcrumbGroupProps } from '../../breadcrumb-group/interfaces';\nimport { ActionButtonsController, ActionsApiInternal, ActionsApiPublic } from './controllers/action-buttons';\nimport {\n AlertFlashContentApiInternal,\n AlertFlashContentApiPublic,\n AlertFlashContentController,\n} from './controllers/alert-flash-content';\nimport { AppLayoutWidgetApiInternal, AppLayoutWidgetController } from './controllers/app-layout-widget';\nimport { BreadcrumbsApiInternal, BreadcrumbsController } from './controllers/breadcrumbs';\nimport { DrawersApiInternal, DrawersApiPublic, DrawersController } from './controllers/drawers';\nimport { SharedReactContexts, SharedReactContextsApiInternal } from './controllers/shared-react-contexts';\nimport { reportRuntimeApiLoadMetric } from './helpers/metrics';\n\nconst storageKey = Symbol.for('awsui-plugin-api');\n\ninterface AwsuiApi {\n awsuiPlugins: {\n appLayout: DrawersApiPublic;\n alert: ActionsApiPublic;\n alertContent: AlertFlashContentApiPublic;\n flashbar: ActionsApiPublic;\n flashContent: AlertFlashContentApiPublic;\n };\n awsuiPluginsInternal: {\n appLayout: DrawersApiInternal;\n appLayoutWidget: AppLayoutWidgetApiInternal;\n alert: ActionsApiInternal;\n alertContent: AlertFlashContentApiInternal;\n flashbar: ActionsApiInternal;\n flashContent: AlertFlashContentApiInternal;\n breadcrumbs: BreadcrumbsApiInternal<BreadcrumbGroupProps>;\n sharedReactContexts: SharedReactContextsApiInternal;\n };\n}\n\ninterface WindowWithApi extends Window {\n [storageKey]: AwsuiApi;\n}\n\nfunction findUpApi(currentWindow: WindowWithApi): AwsuiApi | undefined {\n try {\n if (currentWindow?.[storageKey]) {\n return currentWindow[storageKey];\n }\n\n if (!currentWindow || currentWindow.parent === currentWindow) {\n // When the window has no more parents, it references itself\n return undefined;\n }\n\n return findUpApi(currentWindow.parent as WindowWithApi);\n } catch (ex) {\n // Most likely a cross-origin access error\n return undefined;\n }\n}\n\nexport function loadApi() {\n if (typeof window === 'undefined') {\n return installApi({});\n }\n const win = window as unknown as WindowWithApi;\n const existingApi = findUpApi(win);\n if (!existingApi) {\n reportRuntimeApiLoadMetric();\n }\n win[storageKey] = installApi(existingApi ?? {});\n return win[storageKey];\n}\n\nexport const { awsuiPlugins, awsuiPluginsInternal } = loadApi();\n\ntype DeepPartial<T> = T extends (...args: any) => any ? T : { [P in keyof T]?: DeepPartial<T[P]> };\n\nfunction installApi(api: DeepPartial<AwsuiApi>): AwsuiApi {\n api.awsuiPlugins ??= {};\n api.awsuiPluginsInternal ??= {};\n\n const appLayoutDrawers = new DrawersController();\n api.awsuiPlugins.appLayout = appLayoutDrawers.installPublic(api.awsuiPlugins.appLayout);\n api.awsuiPluginsInternal.appLayout = appLayoutDrawers.installInternal(api.awsuiPluginsInternal.appLayout);\n\n const appLayoutController = new AppLayoutWidgetController();\n api.awsuiPluginsInternal.appLayoutWidget = appLayoutController.installInternal(\n api.awsuiPluginsInternal.appLayoutWidget\n );\n\n const alertActions = new ActionButtonsController();\n api.awsuiPlugins.alert = alertActions.installPublic(api.awsuiPlugins.alert);\n api.awsuiPluginsInternal.alert = alertActions.installInternal(api.awsuiPluginsInternal.alert);\n\n const alertContent = new AlertFlashContentController();\n api.awsuiPlugins.alertContent = alertContent.installPublic(api.awsuiPlugins.alertContent);\n api.awsuiPluginsInternal.alertContent = alertContent.installInternal(api.awsuiPluginsInternal.alertContent);\n\n const flashContent = new AlertFlashContentController();\n api.awsuiPlugins.flashContent = flashContent.installPublic(api.awsuiPlugins.flashContent);\n api.awsuiPluginsInternal.flashContent = flashContent.installInternal(api.awsuiPluginsInternal.flashContent);\n\n const flashbarActions = new ActionButtonsController();\n api.awsuiPlugins.flashbar = flashbarActions.installPublic(api.awsuiPlugins.flashbar);\n api.awsuiPluginsInternal.flashbar = flashbarActions.installInternal(api.awsuiPluginsInternal.flashbar);\n\n const breadcrumbs = new BreadcrumbsController<BreadcrumbGroupProps>();\n api.awsuiPluginsInternal.breadcrumbs = breadcrumbs.installInternal(api.awsuiPluginsInternal.breadcrumbs);\n\n const sharedReactContexts = new SharedReactContexts();\n api.awsuiPluginsInternal.sharedReactContexts = sharedReactContexts.installInternal(\n api.awsuiPluginsInternal.sharedReactContexts\n );\n\n return api as AwsuiApi;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert-flash-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"alert-flash-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMlC,UAAU,OAAO,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACnB;AAED,UAAU,wBAAwB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,O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IAChC,mBAAmB,CAAC,QAAQ,EAAE,qCAAqC,GAAG,MAAM,IAAI,CAAC;IACjF,YAAY,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC;CACjE;AAED,qBAAa,2BAA2B;;IAgBtC,uBAAuB,YAAa,uBAAuB,UAYzD;IAEF,uBAAuB,aAErB;IAEF,YAAY,YAAa,+BAA+B,KAAG,OAAO,CAKhE;IAEF,mBAAmB,aAAc,qCAAqC,gBAapE;IAEF,aAAa,CAAC,GAAG,GAAE,OAAO,CAAC,0BAA0B,CAAM,GAAG,0BAA0B;IAKxF,eAAe,CAAC,WAAW,GAAE,OAAO,CAAC,4BAA4B,CAAM,GAAG,4BAA4B;CAMvG"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _AlertFlashContentController_listeners, _AlertFlashContentController_cleanups, _AlertFlashContentController_provider, _AlertFlashContentController_scheduleUpdate;
|
|
4
4
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
5
5
|
import debounce from '../../debounce';
|
|
6
|
+
import { reportRuntimeApiWarning } from '../helpers/metrics';
|
|
6
7
|
export class AlertFlashContentController {
|
|
7
8
|
constructor() {
|
|
8
9
|
_AlertFlashContentController_listeners.set(this, []);
|
|
@@ -16,7 +17,7 @@ export class AlertFlashContentController {
|
|
|
16
17
|
}), 0));
|
|
17
18
|
this.registerContentReplacer = (content) => {
|
|
18
19
|
if (__classPrivateFieldGet(this, _AlertFlashContentController_provider, "f")) {
|
|
19
|
-
|
|
20
|
+
reportRuntimeApiWarning('alert-flash-content', `Cannot call \`registerContentReplacer\` with new provider: provider with id "${__classPrivateFieldGet(this, _AlertFlashContentController_provider, "f").id}" already registered.`);
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
__classPrivateFieldSet(this, _AlertFlashContentController_provider, content, "f");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert-flash-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;AAItC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"alert-flash-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/alert-flash-content.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;;AAItC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAqD7D,MAAM,OAAO,2BAA2B;IAAxC;QACE,iDAA2D,EAAE,EAAC;QAC9D,gDAAY,IAAI,GAAG,EAAqD,EAAC;QACzE,wDAAoC;QAEpC,sDAAkB,QAAQ,CACxB,GAAG,EAAE,CACH,uBAAA,IAAI,8CAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACjC,IAAI,uBAAA,IAAI,6CAAU,EAAE;gBAClB,MAAM,OAAO,GAAG,QAAQ,CAAC,uBAAA,IAAI,6CAAU,CAAC,CAAC;gBACzC,uBAAA,IAAI,6CAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;aACvC;QACH,CAAC,CAAC,EACJ,CAAC,CACF,EAAC;QAEF,4BAAuB,GAAG,CAAC,OAAgC,EAAE,EAAE;YAC7D,IAAI,uBAAA,IAAI,6CAAU,EAAE;gBAClB,uBAAuB,CACrB,qBAAqB,EACrB,gFAAgF,uBAAA,IAAI,6CAAU,CAAC,EAAE,uBAAuB,CACzH,CAAC;gBACF,OAAO;aACR;YACD,uBAAA,IAAI,yCAAa,OAAO,MAAA,CAAC;YAEzB,wFAAwF;YACxF,uBAAA,IAAI,mDAAgB,MAApB,IAAI,CAAkB,CAAC;QACzB,CAAC,CAAC;QAEF,4BAAuB,GAAG,GAAG,EAAE;YAC7B,uBAAA,IAAI,yCAAa,SAAS,MAAA,CAAC;QAC7B,CAAC,CAAC;QAEF,iBAAY,GAAG,CAAC,OA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mBAAmB,oCAA/B,WAAW,CAAC,mBAAmB,GAAK,IAAI,CAAC,mBAAmB,EAAC;QAC7D,MAAA,WAAW,CAAC,YAAY,oCAAxB,WAAW,CAAC,YAAY,GAAK,IAAI,CAAC,YAAY,EAAC;QAC/C,OAAO,WAA2C,CAAC;IACrD,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ReactNode } from 'react';\n\nimport debounce from '../../debounce';\nimport { reportRuntimeApiWarning } from '../helpers/metrics';\n\n// this code should not depend on React typings, because it is portable between major versions\ninterface RefShim<T> {\n current: T | null;\n}\n\ninterface AlertFlashContentContext {\n type: string;\n headerRef: RefShim<HTMLElement>;\n contentRef: RefShim<HTMLElement>;\n}\n\ninterface AlertFlashContentInitialContext {\n type: string;\n header?: ReactNode;\n content?: ReactNode;\n}\n\nexport type ReplacementType = 'original' | 'remove' | 'replaced';\n\ninterface ReplacementApi {\n hideHeader(): void;\n restoreHeader(): void;\n replaceHeader(replacer: (container: HTMLElement) => void): void;\n hideContent(): void;\n restoreContent(): void;\n replaceContent(replacer: (container: HTMLElement) => void): void;\n}\n\nexport interface AlertFlashContentResult {\n update: () => void;\n unmount: (containers: { replacementHeaderContainer: HTMLElement; replacementContentContainer: HTMLElement }) => void;\n}\n\nexport interface AlertFlashContentConfig {\n id: string;\n runReplacer: (context: AlertFlashContentContext, replacementApi: ReplacementApi) => AlertFlashContentResult;\n initialCheck?: (context: AlertFlashContentInitialContext) => boolean;\n}\n\ntype AlertFlashContentRegistrationListener = (provider: AlertFlashContentConfig) => () => void;\n\nexport interface AlertFlashContentApiPublic {\n registerContentReplacer(config: AlertFlashContentConfig): void;\n}\n\nexport interface AlertFlashContentApiInternal {\n clearRegisteredReplacer(): void;\n onContentRegistered(listener: AlertFlashContentRegistrationListener): () => void;\n initialCheck(context: AlertFlashContentInitialContext): boolean;\n}\n\nexport class AlertFlashContentController {\n #listeners: Array<AlertFlashContentRegistrationListener> = [];\n #cleanups = new Map<AlertFlashContentRegistrationListener, () => void>();\n #provider?: AlertFlashContentConfig;\n\n #scheduleUpdate = debounce(\n () =>\n this.#listeners.forEach(listener => {\n if (this.#provider) {\n const cleanup = listener(this.#provider);\n this.#cleanups.set(listener, cleanup);\n }\n }),\n 0\n );\n\n registerContentReplacer = (content: AlertFlashContentConfig) => {\n if (this.#provider) {\n reportRuntimeApiWarning(\n 'alert-flash-content',\n `Cannot call \\`registerContentReplacer\\` with new provider: provider with id \"${this.#provider.id}\" already registered.`\n );\n return;\n }\n this.#provider = content;\n\n // Notify existing components if registration happens after the components are rendered.\n this.#scheduleUpdate();\n };\n\n clearRegisteredReplacer = () => {\n this.#provider = undefined;\n };\n\n initialCheck = (context: AlertFlashContentInitialContext): boolean => {\n if (this.#provider?.initialCheck) {\n return this.#provider.initialCheck(context);\n }\n return false;\n };\n\n onContentRegistered = (listener: AlertFlashContentRegistrationListener) => {\n if (this.#provider) {\n const cleanup = listener(this.#provider);\n this.#listeners.push(listener);\n this.#cleanups.set(listener, cleanup);\n } else {\n this.#listeners.push(listener);\n }\n return () => {\n this.#cleanups.get(listener)?.();\n this.#listeners = this.#listeners.filter(item => item !== listener);\n this.#cleanups.delete(listener);\n };\n };\n\n installPublic(api: Partial<AlertFlashContentApiPublic> = {}): AlertFlashContentApiPublic {\n api.registerContentReplacer ??= this.registerContentReplacer;\n return api as AlertFlashContentApiPublic;\n }\n\n installInternal(internalApi: Partial<AlertFlashContentApiInternal> = {}): AlertFlashContentApiInternal {\n internalApi.clearRegisteredReplacer ??= this.clearRegisteredReplacer;\n internalApi.onContentRegistered ??= this.onContentRegistered;\n internalApi.initialCheck ??= this.initialCheck;\n return internalApi as AlertFlashContentApiInternal;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawers.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"mappings":"AAGA,OAAO,EA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C1C,OAAO,CAAC,2BAA2B,CAA4C;IAC/E,OAAO,CAAC,oBAAoB,CAAuC;IACnE,OAAO,CAAC,oBAAoB,CAAuC;IAEnE,cAAc,aAER;IAEN,cAAc,WAAY,YAAY,UAMpC;IAEF,YAAY,8BAA+B,kBAAkB,UAgB3D;IAEF,mBAAmB,aAAc,2BAA2B,gBAY1D;IAEF,sBAAsB,aAEpB;IAEF,cAAc,aAAc,sBAAsB,gBAahD;IAEF,cAAc,aAAc,sBAAsB,gBAahD;IAEF,UAAU,aAAc,MAAM,WAAW,qBAAqB,UAE5D;IAEF,WAAW,aAAc,MAAM,WAAW,qBAAqB,UAE7D;IAEF,aAAa,CAAC,GAAG,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAAG,gBAAgB;IAQpE,eAAe,CAAC,WAAW,GAAE,OAAO,CAAC,kBAAkB,CAAM,GAAG,kBAAkB;CAOnF"}
|
|
@@ -2,6 +2,7 @@ import { __rest } from "tslib";
|
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import debounce from '../../debounce';
|
|
5
|
+
import { reportRuntimeApiWarning } from '../helpers/metrics';
|
|
5
6
|
const updatableProperties = [
|
|
6
7
|
'badge',
|
|
7
8
|
'resizable',
|
|
@@ -21,6 +22,9 @@ export class DrawersController {
|
|
|
21
22
|
(_a = this.drawersRegistrationListener) === null || _a === void 0 ? void 0 : _a.call(this, this.drawers);
|
|
22
23
|
}, 0);
|
|
23
24
|
this.registerDrawer = (config) => {
|
|
25
|
+
if (this.drawers.find(drawer => drawer.id === config.id)) {
|
|
26
|
+
reportRuntimeApiWarning('app-layout-drawers', `drawer with id "${config.id}" is already registered`);
|
|
27
|
+
}
|
|
24
28
|
this.drawers = this.drawers.concat(config);
|
|
25
29
|
this.scheduleUpdate();
|
|
26
30
|
};
|
|
@@ -45,7 +49,7 @@ export class DrawersController {
|
|
|
45
49
|
};
|
|
46
50
|
this.onDrawersRegistered = (listener) => {
|
|
47
51
|
if (this.drawersRegistrationListener !== null) {
|
|
48
|
-
|
|
52
|
+
reportRuntimeApiWarning('app-layout-drawers', 'multiple app layout instances detected when calling onDrawersRegistered');
|
|
49
53
|
}
|
|
50
54
|
this.drawersRegistrationListener = listener;
|
|
51
55
|
this.scheduleUpdate();
|
|
@@ -58,7 +62,7 @@ export class DrawersController {
|
|
|
58
62
|
};
|
|
59
63
|
this.onDrawerOpened = (listener) => {
|
|
60
64
|
if (this.drawerOpenedListener !== null) {
|
|
61
|
-
|
|
65
|
+
reportRuntimeApiWarning('app-layout-drawers', 'multiple app layout instances detected when calling onDrawerOpened');
|
|
62
66
|
}
|
|
63
67
|
this.drawerOpenedListener = listener;
|
|
64
68
|
return () => {
|
|
@@ -67,7 +71,7 @@ export class DrawersController {
|
|
|
67
71
|
};
|
|
68
72
|
this.onDrawerClosed = (listener) => {
|
|
69
73
|
if (this.drawerClosedListener !== null) {
|
|
70
|
-
|
|
74
|
+
reportRuntimeApiWarning('app-layout-drawers', 'multiple app layout instances detected when calling onDrawerClosed');
|
|
71
75
|
}
|
|
72
76
|
this.drawerClosedListener = listener;
|
|
73
77
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawers.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"drawers.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/controllers/drawers.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAqC7D,MAAM,mBAAmB,GAAG;IAC1B,OAAO;IACP,WAAW;IACX,aAAa;IACb,eAAe;IACf,eAAe;I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Ac,oCAA1B,WAAW,CAAC,cAAc,GAAK,IAAI,CAAC,cAAc,EAAC;QACnD,OAAO,WAAiC,CAAC;IAC3C,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport debounce from '../../debounce';\nimport { NonCancelableEventHandler } from '../../events';\nimport { reportRuntimeApiWarning } from '../helpers/metrics';\n\ntype DrawerVisibilityChange = (callback: (isVisible: boolean) => void) => void;\n\ninterface MountContentContext {\n onVisibilityChange: DrawerVisibilityChange;\n}\n\nexport interface DrawerStateChangeParams {\n isOpen: boolean;\n initiatedByUserAction?: boolean;\n}\n\nexport interface DrawerConfig {\n id: string;\n type?: 'local' | 'global';\n ariaLabels: {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n };\n badge?: boolean;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n orderPriority?: number;\n defaultActive?: boolean;\n trigger?: {\n iconSvg: string;\n };\n mountContent: (container: HTMLElement, mountContext: MountContentContext) => void;\n unmountContent: (container: HTMLElement) => void;\n preserveInactiveContent?: boolean;\n onToggle?: NonCancelableEventHandler<DrawerStateChangeParams>;\n}\n\nconst updatableProperties = [\n 'badge',\n 'resizable',\n 'defaultSize',\n 'orderPriority',\n 'defaultActive',\n 'onResize',\n] as const;\n\nexport type UpdateDrawerConfig = { id: DrawerConfig['id'] } & Partial<\n Pick<DrawerConfig, (typeof updatableProperties)[number]>\n>;\n\ntype DrawersRegistrationListener = (drawers: Array<DrawerConfig>) => void;\n\nexport type DrawersToggledListener = (drawerId: string, params?: OpenCloseDrawerParams) => void;\n\ninterface OpenCloseDrawerParams {\n initiatedByUserAction: boolean;\n}\n\nexport interface DrawersApiPublic {\n registerDrawer(config: DrawerConfig): void;\n updateDrawer(config: UpdateDrawerConfig): void;\n openDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n closeDrawer(drawerId: string, params?: OpenCloseDrawerParams): void;\n}\n\nexport interface DrawersApiInternal {\n clearRegisteredDrawers(): void;\n onDrawersRegistered(listener: DrawersRegistrationListener): () => void;\n onDrawerOpened(listener: DrawersToggledListener): () => void;\n onDrawerClosed(listener: DrawersToggledListener): () => void;\n}\n\nexport class DrawersController {\n private drawers: Array<DrawerConfig> = [];\n private drawersRegistrationListener: DrawersRegistrationListener | null = null;\n private drawerOpenedListener: DrawersToggledListener | null = null;\n private drawerClosedListener: DrawersToggledListener | null = null;\n\n scheduleUpdate = debounce(() => {\n this.drawersRegistrationListener?.(this.drawers);\n }, 0);\n\n registerDrawer = (config: DrawerConfig) => {\n if (this.drawers.find(drawer => drawer.id === config.id)) {\n reportRuntimeApiWarning('app-layout-drawers', `drawer with id \"${config.id}\" is already registered`);\n }\n this.drawers = this.drawers.concat(config);\n this.scheduleUpdate();\n };\n\n updateDrawer = ({ id: drawerId, ...rest }: UpdateDrawerConfig) => {\n const drawerIndex = this.drawers.findIndex(({ id }) => id === drawerId);\n const oldDrawerConfig = this.drawers?.[drawerIndex];\n if (!oldDrawerConfig) {\n throw new Error(`[AwsUi] [runtime drawers] drawer with id ${drawerId} not found`);\n }\n const drawers = this.drawers.slice();\n const updatedDrawer = { ...oldDrawerConfig };\n for (const key of updatableProperties) {\n if (key in rest) {\n updatedDrawer[key] = (rest as any)[key];\n }\n }\n drawers[drawerIndex] = updatedDrawer;\n this.drawers = drawers;\n this.scheduleUpdate();\n };\n\n onDrawersRegistered = (listener: DrawersRegistrationListener) => {\n if (this.drawersRegistrationListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawersRegistered'\n );\n }\n this.drawersRegistrationListener = listener;\n this.scheduleUpdate();\n return () => {\n this.drawersRegistrationListener = null;\n };\n };\n\n clearRegisteredDrawers = () => {\n this.drawers = [];\n };\n\n onDrawerOpened = (listener: DrawersToggledListener) => {\n if (this.drawerOpenedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerOpened'\n );\n }\n\n this.drawerOpenedListener = listener;\n\n return () => {\n this.drawerOpenedListener = null;\n };\n };\n\n onDrawerClosed = (listener: DrawersToggledListener) => {\n if (this.drawerClosedListener !== null) {\n reportRuntimeApiWarning(\n 'app-layout-drawers',\n 'multiple app layout instances detected when calling onDrawerClosed'\n );\n }\n\n this.drawerClosedListener = listener;\n\n return () => {\n this.drawerClosedListener = null;\n };\n };\n\n openDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerOpenedListener?.(drawerId, params);\n };\n\n closeDrawer = (drawerId: string, params?: OpenCloseDrawerParams) => {\n this.drawerClosedListener?.(drawerId, params);\n };\n\n installPublic(api: Partial<DrawersApiPublic> = {}): DrawersApiPublic {\n api.registerDrawer ??= this.registerDrawer;\n api.updateDrawer ??= this.updateDrawer;\n api.openDrawer ??= this.openDrawer;\n api.closeDrawer ??= this.closeDrawer;\n return api as DrawersApiPublic;\n }\n\n installInternal(internalApi: Partial<DrawersApiInternal> = {}): DrawersApiInternal {\n internalApi.clearRegisteredDrawers ??= this.clearRegisteredDrawers;\n internalApi.onDrawersRegistered ??= this.onDrawersRegistered;\n internalApi.onDrawerOpened ??= this.onDrawerOpened;\n internalApi.onDrawerClosed ??= this.onDrawerClosed;\n return internalApi as DrawersApiInternal;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/metrics.ts"],"names":[],"mappings":"AAKA,wBAAgB,0BAA0B,SAEzC;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAMzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { PACKAGE_VERSION } from '../../environment';
|
|
4
|
+
import { metrics } from '../../metrics';
|
|
5
|
+
export function reportRuntimeApiLoadMetric() {
|
|
6
|
+
metrics.sendPanoramaMetric({ eventName: 'awsui-runtime-api-loaded', eventDetail: { version: PACKAGE_VERSION } });
|
|
7
|
+
}
|
|
8
|
+
export function reportRuntimeApiWarning(component, message) {
|
|
9
|
+
console.warn('[AwsUi]', `[${component}]`, message);
|
|
10
|
+
metrics.sendPanoramaMetric({
|
|
11
|
+
eventName: 'awsui-runtime-api-warning',
|
|
12
|
+
eventDetail: { version: PACKAGE_VERSION, component, message },
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/metrics.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,UAAU,0BAA0B;IACxC,OAAO,CAAC,kBAAkB,CAAC,EAAE,SAAS,EAAE,0BAA0B,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;AACnH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,SAAiB,EAAE,OAAe;IACxE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,SAAS,GAAG,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,kBAAkB,CAAC;QACzB,SAAS,EAAE,2BAA2B;QACtC,WAAW,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE;KAC9D,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { PACKAGE_VERSION } from '../../environment';\nimport { metrics } from '../../metrics';\n\nexport function reportRuntimeApiLoadMetric() {\n metrics.sendPanoramaMetric({ eventName: 'awsui-runtime-api-loaded', eventDetail: { version: PACKAGE_VERSION } });\n}\n\nexport function reportRuntimeApiWarning(component: string, message: string) {\n console.warn('[AwsUi]', `[${component}]`, message);\n metrics.sendPanoramaMetric({\n eventName: 'awsui-runtime-api-warning',\n eventDetail: { version: PACKAGE_VERSION, component, message },\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,4BAA4B,EAE5B,eAAe,EAChB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAE/D,OAAO,EACL,4BAA4B,EAE5B,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAG5C,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,4BAA4B;UAMhG,MAAM;YACJ,SAAS;cACP,SAAS;;;;;;;;;EA+FtB"}
|