@cloudscape-design/components 3.0.262 → 3.0.264
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/THIRD-PARTY-LICENSES +31 -0
- package/autosuggest/options-controller.d.ts +1 -1
- package/autosuggest/options-controller.d.ts.map +1 -1
- package/autosuggest/options-controller.js +22 -23
- package/autosuggest/options-controller.js.map +1 -1
- package/autosuggest/options-list.d.ts.map +1 -1
- package/autosuggest/options-list.js +1 -2
- package/autosuggest/options-list.js.map +1 -1
- package/button/internal.d.ts +0 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +1 -3
- package/button/internal.js.map +1 -1
- package/button/styles.css.js +18 -20
- package/button/styles.scoped.css +136 -298
- package/button/styles.selectors.js +18 -20
- package/collection-preferences/content-display/index.d.ts +9 -0
- package/collection-preferences/content-display/index.d.ts.map +1 -0
- package/collection-preferences/content-display/index.js +55 -0
- package/collection-preferences/content-display/index.js.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/defaults.d.ts +3 -0
- package/collection-preferences/content-display/keyboard-sensor/defaults.d.ts.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/defaults.js +9 -0
- package/collection-preferences/content-display/keyboard-sensor/defaults.js.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/index.d.ts +19 -0
- package/collection-preferences/content-display/keyboard-sensor/index.d.ts.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/index.js +126 -0
- package/collection-preferences/content-display/keyboard-sensor/index.js.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/events.d.ts +11 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/events.d.ts.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/events.js +14 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/events.js.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.d.ts +8 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.d.ts.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.js +17 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.js.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.d.ts +30 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.d.ts.map +1 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.js +95 -0
- package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.js.map +1 -0
- package/collection-preferences/content-display/sortable-item.d.ts +9 -0
- package/collection-preferences/content-display/sortable-item.d.ts.map +1 -0
- package/collection-preferences/content-display/sortable-item.js +52 -0
- package/collection-preferences/content-display/sortable-item.js.map +1 -0
- package/collection-preferences/content-display/styles.css.js +20 -0
- package/collection-preferences/content-display/styles.scoped.css +303 -0
- package/collection-preferences/content-display/styles.selectors.js +21 -0
- package/collection-preferences/content-display/use-drag-and-drop-reorder.d.ts +14 -0
- package/collection-preferences/content-display/use-drag-and-drop-reorder.d.ts.map +1 -0
- package/collection-preferences/content-display/use-drag-and-drop-reorder.js +144 -0
- package/collection-preferences/content-display/use-drag-and-drop-reorder.js.map +1 -0
- package/collection-preferences/content-display/use-live-announcements.d.ts +12 -0
- package/collection-preferences/content-display/use-live-announcements.d.ts.map +1 -0
- package/collection-preferences/content-display/use-live-announcements.js +40 -0
- package/collection-preferences/content-display/use-live-announcements.js.map +1 -0
- package/collection-preferences/content-display/utils.d.ts +9 -0
- package/collection-preferences/content-display/utils.d.ts.map +1 -0
- package/collection-preferences/content-display/utils.js +7 -0
- package/collection-preferences/content-display/utils.js.map +1 -0
- package/collection-preferences/index.d.ts +1 -1
- package/collection-preferences/index.d.ts.map +1 -1
- package/collection-preferences/index.js +15 -9
- package/collection-preferences/index.js.map +1 -1
- package/collection-preferences/interfaces.d.ts +47 -1
- package/collection-preferences/interfaces.d.ts.map +1 -1
- package/collection-preferences/interfaces.js.map +1 -1
- package/collection-preferences/styles.css.js +36 -21
- package/collection-preferences/styles.scoped.css +326 -22
- package/collection-preferences/styles.selectors.js +36 -21
- package/collection-preferences/utils.d.ts +1 -1
- package/collection-preferences/utils.d.ts.map +1 -1
- package/collection-preferences/utils.js +20 -9
- package/collection-preferences/utils.js.map +1 -1
- package/expandable-section/expandable-section-header.js +1 -1
- package/expandable-section/expandable-section-header.js.map +1 -1
- package/expandable-section/styles.css.js +24 -23
- package/expandable-section/styles.scoped.css +66 -44
- package/expandable-section/styles.selectors.js +24 -23
- package/file-upload/file-input/index.d.ts.map +1 -1
- package/file-upload/file-input/index.js +2 -1
- package/file-upload/file-input/index.js.map +1 -1
- package/file-upload/file-input/styles.css.js +4 -3
- package/file-upload/file-input/styles.scoped.css +107 -4
- package/file-upload/file-input/styles.selectors.js +4 -3
- package/internal/components/autosuggest-input/index.js +1 -1
- package/internal/components/autosuggest-input/index.js.map +1 -1
- package/internal/components/options-list/utils/test-indexes.d.ts +1 -1
- package/internal/components/options-list/utils/test-indexes.d.ts.map +1 -1
- package/internal/components/options-list/utils/test-indexes.js.map +1 -1
- package/internal/components/token-list/styles.css.js +9 -9
- package/internal/components/token-list/styles.scoped.css +22 -21
- package/internal/components/token-list/styles.selectors.js +9 -9
- package/internal/drag-handle/index.d.ts +9 -0
- package/internal/drag-handle/index.d.ts.map +1 -0
- package/internal/drag-handle/index.js +13 -0
- package/internal/drag-handle/index.js.map +1 -0
- package/internal/drag-handle/styles.css.js +6 -0
- package/internal/drag-handle/styles.scoped.css +13 -0
- package/internal/drag-handle/styles.selectors.js +7 -0
- package/internal/environment.js +1 -1
- package/internal/handle/index.d.ts +3 -0
- package/internal/handle/index.d.ts.map +1 -0
- package/internal/handle/index.js +14 -0
- package/internal/handle/index.js.map +1 -0
- package/internal/handle/styles.css.js +7 -0
- package/internal/handle/styles.scoped.css +125 -0
- package/internal/handle/styles.selectors.js +8 -0
- package/internal/manifest.json +1 -1
- package/package.json +4 -1
- package/table/body-cell/styles.css.js +23 -23
- package/table/body-cell/styles.scoped.css +59 -59
- package/table/body-cell/styles.selectors.js +23 -23
- package/table/interfaces.d.ts +16 -3
- package/table/interfaces.d.ts.map +1 -1
- package/table/interfaces.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +7 -5
- package/table/internal.js.map +1 -1
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js +3 -6
- package/table/thead.js.map +1 -1
- package/table/utils.d.ts +5 -0
- package/table/utils.d.ts.map +1 -1
- package/table/utils.js +23 -0
- package/table/utils.js.map +1 -1
- package/test-utils/dom/collection-preferences/content-display-preference.d.ts +37 -0
- package/test-utils/dom/collection-preferences/content-display-preference.js +62 -0
- package/test-utils/dom/collection-preferences/content-display-preference.js.map +1 -0
- package/test-utils/dom/collection-preferences/index.d.ts +2 -0
- package/test-utils/dom/collection-preferences/index.js +4 -0
- package/test-utils/dom/collection-preferences/index.js.map +1 -1
- package/test-utils/selectors/collection-preferences/content-display-preference.d.ts +37 -0
- package/test-utils/selectors/collection-preferences/content-display-preference.js +62 -0
- package/test-utils/selectors/collection-preferences/content-display-preference.js.map +1 -0
- package/test-utils/selectors/collection-preferences/index.d.ts +2 -0
- package/test-utils/selectors/collection-preferences/index.js +4 -0
- package/test-utils/selectors/collection-preferences/index.js.map +1 -1
- package/test-utils/tsconfig.tsbuildinfo +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.js +5 -4
- package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
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 { useSortable } from '@dnd-kit/sortable';
|
|
5
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
import styles from '../styles.css.js';
|
|
8
|
+
import DragHandle from '../../internal/drag-handle';
|
|
9
|
+
import InternalToggle from '../../toggle/internal';
|
|
10
|
+
import { useUniqueId } from '../../internal/hooks/use-unique-id';
|
|
11
|
+
const componentPrefix = 'sortable-item';
|
|
12
|
+
const getClassName = (suffix) => styles[`${componentPrefix}-${suffix}`];
|
|
13
|
+
export function SortableItem({ dragHandleAriaLabel, onKeyDown, onToggle, option, }) {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
const { isDragging, isSorting, listeners, over, rect, setNodeRef, transform } = useSortable({
|
|
16
|
+
id: option.id,
|
|
17
|
+
});
|
|
18
|
+
const style = {
|
|
19
|
+
transform: CSS.Translate.toString(transform),
|
|
20
|
+
};
|
|
21
|
+
const idPrefix = useUniqueId(componentPrefix);
|
|
22
|
+
const controlId = `${idPrefix}-control-${option.id}`;
|
|
23
|
+
const dragHandleAttributes = {
|
|
24
|
+
['aria-label']: [dragHandleAriaLabel, option.label].join(', '),
|
|
25
|
+
};
|
|
26
|
+
const combinedListeners = Object.assign(Object.assign({}, listeners), { onKeyDown: (event) => {
|
|
27
|
+
if (onKeyDown) {
|
|
28
|
+
onKeyDown(event);
|
|
29
|
+
}
|
|
30
|
+
if (listeners === null || listeners === void 0 ? void 0 : listeners.onKeyDown) {
|
|
31
|
+
listeners.onKeyDown(event);
|
|
32
|
+
}
|
|
33
|
+
} });
|
|
34
|
+
// The placeholder is rendered from within the dragged item, but is shown at the position of the displaced item.
|
|
35
|
+
// Therefore, we need to translate it by the right amount.
|
|
36
|
+
// Unfortunately we can't use dnd-kit's recommended approach of using a drag overlay
|
|
37
|
+
// because it renders out of place when drag and drop is used in our modal.
|
|
38
|
+
const placeholderOffsetY = isDragging && ((_a = over === null || over === void 0 ? void 0 : over.rect) === null || _a === void 0 ? void 0 : _a.top) !== undefined && ((_b = rect.current) === null || _b === void 0 ? void 0 : _b.top) !== undefined
|
|
39
|
+
? over.rect.top > ((_c = rect.current) === null || _c === void 0 ? void 0 : _c.top)
|
|
40
|
+
? over.rect.bottom - ((_d = rect.current) === null || _d === void 0 ? void 0 : _d.bottom)
|
|
41
|
+
: over.rect.top - ((_e = rect.current) === null || _e === void 0 ? void 0 : _e.top)
|
|
42
|
+
: undefined;
|
|
43
|
+
const placeholderStyle = placeholderOffsetY ? { transform: `translateY(${placeholderOffsetY}px)` } : undefined;
|
|
44
|
+
return (React.createElement("li", { className: clsx(styles['content-display-option'], styles['sortable-item']) },
|
|
45
|
+
isDragging && React.createElement("div", { className: getClassName('placeholder'), style: placeholderStyle }),
|
|
46
|
+
React.createElement("div", { ref: setNodeRef, className: clsx(getClassName('content'), styles.draggable, isDragging && styles.active, isSorting && styles.sorting), style: style },
|
|
47
|
+
React.createElement(DragHandle, { attributes: dragHandleAttributes, hideFocus: isDragging, listeners: combinedListeners }),
|
|
48
|
+
React.createElement("label", { className: getClassName('label'), htmlFor: controlId }, option.label),
|
|
49
|
+
React.createElement("div", { className: getClassName('toggle') },
|
|
50
|
+
React.createElement(InternalToggle, { checked: !!option.visible, onChange: () => onToggle(option), disabled: option.alwaysVisible === true, controlId: controlId })))));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=sortable-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable-item.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/sortable-item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,cAAc,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAGjE,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,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,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAChC,QAAQ,EAAE,MAAM,CAAC,aAAa,KAAK,IAAI,EACvC,SAAS,EAAE,SAAS,GACpB,CACE,CACF,CACH,CACN,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport clsx from 'clsx';\nimport styles from '../styles.css.js';\nimport DragHandle from '../../internal/drag-handle';\nimport InternalToggle from '../../toggle/internal';\nimport { useUniqueId } from '../../internal/hooks/use-unique-id';\nimport { OptionWithVisibility } from './utils';\n\nconst componentPrefix = 'sortable-item';\nconst getClassName = (suffix: string) => styles[`${componentPrefix}-${suffix}`];\n\nexport function SortableItem({\n dragHandleAriaLabel,\n onKeyDown,\n onToggle,\n option,\n}: {\n dragHandleAriaLabel?: string;\n onKeyDown?: (event: React.KeyboardEvent) => void;\n onToggle: (option: OptionWithVisibility) => void;\n option: OptionWithVisibility;\n}) {\n const { isDragging, isSorting, listeners, over, rect, setNodeRef, transform } = useSortable({\n id: option.id,\n });\n const style = {\n transform: CSS.Translate.toString(transform),\n };\n\n const idPrefix = useUniqueId(componentPrefix);\n const controlId = `${idPrefix}-control-${option.id}`;\n\n const dragHandleAttributes = {\n ['aria-label']: [dragHandleAriaLabel, option.label].join(', '),\n };\n\n const combinedListeners = {\n ...listeners,\n onKeyDown: (event: React.KeyboardEvent) => {\n if (onKeyDown) {\n onKeyDown(event);\n }\n if (listeners?.onKeyDown) {\n listeners.onKeyDown(event);\n }\n },\n };\n\n // The placeholder is rendered from within the dragged item, but is shown at the position of the displaced item.\n // Therefore, we need to translate it by the right amount.\n // Unfortunately we can't use dnd-kit's recommended approach of using a drag overlay\n // because it renders out of place when drag and drop is used in our modal.\n const placeholderOffsetY =\n isDragging && over?.rect?.top !== undefined && rect.current?.top !== undefined\n ? over.rect.top > rect.current?.top\n ? over.rect.bottom - rect.current?.bottom\n : over.rect.top - rect.current?.top\n : undefined;\n\n const placeholderStyle = placeholderOffsetY ? { transform: `translateY(${placeholderOffsetY}px)` } : undefined;\n\n return (\n <li className={clsx(styles['content-display-option'], styles['sortable-item'])}>\n {isDragging && <div className={getClassName('placeholder')} style={placeholderStyle} />}\n <div\n ref={setNodeRef}\n className={clsx(\n getClassName('content'),\n styles.draggable,\n isDragging && styles.active,\n isSorting && styles.sorting\n )}\n style={style}\n >\n <DragHandle attributes={dragHandleAttributes} hideFocus={isDragging} listeners={combinedListeners} />\n\n <label className={getClassName('label')} htmlFor={controlId}>\n {option.label}\n </label>\n <div className={getClassName('toggle')}>\n <InternalToggle\n checked={!!option.visible}\n onChange={() => onToggle(option)}\n disabled={option.alwaysVisible === true}\n controlId={controlId}\n />\n </div>\n </div>\n </li>\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import './styles.scoped.css';
|
|
3
|
+
export default {
|
|
4
|
+
"sortable-item-toggle": "awsui_sortable-item-toggle_1f3h0_1bra9_185",
|
|
5
|
+
"sortable-item": "awsui_sortable-item_1f3h0_1bra9_185",
|
|
6
|
+
"sortable-item-placeholder": "awsui_sortable-item-placeholder_1f3h0_1bra9_193",
|
|
7
|
+
"sortable-item-content": "awsui_sortable-item-content_1f3h0_1bra9_203",
|
|
8
|
+
"draggable": "awsui_draggable_1f3h0_1bra9_213",
|
|
9
|
+
"active": "awsui_active_1f3h0_1bra9_222",
|
|
10
|
+
"sorting": "awsui_sorting_1f3h0_1bra9_228",
|
|
11
|
+
"sortable-item-label": "awsui_sortable-item-label_1f3h0_1bra9_271",
|
|
12
|
+
"content-display": "awsui_content-display_1f3h0_1bra9_276",
|
|
13
|
+
"content-display-groups": "awsui_content-display-groups_1f3h0_1bra9_277",
|
|
14
|
+
"content-display-group": "awsui_content-display-group_1f3h0_1bra9_277",
|
|
15
|
+
"content-display-option": "awsui_content-display-option_1f3h0_1bra9_279",
|
|
16
|
+
"content-display-title": "awsui_content-display-title_1f3h0_1bra9_283",
|
|
17
|
+
"content-display-description": "awsui_content-display-description_1f3h0_1bra9_291",
|
|
18
|
+
"content-display-option-list": "awsui_content-display-option-list_1f3h0_1bra9_299"
|
|
19
|
+
};
|
|
20
|
+
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/*
|
|
6
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
/*
|
|
10
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
11
|
+
SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
*/
|
|
13
|
+
/*
|
|
14
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15
|
+
SPDX-License-Identifier: Apache-2.0
|
|
16
|
+
*/
|
|
17
|
+
/*
|
|
18
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19
|
+
SPDX-License-Identifier: Apache-2.0
|
|
20
|
+
*/
|
|
21
|
+
/*
|
|
22
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
23
|
+
SPDX-License-Identifier: Apache-2.0
|
|
24
|
+
*/
|
|
25
|
+
/*
|
|
26
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
27
|
+
SPDX-License-Identifier: Apache-2.0
|
|
28
|
+
*/
|
|
29
|
+
/*
|
|
30
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
31
|
+
SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
/*
|
|
34
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
35
|
+
SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
/*
|
|
38
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
39
|
+
SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
/*
|
|
42
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
43
|
+
SPDX-License-Identifier: Apache-2.0
|
|
44
|
+
*/
|
|
45
|
+
/*
|
|
46
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
47
|
+
SPDX-License-Identifier: Apache-2.0
|
|
48
|
+
*/
|
|
49
|
+
/*
|
|
50
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
51
|
+
SPDX-License-Identifier: Apache-2.0
|
|
52
|
+
*/
|
|
53
|
+
/*
|
|
54
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
55
|
+
SPDX-License-Identifier: Apache-2.0
|
|
56
|
+
*/
|
|
57
|
+
/*
|
|
58
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
59
|
+
SPDX-License-Identifier: Apache-2.0
|
|
60
|
+
*/
|
|
61
|
+
/*
|
|
62
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
63
|
+
SPDX-License-Identifier: Apache-2.0
|
|
64
|
+
*/
|
|
65
|
+
/* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
66
|
+
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
67
|
+
/*
|
|
68
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
69
|
+
SPDX-License-Identifier: Apache-2.0
|
|
70
|
+
*/
|
|
71
|
+
/*
|
|
72
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
73
|
+
SPDX-License-Identifier: Apache-2.0
|
|
74
|
+
*/
|
|
75
|
+
/*
|
|
76
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
77
|
+
SPDX-License-Identifier: Apache-2.0
|
|
78
|
+
*/
|
|
79
|
+
/*
|
|
80
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
81
|
+
SPDX-License-Identifier: Apache-2.0
|
|
82
|
+
*/
|
|
83
|
+
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
84
|
+
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
85
|
+
/*
|
|
86
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
87
|
+
SPDX-License-Identifier: Apache-2.0
|
|
88
|
+
*/
|
|
89
|
+
/*
|
|
90
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
91
|
+
SPDX-License-Identifier: Apache-2.0
|
|
92
|
+
*/
|
|
93
|
+
/*
|
|
94
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
95
|
+
SPDX-License-Identifier: Apache-2.0
|
|
96
|
+
*/
|
|
97
|
+
/*
|
|
98
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
99
|
+
SPDX-License-Identifier: Apache-2.0
|
|
100
|
+
*/
|
|
101
|
+
/*
|
|
102
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
103
|
+
SPDX-License-Identifier: Apache-2.0
|
|
104
|
+
*/
|
|
105
|
+
/*
|
|
106
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
107
|
+
SPDX-License-Identifier: Apache-2.0
|
|
108
|
+
*/
|
|
109
|
+
/*
|
|
110
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
111
|
+
SPDX-License-Identifier: Apache-2.0
|
|
112
|
+
*/
|
|
113
|
+
/*
|
|
114
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
115
|
+
SPDX-License-Identifier: Apache-2.0
|
|
116
|
+
*/
|
|
117
|
+
/*
|
|
118
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
119
|
+
SPDX-License-Identifier: Apache-2.0
|
|
120
|
+
*/
|
|
121
|
+
/*
|
|
122
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
123
|
+
SPDX-License-Identifier: Apache-2.0
|
|
124
|
+
*/
|
|
125
|
+
/*
|
|
126
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
127
|
+
SPDX-License-Identifier: Apache-2.0
|
|
128
|
+
*/
|
|
129
|
+
/*
|
|
130
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
131
|
+
SPDX-License-Identifier: Apache-2.0
|
|
132
|
+
*/
|
|
133
|
+
/*
|
|
134
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
135
|
+
SPDX-License-Identifier: Apache-2.0
|
|
136
|
+
*/
|
|
137
|
+
/*
|
|
138
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
139
|
+
SPDX-License-Identifier: Apache-2.0
|
|
140
|
+
*/
|
|
141
|
+
/*
|
|
142
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
143
|
+
SPDX-License-Identifier: Apache-2.0
|
|
144
|
+
*/
|
|
145
|
+
/*
|
|
146
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
147
|
+
SPDX-License-Identifier: Apache-2.0
|
|
148
|
+
*/
|
|
149
|
+
/*
|
|
150
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
151
|
+
SPDX-License-Identifier: Apache-2.0
|
|
152
|
+
*/
|
|
153
|
+
/*
|
|
154
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
155
|
+
SPDX-License-Identifier: Apache-2.0
|
|
156
|
+
*/
|
|
157
|
+
/* stylelint-disable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
158
|
+
/* stylelint-enable @cloudscape-design/no-motion-outside-of-mixin, selector-combinator-disallowed-list, selector-pseudo-class-no-unknown, selector-class-pattern */
|
|
159
|
+
/*
|
|
160
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
161
|
+
SPDX-License-Identifier: Apache-2.0
|
|
162
|
+
*/
|
|
163
|
+
/*
|
|
164
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
165
|
+
SPDX-License-Identifier: Apache-2.0
|
|
166
|
+
*/
|
|
167
|
+
/*
|
|
168
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
169
|
+
SPDX-License-Identifier: Apache-2.0
|
|
170
|
+
*/
|
|
171
|
+
/*
|
|
172
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
173
|
+
SPDX-License-Identifier: Apache-2.0
|
|
174
|
+
*/
|
|
175
|
+
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
176
|
+
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
177
|
+
/*
|
|
178
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
179
|
+
SPDX-License-Identifier: Apache-2.0
|
|
180
|
+
*/
|
|
181
|
+
/*
|
|
182
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
183
|
+
SPDX-License-Identifier: Apache-2.0
|
|
184
|
+
*/
|
|
185
|
+
.awsui_sortable-item-toggle_1f3h0_1bra9_185:not(#\9) {
|
|
186
|
+
/* used in test-utils */
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.awsui_sortable-item_1f3h0_1bra9_185:not(#\9) {
|
|
190
|
+
position: relative;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.awsui_sortable-item-placeholder_1f3h0_1bra9_193:not(#\9) {
|
|
194
|
+
position: absolute;
|
|
195
|
+
top: 0;
|
|
196
|
+
bottom: 0;
|
|
197
|
+
left: 0;
|
|
198
|
+
right: 0;
|
|
199
|
+
background: var(--color-drag-placeholder-hover-3ohnz1, #d3e7f9);
|
|
200
|
+
border-radius: var(--border-radius-item-u2ibpi, 8px);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203:not(#\9) {
|
|
204
|
+
border-top: var(--border-divider-list-width-hacikr, 1px) solid var(--color-border-divider-default-7s2wjw, #e9ebed);
|
|
205
|
+
display: flex;
|
|
206
|
+
flex-wrap: nowrap;
|
|
207
|
+
justify-content: space-between;
|
|
208
|
+
align-items: flex-start;
|
|
209
|
+
padding-top: var(--space-xs-rsr2qu, 8px);
|
|
210
|
+
padding-bottom: var(--space-xs-rsr2qu, 8px);
|
|
211
|
+
padding-right: 0;
|
|
212
|
+
}
|
|
213
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203:not(#\9):not(.awsui_draggable_1f3h0_1bra9_213) {
|
|
214
|
+
padding-left: var(--space-scaled-l-t03y3z, 20px);
|
|
215
|
+
}
|
|
216
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213:not(#\9) {
|
|
217
|
+
padding-left: 0;
|
|
218
|
+
padding-right: var(--space-scaled-xs-6859qs, 8px);
|
|
219
|
+
background-color: var(--color-background-container-content-i8i4a0, #ffffff);
|
|
220
|
+
z-index: 1;
|
|
221
|
+
}
|
|
222
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9) {
|
|
223
|
+
position: relative;
|
|
224
|
+
z-index: 2;
|
|
225
|
+
box-shadow: var(--shadow-container-active-l4kuxc, 0px 1px 1px 1px #e9ebed, 0px 6px 36px rgba(0, 7, 22, 0.1019607843));
|
|
226
|
+
border-radius: var(--border-radius-item-u2ibpi, 8px);
|
|
227
|
+
}
|
|
228
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213:not(#\9):not(.awsui_active_1f3h0_1bra9_222).awsui_sorting_1f3h0_1bra9_228 {
|
|
229
|
+
transition: transform var(--motion-duration-transition-quick-x85tae, 90ms) var(--motion-easing-transition-quick-lukbd8, linear);
|
|
230
|
+
}
|
|
231
|
+
@media (prefers-reduced-motion: reduce) {
|
|
232
|
+
.awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213:not(#\9):not(.awsui_active_1f3h0_1bra9_222).awsui_sorting_1f3h0_1bra9_228 {
|
|
233
|
+
animation: none;
|
|
234
|
+
transition: none;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
.awsui-motion-disabled .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213:not(#\9):not(.awsui_active_1f3h0_1bra9_222).awsui_sorting_1f3h0_1bra9_228, .awsui-mode-entering .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213:not(#\9):not(.awsui_active_1f3h0_1bra9_222).awsui_sorting_1f3h0_1bra9_228 {
|
|
238
|
+
animation: none;
|
|
239
|
+
transition: none;
|
|
240
|
+
}
|
|
241
|
+
body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9) {
|
|
242
|
+
transition: transform var(--motion-duration-transition-quick-x85tae, 90ms) var(--motion-easing-transition-quick-lukbd8, linear);
|
|
243
|
+
position: relative;
|
|
244
|
+
}
|
|
245
|
+
@media (prefers-reduced-motion: reduce) {
|
|
246
|
+
body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9) {
|
|
247
|
+
animation: none;
|
|
248
|
+
transition: none;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
.awsui-motion-disabled body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9), .awsui-mode-entering body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9) {
|
|
252
|
+
animation: none;
|
|
253
|
+
transition: none;
|
|
254
|
+
}
|
|
255
|
+
body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9) {
|
|
256
|
+
outline: 2px dotted transparent;
|
|
257
|
+
outline-offset: calc(0px - 1px);
|
|
258
|
+
}
|
|
259
|
+
body[data-awsui-focus-visible=true] .awsui_sortable-item-content_1f3h0_1bra9_203.awsui_draggable_1f3h0_1bra9_213.awsui_active_1f3h0_1bra9_222:not(#\9)::before {
|
|
260
|
+
content: " ";
|
|
261
|
+
display: block;
|
|
262
|
+
position: absolute;
|
|
263
|
+
left: calc(-1 * 0px);
|
|
264
|
+
top: calc(-1 * 0px);
|
|
265
|
+
width: calc(100% + 2 * 0px);
|
|
266
|
+
height: calc(100% + 2 * 0px);
|
|
267
|
+
border-radius: var(--border-radius-control-default-focus-ring-7661kz, 4px);
|
|
268
|
+
box-shadow: 0 0 0 2px var(--color-border-item-focused-ap3b6s, #0972d3);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.awsui_sortable-item-label_1f3h0_1bra9_271:not(#\9) {
|
|
272
|
+
padding-right: var(--space-l-4vl6xu, 20px);
|
|
273
|
+
flex-grow: 1;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.awsui_content-display_1f3h0_1bra9_276:not(#\9),
|
|
277
|
+
.awsui_content-display-groups_1f3h0_1bra9_277:not(#\9),
|
|
278
|
+
.awsui_content-display-group_1f3h0_1bra9_277:not(#\9),
|
|
279
|
+
.awsui_content-display-option_1f3h0_1bra9_279:not(#\9) {
|
|
280
|
+
/* used in test-utils */
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.awsui_content-display-title_1f3h0_1bra9_283:not(#\9) {
|
|
284
|
+
font-size: var(--font-body-m-size-sregvd, 14px);
|
|
285
|
+
line-height: var(--font-body-m-line-height-i7xxvv, 22px);
|
|
286
|
+
font-weight: var(--font-display-label-weight-m18hjh, 700);
|
|
287
|
+
color: var(--color-text-form-label-k3j0b4, #000716);
|
|
288
|
+
margin: 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.awsui_content-display-description_1f3h0_1bra9_291:not(#\9) {
|
|
292
|
+
color: var(--color-text-form-secondary-ih9x7l, #5f6b7a);
|
|
293
|
+
font-size: var(--font-body-s-size-ukw2p9, 12px);
|
|
294
|
+
line-height: var(--font-body-s-line-height-kdsbrl, 16px);
|
|
295
|
+
letter-spacing: var(--font-body-s-letter-spacing-cy0oxj, 0.005em);
|
|
296
|
+
margin-top: var(--space-scaled-xxxs-lo883m, 2px);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.awsui_content-display-option-list_1f3h0_1bra9_299:not(#\9) {
|
|
300
|
+
position: relative;
|
|
301
|
+
list-style: none;
|
|
302
|
+
padding: 0;
|
|
303
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
// es-module interop with Babel and Typescript
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
module.exports.default = {
|
|
5
|
+
"sortable-item-toggle": "awsui_sortable-item-toggle_1f3h0_1bra9_185",
|
|
6
|
+
"sortable-item": "awsui_sortable-item_1f3h0_1bra9_185",
|
|
7
|
+
"sortable-item-placeholder": "awsui_sortable-item-placeholder_1f3h0_1bra9_193",
|
|
8
|
+
"sortable-item-content": "awsui_sortable-item-content_1f3h0_1bra9_203",
|
|
9
|
+
"draggable": "awsui_draggable_1f3h0_1bra9_213",
|
|
10
|
+
"active": "awsui_active_1f3h0_1bra9_222",
|
|
11
|
+
"sorting": "awsui_sorting_1f3h0_1bra9_228",
|
|
12
|
+
"sortable-item-label": "awsui_sortable-item-label_1f3h0_1bra9_271",
|
|
13
|
+
"content-display": "awsui_content-display_1f3h0_1bra9_276",
|
|
14
|
+
"content-display-groups": "awsui_content-display-groups_1f3h0_1bra9_277",
|
|
15
|
+
"content-display-group": "awsui_content-display-group_1f3h0_1bra9_277",
|
|
16
|
+
"content-display-option": "awsui_content-display-option_1f3h0_1bra9_279",
|
|
17
|
+
"content-display-title": "awsui_content-display-title_1f3h0_1bra9_283",
|
|
18
|
+
"content-display-description": "awsui_content-display-description_1f3h0_1bra9_291",
|
|
19
|
+
"content-display-option-list": "awsui_content-display-option-list_1f3h0_1bra9_299"
|
|
20
|
+
};
|
|
21
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CollisionDetection, KeyboardCoordinateGetter, UniqueIdentifier } from '@dnd-kit/core';
|
|
3
|
+
import { CollectionPreferencesProps } from '../interfaces';
|
|
4
|
+
export default function useDragAndDropReorder({ sortedOptions, }: {
|
|
5
|
+
sortedOptions: ReadonlyArray<CollectionPreferencesProps.VisibleContentOption>;
|
|
6
|
+
}): {
|
|
7
|
+
activeItem: UniqueIdentifier | null;
|
|
8
|
+
collisionDetection: CollisionDetection;
|
|
9
|
+
coordinateGetter: KeyboardCoordinateGetter;
|
|
10
|
+
handleKeyDown: (event: React.KeyboardEvent) => void;
|
|
11
|
+
sensors: import("@dnd-kit/core").SensorDescriptor<import("@dnd-kit/core").SensorOptions>[];
|
|
12
|
+
setActiveItem: (id: UniqueIdentifier | null) => void;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=use-drag-and-drop-reorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-and-drop-reorder.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/use-drag-and-drop-reorder.ts"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAChD,OAAO,EAGL,kBAAkB,EAElB,wBAAwB,EAExB,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AA+B3D,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,aAAa,GACd,EAAE;IACD,aAAa,EAAE,aAAa,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;CAC/E;;;;2BAa+B,mBAAmB;;wBARtB,gBAAgB,GAAG,IAAI;EA+GnD"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { closestCenter, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
5
|
+
import { hasSortableData } from '@dnd-kit/sortable';
|
|
6
|
+
import { KeyboardSensor } from './keyboard-sensor';
|
|
7
|
+
var KeyboardCode;
|
|
8
|
+
(function (KeyboardCode) {
|
|
9
|
+
KeyboardCode["Space"] = "Space";
|
|
10
|
+
KeyboardCode["Down"] = "ArrowDown";
|
|
11
|
+
KeyboardCode["Right"] = "ArrowRight";
|
|
12
|
+
KeyboardCode["Left"] = "ArrowLeft";
|
|
13
|
+
KeyboardCode["Up"] = "ArrowUp";
|
|
14
|
+
KeyboardCode["Esc"] = "Escape";
|
|
15
|
+
KeyboardCode["Enter"] = "Enter";
|
|
16
|
+
})(KeyboardCode || (KeyboardCode = {}));
|
|
17
|
+
// A custom collision detection algorithm is used when using a keyboard to
|
|
18
|
+
// work around an unexpected behavior when reordering items of variable height
|
|
19
|
+
// with the keyboard.
|
|
20
|
+
// Neither closestCenter nor closestCorners work really well for this case,
|
|
21
|
+
// because the center (or corners) of a tall rectangle might be so low that it
|
|
22
|
+
// is detected as being closest to the rectangle below of the one it should
|
|
23
|
+
// actually swap with.
|
|
24
|
+
// Instead of relying on coordinates, the expected results are achieved by
|
|
25
|
+
// moving X positions up or down in the initially sorted array, depending on
|
|
26
|
+
// the desired direction.
|
|
27
|
+
// We let our collisionDetection and customCoordinateGetter use the same
|
|
28
|
+
// getClosestId function which takes its value from the current component
|
|
29
|
+
// state, to make sure they are always in sync.
|
|
30
|
+
export default function useDragAndDropReorder({ sortedOptions, }) {
|
|
31
|
+
const isKeyboard = useRef(false);
|
|
32
|
+
const positionDelta = useRef(0);
|
|
33
|
+
const [activeItemId, setActiveItemId] = useState(null);
|
|
34
|
+
const setActiveItem = (id) => {
|
|
35
|
+
setActiveItemId(id);
|
|
36
|
+
if (!id) {
|
|
37
|
+
isKeyboard.current = false;
|
|
38
|
+
positionDelta.current = 0;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const handleKeyDown = (event) => {
|
|
42
|
+
if (isKeyboard.current && activeItemId) {
|
|
43
|
+
const currentTargetIndex = sortedOptions.findIndex(({ id }) => id === activeItemId) + positionDelta.current;
|
|
44
|
+
if (event.key === 'ArrowDown' && currentTargetIndex < sortedOptions.length - 1) {
|
|
45
|
+
positionDelta.current += 1;
|
|
46
|
+
}
|
|
47
|
+
else if (event.key === 'ArrowUp' && currentTargetIndex > 0) {
|
|
48
|
+
positionDelta.current -= 1;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (activeItemId && isEscape(event.key)) {
|
|
52
|
+
// Prevent modal from closing when pressing Esc to cancel the dragging action
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const getClosestId = (active) => {
|
|
57
|
+
if (positionDelta.current === 0) {
|
|
58
|
+
return active.id;
|
|
59
|
+
}
|
|
60
|
+
const currentIndex = sortedOptions.findIndex(({ id }) => id === active.id);
|
|
61
|
+
const newIndex = Math.max(0, Math.min(sortedOptions.length - 1, currentIndex + positionDelta.current));
|
|
62
|
+
return sortedOptions[newIndex].id;
|
|
63
|
+
};
|
|
64
|
+
const collisionDetection = ({ active, collisionRect, droppableContainers, droppableRects, pointerCoordinates, }) => {
|
|
65
|
+
if (isKeyboard.current) {
|
|
66
|
+
// For keyboard interaction, determine the colliding container based on the movements made by the arrow keys,
|
|
67
|
+
// via getClosestId
|
|
68
|
+
const collidingContainer = getCollidingContainer({
|
|
69
|
+
activeId: active.id,
|
|
70
|
+
closestId: getClosestId(active),
|
|
71
|
+
droppableContainers,
|
|
72
|
+
});
|
|
73
|
+
return collidingContainer ? [collidingContainer] : [];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// For mouse interaction, use the closest center algorithm
|
|
77
|
+
return closestCenter({ active, collisionRect, droppableRects, droppableContainers, pointerCoordinates });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const coordinateGetter = (event, { context: { active, collisionRect, droppableRects, droppableContainers } }) => {
|
|
81
|
+
if (event.code === KeyboardCode.Up || event.code === KeyboardCode.Down) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
if (!active || !collisionRect) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const closestId = getClosestId(active);
|
|
87
|
+
if (closestId !== null) {
|
|
88
|
+
const activeDroppable = droppableContainers.get(active.id);
|
|
89
|
+
const newDroppable = droppableContainers.get(closestId);
|
|
90
|
+
const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null;
|
|
91
|
+
const newNode = newDroppable === null || newDroppable === void 0 ? void 0 : newDroppable.node.current;
|
|
92
|
+
if (newNode && newRect && activeDroppable && newDroppable) {
|
|
93
|
+
const isAfterActive = isAfter(activeDroppable, newDroppable);
|
|
94
|
+
const offset = {
|
|
95
|
+
x: isAfterActive ? collisionRect.width - newRect.width : 0,
|
|
96
|
+
y: isAfterActive ? collisionRect.height - newRect.height : 0,
|
|
97
|
+
};
|
|
98
|
+
const rectCoordinates = {
|
|
99
|
+
x: newRect.left,
|
|
100
|
+
y: newRect.top,
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
x: rectCoordinates.x - offset.x,
|
|
104
|
+
y: rectCoordinates.y - offset.y,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
111
|
+
coordinateGetter,
|
|
112
|
+
onActivation: () => {
|
|
113
|
+
isKeyboard.current = true;
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
return {
|
|
117
|
+
activeItem: activeItemId,
|
|
118
|
+
collisionDetection,
|
|
119
|
+
coordinateGetter,
|
|
120
|
+
handleKeyDown,
|
|
121
|
+
sensors,
|
|
122
|
+
setActiveItem,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function isAfter(a, b) {
|
|
126
|
+
return hasSortableData(a) && hasSortableData(b) && a.data.current.sortable.index < b.data.current.sortable.index;
|
|
127
|
+
}
|
|
128
|
+
function getCollidingContainer({ activeId, closestId, droppableContainers, }) {
|
|
129
|
+
if (closestId === activeId) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const collidingContainer = droppableContainers.find(({ id }) => id === closestId);
|
|
133
|
+
if (collidingContainer) {
|
|
134
|
+
return {
|
|
135
|
+
id: collidingContainer.id,
|
|
136
|
+
data: {
|
|
137
|
+
droppableContainer: collidingContainer,
|
|
138
|
+
value: 0,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const isEscape = (key) => key === 'Escape' || key === 'Esc';
|
|
144
|
+
//# sourceMappingURL=use-drag-and-drop-reorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-drag-and-drop-reorder.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/use-drag-and-drop-reorder.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAEL,aAAa,EAIb,aAAa,EAEb,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,IAAK,YAQJ;AARD,WAAK,YAAY;IACf,+BAAe,CAAA;IACf,kCAAkB,CAAA;IAClB,oCAAoB,CAAA;IACpB,kCAAkB,CAAA;IAClB,8BAAc,CAAA;IACd,8BAAc,CAAA;IACd,+BAAe,CAAA;AACjB,CAAC,EARI,YAAY,KAAZ,YAAY,QAQhB;AAED,0EAA0E;AAC1E,8EAA8E;AAC9E,qBAAqB;AAErB,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,sBAAsB;AAEtB,0EAA0E;AAC1E,4EAA4E;AAC5E,yBAAyB;AAEzB,wEAAwE;AACxE,yEAAyE;AACzE,+CAA+C;AAE/C,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,aAAa,GAGd;IACC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAA0B,IAAI,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,CAAC,EAA2B,EAAE,EAAE;QACpD,eAAe,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,CAAC,EAAE,EAAE;YACP,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;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AAqB;IAC3D,OAAO,eAAe,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;AACnH,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,QAAQ,EACR,SAAS,EACT,mBAAmB,GAKpB;IACC,IAAI,SAAS,KAAK,QAAQ,EAAE;QAC1B,OAAO;KACR;IACD,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAClF,IAAI,kBAAkB,EAAE;QACtB,OAAO;YACL,EAAE,EAAE,kBAAkB,CAAC,EAAE;YACzB,IAAI,EAAE;gBACJ,kBAAkB,EAAE,kBAAkB;gBACtC,KAAK,EAAE,CAAC;aACT;SACF,CAAC;KACH;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,KAAK,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport {\n Active,\n closestCenter,\n CollisionDetection,\n DroppableContainer,\n KeyboardCoordinateGetter,\n PointerSensor,\n UniqueIdentifier,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { CollectionPreferencesProps } from '../interfaces';\nimport { hasSortableData } from '@dnd-kit/sortable';\nimport { KeyboardSensor } from './keyboard-sensor';\n\nenum KeyboardCode {\n Space = 'Space',\n Down = 'ArrowDown',\n Right = 'ArrowRight',\n Left = 'ArrowLeft',\n Up = 'ArrowUp',\n Esc = 'Escape',\n Enter = 'Enter',\n}\n\n// A custom collision detection algorithm is used when using a keyboard to\n// work around an unexpected behavior when reordering items of variable height\n// with the keyboard.\n\n// Neither closestCenter nor closestCorners work really well for this case,\n// because the center (or corners) of a tall rectangle might be so low that it\n// is detected as being closest to the rectangle below of the one it should\n// actually swap with.\n\n// Instead of relying on coordinates, the expected results are achieved by\n// moving X positions up or down in the initially sorted array, depending on\n// the desired direction.\n\n// We let our collisionDetection and customCoordinateGetter use the same\n// getClosestId function which takes its value from the current component\n// state, to make sure they are always in sync.\n\nexport default function useDragAndDropReorder({\n sortedOptions,\n}: {\n sortedOptions: ReadonlyArray<CollectionPreferencesProps.VisibleContentOption>;\n}) {\n const isKeyboard = useRef(false);\n const positionDelta = useRef(0);\n const [activeItemId, setActiveItemId] = useState<UniqueIdentifier | null>(null);\n\n const setActiveItem = (id: UniqueIdentifier | null) => {\n setActiveItemId(id);\n if (!id) {\n isKeyboard.current = false;\n positionDelta.current = 0;\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isKeyboard.current && activeItemId) {\n const currentTargetIndex = sortedOptions.findIndex(({ id }) => id === activeItemId) + positionDelta.current;\n if (event.key === 'ArrowDown' && currentTargetIndex < sortedOptions.length - 1) {\n positionDelta.current += 1;\n } else if (event.key === 'ArrowUp' && currentTargetIndex > 0) {\n positionDelta.current -= 1;\n }\n }\n if (activeItemId && isEscape(event.key)) {\n // Prevent modal from closing when pressing Esc to cancel the dragging action\n event.stopPropagation();\n }\n };\n\n const getClosestId = (active: Active) => {\n if (positionDelta.current === 0) {\n return active.id;\n }\n const currentIndex = sortedOptions.findIndex(({ id }) => id === active.id);\n const newIndex = Math.max(0, Math.min(sortedOptions.length - 1, currentIndex + positionDelta.current));\n return sortedOptions[newIndex].id;\n };\n\n const collisionDetection: CollisionDetection = ({\n active,\n collisionRect,\n droppableContainers,\n droppableRects,\n pointerCoordinates,\n }) => {\n if (isKeyboard.current) {\n // For keyboard interaction, determine the colliding container based on the movements made by the arrow keys,\n // via getClosestId\n const collidingContainer = getCollidingContainer({\n activeId: active.id,\n closestId: getClosestId(active),\n droppableContainers,\n });\n return collidingContainer ? [collidingContainer] : [];\n } else {\n // For mouse interaction, use the closest center algorithm\n return closestCenter({ active, collisionRect, droppableRects, droppableContainers, pointerCoordinates });\n }\n };\n\n const coordinateGetter: KeyboardCoordinateGetter = (\n event,\n { context: { active, collisionRect, droppableRects, droppableContainers } }\n ) => {\n if (event.code === KeyboardCode.Up || event.code === KeyboardCode.Down) {\n event.preventDefault();\n\n if (!active || !collisionRect) {\n return;\n }\n\n const closestId = getClosestId(active);\n\n if (closestId !== null) {\n const activeDroppable = droppableContainers.get(active.id);\n const newDroppable = droppableContainers.get(closestId);\n const newRect = newDroppable ? droppableRects.get(newDroppable.id) : null;\n const newNode = newDroppable?.node.current;\n\n if (newNode && newRect && activeDroppable && newDroppable) {\n const isAfterActive = isAfter(activeDroppable, newDroppable);\n const offset = {\n x: isAfterActive ? collisionRect.width - newRect.width : 0,\n y: isAfterActive ? collisionRect.height - newRect.height : 0,\n };\n const rectCoordinates = {\n x: newRect.left,\n y: newRect.top,\n };\n\n return {\n x: rectCoordinates.x - offset.x,\n y: rectCoordinates.y - offset.y,\n };\n }\n }\n }\n };\n\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter,\n onActivation: () => {\n isKeyboard.current = true;\n },\n })\n );\n\n return {\n activeItem: activeItemId,\n collisionDetection,\n coordinateGetter,\n handleKeyDown,\n sensors,\n setActiveItem,\n };\n}\n\nfunction isAfter(a: DroppableContainer, b: DroppableContainer) {\n return hasSortableData(a) && hasSortableData(b) && a.data.current.sortable.index < b.data.current.sortable.index;\n}\n\nfunction getCollidingContainer({\n activeId,\n closestId,\n droppableContainers,\n}: {\n activeId: UniqueIdentifier;\n closestId: UniqueIdentifier;\n droppableContainers: DroppableContainer[];\n}) {\n if (closestId === activeId) {\n return;\n }\n const collidingContainer = droppableContainers.find(({ id }) => id === closestId);\n if (collidingContainer) {\n return {\n id: collidingContainer.id,\n data: {\n droppableContainer: collidingContainer,\n value: 0,\n },\n };\n }\n}\n\nconst isEscape = (key: string) => key === 'Escape' || key === 'Esc';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CollectionPreferencesProps } from '../interfaces';
|
|
2
|
+
import { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';
|
|
3
|
+
export default function useLiveAnnouncements({ isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, sortedOptions, }: Partial<CollectionPreferencesProps.ContentDisplayPreference> & {
|
|
4
|
+
isDragging: boolean;
|
|
5
|
+
sortedOptions: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;
|
|
6
|
+
}): {
|
|
7
|
+
onDragStart({ active }: DragStartEvent): string | undefined;
|
|
8
|
+
onDragOver({ active, over }: DragOverEvent): string | undefined;
|
|
9
|
+
onDragEnd({ active, over }: DragEndEvent): string | undefined;
|
|
10
|
+
onDragCancel(): string | undefined;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=use-live-announcements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-live-announcements.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/use-live-announcements.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG5E,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,EAC5B,aAAa,GACd,EAAE,OAAO,CAAC,0BAA0B,CAAC,wBAAwB,CAAC,GAAG;IAChE,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CAC7E;4BAO2B,cAAc;iCAMT,aAAa;gCAcd,YAAY;;EAW3C"}
|