@cloudscape-design/components-themeable 3.0.936 → 3.0.937
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/code-editor/resizable-box/styles.scss +7 -15
- package/lib/internal/scss/internal/components/drag-handle-wrapper/motion.scss +190 -0
- package/lib/internal/scss/internal/components/drag-handle-wrapper/styles.scss +110 -0
- package/lib/internal/template/code-editor/index.d.ts.map +1 -1
- package/lib/internal/template/code-editor/index.js +2 -2
- package/lib/internal/template/code-editor/index.js.map +1 -1
- package/lib/internal/template/code-editor/interfaces.d.ts +2 -0
- package/lib/internal/template/code-editor/interfaces.d.ts.map +1 -1
- package/lib/internal/template/code-editor/interfaces.js.map +1 -1
- package/lib/internal/template/code-editor/pane.d.ts +3 -1
- package/lib/internal/template/code-editor/pane.d.ts.map +1 -1
- package/lib/internal/template/code-editor/pane.js +2 -2
- package/lib/internal/template/code-editor/pane.js.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/index.d.ts +3 -1
- package/lib/internal/template/code-editor/resizable-box/index.d.ts.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/index.js +40 -8
- package/lib/internal/template/code-editor/resizable-box/index.js.map +1 -1
- package/lib/internal/template/code-editor/resizable-box/styles.css.js +4 -3
- package/lib/internal/template/code-editor/resizable-box/styles.scoped.css +16 -37
- package/lib/internal/template/code-editor/resizable-box/styles.selectors.js +4 -3
- package/lib/internal/template/i18n/messages/all.all.js +1 -1
- package/lib/internal/template/i18n/messages/all.all.json +1 -1
- package/lib/internal/template/i18n/messages/all.ar.js +1 -1
- package/lib/internal/template/i18n/messages/all.ar.json +1 -1
- package/lib/internal/template/i18n/messages/all.de.js +1 -1
- package/lib/internal/template/i18n/messages/all.de.json +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.js +1 -1
- package/lib/internal/template/i18n/messages/all.en-GB.json +1 -1
- package/lib/internal/template/i18n/messages/all.en.js +1 -1
- package/lib/internal/template/i18n/messages/all.en.json +1 -1
- package/lib/internal/template/i18n/messages/all.es.js +1 -1
- package/lib/internal/template/i18n/messages/all.es.json +1 -1
- package/lib/internal/template/i18n/messages/all.fr.js +1 -1
- package/lib/internal/template/i18n/messages/all.fr.json +1 -1
- package/lib/internal/template/i18n/messages/all.id.js +1 -1
- package/lib/internal/template/i18n/messages/all.id.json +1 -1
- package/lib/internal/template/i18n/messages/all.it.js +1 -1
- package/lib/internal/template/i18n/messages/all.it.json +1 -1
- package/lib/internal/template/i18n/messages/all.ja.js +1 -1
- package/lib/internal/template/i18n/messages/all.ja.json +1 -1
- package/lib/internal/template/i18n/messages/all.ko.js +1 -1
- package/lib/internal/template/i18n/messages/all.ko.json +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.js +1 -1
- package/lib/internal/template/i18n/messages/all.pt-BR.json +1 -1
- package/lib/internal/template/i18n/messages/all.tr.js +1 -1
- package/lib/internal/template/i18n/messages/all.tr.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-CN.json +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.js +1 -1
- package/lib/internal/template/i18n/messages/all.zh-TW.json +1 -1
- package/lib/internal/template/i18n/messages-types.d.ts +2 -0
- package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
- package/lib/internal/template/i18n/messages-types.js.map +1 -1
- package/lib/internal/template/internal/base-component/styles.scoped.css +29 -0
- package/lib/internal/template/internal/components/drag-handle/button.d.ts +5 -0
- package/lib/internal/template/internal/components/drag-handle/button.d.ts.map +1 -0
- package/lib/internal/template/internal/components/drag-handle/button.js +35 -0
- package/lib/internal/template/internal/components/drag-handle/button.js.map +1 -0
- package/lib/internal/template/internal/components/drag-handle/index.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/index.js +6 -30
- package/lib/internal/template/internal/components/drag-handle/index.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts +7 -1
- package/lib/internal/template/internal/components/drag-handle/interfaces.d.ts.map +1 -1
- package/lib/internal/template/internal/components/drag-handle/interfaces.js.map +1 -1
- package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts +11 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js +30 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts +4 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +138 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts +10 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.d.ts.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.js +4 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/interfaces.js.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.d.ts +6 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.d.ts.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.js +56 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/portal-overlay.js.map +1 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.css.js +32 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.scoped.css +508 -0
- package/lib/internal/template/internal/components/drag-handle-wrapper/styles.selectors.js +33 -0
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/internal/generated/styles/tokens.d.ts +6 -0
- package/lib/internal/template/internal/generated/styles/tokens.js +6 -0
- package/lib/internal/template/internal/generated/theming/index.cjs +186 -0
- package/lib/internal/template/internal/generated/theming/index.js +186 -0
- package/lib/internal/template/internal/utils/pointer-events-mock.d.ts +5 -0
- package/lib/internal/template/internal/utils/pointer-events-mock.d.ts.map +1 -0
- package/lib/internal/template/internal/utils/pointer-events-mock.js +10 -0
- package/lib/internal/template/internal/utils/pointer-events-mock.js.map +1 -0
- package/package.json +1 -1
- package/lib/internal/scss/code-editor/assets/resize-handler.svg +0 -3
|
@@ -184,6 +184,12 @@
|
|
|
184
184
|
--color-background-button-primary-default-e50v6e:#0073bb;
|
|
185
185
|
--color-background-button-primary-disabled-femoov:#ffffff;
|
|
186
186
|
--color-background-button-primary-hover-288r60:#0a4a74;
|
|
187
|
+
--color-background-direction-button-active-wssyfi:#2a2e33;
|
|
188
|
+
--color-background-direction-button-default-5hblg2:#545b64;
|
|
189
|
+
--color-background-direction-button-disabled-m3uin1:#eaeded;
|
|
190
|
+
--color-background-direction-button-hover-nuoi33:#414750;
|
|
191
|
+
--color-text-direction-button-default-6q1q04:#ffffff;
|
|
192
|
+
--color-text-direction-button-disabled-rx60rf:#aab7b8;
|
|
187
193
|
--color-background-calendar-current-date-du8mmf:#f2f3f3;
|
|
188
194
|
--color-background-cell-shaded-wami5b:#f2f3f3;
|
|
189
195
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#687078;
|
|
@@ -835,6 +841,8 @@
|
|
|
835
841
|
--color-background-button-primary-default-e50v6e:#44b9d6;
|
|
836
842
|
--color-background-button-primary-disabled-femoov:#2a2e33;
|
|
837
843
|
--color-background-button-primary-hover-288r60:#00a1c9;
|
|
844
|
+
--color-background-direction-button-disabled-m3uin1:#2a2e33;
|
|
845
|
+
--color-text-direction-button-disabled-rx60rf:#687078;
|
|
838
846
|
--color-background-calendar-current-date-du8mmf:#16191f;
|
|
839
847
|
--color-background-cell-shaded-wami5b:#16191f;
|
|
840
848
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#879596;
|
|
@@ -1145,6 +1153,8 @@
|
|
|
1145
1153
|
--color-background-button-primary-default-e50v6e:#44b9d6;
|
|
1146
1154
|
--color-background-button-primary-disabled-femoov:#2a2e33;
|
|
1147
1155
|
--color-background-button-primary-hover-288r60:#00a1c9;
|
|
1156
|
+
--color-background-direction-button-disabled-m3uin1:#2a2e33;
|
|
1157
|
+
--color-text-direction-button-disabled-rx60rf:#687078;
|
|
1148
1158
|
--color-background-calendar-current-date-du8mmf:#16191f;
|
|
1149
1159
|
--color-background-cell-shaded-wami5b:#16191f;
|
|
1150
1160
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#879596;
|
|
@@ -1490,6 +1500,11 @@
|
|
|
1490
1500
|
--color-background-button-primary-default-e50v6e:#006ce0;
|
|
1491
1501
|
--color-background-button-primary-disabled-femoov:#ebebf0;
|
|
1492
1502
|
--color-background-button-primary-hover-288r60:#002b66;
|
|
1503
|
+
--color-background-direction-button-active-wssyfi:#232b37;
|
|
1504
|
+
--color-background-direction-button-default-5hblg2:#424650;
|
|
1505
|
+
--color-background-direction-button-disabled-m3uin1:#ebebf0;
|
|
1506
|
+
--color-background-direction-button-hover-nuoi33:#333843;
|
|
1507
|
+
--color-text-direction-button-disabled-rx60rf:#b4b4bb;
|
|
1493
1508
|
--color-background-calendar-current-date-du8mmf:#f3f3f7;
|
|
1494
1509
|
--color-background-cell-shaded-wami5b:#f6f6f9;
|
|
1495
1510
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#656871;
|
|
@@ -1860,6 +1875,8 @@
|
|
|
1860
1875
|
--color-background-button-primary-default-e50v6e:#42b4ff;
|
|
1861
1876
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
1862
1877
|
--color-background-button-primary-hover-288r60:#75cfff;
|
|
1878
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
1879
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
1863
1880
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
1864
1881
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
1865
1882
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -2135,6 +2152,8 @@
|
|
|
2135
2152
|
--color-background-button-primary-default-e50v6e:#42b4ff;
|
|
2136
2153
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
2137
2154
|
--color-background-button-primary-hover-288r60:#75cfff;
|
|
2155
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
2156
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
2138
2157
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
2139
2158
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
2140
2159
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -2342,6 +2361,8 @@
|
|
|
2342
2361
|
--color-background-button-primary-default-e50v6e:#42b4ff;
|
|
2343
2362
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
2344
2363
|
--color-background-button-primary-hover-288r60:#75cfff;
|
|
2364
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
2365
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
2345
2366
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
2346
2367
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
2347
2368
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -2545,6 +2566,8 @@
|
|
|
2545
2566
|
--color-background-button-primary-default-e50v6e:#42b4ff;
|
|
2546
2567
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
2547
2568
|
--color-background-button-primary-hover-288r60:#75cfff;
|
|
2569
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
2570
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
2548
2571
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
2549
2572
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
2550
2573
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -2762,6 +2785,8 @@
|
|
|
2762
2785
|
--color-background-button-primary-default-e50v6e:#42b4ff;
|
|
2763
2786
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
2764
2787
|
--color-background-button-primary-hover-288r60:#75cfff;
|
|
2788
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
2789
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
2765
2790
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
2766
2791
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
2767
2792
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -3183,6 +3208,8 @@
|
|
|
3183
3208
|
--color-background-button-primary-default-e50v6e:#dedee3;
|
|
3184
3209
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
3185
3210
|
--color-background-button-primary-hover-288r60:#ffffff;
|
|
3211
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
3212
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
3186
3213
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
3187
3214
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
3188
3215
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -3388,6 +3415,8 @@
|
|
|
3388
3415
|
--color-background-button-primary-default-e50v6e:#dedee3;
|
|
3389
3416
|
--color-background-button-primary-disabled-femoov:#232b37;
|
|
3390
3417
|
--color-background-button-primary-hover-288r60:#ffffff;
|
|
3418
|
+
--color-background-direction-button-disabled-m3uin1:#232b37;
|
|
3419
|
+
--color-text-direction-button-disabled-rx60rf:#656871;
|
|
3391
3420
|
--color-background-calendar-current-date-du8mmf:#333843;
|
|
3392
3421
|
--color-background-cell-shaded-wami5b:#1b232d;
|
|
3393
3422
|
--color-background-code-editor-gutter-active-line-default-ok7m7g:#8c8c94;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DragHandleProps } from './interfaces';
|
|
3
|
+
declare const DragHandleButton: React.ForwardRefExoticComponent<DragHandleProps & React.RefAttributes<DragHandleProps.Ref>>;
|
|
4
|
+
export default DragHandleButton;
|
|
5
|
+
//# sourceMappingURL=button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/drag-handle/button.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAMlD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/C,QAAA,MAAM,gBAAgB,6FA+DrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -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,O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,EAAE,CAAC,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,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,
|
|
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
|
|
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
|
|
9
|
-
import
|
|
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
|
|
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
|
-
|
|
15
|
-
|
|
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,
|
|
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
|
|
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,C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AAQ,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
|
|
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
|
package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts.map
ADDED
|
@@ -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,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe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X-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 @@
|
|
|
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,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,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,sBAAsB;AACtB,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,UAAU,EACV,WAAW,EACX,QAAQ,EACR,gBAAgB,GACO;IACvB,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAEvD,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CA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,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 @@
|
|
|
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 @@
|
|
|
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"}
|