@cloudscape-design/components 3.0.924 → 3.0.925

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/code-editor/index.d.ts.map +1 -1
  2. package/code-editor/index.js +2 -2
  3. package/code-editor/index.js.map +1 -1
  4. package/code-editor/interfaces.d.ts +2 -0
  5. package/code-editor/interfaces.d.ts.map +1 -1
  6. package/code-editor/interfaces.js.map +1 -1
  7. package/code-editor/pane.d.ts +3 -1
  8. package/code-editor/pane.d.ts.map +1 -1
  9. package/code-editor/pane.js +2 -2
  10. package/code-editor/pane.js.map +1 -1
  11. package/code-editor/resizable-box/index.d.ts +3 -1
  12. package/code-editor/resizable-box/index.d.ts.map +1 -1
  13. package/code-editor/resizable-box/index.js +40 -8
  14. package/code-editor/resizable-box/index.js.map +1 -1
  15. package/code-editor/resizable-box/styles.css.js +4 -3
  16. package/code-editor/resizable-box/styles.scoped.css +16 -24
  17. package/code-editor/resizable-box/styles.selectors.js +4 -3
  18. package/i18n/messages/all.all.js +1 -1
  19. package/i18n/messages/all.all.json +1 -1
  20. package/i18n/messages/all.ar.js +1 -1
  21. package/i18n/messages/all.ar.json +1 -1
  22. package/i18n/messages/all.de.js +1 -1
  23. package/i18n/messages/all.de.json +1 -1
  24. package/i18n/messages/all.en-GB.js +1 -1
  25. package/i18n/messages/all.en-GB.json +1 -1
  26. package/i18n/messages/all.en.js +1 -1
  27. package/i18n/messages/all.en.json +1 -1
  28. package/i18n/messages/all.es.js +1 -1
  29. package/i18n/messages/all.es.json +1 -1
  30. package/i18n/messages/all.fr.js +1 -1
  31. package/i18n/messages/all.fr.json +1 -1
  32. package/i18n/messages/all.id.js +1 -1
  33. package/i18n/messages/all.id.json +1 -1
  34. package/i18n/messages/all.it.js +1 -1
  35. package/i18n/messages/all.it.json +1 -1
  36. package/i18n/messages/all.ja.js +1 -1
  37. package/i18n/messages/all.ja.json +1 -1
  38. package/i18n/messages/all.ko.js +1 -1
  39. package/i18n/messages/all.ko.json +1 -1
  40. package/i18n/messages/all.pt-BR.js +1 -1
  41. package/i18n/messages/all.pt-BR.json +1 -1
  42. package/i18n/messages/all.tr.js +1 -1
  43. package/i18n/messages/all.tr.json +1 -1
  44. package/i18n/messages/all.zh-CN.js +1 -1
  45. package/i18n/messages/all.zh-CN.json +1 -1
  46. package/i18n/messages/all.zh-TW.js +1 -1
  47. package/i18n/messages/all.zh-TW.json +1 -1
  48. package/i18n/messages-types.d.ts +2 -0
  49. package/i18n/messages-types.d.ts.map +1 -1
  50. package/i18n/messages-types.js.map +1 -1
  51. package/internal/base-component/styles.scoped.css +14 -0
  52. package/internal/components/drag-handle/button.d.ts +5 -0
  53. package/internal/components/drag-handle/button.d.ts.map +1 -0
  54. package/internal/components/drag-handle/button.js +35 -0
  55. package/internal/components/drag-handle/button.js.map +1 -0
  56. package/internal/components/drag-handle/index.d.ts.map +1 -1
  57. package/internal/components/drag-handle/index.js +6 -30
  58. package/internal/components/drag-handle/index.js.map +1 -1
  59. package/internal/components/drag-handle/interfaces.d.ts +7 -1
  60. package/internal/components/drag-handle/interfaces.d.ts.map +1 -1
  61. package/internal/components/drag-handle/interfaces.js.map +1 -1
  62. package/internal/components/drag-handle-wrapper/direction-button.d.ts +11 -0
  63. package/internal/components/drag-handle-wrapper/direction-button.d.ts.map +1 -0
  64. package/internal/components/drag-handle-wrapper/direction-button.js +30 -0
  65. package/internal/components/drag-handle-wrapper/direction-button.js.map +1 -0
  66. package/internal/components/drag-handle-wrapper/index.d.ts +4 -0
  67. package/internal/components/drag-handle-wrapper/index.d.ts.map +1 -0
  68. package/internal/components/drag-handle-wrapper/index.js +138 -0
  69. package/internal/components/drag-handle-wrapper/index.js.map +1 -0
  70. package/internal/components/drag-handle-wrapper/interfaces.d.ts +10 -0
  71. package/internal/components/drag-handle-wrapper/interfaces.d.ts.map +1 -0
  72. package/internal/components/drag-handle-wrapper/interfaces.js +4 -0
  73. package/internal/components/drag-handle-wrapper/interfaces.js.map +1 -0
  74. package/internal/components/drag-handle-wrapper/portal-overlay.d.ts +6 -0
  75. package/internal/components/drag-handle-wrapper/portal-overlay.d.ts.map +1 -0
  76. package/internal/components/drag-handle-wrapper/portal-overlay.js +56 -0
  77. package/internal/components/drag-handle-wrapper/portal-overlay.js.map +1 -0
  78. package/internal/components/drag-handle-wrapper/styles.css.js +32 -0
  79. package/internal/components/drag-handle-wrapper/styles.scoped.css +508 -0
  80. package/internal/components/drag-handle-wrapper/styles.selectors.js +33 -0
  81. package/internal/environment.js +1 -1
  82. package/internal/environment.json +1 -1
  83. package/internal/generated/styles/tokens.d.ts +6 -0
  84. package/internal/generated/styles/tokens.js +6 -0
  85. package/internal/generated/theming/index.cjs +186 -0
  86. package/internal/generated/theming/index.js +186 -0
  87. package/internal/manifest.json +1 -1
  88. package/internal/utils/pointer-events-mock.d.ts +5 -0
  89. package/internal/utils/pointer-events-mock.d.ts.map +1 -0
  90. package/internal/utils/pointer-events-mock.js +10 -0
  91. package/internal/utils/pointer-events-mock.js.map +1 -0
  92. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { forwardRef, useRef } from 'react';
