@cloudscape-design/components-themeable 3.0.1073 → 3.0.1074

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 (175) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/components/drag-handle/styles.scss +4 -0
  3. package/lib/internal/scss/internal/components/sortable-area/styles.scss +1 -3
  4. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  5. package/lib/internal/template/alert/index.d.ts.map +1 -1
  6. package/lib/internal/template/alert/index.js +7 -5
  7. package/lib/internal/template/alert/index.js.map +1 -1
  8. package/lib/internal/template/alert/internal.d.ts +1 -1
  9. package/lib/internal/template/alert/internal.js +1 -1
  10. package/lib/internal/template/alert/internal.js.map +1 -1
  11. package/lib/internal/template/anchor-navigation/internal.d.ts.map +1 -1
  12. package/lib/internal/template/anchor-navigation/internal.js +1 -1
  13. package/lib/internal/template/anchor-navigation/internal.js.map +1 -1
  14. package/lib/internal/template/app-layout/index.js.map +1 -1
  15. package/lib/internal/template/app-layout-toolbar/index.js.map +1 -1
  16. package/lib/internal/template/area-chart/internal.d.ts.map +1 -1
  17. package/lib/internal/template/area-chart/internal.js +1 -1
  18. package/lib/internal/template/area-chart/internal.js.map +1 -1
  19. package/lib/internal/template/attribute-editor/internal.js +1 -1
  20. package/lib/internal/template/attribute-editor/internal.js.map +1 -1
  21. package/lib/internal/template/box/internal.d.ts.map +1 -1
  22. package/lib/internal/template/box/internal.js +1 -1
  23. package/lib/internal/template/box/internal.js.map +1 -1
  24. package/lib/internal/template/breadcrumb-group/skeleton.d.ts +1 -1
  25. package/lib/internal/template/button/internal.d.ts +2 -2
  26. package/lib/internal/template/button/internal.d.ts.map +1 -1
  27. package/lib/internal/template/button/internal.js +1 -1
  28. package/lib/internal/template/button/internal.js.map +1 -1
  29. package/lib/internal/template/button-group/internal.js +1 -1
  30. package/lib/internal/template/button-group/internal.js.map +1 -1
  31. package/lib/internal/template/container/internal.d.ts.map +1 -1
  32. package/lib/internal/template/container/internal.js +1 -1
  33. package/lib/internal/template/container/internal.js.map +1 -1
  34. package/lib/internal/template/copy-to-clipboard/internal.d.ts.map +1 -1
  35. package/lib/internal/template/copy-to-clipboard/internal.js +1 -1
  36. package/lib/internal/template/copy-to-clipboard/internal.js.map +1 -1
  37. package/lib/internal/template/date-input/internal.d.ts +1 -1
  38. package/lib/internal/template/date-input/internal.js +1 -1
  39. package/lib/internal/template/date-input/internal.js.map +1 -1
  40. package/lib/internal/template/file-dropzone/internal.d.ts.map +1 -1
  41. package/lib/internal/template/file-dropzone/internal.js +1 -1
  42. package/lib/internal/template/file-dropzone/internal.js.map +1 -1
  43. package/lib/internal/template/file-input/internal.d.ts +1 -1
  44. package/lib/internal/template/file-input/internal.d.ts.map +1 -1
  45. package/lib/internal/template/file-input/internal.js +1 -1
  46. package/lib/internal/template/file-input/internal.js.map +1 -1
  47. package/lib/internal/template/file-upload/internal.d.ts +1 -1
  48. package/lib/internal/template/file-upload/internal.js +1 -1
  49. package/lib/internal/template/file-upload/internal.js.map +1 -1
  50. package/lib/internal/template/form/index.d.ts.map +1 -1
  51. package/lib/internal/template/form/index.js +6 -5
  52. package/lib/internal/template/form/index.js.map +1 -1
  53. package/lib/internal/template/form-field/interfaces.d.ts +1 -1
  54. package/lib/internal/template/form-field/interfaces.d.ts.map +1 -1
  55. package/lib/internal/template/form-field/interfaces.js.map +1 -1
  56. package/lib/internal/template/form-field/internal.d.ts.map +1 -1
  57. package/lib/internal/template/form-field/internal.js +6 -4
  58. package/lib/internal/template/form-field/internal.js.map +1 -1
  59. package/lib/internal/template/grid/internal.js +1 -1
  60. package/lib/internal/template/grid/internal.js.map +1 -1
  61. package/lib/internal/template/header/internal.d.ts.map +1 -1
  62. package/lib/internal/template/header/internal.js +1 -1
  63. package/lib/internal/template/header/internal.js.map +1 -1
  64. package/lib/internal/template/icon/internal.js +1 -1
  65. package/lib/internal/template/icon/internal.js.map +1 -1
  66. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  67. package/lib/internal/template/internal/components/drag-handle/button.d.ts +1 -1
  68. package/lib/internal/template/internal/components/drag-handle/button.d.ts.map +1 -1
  69. package/lib/internal/template/internal/components/drag-handle/button.js +8 -4
  70. package/lib/internal/template/internal/components/drag-handle/button.js.map +1 -1
  71. package/lib/internal/template/internal/components/drag-handle/index.d.ts +1 -1
  72. package/lib/internal/template/internal/components/drag-handle/index.d.ts.map +1 -1
  73. package/lib/internal/template/internal/components/drag-handle/index.js +3 -3
  74. package/lib/internal/template/internal/components/drag-handle/index.js.map +1 -1
  75. package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts +3 -0
  76. package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts.map +1 -1
  77. package/lib/internal/template/internal/components/drag-handle/interfaces.js.map +1 -1
  78. package/lib/internal/template/internal/components/drag-handle/styles.css.js +14 -13
  79. package/lib/internal/template/internal/components/drag-handle/styles.scoped.css +22 -18
  80. package/lib/internal/template/internal/components/drag-handle/styles.selectors.js +14 -13
  81. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts +1 -1
  82. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
  83. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +10 -9
  84. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -1
  85. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts +2 -1
  86. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts.map +1 -1
  87. package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.js.map +1 -1
  88. package/lib/internal/template/internal/components/sortable-area/index.d.ts.map +1 -1
  89. package/lib/internal/template/internal/components/sortable-area/index.js +20 -5
  90. package/lib/internal/template/internal/components/sortable-area/index.js.map +1 -1
  91. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/index.d.ts +20 -5
  92. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/index.d.ts.map +1 -1
  93. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/index.js +60 -36
  94. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/index.js.map +1 -1
  95. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/events.d.ts +3 -1
  96. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/events.d.ts.map +1 -1
  97. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/events.js +2 -0
  98. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/events.js.map +1 -1
  99. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/scroll.d.ts +1 -1
  100. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/scroll.d.ts.map +1 -1
  101. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/scroll.js +4 -9
  102. package/lib/internal/template/internal/components/sortable-area/keyboard-sensor/utilities/scroll.js.map +1 -1
  103. package/lib/internal/template/internal/components/sortable-area/styles.css.js +8 -8
  104. package/lib/internal/template/internal/components/sortable-area/styles.scoped.css +15 -19
  105. package/lib/internal/template/internal/components/sortable-area/styles.selectors.js +8 -8
  106. package/lib/internal/template/internal/components/sortable-area/use-drag-and-drop-reorder.d.ts +4 -2
  107. package/lib/internal/template/internal/components/sortable-area/use-drag-and-drop-reorder.d.ts.map +1 -1
  108. package/lib/internal/template/internal/components/sortable-area/use-drag-and-drop-reorder.js +36 -40
  109. package/lib/internal/template/internal/components/sortable-area/use-drag-and-drop-reorder.js.map +1 -1
  110. package/lib/internal/template/internal/environment.js +2 -2
  111. package/lib/internal/template/internal/environment.json +2 -2
  112. package/lib/internal/template/internal/generated/theming/index.cjs +14 -0
  113. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +63 -0
  114. package/lib/internal/template/internal/generated/theming/index.d.ts +63 -0
  115. package/lib/internal/template/internal/generated/theming/index.js +14 -0
  116. package/lib/internal/template/internal/hooks/use-base-component/index.d.ts +5 -5
  117. package/lib/internal/template/internal/hooks/use-base-component/index.d.ts.map +1 -1
  118. package/lib/internal/template/internal/hooks/use-base-component/index.js.map +1 -1
  119. package/lib/internal/template/link/internal.d.ts +1 -1
  120. package/lib/internal/template/link/internal.d.ts.map +1 -1
  121. package/lib/internal/template/link/internal.js +2 -4
  122. package/lib/internal/template/link/internal.js.map +1 -1
  123. package/lib/internal/template/list/internal.d.ts.map +1 -1
  124. package/lib/internal/template/list/internal.js +1 -1
  125. package/lib/internal/template/list/internal.js.map +1 -1
  126. package/lib/internal/template/mixed-line-bar-chart/internal.d.ts.map +1 -1
  127. package/lib/internal/template/mixed-line-bar-chart/internal.js +1 -1
  128. package/lib/internal/template/mixed-line-bar-chart/internal.js.map +1 -1
  129. package/lib/internal/template/modal/internal.js +1 -1
  130. package/lib/internal/template/modal/internal.js.map +1 -1
  131. package/lib/internal/template/multiselect/internal.d.ts +1 -1
  132. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  133. package/lib/internal/template/multiselect/internal.js +1 -1
  134. package/lib/internal/template/multiselect/internal.js.map +1 -1
  135. package/lib/internal/template/pagination/internal.d.ts.map +1 -1
  136. package/lib/internal/template/pagination/internal.js +1 -1
  137. package/lib/internal/template/pagination/internal.js.map +1 -1
  138. package/lib/internal/template/popover/internal.js +1 -1
  139. package/lib/internal/template/popover/internal.js.map +1 -1
  140. package/lib/internal/template/prompt-input/internal.js +1 -1
  141. package/lib/internal/template/prompt-input/internal.js.map +1 -1
  142. package/lib/internal/template/property-filter/internal.d.ts +1 -1
  143. package/lib/internal/template/property-filter/internal.d.ts.map +1 -1
  144. package/lib/internal/template/radio-group/internal.d.ts +1 -1
  145. package/lib/internal/template/radio-group/internal.d.ts.map +1 -1
  146. package/lib/internal/template/radio-group/internal.js +1 -1
  147. package/lib/internal/template/radio-group/internal.js.map +1 -1
  148. package/lib/internal/template/segmented-control/internal.d.ts.map +1 -1
  149. package/lib/internal/template/segmented-control/internal.js +1 -1
  150. package/lib/internal/template/segmented-control/internal.js.map +1 -1
  151. package/lib/internal/template/select/internal.js +1 -1
  152. package/lib/internal/template/select/internal.js.map +1 -1
  153. package/lib/internal/template/slider/internal.d.ts.map +1 -1
  154. package/lib/internal/template/slider/internal.js +1 -1
  155. package/lib/internal/template/slider/internal.js.map +1 -1
  156. package/lib/internal/template/space-between/internal.d.ts +1 -1
  157. package/lib/internal/template/space-between/internal.d.ts.map +1 -1
  158. package/lib/internal/template/steps/internal.d.ts +1 -1
  159. package/lib/internal/template/steps/internal.d.ts.map +1 -1
  160. package/lib/internal/template/steps/internal.js.map +1 -1
  161. package/lib/internal/template/text-filter/internal.d.ts +1 -1
  162. package/lib/internal/template/text-filter/internal.d.ts.map +1 -1
  163. package/lib/internal/template/tiles/internal.d.ts +1 -1
  164. package/lib/internal/template/tiles/internal.d.ts.map +1 -1
  165. package/lib/internal/template/tiles/internal.js +1 -1
  166. package/lib/internal/template/tiles/internal.js.map +1 -1
  167. package/lib/internal/template/time-input/internal.d.ts +1 -1
  168. package/lib/internal/template/time-input/internal.d.ts.map +1 -1
  169. package/lib/internal/template/time-input/internal.js +1 -1
  170. package/lib/internal/template/time-input/internal.js.map +1 -1
  171. package/lib/internal/template/toggle/internal.js +1 -1
  172. package/lib/internal/template/toggle/internal.js.map +1 -1
  173. package/lib/internal/template/wizard/wizard-form.js +5 -3
  174. package/lib/internal/template/wizard/wizard-form.js.map +1 -1
  175. package/package.json +1 -1
