@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
|
@@ -1,6 +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 { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { reportRuntimeApiWarning } from './metrics';
|
|
4
5
|
export function createUseDiscoveredContent(componentName, controller) {
|
|
5
6
|
return function useDiscoveredContent({ type, header, children, }) {
|
|
6
7
|
const headerRef = useRef(null);
|
|
@@ -22,7 +23,7 @@ export function createUseDiscoveredContent(componentName, controller) {
|
|
|
22
23
|
let mounted = true;
|
|
23
24
|
function checkMounted(methodName) {
|
|
24
25
|
if (!mounted) {
|
|
25
|
-
|
|
26
|
+
reportRuntimeApiWarning(`${componentName}-content-replacer`, `"${methodName}" called after component unmounted`);
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
29
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"use-discovered-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAO/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,UAAU,0BAA0B,CAAC,aAAqB,EAAE,UAAwC;IACxG,OAAO,SAAS,oBAAoB,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,QAAQ,GAKT;QACC,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAChD,MAAM,oBAAoB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC3D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACtD,UAAU,CAAC,YAAY,CAAC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IAAI,YAAY,CAAC,aAAa,CAAC,EAAE;4BAC/B,0BAA0B,CAAC,QAAQ,CAAC,CAAC;yBACtC;oBACH,CAAC;oBACD,cAAc;wBACZ,IAAI,YAAY,CAAC,gBAAgB,CAAC,EAAE;4BAClC,0BAA0B,CAAC,UAAU,CAAC,CAAC;yBACxC;oBACH,CAAC;oBACD,cAAc,CAAC,QAA0C;wBACvD,IAAI,YAAY,CAAC,gBAAgB,CAAC,EAAE;4BAClC,QAAQ,CAAC,qBAAqB,CAAC,OAAQ,CAAC,CAAC;4BACzC,0BAA0B,CAAC,UAAU,CAAC,CAAC;yBACxC;oBACH,CAAC;iBACF,CAAC,CAAC;gBAEH,OAAO,GAAG,EAAE;;oBACV,MAAA,eAAe,CAAC,OAAO,0CAAE,OAAO,CAAC;wBAC/B,0BAA0B,EAAE,oBAAoB,CAAC,OAAQ;wBACzD,2BAA2B,EAAE,qBAAqB,CAAC,OAAQ;qBAC5D,CAAC,CAAC;oBACH,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAEX,SAAS,CAAC,GAAG,EAAE;;YACb,MAAA,eAAe,CAAC,OAAO,0CAAE,MAAM,EAAE,CAAC;QACpC,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE7B,OAAO;YACL,aAAa;YACb,qBAAqB;YACrB,sBAAsB;YACtB,SAAS,EAAE,SAAsC;YACjD,oBAAoB,EAAE,oBAAiD;YACvE,UAAU,EAAE,UAAuC;YACnD,qBAAqB,EAAE,qBAAkD;SAC1E,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ReactNode, useEffect, useRef, useState } from 'react';\n\nimport {\n AlertFlashContentApiInternal,\n AlertFlashContentResult,\n ReplacementType,\n} from '../controllers/alert-flash-content';\nimport { reportRuntimeApiWarning } from './metrics';\n\nexport function createUseDiscoveredContent(componentName: string, controller: AlertFlashContentApiInternal) {\n return function useDiscoveredContent({\n type,\n header,\n children,\n }: {\n type: string;\n header: ReactNode;\n children: ReactNode;\n }) {\n const headerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const replacementHeaderRef = useRef<HTMLDivElement>(null);\n const replacementContentRef = useRef<HTMLDivElement>(null);\n const [initialHidden, setInitialHidden] = useState(() =>\n controller.initialCheck({\n type,\n header,\n content: children,\n })\n );\n const [headerReplacementType, setFoundHeaderReplacement] = useState<ReplacementType>('original');\n const [contentReplacementType, setFoundContentReplacement] = useState<ReplacementType>('original');\n const mountedProvider = useRef<AlertFlashContentResult | undefined>();\n\n useEffect(() => {\n const context = { type, headerRef, contentRef };\n\n setInitialHidden(false);\n\n return controller.onContentRegistered(provider => {\n let mounted = true;\n\n function checkMounted(methodName: string) {\n if (!mounted) {\n reportRuntimeApiWarning(\n `${componentName}-content-replacer`,\n `\"${methodName}\" called after component unmounted`\n );\n return false;\n }\n return true;\n }\n\n mountedProvider.current = provider.runReplacer(context, {\n hideHeader() {\n if (checkMounted('hideHeader')) {\n setFoundHeaderReplacement('remove');\n }\n },\n restoreHeader() {\n if (checkMounted('restoreHeader')) {\n setFoundHeaderReplacement('original');\n }\n },\n replaceHeader(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceHeader')) {\n replacer(replacementHeaderRef.current!);\n setFoundHeaderReplacement('replaced');\n }\n },\n hideContent() {\n if (checkMounted('hideContent')) {\n setFoundContentReplacement('remove');\n }\n },\n restoreContent() {\n if (checkMounted('restoreContent')) {\n setFoundContentReplacement('original');\n }\n },\n replaceContent(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceContent')) {\n replacer(replacementContentRef.current!);\n setFoundContentReplacement('replaced');\n }\n },\n });\n\n return () => {\n mountedProvider.current?.unmount({\n replacementHeaderContainer: replacementHeaderRef.current!,\n replacementContentContainer: replacementContentRef.current!,\n });\n mounted = false;\n };\n });\n }, [type]);\n\n useEffect(() => {\n mountedProvider.current?.update();\n }, [type, header, children]);\n\n return {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRef as React.Ref<HTMLDivElement>,\n replacementHeaderRef: replacementHeaderRef as React.Ref<HTMLDivElement>,\n contentRef: contentRef as React.Ref<HTMLDivElement>,\n replacementContentRef: replacementContentRef as React.Ref<HTMLDivElement>,\n };\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/split-panel/implementation.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,MAAM,MAAM,6BAA6B,GAAG,YAAY,CAAC,eAAe,EAAE,uBAAuB,GAAG,eAAe,CAAC,GAClH,0BAA0B,CAAC;AAE7B,wBAAgB,wBAAwB,CAAC,EACvC,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,WAAgB,EAChB,GAAG,SAAS,EACb,EAAE,6BAA6B,
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/split-panel/implementation.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAKlF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAO/C,MAAM,MAAM,6BAA6B,GAAG,YAAY,CAAC,eAAe,EAAE,uBAAuB,GAAG,eAAe,CAAC,GAClH,0BAA0B,CAAC;AAE7B,wBAAgB,wBAAwB,CAAC,EACvC,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACb,WAAgB,EAChB,GAAG,SAAS,EACb,EAAE,6BAA6B,eA0N/B;AAED,eAAO,MAAM,0BAA0B,2FAAsD,CAAC"}
|
|
@@ -39,7 +39,7 @@ export function SplitPanelImplementation(_a) {
|
|
|
39
39
|
const sizeControlProps = {
|
|
40
40
|
position,
|
|
41
41
|
panelRef: splitPanelRefObject,
|
|
42
|
-
handleRef: refs.
|
|
42
|
+
handleRef: refs.slider,
|
|
43
43
|
onResize,
|
|
44
44
|
};
|
|
45
45
|
const onSliderPointerDown = usePointerEvents(sizeControlProps);
|
|
@@ -56,12 +56,11 @@ export function SplitPanelImplementation(_a) {
|
|
|
56
56
|
React.createElement(InternalButton, { className: testUtilStyles['preferences-button'], iconName: "settings", variant: "icon", onClick: () => setPreferencesOpen(true), formAction: "none", ariaLabel: i18nStrings.preferencesTitle, ref: refs.preferences }),
|
|
57
57
|
React.createElement("span", { className: styles.divider }))),
|
|
58
58
|
isOpen ? (React.createElement(InternalButton, { className: testUtilStyles['close-button'], iconName: isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close', variant: "icon", onClick: onToggle, formAction: "none", ariaLabel: i18nStrings.closeButtonAriaLabel, ariaExpanded: isOpen })) : position === 'side' ? null : (React.createElement(InternalButton, { className: testUtilStyles['open-button'], iconName: "angle-up", variant: "icon", formAction: "none", ariaLabel: i18nStrings.openButtonAriaLabel, ref: refs.toggle, ariaExpanded: isOpen })))));
|
|
59
|
-
const resizeHandle = (React.createElement(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
ariaValuenow: position === 'bottom' ? relativeSize : 100 - relativeSize, position: position, onKeyDown: onKeyDown, onPointerDown: onSliderPointerDown })));
|
|
59
|
+
const resizeHandle = (React.createElement(PanelResizeHandle, { ref: refs.slider, className: testUtilStyles.slider, ariaLabel: i18nStrings.resizeHandleAriaLabel,
|
|
60
|
+
// Allows us to use the logical left/right keys to move the slider left/right,
|
|
61
|
+
// but match aria keyboard behavior of using left/right to decrease/increase
|
|
62
|
+
// the slider value.
|
|
63
|
+
ariaValuenow: position === 'bottom' ? relativeSize : 100 - relativeSize, position: position, onKeyDown: onKeyDown, onPointerDown: onSliderPointerDown }));
|
|
65
64
|
/*
|
|
66
65
|
This effect forces the browser to recalculate the layout
|
|
67
66
|
whenever the split panel might have moved.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/split-panel/implementation.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,UAAU,MAAM,gCAAgC,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE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AI,CACxB,oBAAC,uBAAuB,IACtB,KAAK,EAAE,YAAY,EACnB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,SAAS,EACxB,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,aAAa,EAC5B,iBAAiB,EAAE,iBAAiB,IAEnC,QAAQ,CACe,CAC3B;QACA,iBAAiB,IAAI,CACpB,oBAAC,gBAAgB,IACf,OAAO,EAAE,IAAI,EACb,WAAW,EAAE,EAAE,QAAQ,EAAE,EACzB,oBAAoB,EAAE,QAAQ,KAAK,QAAQ,IAAI,gBAAgB,EAC/D,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE;gBACX,MAAM,EAAE,WAAW,CAAC,gBAAgB;gBACpC,OAAO,EAAE,WAAW,CAAC,kBAAkB;gBACvC,MAAM,EAAE,WAAW,CAAC,iBAAiB;gBACrC,aAAa,EAAE,WAAW,CAAC,wBAAwB;gBACnD,mBAAmB,EAAE,WAAW,CAAC,8BAA8B;gBAC/D,cAAc,EAAE,WAAW,CAAC,yBAAyB;gBACrD,YAAY,EAAE,WAAW,CAAC,uBAAuB;aAClD,EACD,SAAS,EAAE,WAAW,CAAC,EAAE;gBACvB,mBAAmB,mBAAM,WAAW,EAAG,CAAC;gBACxC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,EACD,SAAS,EAAE,GAAG,EAAE;gBACd,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC,GACD,CACH,CACA,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useAppLayoutToolbarEnabled } from '../app-layout/utils/feature-flags';\nimport { SizeControlProps } from '../app-layout/utils/interfaces';\nimport { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';\nimport { usePointerEvents } from '../app-layout/utils/use-pointer-events';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport PanelResizeHandle from '../internal/components/panel-resize-handle';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport globalVars from '../internal/styles/global-vars';\nimport { SomeRequired } from '../internal/types';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport { SplitPanelContentBottom } from './bottom';\nimport { SplitPanelProps } from './interfaces';\nimport PreferencesModal from './preferences-modal';\nimport { SplitPanelContentSide } from './side';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type SplitPanelImplementationProps = SomeRequired<SplitPanelProps, 'hidePreferencesButton' | 'closeBehavior'> &\n InternalBaseComponentProps;\n\nexport function SplitPanelImplementation({\n __internalRootRef,\n header,\n children,\n hidePreferencesButton,\n closeBehavior,\n i18nStrings = {},\n ...restProps\n}: SplitPanelImplementationProps) {\n const isRefresh = useVisualRefresh();\n const isToolbar = useAppLayoutToolbarEnabled();\n\n const {\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n onPreferencesChange,\n onResize,\n onToggle,\n size,\n relativeSize,\n setSplitPanelToggle,\n refs,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n const openButtonAriaLabel = i18nStrings.openButtonAriaLabel;\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });\n\n return () => {\n setSplitPanelToggle({ displayed: false, ariaLabel: undefined });\n };\n }, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n panelRef: splitPanelRefObject,\n handleRef: refs.handle,\n onResize,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const contentStyle = {\n [globalVars.stickyVerticalTopOffset]: topOffset,\n [globalVars.stickyVerticalBottomOffset]: bottomOffset,\n };\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={clsx(styles.header, isToolbar && styles['with-toolbar'])} style={appLayoutMaxWidth}>\n <h2 className={clsx(styles['header-text'], testUtilStyles['header-text'])} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={testUtilStyles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18nStrings.preferencesTitle}\n ref={refs.preferences}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={testUtilStyles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18nStrings.closeButtonAriaLabel}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={testUtilStyles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18nStrings.openButtonAriaLabel}\n ref={refs.toggle}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <div ref={refs.handle}>\n <PanelResizeHandle\n ref={refs.slider}\n className={testUtilStyles.slider}\n ariaLabel={i18nStrings.resizeHandleAriaLabel}\n // Allows us to use the logical left/right keys to move the slider left/right,\n // but match aria keyboard behavior of using left/right to decrease/increase\n // the slider value.\n ariaValuenow={position === 'bottom' ? relativeSize : 100 - relativeSize}\n position={position}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n />\n </div>\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = splitPanelRefObject.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isToolbar && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n style={contentStyle}\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n openButtonAriaLabel={openButtonAriaLabel}\n toggleRef={refs.toggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {children}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n style={contentStyle}\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {children}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18nStrings.preferencesTitle,\n confirm: i18nStrings.preferencesConfirm,\n cancel: i18nStrings.preferencesCancel,\n positionLabel: i18nStrings.preferencesPositionLabel,\n positionDescription: i18nStrings.preferencesPositionDescription,\n positionBottom: i18nStrings.preferencesPositionBottom,\n positionSide: i18nStrings.preferencesPositionSide,\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n );\n}\n\nexport const createWidgetizedSplitPanel = createWidgetizedComponent(SplitPanelImplementation);\n"]}
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/split-panel/implementation.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,iBAAiB,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAE,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D,CACH,CACA,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,yBAAyB,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useAppLayoutToolbarEnabled } from '../app-layout/utils/feature-flags';\nimport { SizeControlProps } from '../app-layout/utils/interfaces';\nimport { useKeyboardEvents } from '../app-layout/utils/use-keyboard-events';\nimport { usePointerEvents } from '../app-layout/utils/use-pointer-events';\nimport { InternalButton } from '../button/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport PanelResizeHandle from '../internal/components/panel-resize-handle';\nimport { useSplitPanelContext } from '../internal/context/split-panel-context';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { useUniqueId } from '../internal/hooks/use-unique-id';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport globalVars from '../internal/styles/global-vars';\nimport { SomeRequired } from '../internal/types';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport { SplitPanelContentBottom } from './bottom';\nimport { SplitPanelProps } from './interfaces';\nimport PreferencesModal from './preferences-modal';\nimport { SplitPanelContentSide } from './side';\n\nimport styles from './styles.css.js';\nimport testUtilStyles from './test-classes/styles.css.js';\n\nexport type SplitPanelImplementationProps = SomeRequired<SplitPanelProps, 'hidePreferencesButton' | 'closeBehavior'> &\n InternalBaseComponentProps;\n\nexport function SplitPanelImplementation({\n __internalRootRef,\n header,\n children,\n hidePreferencesButton,\n closeBehavior,\n i18nStrings = {},\n ...restProps\n}: SplitPanelImplementationProps) {\n const isRefresh = useVisualRefresh();\n const isToolbar = useAppLayoutToolbarEnabled();\n\n const {\n position,\n topOffset,\n bottomOffset,\n rightOffset,\n contentWidthStyles,\n isOpen,\n isForcedPosition,\n onPreferencesChange,\n onResize,\n onToggle,\n size,\n relativeSize,\n setSplitPanelToggle,\n refs,\n } = useSplitPanelContext();\n const baseProps = getBaseProps(restProps);\n const [isPreferencesOpen, setPreferencesOpen] = useState<boolean>(false);\n\n const appLayoutMaxWidth = isRefresh && position === 'bottom' ? contentWidthStyles : undefined;\n\n const openButtonAriaLabel = i18nStrings.openButtonAriaLabel;\n useEffect(() => {\n setSplitPanelToggle({ displayed: closeBehavior === 'collapse', ariaLabel: openButtonAriaLabel });\n\n return () => {\n setSplitPanelToggle({ displayed: false, ariaLabel: undefined });\n };\n }, [setSplitPanelToggle, openButtonAriaLabel, closeBehavior]);\n\n const splitPanelRefObject = useRef<HTMLDivElement>(null);\n\n const sizeControlProps: SizeControlProps = {\n position,\n panelRef: splitPanelRefObject,\n handleRef: refs.slider,\n onResize,\n };\n const onSliderPointerDown = usePointerEvents(sizeControlProps);\n const onKeyDown = useKeyboardEvents(sizeControlProps);\n\n const contentStyle = {\n [globalVars.stickyVerticalTopOffset]: topOffset,\n [globalVars.stickyVerticalBottomOffset]: bottomOffset,\n };\n\n const panelHeaderId = useUniqueId('split-panel-header');\n\n const wrappedHeader = (\n <div className={clsx(styles.header, isToolbar && styles['with-toolbar'])} style={appLayoutMaxWidth}>\n <h2 className={clsx(styles['header-text'], testUtilStyles['header-text'])} id={panelHeaderId}>\n {header}\n </h2>\n <div className={styles['header-actions']}>\n {!hidePreferencesButton && isOpen && (\n <>\n <InternalButton\n className={testUtilStyles['preferences-button']}\n iconName=\"settings\"\n variant=\"icon\"\n onClick={() => setPreferencesOpen(true)}\n formAction=\"none\"\n ariaLabel={i18nStrings.preferencesTitle}\n ref={refs.preferences}\n />\n <span className={styles.divider} />\n </>\n )}\n\n {isOpen ? (\n <InternalButton\n className={testUtilStyles['close-button']}\n iconName={\n isRefresh && closeBehavior === 'collapse' ? (position === 'side' ? 'angle-right' : 'angle-down') : 'close'\n }\n variant=\"icon\"\n onClick={onToggle}\n formAction=\"none\"\n ariaLabel={i18nStrings.closeButtonAriaLabel}\n ariaExpanded={isOpen}\n />\n ) : position === 'side' ? null : (\n <InternalButton\n className={testUtilStyles['open-button']}\n iconName=\"angle-up\"\n variant=\"icon\"\n formAction=\"none\"\n ariaLabel={i18nStrings.openButtonAriaLabel}\n ref={refs.toggle}\n ariaExpanded={isOpen}\n />\n )}\n </div>\n </div>\n );\n\n const resizeHandle = (\n <PanelResizeHandle\n ref={refs.slider}\n className={testUtilStyles.slider}\n ariaLabel={i18nStrings.resizeHandleAriaLabel}\n // Allows us to use the logical left/right keys to move the slider left/right,\n // but match aria keyboard behavior of using left/right to decrease/increase\n // the slider value.\n ariaValuenow={position === 'bottom' ? relativeSize : 100 - relativeSize}\n position={position}\n onKeyDown={onKeyDown}\n onPointerDown={onSliderPointerDown}\n />\n );\n\n /*\n This effect forces the browser to recalculate the layout\n whenever the split panel might have moved.\n\n This is needed as a workaround for a bug in Safari, which does\n not automatically calculate the new position of the split panel\n _content_ when the split panel moves.\n */\n useLayoutEffect(() => {\n const root = splitPanelRefObject.current;\n\n if (root) {\n const property = 'transform';\n const temporaryValue = 'translateZ(0)';\n\n const valueBefore = root.style[property];\n root.style[property] = temporaryValue;\n\n // This line forces the browser to recalculate the layout\n void root.offsetHeight;\n\n root.style[property] = valueBefore;\n }\n }, [rightOffset, __internalRootRef]);\n\n const mergedRef = useMergeRefs(splitPanelRefObject, __internalRootRef);\n\n if (closeBehavior === 'hide' && !isOpen) {\n return <></>;\n }\n\n /**\n * The AppLayout factor moved the circular buttons out of the\n * SplitPanel and into the Tools component. This conditional\n * is still needed for the early return to prevent execution\n * of the following code.\n */\n if (isRefresh && !isToolbar && !isOpen && position === 'side') {\n return <></>;\n }\n\n return (\n <>\n {position === 'side' && (\n <SplitPanelContentSide\n style={contentStyle}\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n openButtonAriaLabel={openButtonAriaLabel}\n toggleRef={refs.toggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n >\n {children}\n </SplitPanelContentSide>\n )}\n\n {position === 'bottom' && (\n <SplitPanelContentBottom\n style={contentStyle}\n resizeHandle={resizeHandle}\n baseProps={baseProps}\n isOpen={isOpen}\n splitPanelRef={mergedRef}\n cappedSize={size}\n onToggle={onToggle}\n header={wrappedHeader}\n panelHeaderId={panelHeaderId}\n appLayoutMaxWidth={appLayoutMaxWidth}\n >\n {children}\n </SplitPanelContentBottom>\n )}\n {isPreferencesOpen && (\n <PreferencesModal\n visible={true}\n preferences={{ position }}\n disabledSidePosition={position === 'bottom' && isForcedPosition}\n isRefresh={isRefresh}\n i18nStrings={{\n header: i18nStrings.preferencesTitle,\n confirm: i18nStrings.preferencesConfirm,\n cancel: i18nStrings.preferencesCancel,\n positionLabel: i18nStrings.preferencesPositionLabel,\n positionDescription: i18nStrings.preferencesPositionDescription,\n positionBottom: i18nStrings.preferencesPositionBottom,\n positionSide: i18nStrings.preferencesPositionSide,\n }}\n onConfirm={preferences => {\n onPreferencesChange({ ...preferences });\n setPreferencesOpen(false);\n }}\n onDismiss={() => {\n setPreferencesOpen(false);\n }}\n />\n )}\n </>\n );\n}\n\nexport const createWidgetizedSplitPanel = createWidgetizedComponent(SplitPanelImplementation);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,+BAE9C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,WAKrD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,WAgBlD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,8BAqB5G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM,+BAsBd;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,WAE3C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,+BAE9C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,WAKrD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,WAgBlD;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,8BAqB5G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,mBAAmB,EAC7B,kBAAkB,EAAE,MAAM,EAC1B,KAAK,EAAE,MAAM,+BAsBd;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,WAE3C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,IAAI,GAAG,WAAW,QAW3D"}
|
|
@@ -83,12 +83,11 @@ export function isTableCell(element) {
|
|
|
83
83
|
}
|
|
84
84
|
export function focusNextElement(element) {
|
|
85
85
|
if (element) {
|
|
86
|
-
// Table cells are not focusable by default (tabIndex=undefined)
|
|
87
|
-
// To force focusing we have to imperatively set tabIndex to -1.
|
|
88
|
-
//
|
|
89
|
-
// gets focused instead.
|
|
86
|
+
// Table cells are not focusable by default (tabIndex=undefined) so cell.focus() is ignored.
|
|
87
|
+
// To force focusing we have to imperatively set tabIndex to -1. This tabIndex is then to be
|
|
88
|
+
// overridden by the single tab stop context to be 0 or undefined.
|
|
90
89
|
// We cannot make cells have tabIndex=-1 by default due to an associated bug with text selection, see: PR 2158.
|
|
91
|
-
if (isTableCell(element)) {
|
|
90
|
+
if (isTableCell(element) && element.tabIndex !== 0) {
|
|
92
91
|
element.tabIndex = -1;
|
|
93
92
|
}
|
|
94
93
|
element.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/table/table-role/utils.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAgC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAoB;IACpD,IAAI,OAAO,YAAY,gBAAgB,IAAI,OAAO,YAAY,iBAAiB,EAAE;QAC/E,OAAO,OAAO,CAAC,QAAQ,CAAC;KACzB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAe;IACjD,IAAI,OAAO,GAAmB,MAAM,CAAC;IACrC,OAAO,OAAO,EAAE;QACd,0GAA0G;QAC1G,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QACD,IACE,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ;YACzC,OAAO,CAAC,YAAY,CAAC,sCAAsC,CAAC,KAAK,MAAM,EACvE;YACA,OAAO,IAAI,CAAC;SACb;QACD,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;KACjC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAuB,EAAE,kBAA0B,EAAE,KAAa;;IAC3G,IAAI,SAAS,GAA+B,IAAI,CAAC;IACjD,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC,CA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SACP;KACF;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO,OAAO,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAA2B;IAC1D,IAAI,OAAO,EAAE;QACX,4FAA4F;QAC5F,4FAA4F;QAC5F,kEAAkE;QAClE,+GAA+G;QAC/G,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE;YAClD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;SACvB;QACD,OAAO,CAAC,KAAK,EAAE,CAAC;KACjB;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function getClosestCell(element: Element) {\n return element.closest('td,th') as null | HTMLTableCellElement;\n}\n\nexport function isElementDisabled(element: HTMLElement) {\n if (element instanceof HTMLInputElement || element instanceof HTMLButtonElement) {\n return element.disabled;\n }\n return false;\n}\n\n/**\n * Returns true if the target element or one of its parents is a dialog or is marked with data-awsui-table-suppress-navigation attribute.\n * This is used to suppress navigation for interactive content without a need to use a custom suppression check.\n */\nexport function defaultIsSuppressed(target: Element) {\n let current: null | Element = target;\n while (current) {\n // Stop checking for parents upon reaching the cell element as the function only aims at the cell content.\n if (isTableCell(current)) {\n return false;\n }\n if (\n current.getAttribute('role') === 'dialog' ||\n current.getAttribute('data-awsui-table-suppress-navigation') === 'true'\n ) {\n return true;\n }\n current = current.parentElement;\n }\n return false;\n}\n\n/**\n * Finds the closest row to the targetAriaRowIndex+delta in the direction of delta.\n */\nexport function findTableRowByAriaRowIndex(table: HTMLTableElement, targetAriaRowIndex: number, delta: number) {\n let targetRow: null | HTMLTableRowElement = null;\n const rowElements = Array.from(table.querySelectorAll('tr[aria-rowindex]'));\n if (delta < 0) {\n rowElements.reverse();\n }\n for (const element of rowElements) {\n const rowIndex = parseInt(element.getAttribute('aria-rowindex') ?? '');\n targetRow = element as HTMLTableRowElement;\n\n if (rowIndex === targetAriaRowIndex) {\n break;\n }\n if (delta >= 0 && rowIndex > targetAriaRowIndex) {\n break;\n }\n if (delta < 0 && rowIndex < targetAriaRowIndex) {\n break;\n }\n }\n return targetRow;\n}\n\n/**\n * Finds the closest column to the targetAriaColIndex+delta in the direction of delta.\n */\nexport function findTableRowCellByAriaColIndex(\n tableRow: HTMLTableRowElement,\n targetAriaColIndex: number,\n delta: number\n) {\n let targetCell: null | HTMLTableCellElement = null;\n const cellElements = Array.from(tableRow.querySelectorAll('td[aria-colindex],th[aria-colindex]'));\n if (delta < 0) {\n cellElements.reverse();\n }\n for (const element of cellElements) {\n const columnIndex = parseInt(element.getAttribute('aria-colindex') ?? '');\n targetCell = element as HTMLTableCellElement;\n\n if (columnIndex === targetAriaColIndex) {\n break;\n }\n if (delta >= 0 && columnIndex > targetAriaColIndex) {\n break;\n }\n if (delta < 0 && columnIndex < targetAriaColIndex) {\n break;\n }\n }\n return targetCell;\n}\n\nexport function isTableCell(element: Element) {\n return element.tagName === 'TD' || element.tagName === 'TH';\n}\n\nexport function focusNextElement(element: null | HTMLElement) {\n if (element) {\n // Table cells are not focusable by default (tabIndex=undefined) so cell.focus() is ignored.\n // To force focusing we have to imperatively set tabIndex to -1. This tabIndex is then to be\n // overridden by the single tab stop context to be 0 or undefined.\n // We cannot make cells have tabIndex=-1 by default due to an associated bug with text selection, see: PR 2158.\n if (isTableCell(element) && element.tabIndex !== 0) {\n element.tabIndex = -1;\n }\n element.focus();\n }\n}\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { AppLayoutDrawerImplementation as AppLayoutDrawer, AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers, } from './drawer';
|
|
2
|
-
export { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';
|
|
3
|
-
export { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';
|
|
4
|
-
export { AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom, AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide, } from './split-panel';
|
|
5
|
-
export { AppLayoutToolbarImplementation as AppLayoutToolbar } from './toolbar';
|
|
6
|
-
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,6BAA6B,IAAI,eAAe,EAChD,oCAAoC,IAAI,sBAAsB,GAC/D,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iCAAiC,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,oCAAoC,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACL,6CAA6C,IAAI,+BAA+B,EAChF,2CAA2C,IAAI,6BAA6B,GAC7E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
export { AppLayoutDrawerImplementation as AppLayoutDrawer, AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers, } from './drawer';
|
|
4
|
-
export { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';
|
|
5
|
-
export { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';
|
|
6
|
-
export { AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom, AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide, } from './split-panel';
|
|
7
|
-
export { AppLayoutToolbarImplementation as AppLayoutToolbar } from './toolbar';
|
|
8
|
-
//# sourceMappingURL=exports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../../src/app-layout/visual-refresh-toolbar/exports.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EACL,6BAA6B,IAAI,eAAe,EAChD,oCAAoC,IAAI,sBAAsB,GAC/D,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iCAAiC,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,oCAAoC,IAAI,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACjG,OAAO,EACL,6CAA6C,IAAI,+BAA+B,EAChF,2CAA2C,IAAI,6BAA6B,GAC7E,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,8BAA8B,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n AppLayoutDrawerImplementation as AppLayoutDrawer,\n AppLayoutGlobalDrawersImplementation as AppLayoutGlobalDrawers,\n} from './drawer';\nexport { AppLayoutNavigationImplementation as AppLayoutNavigation } from './navigation';\nexport { AppLayoutNotificationsImplementation as AppLayoutNotifications } from './notifications';\nexport {\n AppLayoutSplitPanelDrawerBottomImplementation as AppLayoutSplitPanelDrawerBottom,\n AppLayoutSplitPanelDrawerSideImplementation as AppLayoutSplitPanelDrawerSide,\n} from './split-panel';\nexport { AppLayoutToolbarImplementation as AppLayoutToolbar } from './toolbar';\n"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DndAreaProps } from './interfaces';
|
|
3
|
-
export declare function DndArea<Data>({ items, renderItem, onItemsChange, disableReorder, i18nStrings, borderRadiusVariant, }: DndAreaProps<Data>): JSX.Element;
|
|
4
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-area/index.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAe,YAAY,EAAmB,MAAM,cAAc,CAAC;AAM1E,wBAAgB,OAAO,CAAC,IAAI,EAAE,EAC5B,KAAK,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,EACX,mBAA4B,GAC7B,EAAE,YAAY,CAAC,IAAI,CAAC,eA2EpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-area/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACzG,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,qBAAqB,MAAM,6BAA6B,CAAC;AAChE,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAE5D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,UAAU,OAAO,CAAO,EAC5B,KAAK,EACL,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,EACX,mBAAmB,GAAG,MAAM,GACT;;IACnB,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,qB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AC5B;YACH,CAAC,GACF,CAAC;IACN,MAAM,SAAS,GAAG,IAAI,CACpB,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,eAAe,mBAAmB,EAAE,CAAC,CAAC,EACpF,SAAS,IAAI,MAAM,CAAC,OAAO,CAC5B,CAAC;IACF,OAAO,CACL,0CACG,UAAU,CAAC;QACV,IAAI;QACJ,GAAG,EAAE,UAAU;QACf,KAAK;QACL,SAAS;QACT,UAAU;QACV,SAAS;QACT,QAAQ,EAAE,KAAK;QACf,eAAe,kCACV,mBAAmB,KACtB,SAAS,EAAE,MAAA,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,mCAAI,EAAE,EAC7D,eAAe,EAAE,UAAU,CAAC,kBAAkB,CAAC,EAC/C,QAAQ,EAAE,UAAU,CAAC,eAAe,CAAC,GACtC;KACF,CAAC,CACD,CACJ,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef } from 'react';\nimport { DndContext, DragOverlay } from '@dnd-kit/core';\nimport { arrayMove, SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport clsx from 'clsx';\n\nimport { joinStrings } from '../../utils/strings';\nimport Portal from '../portal';\nimport { DndAreaItem, DndAreaProps, RenderItemProps } from './interfaces';\nimport useDragAndDropReorder from './use-drag-and-drop-reorder';\nimport useLiveAnnouncements from './use-live-announcements';\n\nimport styles from './styles.css.js';\n\nexport function DndArea<Data>({\n items,\n renderItem,\n onItemsChange,\n disableReorder,\n i18nStrings,\n borderRadiusVariant = 'item',\n}: DndAreaProps<Data>) {\n const { activeItemId, setActiveItemId, collisionDetection, handleKeyDown, sensors } = useDragAndDropReorder({\n items,\n });\n const activeItem = activeItemId ? items.find(item => item.id === activeItemId) : null;\n const isDragging = activeItemId !== null;\n const announcements = useLiveAnnouncements({ items, isDragging, ...i18nStrings });\n const portalContainer = usePortalContainer();\n return (\n <DndContext\n sensors={sensors}\n collisionDetection={collisionDetection}\n accessibility={{\n announcements,\n restoreFocus: false,\n screenReaderInstructions: i18nStrings.dragHandleAriaDescription\n ? { draggable: i18nStrings.dragHandleAriaDescription }\n : undefined,\n container: portalContainer,\n }}\n onDragStart={({ active }) => setActiveItemId(active.id)}\n onDragEnd={event => {\n setActiveItemId(null);\n const { active, over } = event;\n\n if (over && active.id !== over.id) {\n const oldIndex = items.findIndex(item => item.id === active.id);\n const newIndex = items.findIndex(item => item.id === over.id);\n onItemsChange(arrayMove([...items], oldIndex, newIndex));\n }\n }}\n onDragCancel={() => setActiveItemId(null)}\n >\n <SortableContext\n disabled={disableReorder}\n items={items.map(item => item.id)}\n strategy={verticalListSortingStrategy}\n >\n {items.map(item => (\n <DraggableItem\n key={item.id}\n item={item}\n renderItem={renderItem}\n onKeyDown={handleKeyDown}\n dragHandleAriaLabel={i18nStrings.dragHandleAriaLabel}\n borderRadiusVariant={borderRadiusVariant}\n />\n ))}\n </SortableContext>\n\n <Portal container={portalContainer}>\n {/* Make sure that the drag overlay is above the modal by assigning the z-index as inline style\n so that it prevails over dnd-kit's inline z-index of 999 */}\n <DragOverlay\n className={clsx(styles['drag-overlay'], styles[`drag-overlay-${borderRadiusVariant}`])}\n dropAnimation={null}\n style={{ zIndex: 5000 }}\n >\n {activeItem &&\n renderItem({\n item: activeItem,\n style: {},\n className: styles.active,\n isDragging: true,\n isSorting: false,\n isActive: true,\n dragHandleProps: {\n ariaLabel: joinStrings(i18nStrings.dragHandleAriaLabel, activeItem.label) ?? '',\n onKeyDown: handleKeyDown,\n },\n })}\n </DragOverlay>\n </Portal>\n </DndContext>\n );\n}\n\nfunction usePortalContainer() {\n const portalContainerRef = useRef(document.createElement('div'));\n useEffect(() => {\n const container = portalContainerRef.current;\n if (!container.isConnected) {\n document.body.appendChild(container);\n }\n return () => {\n if (container.isConnected) {\n document.body.removeChild(container);\n }\n };\n }, []);\n return portalContainerRef.current;\n}\n\nfunction DraggableItem<Data>({\n item,\n dragHandleAriaLabel,\n onKeyDown,\n renderItem,\n borderRadiusVariant,\n}: {\n item: DndAreaItem<Data>;\n dragHandleAriaLabel?: string;\n onKeyDown: (event: React.KeyboardEvent) => void;\n renderItem: (props: RenderItemProps<Data>) => React.ReactNode;\n borderRadiusVariant: 'item' | 'container';\n}) {\n const { isDragging, isSorting, listeners, setNodeRef, transform, attributes } = useSortable({ id: item.id });\n const style = { transform: CSS.Translate.toString(transform) };\n const dragHandleListeners = attributes['aria-disabled']\n ? {}\n : {\n ...listeners,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (onKeyDown) {\n onKeyDown(event);\n }\n if (listeners?.onKeyDown) {\n listeners.onKeyDown(event);\n }\n },\n };\n const className = clsx(\n isDragging && clsx(styles.placeholder, styles[`placeholder-${borderRadiusVariant}`]),\n isSorting && styles.sorting\n );\n return (\n <>\n {renderItem({\n item,\n ref: setNodeRef,\n style,\n className,\n isDragging,\n isSorting,\n isActive: false,\n dragHandleProps: {\n ...dragHandleListeners,\n ariaLabel: joinStrings(dragHandleAriaLabel, item.label) ?? '',\n ariaDescribedby: attributes['aria-describedby'],\n disabled: attributes['aria-disabled'],\n },\n })}\n </>\n );\n}\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface DndAreaProps<Data> {
|
|
3
|
-
items: readonly DndAreaItem<Data>[];
|
|
4
|
-
renderItem: (props: RenderItemProps<Data>) => React.ReactNode;
|
|
5
|
-
onItemsChange: (sortedOptions: readonly DndAreaItem<Data>[]) => void;
|
|
6
|
-
i18nStrings: DndAreaI18nStrings;
|
|
7
|
-
disableReorder?: boolean;
|
|
8
|
-
borderRadiusVariant?: 'item' | 'container';
|
|
9
|
-
}
|
|
10
|
-
export interface DndAreaItem<Data> {
|
|
11
|
-
id: string;
|
|
12
|
-
label: string;
|
|
13
|
-
data: Data;
|
|
14
|
-
}
|
|
15
|
-
export interface RenderItemProps<Data> {
|
|
16
|
-
ref?: React.RefCallback<HTMLElement>;
|
|
17
|
-
item: DndAreaItem<Data>;
|
|
18
|
-
style: React.CSSProperties;
|
|
19
|
-
className?: string;
|
|
20
|
-
isDragging: boolean;
|
|
21
|
-
isSorting: boolean;
|
|
22
|
-
isActive: boolean;
|
|
23
|
-
dragHandleProps: {
|
|
24
|
-
ariaLabel: string;
|
|
25
|
-
ariaDescribedby?: string;
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
onPointerDown?: React.PointerEventHandler;
|
|
28
|
-
onKeyDown?: React.KeyboardEventHandler;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export interface DndAreaI18nStrings {
|
|
32
|
-
liveAnnouncementDndStarted?: (position: number, total: number) => string;
|
|
33
|
-
liveAnnouncementDndItemReordered?: (initialPosition: number, currentPosition: number, total: number) => string;
|
|
34
|
-
liveAnnouncementDndItemCommitted?: (initialPosition: number, finalPosition: number, total: number) => string;
|
|
35
|
-
liveAnnouncementDndDiscarded?: string;
|
|
36
|
-
dragHandleAriaLabel?: string;
|
|
37
|
-
dragHandleAriaDescription?: string;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-area/interfaces.ts"],"names":[],"mappings":";AAGA,MAAM,WAAW,YAAY,CAAC,IAAI;IAChC,KAAK,EAAE,SAAS,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;IACpC,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9D,aAAa,EAAE,CAAC,aAAa,EAAE,SAAS,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC;IACrE,WAAW,EAAE,kBAAkB,CAA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,CAAC,EAAE,MAAM,CAAC;CACpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-area/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface DndAreaProps<Data> {\n items: readonly DndAreaItem<Data>[];\n renderItem: (props: RenderItemProps<Data>) => React.ReactNode;\n onItemsChange: (sortedOptions: readonly DndAreaItem<Data>[]) => void;\n i18nStrings: DndAreaI18nStrings;\n disableReorder?: boolean;\n borderRadiusVariant?: 'item' | 'container';\n}\n\nexport interface DndAreaItem<Data> {\n id: string;\n label: string;\n data: Data;\n}\n\nexport interface RenderItemProps<Data> {\n ref?: React.RefCallback<HTMLElement>;\n item: DndAreaItem<Data>;\n style: React.CSSProperties;\n className?: string;\n isDragging: boolean;\n isSorting: boolean;\n isActive: boolean;\n dragHandleProps: {\n ariaLabel: string;\n ariaDescribedby?: string;\n disabled?: boolean;\n onPointerDown?: React.PointerEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n };\n}\n\nexport interface DndAreaI18nStrings {\n liveAnnouncementDndStarted?: (position: number, total: number) => string;\n liveAnnouncementDndItemReordered?: (initialPosition: number, currentPosition: number, total: number) => string;\n liveAnnouncementDndItemCommitted?: (initialPosition: number, finalPosition: number, total: number) => string;\n liveAnnouncementDndDiscarded?: string;\n dragHandleAriaLabel?: string;\n dragHandleAriaDescription?: string;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/dnd-area/keyboard-sensor/defaults.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,aAIlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../../../src/internal/components/dnd-area/keyboard-sensor/defaults.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAiB,MAAM,eAAe,CAAC;AAE5D,MAAM,CAAC,MAAM,oBAAoB,GAAkB;IACjD,KAAK,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;IAC/C,MAAM,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC;IAC1B,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC;CAC9C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { KeyboardCode, KeyboardCodes } from '@dnd-kit/core';\n\nexport const defaultKeyboardCodes: KeyboardCodes = {\n start: [KeyboardCode.Space, KeyboardCode.Enter],\n cancel: [KeyboardCode.Esc],\n end: [KeyboardCode.Space, KeyboardCode.Enter],\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/dnd-area/keyboard-sensor/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAyB3E,qBAAa,cAAe,YAAW,cAAc;IAMvC,OAAO,CAAC,KAAK;IALlB,iBAAiB,UAAS;IACjC,OAAO,CAAC,oBAAoB,CAA0B;IACtD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,eAAe,CAAY;gBAEf,KAAK,EAAE,mBAAmB;IAc9C,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,aA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C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC5C,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC;gBAE/C,IAAI,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;oBAC3C,OAAO,KAAK,CAAC;iBACd;gBAED,KAAK,CAAC,cAAc,EAAE,CAAC;gBAEvB,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;gBAE7C,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACF;CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport type { Activators, SensorInstance } from '@dnd-kit/core';\nimport { defaultCoordinates } from '@dnd-kit/core';\nimport { KeyboardSensorOptions, KeyboardSensorProps } from '@dnd-kit/core';\nimport {\n Coordinates,\n getOwnerDocument,\n getWindow,\n isKeyboardEvent,\n subtract as getCoordinatesDelta,\n} from '@dnd-kit/utilities';\n\nimport { scrollElementIntoView } from '../../../utils/scrollable-containers';\nimport { defaultKeyboardCodes } from './defaults';\nimport { EventName } from './utilities/events';\nimport { Listeners } from './utilities/listeners';\nimport { applyScroll } from './utilities/scroll';\n\n// Slightly modified version of @dnd-kit's KeyboardSensor:\n// https://github.com/clauderic/dnd-kit/blob/master/packages/core/src/sensors/keyboard/KeyboardSensor.ts\n\n// The only difference is that here, reordering is deactivated on blur, as in\n// this PR: https://github.com/clauderic/dnd-kit/pull/1087.\n// If it is merged, then @dnd-kit's KeyboardSensor can be used instead\n// and all files under this directory (`keyboard-sensor`) can be removed.\n\n// Changes from mainstream are marked below as \"Customization\"\n\nexport class KeyboardSensor implements SensorInstance {\n public autoScrollEnabled = false;\n private referenceCoordinates: Coordinates | undefined;\n private listeners: Listeners;\n private windowListeners: Listeners;\n\n constructor(private props: KeyboardSensorProps) {\n const {\n event: { target },\n } = props;\n\n this.props = props;\n this.listeners = new Listeners(getOwnerDocument(target));\n this.windowListeners = new Listeners(getWindow(target));\n this.handleKeyDown = this.handleKeyDown.bind(this);\n this.handleCancel = this.handleCancel.bind(this);\n\n this.attach();\n }\n\n private attach() {\n this.handleStart();\n\n this.windowListeners.add(EventName.Resize, this.handleCancel);\n this.windowListeners.add(EventName.VisibilityChange, this.handleCancel);\n\n // Customization: deactivate reordering on blur event\n this.props.event.target?.addEventListener(EventName.Blur, this.handleCancel);\n\n setTimeout(() => this.listeners.add(EventName.Keydown, this.handleKeyDown));\n }\n\n private handleStart() {\n const { activeNode, onStart } = this.props;\n const node = activeNode.node.current;\n\n if (node) {\n scrollElementIntoView(node);\n }\n\n onStart(defaultCoordinates);\n }\n\n private handleKeyDown(event: Event) {\n if (isKeyboardEvent(event)) {\n const { active, context, options } = this.props;\n const { keyboardCodes = defaultKeyboardCodes, coordinateGetter } = options;\n const { code } = event;\n\n if (keyboardCodes.end.indexOf(code) !== -1) {\n this.handleEnd(event);\n return;\n }\n\n if (keyboardCodes.cancel.indexOf(code) !== -1) {\n this.handleCancel(event);\n return;\n }\n\n const { collisionRect } = context.current;\n const currentCoordinates = collisionRect ? { x: collisionRect.left, y: collisionRect.top } : defaultCoordinates;\n\n if (!this.referenceCoordinates) {\n this.referenceCoordinates = currentCoordinates;\n }\n\n if (!coordinateGetter) {\n return;\n }\n\n const newCoordinates = coordinateGetter(event, {\n active,\n context: context.current,\n currentCoordinates,\n });\n\n if (newCoordinates) {\n const { scrollableAncestors } = context.current;\n const direction = event.code;\n\n const scrolled = applyScroll({ currentCoordinates, direction, newCoordinates, scrollableAncestors });\n\n if (!scrolled) {\n this.handleMove(event, getCoordinatesDelta(newCoordinates, this.referenceCoordinates));\n }\n }\n }\n }\n\n private handleMove(event: Event, coordinates: Coordinates) {\n const { onMove } = this.props;\n\n event.preventDefault();\n onMove(coordinates);\n }\n\n private handleEnd(event: Event) {\n const { onEnd } = this.props;\n\n event.preventDefault();\n this.detach();\n onEnd();\n }\n\n private handleCancel(event: Event) {\n const { onCancel } = this.props;\n\n // Customization: do not prevent browser from managing native focus\n if (event.type !== EventName.Blur) {\n event.preventDefault();\n }\n this.detach();\n onCancel();\n }\n\n private detach() {\n // Customization: clean up listener for blur event\n this.props.event.target?.removeEventListener(EventName.Blur, this.handleCancel);\n\n this.listeners.removeAll();\n this.windowListeners.removeAll();\n }\n\n static activators: Activators<KeyboardSensorOptions> = [\n {\n eventName: 'onKeyDown' as const,\n handler: (event: React.KeyboardEvent, { keyboardCodes = defaultKeyboardCodes, onActivation }, { active }) => {\n const { code } = event.nativeEvent;\n\n if (keyboardCodes.start.indexOf(code) !== -1) {\n const activator = active.activatorNode.current;\n\n if (activator && event.target !== activator) {\n return false;\n }\n\n event.preventDefault();\n\n onActivation?.({ event: event.nativeEvent });\n\n return true;\n }\n\n return false;\n },\n },\n ];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/events.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,gBAAgB,qBAAqB;CACtC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/events.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,8BAAiB,CAAA;IACjB,kDAAqC,CAAA;AACvC,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport enum EventName {\n Blur = 'blur',\n Keydown = 'keydown',\n Resize = 'resize',\n VisibilityChange = 'visibilitychange',\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/listeners.ts"],"names":[],"mappings":"AAEA,qBAAa,SAAS;IAGR,OAAO,CAAC,MAAM;IAF1B,OAAO,CAAC,SAAS,CAAqG;gBAElG,MAAM,EAAE,WAAW,GAAG,IAAI;IAEvC,GAAG,CAAC,CAAC,SAAS,KAAK,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAC3B,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO;IAMtC,SAAS,aAEd;CACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.js","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/listeners.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,MAAM,OAAO,SAAS;IAGpB,YAAoB,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;QAFtC,cAAS,GAAkG,EAAE,CAAC;QAa/G,cAAS,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,CAAA,EAAA,CAAC,CAAC;QACpF,CAAC,CAAC;IAb+C,CAAC;IAE3C,GAAG,CACR,SAAiB,EACjB,OAA2B,EAC3B,OAA2C;;QAE3C,MAAA,IAAI,CAAC,MAAM,0CAAE,gBAAgB,CAAC,SAAS,EAAE,OAAwB,EAAE,OAAO,CAAC,CAAC;QAC5E,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,OAAwB,EAAE,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;CAKF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nexport class Listeners {\n private listeners: [string, EventListenerOrEventListenerObject, AddEventListenerOptions | boolean | undefined][] = [];\n\n constructor(private target: EventTarget | null) {}\n\n public add<T extends Event>(\n eventName: string,\n handler: (event: T) => void,\n options?: AddEventListenerOptions | boolean\n ) {\n this.target?.addEventListener(eventName, handler as EventListener, options);\n this.listeners.push([eventName, handler as EventListener, options]);\n }\n\n public removeAll = () => {\n this.listeners.forEach(listener => this.target?.removeEventListener(...listener));\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/scroll.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,WAAW,EAAmC,MAAM,oBAAoB,CAAC;AAsE7F,wBAAgB,WAAW,CAAC,EAC1B,kBAAkB,EAClB,SAAS,EACT,cAAc,EACd,mBAAmB,GACpB,EAAE;IACD,kBAAkB,EAAE,WAAW,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,WAAW,CAAC;IAC5B,mBAAmB,EAAE,OAAO,EAAE,CAAC;CAChC,WA0CA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../../../../../../src/internal/components/dnd-area/keyboard-sensor/utilities/scroll.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAe,QAAQ,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE7F,SAAS,0BAA0B,CAAC,OAAuB;IACzD,IAAI,CAAC,SAAS,IAAI,CAAC,OA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AK,YAAY,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,KAAK,YAAY,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAE/G,IAAI,UAAU,IAAI,kBAAkB,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,EAAE;YAC3D,MAAM,oBAAoB,GAAG,eAAe,CAAC,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC;YAC5E,MAAM,yBAAyB,GAC7B,CAAC,SAAS,KAAK,YAAY,CAAC,IAAI,IAAI,oBAAoB,IAAI,SAAS,CAAC,CAAC,CAAC;gBACxE,CAAC,SAAS,KAAK,YAAY,CAAC,EAAE,IAAI,oBAAoB,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;YAEzE,IAAI,yBAAyB,EAAE;gBAC7B,gFAAgF;gBAChF,qDAAqD;gBACrD,eAAe,CAAC,QAAQ,CAAC;oBACvB,GAAG,EAAE,oBAAoB;oBACzB,QAAQ,EAAE,QAAQ;iBACnB,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;aACb;YAED,MAAM;SACP;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { KeyboardCode } from '@dnd-kit/core';\nimport { canUseDOM, Coordinates, subtract as getCoordinatesDelta } from '@dnd-kit/utilities';\n\nfunction isDocumentScrollingElement(element: Element | null) {\n if (!canUseDOM || !element) {\n return false;\n }\n\n return element === document.scrollingElement;\n}\n\nfunction getScrollPosition(scrollingContainer: Element) {\n const minScroll = {\n x: 0,\n y: 0,\n };\n const dimensions = isDocumentScrollingElement(scrollingContainer)\n ? {\n height: window.innerHeight,\n width: window.innerWidth,\n }\n : {\n height: scrollingContainer.clientHeight,\n width: scrollingContainer.clientWidth,\n };\n const maxScroll = {\n x: scrollingContainer.scrollWidth - dimensions.width,\n y: scrollingContainer.scrollHeight - dimensions.height,\n };\n\n const isTop = scrollingContainer.scrollTop <= minScroll.y;\n const isLeft = scrollingContainer.scrollLeft <= minScroll.x;\n const isBottom = scrollingContainer.scrollTop >= maxScroll.y;\n const isRight = scrollingContainer.scrollLeft >= maxScroll.x;\n\n return {\n isTop,\n isLeft,\n isBottom,\n isRight,\n maxScroll,\n minScroll,\n };\n}\n\nfunction getScrollElementRect(element: Element) {\n if (element === document.scrollingElement) {\n const { innerWidth, innerHeight } = window;\n\n return {\n top: 0,\n left: 0,\n right: innerWidth,\n bottom: innerHeight,\n width: innerWidth,\n height: innerHeight,\n };\n }\n\n const { top, left, right, bottom } = element.getBoundingClientRect();\n\n return {\n top,\n left,\n right,\n bottom,\n width: element.clientWidth,\n height: element.clientHeight,\n };\n}\n\nexport function applyScroll({\n currentCoordinates,\n direction,\n newCoordinates,\n scrollableAncestors,\n}: {\n currentCoordinates: Coordinates;\n direction: string;\n newCoordinates: Coordinates;\n scrollableAncestors: Element[];\n}) {\n for (const scrollContainer of scrollableAncestors) {\n const coordinatesDelta = getCoordinatesDelta(newCoordinates, currentCoordinates);\n const { isTop, isBottom, maxScroll, minScroll } = getScrollPosition(scrollContainer);\n const scrollElementRect = getScrollElementRect(scrollContainer);\n\n const clampedCoordinates = {\n y: Math.min(\n direction === KeyboardCode.Down\n ? scrollElementRect.bottom - scrollElementRect.height / 2\n : scrollElementRect.bottom,\n Math.max(\n direction === KeyboardCode.Down\n ? scrollElementRect.top\n : scrollElementRect.top + scrollElementRect.height / 2,\n newCoordinates.y\n )\n ),\n };\n\n const canScrollY = (direction === KeyboardCode.Down && !isBottom) || (direction === KeyboardCode.Up && !isTop);\n\n if (canScrollY && clampedCoordinates.y !== newCoordinates.y) {\n const newScrollCoordinates = scrollContainer.scrollTop + coordinatesDelta.y;\n const canScrollToNewCoordinates =\n (direction === KeyboardCode.Down && newScrollCoordinates <= maxScroll.y) ||\n (direction === KeyboardCode.Up && newScrollCoordinates >= minScroll.y);\n\n if (canScrollToNewCoordinates) {\n // We don't need to update coordinates, the scroll adjustment alone will trigger\n // logic to auto-detect the new container we are over\n scrollContainer.scrollTo({\n top: newScrollCoordinates,\n behavior: 'smooth',\n });\n return true;\n }\n\n break;\n }\n }\n return false;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import './styles.scoped.css';
|
|
3
|
-
export default {
|
|
4
|
-
"drag-overlay": "awsui_drag-overlay_1kgab_lhzgl_145",
|
|
5
|
-
"drag-overlay-item": "awsui_drag-overlay-item_1kgab_lhzgl_148",
|
|
6
|
-
"drag-overlay-container": "awsui_drag-overlay-container_1kgab_lhzgl_175",
|
|
7
|
-
"active": "awsui_active_1kgab_lhzgl_203",
|
|
8
|
-
"placeholder": "awsui_placeholder_1kgab_lhzgl_213",
|
|
9
|
-
"placeholder-item": "awsui_placeholder-item_1kgab_lhzgl_222",
|
|
10
|
-
"placeholder-container": "awsui_placeholder-container_1kgab_lhzgl_228",
|
|
11
|
-
"sorting": "awsui_sorting_1kgab_lhzgl_235"
|
|
12
|
-
};
|
|
13
|
-
|
|
@@ -1,14 +0,0 @@
|
|
|
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_1kgab_lhzgl_145",
|
|
6
|
-
"drag-overlay-item": "awsui_drag-overlay-item_1kgab_lhzgl_148",
|
|
7
|
-
"drag-overlay-container": "awsui_drag-overlay-container_1kgab_lhzgl_175",
|
|
8
|
-
"active": "awsui_active_1kgab_lhzgl_203",
|
|
9
|
-
"placeholder": "awsui_placeholder_1kgab_lhzgl_213",
|
|
10
|
-
"placeholder-item": "awsui_placeholder-item_1kgab_lhzgl_222",
|
|
11
|
-
"placeholder-container": "awsui_placeholder-container_1kgab_lhzgl_228",
|
|
12
|
-
"sorting": "awsui_sorting_1kgab_lhzgl_235"
|
|
13
|
-
};
|
|
14
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-drag-and-drop-reorder.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-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,WAAW,EAAE,MAAM,cAAc,CAAC;AA8B3C,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,SAAS,WAAW,CAAC,IAAI,CAAC,EAAE,CAAA;CAAE;;0BAKzE,gBAAgB,GAAG,IAAI;;;2BAQpB,mBAAmB;;EAuGlD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-drag-and-drop-reorder.js","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-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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,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 { DndAreaItem } 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<Data>({ items }: { items: readonly DndAreaItem<Data>[] }) {\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 = items.findIndex(item => item.id === 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 => item.id === active.id);\n const newIndex = Math.max(0, Math.min(items.length - 1, currentIndex + positionDelta.current));\n return items[newIndex].id;\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"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';
|
|
2
|
-
import { DndAreaI18nStrings, DndAreaItem } from './interfaces';
|
|
3
|
-
export default function useLiveAnnouncements<Data>({ items, isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, }: {
|
|
4
|
-
items: readonly DndAreaItem<Data>[];
|
|
5
|
-
isDragging: boolean;
|
|
6
|
-
} & DndAreaI18nStrings): {
|
|
7
|
-
onDragStart({ active }: DragStartEvent): string | undefined;
|
|
8
|
-
onDragOver({ active, over }: DragOverEvent): string | undefined;
|
|
9
|
-
onDragEnd({ active, over }: DragEndEvent): string | undefined;
|
|
10
|
-
onDragCancel(): string | undefined;
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=use-live-announcements.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-live-announcements.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-area/use-live-announcements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,IAAI,EAAE,EACjD,KAAK,EACL,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,GAC7B,EAAE;IAAE,KAAK,EAAE,SAAS,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,GAAG,kBAAkB;4BAOxD,cAAc;iCAMT,aAAa;gCAcd,YAAY;;EAW3C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-live-announcements.js","sourceRoot":"","sources":["../../../../../src/internal/components/dnd-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,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,GACsD;IAClF,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,UAAU,EAAE;QACf,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;KACpC;IAED,OAAO;QACL,WAAW,CAAC,EAAE,MAAM,EAAkB;YACpC,IAAI,MAAM,IAAI,0BAA0B,EAAE;gBACxC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC7D,OAAO,0BAA0B,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;aAC5D;QACH,CAAC;QACD,U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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 { DndAreaI18nStrings, DndAreaItem } from './interfaces';\n\nexport default function useLiveAnnouncements<Data>({\n items,\n isDragging,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n}: { items: readonly DndAreaItem<Data>[]; isDragging: boolean } & 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 => item.id === 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 => item.id === active.id);\n const currentIdex = over ? items.findIndex(item => item.id === 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 => item.id === active.id);\n const finalIndex = over ? items.findIndex(item => item.id === over.id) : initialIndex;\n return liveAnnouncementDndItemCommitted(initialIndex + 1, finalIndex + 1, items.length);\n }\n },\n onDragCancel() {\n return liveAnnouncementDndDiscarded;\n },\n };\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/events.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
/package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/listeners.d.ts
RENAMED
|
File without changes
|
/package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/listeners.js
RENAMED
|
File without changes
|
/package/internal/components/{dnd-area → sortable-area}/keyboard-sensor/utilities/scroll.d.ts
RENAMED
|
File without changes
|
|
File without changes
|