4
+ import clsx from 'clsx';
5
+ import InternalIcon from '../../../icon/internal';
6
+ import useForwardFocus from '../../hooks/forward-focus';
7
+ import { ResizeIcon } from './resize-icon';
8
+ import styles from './styles.css.js';
9
+ const DragHandleButton = forwardRef(({ variant = 'drag-indicator', size = 'normal', className, ariaLabel, ariaDescribedby, ariaValue, disabled, onPointerDown, onKeyDown, }, ref) => {
10
+ const dragHandleRefObject = useRef(null);
11
+ useForwardFocus(ref, dragHandleRefObject);
12
+ const iconProps = (() => {
13
+ const shared = { variant: disabled ? 'disabled' : undefined, size };
14
+ switch (variant) {
15
+ case 'drag-indicator':
16
+ return Object.assign(Object.assign({}, shared), { name: 'drag-indicator' });
17
+ case 'resize-area':
18
+ return Object.assign(Object.assign({}, shared), { name: 'resize-area' });
19
+ case 'resize-horizontal':
20
+ return Object.assign(Object.assign({}, shared), { svg: React.createElement(ResizeIcon, { variant: "horizontal" }) });
21
+ case 'resize-vertical':
22
+ return Object.assign(Object.assign({}, shared), { svg: React.createElement(ResizeIcon, { variant: "vertical" }) });
23
+ }
24
+ })();
25
+ return (
26
+ // We need to use a div with button role instead of a button
27
+ // so that Safari will focus on it when clicking it.
28
+ // (See https://bugs.webkit.org/show_bug.cgi?id=22261)
29
+ // Otherwise, we can't reliably catch keyboard events coming from the handle
30
+ // when it is being dragged.
31
+ React.createElement("div", { ref: dragHandleRefObject, role: ariaValue ? 'slider' : 'button', tabIndex: 0, className: clsx(className, styles.handle, styles[`handle-${variant}`], styles[`handle-size-${size}`], disabled && styles['handle-disabled']), "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, "aria-disabled": disabled, "aria-valuemax": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueMax, "aria-valuemin": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueMin, "aria-valuenow": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueNow, onPointerDown: onPointerDown, onKeyDown: onKeyDown },
32
+ React.createElement(InternalIcon, Object.assign({}, iconProps))));
33
+ });
34
+ export default DragHandleButton;
35
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/button.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,i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B,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,EAC7B,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC,CACtC,gBACW,SAAS,sBACH,eAAe,mBAClB,QAAQ,mBACR,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,mBACnB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,mBACnB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAClC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS;QAEpB,oBAAC,YAAY,oBAAK,SAAS,EAAI,CAC3B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { IconProps } from '../../../icon/interfaces';\nimport InternalIcon from '../../../icon/internal';\nimport useForwardFocus from '../../hooks/forward-focus';\nimport { DragHandleProps } from './interfaces';\nimport { ResizeIcon } from './resize-icon';\n\nimport styles from './styles.css.js';\n\nconst DragHandleButton = forwardRef(\n (\n {\n variant = 'drag-indicator',\n size = 'normal',\n className,\n ariaLabel,\n ariaDescribedby,\n ariaValue,\n disabled,\n onPointerDown,\n onKeyDown,\n }: DragHandleProps,\n ref: React.Ref<DragHandleProps.Ref>\n ) => {\n const dragHandleRefObject = useRef<HTMLDivElement>(null);\n\n useForwardFocus(ref, dragHandleRefObject);\n\n const iconProps: IconProps = (() => {\n const shared = { variant: disabled ? ('disabled' as const) : undefined, size };\n switch (variant) {\n case 'drag-indicator':\n return { ...shared, name: 'drag-indicator' };\n case 'resize-area':\n return { ...shared, name: 'resize-area' };\n case 'resize-horizontal':\n return { ...shared, svg: <ResizeIcon variant=\"horizontal\" /> };\n case 'resize-vertical':\n return { ...shared, svg: <ResizeIcon variant=\"vertical\" /> };\n }\n })();\n\n return (\n // We need to use a div with button role instead of a button\n // so that Safari will focus on it when clicking it.\n // (See https://bugs.webkit.org/show_bug.cgi?id=22261)\n // Otherwise, we can't reliably catch keyboard events coming from the handle\n // when it is being dragged.\n <div\n ref={dragHandleRefObject}\n role={ariaValue ? 'slider' : 'button'}\n tabIndex={0}\n className={clsx(\n className,\n styles.handle,\n styles[`handle-${variant}`],\n styles[`handle-size-${size}`],\n disabled && styles['handle-disabled']\n )}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-disabled={disabled}\n aria-valuemax={ariaValue?.valueMax}\n aria-valuemin={ariaValue?.valueMin}\n aria-valuenow={ariaValue?.valueNow}\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n >\n <InternalIcon {...iconProps} />\n </div>\n );\n }\n);\n\nexport default DragHandleButton;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAOlD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,kBAAkB,6FAiEvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAK1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,QAAA,MAAM,kBAAkB,6FAyCvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -1,39 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import React, { forwardRef, useRef } from 'react';
5
- import clsx from 'clsx';
6
- import InternalIcon from '../../../icon/internal';
4
+ import React, { forwardRef } from 'react';
7
5
  import { getBaseProps } from '../../base-component';
8
- import useForwardFocus from '../../hooks/forward-focus';
9
- import { ResizeIcon } from './resize-icon';
10
- import styles from './styles.css.js';
6
+ import DragHandleWrapper from '../drag-handle-wrapper';
7
+ import DragHandleButton from './button';
11
8
  const InternalDragHandle = forwardRef((_a, ref) => {
12
- var { variant = 'drag-indicator', size = 'normal', ariaLabel, ariaDescribedby, ariaValue, disabled, onPointerDown, onKeyDown } = _a, rest = __rest(_a, ["variant", "size", "ariaLabel", "ariaDescribedby", "ariaValue", "disabled", "onPointerDown", "onKeyDown"]);
9
+ var { variant, size, ariaLabel, ariaDescribedby, tooltipText, ariaValue, disabled, directions = {}, onPointerDown, onKeyDown, onDirectionClick } = _a, rest = __rest(_a, ["variant", "size", "ariaLabel", "ariaDescribedby", "tooltipText", "ariaValue", "disabled", "directions", "onPointerDown", "onKeyDown", "onDirectionClick"]);
13
10
  const baseProps = getBaseProps(rest);
14
- const dragHandleRefObject = useRef(null);
15
- useForwardFocus(ref, dragHandleRefObject);
16
- const iconProps = (() => {
17
- const shared = { variant: disabled ? 'disabled' : undefined, size };
18
- switch (variant) {
19
- case 'drag-indicator':
20
- return Object.assign(Object.assign({}, shared), { name: 'drag-indicator' });
21
- case 'resize-area':
22
- return Object.assign(Object.assign({}, shared), { name: 'resize-area' });
23
- case 'resize-horizontal':
24
- return Object.assign(Object.assign({}, shared), { svg: React.createElement(ResizeIcon, { variant: "horizontal" }) });
25
- case 'resize-vertical':
26
- return Object.assign(Object.assign({}, shared), { svg: React.createElement(ResizeIcon, { variant: "vertical" }) });
27
- }
28
- })();
29
- return (
30
- // We need to use a div with button role instead of a button
31
- // so that Safari will focus on it when clicking it.
32
- // (See https://bugs.webkit.org/show_bug.cgi?id=22261)
33
- // Otherwise, we can't reliably catch keyboard events coming from the handle
34
- // when it is being dragged.
35
- React.createElement("div", Object.assign({}, baseProps, { ref: dragHandleRefObject, role: ariaValue ? 'slider' : 'button', tabIndex: 0, className: clsx(baseProps.className, styles.handle, styles[`handle-${variant}`], styles[`handle-size-${size}`], disabled && styles['handle-disabled']), "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, "aria-disabled": disabled, "aria-valuemax": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueMax, "aria-valuemin": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueMin, "aria-valuenow": ariaValue === null || ariaValue === void 0 ? void 0 : ariaValue.valueNow, onPointerDown: onPointerDown, onKeyDown: onKeyDown }),
36
- React.createElement(InternalIcon, Object.assign({}, iconProps))));
11
+ return (React.createElement(DragHandleWrapper, { directions: !disabled ? directions : {}, tooltipText: tooltipText, onDirectionClick: onDirectionClick },
12
+ React.createElement(DragHandleButton, { ref: ref, className: baseProps.className, variant: variant, size: size, ariaLabel: ariaLabel, ariaDescribedby: ariaDescribedby, ariaValue: ariaValue, disabled: disabled, onPointerDown: onPointerDown, onKeyDown: onKeyDown })));
37
13
  });
38
14
  export default InternalDragHandle;
39
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,kBAAkB,GAAG,UAAU,CACnC,CACE,EAUkB,EAClB,GAAmC,EACnC,EAAE;QAZF,EACE,OAA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AC,EAC3B,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,EAC7B,QAAQ,IAAI,MAAM,CAAC,iBAAiB,CAAC,CACtC,gBACW,SAAS,sBACH,eAAe,mBAClB,QAAQ,mBACR,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,mBACnB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,mBACnB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAClC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS;QAEpB,oBAAC,YAAY,oBAAK,SAAS,EAAI,CAC3B,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { IconProps } from '../../../icon/interfaces';\nimport InternalIcon from '../../../icon/internal';\nimport { getBaseProps } from '../../base-component';\nimport useForwardFocus from '../../hooks/forward-focus';\nimport { DragHandleProps } from './interfaces';\nimport { ResizeIcon } from './resize-icon';\n\nimport styles from './styles.css.js';\n\nexport { DragHandleProps };\n\nconst InternalDragHandle = forwardRef(\n (\n {\n variant = 'drag-indicator',\n size = 'normal',\n ariaLabel,\n ariaDescribedby,\n ariaValue,\n disabled,\n onPointerDown,\n onKeyDown,\n ...rest\n }: DragHandleProps,\n ref: React.Ref<DragHandleProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n const dragHandleRefObject = useRef<HTMLDivElement>(null);\n\n useForwardFocus(ref, dragHandleRefObject);\n\n const iconProps: IconProps = (() => {\n const shared = { variant: disabled ? ('disabled' as const) : undefined, size };\n switch (variant) {\n case 'drag-indicator':\n return { ...shared, name: 'drag-indicator' };\n case 'resize-area':\n return { ...shared, name: 'resize-area' };\n case 'resize-horizontal':\n return { ...shared, svg: <ResizeIcon variant=\"horizontal\" /> };\n case 'resize-vertical':\n return { ...shared, svg: <ResizeIcon variant=\"vertical\" /> };\n }\n })();\n\n return (\n // We need to use a div with button role instead of a button\n // so that Safari will focus on it when clicking it.\n // (See https://bugs.webkit.org/show_bug.cgi?id=22261)\n // Otherwise, we can't reliably catch keyboard events coming from the handle\n // when it is being dragged.\n <div\n {...baseProps}\n ref={dragHandleRefObject}\n role={ariaValue ? 'slider' : 'button'}\n tabIndex={0}\n className={clsx(\n baseProps.className,\n styles.handle,\n styles[`handle-${variant}`],\n styles[`handle-size-${size}`],\n disabled && styles['handle-disabled']\n )}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-disabled={disabled}\n aria-valuemax={ariaValue?.valueMax}\n aria-valuemin={ariaValue?.valueMin}\n aria-valuenow={ariaValue?.valueNow}\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n >\n <InternalIcon {...iconProps} />\n </div>\n );\n }\n);\n\nexport default InternalDragHandle;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AACvD,OAAO,gBAAgB,MAAM,UAAU,CAAC;AAKxC,MAAM,kBAAkB,GAAG,UAAU,CACnC,CACE,EAakB,EAClB,GAAmC,EACnC,EAAE;QAfF,EACE,OAAO,EACP,IAAI,EACJ,SAAS,EACT,eAAe,EACf,WAAW,EACX,SAAS,EACT,QAAQ,EACR,UAAU,GAAG,EAAE,EACf,aAAa,EACb,SAAS,EACT,gBAAgB,OAEA,EADb,IAAI,cAZT,2JAaC,CADQ;IAIT,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO,CACL,oBAAC,iBAAiB,IAChB,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EACvC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB;QAElC,oBAAC,gBAAgB,IACf,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,CAAC,SAAS,EAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,GACpB,CACgB,CACrB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef } from 'react';\n\nimport { getBaseProps } from '../../base-component';\nimport DragHandleWrapper from '../drag-handle-wrapper';\nimport DragHandleButton from './button';\nimport { DragHandleProps } from './interfaces';\n\nexport { DragHandleProps };\n\nconst InternalDragHandle = forwardRef(\n (\n {\n variant,\n size,\n ariaLabel,\n ariaDescribedby,\n tooltipText,\n ariaValue,\n disabled,\n directions = {},\n onPointerDown,\n onKeyDown,\n onDirectionClick,\n ...rest\n }: DragHandleProps,\n ref: React.Ref<DragHandleProps.Ref>\n ) => {\n const baseProps = getBaseProps(rest);\n\n return (\n <DragHandleWrapper\n directions={!disabled ? directions : {}}\n tooltipText={tooltipText}\n onDirectionClick={onDirectionClick}\n >\n <DragHandleButton\n ref={ref}\n className={baseProps.className}\n variant={variant}\n size={size}\n ariaLabel={ariaLabel}\n ariaDescribedby={ariaDescribedby}\n ariaValue={ariaValue}\n disabled={disabled}\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n />\n </DragHandleWrapper>\n );\n }\n);\n\nexport default InternalDragHandle;\n"]}
@@ -1,17 +1,23 @@
1
1
  /// <reference types="react" />
2
+ import { Direction as WrapperDirection, DirectionState as WrapperDirectionState } from '../drag-handle-wrapper/interfaces';
2
3
  export interface DragHandleProps {
3
4
  variant?: DragHandleProps.Variant;
4
5
  size?: DragHandleProps.Size;
5
- ariaLabel: string;
6
+ ariaLabel?: string;
6
7
  ariaDescribedby?: string;
7
8
  ariaValue?: DragHandleProps.AriaValue;
8
9
  disabled?: boolean;
9
10
  className?: string;
10
11
  onPointerDown?: React.PointerEventHandler;
11
12
  onKeyDown?: React.KeyboardEventHandler;
13
+ tooltipText?: string;
14
+ directions?: Partial<Record<DragHandleProps.Direction, DragHandleProps.DirectionState>>;
15
+ onDirectionClick?: (direction: DragHandleProps.Direction) => void;
12
16
  }
13
17
  export declare namespace DragHandleProps {
14
18
  type Variant = 'drag-indicator' | 'resize-area' | 'resize-horizontal' | 'resize-vertical';
19
+ type Direction = WrapperDirection;
20
+ type DirectionState = WrapperDirectionState;
15
21
  type Size = 'small' | 'normal';
16
22
  interface AriaValue {
17
23
  valueMin: number;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/interfaces.ts"],"names":[],"mappings":";AAGA,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC;IAClC,IAAI,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC;IAC1C,SAAS,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC;CACxC;AAED,yBAAiB,eAAe,CAAC;IAC/B,KAAY,OAAO,GAAG,gBAAg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AAG,iBAAiB,CAAC;IAEjG,KAAY,SAAS,GAAG,gBAAgB,CAAC;IACzC,KAAY,cAAc,GAAG,qBAAqB,CAAC;IAEnD,KAAY,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC;IAEtC,UAAiB,SAAS;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB;IAED,UAAiB,GAAG;QAClB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;KACrC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/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 DragHandleProps {\n variant?: DragHandleProps.Variant;\n size?: DragHandleProps.Size;\n ariaLabel: string;\n ariaDescribedby?: string;\n ariaValue?: DragHandleProps.AriaValue;\n disabled?: boolean;\n className?: string;\n onPointerDown?: React.PointerEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n}\n\nexport namespace DragHandleProps {\n export type Variant = 'drag-indicator' | 'resize-area' | 'resize-horizontal' | 'resize-vertical';\n\n export type Size = 'small' | 'normal';\n\n export interface AriaValue {\n valueMin: number;\n valueMax: number;\n valueNow: number;\n }\n\n export interface Ref {\n focus(options?: FocusOptions): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/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\nimport {\n Direction as WrapperDirection,\n DirectionState as WrapperDirectionState,\n} from '../drag-handle-wrapper/interfaces';\n\nexport interface DragHandleProps {\n variant?: DragHandleProps.Variant;\n size?: DragHandleProps.Size;\n ariaLabel?: string;\n ariaDescribedby?: string;\n ariaValue?: DragHandleProps.AriaValue;\n disabled?: boolean;\n className?: string;\n onPointerDown?: React.PointerEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n\n tooltipText?: string;\n directions?: Partial<Record<DragHandleProps.Direction, DragHandleProps.DirectionState>>;\n onDirectionClick?: (direction: DragHandleProps.Direction) => void;\n}\n\nexport namespace DragHandleProps {\n export type Variant = 'drag-indicator' | 'resize-area' | 'resize-horizontal' | 'resize-vertical';\n\n export type Direction = WrapperDirection;\n export type DirectionState = WrapperDirectionState;\n\n export type Size = 'small' | 'normal';\n\n export interface AriaValue {\n valueMin: number;\n valueMax: number;\n valueNow: number;\n }\n\n export interface Ref {\n focus(options?: FocusOptions): void;\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Direction, DirectionState } from './interfaces';
3
+ interface DirectionButtonProps {
4
+ direction: Direction;
5
+ state: DirectionState;
6
+ onClick: React.MouseEventHandler;
7
+ show: boolean;
8
+ }
9
+ export default function DirectionButton({ direction, state, show, onClick }: DirectionButtonProps): JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=direction-button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-button.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/direction-button.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAczD,UAAU,oBAAoB;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,oBAAoB,eA8BhG"}
@@ -0,0 +1,30 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React from 'react';
4
+ import clsx from 'clsx';
5
+ import InternalIcon from '../../../icon/internal';
6
+ import { Transition } from '../transition';
7
+ import styles from './styles.css.js';
8
+ // Mapping from CSS logical property direction to icon name. The icon component
9
+ // already flips the left/right icons automatically based on RTL, so we don't
10
+ // need to do anything special.
11
+ const ICON_LOGICAL_PROPERTY_MAP = {
12
+ 'block-start': 'arrow-up',
13
+ 'block-end': 'arrow-down',
14
+ 'inline-start': 'arrow-left',
15
+ 'inline-end': 'arrow-right',
16
+ };
17
+ export default function DirectionButton({ direction, state, show, onClick }) {
18
+ return (React.createElement(Transition, { in: show }, (transitionState, ref) => (
19
+ // The wrapper exists to provide a padding around each direction button that
20
+ // prevents any accidental presses around the button from propagating to any
21
+ // interactive elements behind the button.
22
+ React.createElement("span", { ref: ref, className: clsx(styles['direction-button-wrapper'], styles[`direction-button-wrapper-${direction}`], transitionState === 'exited' && styles['direction-button-wrapper-hidden'], styles[`direction-button-wrapper-motion-${transitionState}`]) },
23
+ React.createElement("span", { className: clsx(styles['direction-button'], state === 'disabled' && styles['direction-button-disabled']), onClick: state !== 'disabled' ? onClick : undefined,
24
+ // This prevents focus from being lost to `document.body` on
25
+ // mouse/pointer press. This allows us to listen to onClick while
26
+ // keeping this button pointer-accessible only.
27
+ onPointerDown: event => event.preventDefault() },
28
+ React.createElement(InternalIcon, { name: ICON_LOGICAL_PROPERTY_MAP[direction], size: "small" }))))));
29
+ }
30
+ //# sourceMappingURL=direction-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"direction-button.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/direction-button.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,MAAM,OAAO,CA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AAI,EAAC,OAAO,GAAG,CACpE,CACF,CACR,CACU,CACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { IconProps } from '../../../icon/interfaces';\nimport InternalIcon from '../../../icon/internal';\nimport { Transition } from '../transition';\nimport { Direction, DirectionState } from './interfaces';\n\nimport styles from './styles.css.js';\n\n// Mapping from CSS logical property direction to icon name. The icon component\n// already flips the left/right icons automatically based on RTL, so we don't\n// need to do anything special.\nconst ICON_LOGICAL_PROPERTY_MAP: Record<Direction, IconProps.Name> = {\n 'block-start': 'arrow-up',\n 'block-end': 'arrow-down',\n 'inline-start': 'arrow-left',\n 'inline-end': 'arrow-right',\n};\n\ninterface DirectionButtonProps {\n direction: Direction;\n state: DirectionState;\n onClick: React.MouseEventHandler;\n show: boolean;\n}\n\nexport default function DirectionButton({ direction, state, show, onClick }: DirectionButtonProps) {\n return (\n <Transition in={show}>\n {(transitionState, ref) => (\n // The wrapper exists to provide a padding around each direction button that\n // prevents any accidental presses around the button from propagating to any\n // interactive elements behind the button.\n <span\n ref={ref}\n className={clsx(\n styles['direction-button-wrapper'],\n styles[`direction-button-wrapper-${direction}`],\n transitionState === 'exited' && styles['direction-button-wrapper-hidden'],\n styles[`direction-button-wrapper-motion-${transitionState}`]\n )}\n >\n <span\n className={clsx(styles['direction-button'], state === 'disabled' && styles['direction-button-disabled'])}\n onClick={state !== 'disabled' ? onClick : undefined}\n // This prevents focus from being lost to `document.body` on\n // mouse/pointer press. This allows us to listen to onClick while\n // keeping this button pointer-accessible only.\n onPointerDown={event => event.preventDefault()}\n >\n <InternalIcon name={ICON_LOGICAL_PROPERTY_MAP[direction]} size=\"small\" />\n </span>\n </span>\n )}\n </Transition>\n );\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { DragHandleWrapperProps } from './interfaces';
3
+ export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, }: DragHandleWrapperProps): JSX.Element;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAa,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAWjE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,EAAE,sBAAsB,eAwMxB"}
@@ -0,0 +1,138 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { useEffect, useRef, useState } from 'react';
4
+ import clsx from 'clsx';
5
+ import { nodeContains } from '@cloudscape-design/component-toolkit/dom';
6
+ import { getFirstFocusable } from '../focus-lock/utils';
7
+ import Tooltip from '../tooltip';
8
+ import DirectionButton from './direction-button';
9
+ import PortalOverlay from './portal-overlay';
10
+ import styles from './styles.css.js';
11
+ // The amount of distance after pointer down that the cursor is allowed to
12
+ // jitter for a subsequent mouseup to still register as a "press" instead of
13
+ // a drag. A little allowance is needed for usability reasons, but this number
14
+ // isn't set in stone.
15
+ const PRESS_DELTA_MAX = 3;
16
+ export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, }) {
17
+ const wrapperRef = useRef(null);
18
+ const dragHandleRef = useRef(null);
19
+ const [showTooltip, setShowTooltip] = useState(false);
20
+ const [showButtons, setShowButtons] = useState(false);
21
+ // The tooltip ("Drag or select to move/resize") shouldn't show if clicking
22
+ // on the handle wouldn't do anything.
23
+ const isDisabled = !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];
24
+ const onWrapperFocusIn = event => {
25
+ // The drag handle is focused when it's either tabbed to, or the pointer
26
+ // is pressed on it. We exclude handling the pointer press in this handler,
27
+ // since it could be the start of a drag event - the pointer stuff is
28
+ // handled in the "pointerup" listener instead.
29
+ if (!isPointerDown.current && !nodeContains(wrapperRef.current, event.relatedTarget)) {
30
+ setShowTooltip(false);
31
+ setShowButtons(true);
32
+ }
33
+ };
34
+ const onWrapperFocusOut = event => {
35
+ // Close the directional buttons when the focus leaves the drag handle.
36
+ // "focusout" is also triggered when the user leaves the current tab, but
37
+ // since it'll be returned when they switch back anyway, we exclude that
38
+ // case by checking for `document.hasFocus()`.
39
+ if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {
40
+ setShowButtons(false);
41
+ }
42
+ };
43
+ const isPointerDown = useRef(false);
44
+ const initialPointerPosition = useRef();
45
+ const didPointerDrag = useRef(false);
46
+ useEffect(() => {
47
+ const controller = new AbortController();
48
+ // See `PRESS_DELTA_MAX` above. We need to differentiate between a "click"
49
+ // and a "drag" action. We can say a "click" happens when a "pointerdown"
50
+ // is followed by a "pointerup" with no "pointermove" between the two.
51
+ // However, it would be a poor usability experience if a "click" isn't
52
+ // registered because, while pressing my mouse, I moved it by just one
53
+ // pixel, making it a "drag" instead. So we allow the pointer to move by
54
+ // `PRESS_DELTA_MAX` pixels before setting `didPointerDrag` to true.
55
+ document.addEventListener('pointermove', event => {
56
+ if (isPointerDown.current &&
57
+ initialPointerPosition.current &&
58
+ (event.clientX > initialPointerPosition.current.x + PRESS_DELTA_MAX ||
59
+ event.clientX < initialPointerPosition.current.x - PRESS_DELTA_MAX ||
60
+ event.clientY > initialPointerPosition.current.y + PRESS_DELTA_MAX ||
61
+ event.clientY < initialPointerPosition.current.y - PRESS_DELTA_MAX)) {
62
+ didPointerDrag.current = true;
63
+ }
64
+ }, { signal: controller.signal });
65
+ // Shared behavior when a "pointerdown" state ends. This is shared so it
66
+ // can be called for both "pointercancel" and "pointerup" events.
67
+ const resetPointerDownState = () => {
68
+ isPointerDown.current = false;
69
+ initialPointerPosition.current = undefined;
70
+ };
71
+ document.addEventListener('pointercancel', () => {
72
+ resetPointerDownState();
73
+ }, { signal: controller.signal });
74
+ document.addEventListener('pointerup', () => {
75
+ if (isPointerDown.current && !didPointerDrag.current) {
76
+ // The cursor didn't move much between "pointerdown" and "pointerup".
77
+ // Handle this as a "click" instead of a "drag".
78
+ setShowButtons(true);
79
+ }
80
+ resetPointerDownState();
81
+ }, { signal: controller.signal });
82
+ return () => controller.abort();
83
+ }, []);
84
+ const onHandlePointerDown = event => {
85
+ // Tooltip behavior: the tooltip should appear on hover, but disappear when
86
+ // the pointer starts dragging (having the tooltip get in the way while
87
+ // you're trying to drag upwards is annoying). Additionally, the tooltip
88
+ // shouldn't reappear when dragging ends, but only when the pointer leaves
89
+ // the drag handle and comes back.
90
+ isPointerDown.current = true;
91
+ didPointerDrag.current = false;
92
+ initialPointerPosition.current = { x: event.clientX, y: event.clientY };
93
+ setShowTooltip(false);
94
+ };
95
+ // Tooltip behavior: the tooltip should stay open when the cursor moves
96
+ // from the drag handle into the tooltip content itself. This is why the
97
+ // handler is set on the wrapper for both the drag handle and the tooltip.
98
+ const onTooltipGroupPointerEnter = () => {
99
+ if (!isPointerDown.current) {
100
+ setShowTooltip(true);
101
+ }
102
+ };
103
+ const onTooltipGroupPointerLeave = () => {
104
+ setShowTooltip(false);
105
+ };
106
+ const onDragHandleKeyDown = event => {
107
+ // For accessibility reasons, pressing escape should should always close
108
+ // the floating controls.
109
+ if (event.key === 'Escape') {
110
+ setShowButtons(false);
111
+ }
112
+ else {
113
+ // Pressing any other key will display the focus-visible ring around the
114
+ // drag handle if it's in focus, so we should also show the buttons now.
115
+ setShowButtons(true);
116
+ }
117
+ };
118
+ const onInternalDirectionClick = (direction) => {
119
+ var _a;
120
+ // Move focus back to the wrapper on click. This prevents focus from staying
121
+ // on an aria-hidden control, and allows future keyboard events to be handled
122
+ // cleanly using the drag handle's own handlers.
123
+ if (dragHandleRef.current) {
124
+ (_a = getFirstFocusable(dragHandleRef.current)) === null || _a === void 0 ? void 0 : _a.focus();
125
+ }
126
+ onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick(direction);
127
+ };
128
+ return (React.createElement("div", { className: clsx(styles['drag-handle-wrapper'], showButtons && styles['drag-handle-wrapper-open']), ref: wrapperRef, onFocus: onWrapperFocusIn, onBlur: onWrapperFocusOut },
129
+ React.createElement("div", { onPointerEnter: onTooltipGroupPointerEnter, onPointerLeave: onTooltipGroupPointerLeave },
130
+ React.createElement("div", { className: styles['drag-handle'], ref: dragHandleRef, onPointerDown: onHandlePointerDown, onKeyDown: onDragHandleKeyDown }, children),
131
+ !isDisabled && !showButtons && showTooltip && tooltipText && (React.createElement(Tooltip, { trackRef: dragHandleRef, value: tooltipText, onDismiss: () => setShowTooltip(false) }))),
132
+ React.createElement(PortalOverlay, { track: dragHandleRef.current },
133
+ directions['block-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-start", state: directions['block-start'], onClick: () => onInternalDirectionClick('block-start') })),
134
+ directions['block-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-end", state: directions['block-end'], onClick: () => onInternalDirectionClick('block-end') })),
135
+ directions['inline-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-start", state: directions['inline-start'], onClick: () => onInternalDirectionClick('inline-start') })),
136
+ directions['inline-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-end", state: directions['inline-end'], onClick: () => onInternalDirectionClick('inline-end') })))));
137
+ }
138
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,EAA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Aa,IAAC,KAAK,EAAE,aAAa,CAAC,OAAO;YACxC,UAAU,CAAC,aAAa,CAAC,IAAI,CAC5B,oBAAC,eAAe,IACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAC,aAAa,EACvB,KAAK,EAAE,UAAU,CAAC,aAAa,CAAC,EAChC,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,GACtD,CACH;YACA,UAAU,CAAC,WAAW,CAAC,IAAI,CAC1B,oBAAC,eAAe,IACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAC,WAAW,EACrB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,WAAW,CAAC,GACpD,CACH;YACA,UAAU,CAAC,cAAc,CAAC,IAAI,CAC7B,oBAAC,eAAe,IACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAC,cAAc,EACxB,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,EACjC,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,cAAc,CAAC,GACvD,CACH;YACA,UAAU,CAAC,YAAY,CAAC,IAAI,CAC3B,oBAAC,eAAe,IACd,IAAI,EAAE,CAAC,UAAU,IAAI,WAAW,EAChC,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,YAAY,CAAC,GACrD,CACH,CACa,CACZ,CACP,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, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\n\nimport { getFirstFocusable } from '../focus-lock/utils';\nimport Tooltip from '../tooltip';\nimport DirectionButton from './direction-button';\nimport { Direction, DragHandleWrapperProps } from './interfaces';\nimport PortalOverlay from './portal-overlay';\n\nimport styles from './styles.css.js';\n\n// The amount of distance after pointer down that the cursor is allowed to\n// jitter for a subsequent mouseup to still register as a \"press\" instead of\n// a drag. A little allowance is needed for usability reasons, but this number\n// isn't set in stone.\nconst PRESS_DELTA_MAX = 3;\n\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [showButtons, setShowButtons] = useState(false);\n\n // The tooltip (\"Drag or select to move/resize\") shouldn't show if clicking\n // on the handle wouldn't do anything.\n const isDisabled =\n !directions['block-start'] && !directions['block-end'] && !directions['inline-start'] && !directions['inline-end'];\n\n const onWrapperFocusIn: React.FocusEventHandler = event => {\n // The drag handle is focused when it's either tabbed to, or the pointer\n // is pressed on it. We exclude handling the pointer press in this handler,\n // since it could be the start of a drag event - the pointer stuff is\n // handled in the \"pointerup\" listener instead.\n if (!isPointerDown.current && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n setShowButtons(true);\n }\n };\n\n const onWrapperFocusOut: React.FocusEventHandler = event => {\n // Close the directional buttons when the focus leaves the drag handle.\n // \"focusout\" is also triggered when the user leaves the current tab, but\n // since it'll be returned when they switch back anyway, we exclude that\n // case by checking for `document.hasFocus()`.\n if (document.hasFocus() && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowButtons(false);\n }\n };\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(false);\n\n useEffect(() => {\n const controller = new AbortController();\n\n // See `PRESS_DELTA_MAX` above. We need to differentiate between a \"click\"\n // and a \"drag\" action. We can say a \"click\" happens when a \"pointerdown\"\n // is followed by a \"pointerup\" with no \"pointermove\" between the two.\n // However, it would be a poor usability experience if a \"click\" isn't\n // registered because, while pressing my mouse, I moved it by just one\n // pixel, making it a \"drag\" instead. So we allow the pointer to move by\n // `PRESS_DELTA_MAX` pixels before setting `didPointerDrag` to true.\n document.addEventListener(\n 'pointermove',\n event => {\n if (\n isPointerDown.current &&\n initialPointerPosition.current &&\n (event.clientX > initialPointerPosition.current.x + PRESS_DELTA_MAX ||\n event.clientX < initialPointerPosition.current.x - PRESS_DELTA_MAX ||\n event.clientY > initialPointerPosition.current.y + PRESS_DELTA_MAX ||\n event.clientY < initialPointerPosition.current.y - PRESS_DELTA_MAX)\n ) {\n didPointerDrag.current = true;\n }\n },\n { signal: controller.signal }\n );\n\n // Shared behavior when a \"pointerdown\" state ends. This is shared so it\n // can be called for both \"pointercancel\" and \"pointerup\" events.\n const resetPointerDownState = () => {\n isPointerDown.current = false;\n initialPointerPosition.current = undefined;\n };\n\n document.addEventListener(\n 'pointercancel',\n () => {\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n document.addEventListener(\n 'pointerup',\n () => {\n if (isPointerDown.current && !didPointerDrag.current) {\n // The cursor didn't move much between \"pointerdown\" and \"pointerup\".\n // Handle this as a \"click\" instead of a \"drag\".\n setShowButtons(true);\n }\n resetPointerDownState();\n },\n { signal: controller.signal }\n );\n\n return () => controller.abort();\n }, []);\n\n const onHandlePointerDown: React.PointerEventHandler = event => {\n // Tooltip behavior: the tooltip should appear on hover, but disappear when\n // the pointer starts dragging (having the tooltip get in the way while\n // you're trying to drag upwards is annoying). Additionally, the tooltip\n // shouldn't reappear when dragging ends, but only when the pointer leaves\n // the drag handle and comes back.\n\n isPointerDown.current = true;\n didPointerDrag.current = false;\n initialPointerPosition.current = { x: event.clientX, y: event.clientY };\n setShowTooltip(false);\n };\n\n // Tooltip behavior: the tooltip should stay open when the cursor moves\n // from the drag handle into the tooltip content itself. This is why the\n // handler is set on the wrapper for both the drag handle and the tooltip.\n const onTooltipGroupPointerEnter: React.PointerEventHandler = () => {\n if (!isPointerDown.current) {\n setShowTooltip(true);\n }\n };\n const onTooltipGroupPointerLeave: React.PointerEventHandler = () => {\n setShowTooltip(false);\n };\n\n const onDragHandleKeyDown: React.KeyboardEventHandler = event => {\n // For accessibility reasons, pressing escape should should always close\n // the floating controls.\n if (event.key === 'Escape') {\n setShowButtons(false);\n } else {\n // Pressing any other key will display the focus-visible ring around the\n // drag handle if it's in focus, so we should also show the buttons now.\n setShowButtons(true);\n }\n };\n\n const onInternalDirectionClick = (direction: Direction) => {\n // Move focus back to the wrapper on click. This prevents focus from staying\n // on an aria-hidden control, and allows future keyboard events to be handled\n // cleanly using the drag handle's own handlers.\n if (dragHandleRef.current) {\n getFirstFocusable(dragHandleRef.current)?.focus();\n }\n onDirectionClick?.(direction);\n };\n\n return (\n <div\n className={clsx(styles['drag-handle-wrapper'], showButtons && styles['drag-handle-wrapper-open'])}\n ref={wrapperRef}\n onFocus={onWrapperFocusIn}\n onBlur={onWrapperFocusOut}\n >\n <div onPointerEnter={onTooltipGroupPointerEnter} onPointerLeave={onTooltipGroupPointerLeave}>\n <div\n className={styles['drag-handle']}\n ref={dragHandleRef}\n onPointerDown={onHandlePointerDown}\n onKeyDown={onDragHandleKeyDown}\n >\n {children}\n </div>\n\n {!isDisabled && !showButtons && showTooltip && tooltipText && (\n <Tooltip trackRef={dragHandleRef} value={tooltipText} onDismiss={() => setShowTooltip(false)} />\n )}\n </div>\n\n <PortalOverlay track={dragHandleRef.current}>\n {directions['block-start'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"block-start\"\n state={directions['block-start']}\n onClick={() => onInternalDirectionClick('block-start')}\n />\n )}\n {directions['block-end'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"block-end\"\n state={directions['block-end']}\n onClick={() => onInternalDirectionClick('block-end')}\n />\n )}\n {directions['inline-start'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"inline-start\"\n state={directions['inline-start']}\n onClick={() => onInternalDirectionClick('inline-start')}\n />\n )}\n {directions['inline-end'] && (\n <DirectionButton\n show={!isDisabled && showButtons}\n direction=\"inline-end\"\n state={directions['inline-end']}\n onClick={() => onInternalDirectionClick('inline-end')}\n />\n )}\n </PortalOverlay>\n </div>\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ export type Direction = 'block-start' | 'block-end' | 'inline-start' | 'inline-end';
3
+ export type DirectionState = 'active' | 'disabled';
4
+ export interface DragHandleWrapperProps {
5
+ directions: Partial<Record<Direction, DirectionState>>;
6
+ onDirectionClick?: (direction: Direction) => void;
7
+ tooltipText?: string;
8
+ children: React.ReactNode;
9
+ }
10
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/interfaces.ts"],"names":[],"mappings":";AAGA,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,cAAc,GAAG,YAAY,CAAC;AACpF,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnD,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;IACvD,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
@@ -0,0 +1,4 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ export {};
4
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/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 type Direction = 'block-start' | 'block-end' | 'inline-start' | 'inline-end';\nexport type DirectionState = 'active' | 'disabled';\n\nexport interface DragHandleWrapperProps {\n directions: Partial<Record<Direction, DirectionState>>;\n onDirectionClick?: (direction: Direction) => void;\n tooltipText?: string;\n children: React.ReactNode;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export default function PortalOverlay({ track, children }: {
3
+ track: HTMLElement | null;
4
+ children: React.ReactNode;
5
+ }): JSX.Element | null;
6
+ //# sourceMappingURL=portal-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAYjD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,sBAyDlH"}
@@ -0,0 +1,56 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import React, { useEffect, useRef } from 'react';
4
+ import { getIsRtl, getLogicalBoundingClientRect, getScrollInlineStart, } from '@cloudscape-design/component-toolkit/internal';
5
+ import Portal from '../portal';
6
+ import styles from './styles.css.js';
7
+ export default function PortalOverlay({ track, children }) {
8
+ const ref = useRef(null);
9
+ useEffect(() => {
10
+ if (track === null) {
11
+ return;
12
+ }
13
+ let cleanedUp = false;
14
+ let lastX;
15
+ let lastY;
16
+ let lastInlineSize;
17
+ let lastBlockSize;
18
+ const updateElement = () => {
19
+ if (ref.current) {
20
+ const isRtl = getIsRtl(ref.current);
21
+ const { insetInlineStart, insetBlockStart, inlineSize, blockSize } = getLogicalBoundingClientRect(track);
22
+ // For simplicity, we just make all our calculations independent of
23
+ // the browser's scrolling edge. When it comes to applying the changes,
24
+ // translate is independent of writing direction, so we need to invert
25
+ // the X coordinate ourselves just before applying the values.
26
+ const newX = (insetInlineStart + getScrollInlineStart(document.documentElement)) * (isRtl ? -1 : 1);
27
+ const newY = insetBlockStart + document.documentElement.scrollTop;
28
+ if (lastX !== newX || lastY !== newY) {
29
+ ref.current.style.translate = `${newX}px ${newY}px`;
30
+ lastX = newX;
31
+ lastY = newY;
32
+ }
33
+ if (lastInlineSize !== inlineSize || lastBlockSize !== blockSize) {
34
+ ref.current.style.width = `${inlineSize}px`;
35
+ ref.current.style.height = `${blockSize}px`;
36
+ lastInlineSize = inlineSize;
37
+ lastBlockSize = blockSize;
38
+ }
39
+ }
40
+ if (!cleanedUp) {
41
+ requestAnimationFrame(updateElement);
42
+ }
43
+ };
44
+ updateElement();
45
+ return () => {
46
+ cleanedUp = true;
47
+ };
48
+ }, [track]);
49
+ if (track === null) {
50
+ return null;
51
+ }
52
+ return (React.createElement(Portal, null,
53
+ React.createElement("span", { ref: ref, className: styles['portal-overlay'] },
54
+ React.createElement("span", { className: styles['portal-overlay-contents'] }, children))));
55
+ }
56
+ //# sourceMappingURL=portal-overlay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-overlay.js","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle-wrapper/portal-overlay.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,GACrB,MAAM,+CAA+C,CAAC;AAEvD,OAAO,MAAM,MAAM,WAAW,CAAC;AAE/B,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,aAAa,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AAC;oBAC5C,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,SAAS,IAAI,CAAC;oBAC5C,cAAc,GAAG,UAAU,CAAC;oBAC5B,aAAa,GAAG,SAAS,CAAC;iBAC3B;aACF;YACD,IAAI,CAAC,SAAS,EAAE;gBACd,qBAAqB,CAAC,aAAa,CAAC,CAAC;aACtC;QACH,CAAC,CAAC;QACF,aAAa,EAAE,CAAC;QAEhB,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,oBAAC,MAAM;QACL,8BAAM,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC;YACjD,8BAAM,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,IAAG,QAAQ,CAAQ,CAChE,CACA,CACV,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef } from 'react';\n\nimport {\n getIsRtl,\n getLogicalBoundingClientRect,\n getScrollInlineStart,\n} from '@cloudscape-design/component-toolkit/internal';\n\nimport Portal from '../portal';\n\nimport styles from './styles.css.js';\n\nexport default function PortalOverlay({ track, children }: { track: HTMLElement | null; children: React.ReactNode }) {\n const ref = useRef<HTMLSpanElement | null>(null);\n\n useEffect(() => {\n if (track === null) {\n return;\n }\n\n let cleanedUp = false;\n let lastX: number | undefined;\n let lastY: number | undefined;\n let lastInlineSize: number | undefined;\n let lastBlockSize: number | undefined;\n const updateElement = () => {\n if (ref.current) {\n const isRtl = getIsRtl(ref.current);\n const { insetInlineStart, insetBlockStart, inlineSize, blockSize } = getLogicalBoundingClientRect(track);\n // For simplicity, we just make all our calculations independent of\n // the browser's scrolling edge. When it comes to applying the changes,\n // translate is independent of writing direction, so we need to invert\n // the X coordinate ourselves just before applying the values.\n const newX = (insetInlineStart + getScrollInlineStart(document.documentElement)) * (isRtl ? -1 : 1);\n const newY = insetBlockStart + document.documentElement.scrollTop;\n if (lastX !== newX || lastY !== newY) {\n ref.current.style.translate = `${newX}px ${newY}px`;\n lastX = newX;\n lastY = newY;\n }\n if (lastInlineSize !== inlineSize || lastBlockSize !== blockSize) {\n ref.current.style.width = `${inlineSize}px`;\n ref.current.style.height = `${blockSize}px`;\n lastInlineSize = inlineSize;\n lastBlockSize = blockSize;\n }\n }\n if (!cleanedUp) {\n requestAnimationFrame(updateElement);\n }\n };\n updateElement();\n\n return () => {\n cleanedUp = true;\n };\n }, [track]);\n\n if (track === null) {\n return null;\n }\n\n return (\n <Portal>\n <span ref={ref} className={styles['portal-overlay']}>\n <span className={styles['portal-overlay-contents']}>{children}</span>\n </span>\n </Portal>\n );\n}\n"]}
@@ -0,0 +1,32 @@
1
+
2
+ import './styles.scoped.css';
3
+ export default {
4
+ "direction-button-wrapper": "awsui_direction-button-wrapper_155yk_1x7ys_170",
5
+ "direction-button-wrapper-motion-enter": "awsui_direction-button-wrapper-motion-enter_155yk_1x7ys_180",
6
+ "direction-button-wrapper-motion-entering": "awsui_direction-button-wrapper-motion-entering_155yk_1x7ys_181",
7
+ "direction-button-wrapper-motion-exit": "awsui_direction-button-wrapper-motion-exit_155yk_1x7ys_182",
8
+ "direction-button-wrapper-motion-exiting": "awsui_direction-button-wrapper-motion-exiting_155yk_1x7ys_183",
9
+ "direction-button-wrapper-block-start": "awsui_direction-button-wrapper-block-start_155yk_1x7ys_206",
10
+ "slide-up": "awsui_slide-up_155yk_1x7ys_1",
11
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_155yk_1x7ys_1",
12
+ "slide-up-exit": "awsui_slide-up-exit_155yk_1x7ys_1",
13
+ "awsui-motion-fade-out-0": "awsui_awsui-motion-fade-out-0_155yk_1x7ys_1",
14
+ "direction-button-wrapper-block-end": "awsui_direction-button-wrapper-block-end_155yk_1x7ys_233",
15
+ "slide-down": "awsui_slide-down_155yk_1x7ys_1",
16
+ "slide-down-exit": "awsui_slide-down-exit_155yk_1x7ys_1",
17
+ "direction-button-wrapper-inline-start": "awsui_direction-button-wrapper-inline-start_155yk_1x7ys_260",
18
+ "slide-left": "awsui_slide-left_155yk_1x7ys_1",
19
+ "direction-button-wrapper-rtl": "awsui_direction-button-wrapper-rtl_155yk_1x7ys_273",
20
+ "slide-right": "awsui_slide-right_155yk_1x7ys_1",
21
+ "slide-left-exit": "awsui_slide-left-exit_155yk_1x7ys_1",
22
+ "slide-right-exit": "awsui_slide-right-exit_155yk_1x7ys_1",
23
+ "direction-button-wrapper-inline-end": "awsui_direction-button-wrapper-inline-end_155yk_1x7ys_313",
24
+ "drag-handle-wrapper": "awsui_drag-handle-wrapper_155yk_1x7ys_430",
25
+ "portal-overlay": "awsui_portal-overlay_155yk_1x7ys_435",
26
+ "portal-overlay-contents": "awsui_portal-overlay-contents_155yk_1x7ys_443",
27
+ "drag-handle": "awsui_drag-handle_155yk_1x7ys_430",
28
+ "direction-button-wrapper-hidden": "awsui_direction-button-wrapper-hidden_155yk_1x7ys_460",
29
+ "direction-button": "awsui_direction-button_155yk_1x7ys_170",
30
+ "direction-button-disabled": "awsui_direction-button-disabled_155yk_1x7ys_503"
31
+ };
32
+