@@ -7,10 +7,13 @@ import InternalIcon from '../../../icon/internal';
7
7
  import { ResizeIcon } from './resize-icon';
8
8
  import styles from './styles.css.js';
9
9
  import testUtilsStyles from './test-classes/styles.css.js';
10
- const DragHandleButton = forwardRef(({ variant = 'drag-indicator', size = 'normal', active = false, className, ariaLabel, ariaLabelledBy, ariaDescribedby, ariaValue, disabled, onPointerDown, onKeyDown, }, ref) => {
10
+ const DragHandleButton = forwardRef(({ variant = 'drag-indicator', size = 'normal', active = false, className, ariaLabel, ariaLabelledBy, ariaDescribedby, ariaValue, disabled, onPointerDown, onClick, onKeyDown, }, ref) => {
11
11
  const dragHandleRefObject = useRef(null);
12
12
  const iconProps = (() => {
13
- const shared = { variant: disabled ? 'disabled' : undefined, size };
13
+ const shared = {
14
+ variant: disabled ? 'disabled' : undefined,
15
+ size,
16
+ };
14
17
  switch (variant) {
15
18
  case 'drag-indicator':
16
19
  return Object.assign(Object.assign({}, shared), { name: 'drag-indicator' });
@@ -28,8 +31,9 @@ const DragHandleButton = forwardRef(({ variant = 'drag-indicator', size = 'norma
28
31
  // (See https://bugs.webkit.org/show_bug.cgi?id=22261)
29
32
  // Otherwise, we can't reliably catch keyboard events coming from the handle
30
33
  // when it is being dragged.
31
- React.createElement("div", { ref: useMergeRefs(ref, dragHandleRefObject), role: ariaValue ? 'slider' : 'application', tabIndex: 0, className: clsx(className, styles.handle, testUtilsStyles.root, styles[`handle-${variant}`], styles[`handle-size-${size}`], disabled && styles['handle-disabled'], active && styles.active), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "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))));
34
+ React.createElement("div", { ref: useMergeRefs(ref, dragHandleRefObject), role: ariaValue ? 'slider' : 'application', tabIndex: 0, className: clsx(className, styles.handle, testUtilsStyles.root, styles[`handle-${variant}`], styles[`handle-size-${size}`], disabled && styles['handle-disabled'], active && styles.active), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "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, onClick: onClick, onKeyDown: onKeyDown },
35
+ React.createElement("div", { className: styles['prevent-pointer'] },
36
+ React.createElement(InternalIcon, Object.assign({}, iconProps)))));
33
37
  });
34
38
  export default DragHandleButton;
35
39
  //# sourceMappingURL=button.js.map
@@ -1 +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;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAG7E,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,gBAAgB,GAAG,UAAU,CACjC,CACE,EACE,OAAO,GAAG,gBAAgB,EAC1B,IAAI,GAAG,QAAQ,EACf,MAAM,GAAG,KAAK,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,SAAS,EACT,QAAQ,EACR,aAAa,EACb,SAAS,GACO,EAClB,GAAuB,EACvB,EAAE;IACF,MAAM,mBAAmB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzD,MAAM,SAAS,GAAc,CAAC,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAE,UAAoB,CAAC,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;QAC/E,QAAQ,OAAO,EAAE;YACf,KAAK,gBAAgB;gBACnB,uCAAY,MAAM,KAAE,IAAI,EAAE,gBAAgB,IAAG;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reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { forwardRef, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { IconProps } from '../../../icon/interfaces';\nimport InternalIcon from '../../../icon/internal';\nimport { DragHandleProps } from './interfaces';\nimport { ResizeIcon } from './resize-icon';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\nconst DragHandleButton = forwardRef(\n (\n {\n variant = 'drag-indicator',\n size = 'normal',\n active = false,\n className,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedby,\n ariaValue,\n disabled,\n onPointerDown,\n onKeyDown,\n }: DragHandleProps,\n ref: React.Ref<Element>\n ) => {\n const dragHandleRefObject = useRef<HTMLDivElement>(null);\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={useMergeRefs(ref, dragHandleRefObject)}\n role={ariaValue ? 'slider' : 'application'}\n tabIndex={0}\n className={clsx(\n className,\n styles.handle,\n testUtilsStyles.root,\n styles[`handle-${variant}`],\n styles[`handle-size-${size}`],\n disabled && styles['handle-disabled'],\n active && styles.active\n )}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\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
+ {"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;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAG7E,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAE3D,MAAM,gBAAgB,GAAG,UAAU,CACjC,CACE,EACE,OAAO,GAAG,gBAAgB,EAC1B,IAAI,GAAG,QAAQ,EACf,MAAM,GAAG,KAAK,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,SAAS,EACT,QAAQ,EACR,aAAa,EACb,OAAO,EACP,SAAS,GACO,EAClB,GAAuB,EACvB,EAAE;IACF,MAAM,mBAAmB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzD,MAAM,SAAS,GAAc,CAAC,GAAG,EAAE;QACjC,MAAM,MAAM,GAAG;YACb,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAE,UAAoB,CAAC,CAAC,CAAC,SAAS;YACrD,IAAI;SACL,CAAC;QACF,QAAQ,OAAO,EAAE;YACf,KAAK,gBAAgB;gBACnB,uCAAY,MAAM,KAAE,IAAI,EAAE,gBAAgB,IAAG;YAC/C,KAAK,aAAa;gBAChB,uCAAY,MAAM,KAAE,IAAI,EAAE,aAAa,IAAG;YAC5C,KAAK,mBAAmB;gBACtB,uCAAY,MAAM,KAAE,GA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forwardRef, useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { IconProps } from '../../../icon/interfaces';\nimport InternalIcon from '../../../icon/internal';\nimport { DragHandleProps } from './interfaces';\nimport { ResizeIcon } from './resize-icon';\n\nimport styles from './styles.css.js';\nimport testUtilsStyles from './test-classes/styles.css.js';\n\nconst DragHandleButton = forwardRef(\n (\n {\n variant = 'drag-indicator',\n size = 'normal',\n active = false,\n className,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedby,\n ariaValue,\n disabled,\n onPointerDown,\n onClick,\n onKeyDown,\n }: DragHandleProps,\n ref: React.Ref<Element>\n ) => {\n const dragHandleRefObject = useRef<HTMLDivElement>(null);\n\n const iconProps: IconProps = (() => {\n const shared = {\n variant: disabled ? ('disabled' as const) : undefined,\n size,\n };\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={useMergeRefs(ref, dragHandleRefObject)}\n role={ariaValue ? 'slider' : 'application'}\n tabIndex={0}\n className={clsx(\n className,\n styles.handle,\n testUtilsStyles.root,\n styles[`handle-${variant}`],\n styles[`handle-size-${size}`],\n disabled && styles['handle-disabled'],\n active && styles.active\n )}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\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 onClick={onClick}\n onKeyDown={onKeyDown}\n >\n {/* ensure that events happen on the parent div, not the icon */}\n <div className={styles['prevent-pointer']}>\n <InternalIcon {...iconProps} />\n </div>\n </div>\n );\n }\n);\n\nexport default DragHandleButton;\n"]}
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DragHandleProps } from './interfaces';
3
3
  export { DragHandleProps };
4
- declare const InternalDragHandle: React.ForwardRefExoticComponent<DragHandleProps & React.RefAttributes<Element>>;
4
+ declare const InternalDragHandle: React.ForwardRefExoticComponent<Pick<DragHandleProps, "size" | "active" | "disabled" | "className" | "onKeyDown" | "onClick" | "onPointerDown" | "variant" | "ariaLabel" | "ariaDescribedby" | "directions" | "tooltipText" | "onDirectionClick" | "triggerMode" | "initialShowButtons" | "controlledShowButtons" | "hideButtonsOnDrag" | "clickDragThreshold" | "ariaLabelledBy" | "ariaValue"> & React.RefAttributes<Element>>;
5
5
  export default InternalDragHandle;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,iFAqDvB,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,kaAyDvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -6,10 +6,10 @@ import { getBaseProps } from '../../base-component';
6
6
  import DragHandleWrapper from '../drag-handle-wrapper';
7
7
  import DragHandleButton from './button';
8
8
  const InternalDragHandle = forwardRef((_a, ref) => {
9
- var { variant, size, ariaLabel, ariaLabelledBy, ariaDescribedby, tooltipText, ariaValue, disabled, directions = {}, onPointerDown, onKeyDown, onDirectionClick, triggerMode, initialShowButtons, hideButtonsOnDrag = false, clickDragThreshold = 3, active } = _a, rest = __rest(_a, ["variant", "size", "ariaLabel", "ariaLabelledBy", "ariaDescribedby", "tooltipText", "ariaValue", "disabled", "directions", "onPointerDown", "onKeyDown", "onDirectionClick", "triggerMode", "initialShowButtons", "hideButtonsOnDrag", "clickDragThreshold", "active"]);
9
+ var { variant, size, ariaLabel, ariaLabelledBy, ariaDescribedby, tooltipText, ariaValue, disabled, directions = {}, onPointerDown, onClick, onKeyDown, onDirectionClick, triggerMode, initialShowButtons, controlledShowButtons, hideButtonsOnDrag = false, clickDragThreshold = 3, active } = _a, rest = __rest(_a, ["variant", "size", "ariaLabel", "ariaLabelledBy", "ariaDescribedby", "tooltipText", "ariaValue", "disabled", "directions", "onPointerDown", "onClick", "onKeyDown", "onDirectionClick", "triggerMode", "initialShowButtons", "controlledShowButtons", "hideButtonsOnDrag", "clickDragThreshold", "active"]);
10
10
  const baseProps = getBaseProps(rest);
11
- return (React.createElement(DragHandleWrapper, { directions: !disabled ? directions : {}, tooltipText: tooltipText, onDirectionClick: onDirectionClick, triggerMode: triggerMode, initialShowButtons: initialShowButtons, hideButtonsOnDrag: hideButtonsOnDrag, clickDragThreshold: clickDragThreshold },
12
- React.createElement(DragHandleButton, { ref: ref, className: baseProps.className, variant: variant, size: size, ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy, ariaDescribedby: ariaDescribedby, ariaValue: ariaValue, disabled: disabled, active: active, onPointerDown: onPointerDown, onKeyDown: onKeyDown })));
11
+ return (React.createElement(DragHandleWrapper, { directions: !disabled ? directions : {}, tooltipText: tooltipText, onDirectionClick: onDirectionClick, triggerMode: triggerMode, initialShowButtons: initialShowButtons, controlledShowButtons: controlledShowButtons, hideButtonsOnDrag: hideButtonsOnDrag, clickDragThreshold: clickDragThreshold },
12
+ React.createElement(DragHandleButton, { ref: ref, className: baseProps.className, variant: variant, size: size, ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy, ariaDescribedby: ariaDescribedby, ariaValue: ariaValue, disabled: disabled, active: active, onPointerDown: onPointerDown, onClick: onClick, onKeyDown: onKeyDown })));
13
13
  });
14
14
  export default InternalDragHandle;
15
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,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,EAmBkB,EAClB,GAAuB,EACvB,EAAE;QArBF,EACE,OAAO,EACP,IAAI,EACJ,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EACX,SAAS,EACT,QAAQ,EACR,UAAU,GAAG,EAAE,EACf,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,GAAG,KAAK,EACzB,kBAAkB,GAAG,CAAC,EACtB,MAAM,OAEU,EADb,IAAI,cAlBT,uQAmBC,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,EAClC,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,kBAAkB,EACtC,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB;QAEtC,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,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,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 ariaLabelledBy,\n ariaDescribedby,\n tooltipText,\n ariaValue,\n disabled,\n directions = {},\n onPointerDown,\n onKeyDown,\n onDirectionClick,\n triggerMode,\n initialShowButtons,\n hideButtonsOnDrag = false,\n clickDragThreshold = 3,\n active,\n ...rest\n }: DragHandleProps,\n ref: React.Ref<Element>\n ) => {\n const baseProps = getBaseProps(rest);\n\n return (\n <DragHandleWrapper\n directions={!disabled ? directions : {}}\n tooltipText={tooltipText}\n onDirectionClick={onDirectionClick}\n triggerMode={triggerMode}\n initialShowButtons={initialShowButtons}\n hideButtonsOnDrag={hideButtonsOnDrag}\n clickDragThreshold={clickDragThreshold}\n >\n <DragHandleButton\n ref={ref}\n className={baseProps.className}\n variant={variant}\n size={size}\n ariaLabel={ariaLabel}\n ariaLabelledBy={ariaLabelledBy}\n ariaDescribedby={ariaDescribedby}\n ariaValue={ariaValue}\n disabled={disabled}\n active={active}\n onPointerDown={onPointerDown}\n onKeyDown={onKeyDown}\n />\n </DragHandleWrapper>\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,EAqBkB,EAClB,GAAuB,EACvB,EAAE;QAvBF,EACE,OAAO,EACP,IAAI,EACJ,SAAS,EACT,cAAc,EACd,eAAe,EACf,WAAW,EACX,SAAS,EACT,QAAQ,EACR,UAAU,GAAG,EAAE,EACf,aAAa,EACb,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,GAAG,KAAK,EACzB,kBAAkB,GAAG,CAAC,EACtB,MAAM,OAEU,EADb,IAAI,cApBT,2SAqBC,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,EAClC,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,kBAAkB,EACtC,qBAAqB,EAAE,qBAAqB,EAC5C,iBAAiB,EAAE,iBAAiB,EACpC,kBAAkB,EAAE,kBAAkB;QAEtC,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,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,OAAO,EAChB,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 ariaLabelledBy,\n ariaDescribedby,\n tooltipText,\n ariaValue,\n disabled,\n directions = {},\n onPointerDown,\n onClick,\n onKeyDown,\n onDirectionClick,\n triggerMode,\n initialShowButtons,\n controlledShowButtons,\n hideButtonsOnDrag = false,\n clickDragThreshold = 3,\n active,\n ...rest\n }: DragHandleProps,\n ref: React.Ref<Element>\n ) => {\n const baseProps = getBaseProps(rest);\n\n return (\n <DragHandleWrapper\n directions={!disabled ? directions : {}}\n tooltipText={tooltipText}\n onDirectionClick={onDirectionClick}\n triggerMode={triggerMode}\n initialShowButtons={initialShowButtons}\n controlledShowButtons={controlledShowButtons}\n hideButtonsOnDrag={hideButtonsOnDrag}\n clickDragThreshold={clickDragThreshold}\n >\n <DragHandleButton\n ref={ref}\n className={baseProps.className}\n variant={variant}\n size={size}\n ariaLabel={ariaLabel}\n ariaLabelledBy={ariaLabelledBy}\n ariaDescribedby={ariaDescribedby}\n ariaValue={ariaValue}\n disabled={disabled}\n active={active}\n onPointerDown={onPointerDown}\n onClick={onClick}\n onKeyDown={onKeyDown}\n />\n </DragHandleWrapper>\n );\n }\n);\n\nexport default InternalDragHandle;\n"]}
@@ -12,11 +12,13 @@ export interface DragHandleProps {
12
12
  className?: string;
13
13
  onPointerDown?: React.PointerEventHandler;
14
14
  onKeyDown?: React.KeyboardEventHandler;
15
+ onClick?: React.MouseEventHandler;
15
16
  tooltipText?: string;
16
17
  directions?: Partial<Record<DragHandleProps.Direction, DragHandleProps.DirectionState>>;
17
18
  onDirectionClick?: (direction: DragHandleProps.Direction) => void;
18
19
  triggerMode?: TriggerMode;
19
20
  initialShowButtons?: boolean;
21
+ controlledShowButtons?: boolean;
20
22
  /**
21
23
  * Hide the UAP buttons when dragging is active.
22
24
  */
@@ -26,6 +28,7 @@ export interface DragHandleProps {
26
28
  * a drag. Small threshold needed for usability.
27
29
  */
28
30
  clickDragThreshold?: number;
31
+ ref?: React.RefObject<HTMLElement>;
29
32
  }
30
33
  export declare namespace DragHandleProps {
31
34
  type Variant = 'drag-indicator' | 'resize-area' | 'resize-horizontal' | 'resize-vertical';
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/interfaces.ts"],"names":[],"mappings":";AAGA,OAAO,EACL,SAAS,IAAI,gBAAgB,EAC7B,cAAc,IAAI,qBAAqB,EACvC,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC;IAClC,IAAI,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE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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;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\nimport {\n Direction as WrapperDirection,\n DirectionState as WrapperDirectionState,\n TriggerMode,\n} from '../drag-handle-wrapper/interfaces';\n\nexport interface DragHandleProps {\n variant?: DragHandleProps.Variant;\n size?: DragHandleProps.Size;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n ariaDescribedby?: string;\n ariaValue?: DragHandleProps.AriaValue;\n active?: boolean;\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 triggerMode?: TriggerMode;\n initialShowButtons?: boolean;\n /**\n * Hide the UAP buttons when dragging is active.\n */\n hideButtonsOnDrag?: boolean;\n /**\n * Max cursor movement (in pixels) that still counts as a press rather than\n * a drag. Small threshold needed for usability.\n */\n clickDragThreshold?: number;\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"]}
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 TriggerMode,\n} from '../drag-handle-wrapper/interfaces';\n\nexport interface DragHandleProps {\n variant?: DragHandleProps.Variant;\n size?: DragHandleProps.Size;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n ariaDescribedby?: string;\n ariaValue?: DragHandleProps.AriaValue;\n active?: boolean;\n disabled?: boolean;\n className?: string;\n onPointerDown?: React.PointerEventHandler;\n onKeyDown?: React.KeyboardEventHandler;\n onClick?: React.MouseEventHandler;\n\n tooltipText?: string;\n directions?: Partial<Record<DragHandleProps.Direction, DragHandleProps.DirectionState>>;\n onDirectionClick?: (direction: DragHandleProps.Direction) => void;\n triggerMode?: TriggerMode;\n initialShowButtons?: boolean;\n controlledShowButtons?: boolean;\n /**\n * Hide the UAP buttons when dragging is active.\n */\n hideButtonsOnDrag?: boolean;\n /**\n * Max cursor movement (in pixels) that still counts as a press rather than\n * a drag. Small threshold needed for usability.\n */\n clickDragThreshold?: number;\n ref?: React.RefObject<HTMLElement>;\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"]}
@@ -1,18 +1,19 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "handle": "awsui_handle_sdha6_91agl_145",
5
- "handle-size-normal": "awsui_handle-size-normal_sdha6_91agl_153",
6
- "handle-size-small": "awsui_handle-size-small_sdha6_91agl_157",
7
- "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_91agl_160",
8
- "handle-disabled": "awsui_handle-disabled_sdha6_91agl_160",
9
- "active": "awsui_active_sdha6_91agl_163",
10
- "handle-resize-area": "awsui_handle-resize-area_sdha6_91agl_166",
11
- "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_91agl_173",
12
- "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_91agl_176",
13
- "hide-focus": "awsui_hide-focus_sdha6_91agl_186",
14
- "resize-icon": "awsui_resize-icon_sdha6_91agl_208",
15
- "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_91agl_214",
16
- "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_91agl_218"
4
+ "handle": "awsui_handle_sdha6_13tiu_145",
5
+ "handle-size-normal": "awsui_handle-size-normal_sdha6_13tiu_153",
6
+ "handle-size-small": "awsui_handle-size-small_sdha6_13tiu_157",
7
+ "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_13tiu_160",
8
+ "handle-disabled": "awsui_handle-disabled_sdha6_13tiu_160",
9
+ "active": "awsui_active_sdha6_13tiu_163",
10
+ "handle-resize-area": "awsui_handle-resize-area_sdha6_13tiu_166",
11
+ "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_13tiu_173",
12
+ "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_13tiu_176",
13
+ "hide-focus": "awsui_hide-focus_sdha6_13tiu_186",
14
+ "resize-icon": "awsui_resize-icon_sdha6_13tiu_208",
15
+ "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_13tiu_214",
16
+ "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_13tiu_218",
17
+ "prevent-pointer": "awsui_prevent-pointer_sdha6_13tiu_222"
17
18
  };
18
19
 
@@ -142,7 +142,7 @@
142
142
  */
143
143
  /* Style used for links in slots/components that are text heavy, to help links stand out among
144
144
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
145
- .awsui_handle_sdha6_91agl_145:not(#\9) {
145
+ .awsui_handle_sdha6_13tiu_145:not(#\9) {
146
146
  appearance: none;
147
147
  color: var(--color-text-interactive-default-qwoe3g, #545b64);
148
148
  background: transparent;
@@ -150,47 +150,47 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
150
150
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
151
151
  touch-action: none;
152
152
  }
153
- .awsui_handle-size-normal_sdha6_91agl_153:not(#\9) {
153
+ .awsui_handle-size-normal_sdha6_13tiu_153:not(#\9) {
154
154
  block-size: var(--line-height-body-m-bedeoh, 22px);
155
155
  padding-inline: var(--space-scaled-xxxs-prgw5k, 2px);
156
156
  }
157
- .awsui_handle-size-small_sdha6_91agl_157:not(#\9) {
157
+ .awsui_handle-size-small_sdha6_13tiu_157:not(#\9) {
158
158
  block-size: var(--line-height-body-s-otgtsr, 16px);
159
159
  }
160
- .awsui_handle-drag-indicator_sdha6_91agl_160:not(#\9):not(.awsui_handle-disabled_sdha6_91agl_160) {
160
+ .awsui_handle-drag-indicator_sdha6_13tiu_160:not(#\9):not(.awsui_handle-disabled_sdha6_13tiu_160) {
161
161
  cursor: grab;
162
162
  }
163
- .awsui_handle-drag-indicator_sdha6_91agl_160:not(#\9):not(.awsui_handle-disabled_sdha6_91agl_160).awsui_active_sdha6_91agl_163 {
163
+ .awsui_handle-drag-indicator_sdha6_13tiu_160:not(#\9):not(.awsui_handle-disabled_sdha6_13tiu_160).awsui_active_sdha6_13tiu_163 {
164
164
  cursor: grabbing;
165
165
  }
166
- .awsui_handle-resize-area_sdha6_91agl_166:not(#\9) {
166
+ .awsui_handle-resize-area_sdha6_13tiu_166:not(#\9) {
167
167
  cursor: nwse-resize;
168
168
  /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
169
169
  }
170
- .awsui_handle-resize-area_sdha6_91agl_166:not(#\9):dir(rtl) {
170
+ .awsui_handle-resize-area_sdha6_13tiu_166:not(#\9):dir(rtl) {
171
171
  cursor: nesw-resize;
172
172
  }
173
- .awsui_handle-resize-horizontal_sdha6_91agl_173:not(#\9) {
173
+ .awsui_handle-resize-horizontal_sdha6_13tiu_173:not(#\9) {
174
174
  cursor: ew-resize;
175
175
  }
176
- .awsui_handle-resize-vertical_sdha6_91agl_176:not(#\9) {
176
+ .awsui_handle-resize-vertical_sdha6_13tiu_176:not(#\9) {
177
177
  cursor: ns-resize;
178
178
  }
179
- .awsui_handle_sdha6_91agl_145:not(#\9):hover {
179
+ .awsui_handle_sdha6_13tiu_145:not(#\9):hover {
180
180
  color: var(--color-text-interactive-hover-bu4gls, #16191f);
181
181
  }
182
- .awsui_handle_sdha6_91agl_145:not(#\9):focus {
182
+ .awsui_handle_sdha6_13tiu_145:not(#\9):focus {
183
183
  outline: none;
184
184
  text-decoration: none;
185
185
  }
186
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_91agl_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_91agl_186) {
186
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_13tiu_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_13tiu_186) {
187
187
  position: relative;
188
188
  }
189
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_91agl_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_91agl_186) {
189
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_13tiu_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_13tiu_186) {
190
190
  outline: 2px dotted transparent;
191
191
  outline-offset: calc(0px - 1px);
192
192
  }
193
- body[data-awsui-focus-visible=true] .awsui_handle_sdha6_91agl_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_91agl_186)::before {
193
+ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_13tiu_145:not(#\9):focus:not(.awsui_hide-focus_sdha6_13tiu_186)::before {
194
194
  content: " ";
195
195
  display: block;
196
196
  position: absolute;
@@ -205,16 +205,20 @@ body[data-awsui-focus-visible=true] .awsui_handle_sdha6_91agl_145:not(#\9):focus
205
205
  box-shadow: 0 0 0 2px var(--color-border-item-focused-r5f6xl, #0073bb);
206
206
  }
207
207
 
208
- .awsui_resize-icon_sdha6_91agl_208:not(#\9) {
208
+ .awsui_resize-icon_sdha6_13tiu_208:not(#\9) {
209
209
  stroke: var(--color-text-interactive-default-qwoe3g, #545b64);
210
210
  }
211
- .awsui_resize-icon_sdha6_91agl_208:not(#\9):hover {
211
+ .awsui_resize-icon_sdha6_13tiu_208:not(#\9):hover {
212
212
  stroke: var(--color-text-interactive-hover-bu4gls, #16191f);
213
213
  }
214
- .awsui_resize-icon-vertical_sdha6_91agl_214:not(#\9) {
214
+ .awsui_resize-icon-vertical_sdha6_13tiu_214:not(#\9) {
215
215
  margin-block: auto;
216
216
  margin-inline: auto;
217
217
  }
218
- .awsui_resize-icon-horizontal_sdha6_91agl_218:not(#\9) {
218
+ .awsui_resize-icon-horizontal_sdha6_13tiu_218:not(#\9) {
219
219
  transform: rotate(90deg);
220
+ }
221
+
222
+ .awsui_prevent-pointer_sdha6_13tiu_222:not(#\9) {
223
+ pointer-events: none;
220
224
  }
@@ -2,18 +2,19 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "handle": "awsui_handle_sdha6_91agl_145",
6
- "handle-size-normal": "awsui_handle-size-normal_sdha6_91agl_153",
7
- "handle-size-small": "awsui_handle-size-small_sdha6_91agl_157",
8
- "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_91agl_160",
9
- "handle-disabled": "awsui_handle-disabled_sdha6_91agl_160",
10
- "active": "awsui_active_sdha6_91agl_163",
11
- "handle-resize-area": "awsui_handle-resize-area_sdha6_91agl_166",
12
- "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_91agl_173",
13
- "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_91agl_176",
14
- "hide-focus": "awsui_hide-focus_sdha6_91agl_186",
15
- "resize-icon": "awsui_resize-icon_sdha6_91agl_208",
16
- "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_91agl_214",
17
- "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_91agl_218"
5
+ "handle": "awsui_handle_sdha6_13tiu_145",
6
+ "handle-size-normal": "awsui_handle-size-normal_sdha6_13tiu_153",
7
+ "handle-size-small": "awsui_handle-size-small_sdha6_13tiu_157",
8
+ "handle-drag-indicator": "awsui_handle-drag-indicator_sdha6_13tiu_160",
9
+ "handle-disabled": "awsui_handle-disabled_sdha6_13tiu_160",
10
+ "active": "awsui_active_sdha6_13tiu_163",
11
+ "handle-resize-area": "awsui_handle-resize-area_sdha6_13tiu_166",
12
+ "handle-resize-horizontal": "awsui_handle-resize-horizontal_sdha6_13tiu_173",
13
+ "handle-resize-vertical": "awsui_handle-resize-vertical_sdha6_13tiu_176",
14
+ "hide-focus": "awsui_hide-focus_sdha6_13tiu_186",
15
+ "resize-icon": "awsui_resize-icon_sdha6_13tiu_208",
16
+ "resize-icon-vertical": "awsui_resize-icon-vertical_sdha6_13tiu_214",
17
+ "resize-icon-horizontal": "awsui_resize-icon-horizontal_sdha6_13tiu_218",
18
+ "prevent-pointer": "awsui_prevent-pointer_sdha6_13tiu_222"
18
19
  };
19
20
 
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { DragHandleWrapperProps } from './interfaces';
3
- export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode, initialShowButtons, hideButtonsOnDrag, clickDragThreshold, }: DragHandleWrapperProps): JSX.Element;
3
+ export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode, initialShowButtons, controlledShowButtons, hideButtonsOnDrag, clickDragThreshold, }: DragHandleWrapperProps): JSX.Element;
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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;AAKjE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAqB,EACrB,kBAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,GACnB,EAAE,sBAAsB,eAsNxB"}
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;AAKjE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAqB,EACrB,kBAA0B,EAC1B,qBAA6B,EAC7B,iBAAiB,EACjB,kBAAkB,GACnB,EAAE,sBAAsB,eAwNxB"}
@@ -8,7 +8,7 @@ import Tooltip from '../tooltip';
8
8
  import DirectionButton from './direction-button';
9
9
  import PortalOverlay from './portal-overlay';
10
10
  import styles from './styles.css.js';
11
- export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode = 'focus', initialShowButtons = false, hideButtonsOnDrag, clickDragThreshold, }) {
11
+ export default function DragHandleWrapper({ directions, tooltipText, children, onDirectionClick, triggerMode = 'focus', initialShowButtons = false, controlledShowButtons = false, hideButtonsOnDrag, clickDragThreshold, }) {
12
12
  const wrapperRef = useRef(null);
13
13
  const dragHandleRef = useRef(null);
14
14
  const [showTooltip, setShowTooltip] = useState(false);
@@ -118,7 +118,7 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
118
118
  event.key !== 'Control' &&
119
119
  event.key !== 'Meta' &&
120
120
  event.key !== 'Shift' &&
121
- triggerMode !== 'keyboard-activate') {
121
+ triggerMode === 'focus') {
122
122
  // Pressing any other key will display the focus-visible ring around the
123
123
  // drag handle if it's in focus, so we should also show the buttons now.
124
124
  setShowButtons(true);
@@ -134,14 +134,15 @@ export default function DragHandleWrapper({ directions, tooltipText, children, o
134
134
  }
135
135
  onDirectionClick === null || onDirectionClick === void 0 ? void 0 : onDirectionClick(direction);
136
136
  };
137
- return (React.createElement("div", { className: clsx(styles['drag-handle-wrapper'], showButtons && styles['drag-handle-wrapper-open']), ref: wrapperRef, onFocus: onWrapperFocusIn, onBlur: onWrapperFocusOut },
137
+ const _showButtons = triggerMode === 'controlled' ? controlledShowButtons : showButtons;
138
+ return (React.createElement("div", { className: clsx(styles['drag-handle-wrapper'], _showButtons && styles['drag-handle-wrapper-open']), ref: wrapperRef, onFocus: onWrapperFocusIn, onBlur: onWrapperFocusOut },
138
139
  React.createElement("div", { onPointerEnter: onTooltipGroupPointerEnter, onPointerLeave: onTooltipGroupPointerLeave },
139
140
  React.createElement("div", { className: styles['drag-handle'], ref: dragHandleRef, onPointerDown: onHandlePointerDown, onKeyDown: onDragHandleKeyDown }, children),
140
- !isDisabled && !showButtons && showTooltip && tooltipText && (React.createElement(Tooltip, { trackRef: dragHandleRef, value: tooltipText, onDismiss: () => setShowTooltip(false) }))),
141
- React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !showButtons },
142
- directions['block-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-start", state: directions['block-start'], onClick: () => onInternalDirectionClick('block-start') })),
143
- directions['block-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "block-end", state: directions['block-end'], onClick: () => onInternalDirectionClick('block-end') })),
144
- directions['inline-start'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-start", state: directions['inline-start'], onClick: () => onInternalDirectionClick('inline-start') })),
145
- directions['inline-end'] && (React.createElement(DirectionButton, { show: !isDisabled && showButtons, direction: "inline-end", state: directions['inline-end'], onClick: () => onInternalDirectionClick('inline-end') })))));
141
+ !isDisabled && !_showButtons && showTooltip && tooltipText && (React.createElement(Tooltip, { trackRef: dragHandleRef, value: tooltipText, onDismiss: () => setShowTooltip(false) }))),
142
+ React.createElement(PortalOverlay, { track: dragHandleRef, isDisabled: !_showButtons },
143
+ directions['block-start'] && (React.createElement(DirectionButton, { show: !isDisabled && _showButtons, direction: "block-start", state: directions['block-start'], onClick: () => onInternalDirectionClick('block-start') })),
144
+ directions['block-end'] && (React.createElement(DirectionButton, { show: !isDisabled && _showButtons, direction: "block-end", state: directions['block-end'], onClick: () => onInternalDirectionClick('block-end') })),
145
+ directions['inline-start'] && (React.createElement(DirectionButton, { show: !isDisabled && _showButtons, direction: "inline-start", state: directions['inline-start'], onClick: () => onInternalDirectionClick('inline-start') })),
146
+ directions['inline-end'] && (React.createElement(DirectionButton, { show: !isDisabled && _showButtons, direction: "inline-end", state: directions['inline-end'], onClick: () => onInternalDirectionClick('inline-end') })))));
146
147
  }
147
148
  //# sourceMappingURL=index.js.map
@@ -1 +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,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAAG,OAAO,EACrB,kBAAkB,GAAG,KAAK,EAC1B,iBAAiB,EACjB,kBAAkB,GACK;IACvB,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CAAC,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AAS,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,GAAI,CACjG,CACG;QAEN,oBAAC,aAAa,IAAC,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC,WAAW;YAC1D,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\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [showButtons, setShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(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. In cases where focus is moved\n // to the button (by manually calling `.focus()`, the buttons should only appear)\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setShowButtons(true);\n }\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 useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // 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 // `clickDragThreshold` 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 + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setShowButtons(false);\n }\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 }, [clickDragThreshold, hideButtonsOnDrag]);\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 always close the floating controls.\n if (event.key === 'Escape') {\n setShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setShowButtons(prevshowButtons => !prevshowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode !== 'keyboard-activate'\n ) {\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} isDisabled={!showButtons}>\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"]}
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,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,eAAe,MAAM,oBAAoB,CAAC;AAEjD,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,WAAW,GAAG,OAAO,EACrB,kBAAkB,GAAG,KAAK,EAC1B,qBAAqB,GAAG,KAAK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AU,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\nexport default function DragHandleWrapper({\n directions,\n tooltipText,\n children,\n onDirectionClick,\n triggerMode = 'focus',\n initialShowButtons = false,\n controlledShowButtons = false,\n hideButtonsOnDrag,\n clickDragThreshold,\n}: DragHandleWrapperProps) {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLDivElement | null>(null);\n const [showTooltip, setShowTooltip] = useState(false);\n const [showButtons, setShowButtons] = useState(initialShowButtons);\n\n const isPointerDown = useRef(false);\n const initialPointerPosition = useRef<{ x: number; y: number } | undefined>();\n const didPointerDrag = useRef(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. In cases where focus is moved\n // to the button (by manually calling `.focus()`, the buttons should only appear)\n // if the action that triggered the focus move was the result of a keypress.\n if (document.body.dataset.awsuiFocusVisible && !nodeContains(wrapperRef.current, event.relatedTarget)) {\n setShowTooltip(false);\n if (triggerMode === 'focus') {\n setShowButtons(true);\n }\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 useEffect(() => {\n const controller = new AbortController();\n\n // We need to differentiate between a \"click\" and a \"drag\" action.\n // We can say a \"click\" happens when a \"pointerdown\" is followed by\n // 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 // `clickDragThreshold` 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 + clickDragThreshold ||\n event.clientX < initialPointerPosition.current.x - clickDragThreshold ||\n event.clientY > initialPointerPosition.current.y + clickDragThreshold ||\n event.clientY < initialPointerPosition.current.y - clickDragThreshold)\n ) {\n didPointerDrag.current = true;\n if (hideButtonsOnDrag) {\n setShowButtons(false);\n }\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 }, [clickDragThreshold, hideButtonsOnDrag]);\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 always close the floating controls.\n if (event.key === 'Escape') {\n setShowButtons(false);\n } else if (triggerMode === 'keyboard-activate' && (event.key === 'Enter' || event.key === ' ')) {\n // toggle buttons when Enter or space is pressed in 'keyboard-activate' triggerMode\n setShowButtons(prevshowButtons => !prevshowButtons);\n } else if (\n event.key !== 'Alt' &&\n event.key !== 'Control' &&\n event.key !== 'Meta' &&\n event.key !== 'Shift' &&\n triggerMode === 'focus'\n ) {\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 const _showButtons = triggerMode === 'controlled' ? controlledShowButtons : showButtons;\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} isDisabled={!_showButtons}>\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"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  export type Direction = 'block-start' | 'block-end' | 'inline-start' | 'inline-end';
3
3
  export type DirectionState = 'active' | 'disabled';
4
- export type TriggerMode = 'focus' | 'keyboard-activate';
4
+ export type TriggerMode = 'focus' | 'keyboard-activate' | 'controlled';
5
5
  export interface DragHandleWrapperProps {
6
6
  directions: Partial<Record<Direction, DirectionState>>;
7
7
  onDirectionClick?: (direction: Direction) => void;
@@ -9,6 +9,7 @@ export interface DragHandleWrapperProps {
9
9
  children: React.ReactNode;
10
10
  triggerMode?: TriggerMode;
11
11
  initialShowButtons?: boolean;
12
+ controlledShowButtons?: boolean;
12
13
  hideButtonsOnDrag: boolean;
13
14
  clickDragThreshold: number;
14
15
  }
@@ -1 +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;AACnD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAExD,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;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
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;AACnD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,mBAAmB,GAAG,YAAY,CAAC;AAEvE,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;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
@@ -1 +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';\nexport type TriggerMode = 'focus' | 'keyboard-activate';\n\nexport interface DragHandleWrapperProps {\n directions: Partial<Record<Direction, DirectionState>>;\n onDirectionClick?: (direction: Direction) => void;\n tooltipText?: string;\n children: React.ReactNode;\n triggerMode?: TriggerMode;\n initialShowButtons?: boolean;\n hideButtonsOnDrag: boolean;\n clickDragThreshold: number;\n}\n"]}
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';\nexport type TriggerMode = 'focus' | 'keyboard-activate' | 'controlled';\n\nexport interface DragHandleWrapperProps {\n directions: Partial<Record<Direction, DirectionState>>;\n onDirectionClick?: (direction: Direction) => void;\n tooltipText?: string;\n children: React.ReactNode;\n triggerMode?: TriggerMode;\n initialShowButtons?: boolean;\n controlledShowButtons?: boolean;\n hideButtonsOnDrag: boolean;\n clickDragThreshold: number;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/index.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAI,EAAE,EACzC,KAAK,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,GACZ,EAAE,iBAAiB,CAAC,IAAI,CAAC,eA8EzB;AA2ED,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,GACpD,iBAAiB,CAAC,mBAAmB,CAEvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/sortable-area/index.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,IAAI,EAAE,EACzC,KAAK,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,WAAW,GACZ,EAAE,iBAAiB,CAAC,IAAI,CAAC,eAiFzB;AA+FD,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC,GACpD,iBAAiB,CAAC,mBAAmB,CAEvC"}
@@ -8,12 +8,13 @@ import clsx from 'clsx';
8
8
  import { Portal } from '@cloudscape-design/component-toolkit/internal';
9
9
  import { fireNonCancelableEvent } from '../../events';
10
10
  import { joinStrings } from '../../utils/strings';
11
+ import { EventName } from './keyboard-sensor/utilities/events';
11
12
  import useDragAndDropReorder from './use-drag-and-drop-reorder';
12
13
  import useLiveAnnouncements from './use-live-announcements';
13
14
  import styles from './styles.css.js';
14
15
  export default function SortableArea({ items, itemDefinition, renderItem, onItemsChange, disableReorder, i18nStrings, }) {
15
16
  var _a;
16
- const { activeItemId, setActiveItemId, collisionDetection, handleKeyDown, sensors } = useDragAndDropReorder({
17
+ const { activeItemId, setActiveItemId, collisionDetection, handleKeyDown, sensors, isKeyboard } = useDragAndDropReorder({
17
18
  items,
18
19
  itemDefinition,
19
20
  });
@@ -38,9 +39,9 @@ export default function SortableArea({ items, itemDefinition, renderItem, onItem
38
39
  fireNonCancelableEvent(onItemsChange, { items: arrayMove([...items], oldIndex, newIndex), movedItem });
39
40
  }
40
41
  }, onDragCancel: () => setActiveItemId(null) },
41
- React.createElement(SortableContext, { disabled: disableReorder, items: items.map(item => itemDefinition.id(item)), strategy: verticalListSortingStrategy }, items.map(item => (React.createElement(DraggableItem, { key: itemDefinition.id(item), item: item, itemDefinition: itemDefinition, renderItem: renderItem, onKeyDown: handleKeyDown, dragHandleAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.dragHandleAriaLabel })))),
42
+ React.createElement(SortableContext, { disabled: disableReorder, items: items.map(item => itemDefinition.id(item)), strategy: verticalListSortingStrategy }, items.map(item => (React.createElement(DraggableItem, { key: itemDefinition.id(item), item: item, itemDefinition: itemDefinition, showDirectionButtons: item === activeItem && isKeyboard.current, renderItem: renderItem, onKeyDown: handleKeyDown, dragHandleAriaLabel: i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.dragHandleAriaLabel })))),
42
43
  React.createElement(Portal, { container: portalContainer },
43
- React.createElement(DragOverlay, { className: clsx(styles['drag-overlay'], styles[`drag-overlay-${getBorderRadiusVariant(itemDefinition)}`]), dropAnimation: null, style: { zIndex: 5000 } }, activeItem &&
44
+ React.createElement(DragOverlay, { className: clsx(styles['drag-overlay'], styles[`drag-overlay-${getBorderRadiusVariant(itemDefinition)}`]), dropAnimation: null, style: { zIndex: 5000 }, transition: isKeyboard.current ? 'transform 250ms' : '' }, activeItem &&
44
45
  renderItem({
45
46
  item: activeItem,
46
47
  id: activeItemId.toString(),
@@ -71,7 +72,7 @@ function usePortalContainer() {
71
72
  }, []);
72
73
  return portalContainerRef.current;
73
74
  }
74
- function DraggableItem({ item, itemDefinition, dragHandleAriaLabel, onKeyDown, renderItem, }) {
75
+ function DraggableItem({ item, itemDefinition, dragHandleAriaLabel, showDirectionButtons, onKeyDown, renderItem, }) {
75
76
  var _a;
76
77
  const id = itemDefinition.id(item);
77
78
  const { isDragging, isSorting, listeners, setNodeRef, transform, attributes } = useSortable({
@@ -89,6 +90,7 @@ function DraggableItem({ item, itemDefinition, dragHandleAriaLabel, onKeyDown, r
89
90
  }
90
91
  } });
91
92
  const className = clsx(isDragging && clsx(styles.placeholder, styles[`placeholder-${getBorderRadiusVariant(itemDefinition)}`]), isSorting && styles.sorting);
93
+ const dragHandleRef = useRef(null);
92
94
  return (React.createElement(React.Fragment, null, renderItem({
93
95
  item,
94
96
  id,
@@ -98,7 +100,20 @@ function DraggableItem({ item, itemDefinition, dragHandleAriaLabel, onKeyDown, r
98
100
  isDropPlaceholder: isDragging,
99
101
  isSortingActive: isSorting,
100
102
  isDragGhost: false,
101
- dragHandleProps: Object.assign(Object.assign({}, dragHandleListeners), { ariaLabel: (_a = joinStrings(dragHandleAriaLabel, itemDefinition.label(item))) !== null && _a !== void 0 ? _a : '', ariaDescribedby: attributes['aria-describedby'], disabled: attributes['aria-disabled'] }),
103
+ dragHandleProps: Object.assign(Object.assign({}, dragHandleListeners), { ariaLabel: (_a = joinStrings(dragHandleAriaLabel, itemDefinition.label(item))) !== null && _a !== void 0 ? _a : '', ariaDescribedby: attributes['aria-describedby'], disabled: attributes['aria-disabled'], triggerMode: 'controlled', controlledShowButtons: showDirectionButtons, ref: dragHandleRef, directions: showDirectionButtons
104
+ ? {
105
+ 'block-start': 'active',
106
+ 'block-end': 'active',
107
+ }
108
+ : undefined, onDirectionClick: direction => {
109
+ var _a;
110
+ const event = new Event(direction === 'block-start' ? EventName.CustomUp : EventName.CustomDown, {
111
+ bubbles: true,
112
+ cancelable: true,
113
+ });
114
+ onKeyDown(event);
115
+ (_a = dragHandleRef.current) === null || _a === void 0 ? void 0 : _a.dispatchEvent(event);
116
+ } }),
102
117
  })));
103
118
  }
104
119
  export function getBorderRadiusVariant(itemDefinition) {