@cloudscape-design/components 3.0.873 → 3.0.875
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/visual-refresh-toolbar/toolbar/trigger-button/index.js +4 -4
- package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/index.js.map +1 -1
- package/attribute-editor/grid-defaults.d.ts +3 -0
- package/attribute-editor/grid-defaults.d.ts.map +1 -0
- package/attribute-editor/grid-defaults.js +122 -0
- package/attribute-editor/grid-defaults.js.map +1 -0
- package/attribute-editor/interfaces.d.ts +49 -2
- package/attribute-editor/interfaces.d.ts.map +1 -1
- package/attribute-editor/interfaces.js.map +1 -1
- package/attribute-editor/internal.d.ts.map +1 -1
- package/attribute-editor/internal.js +35 -15
- package/attribute-editor/internal.js.map +1 -1
- package/attribute-editor/row.d.ts +5 -3
- package/attribute-editor/row.d.ts.map +1 -1
- package/attribute-editor/row.js +29 -26
- package/attribute-editor/row.js.map +1 -1
- package/attribute-editor/styles.css.js +15 -14
- package/attribute-editor/styles.scoped.css +49 -41
- package/attribute-editor/styles.selectors.js +15 -14
- package/attribute-editor/utils.d.ts +11 -0
- package/attribute-editor/utils.d.ts.map +1 -0
- package/attribute-editor/utils.js +43 -0
- package/attribute-editor/utils.js.map +1 -0
- package/button-dropdown/interfaces.d.ts +6 -2
- package/button-dropdown/interfaces.d.ts.map +1 -1
- package/button-dropdown/interfaces.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +11 -3
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/utils/use-button-dropdown.js +1 -1
- package/button-dropdown/utils/use-button-dropdown.js.map +1 -1
- package/button-group/item-element.d.ts.map +1 -1
- package/button-group/item-element.js +15 -11
- package/button-group/item-element.js.map +1 -1
- package/code-editor/resizable-box/index.js +4 -4
- package/code-editor/resizable-box/index.js.map +1 -1
- package/container/use-sticky-header.js +4 -4
- package/container/use-sticky-header.js.map +1 -1
- package/file-dropzone/use-files-dragging.d.ts.map +1 -1
- package/file-dropzone/use-files-dragging.js +5 -6
- package/file-dropzone/use-files-dragging.js.map +1 -1
- package/form-field/interfaces.d.ts +2 -1
- package/form-field/interfaces.d.ts.map +1 -1
- package/form-field/interfaces.js.map +1 -1
- package/form-field/internal.d.ts +1 -1
- package/form-field/internal.d.ts.map +1 -1
- package/form-field/internal.js +2 -2
- package/form-field/internal.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +4 -4
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/animate.js +1 -1
- package/internal/animate.js.map +1 -1
- package/internal/components/chart-plot/focus-outline.js +4 -4
- package/internal/components/chart-plot/focus-outline.js.map +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.d.ts +2 -1
- package/internal/components/dropdown/dropdown-fit-handler.d.ts.map +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.js +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
- package/internal/components/dropdown/dropdown-position.d.ts +16 -0
- package/internal/components/dropdown/dropdown-position.d.ts.map +1 -0
- package/internal/components/dropdown/dropdown-position.js +27 -0
- package/internal/components/dropdown/dropdown-position.js.map +1 -0
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +19 -35
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/transition/index.js +4 -4
- package/internal/components/transition/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/focus-tracker.d.ts +1 -0
- package/internal/focus-tracker.d.ts.map +1 -1
- package/internal/focus-tracker.js +4 -4
- package/internal/focus-tracker.js.map +1 -1
- package/internal/hooks/use-mouse-down-target.js +4 -4
- package/internal/hooks/use-mouse-down-target.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/multiselect/interfaces.d.ts +4 -0
- package/multiselect/interfaces.d.ts.map +1 -1
- package/multiselect/interfaces.js.map +1 -1
- package/multiselect/internal.d.ts +1 -3
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js.map +1 -1
- package/package.json +1 -1
- package/popover/container.d.ts.map +1 -1
- package/popover/container.js +5 -6
- package/popover/container.js.map +1 -1
- package/table/resizer/index.d.ts.map +1 -1
- package/table/resizer/index.js +5 -6
- package/table/resizer/index.js.map +1 -1
- package/table/table-role/grid-navigation.js +5 -6
- package/table/table-role/grid-navigation.js.map +1 -1
- package/test-utils/dom/attribute-editor/index.d.ts +1 -0
- package/test-utils/dom/attribute-editor/index.js +4 -2
- package/test-utils/dom/attribute-editor/index.js.map +1 -1
- package/test-utils/dom/index.d.ts +78 -78
- package/test-utils/dom/index.js +9 -3
- package/test-utils/dom/index.js.map +1 -1
- package/test-utils/selectors/attribute-editor/index.d.ts +1 -0
- package/test-utils/selectors/attribute-editor/index.js +4 -2
- package/test-utils/selectors/attribute-editor/index.js.map +1 -1
- package/test-utils/selectors/index.d.ts +78 -78
- package/test-utils/selectors/index.js +5 -1
- package/test-utils/selectors/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/top-navigation/styles.css.js +47 -47
- package/top-navigation/styles.scoped.css +66 -65
- package/top-navigation/styles.selectors.js +47 -47
package/popover/container.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/popover/container.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAE3D,OAAO,MAAM,MAAM,iBAAiB,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AAC,MAAM,CAAC,0BAA0B,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO;aACvD,CAAC;YAEF,6BAAK,GAAG,EAAE,UAAU,IAAG,QAAQ,CAAO,CAClC,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useLayoutEffect, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { InternalPosition, PopoverProps } from './interfaces';\nimport usePopoverPosition from './use-popover-position.js';\n\nimport styles from './styles.css.js';\n\ninterface PopoverContainerProps {\n /** References the element the container is positioned against. */\n trackRef: React.RefObject<HTMLElement | SVGElement>;\n /**\n Used to update the container position in case track or track position changes:\n \n const trackRef = useRef<Element>(null)\n return (<>\n <Track style={getPosition(selectedItemId)} ref={trackRef} />\n <PopoverContainer trackRef={trackRef} trackKey={selectedItemId} .../>\n </>)\n */\n trackKey?: string | number;\n position: PopoverProps.Position;\n zIndex?: React.CSSProperties['zIndex'];\n arrow: (position: InternalPosition | null) => React.ReactNode;\n children: React.ReactNode;\n renderWithPortal?: boolean;\n size: PopoverProps.Size | 'content';\n fixedWidth: boolean;\n variant?: 'annotation';\n // When keepPosition is true, the popover will not recalculate its position when it resizes nor when it receives clicks.\n keepPosition?: boolean;\n // When allowScrollToFit is true, we will scroll to the the popover if it overflows the viewport even when choosing the best possible position for it.\n // Do not use this if the popover is open on hover, in order to avoid unexpected movement.\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n // Whether the popover should be hidden when the trigger is scrolled away.\n hideOnOverscroll?: boolean;\n}\n\nexport default function PopoverContainer({\n position,\n trackRef,\n trackKey,\n arrow,\n children,\n zIndex,\n renderWithPortal,\n size,\n fixedWidth,\n variant,\n keepPosition,\n allowScrollToFit,\n allowVerticalOverflow,\n hideOnOverscroll,\n}: PopoverContainerProps) {\n const bodyRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n const arrowRef = useRef<HTMLDivElement | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n // Updates the position handler.\n const { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling } =\n usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n trackRef,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition: position,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n });\n\n // Recalculate position when properties change.\n useLayoutEffect(() => {\n updatePositionHandler();\n }, [updatePositionHandler, trackKey]);\n\n // Recalculate position when content size changes.\n useResizeObserver(contentRef, () => {\n updatePositionHandler(true);\n });\n\n // Recalculate position on DOM events.\n useLayoutEffect(() => {\n /*\n This is a heuristic. Some layout changes are caused by user clicks (e.g. toggling the tools panel, submitting a form),\n and by tracking the click event we can adapt the popover's position to the new layout.\n\n TODO: extend this to Enter and Spacebar?\n */\n\n const onClick = (event: UIEvent | KeyboardEvent) => {\n if (\n // Do not update position if keepPosition is true.\n keepPosition ||\n // If the click was on the trigger, this will make the popover appear or disappear,\n // so no need to update its position either in this case.\n nodeContains(trackRef.current, event.target)\n ) {\n return;\n }\n\n requestAnimationFrame(() => {\n updatePositionHandler();\n });\n };\n\n const updatePositionOnResize = () => requestAnimationFrame(() => updatePositionHandler());\n const refreshPosition = () => requestAnimationFrame(() => positionHandlerRef.current());\n const controller = new AbortController();\n\n window.addEventListener('click', onClick, { signal: controller.signal });\n window.addEventListener('resize', updatePositionOnResize, { signal: controller.signal });\n window.addEventListener('scroll', refreshPosition, { capture: true, signal: controller.signal });\n\n return () => {\n controller.abort();\n };\n }, [hideOnOverscroll, keepPosition, positionHandlerRef, trackRef, updatePositionHandler]);\n\n return isOverscrolling ? null : (\n <div\n ref={popoverRef}\n style={{ ...popoverStyle, zIndex }}\n className={clsx(styles.container, isRefresh && styles.refresh)}\n >\n <div\n ref={arrowRef}\n className={clsx(styles[`container-arrow`], styles[`container-arrow-position-${internalPosition}`])}\n aria-hidden={true}\n >\n {arrow(internalPosition)}\n </div>\n\n <div\n ref={bodyRef}\n className={clsx(styles['container-body'], styles[`container-body-size-${size}`], {\n [styles['fixed-width']]: fixedWidth,\n [styles[`container-body-variant-${variant}`]]: variant,\n })}\n >\n <div ref={contentRef}>{children}</div>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/table/resizer/index.tsx"],"names":[],"mappings":";AAiBA,UAAU,YAAY;IACpB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAMD,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,eAE5D;AAED,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,QAA+B,EAC/B,QAAQ,EACR,aAAa,EACb,OAAO,EACP,eAAe,GAChB,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/table/resizer/index.tsx"],"names":[],"mappings":";AAiBA,UAAU,YAAY;IACpB,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAMD,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,eAE5D;AAED,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,QAA+B,EAC/B,QAAQ,EACR,aAAa,EACb,OAAO,EACP,eAAe,GAChB,EAAE,YAAY,eAkNd;AAED,wBAAgB,aAAa,gBAE5B"}
|
package/table/resizer/index.js
CHANGED
|
@@ -123,14 +123,15 @@ export function Resizer({ onWidthUpdate, onWidthUpdateCommit, ariaLabelledby, mi
|
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
125
|
updateTrackerPosition(getLogicalBoundingClientRect(elements.header).insetInlineEnd);
|
|
126
|
+
const controller = new AbortController();
|
|
126
127
|
if (isDragging) {
|
|
127
128
|
document.body.classList.add(styles['resize-active']);
|
|
128
|
-
document.addEventListener('mousemove', onMouseMove);
|
|
129
|
-
document.addEventListener('mouseup', onMouseUp);
|
|
129
|
+
document.addEventListener('mousemove', onMouseMove, { signal: controller.signal });
|
|
130
|
+
document.addEventListener('mouseup', onMouseUp, { signal: controller.signal });
|
|
130
131
|
}
|
|
131
132
|
if (resizerHasFocus) {
|
|
132
133
|
document.body.classList.add(styles['resize-active-with-focus']);
|
|
133
|
-
elements.header.addEventListener('keydown', onKeyDown);
|
|
134
|
+
elements.header.addEventListener('keydown', onKeyDown, { signal: controller.signal });
|
|
134
135
|
}
|
|
135
136
|
if (isKeyboardDragging) {
|
|
136
137
|
document.body.classList.add(styles['resize-active']);
|
|
@@ -139,9 +140,7 @@ export function Resizer({ onWidthUpdate, onWidthUpdateCommit, ariaLabelledby, mi
|
|
|
139
140
|
clearTimeout(autoGrowTimeout.current);
|
|
140
141
|
document.body.classList.remove(styles['resize-active']);
|
|
141
142
|
document.body.classList.remove(styles['resize-active-with-focus']);
|
|
142
|
-
|
|
143
|
-
document.removeEventListener('mouseup', onMouseUp);
|
|
144
|
-
elements.header.removeEventListener('keydown', onKeyDown);
|
|
143
|
+
controller.abort();
|
|
145
144
|
};
|
|
146
145
|
}, [minWidth, isDragging, isKeyboardDragging, resizerHasFocus, onWidthUpdate, onWidthUpdateCommit]);
|
|
147
146
|
const { tabIndex: resizerTabIndex } = useSingleTabStopNavigation(resizerToggleRef, { tabIndex });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/resizer/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,QAAQ,EAAE,4BAA4B,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAExH,OAAO,EAAE,0BAA0B,EAAE,MAAM,8DAA8D,CAAC;AAC1G,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAarC,MAAM,oBAAoB,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AM,EAAE,KAAK,CAAC,EAAE;gBACd,yEAAyE;gBACzE,uFAAuF;gBACvF,IAAI,KAAK,CAAC,aAAa,KAAK,mBAAmB,CAAC,OAAO,EAAE;oBACvD,kBAAkB,CAAC,KAAK,CAAC,CAAC;iBAC3B;YACH,CAAC,0BAIqB,eAAe,qBACpB,cAAc,EAC/B,QAAQ,EAAE,eAAe,mBACV,OAAO,GACtB;QACF,8BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,UAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,0CACjC,IAAI,EAC1C,GAAG,EAAE,mBAAmB,EACxB,EAAE,EAAE,WAAW,EACf,IAAI,EAAC,WAAW,EAChB,QAAQ,EAAE,CAAC,CAAC,iBACC,CAAC,kBAAkB,sBACf,UAAU,mBACZ,eAAe,oBAEd,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,mBAC3B,QAAQ,mBACR,OAAO,EACtB,MAAM,EAAE,GAAG,EAAE;gBACX,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC1B,IAAI,kBAAkB,EAAE;oBACtB,qBAAqB,CAAC,KAAK,CAAC,CAAC;iBAC9B;gBACD,mBAAmB,EAAE,CAAC;YACxB,CAAC,GACD,CACD,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,8BAAM,SAAS,EAAE,MAAM,CAAC,OAAO,GAAI,CAAC;AAC7C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { getIsRtl, getLogicalBoundingClientRect, getLogicalPageX } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context.js';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { DEFAULT_COLUMN_WIDTH } from '../use-column-widths';\nimport { getHeaderWidth, getResizerElements } from './resizer-lookup';\n\nimport styles from './styles.css.js';\n\ninterface ResizerProps {\n onWidthUpdate: (newWidth: number) => void;\n onWidthUpdateCommit: () => void;\n ariaLabelledby?: string;\n minWidth?: number;\n tabIndex?: number;\n focusId?: string;\n showFocusRing?: boolean;\n roleDescription?: string;\n}\n\nconst AUTO_GROW_START_TIME = 10;\nconst AUTO_GROW_INTERVAL = 10;\nconst AUTO_GROW_INCREMENT = 5;\n\nexport function Divider({ className }: { className?: string }) {\n return <span className={clsx(styles.divider, styles['divider-disabled'], className)} />;\n}\n\nexport function Resizer({\n onWidthUpdate,\n onWidthUpdateCommit,\n ariaLabelledby,\n minWidth = DEFAULT_COLUMN_WIDTH,\n tabIndex,\n showFocusRing,\n focusId,\n roleDescription,\n}: ResizerProps) {\n onWidthUpdate = useStableCallback(onWidthUpdate);\n onWidthUpdateCommit = useStableCallback(onWidthUpdateCommit);\n\n const separatorId = useUniqueId();\n const resizerToggleRef = useRef<HTMLButtonElement>(null);\n const resizerSeparatorRef = useRef<HTMLSpanElement>(null);\n\n const [isDragging, setIsDragging] = useState(false);\n const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);\n const autoGrowTimeout = useRef<ReturnType<typeof setTimeout> | undefined>();\n const [resizerHasFocus, setResizerHasFocus] = useState(false);\n const [headerCellWidth, setHeaderCellWidth] = useState(0);\n\n // Read header width after mounting for it to be available in the element's ARIA label before it gets focused.\n useEffect(() => {\n setHeaderCellWidth(getHeaderWidth(resizerToggleRef.current));\n }, []);\n\n useEffect(() => {\n const elements = getResizerElements(resizerToggleRef.current);\n const document = resizerToggleRef.current?.ownerDocument ?? window.document;\n\n if ((!isDragging && !resizerHasFocus) || !elements) {\n return;\n }\n\n const { insetInlineStart: inlineStartEdge, insetInlineEnd: inlineEndEdge } = getLogicalBoundingClientRect(\n elements.scrollParent\n );\n\n const updateTrackerPosition = (newOffset: number) => {\n const { insetInlineStart: scrollParentInsetInlineStart } = getLogicalBoundingClientRect(elements.table);\n elements.tracker.style.insetBlockStart = getLogicalBoundingClientRect(elements.header).blockSize + 'px';\n // minus one pixel to offset the cell border\n elements.tracker.style.insetInlineStart = newOffset - scrollParentInsetInlineStart - 1 + 'px';\n };\n\n const updateColumnWidth = (newWidth: number) => {\n const { insetInlineEnd, inlineSize } = getLogicalBoundingClientRect(elements.header);\n const updatedWidth = newWidth < minWidth ? minWidth : newWidth;\n updateTrackerPosition(insetInlineEnd + updatedWidth - inlineSize);\n if (newWidth >= minWidth) {\n setHeaderCellWidth(newWidth);\n }\n // callbacks must be the last calls in the handler, because they may cause an extra update\n onWidthUpdate(newWidth);\n };\n\n const resizeColumn = (offset: number) => {\n if (offset > inlineStartEdge) {\n const cellLeft = getLogicalBoundingClientRect(elements.header).insetInlineStart;\n const newWidth = offset - cellLeft;\n // callbacks must be the last calls in the handler, because they may cause an extra update\n updateColumnWidth(newWidth);\n }\n };\n\n const onAutoGrow = () => {\n const inlineSize = getLogicalBoundingClientRect(elements.header).inlineSize;\n autoGrowTimeout.current = setTimeout(onAutoGrow, AUTO_GROW_INTERVAL);\n // callbacks must be the last calls in the handler, because they may cause an extra update\n updateColumnWidth(inlineSize + AUTO_GROW_INCREMENT);\n elements.scrollParent.scrollLeft += AUTO_GROW_INCREMENT * (getIsRtl(elements.scrollParent) ? -1 : 1);\n };\n\n const onMouseMove = (event: MouseEvent) => {\n clearTimeout(autoGrowTimeout.current);\n const offset = getLogicalPageX(event);\n if (offset > inlineEndEdge) {\n autoGrowTimeout.current = setTimeout(onAutoGrow, AUTO_GROW_START_TIME);\n } else {\n resizeColumn(offset);\n }\n };\n\n const onMouseUp = (event: MouseEvent) => {\n resizeColumn(getLogicalPageX(event));\n setIsDragging(false);\n onWidthUpdateCommit();\n clearTimeout(autoGrowTimeout.current);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (isKeyboardDragging) {\n const keys = [KeyCode.left, KeyCode.right, KeyCode.enter, KeyCode.right, KeyCode.space, KeyCode.escape];\n\n if (keys.indexOf(event.keyCode) !== -1) {\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onActivate: () => {\n setIsKeyboardDragging(false);\n resizerToggleRef.current?.focus();\n },\n onEscape: () => {\n setIsKeyboardDragging(false);\n resizerToggleRef.current?.focus();\n },\n onInlineStart: () => updateColumnWidth(getLogicalBoundingClientRect(elements.header).inlineSize - 10),\n onInlineEnd: () => updateColumnWidth(getLogicalBoundingClientRect(elements.header).inlineSize + 10),\n });\n }\n }\n // Enter keyboard dragging mode\n else if (event.keyCode === KeyCode.enter || event.keyCode === KeyCode.space) {\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onActivate: () => {\n setIsKeyboardDragging(true);\n resizerSeparatorRef.current?.focus();\n },\n });\n }\n };\n\n updateTrackerPosition(getLogicalBoundingClientRect(elements.header).insetInlineEnd);\n\n if (isDragging) {\n document.body.classList.add(styles['resize-active']);\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', onMouseUp);\n }\n if (resizerHasFocus) {\n document.body.classList.add(styles['resize-active-with-focus']);\n elements.header.addEventListener('keydown', onKeyDown);\n }\n if (isKeyboardDragging) {\n document.body.classList.add(styles['resize-active']);\n }\n\n return () => {\n clearTimeout(autoGrowTimeout.current);\n document.body.classList.remove(styles['resize-active']);\n document.body.classList.remove(styles['resize-active-with-focus']);\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', onMouseUp);\n elements.header.removeEventListener('keydown', onKeyDown);\n };\n }, [minWidth, isDragging, isKeyboardDragging, resizerHasFocus, onWidthUpdate, onWidthUpdateCommit]);\n\n const { tabIndex: resizerTabIndex } = useSingleTabStopNavigation(resizerToggleRef, { tabIndex });\n\n return (\n <>\n <button\n ref={resizerToggleRef}\n className={clsx(\n styles.resizer,\n (resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus']\n )}\n onMouseDown={event => {\n if (event.button !== 0) {\n return;\n }\n event.preventDefault();\n setIsDragging(true);\n }}\n onClick={() => {\n // Prevent mouse drag activation and activate keyboard dragging for VO+Space click.\n setIsDragging(false);\n setResizerHasFocus(true);\n setIsKeyboardDragging(true);\n resizerSeparatorRef.current?.focus();\n }}\n onFocus={() => {\n setHeaderCellWidth(getHeaderWidth(resizerToggleRef.current));\n setResizerHasFocus(true);\n }}\n onBlur={event => {\n // Ignoring blur event when focus moves to the resizer separator element.\n // (This focus transition is done programmatically when the resizer button is clicked).\n if (event.relatedTarget !== resizerSeparatorRef.current) {\n setResizerHasFocus(false);\n }\n }}\n // Using a custom role-description to make the element's purpose better clear.\n // The role-description must include the word \"button\" to imply the interaction model.\n // See https://www.w3.org/TR/wai-aria-1.1/#aria-roledescription\n aria-roledescription={roleDescription}\n aria-labelledby={ariaLabelledby}\n tabIndex={resizerTabIndex}\n data-focus-id={focusId}\n />\n <span\n className={clsx(styles.divider, isDragging && styles['divider-active'])}\n data-awsui-table-suppress-navigation={true}\n ref={resizerSeparatorRef}\n id={separatorId}\n role=\"separator\"\n tabIndex={-1}\n aria-hidden={!isKeyboardDragging}\n aria-orientation=\"vertical\"\n aria-valuenow={headerCellWidth}\n // aria-valuetext is needed because the VO announces \"collapsed\" when only aria-valuenow set without aria-valuemax\n aria-valuetext={headerCellWidth.toFixed(0)}\n aria-valuemin={minWidth}\n data-focus-id={focusId}\n onBlur={() => {\n setResizerHasFocus(false);\n if (isKeyboardDragging) {\n setIsKeyboardDragging(false);\n }\n onWidthUpdateCommit();\n }}\n />\n </>\n );\n}\n\nexport function ResizeTracker() {\n return <span className={styles.tracker} />;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table/resizer/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,M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AM,EAAE,GAAG,EAAE;gBACX,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC1B,IAAI,kBAAkB,EAAE;oBACtB,qBAAqB,CAAC,KAAK,CAAC,CAAC;iBAC9B;gBACD,mBAAmB,EAAE,CAAC;YACxB,CAAC,GACD,CACD,CACJ,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,8BAAM,SAAS,EAAE,MAAM,CAAC,OAAO,GAAI,CAAC;AAC7C,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\nimport { getIsRtl, getLogicalBoundingClientRect, getLogicalPageX } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useSingleTabStopNavigation } from '../../internal/context/single-tab-stop-navigation-context.js';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { DEFAULT_COLUMN_WIDTH } from '../use-column-widths';\nimport { getHeaderWidth, getResizerElements } from './resizer-lookup';\n\nimport styles from './styles.css.js';\n\ninterface ResizerProps {\n onWidthUpdate: (newWidth: number) => void;\n onWidthUpdateCommit: () => void;\n ariaLabelledby?: string;\n minWidth?: number;\n tabIndex?: number;\n focusId?: string;\n showFocusRing?: boolean;\n roleDescription?: string;\n}\n\nconst AUTO_GROW_START_TIME = 10;\nconst AUTO_GROW_INTERVAL = 10;\nconst AUTO_GROW_INCREMENT = 5;\n\nexport function Divider({ className }: { className?: string }) {\n return <span className={clsx(styles.divider, styles['divider-disabled'], className)} />;\n}\n\nexport function Resizer({\n onWidthUpdate,\n onWidthUpdateCommit,\n ariaLabelledby,\n minWidth = DEFAULT_COLUMN_WIDTH,\n tabIndex,\n showFocusRing,\n focusId,\n roleDescription,\n}: ResizerProps) {\n onWidthUpdate = useStableCallback(onWidthUpdate);\n onWidthUpdateCommit = useStableCallback(onWidthUpdateCommit);\n\n const separatorId = useUniqueId();\n const resizerToggleRef = useRef<HTMLButtonElement>(null);\n const resizerSeparatorRef = useRef<HTMLSpanElement>(null);\n\n const [isDragging, setIsDragging] = useState(false);\n const [isKeyboardDragging, setIsKeyboardDragging] = useState(false);\n const autoGrowTimeout = useRef<ReturnType<typeof setTimeout> | undefined>();\n const [resizerHasFocus, setResizerHasFocus] = useState(false);\n const [headerCellWidth, setHeaderCellWidth] = useState(0);\n\n // Read header width after mounting for it to be available in the element's ARIA label before it gets focused.\n useEffect(() => {\n setHeaderCellWidth(getHeaderWidth(resizerToggleRef.current));\n }, []);\n\n useEffect(() => {\n const elements = getResizerElements(resizerToggleRef.current);\n const document = resizerToggleRef.current?.ownerDocument ?? window.document;\n\n if ((!isDragging && !resizerHasFocus) || !elements) {\n return;\n }\n\n const { insetInlineStart: inlineStartEdge, insetInlineEnd: inlineEndEdge } = getLogicalBoundingClientRect(\n elements.scrollParent\n );\n\n const updateTrackerPosition = (newOffset: number) => {\n const { insetInlineStart: scrollParentInsetInlineStart } = getLogicalBoundingClientRect(elements.table);\n elements.tracker.style.insetBlockStart = getLogicalBoundingClientRect(elements.header).blockSize + 'px';\n // minus one pixel to offset the cell border\n elements.tracker.style.insetInlineStart = newOffset - scrollParentInsetInlineStart - 1 + 'px';\n };\n\n const updateColumnWidth = (newWidth: number) => {\n const { insetInlineEnd, inlineSize } = getLogicalBoundingClientRect(elements.header);\n const updatedWidth = newWidth < minWidth ? minWidth : newWidth;\n updateTrackerPosition(insetInlineEnd + updatedWidth - inlineSize);\n if (newWidth >= minWidth) {\n setHeaderCellWidth(newWidth);\n }\n // callbacks must be the last calls in the handler, because they may cause an extra update\n onWidthUpdate(newWidth);\n };\n\n const resizeColumn = (offset: number) => {\n if (offset > inlineStartEdge) {\n const cellLeft = getLogicalBoundingClientRect(elements.header).insetInlineStart;\n const newWidth = offset - cellLeft;\n // callbacks must be the last calls in the handler, because they may cause an extra update\n updateColumnWidth(newWidth);\n }\n };\n\n const onAutoGrow = () => {\n const inlineSize = getLogicalBoundingClientRect(elements.header).inlineSize;\n autoGrowTimeout.current = setTimeout(onAutoGrow, AUTO_GROW_INTERVAL);\n // callbacks must be the last calls in the handler, because they may cause an extra update\n updateColumnWidth(inlineSize + AUTO_GROW_INCREMENT);\n elements.scrollParent.scrollLeft += AUTO_GROW_INCREMENT * (getIsRtl(elements.scrollParent) ? -1 : 1);\n };\n\n const onMouseMove = (event: MouseEvent) => {\n clearTimeout(autoGrowTimeout.current);\n const offset = getLogicalPageX(event);\n if (offset > inlineEndEdge) {\n autoGrowTimeout.current = setTimeout(onAutoGrow, AUTO_GROW_START_TIME);\n } else {\n resizeColumn(offset);\n }\n };\n\n const onMouseUp = (event: MouseEvent) => {\n resizeColumn(getLogicalPageX(event));\n setIsDragging(false);\n onWidthUpdateCommit();\n clearTimeout(autoGrowTimeout.current);\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (isKeyboardDragging) {\n const keys = [KeyCode.left, KeyCode.right, KeyCode.enter, KeyCode.right, KeyCode.space, KeyCode.escape];\n\n if (keys.indexOf(event.keyCode) !== -1) {\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onActivate: () => {\n setIsKeyboardDragging(false);\n resizerToggleRef.current?.focus();\n },\n onEscape: () => {\n setIsKeyboardDragging(false);\n resizerToggleRef.current?.focus();\n },\n onInlineStart: () => updateColumnWidth(getLogicalBoundingClientRect(elements.header).inlineSize - 10),\n onInlineEnd: () => updateColumnWidth(getLogicalBoundingClientRect(elements.header).inlineSize + 10),\n });\n }\n }\n // Enter keyboard dragging mode\n else if (event.keyCode === KeyCode.enter || event.keyCode === KeyCode.space) {\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onActivate: () => {\n setIsKeyboardDragging(true);\n resizerSeparatorRef.current?.focus();\n },\n });\n }\n };\n\n updateTrackerPosition(getLogicalBoundingClientRect(elements.header).insetInlineEnd);\n const controller = new AbortController();\n\n if (isDragging) {\n document.body.classList.add(styles['resize-active']);\n document.addEventListener('mousemove', onMouseMove, { signal: controller.signal });\n document.addEventListener('mouseup', onMouseUp, { signal: controller.signal });\n }\n if (resizerHasFocus) {\n document.body.classList.add(styles['resize-active-with-focus']);\n elements.header.addEventListener('keydown', onKeyDown, { signal: controller.signal });\n }\n if (isKeyboardDragging) {\n document.body.classList.add(styles['resize-active']);\n }\n\n return () => {\n clearTimeout(autoGrowTimeout.current);\n document.body.classList.remove(styles['resize-active']);\n document.body.classList.remove(styles['resize-active-with-focus']);\n controller.abort();\n };\n }, [minWidth, isDragging, isKeyboardDragging, resizerHasFocus, onWidthUpdate, onWidthUpdateCommit]);\n\n const { tabIndex: resizerTabIndex } = useSingleTabStopNavigation(resizerToggleRef, { tabIndex });\n\n return (\n <>\n <button\n ref={resizerToggleRef}\n className={clsx(\n styles.resizer,\n (resizerHasFocus || showFocusRing || isKeyboardDragging) && styles['has-focus']\n )}\n onMouseDown={event => {\n if (event.button !== 0) {\n return;\n }\n event.preventDefault();\n setIsDragging(true);\n }}\n onClick={() => {\n // Prevent mouse drag activation and activate keyboard dragging for VO+Space click.\n setIsDragging(false);\n setResizerHasFocus(true);\n setIsKeyboardDragging(true);\n resizerSeparatorRef.current?.focus();\n }}\n onFocus={() => {\n setHeaderCellWidth(getHeaderWidth(resizerToggleRef.current));\n setResizerHasFocus(true);\n }}\n onBlur={event => {\n // Ignoring blur event when focus moves to the resizer separator element.\n // (This focus transition is done programmatically when the resizer button is clicked).\n if (event.relatedTarget !== resizerSeparatorRef.current) {\n setResizerHasFocus(false);\n }\n }}\n // Using a custom role-description to make the element's purpose better clear.\n // The role-description must include the word \"button\" to imply the interaction model.\n // See https://www.w3.org/TR/wai-aria-1.1/#aria-roledescription\n aria-roledescription={roleDescription}\n aria-labelledby={ariaLabelledby}\n tabIndex={resizerTabIndex}\n data-focus-id={focusId}\n />\n <span\n className={clsx(styles.divider, isDragging && styles['divider-active'])}\n data-awsui-table-suppress-navigation={true}\n ref={resizerSeparatorRef}\n id={separatorId}\n role=\"separator\"\n tabIndex={-1}\n aria-hidden={!isKeyboardDragging}\n aria-orientation=\"vertical\"\n aria-valuenow={headerCellWidth}\n // aria-valuetext is needed because the VO announces \"collapsed\" when only aria-valuenow set without aria-valuemax\n aria-valuetext={headerCellWidth.toFixed(0)}\n aria-valuemin={minWidth}\n data-focus-id={focusId}\n onBlur={() => {\n setResizerHasFocus(false);\n if (isKeyboardDragging) {\n setIsKeyboardDragging(false);\n }\n onWidthUpdateCommit();\n }}\n />\n </>\n );\n}\n\nexport function ResizeTracker() {\n return <span className={styles.tracker} />;\n}\n"]}
|
|
@@ -166,13 +166,12 @@ class GridNavigationProcessor {
|
|
|
166
166
|
}
|
|
167
167
|
init(table) {
|
|
168
168
|
this._table = table;
|
|
169
|
-
|
|
170
|
-
this.table.addEventListener('
|
|
171
|
-
this.table.addEventListener('
|
|
169
|
+
const controller = new AbortController();
|
|
170
|
+
this.table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });
|
|
171
|
+
this.table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });
|
|
172
|
+
this.table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });
|
|
172
173
|
this.cleanup = () => {
|
|
173
|
-
|
|
174
|
-
this.table.removeEventListener('focusout', this.onFocusout);
|
|
175
|
-
this.table.removeEventListener('keydown', this.onKeydown);
|
|
174
|
+
controller.abort();
|
|
176
175
|
};
|
|
177
176
|
}
|
|
178
177
|
cleanup() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-navigation.js","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAA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G,CAAC,OAAgB,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,cAAc,CAAC,OAAO,0CAAE,YAAY,CAAC,OAAO,CAAC,CAAA,EAAA,CAAC;QACrG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC;CACF","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport { useEffect, useMemo } from 'react';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../../internal/context/single-tab-stop-navigation-context';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport { FocusedCell, GridNavigationProps } from './interfaces';\nimport {\n defaultIsSuppressed,\n findTableRowByAriaRowIndex,\n findTableRowCellByAriaColIndex,\n focusNextElement,\n getClosestCell,\n isElementDisabled,\n isTableCell,\n} from './utils';\n\n/**\n * Makes table navigable with keyboard commands.\n * See grid-navigation.md\n */\nexport function GridNavigationProvider({ keyboardNavigation, pageSize, getTable, children }: GridNavigationProps) {\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const gridNavigation = useMemo(() => new GridNavigationProcessor(navigationAPI), []);\n\n const getTableStable = useStableCallback(getTable);\n\n // Initialize the processor with the table container assuming it is mounted synchronously and only once.\n useEffect(() => {\n if (keyboardNavigation) {\n const table = getTableStable();\n table && gridNavigation.init(table);\n }\n return () => gridNavigation.cleanup();\n }, [keyboardNavigation, gridNavigation, getTableStable]);\n\n // Notify the processor of the props change.\n useEffect(() => {\n gridNavigation.update({ pageSize });\n }, [gridNavigation, pageSize]);\n\n // Notify the processor of the new render.\n useEffect(() => {\n if (keyboardNavigation) {\n gridNavigation.refresh();\n }\n });\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={keyboardNavigation}\n getNextFocusTarget={gridNavigation.getNextFocusTarget}\n isElementSuppressed={gridNavigation.isElementSuppressed}\n onRegisterFocusable={gridNavigation.onRegisterFocusable}\n onUnregisterActive={gridNavigation.onUnregisterActive}\n >\n {children}\n </SingleTabStopNavigationProvider>\n );\n}\n\n/**\n * This helper encapsulates the grid navigation behaviors which are:\n * 1. Responding to keyboard commands and moving the focus accordingly;\n * 2. Muting table interactive elements for only one to be user-focusable at a time;\n * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.\n */\nclass GridNavigationProcessor {\n // Props\n private _pageSize = 0;\n private _table: null | HTMLTableElement = null;\n private _navigationAPI: { current: null | SingleTabStopNavigationAPI };\n\n // State\n private focusedCell: null | FocusedCell = null;\n private focusInside = false;\n private keepUserIndex = false;\n\n constructor(navigationAPI: { current: null | SingleTabStopNavigationAPI }) {\n this._navigationAPI = navigationAPI;\n }\n\n public init(table: HTMLTableElement) {\n this._table = table;\n\n this.table.addEventListener('focusin', this.onFocusin);\n this.table.addEventListener('focusout', this.onFocusout);\n this.table.addEventListener('keydown', this.onKeydown);\n\n this.cleanup = () => {\n this.table.removeEventListener('focusin', this.onFocusin);\n this.table.removeEventListener('focusout', this.onFocusout);\n this.table.removeEventListener('keydown', this.onKeydown);\n };\n }\n\n public cleanup() {\n // Do nothing before initialized.\n }\n\n public update({ pageSize }: { pageSize: number }) {\n this._pageSize = pageSize;\n }\n\n public refresh() {\n // Timeout ensures the newly rendered content elements are registered.\n setTimeout(() => {\n if (this._table) {\n // Update focused cell indices in case table rows, columns, or firstIndex change.\n this.updateFocusedCell(this.focusedCell?.element);\n this._navigationAPI.current?.updateFocusTarget();\n }\n }, 0);\n }\n\n public onRegisterFocusable = (focusableElement: HTMLElement) => {\n if (!this.focusInside) {\n return;\n }\n // When newly registered element belongs to the focused cell the focus must transition to it.\n const focusedElement = this.focusedCell?.element;\n if (focusedElement && isTableCell(focusedElement) && focusedElement.contains(focusableElement)) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n focusableElement.focus({ preventScroll: true });\n }\n };\n\n public onUnregisterActive = () => {\n // If the focused cell appears to be no longer attached to the table we need to re-apply\n // focus to a cell with the same or closest position.\n if (this.focusedCell && !nodeBelongs(this.table, this.focusedCell.element)) {\n this.moveFocusBy(this.focusedCell, { x: 0, y: 0 });\n }\n };\n\n public getNextFocusTarget = () => {\n const cell = this.focusedCell;\n const firstTableCell = this.table.querySelector('td,th') as null | HTMLTableCellElement;\n\n // A single element of the table is made user-focusable.\n // It defaults to the first interactive element of the first cell or the first cell itself otherwise.\n let focusTarget: null | HTMLElement =\n (firstTableCell && this.getFocusablesFrom(firstTableCell)[0]) ?? firstTableCell;\n\n // When a navigation-focused element is present in the table it is used for user-navigation instead.\n if (cell) {\n focusTarget = this.getNextFocusable(cell, { x: 0, y: 0 });\n }\n\n return focusTarget;\n };\n\n public isElementSuppressed = (element: null | Element) => {\n // Omit calculation as irrelevant until the table receives focus.\n if (!this.focusedCell) {\n return false;\n }\n return !element || defaultIsSuppressed(element);\n };\n\n private get pageSize() {\n return this._pageSize;\n }\n\n private get table(): HTMLTableElement {\n if (!this._table) {\n throw new Error('Invariant violation: GridNavigationProcessor is used before initialization.');\n }\n return this._table;\n }\n\n private onFocusin = (event: FocusEvent) => {\n this.focusInside = true;\n\n if (!(event.target instanceof HTMLElement)) {\n return;\n }\n\n this.updateFocusedCell(event.target);\n if (!this.focusedCell) {\n return;\n }\n\n this._navigationAPI.current?.updateFocusTarget();\n\n // Focusing on cell is not eligible when it contains focusable elements in the content.\n // If content focusables are available - move the focus to the first one.\n const focusedElement = this.focusedCell.element;\n const nextTarget = isTableCell(focusedElement) ? this.getFocusablesFrom(focusedElement)[0] : null;\n if (nextTarget) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n nextTarget.focus({ preventScroll: true });\n } else {\n this.keepUserIndex = false;\n }\n };\n\n private onFocusout = () => {\n this.focusInside = false;\n };\n\n private onKeydown = (event: KeyboardEvent) => {\n if (!this.focusedCell) {\n return;\n }\n\n const keys = [\n KeyCode.up,\n KeyCode.down,\n KeyCode.left,\n KeyCode.right,\n KeyCode.pageUp,\n KeyCode.pageDown,\n KeyCode.home,\n KeyCode.end,\n ];\n const ctrlKey = event.ctrlKey ? 1 : 0;\n const altKey = event.altKey ? 1 : 0;\n const shiftKey = event.shiftKey ? 1 : 0;\n const metaKey = event.metaKey ? 1 : 0;\n const modifiersPressed = ctrlKey + altKey + shiftKey + metaKey;\n const invalidModifierCombination =\n (modifiersPressed && !event.ctrlKey) ||\n (event.ctrlKey && event.keyCode !== KeyCode.home && event.keyCode !== KeyCode.end);\n\n if (\n invalidModifierCombination ||\n this.isElementSuppressed(document.activeElement) ||\n !this.isRegistered(document.activeElement) ||\n keys.indexOf(event.keyCode) === -1\n ) {\n return;\n }\n\n const from = this.focusedCell;\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onBlockStart: () => this.moveFocusBy(from, { y: -1, x: 0 }),\n onBlockEnd: () => this.moveFocusBy(from, { y: 1, x: 0 }),\n onInlineStart: () => this.moveFocusBy(from, { y: 0, x: -1 }),\n onInlineEnd: () => this.moveFocusBy(from, { y: 0, x: 1 }),\n onPageUp: () => this.moveFocusBy(from, { y: -this.pageSize, x: 0 }),\n onPageDown: () => this.moveFocusBy(from, { y: this.pageSize, x: 0 }),\n onHome: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: -Infinity, x: -Infinity })\n : this.moveFocusBy(from, { y: 0, x: -Infinity }),\n onEnd: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: Infinity, x: Infinity })\n : this.moveFocusBy(from, { y: 0, x: Infinity }),\n });\n };\n\n private moveFocusBy(cell: FocusedCell, delta: { x: number; y: number }) {\n // For vertical moves preserve column- and element indices set by user.\n // It allows keeping indices while moving over disabled actions or cells with colspan > 1.\n if (delta.y !== 0 && delta.x === 0) {\n this.keepUserIndex = true;\n }\n focusNextElement(this.getNextFocusable(cell, delta));\n }\n\n private isRegistered(element: null | Element): boolean {\n return !element || (this._navigationAPI.current?.isRegistered(element) ?? false);\n }\n\n private updateFocusedCell(focusedElement?: HTMLElement): void {\n if (!focusedElement) {\n return;\n }\n\n const cellElement = getClosestCell(focusedElement);\n const rowElement = cellElement?.closest('tr');\n if (!cellElement || !rowElement) {\n return;\n }\n\n const colIndex = parseInt(cellElement.getAttribute('aria-colindex') ?? '');\n const rowIndex = parseInt(rowElement.getAttribute('aria-rowindex') ?? '');\n if (isNaN(colIndex) || isNaN(rowIndex)) {\n return;\n }\n\n const cellFocusables = this.getFocusablesFrom(cellElement);\n const elementIndex = cellFocusables.indexOf(focusedElement);\n\n const prevColIndex = this.focusedCell?.colIndex ?? -1;\n const prevElementIndex = this.focusedCell?.elementIndex ?? -1;\n this.focusedCell = {\n rowIndex,\n colIndex: this.keepUserIndex && prevColIndex !== -1 ? prevColIndex : colIndex,\n elementIndex: this.keepUserIndex && prevElementIndex !== -1 ? prevElementIndex : elementIndex,\n element: focusedElement,\n };\n }\n\n private getNextFocusable(from: FocusedCell, delta: { y: number; x: number }) {\n // Find next row to move focus into (can be null if the top/bottom is reached).\n const targetAriaRowIndex = from.rowIndex + delta.y;\n const targetRow = findTableRowByAriaRowIndex(this.table, targetAriaRowIndex, delta.y);\n if (!targetRow) {\n return null;\n }\n\n // Return next interactive cell content element if available.\n const cellElement = getClosestCell(from.element);\n const cellFocusables = cellElement ? this.getFocusablesFrom(cellElement) : [];\n const nextElementIndex = from.elementIndex + delta.x;\n const isValidDirection = !!delta.x;\n const isValidIndex = from.elementIndex !== -1 && 0 <= nextElementIndex && nextElementIndex < cellFocusables.length;\n const isTargetDifferent = from.element !== cellFocusables[nextElementIndex];\n if (isValidDirection && isValidIndex && isTargetDifferent) {\n return cellFocusables[nextElementIndex];\n }\n\n // Find next cell to focus or move focus into (can be null if the left/right edge is reached).\n const targetAriaColIndex = from.colIndex + delta.x;\n const targetCell = findTableRowCellByAriaColIndex(targetRow, targetAriaColIndex, delta.x);\n if (!targetCell) {\n return null;\n }\n\n // When target cell matches the current cell it means we reached the left or right boundary.\n if (targetCell === cellElement && delta.x !== 0) {\n return null;\n }\n\n const targetCellFocusables = this.getFocusablesFrom(targetCell);\n\n // When delta.x = 0 keep element index if possible.\n let focusIndex = from.elementIndex;\n // Use first element index when moving to the right or to extreme left.\n if ((isFinite(delta.x) && delta.x > 0) || delta.x === -Infinity) {\n focusIndex = 0;\n }\n // Use last element index when moving to the left or to extreme right.\n if ((isFinite(delta.x) && delta.x < 0) || delta.x === Infinity) {\n focusIndex = targetCellFocusables.length - 1;\n }\n\n return targetCellFocusables[focusIndex] ?? targetCell;\n }\n\n private getFocusablesFrom(target: HTMLElement) {\n const isElementRegistered = (element: Element) => this._navigationAPI.current?.isRegistered(element);\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid-navigation.js","sourceRoot":"","sources":["../../../../src/table/table-role/grid-navigation.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAEL,+BAA+B,GAChC,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAA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liates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useRef } from 'react';\nimport { useEffect, useMemo } from 'react';\n\nimport { useStableCallback } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getAllFocusables } from '../../internal/components/focus-lock/utils';\nimport {\n SingleTabStopNavigationAPI,\n SingleTabStopNavigationProvider,\n} from '../../internal/context/single-tab-stop-navigation-context';\nimport { KeyCode } from '../../internal/keycode';\nimport handleKey, { isEventLike } from '../../internal/utils/handle-key';\nimport { nodeBelongs } from '../../internal/utils/node-belongs';\nimport { FocusedCell, GridNavigationProps } from './interfaces';\nimport {\n defaultIsSuppressed,\n findTableRowByAriaRowIndex,\n findTableRowCellByAriaColIndex,\n focusNextElement,\n getClosestCell,\n isElementDisabled,\n isTableCell,\n} from './utils';\n\n/**\n * Makes table navigable with keyboard commands.\n * See grid-navigation.md\n */\nexport function GridNavigationProvider({ keyboardNavigation, pageSize, getTable, children }: GridNavigationProps) {\n const navigationAPI = useRef<SingleTabStopNavigationAPI>(null);\n const gridNavigation = useMemo(() => new GridNavigationProcessor(navigationAPI), []);\n\n const getTableStable = useStableCallback(getTable);\n\n // Initialize the processor with the table container assuming it is mounted synchronously and only once.\n useEffect(() => {\n if (keyboardNavigation) {\n const table = getTableStable();\n table && gridNavigation.init(table);\n }\n return () => gridNavigation.cleanup();\n }, [keyboardNavigation, gridNavigation, getTableStable]);\n\n // Notify the processor of the props change.\n useEffect(() => {\n gridNavigation.update({ pageSize });\n }, [gridNavigation, pageSize]);\n\n // Notify the processor of the new render.\n useEffect(() => {\n if (keyboardNavigation) {\n gridNavigation.refresh();\n }\n });\n\n return (\n <SingleTabStopNavigationProvider\n ref={navigationAPI}\n navigationActive={keyboardNavigation}\n getNextFocusTarget={gridNavigation.getNextFocusTarget}\n isElementSuppressed={gridNavigation.isElementSuppressed}\n onRegisterFocusable={gridNavigation.onRegisterFocusable}\n onUnregisterActive={gridNavigation.onUnregisterActive}\n >\n {children}\n </SingleTabStopNavigationProvider>\n );\n}\n\n/**\n * This helper encapsulates the grid navigation behaviors which are:\n * 1. Responding to keyboard commands and moving the focus accordingly;\n * 2. Muting table interactive elements for only one to be user-focusable at a time;\n * 3. Suppressing the above behaviors when focusing an element inside a dialog or when instructed explicitly.\n */\nclass GridNavigationProcessor {\n // Props\n private _pageSize = 0;\n private _table: null | HTMLTableElement = null;\n private _navigationAPI: { current: null | SingleTabStopNavigationAPI };\n\n // State\n private focusedCell: null | FocusedCell = null;\n private focusInside = false;\n private keepUserIndex = false;\n\n constructor(navigationAPI: { current: null | SingleTabStopNavigationAPI }) {\n this._navigationAPI = navigationAPI;\n }\n\n public init(table: HTMLTableElement) {\n this._table = table;\n const controller = new AbortController();\n\n this.table.addEventListener('focusin', this.onFocusin, { signal: controller.signal });\n this.table.addEventListener('focusout', this.onFocusout, { signal: controller.signal });\n this.table.addEventListener('keydown', this.onKeydown, { signal: controller.signal });\n\n this.cleanup = () => {\n controller.abort();\n };\n }\n\n public cleanup() {\n // Do nothing before initialized.\n }\n\n public update({ pageSize }: { pageSize: number }) {\n this._pageSize = pageSize;\n }\n\n public refresh() {\n // Timeout ensures the newly rendered content elements are registered.\n setTimeout(() => {\n if (this._table) {\n // Update focused cell indices in case table rows, columns, or firstIndex change.\n this.updateFocusedCell(this.focusedCell?.element);\n this._navigationAPI.current?.updateFocusTarget();\n }\n }, 0);\n }\n\n public onRegisterFocusable = (focusableElement: HTMLElement) => {\n if (!this.focusInside) {\n return;\n }\n // When newly registered element belongs to the focused cell the focus must transition to it.\n const focusedElement = this.focusedCell?.element;\n if (focusedElement && isTableCell(focusedElement) && focusedElement.contains(focusableElement)) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n focusableElement.focus({ preventScroll: true });\n }\n };\n\n public onUnregisterActive = () => {\n // If the focused cell appears to be no longer attached to the table we need to re-apply\n // focus to a cell with the same or closest position.\n if (this.focusedCell && !nodeBelongs(this.table, this.focusedCell.element)) {\n this.moveFocusBy(this.focusedCell, { x: 0, y: 0 });\n }\n };\n\n public getNextFocusTarget = () => {\n const cell = this.focusedCell;\n const firstTableCell = this.table.querySelector('td,th') as null | HTMLTableCellElement;\n\n // A single element of the table is made user-focusable.\n // It defaults to the first interactive element of the first cell or the first cell itself otherwise.\n let focusTarget: null | HTMLElement =\n (firstTableCell && this.getFocusablesFrom(firstTableCell)[0]) ?? firstTableCell;\n\n // When a navigation-focused element is present in the table it is used for user-navigation instead.\n if (cell) {\n focusTarget = this.getNextFocusable(cell, { x: 0, y: 0 });\n }\n\n return focusTarget;\n };\n\n public isElementSuppressed = (element: null | Element) => {\n // Omit calculation as irrelevant until the table receives focus.\n if (!this.focusedCell) {\n return false;\n }\n return !element || defaultIsSuppressed(element);\n };\n\n private get pageSize() {\n return this._pageSize;\n }\n\n private get table(): HTMLTableElement {\n if (!this._table) {\n throw new Error('Invariant violation: GridNavigationProcessor is used before initialization.');\n }\n return this._table;\n }\n\n private onFocusin = (event: FocusEvent) => {\n this.focusInside = true;\n\n if (!(event.target instanceof HTMLElement)) {\n return;\n }\n\n this.updateFocusedCell(event.target);\n if (!this.focusedCell) {\n return;\n }\n\n this._navigationAPI.current?.updateFocusTarget();\n\n // Focusing on cell is not eligible when it contains focusable elements in the content.\n // If content focusables are available - move the focus to the first one.\n const focusedElement = this.focusedCell.element;\n const nextTarget = isTableCell(focusedElement) ? this.getFocusablesFrom(focusedElement)[0] : null;\n if (nextTarget) {\n // Scroll is unnecessary when moving focus from a cell to element within the cell.\n nextTarget.focus({ preventScroll: true });\n } else {\n this.keepUserIndex = false;\n }\n };\n\n private onFocusout = () => {\n this.focusInside = false;\n };\n\n private onKeydown = (event: KeyboardEvent) => {\n if (!this.focusedCell) {\n return;\n }\n\n const keys = [\n KeyCode.up,\n KeyCode.down,\n KeyCode.left,\n KeyCode.right,\n KeyCode.pageUp,\n KeyCode.pageDown,\n KeyCode.home,\n KeyCode.end,\n ];\n const ctrlKey = event.ctrlKey ? 1 : 0;\n const altKey = event.altKey ? 1 : 0;\n const shiftKey = event.shiftKey ? 1 : 0;\n const metaKey = event.metaKey ? 1 : 0;\n const modifiersPressed = ctrlKey + altKey + shiftKey + metaKey;\n const invalidModifierCombination =\n (modifiersPressed && !event.ctrlKey) ||\n (event.ctrlKey && event.keyCode !== KeyCode.home && event.keyCode !== KeyCode.end);\n\n if (\n invalidModifierCombination ||\n this.isElementSuppressed(document.activeElement) ||\n !this.isRegistered(document.activeElement) ||\n keys.indexOf(event.keyCode) === -1\n ) {\n return;\n }\n\n const from = this.focusedCell;\n event.preventDefault();\n\n isEventLike(event) &&\n handleKey(event, {\n onBlockStart: () => this.moveFocusBy(from, { y: -1, x: 0 }),\n onBlockEnd: () => this.moveFocusBy(from, { y: 1, x: 0 }),\n onInlineStart: () => this.moveFocusBy(from, { y: 0, x: -1 }),\n onInlineEnd: () => this.moveFocusBy(from, { y: 0, x: 1 }),\n onPageUp: () => this.moveFocusBy(from, { y: -this.pageSize, x: 0 }),\n onPageDown: () => this.moveFocusBy(from, { y: this.pageSize, x: 0 }),\n onHome: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: -Infinity, x: -Infinity })\n : this.moveFocusBy(from, { y: 0, x: -Infinity }),\n onEnd: () =>\n event.ctrlKey\n ? this.moveFocusBy(from, { y: Infinity, x: Infinity })\n : this.moveFocusBy(from, { y: 0, x: Infinity }),\n });\n };\n\n private moveFocusBy(cell: FocusedCell, delta: { x: number; y: number }) {\n // For vertical moves preserve column- and element indices set by user.\n // It allows keeping indices while moving over disabled actions or cells with colspan > 1.\n if (delta.y !== 0 && delta.x === 0) {\n this.keepUserIndex = true;\n }\n focusNextElement(this.getNextFocusable(cell, delta));\n }\n\n private isRegistered(element: null | Element): boolean {\n return !element || (this._navigationAPI.current?.isRegistered(element) ?? false);\n }\n\n private updateFocusedCell(focusedElement?: HTMLElement): void {\n if (!focusedElement) {\n return;\n }\n\n const cellElement = getClosestCell(focusedElement);\n const rowElement = cellElement?.closest('tr');\n if (!cellElement || !rowElement) {\n return;\n }\n\n const colIndex = parseInt(cellElement.getAttribute('aria-colindex') ?? '');\n const rowIndex = parseInt(rowElement.getAttribute('aria-rowindex') ?? '');\n if (isNaN(colIndex) || isNaN(rowIndex)) {\n return;\n }\n\n const cellFocusables = this.getFocusablesFrom(cellElement);\n const elementIndex = cellFocusables.indexOf(focusedElement);\n\n const prevColIndex = this.focusedCell?.colIndex ?? -1;\n const prevElementIndex = this.focusedCell?.elementIndex ?? -1;\n this.focusedCell = {\n rowIndex,\n colIndex: this.keepUserIndex && prevColIndex !== -1 ? prevColIndex : colIndex,\n elementIndex: this.keepUserIndex && prevElementIndex !== -1 ? prevElementIndex : elementIndex,\n element: focusedElement,\n };\n }\n\n private getNextFocusable(from: FocusedCell, delta: { y: number; x: number }) {\n // Find next row to move focus into (can be null if the top/bottom is reached).\n const targetAriaRowIndex = from.rowIndex + delta.y;\n const targetRow = findTableRowByAriaRowIndex(this.table, targetAriaRowIndex, delta.y);\n if (!targetRow) {\n return null;\n }\n\n // Return next interactive cell content element if available.\n const cellElement = getClosestCell(from.element);\n const cellFocusables = cellElement ? this.getFocusablesFrom(cellElement) : [];\n const nextElementIndex = from.elementIndex + delta.x;\n const isValidDirection = !!delta.x;\n const isValidIndex = from.elementIndex !== -1 && 0 <= nextElementIndex && nextElementIndex < cellFocusables.length;\n const isTargetDifferent = from.element !== cellFocusables[nextElementIndex];\n if (isValidDirection && isValidIndex && isTargetDifferent) {\n return cellFocusables[nextElementIndex];\n }\n\n // Find next cell to focus or move focus into (can be null if the left/right edge is reached).\n const targetAriaColIndex = from.colIndex + delta.x;\n const targetCell = findTableRowCellByAriaColIndex(targetRow, targetAriaColIndex, delta.x);\n if (!targetCell) {\n return null;\n }\n\n // When target cell matches the current cell it means we reached the left or right boundary.\n if (targetCell === cellElement && delta.x !== 0) {\n return null;\n }\n\n const targetCellFocusables = this.getFocusablesFrom(targetCell);\n\n // When delta.x = 0 keep element index if possible.\n let focusIndex = from.elementIndex;\n // Use first element index when moving to the right or to extreme left.\n if ((isFinite(delta.x) && delta.x > 0) || delta.x === -Infinity) {\n focusIndex = 0;\n }\n // Use last element index when moving to the left or to extreme right.\n if ((isFinite(delta.x) && delta.x < 0) || delta.x === Infinity) {\n focusIndex = targetCellFocusables.length - 1;\n }\n\n return targetCellFocusables[focusIndex] ?? targetCell;\n }\n\n private getFocusablesFrom(target: HTMLElement) {\n const isElementRegistered = (element: Element) => this._navigationAPI.current?.isRegistered(element);\n return getAllFocusables(target).filter(el => isElementRegistered(el) && !isElementDisabled(el));\n }\n}\n"]}
|
|
@@ -13,6 +13,7 @@ export declare class AttributeEditorRowWrapper extends ElementWrapper {
|
|
|
13
13
|
*/
|
|
14
14
|
findField(column: number): FormFieldWrapper | null;
|
|
15
15
|
findRemoveButton(): ButtonWrapper | null;
|
|
16
|
+
findCustomAction(): ElementWrapper | null;
|
|
16
17
|
}
|
|
17
18
|
export default class AttributeEditorWrapper extends ComponentWrapper {
|
|
18
19
|
static rootSelector: string;
|
|
@@ -7,7 +7,6 @@ const dom_1 = require("@cloudscape-design/test-utils-core/dom");
|
|
|
7
7
|
const button_1 = require("../button");
|
|
8
8
|
const form_field_1 = require("../form-field");
|
|
9
9
|
const styles_selectors_js_1 = require("../../../attribute-editor/styles.selectors.js");
|
|
10
|
-
const styles_selectors_js_2 = require("../../../grid/styles.selectors.js");
|
|
11
10
|
class AttributeEditorRowWrapper extends dom_1.ElementWrapper {
|
|
12
11
|
/**
|
|
13
12
|
* Returns all fields. Fields are supplied in the `definition` property of the component.
|
|
@@ -21,11 +20,14 @@ class AttributeEditorRowWrapper extends dom_1.ElementWrapper {
|
|
|
21
20
|
* @param column 1-based column index
|
|
22
21
|
*/
|
|
23
22
|
findField(column) {
|
|
24
|
-
return this.findComponent(`.${styles_selectors_js_1.default
|
|
23
|
+
return this.findComponent(`.${styles_selectors_js_1.default.field}:nth-child(${column})`, form_field_1.default);
|
|
25
24
|
}
|
|
26
25
|
findRemoveButton() {
|
|
27
26
|
return this.findComponent(`.${styles_selectors_js_1.default['remove-button']}`, button_1.default);
|
|
28
27
|
}
|
|
28
|
+
findCustomAction() {
|
|
29
|
+
return this.findComponent(`.${styles_selectors_js_1.default['remove-button-container']}`, dom_1.ElementWrapper);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
exports.AttributeEditorRowWrapper = AttributeEditorRowWrapper;
|
|
31
33
|
class AttributeEditorWrapper extends dom_1.ComponentWrapper {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/attribute-editor/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,sCAAsC;AACtC,8CAA6C;AAE7C,uFAAmE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/test-utils/dom/attribute-editor/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,gEAA0F;AAE1F,sCAAsC;AACtC,8CAA6C;AAE7C,uFAAmE;AAEnE,MAAa,yBAA0B,SAAQ,oBAAc;IAC3D;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,kBAAkB,CAAC,6BAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,oBAAgB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAc;QACtB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,6BAAM,CAAC,KAAK,cAAc,MAAM,GAAG,EAAE,oBAAgB,CAAC,CAAC;IACvF,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,6BAAM,CAAC,eAAe,CAAC,EAAE,EAAE,gBAAa,CAAC,CAAC;IAC1E,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,6BAAM,CAAC,yBAAyB,CAAC,EAAE,EAAE,oBAAc,CAAC,CAAC;IACrF,CAAC;CACF;AAxBD,8DAwBC;AAED,MAAqB,sBAAuB,SAAQ,sBAAgB;IAGlE,aAAa;QACX,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,GAAW;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,6BAAM,CAAC,GAAG,cAAc,GAAG,GAAG,EAAE,yBAAyB,CAAC,CAAC;IAC3F,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,kBAAkB,CAAC,6BAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,yBAAyB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACrG,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,6BAAM,CAAC,YAAY,CAAC,EAAE,EAAE,gBAAa,CAAE,CAAC;IACxE,CAAC;IAED,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC,6BAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACzD,CAAC;;AAhCH,yCAiCC;AAhCQ,mCAAY,GAAW,6BAAM,CAAC,IAAI,CAAC"}
|
|
@@ -1,162 +1,162 @@
|
|
|
1
1
|
import { ElementWrapper } from '@cloudscape-design/test-utils-core/dom';
|
|
2
2
|
export { ElementWrapper };
|
|
3
3
|
import AlertWrapper from './alert';
|
|
4
|
-
export { AlertWrapper };
|
|
5
4
|
import AnchorNavigationWrapper from './anchor-navigation';
|
|
6
|
-
export { AnchorNavigationWrapper };
|
|
7
5
|
import AnnotationWrapper from './annotation';
|
|
8
|
-
export { AnnotationWrapper };
|
|
9
6
|
import AppLayoutWrapper from './app-layout';
|
|
10
|
-
export { AppLayoutWrapper };
|
|
11
7
|
import AreaChartWrapper from './area-chart';
|
|
12
|
-
export { AreaChartWrapper };
|
|
13
8
|
import AttributeEditorWrapper from './attribute-editor';
|
|
14
|
-
export { AttributeEditorWrapper };
|
|
15
9
|
import AutosuggestWrapper from './autosuggest';
|
|
16
|
-
export { AutosuggestWrapper };
|
|
17
10
|
import BadgeWrapper from './badge';
|
|
18
|
-
export { BadgeWrapper };
|
|
19
11
|
import BarChartWrapper from './bar-chart';
|
|
20
|
-
export { BarChartWrapper };
|
|
21
12
|
import BoxWrapper from './box';
|
|
22
|
-
export { BoxWrapper };
|
|
23
13
|
import BreadcrumbGroupWrapper from './breadcrumb-group';
|
|
24
|
-
export { BreadcrumbGroupWrapper };
|
|
25
14
|
import ButtonWrapper from './button';
|
|
26
|
-
export { ButtonWrapper };
|
|
27
15
|
import ButtonDropdownWrapper from './button-dropdown';
|
|
28
|
-
export { ButtonDropdownWrapper };
|
|
29
16
|
import ButtonGroupWrapper from './button-group';
|
|
30
|
-
export { ButtonGroupWrapper };
|
|
31
17
|
import CalendarWrapper from './calendar';
|
|
32
|
-
export { CalendarWrapper };
|
|
33
18
|
import CardsWrapper from './cards';
|
|
34
|
-
export { CardsWrapper };
|
|
35
19
|
import CheckboxWrapper from './checkbox';
|
|
36
|
-
export { CheckboxWrapper };
|
|
37
20
|
import CodeEditorWrapper from './code-editor';
|
|
38
|
-
export { CodeEditorWrapper };
|
|
39
21
|
import CollectionPreferencesWrapper from './collection-preferences';
|
|
40
|
-
export { CollectionPreferencesWrapper };
|
|
41
22
|
import ColumnLayoutWrapper from './column-layout';
|
|
42
|
-
export { ColumnLayoutWrapper };
|
|
43
23
|
import ContainerWrapper from './container';
|
|
44
|
-
export { ContainerWrapper };
|
|
45
24
|
import ContentLayoutWrapper from './content-layout';
|
|
46
|
-
export { ContentLayoutWrapper };
|
|
47
25
|
import CopyToClipboardWrapper from './copy-to-clipboard';
|
|
48
|
-
export { CopyToClipboardWrapper };
|
|
49
26
|
import DateInputWrapper from './date-input';
|
|
50
|
-
export { DateInputWrapper };
|
|
51
27
|
import DatePickerWrapper from './date-picker';
|
|
52
|
-
export { DatePickerWrapper };
|
|
53
28
|
import DateRangePickerWrapper from './date-range-picker';
|
|
54
|
-
export { DateRangePickerWrapper };
|
|
55
29
|
import DrawerWrapper from './drawer';
|
|
56
|
-
export { DrawerWrapper };
|
|
57
30
|
import ExpandableSectionWrapper from './expandable-section';
|
|
58
|
-
export { ExpandableSectionWrapper };
|
|
59
31
|
import FileDropzoneWrapper from './file-dropzone';
|
|
60
|
-
export { FileDropzoneWrapper };
|
|
61
32
|
import FileInputWrapper from './file-input';
|
|
62
|
-
export { FileInputWrapper };
|
|
63
33
|
import FileTokenGroupWrapper from './file-token-group';
|
|
64
|
-
export { FileTokenGroupWrapper };
|
|
65
34
|
import FileUploadWrapper from './file-upload';
|
|
66
|
-
export { FileUploadWrapper };
|
|
67
35
|
import FlashbarWrapper from './flashbar';
|
|
68
|
-
export { FlashbarWrapper };
|
|
69
36
|
import FormWrapper from './form';
|
|
70
|
-
export { FormWrapper };
|
|
71
37
|
import FormFieldWrapper from './form-field';
|
|
72
|
-
export { FormFieldWrapper };
|
|
73
38
|
import GridWrapper from './grid';
|
|
74
|
-
export { GridWrapper };
|
|
75
39
|
import HeaderWrapper from './header';
|
|
76
|
-
export { HeaderWrapper };
|
|
77
40
|
import HelpPanelWrapper from './help-panel';
|
|
78
|
-
export { HelpPanelWrapper };
|
|
79
41
|
import HotspotWrapper from './hotspot';
|
|
80
|
-
export { HotspotWrapper };
|
|
81
42
|
import IconWrapper from './icon';
|
|
82
|
-
export { IconWrapper };
|
|
83
43
|
import InputWrapper from './input';
|
|
84
|
-
export { InputWrapper };
|
|
85
44
|
import KeyValuePairsWrapper from './key-value-pairs';
|
|
86
|
-
export { KeyValuePairsWrapper };
|
|
87
45
|
import LineChartWrapper from './line-chart';
|
|
88
|
-
export { LineChartWrapper };
|
|
89
46
|
import LinkWrapper from './link';
|
|
90
|
-
export { LinkWrapper };
|
|
91
47
|
import LiveRegionWrapper from './live-region';
|
|
92
|
-
export { LiveRegionWrapper };
|
|
93
48
|
import MixedLineBarChartWrapper from './mixed-line-bar-chart';
|
|
94
|
-
export { MixedLineBarChartWrapper };
|
|
95
49
|
import ModalWrapper from './modal';
|
|
96
|
-
export { ModalWrapper };
|
|
97
50
|
import MultiselectWrapper from './multiselect';
|
|
98
|
-
export { MultiselectWrapper };
|
|
99
51
|
import PaginationWrapper from './pagination';
|
|
100
|
-
export { PaginationWrapper };
|
|
101
52
|
import PieChartWrapper from './pie-chart';
|
|
102
|
-
export { PieChartWrapper };
|
|
103
53
|
import PopoverWrapper from './popover';
|
|
104
|
-
export { PopoverWrapper };
|
|
105
54
|
import ProgressBarWrapper from './progress-bar';
|
|
106
|
-
export { ProgressBarWrapper };
|
|
107
55
|
import PromptInputWrapper from './prompt-input';
|
|
108
|
-
export { PromptInputWrapper };
|
|
109
56
|
import PropertyFilterWrapper from './property-filter';
|
|
110
|
-
export { PropertyFilterWrapper };
|
|
111
57
|
import RadioGroupWrapper from './radio-group';
|
|
112
|
-
export { RadioGroupWrapper };
|
|
113
58
|
import S3ResourceSelectorWrapper from './s3-resource-selector';
|
|
114
|
-
export { S3ResourceSelectorWrapper };
|
|
115
59
|
import SegmentedControlWrapper from './segmented-control';
|
|
116
|
-
export { SegmentedControlWrapper };
|
|
117
60
|
import SelectWrapper from './select';
|
|
118
|
-
export { SelectWrapper };
|
|
119
61
|
import SideNavigationWrapper from './side-navigation';
|
|
120
|
-
export { SideNavigationWrapper };
|
|
121
62
|
import SliderWrapper from './slider';
|
|
122
|
-
export { SliderWrapper };
|
|
123
63
|
import SpaceBetweenWrapper from './space-between';
|
|
124
|
-
export { SpaceBetweenWrapper };
|
|
125
64
|
import SpinnerWrapper from './spinner';
|
|
126
|
-
export { SpinnerWrapper };
|
|
127
65
|
import SplitPanelWrapper from './split-panel';
|
|
128
|
-
export { SplitPanelWrapper };
|
|
129
66
|
import StatusIndicatorWrapper from './status-indicator';
|
|
130
|
-
export { StatusIndicatorWrapper };
|
|
131
67
|
import StepsWrapper from './steps';
|
|
132
|
-
export { StepsWrapper };
|
|
133
68
|
import TableWrapper from './table';
|
|
134
|
-
export { TableWrapper };
|
|
135
69
|
import TabsWrapper from './tabs';
|
|
136
|
-
export { TabsWrapper };
|
|
137
70
|
import TagEditorWrapper from './tag-editor';
|
|
138
|
-
export { TagEditorWrapper };
|
|
139
71
|
import TextContentWrapper from './text-content';
|
|
140
|
-
export { TextContentWrapper };
|
|
141
72
|
import TextFilterWrapper from './text-filter';
|
|
142
|
-
export { TextFilterWrapper };
|
|
143
73
|
import TextareaWrapper from './textarea';
|
|
144
|
-
export { TextareaWrapper };
|
|
145
74
|
import TilesWrapper from './tiles';
|
|
146
|
-
export { TilesWrapper };
|
|
147
75
|
import TimeInputWrapper from './time-input';
|
|
148
|
-
export { TimeInputWrapper };
|
|
149
76
|
import ToggleWrapper from './toggle';
|
|
150
|
-
export { ToggleWrapper };
|
|
151
77
|
import ToggleButtonWrapper from './toggle-button';
|
|
152
|
-
export { ToggleButtonWrapper };
|
|
153
78
|
import TokenGroupWrapper from './token-group';
|
|
154
|
-
export { TokenGroupWrapper };
|
|
155
79
|
import TopNavigationWrapper from './top-navigation';
|
|
156
|
-
export { TopNavigationWrapper };
|
|
157
80
|
import TutorialPanelWrapper from './tutorial-panel';
|
|
158
|
-
export { TutorialPanelWrapper };
|
|
159
81
|
import WizardWrapper from './wizard';
|
|
82
|
+
export { AlertWrapper };
|
|
83
|
+
export { AnchorNavigationWrapper };
|
|
84
|
+
export { AnnotationWrapper };
|
|
85
|
+
export { AppLayoutWrapper };
|
|
86
|
+
export { AreaChartWrapper };
|
|
87
|
+
export { AttributeEditorWrapper };
|
|
88
|
+
export { AutosuggestWrapper };
|
|
89
|
+
export { BadgeWrapper };
|
|
90
|
+
export { BarChartWrapper };
|
|
91
|
+
export { BoxWrapper };
|
|
92
|
+
export { BreadcrumbGroupWrapper };
|
|
93
|
+
export { ButtonWrapper };
|
|
94
|
+
export { ButtonDropdownWrapper };
|
|
95
|
+
export { ButtonGroupWrapper };
|
|
96
|
+
export { CalendarWrapper };
|
|
97
|
+
export { CardsWrapper };
|
|
98
|
+
export { CheckboxWrapper };
|
|
99
|
+
export { CodeEditorWrapper };
|
|
100
|
+
export { CollectionPreferencesWrapper };
|
|
101
|
+
export { ColumnLayoutWrapper };
|
|
102
|
+
export { ContainerWrapper };
|
|
103
|
+
export { ContentLayoutWrapper };
|
|
104
|
+
export { CopyToClipboardWrapper };
|
|
105
|
+
export { DateInputWrapper };
|
|
106
|
+
export { DatePickerWrapper };
|
|
107
|
+
export { DateRangePickerWrapper };
|
|
108
|
+
export { DrawerWrapper };
|
|
109
|
+
export { ExpandableSectionWrapper };
|
|
110
|
+
export { FileDropzoneWrapper };
|
|
111
|
+
export { FileInputWrapper };
|
|
112
|
+
export { FileTokenGroupWrapper };
|
|
113
|
+
export { FileUploadWrapper };
|
|
114
|
+
export { FlashbarWrapper };
|
|
115
|
+
export { FormWrapper };
|
|
116
|
+
export { FormFieldWrapper };
|
|
117
|
+
export { GridWrapper };
|
|
118
|
+
export { HeaderWrapper };
|
|
119
|
+
export { HelpPanelWrapper };
|
|
120
|
+
export { HotspotWrapper };
|
|
121
|
+
export { IconWrapper };
|
|
122
|
+
export { InputWrapper };
|
|
123
|
+
export { KeyValuePairsWrapper };
|
|
124
|
+
export { LineChartWrapper };
|
|
125
|
+
export { LinkWrapper };
|
|
126
|
+
export { LiveRegionWrapper };
|
|
127
|
+
export { MixedLineBarChartWrapper };
|
|
128
|
+
export { ModalWrapper };
|
|
129
|
+
export { MultiselectWrapper };
|
|
130
|
+
export { PaginationWrapper };
|
|
131
|
+
export { PieChartWrapper };
|
|
132
|
+
export { PopoverWrapper };
|
|
133
|
+
export { ProgressBarWrapper };
|
|
134
|
+
export { PromptInputWrapper };
|
|
135
|
+
export { PropertyFilterWrapper };
|
|
136
|
+
export { RadioGroupWrapper };
|
|
137
|
+
export { S3ResourceSelectorWrapper };
|
|
138
|
+
export { SegmentedControlWrapper };
|
|
139
|
+
export { SelectWrapper };
|
|
140
|
+
export { SideNavigationWrapper };
|
|
141
|
+
export { SliderWrapper };
|
|
142
|
+
export { SpaceBetweenWrapper };
|
|
143
|
+
export { SpinnerWrapper };
|
|
144
|
+
export { SplitPanelWrapper };
|
|
145
|
+
export { StatusIndicatorWrapper };
|
|
146
|
+
export { StepsWrapper };
|
|
147
|
+
export { TableWrapper };
|
|
148
|
+
export { TabsWrapper };
|
|
149
|
+
export { TagEditorWrapper };
|
|
150
|
+
export { TextContentWrapper };
|
|
151
|
+
export { TextFilterWrapper };
|
|
152
|
+
export { TextareaWrapper };
|
|
153
|
+
export { TilesWrapper };
|
|
154
|
+
export { TimeInputWrapper };
|
|
155
|
+
export { ToggleWrapper };
|
|
156
|
+
export { ToggleButtonWrapper };
|
|
157
|
+
export { TokenGroupWrapper };
|
|
158
|
+
export { TopNavigationWrapper };
|
|
159
|
+
export { TutorialPanelWrapper };
|
|
160
160
|
export { WizardWrapper };
|
|
161
161
|
declare module '@cloudscape-design/test-utils-core/dist/dom' {
|
|
162
162
|
interface ElementWrapper {
|
package/test-utils/dom/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PaginationWrapper = exports.MultiselectWrapper = exports.ModalWrapper = exports.MixedLineBarChartWrapper = exports.LiveRegionWrapper = exports.LinkWrapper = exports.LineChartWrapper = exports.KeyValuePairsWrapper = exports.InputWrapper = exports.IconWrapper = exports.HotspotWrapper = exports.HelpPanelWrapper = exports.HeaderWrapper = exports.GridWrapper = exports.FormFieldWrapper = exports.FormWrapper = exports.FlashbarWrapper = exports.FileUploadWrapper = exports.FileTokenGroupWrapper = exports.FileInputWrapper = exports.FileDropzoneWrapper = exports.ExpandableSectionWrapper = exports.DrawerWrapper = exports.DateRangePickerWrapper = exports.DatePickerWrapper = exports.DateInputWrapper = exports.CopyToClipboardWrapper = exports.ContentLayoutWrapper = exports.ContainerWrapper = exports.ColumnLayoutWrapper = exports.CollectionPreferencesWrapper = exports.CodeEditorWrapper = exports.CheckboxWrapper = exports.CardsWrapper = exports.CalendarWrapper = exports.ButtonGroupWrapper = exports.ButtonDropdownWrapper = exports.ButtonWrapper = exports.BreadcrumbGroupWrapper = exports.BoxWrapper = exports.BarChartWrapper = exports.BadgeWrapper = exports.AutosuggestWrapper = exports.AttributeEditorWrapper = exports.AreaChartWrapper = exports.AppLayoutWrapper = exports.AnnotationWrapper = exports.AnchorNavigationWrapper = exports.AlertWrapper = exports.ElementWrapper = void 0;
|
|
4
4
|
exports.WizardWrapper = exports.TutorialPanelWrapper = exports.TopNavigationWrapper = exports.TokenGroupWrapper = exports.ToggleButtonWrapper = exports.ToggleWrapper = exports.TimeInputWrapper = exports.TilesWrapper = exports.TextareaWrapper = exports.TextFilterWrapper = exports.TextContentWrapper = exports.TagEditorWrapper = exports.TabsWrapper = exports.TableWrapper = exports.StepsWrapper = exports.StatusIndicatorWrapper = exports.SplitPanelWrapper = exports.SpinnerWrapper = exports.SpaceBetweenWrapper = exports.SliderWrapper = exports.SideNavigationWrapper = exports.SelectWrapper = exports.SegmentedControlWrapper = exports.S3ResourceSelectorWrapper = exports.RadioGroupWrapper = exports.PropertyFilterWrapper = exports.PromptInputWrapper = exports.ProgressBarWrapper = exports.PopoverWrapper = exports.PieChartWrapper = void 0;
|
|
5
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
7
|
const dom_1 = require("@cloudscape-design/test-utils-core/dom");
|
|
6
8
|
Object.defineProperty(exports, "ElementWrapper", { enumerable: true, get: function () { return dom_1.ElementWrapper; } });
|
|
7
9
|
const utils_1 = require("@cloudscape-design/test-utils-core/utils");
|
|
@@ -874,8 +876,12 @@ dom_1.ElementWrapper.prototype.findWizard = function (selector) {
|
|
|
874
876
|
dom_1.ElementWrapper.prototype.findAllWizards = function (selector) {
|
|
875
877
|
return this.findAllComponents(wizard_1.default, selector);
|
|
876
878
|
};
|
|
877
|
-
function wrapper(root = document.body) {
|
|
878
|
-
|
|
879
|
-
|
|
879
|
+
function wrapper(root = document.body) {
|
|
880
|
+
if (document && document.body && !document.body.contains(root)) {
|
|
881
|
+
console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly');
|
|
882
|
+
}
|
|
883
|
+
;
|
|
884
|
+
return new dom_1.ElementWrapper(root);
|
|
885
|
+
}
|
|
880
886
|
exports.default = wrapper;
|
|
881
887
|
//# sourceMappingURL=index.js.map
|