@cloudscape-design/components 3.0.261 → 3.0.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/THIRD-PARTY-LICENSES +31 -0
  2. package/app-layout/drawer/index.d.ts +1 -1
  3. package/app-layout/drawer/index.d.ts.map +1 -1
  4. package/app-layout/drawer/index.js +3 -3
  5. package/app-layout/drawer/index.js.map +1 -1
  6. package/app-layout/drawer/interfaces.d.ts +17 -3
  7. package/app-layout/drawer/interfaces.d.ts.map +1 -1
  8. package/app-layout/drawer/interfaces.js.map +1 -1
  9. package/app-layout/drawer/resizable-drawer.d.ts.map +1 -1
  10. package/app-layout/drawer/resizable-drawer.js +6 -4
  11. package/app-layout/drawer/resizable-drawer.js.map +1 -1
  12. package/app-layout/index.d.ts.map +1 -1
  13. package/app-layout/index.js +47 -31
  14. package/app-layout/index.js.map +1 -1
  15. package/app-layout/mobile-toolbar/index.d.ts.map +1 -1
  16. package/app-layout/mobile-toolbar/index.js +4 -1
  17. package/app-layout/mobile-toolbar/index.js.map +1 -1
  18. package/app-layout/test-classes/styles.css.js +19 -18
  19. package/app-layout/test-classes/styles.scoped.css +22 -18
  20. package/app-layout/test-classes/styles.selectors.js +19 -18
  21. package/app-layout/visual-refresh/drawers.d.ts +1 -0
  22. package/app-layout/visual-refresh/drawers.d.ts.map +1 -1
  23. package/app-layout/visual-refresh/drawers.js +2 -2
  24. package/app-layout/visual-refresh/drawers.js.map +1 -1
  25. package/attribute-editor/row.d.ts.map +1 -1
  26. package/attribute-editor/row.js +1 -3
  27. package/attribute-editor/row.js.map +1 -1
  28. package/collection-preferences/content-display/index.d.ts +9 -0
  29. package/collection-preferences/content-display/index.d.ts.map +1 -0
  30. package/collection-preferences/content-display/index.js +55 -0
  31. package/collection-preferences/content-display/index.js.map +1 -0
  32. package/collection-preferences/content-display/keyboard-sensor/defaults.d.ts +3 -0
  33. package/collection-preferences/content-display/keyboard-sensor/defaults.d.ts.map +1 -0
  34. package/collection-preferences/content-display/keyboard-sensor/defaults.js +9 -0
  35. package/collection-preferences/content-display/keyboard-sensor/defaults.js.map +1 -0
  36. package/collection-preferences/content-display/keyboard-sensor/index.d.ts +19 -0
  37. package/collection-preferences/content-display/keyboard-sensor/index.d.ts.map +1 -0
  38. package/collection-preferences/content-display/keyboard-sensor/index.js +126 -0
  39. package/collection-preferences/content-display/keyboard-sensor/index.js.map +1 -0
  40. package/collection-preferences/content-display/keyboard-sensor/utilities/events.d.ts +11 -0
  41. package/collection-preferences/content-display/keyboard-sensor/utilities/events.d.ts.map +1 -0
  42. package/collection-preferences/content-display/keyboard-sensor/utilities/events.js +14 -0
  43. package/collection-preferences/content-display/keyboard-sensor/utilities/events.js.map +1 -0
  44. package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.d.ts +8 -0
  45. package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.d.ts.map +1 -0
  46. package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.js +17 -0
  47. package/collection-preferences/content-display/keyboard-sensor/utilities/listeners.js.map +1 -0
  48. package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.d.ts +30 -0
  49. package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.d.ts.map +1 -0
  50. package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.js +95 -0
  51. package/collection-preferences/content-display/keyboard-sensor/utilities/scroll.js.map +1 -0
  52. package/collection-preferences/content-display/sortable-item.d.ts +9 -0
  53. package/collection-preferences/content-display/sortable-item.d.ts.map +1 -0
  54. package/collection-preferences/content-display/sortable-item.js +52 -0
  55. package/collection-preferences/content-display/sortable-item.js.map +1 -0
  56. package/collection-preferences/content-display/styles.css.js +20 -0
  57. package/collection-preferences/content-display/styles.scoped.css +303 -0
  58. package/collection-preferences/content-display/styles.selectors.js +21 -0
  59. package/collection-preferences/content-display/use-drag-and-drop-reorder.d.ts +14 -0
  60. package/collection-preferences/content-display/use-drag-and-drop-reorder.d.ts.map +1 -0
  61. package/collection-preferences/content-display/use-drag-and-drop-reorder.js +144 -0
  62. package/collection-preferences/content-display/use-drag-and-drop-reorder.js.map +1 -0
  63. package/collection-preferences/content-display/use-live-announcements.d.ts +12 -0
  64. package/collection-preferences/content-display/use-live-announcements.d.ts.map +1 -0
  65. package/collection-preferences/content-display/use-live-announcements.js +40 -0
  66. package/collection-preferences/content-display/use-live-announcements.js.map +1 -0
  67. package/collection-preferences/content-display/utils.d.ts +9 -0
  68. package/collection-preferences/content-display/utils.d.ts.map +1 -0
  69. package/collection-preferences/content-display/utils.js +7 -0
  70. package/collection-preferences/content-display/utils.js.map +1 -0
  71. package/collection-preferences/index.d.ts +1 -1
  72. package/collection-preferences/index.d.ts.map +1 -1
  73. package/collection-preferences/index.js +15 -9
  74. package/collection-preferences/index.js.map +1 -1
  75. package/collection-preferences/interfaces.d.ts +47 -1
  76. package/collection-preferences/interfaces.d.ts.map +1 -1
  77. package/collection-preferences/interfaces.js.map +1 -1
  78. package/collection-preferences/styles.css.js +36 -21
  79. package/collection-preferences/styles.scoped.css +326 -22
  80. package/collection-preferences/styles.selectors.js +36 -21
  81. package/collection-preferences/utils.d.ts +1 -1
  82. package/collection-preferences/utils.d.ts.map +1 -1
  83. package/collection-preferences/utils.js +20 -9
  84. package/collection-preferences/utils.js.map +1 -1
  85. package/internal/components/token-list/styles.css.js +9 -9
  86. package/internal/components/token-list/styles.scoped.css +22 -21
  87. package/internal/components/token-list/styles.selectors.js +9 -9
  88. package/internal/drag-handle/index.d.ts +9 -0
  89. package/internal/drag-handle/index.d.ts.map +1 -0
  90. package/internal/drag-handle/index.js +13 -0
  91. package/internal/drag-handle/index.js.map +1 -0
  92. package/internal/drag-handle/styles.css.js +6 -0
  93. package/internal/drag-handle/styles.scoped.css +13 -0
  94. package/internal/drag-handle/styles.selectors.js +7 -0
  95. package/internal/environment.js +1 -1
  96. package/internal/handle/index.d.ts +3 -0
  97. package/internal/handle/index.d.ts.map +1 -0
  98. package/internal/handle/index.js +14 -0
  99. package/internal/handle/index.js.map +1 -0
  100. package/internal/handle/styles.css.js +7 -0
  101. package/internal/handle/styles.scoped.css +125 -0
  102. package/internal/handle/styles.selectors.js +8 -0
  103. package/internal/manifest.json +1 -1
  104. package/package.json +4 -1
  105. package/table/body-cell/styles.css.js +23 -40
  106. package/table/body-cell/styles.scoped.css +59 -220
  107. package/table/body-cell/styles.selectors.js +23 -40
  108. package/table/header-cell/index.js +1 -1
  109. package/table/header-cell/index.js.map +1 -1
  110. package/table/header-cell/styles.css.js +24 -0
  111. package/table/header-cell/styles.scoped.css +252 -0
  112. package/table/header-cell/styles.selectors.js +25 -0
  113. package/table/interfaces.d.ts +16 -3
  114. package/table/interfaces.d.ts.map +1 -1
  115. package/table/interfaces.js.map +1 -1
  116. package/table/internal.d.ts.map +1 -1
  117. package/table/internal.js +17 -9
  118. package/table/internal.js.map +1 -1
  119. package/table/thead.d.ts.map +1 -1
  120. package/table/thead.js +4 -7
  121. package/table/thead.js.map +1 -1
  122. package/table/use-column-widths.js +1 -1
  123. package/table/use-column-widths.js.map +1 -1
  124. package/table/utils.d.ts +5 -0
  125. package/table/utils.d.ts.map +1 -1
  126. package/table/utils.js +23 -0
  127. package/table/utils.js.map +1 -1
  128. package/test-utils/dom/app-layout/index.d.ts +6 -0
  129. package/test-utils/dom/app-layout/index.js +18 -0
  130. package/test-utils/dom/app-layout/index.js.map +1 -1
  131. package/test-utils/dom/collection-preferences/content-display-preference.d.ts +37 -0
  132. package/test-utils/dom/collection-preferences/content-display-preference.js +62 -0
  133. package/test-utils/dom/collection-preferences/content-display-preference.js.map +1 -0
  134. package/test-utils/dom/collection-preferences/index.d.ts +2 -0
  135. package/test-utils/dom/collection-preferences/index.js +4 -0
  136. package/test-utils/dom/collection-preferences/index.js.map +1 -1
  137. package/test-utils/dom/table/index.js +10 -9
  138. package/test-utils/dom/table/index.js.map +1 -1
  139. package/test-utils/selectors/app-layout/index.d.ts +6 -0
  140. package/test-utils/selectors/app-layout/index.js +18 -0
  141. package/test-utils/selectors/app-layout/index.js.map +1 -1
  142. package/test-utils/selectors/collection-preferences/content-display-preference.d.ts +37 -0
  143. package/test-utils/selectors/collection-preferences/content-display-preference.js +62 -0
  144. package/test-utils/selectors/collection-preferences/content-display-preference.js.map +1 -0
  145. package/test-utils/selectors/collection-preferences/index.d.ts +2 -0
  146. package/test-utils/selectors/collection-preferences/index.js +4 -0
  147. package/test-utils/selectors/collection-preferences/index.js.map +1 -1
  148. package/test-utils/selectors/table/index.js +10 -9
  149. package/test-utils/selectors/table/index.js.map +1 -1
  150. package/test-utils/tsconfig.tsbuildinfo +1 -1
  151. package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
  152. package/top-navigation/parts/overflow-menu/menu-item.js +5 -4
  153. package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
  154. package/top-navigation/parts/utility.js +1 -1
  155. package/top-navigation/parts/utility.js.map +1 -1
  156. package/table/table-wrapper.d.ts +0 -13
  157. package/table/table-wrapper.d.ts.map +0 -1
  158. package/table/table-wrapper.js +0 -15
  159. package/table/table-wrapper.js.map +0 -1
@@ -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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C,cAAc,EAAE;QACxB,gBAAgB;QAChB,YAAY,EAAE,GAAG,EAAE;YACjB,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC5B,CAAC;KACF,CAAC,CACH,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,YAAY;QACxB,kBAAkB;QAClB,gBAAgB;QAChB,aAAa;QACb,OAAO;QACP,aAAa;KACd,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,CAAqB,EAAE,CAAqB;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"}
@@ -0,0 +1,40 @@
1
+ import { useRef } from 'react';
2
+ export default function useLiveAnnouncements({ isDragging, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, sortedOptions, }) {
3
+ const isFirstAnnouncement = useRef(true);
4
+ if (!isDragging) {
5
+ isFirstAnnouncement.current = true;
6
+ }
7
+ return {
8
+ onDragStart({ active }) {
9
+ if (active && liveAnnouncementDndStarted) {
10
+ const index = sortedOptions.findIndex(option => option.id === active.id);
11
+ return liveAnnouncementDndStarted(index + 1, sortedOptions.length);
12
+ }
13
+ },
14
+ onDragOver({ active, over }) {
15
+ if (liveAnnouncementDndItemReordered) {
16
+ // Don't announce on the first dragOver because it's redundant with onDragStart.
17
+ if (isFirstAnnouncement.current) {
18
+ isFirstAnnouncement.current = false;
19
+ if (!over || over.id === active.id) {
20
+ return;
21
+ }
22
+ }
23
+ const initialIndex = sortedOptions.findIndex(option => option.id === active.id);
24
+ const currentIdex = over ? sortedOptions.findIndex(option => option.id === over.id) : initialIndex;
25
+ return liveAnnouncementDndItemReordered(initialIndex + 1, currentIdex + 1, sortedOptions.length);
26
+ }
27
+ },
28
+ onDragEnd({ active, over }) {
29
+ if (liveAnnouncementDndItemCommitted) {
30
+ const initialIndex = sortedOptions.findIndex(option => option.id === active.id);
31
+ const finalIndex = over ? sortedOptions.findIndex(option => option.id === over.id) : initialIndex;
32
+ return liveAnnouncementDndItemCommitted(initialIndex + 1, finalIndex + 1, sortedOptions.length);
33
+ }
34
+ },
35
+ onDragCancel() {
36
+ return liveAnnouncementDndDiscarded;
37
+ },
38
+ };
39
+ }
40
+ //# sourceMappingURL=use-live-announcements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-live-announcements.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/use-live-announcements.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,UAAU,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,EAC5B,aAAa,GAId;IACC,MAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,UAAU,EAAE;QACf,mBAAmB,CAAC,OAAO,GAAG,IAAI,CAAC;KACpC;IAED,OAAO;QACL,WAAW,CAAC,EAAE,MAAM,EAAkB;YACpC,IAAI,MAAM,IAAI,0BAA0B,EAAE;gBACxC,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBACzE,OAAO,0BAA0B,CAAC,KAAK,GAAG,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;aACpE;QACH,CAAC;QACD,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAiB;YACxC,IAAI,gCAAgC,EAAE;gBACpC,gFAAgF;gBAChF,IAAI,mBAAmB,CAAC,OAAO,EAAE;oBAC/B,mBAAmB,CAAC,OAAO,GAAG,KAAK,CAAC;oBACpC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE;wBAClC,OAAO;qBACR;iBACF;gBACD,MAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBAChF,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;gBACnG,OAAO,gCAAgC,CAAC,YAAY,GAAG,CAAC,EAAE,WAAW,GAAG,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;aAClG;QACH,CAAC;QACD,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAgB;YACtC,IAAI,gCAAgC,EAAE;gBACpC,MAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBAChF,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;gBAClG,OAAO,gCAAgC,CAAC,YAAY,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;aACjG;QACH,CAAC;QACD,YAAY;YACV,OAAO,4BAA4B,CAAC;QACtC,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CollectionPreferencesProps } from '../interfaces';\nimport { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';\nimport { useRef } from 'react';\n\nexport default function useLiveAnnouncements({\n isDragging,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n sortedOptions,\n}: Partial<CollectionPreferencesProps.ContentDisplayPreference> & {\n isDragging: boolean;\n sortedOptions: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}) {\n const isFirstAnnouncement = useRef(true);\n if (!isDragging) {\n isFirstAnnouncement.current = true;\n }\n\n return {\n onDragStart({ active }: DragStartEvent) {\n if (active && liveAnnouncementDndStarted) {\n const index = sortedOptions.findIndex(option => option.id === active.id);\n return liveAnnouncementDndStarted(index + 1, sortedOptions.length);\n }\n },\n onDragOver({ active, over }: DragOverEvent) {\n if (liveAnnouncementDndItemReordered) {\n // Don't announce on the first dragOver because it's redundant with onDragStart.\n if (isFirstAnnouncement.current) {\n isFirstAnnouncement.current = false;\n if (!over || over.id === active.id) {\n return;\n }\n }\n const initialIndex = sortedOptions.findIndex(option => option.id === active.id);\n const currentIdex = over ? sortedOptions.findIndex(option => option.id === over.id) : initialIndex;\n return liveAnnouncementDndItemReordered(initialIndex + 1, currentIdex + 1, sortedOptions.length);\n }\n },\n onDragEnd({ active, over }: DragEndEvent) {\n if (liveAnnouncementDndItemCommitted) {\n const initialIndex = sortedOptions.findIndex(option => option.id === active.id);\n const finalIndex = over ? sortedOptions.findIndex(option => option.id === over.id) : initialIndex;\n return liveAnnouncementDndItemCommitted(initialIndex + 1, finalIndex + 1, sortedOptions.length);\n }\n },\n onDragCancel() {\n return liveAnnouncementDndDiscarded;\n },\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { CollectionPreferencesProps } from '../interfaces';
2
+ export interface OptionWithVisibility extends CollectionPreferencesProps.ContentDisplayOption {
3
+ visible?: boolean;
4
+ }
5
+ export declare function getSortedOptions({ options, contentDisplay, }: {
6
+ options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;
7
+ contentDisplay: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;
8
+ }): ReadonlyArray<OptionWithVisibility>;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,WAAW,oBAAqB,SAAQ,0BAA0B,CAAC,oBAAoB;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,cAAc,GACf,EAAE;IACD,OAAO,EAAE,aAAa,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IACxE,cAAc,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CAC9E,GAAG,aAAa,CAAC,oBAAoB,CAAC,CAWtC"}
@@ -0,0 +1,7 @@
1
+ export function getSortedOptions({ options, contentDisplay, }) {
2
+ const optionsById = options.reduce((currentValue, option) => (Object.assign(Object.assign({}, currentValue), { [option.id]: option })), {});
3
+ return contentDisplay
4
+ .map(({ id, visible }) => (Object.assign(Object.assign({}, optionsById[id]), { visible })))
5
+ .filter(Boolean);
6
+ }
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"lib/default/","sources":["collection-preferences/content-display/utils.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,cAAc,GAIf;IACC,MAAM,WAAW,GAAoE,OAAO,CAAC,MAAM,CACjG,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,CAAC,iCAAM,YAAY,KAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,IAAG,EACpE,EAAE,CACH,CAAC;IACF,OAAO,cAAc;SAClB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAiD,EAAE,EAAE,CAAC,iCACpE,WAAW,CAAC,EAAE,CAAC,KAClB,OAAO,IACP,CAAC;SACF,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CollectionPreferencesProps } from '../interfaces';\n\nexport interface OptionWithVisibility extends CollectionPreferencesProps.ContentDisplayOption {\n visible?: boolean;\n}\n\nexport function getSortedOptions({\n options,\n contentDisplay,\n}: {\n options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;\n contentDisplay: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}): ReadonlyArray<OptionWithVisibility> {\n const optionsById: Record<string, CollectionPreferencesProps.ContentDisplayOption> = options.reduce(\n (currentValue, option) => ({ ...currentValue, [option.id]: option }),\n {}\n );\n return contentDisplay\n .map(({ id, visible }: CollectionPreferencesProps.ContentDisplayItem) => ({\n ...optionsById[id],\n visible,\n }))\n .filter(Boolean);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { CollectionPreferencesProps } from './interfaces';
3
3
  export { CollectionPreferencesProps };
4
- export default function CollectionPreferences({ title, confirmLabel, cancelLabel, disabled, onConfirm, onCancel, visibleContentPreference, pageSizePreference, wrapLinesPreference, stripedRowsPreference, contentDensityPreference, preferences, customPreference, ...rest }: CollectionPreferencesProps): JSX.Element;
4
+ export default function CollectionPreferences({ title, confirmLabel, cancelLabel, disabled, onConfirm, onCancel, visibleContentPreference, contentDisplayPreference, pageSizePreference, wrapLinesPreference, stripedRowsPreference, contentDensityPreference, preferences, customPreference, ...rest }: CollectionPreferencesProps): JSX.Element;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAK1D,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAgB,EAChB,SAAS,EACT,QAAQ,EACR,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,0BAA0B,eA6I5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/index.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAO1D,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAItC,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,QAAgB,EAChB,SAAS,EACT,QAAQ,EACR,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,WAAW,EACX,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,0BAA0B,eA4J5B"}
@@ -15,10 +15,13 @@ import checkControlled from '../internal/hooks/check-controlled';
15
15
  import styles from './styles.css.js';
16
16
  import { applyDisplayName } from '../internal/utils/apply-display-name';
17
17
  import useBaseComponent from '../internal/hooks/use-base-component';
18
+ import ContentDisplayPreference from './content-display';
19
+ import { warnOnce } from '../internal/logging';
20
+ const componentName = 'CollectionPreferences';
18
21
  export default function CollectionPreferences(_a) {
19
- var { title, confirmLabel, cancelLabel, disabled = false, onConfirm, onCancel, visibleContentPreference, pageSizePreference, wrapLinesPreference, stripedRowsPreference, contentDensityPreference, preferences, customPreference } = _a, rest = __rest(_a, ["title", "confirmLabel", "cancelLabel", "disabled", "onConfirm", "onCancel", "visibleContentPreference", "pageSizePreference", "wrapLinesPreference", "stripedRowsPreference", "contentDensityPreference", "preferences", "customPreference"]);
20
- const { __internalRootRef } = useBaseComponent('CollectionPreferences');
21
- checkControlled('CollectionPreferences', 'preferences', preferences, 'onConfirm', onConfirm);
22
+ var { title, confirmLabel, cancelLabel, disabled = false, onConfirm, onCancel, visibleContentPreference, contentDisplayPreference, pageSizePreference, wrapLinesPreference, stripedRowsPreference, contentDensityPreference, preferences, customPreference } = _a, rest = __rest(_a, ["title", "confirmLabel", "cancelLabel", "disabled", "onConfirm", "onCancel", "visibleContentPreference", "contentDisplayPreference", "pageSizePreference", "wrapLinesPreference", "stripedRowsPreference", "contentDensityPreference", "preferences", "customPreference"]);
23
+ const { __internalRootRef } = useBaseComponent(componentName);
24
+ checkControlled(componentName, 'preferences', preferences, 'onConfirm', onConfirm);
22
25
  const baseProps = getBaseProps(rest);
23
26
  const [modalVisible, setModalVisible] = useState(false);
24
27
  const [temporaryPreferences, setTemporaryPreferences] = useState(copyPreferences(preferences || {}));
@@ -41,13 +44,16 @@ export default function CollectionPreferences(_a) {
41
44
  setModalVisible(false);
42
45
  setTemporaryPreferences(copyPreferences(preferences || {}));
43
46
  };
44
- const hasLeftContent = !!(pageSizePreference ||
47
+ const hasContentOnTheLeft = !!(pageSizePreference ||
45
48
  wrapLinesPreference ||
46
49
  stripedRowsPreference ||
47
50
  contentDensityPreference ||
48
51
  customPreference);
49
- const hasRightContent = !!visibleContentPreference;
52
+ const hasContentOnTheRight = !!(visibleContentPreference || contentDisplayPreference);
50
53
  const onChange = (changedPreferences) => setTemporaryPreferences(mergePreferences(changedPreferences, temporaryPreferences));
54
+ if (visibleContentPreference && contentDisplayPreference) {
55
+ warnOnce(componentName, 'You provided both `visibleContentPreference` and `contentDisplayPreference` props. `visibleContentPreference` will be ignored and only `contentDisplayPreference` will be rendered.');
56
+ }
51
57
  return (React.createElement("div", Object.assign({}, baseProps, { className: clsx(baseProps.className, styles.root), ref: __internalRootRef }),
52
58
  React.createElement(InternalButton, { ref: triggerRef, className: styles['trigger-button'], disabled: disabled, ariaLabel: title, onClick: () => {
53
59
  setTemporaryPreferences(copyPreferences(preferences || {}));
@@ -56,13 +62,13 @@ export default function CollectionPreferences(_a) {
56
62
  !disabled && modalVisible && (React.createElement(InternalModal, { className: styles['modal-root'], visible: true, header: title, footer: React.createElement(InternalBox, { float: "right" },
57
63
  React.createElement(InternalSpaceBetween, { direction: "horizontal", size: "xs" },
58
64
  React.createElement(InternalButton, { className: styles['cancel-button'], variant: "link", formAction: "none", onClick: onCancelListener }, cancelLabel),
59
- React.createElement(InternalButton, { className: styles['confirm-button'], variant: "primary", formAction: "none", onClick: onConfirmListener }, confirmLabel))), closeAriaLabel: cancelLabel, size: hasLeftContent && hasRightContent ? 'large' : 'medium', onDismiss: onCancelListener },
60
- React.createElement(ModalContentLayout, { left: hasLeftContent && (React.createElement(InternalSpaceBetween, { size: "l" },
65
+ React.createElement(InternalButton, { className: styles['confirm-button'], variant: "primary", formAction: "none", onClick: onConfirmListener }, confirmLabel))), closeAriaLabel: cancelLabel, size: hasContentOnTheLeft && hasContentOnTheRight ? 'large' : 'medium', onDismiss: onCancelListener },
66
+ React.createElement(ModalContentLayout, { left: hasContentOnTheLeft && (React.createElement(InternalSpaceBetween, { size: "l" },
61
67
  pageSizePreference && (React.createElement(PageSizePreference, Object.assign({ value: temporaryPreferences.pageSize }, pageSizePreference, { onChange: pageSize => onChange({ pageSize }) }))),
62
68
  wrapLinesPreference && (React.createElement(WrapLinesPreference, Object.assign({ value: temporaryPreferences.wrapLines }, wrapLinesPreference, { onChange: wrapLines => onChange({ wrapLines }) }))),
63
69
  stripedRowsPreference && (React.createElement(StripedRowsPreference, Object.assign({ value: temporaryPreferences.stripedRows }, stripedRowsPreference, { onChange: stripedRows => onChange({ stripedRows }) }))),
64
70
  contentDensityPreference && (React.createElement(ContentDensityPreference, Object.assign({ value: temporaryPreferences.contentDensity }, contentDensityPreference, { onChange: contentDensity => onChange({ contentDensity }) }))),
65
- customPreference && (React.createElement(CustomPreference, { value: temporaryPreferences.custom, customPreference: customPreference, onChange: custom => onChange({ custom }) })))), right: visibleContentPreference && (React.createElement(VisibleContentPreference, Object.assign({ value: temporaryPreferences.visibleContent }, visibleContentPreference, { onChange: visibleContent => onChange({ visibleContent }) }))) })))));
71
+ customPreference && (React.createElement(CustomPreference, { value: temporaryPreferences.custom, customPreference: customPreference, onChange: custom => onChange({ custom }) })))), right: contentDisplayPreference ? (React.createElement(ContentDisplayPreference, Object.assign({}, contentDisplayPreference, { value: temporaryPreferences.contentDisplay, onChange: contentDisplay => onChange({ contentDisplay }) }))) : (visibleContentPreference && (React.createElement(VisibleContentPreference, Object.assign({ value: temporaryPreferences.visibleContent }, visibleContentPreference, { onChange: visibleItems => onChange({ visibleContent: visibleItems }) })))) })))));
66
72
  }
67
- applyDisplayName(CollectionPreferences, 'CollectionPreferences');
73
+ applyDisplayName(CollectionPreferences, componentName);
68
74
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["collection-preferences/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,wBAAwB,MAAM,mBAAmB,CAAC;AACzD,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAEjE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAIpE,MAAM,CAAC,OAA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wBAAwB,IAC5B,QAAQ,EAAE,cAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,IACxD,CACH;oBACA,gBAAgB,IAAI,CACnB,oBAAC,gBAAgB,IACf,KAAK,EAAE,oBAAoB,CAAC,MAAM,EAClC,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,GACxC,CACH,CACoB,CACxB,EAEH,KAAK,EACH,wBAAwB,IAAI,CAC1B,oBAAC,wBAAwB,kBACvB,KAAK,EAAE,oBAAoB,CAAC,cAAc,IACtC,wBAAwB,IAC5B,QAAQ,EAAE,cAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,IACxD,CACH,GAEH,CACY,CACjB,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport InternalModal from '../modal/internal';\nimport InternalSpaceBetween from '../space-between/internal';\nimport {\n copyPreferences,\n mergePreferences,\n ModalContentLayout,\n PageSizePreference,\n WrapLinesPreference,\n StripedRowsPreference,\n ContentDensityPreference,\n CustomPreference,\n} from './utils';\nimport VisibleContentPreference from './visible-content';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { CollectionPreferencesProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\n\nexport { CollectionPreferencesProps };\n\nexport default function CollectionPreferences({\n title,\n confirmLabel,\n cancelLabel,\n disabled = false,\n onConfirm,\n onCancel,\n visibleContentPreference,\n pageSizePreference,\n wrapLinesPreference,\n stripedRowsPreference,\n contentDensityPreference,\n preferences,\n customPreference,\n ...rest\n}: CollectionPreferencesProps) {\n const { __internalRootRef } = useBaseComponent('CollectionPreferences');\n checkControlled('CollectionPreferences', 'preferences', preferences, 'onConfirm', onConfirm);\n const baseProps = getBaseProps(rest);\n const [modalVisible, setModalVisible] = useState(false);\n const [temporaryPreferences, setTemporaryPreferences] = useState(copyPreferences(preferences || {}));\n const triggerRef = useRef<ButtonProps.Ref>(null);\n const dialogPreviouslyOpen = useRef(false);\n useEffect(() => {\n if (!modalVisible) {\n dialogPreviouslyOpen.current && triggerRef.current && triggerRef.current.focus();\n } else {\n dialogPreviouslyOpen.current = true;\n }\n }, [modalVisible]);\n\n const onConfirmListener = () => {\n setModalVisible(false);\n fireNonCancelableEvent(onConfirm, temporaryPreferences);\n };\n\n const onCancelListener = () => {\n fireNonCancelableEvent(onCancel, {});\n setModalVisible(false);\n setTemporaryPreferences(copyPreferences(preferences || {}));\n };\n\n const hasLeftContent = !!(\n pageSizePreference ||\n wrapLinesPreference ||\n stripedRowsPreference ||\n contentDensityPreference ||\n customPreference\n );\n const hasRightContent = !!visibleContentPreference;\n\n const onChange = (changedPreferences: CollectionPreferencesProps.Preferences) =>\n setTemporaryPreferences(mergePreferences(changedPreferences, temporaryPreferences));\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <InternalButton\n ref={triggerRef}\n className={styles['trigger-button']}\n disabled={disabled}\n ariaLabel={title}\n onClick={() => {\n setTemporaryPreferences(copyPreferences(preferences || {}));\n setModalVisible(true);\n }}\n variant=\"icon\"\n iconName=\"settings\"\n formAction=\"none\"\n />\n {!disabled && modalVisible && (\n <InternalModal\n className={styles['modal-root']}\n visible={true}\n header={title}\n footer={\n <InternalBox float=\"right\">\n <InternalSpaceBetween direction=\"horizontal\" size=\"xs\">\n <InternalButton\n className={styles['cancel-button']}\n variant=\"link\"\n formAction=\"none\"\n onClick={onCancelListener}\n >\n {cancelLabel}\n </InternalButton>\n <InternalButton\n className={styles['confirm-button']}\n variant=\"primary\"\n formAction=\"none\"\n onClick={onConfirmListener}\n >\n {confirmLabel}\n </InternalButton>\n </InternalSpaceBetween>\n </InternalBox>\n }\n closeAriaLabel={cancelLabel}\n size={hasLeftContent && hasRightContent ? 'large' : 'medium'}\n onDismiss={onCancelListener}\n >\n <ModalContentLayout\n left={\n hasLeftContent && (\n <InternalSpaceBetween size=\"l\">\n {pageSizePreference && (\n <PageSizePreference\n value={temporaryPreferences.pageSize}\n {...pageSizePreference}\n onChange={pageSize => onChange({ pageSize })}\n />\n )}\n {wrapLinesPreference && (\n <WrapLinesPreference\n value={temporaryPreferences.wrapLines}\n {...wrapLinesPreference}\n onChange={wrapLines => onChange({ wrapLines })}\n />\n )}\n {stripedRowsPreference && (\n <StripedRowsPreference\n value={temporaryPreferences.stripedRows}\n {...stripedRowsPreference}\n onChange={stripedRows => onChange({ stripedRows })}\n />\n )}\n {contentDensityPreference && (\n <ContentDensityPreference\n value={temporaryPreferences.contentDensity}\n {...contentDensityPreference}\n onChange={contentDensity => onChange({ contentDensity })}\n />\n )}\n {customPreference && (\n <CustomPreference\n value={temporaryPreferences.custom}\n customPreference={customPreference}\n onChange={custom => onChange({ custom })}\n />\n )}\n </InternalSpaceBetween>\n )\n }\n right={\n visibleContentPreference && (\n <VisibleContentPreference\n value={temporaryPreferences.visibleContent}\n {...visibleContentPreference}\n onChange={visibleContent => onChange({ visibleContent })}\n />\n )\n }\n />\n </InternalModal>\n )}\n </div>\n );\n}\n\napplyDisplayName(CollectionPreferences, 'CollectionPreferences');\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["collection-preferences/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EA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,EAClC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,GACxC,CACH,CACoB,CACxB,EAEH,KAAK,EACH,wBAAwB,CAAC,CAAC,CAAC,CACzB,oBAAC,wBAAwB,oBACnB,wBAAwB,IAC5B,KAAK,EAAE,oBAAoB,CAAC,cAAc,EAC1C,QAAQ,EAAE,cAAc,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC,IACxD,CACH,CAAC,CAAC,CAAC,CACF,wBAAwB,IAAI,CAC1B,oBAAC,wBAAwB,kBACvB,KAAK,EAAE,oBAAoB,CAAC,cAAc,IACtC,wBAAwB,IAC5B,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,IACpE,CACH,CACF,GAEH,CACY,CACjB,CACG,CACP,CAAC;AACJ,CAAC;AAED,gBAAgB,CAAC,qBAAqB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { getBaseProps } from '../internal/base-component';\nimport InternalBox from '../box/internal';\nimport { ButtonProps } from '../button/interfaces';\nimport { InternalButton } from '../button/internal';\nimport InternalModal from '../modal/internal';\nimport InternalSpaceBetween from '../space-between/internal';\nimport {\n copyPreferences,\n mergePreferences,\n ModalContentLayout,\n PageSizePreference,\n WrapLinesPreference,\n StripedRowsPreference,\n ContentDensityPreference,\n CustomPreference,\n} from './utils';\nimport VisibleContentPreference from './visible-content';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { CollectionPreferencesProps } from './interfaces';\nimport styles from './styles.css.js';\nimport { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport ContentDisplayPreference from './content-display';\nimport { warnOnce } from '../internal/logging';\n\nexport { CollectionPreferencesProps };\n\nconst componentName = 'CollectionPreferences';\n\nexport default function CollectionPreferences({\n title,\n confirmLabel,\n cancelLabel,\n disabled = false,\n onConfirm,\n onCancel,\n visibleContentPreference,\n contentDisplayPreference,\n pageSizePreference,\n wrapLinesPreference,\n stripedRowsPreference,\n contentDensityPreference,\n preferences,\n customPreference,\n ...rest\n}: CollectionPreferencesProps) {\n const { __internalRootRef } = useBaseComponent(componentName);\n checkControlled(componentName, 'preferences', preferences, 'onConfirm', onConfirm);\n const baseProps = getBaseProps(rest);\n const [modalVisible, setModalVisible] = useState(false);\n const [temporaryPreferences, setTemporaryPreferences] = useState(copyPreferences(preferences || {}));\n const triggerRef = useRef<ButtonProps.Ref>(null);\n const dialogPreviouslyOpen = useRef(false);\n useEffect(() => {\n if (!modalVisible) {\n dialogPreviouslyOpen.current && triggerRef.current && triggerRef.current.focus();\n } else {\n dialogPreviouslyOpen.current = true;\n }\n }, [modalVisible]);\n\n const onConfirmListener = () => {\n setModalVisible(false);\n fireNonCancelableEvent(onConfirm, temporaryPreferences);\n };\n\n const onCancelListener = () => {\n fireNonCancelableEvent(onCancel, {});\n setModalVisible(false);\n setTemporaryPreferences(copyPreferences(preferences || {}));\n };\n\n const hasContentOnTheLeft = !!(\n pageSizePreference ||\n wrapLinesPreference ||\n stripedRowsPreference ||\n contentDensityPreference ||\n customPreference\n );\n const hasContentOnTheRight = !!(visibleContentPreference || contentDisplayPreference);\n\n const onChange = (changedPreferences: CollectionPreferencesProps.Preferences) =>\n setTemporaryPreferences(mergePreferences(changedPreferences, temporaryPreferences));\n\n if (visibleContentPreference && contentDisplayPreference) {\n warnOnce(\n componentName,\n 'You provided both `visibleContentPreference` and `contentDisplayPreference` props. `visibleContentPreference` will be ignored and only `contentDisplayPreference` will be rendered.'\n );\n }\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <InternalButton\n ref={triggerRef}\n className={styles['trigger-button']}\n disabled={disabled}\n ariaLabel={title}\n onClick={() => {\n setTemporaryPreferences(copyPreferences(preferences || {}));\n setModalVisible(true);\n }}\n variant=\"icon\"\n iconName=\"settings\"\n formAction=\"none\"\n />\n {!disabled && modalVisible && (\n <InternalModal\n className={styles['modal-root']}\n visible={true}\n header={title}\n footer={\n <InternalBox float=\"right\">\n <InternalSpaceBetween direction=\"horizontal\" size=\"xs\">\n <InternalButton\n className={styles['cancel-button']}\n variant=\"link\"\n formAction=\"none\"\n onClick={onCancelListener}\n >\n {cancelLabel}\n </InternalButton>\n <InternalButton\n className={styles['confirm-button']}\n variant=\"primary\"\n formAction=\"none\"\n onClick={onConfirmListener}\n >\n {confirmLabel}\n </InternalButton>\n </InternalSpaceBetween>\n </InternalBox>\n }\n closeAriaLabel={cancelLabel}\n size={hasContentOnTheLeft && hasContentOnTheRight ? 'large' : 'medium'}\n onDismiss={onCancelListener}\n >\n <ModalContentLayout\n left={\n hasContentOnTheLeft && (\n <InternalSpaceBetween size=\"l\">\n {pageSizePreference && (\n <PageSizePreference\n value={temporaryPreferences.pageSize}\n {...pageSizePreference}\n onChange={pageSize => onChange({ pageSize })}\n />\n )}\n {wrapLinesPreference && (\n <WrapLinesPreference\n value={temporaryPreferences.wrapLines}\n {...wrapLinesPreference}\n onChange={wrapLines => onChange({ wrapLines })}\n />\n )}\n {stripedRowsPreference && (\n <StripedRowsPreference\n value={temporaryPreferences.stripedRows}\n {...stripedRowsPreference}\n onChange={stripedRows => onChange({ stripedRows })}\n />\n )}\n {contentDensityPreference && (\n <ContentDensityPreference\n value={temporaryPreferences.contentDensity}\n {...contentDensityPreference}\n onChange={contentDensity => onChange({ contentDensity })}\n />\n )}\n {customPreference && (\n <CustomPreference\n value={temporaryPreferences.custom}\n customPreference={customPreference}\n onChange={custom => onChange({ custom })}\n />\n )}\n </InternalSpaceBetween>\n )\n }\n right={\n contentDisplayPreference ? (\n <ContentDisplayPreference\n {...contentDisplayPreference}\n value={temporaryPreferences.contentDisplay}\n onChange={contentDisplay => onChange({ contentDisplay })}\n />\n ) : (\n visibleContentPreference && (\n <VisibleContentPreference\n value={temporaryPreferences.visibleContent}\n {...visibleContentPreference}\n onChange={visibleItems => onChange({ visibleContent: visibleItems })}\n />\n )\n )\n }\n />\n </InternalModal>\n )}\n </div>\n );\n}\n\napplyDisplayName(CollectionPreferences, componentName);\n"]}
@@ -68,6 +68,30 @@ export interface CollectionPreferencesProps<CustomPreferenceType = any> extends
68
68
  * You must set the current value in the `preferences.contentDensity` property.
69
69
  */
70
70
  contentDensityPreference?: CollectionPreferencesProps.ContentDensityPreference;
71
+ /**
72
+ * Configures the built-in content display preference for order and visibility of columns in a table.
73
+ *
74
+ * Once set, the component displays this preference in the modal.
75
+ *
76
+ * It contains the following:
77
+ * - `title` (string) - Specifies the text displayed at the top of the preference.
78
+ * - `description` (string) - Specifies the description displayed below the title.
79
+ * - `liveAnnouncementDndStarted` ((position: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an option is picked.
80
+ * - `liveAnnouncementDndDiscarded` (string) - (Optional) Adds a message to be announced by screen readers when a reordering action is canceled.
81
+ * - `liveAnnouncementDndItemReordered` ((initialPosition: number, currentPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an item is being moved.
82
+ * - `liveAnnouncementDndItemCommitted` ((initialPosition: number, finalPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when a reordering action is committed.
83
+ * - `dragHandleAriaDescription` (string) - (Optional) Adds an ARIA description for the drag handle.
84
+ * - `dragHandleAriaLabel` (string) - (Optional) Adds an ARIA label for the drag handle.
85
+ * - `options` - Specifies an array of options for reordering and visible content selection.
86
+ *
87
+ * Each option contains the following:
88
+ * - `id` (string) - Corresponds to a table column `id`.
89
+ * - `label` (string) - Specifies a short description of the content.
90
+ * - `alwaysVisible` (boolean) - (Optional) Determines whether the visibility is always on and therefore cannot be toggled. This is set to `false` by default.
91
+ *
92
+ * You must provide an ordered list of the items to display in the `preferences.contentDisplay` property.
93
+ */
94
+ contentDisplayPreference?: CollectionPreferencesProps.ContentDisplayPreference;
71
95
  /**
72
96
  * Configures the built-in "visible content selection" preference (for example, visible columns in a table).
73
97
  *
@@ -93,7 +117,8 @@ export interface CollectionPreferencesProps<CustomPreferenceType = any> extends
93
117
  * It contains the following:
94
118
  * - `pageSize` (number) - (Optional)
95
119
  * - `wrapLines` (boolean) - (Optional)
96
- * - `visibleContent` (ReadonlyArray<string>) - Specifies the list of visible content `id`s. The order of the `id`s does not influence the display.
120
+ * - `contentDisplay` (ReadonlyArray<ContentDisplayItem>) - (Optional) Specifies the list of content and their visibility. The order of the elements influences the display.
121
+ * - `visibleContent` (ReadonlyArray<string>) - Specifies the list of visible content `id`s. The order of the `id`s does not influence the display. If the `contentDisplay` property is set, this property is ignored.
97
122
  * - `custom` (CustomPreferenceType) - Specifies the value for your custom preference.
98
123
  */
99
124
  preferences?: CollectionPreferencesProps.Preferences<CustomPreferenceType>;
@@ -143,8 +168,29 @@ export declare namespace CollectionPreferencesProps {
143
168
  stripedRows?: boolean;
144
169
  contentDensity?: 'comfortable' | 'compact';
145
170
  visibleContent?: ReadonlyArray<string>;
171
+ contentDisplay?: ReadonlyArray<ContentDisplayItem>;
146
172
  custom?: CustomPreferenceType;
147
173
  }
174
+ interface ContentDisplayPreference {
175
+ title: string;
176
+ description?: string;
177
+ options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;
178
+ liveAnnouncementDndStarted?: (position: number, total: number) => string;
179
+ liveAnnouncementDndItemReordered?: (initialPosition: number, currentPosition: number, total: number) => string;
180
+ liveAnnouncementDndItemCommitted?: (initialPosition: number, finalPosition: number, total: number) => string;
181
+ liveAnnouncementDndDiscarded?: string;
182
+ dragHandleAriaLabel?: string;
183
+ dragHandleAriaDescription?: string;
184
+ }
185
+ interface ContentDisplayOption {
186
+ id: string;
187
+ label: string;
188
+ alwaysVisible?: boolean;
189
+ }
190
+ interface ContentDisplayItem {
191
+ id: string;
192
+ visible: boolean;
193
+ }
148
194
  interface VisibleContentPreference {
149
195
  title: string;
150
196
  options: ReadonlyArray<CollectionPreferencesProps.VisibleContentOptionsGroup>;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["collection-preferences/interfaces.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,MAAM,WAAW,0BAA0B,CAAC,oBAAoB,GAAG,GAAG,CAAE,SAAQ,kBAAkB;IAChG;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,0BAA0B,CAAC,kBAAkB,CAAC;IACnE;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,0BAA0B,CAAC,mBAAmB,CAAC;IACrE;;;;;;;;;;OAUG;IACH,qBAAqB,CAAC,EAAE,0BAA0B,CAAC,qBAAqB,CAAC;IACzE;;;;;;;;;;OAUG;IACH,wBAAwB,CAAC,EAAE,0BAA0B,CAAC,wBAAwB,CAAC;IAC/E;;;;;;;;;;;;;;;;;OAiBG;IACH,wBAAwB,CAAC,EAAE,0BAA0B,CAAC,wBAAwB,CAAC;IAC/E;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,0BAA0B,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAC3E;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,gBAAgB,CAAC,EAAE,CACjB,WAAW,EAAE,oBAAoB,EACjC,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,KACjD,KAAK,CAAC,SAAS,CAAC;IACr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;QACnC,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB;IAED,UAAiB,kBAAkB;QACjC,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,OAAO,CAAC;KAClB;IAED,UAAiB,wBAAwB;QACvC,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,aAAa,CAAC,0BAA0B,CAAC,0BAA0B,CAAC,CAAC;KAC/E;IAED,UAAiB,0BAA0B;QACzC,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,aAAa,CAAC,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;KACzE;IAED,UAAiB,oBAAoB;QACnC,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;IAED,UAAiB,kBAAkB;QACjC,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;KACxC;IAED,UAAiB,cAAc;QAC7B,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf;IAED,UAAiB,mBAAmB;QAClC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB;IAED,UAAiB,qBAAqB;QACpC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB;IAED,UAAiB,wBAAwB;QACvC,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["collection-preferences/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CollectionPreferencesProps<CustomPreferenceType = any> extends BaseComponentProps {\n /**\n * Specifies the title of the preferences modal dialog. It is also used as an `aria-label` for the trigger button.\n */\n title: string;\n /**\n * Label of the confirm button in the modal footer.\n */\n confirmLabel: string;\n /**\n * Label of the cancel button in the modal footer.\n */\n cancelLabel: string;\n /**\n * Determines whether the preferences trigger button is disabled.\n */\n disabled?: boolean;\n /**\n * Configures the built-in \"page size selection\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `title` (string) - Specifies the text displayed at the top of the preference.\n * - `options` - Specifies an array of options for page size selection. Each entry contains:\n * - `value` (number) - The value for the radio button (that is, the number of items per page).\n * - `label` (string) - A label for the radio button (for example, \"10 resources\").\n *\n * You must set the current value in the `preferences.pageSize` property.\n */\n pageSizePreference?: CollectionPreferencesProps.PageSizePreference;\n /**\n * Configures the built-in \"wrap lines\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.wrapLines` property.\n */\n wrapLinesPreference?: CollectionPreferencesProps.WrapLinesPreference;\n /**\n * Configures the built-in \"striped rows\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.stripedRows` property.\n */\n stripedRowsPreference?: CollectionPreferencesProps.StripedRowsPreference;\n /**\n * Configures the content density preference (Comfortable / Compact).\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.contentDensity` property.\n */\n contentDensityPreference?: CollectionPreferencesProps.ContentDensityPreference;\n /**\n * Configures the built-in \"visible content selection\" preference (for example, visible columns in a table).\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `title` (string) - Specifies the text displayed at the top of the preference.\n * - `options` - Specifies an array of groups of options for visible content selection.\n *\n * Each group of options contains the following:\n * - `label` (string) - The text to display as a title for the options group.\n * - `options` - Specifies an aray of options in the group. Each option contains the following:\n * - `id` (string) - Corresponds to a column `id` for tables or to a section `id` for cards.\n * - `label` (string) - Specifies a short description of the content.\n * - `editable` (boolean) - (Optional) Determines whether the user is able to toggle its visibility. This is `true` by default.\n *\n * You must set the current list of visible content `id`s in the `preferences.visibleContent` property.\n */\n visibleContentPreference?: CollectionPreferencesProps.VisibleContentPreference;\n /**\n * Specifies the current preference values. This includes both built-in and custom preferences.\n *\n * It contains the following:\n * - `pageSize` (number) - (Optional)\n * - `wrapLines` (boolean) - (Optional)\n * - `visibleContent` (ReadonlyArray<string>) - Specifies the list of visible content `id`s. The order of the `id`s does not influence the display.\n * - `custom` (CustomPreferenceType) - Specifies the value for your custom preference.\n */\n preferences?: CollectionPreferencesProps.Preferences<CustomPreferenceType>;\n /**\n * Configures custom preferences. The function receives two parameters:\n *\n * - `customValue` (CustomPreferenceType) - Current value for your custom preference. It is initialized using the value you provide in `preferences.custom`.\n * - `setCustomValue` - A function that is called to notify a state update.\n *\n * It should return the content of your custom preference, for example:\n * ```\n * (customValue, setCustomValue) => (\n * <Checkbox checked={customValue} onChange={({ detail }) => setCustomValue(detail.checked)} />\n * )\n * ```\n *\n * When the user confirms the changes, the new value is passed in the `detail.custom` property of the `onConfirm` listener.\n * When the user cancels the changes, the `customValue` is reset to the one present in `preferences.custom` property.\n *\n * **Display**\n * - If any of the built-in preferences (`pageSizePreference`, `wrapLinesPreference`, or `visibleContentPreference`) are displayed,\n * the custom content is displayed at the bottom of the left column within the modal.\n * - If no built-in preference is displayed, the custom content occupies the whole modal.\n */\n customPreference?: (\n customValue: CustomPreferenceType,\n setCustomValue: React.Dispatch<CustomPreferenceType>\n ) => React.ReactNode;\n /**\n * Called when the user cancels a preference change using the cancel button in the modal footer or by dismissing the modal.\n */\n onCancel?: NonCancelableEventHandler;\n /**\n * Called when the user confirms a preference change using the confirm button in the modal footer.\n *\n * The event `detail` contains the following:\n * - `pageSize` (number) - (Optional) The selected page size value. Available only if you specify the `pageSizePreference` property.\n * - `wrapLines` (boolean) - (Optional) The current line wrapping preference value. Available only if you specify the `wrapLinesPreference` property.\n * - `visibleContent` (ReadonlyArray<string>) - (Optional) The list of selected content `id`s. Available only if you specify the `visibleContentPreference` property.\n * - `custom` (CustomPreferenceType) - (Optional) The selected value for your custom preference.\n *\n * The values for all configured preferences are present even if the user didn't change their values.\n */\n onConfirm?: NonCancelableEventHandler<CollectionPreferencesProps.Preferences<CustomPreferenceType>>;\n}\n\nexport namespace CollectionPreferencesProps {\n export interface Preferences<CustomPreferenceType = any> {\n pageSize?: number;\n wrapLines?: boolean;\n stripedRows?: boolean;\n contentDensity?: 'comfortable' | 'compact';\n visibleContent?: ReadonlyArray<string>;\n custom?: CustomPreferenceType;\n }\n\n export interface VisibleContentPreference {\n title: string;\n options: ReadonlyArray<CollectionPreferencesProps.VisibleContentOptionsGroup>;\n }\n\n export interface VisibleContentOptionsGroup {\n label: string;\n options: ReadonlyArray<CollectionPreferencesProps.VisibleContentOption>;\n }\n\n export interface VisibleContentOption {\n id: string;\n label: string;\n editable?: boolean;\n }\n\n export interface PageSizePreference {\n title: string;\n options: ReadonlyArray<PageSizeOption>;\n }\n\n export interface PageSizeOption {\n value: number;\n label: string;\n }\n\n export interface WrapLinesPreference {\n label: string;\n description: string;\n }\n\n export interface StripedRowsPreference {\n label: string;\n description: string;\n }\n\n export interface ContentDensityPreference {\n label: string;\n description: string;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["collection-preferences/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BaseComponentProps } from '../internal/base-component';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface CollectionPreferencesProps<CustomPreferenceType = any> extends BaseComponentProps {\n /**\n * Specifies the title of the preferences modal dialog. It is also used as an `aria-label` for the trigger button.\n */\n title: string;\n /**\n * Label of the confirm button in the modal footer.\n */\n confirmLabel: string;\n /**\n * Label of the cancel button in the modal footer.\n */\n cancelLabel: string;\n /**\n * Determines whether the preferences trigger button is disabled.\n */\n disabled?: boolean;\n /**\n * Configures the built-in \"page size selection\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `title` (string) - Specifies the text displayed at the top of the preference.\n * - `options` - Specifies an array of options for page size selection. Each entry contains:\n * - `value` (number) - The value for the radio button (that is, the number of items per page).\n * - `label` (string) - A label for the radio button (for example, \"10 resources\").\n *\n * You must set the current value in the `preferences.pageSize` property.\n */\n pageSizePreference?: CollectionPreferencesProps.PageSizePreference;\n /**\n * Configures the built-in \"wrap lines\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.wrapLines` property.\n */\n wrapLinesPreference?: CollectionPreferencesProps.WrapLinesPreference;\n /**\n * Configures the built-in \"striped rows\" preference.\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.stripedRows` property.\n */\n stripedRowsPreference?: CollectionPreferencesProps.StripedRowsPreference;\n /**\n * Configures the content density preference (Comfortable / Compact).\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `label` (string) - Specifies the label for the option checkbox.\n * - `description` (string) - Specifies the text displayed below the checkbox label.\n *\n * You must set the current value in the `preferences.contentDensity` property.\n */\n contentDensityPreference?: CollectionPreferencesProps.ContentDensityPreference;\n /**\n * Configures the built-in content display preference for order and visibility of columns in a table.\n *\n * Once set, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `title` (string) - Specifies the text displayed at the top of the preference.\n * - `description` (string) - Specifies the description displayed below the title.\n * - `liveAnnouncementDndStarted` ((position: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an option is picked.\n * - `liveAnnouncementDndDiscarded` (string) - (Optional) Adds a message to be announced by screen readers when a reordering action is canceled.\n * - `liveAnnouncementDndItemReordered` ((initialPosition: number, currentPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when an item is being moved.\n * - `liveAnnouncementDndItemCommitted` ((initialPosition: number, finalPosition: number, total: number) => string) - (Optional) Adds a message to be announced by screen readers when a reordering action is committed.\n * - `dragHandleAriaDescription` (string) - (Optional) Adds an ARIA description for the drag handle.\n * - `dragHandleAriaLabel` (string) - (Optional) Adds an ARIA label for the drag handle.\n * - `options` - Specifies an array of options for reordering and visible content selection.\n *\n * Each option contains the following:\n * - `id` (string) - Corresponds to a table column `id`.\n * - `label` (string) - Specifies a short description of the content.\n * - `alwaysVisible` (boolean) - (Optional) Determines whether the visibility is always on and therefore cannot be toggled. This is set to `false` by default.\n *\n * You must provide an ordered list of the items to display in the `preferences.contentDisplay` property.\n */\n contentDisplayPreference?: CollectionPreferencesProps.ContentDisplayPreference;\n /**\n * Configures the built-in \"visible content selection\" preference (for example, visible columns in a table).\n *\n * If you set it, the component displays this preference in the modal.\n *\n * It contains the following:\n * - `title` (string) - Specifies the text displayed at the top of the preference.\n * - `options` - Specifies an array of groups of options for visible content selection.\n *\n * Each group of options contains the following:\n * - `label` (string) - The text to display as a title for the options group.\n * - `options` - Specifies an aray of options in the group. Each option contains the following:\n * - `id` (string) - Corresponds to a column `id` for tables or to a section `id` for cards.\n * - `label` (string) - Specifies a short description of the content.\n * - `editable` (boolean) - (Optional) Determines whether the user is able to toggle its visibility. This is `true` by default.\n *\n * You must set the current list of visible content `id`s in the `preferences.visibleContent` property.\n */\n visibleContentPreference?: CollectionPreferencesProps.VisibleContentPreference;\n /**\n * Specifies the current preference values. This includes both built-in and custom preferences.\n *\n * It contains the following:\n * - `pageSize` (number) - (Optional)\n * - `wrapLines` (boolean) - (Optional)\n * - `contentDisplay` (ReadonlyArray<ContentDisplayItem>) - (Optional) Specifies the list of content and their visibility. The order of the elements influences the display.\n * - `visibleContent` (ReadonlyArray<string>) - Specifies the list of visible content `id`s. The order of the `id`s does not influence the display. If the `contentDisplay` property is set, this property is ignored.\n * - `custom` (CustomPreferenceType) - Specifies the value for your custom preference.\n */\n preferences?: CollectionPreferencesProps.Preferences<CustomPreferenceType>;\n /**\n * Configures custom preferences. The function receives two parameters:\n *\n * - `customValue` (CustomPreferenceType) - Current value for your custom preference. It is initialized using the value you provide in `preferences.custom`.\n * - `setCustomValue` - A function that is called to notify a state update.\n *\n * It should return the content of your custom preference, for example:\n * ```\n * (customValue, setCustomValue) => (\n * <Checkbox checked={customValue} onChange={({ detail }) => setCustomValue(detail.checked)} />\n * )\n * ```\n *\n * When the user confirms the changes, the new value is passed in the `detail.custom` property of the `onConfirm` listener.\n * When the user cancels the changes, the `customValue` is reset to the one present in `preferences.custom` property.\n *\n * **Display**\n * - If any of the built-in preferences (`pageSizePreference`, `wrapLinesPreference`, or `visibleContentPreference`) are displayed,\n * the custom content is displayed at the bottom of the left column within the modal.\n * - If no built-in preference is displayed, the custom content occupies the whole modal.\n */\n customPreference?: (\n customValue: CustomPreferenceType,\n setCustomValue: React.Dispatch<CustomPreferenceType>\n ) => React.ReactNode;\n /**\n * Called when the user cancels a preference change using the cancel button in the modal footer or by dismissing the modal.\n */\n onCancel?: NonCancelableEventHandler;\n /**\n * Called when the user confirms a preference change using the confirm button in the modal footer.\n *\n * The event `detail` contains the following:\n * - `pageSize` (number) - (Optional) The selected page size value. Available only if you specify the `pageSizePreference` property.\n * - `wrapLines` (boolean) - (Optional) The current line wrapping preference value. Available only if you specify the `wrapLinesPreference` property.\n * - `visibleContent` (ReadonlyArray<string>) - (Optional) The list of selected content `id`s. Available only if you specify the `visibleContentPreference` property.\n * - `custom` (CustomPreferenceType) - (Optional) The selected value for your custom preference.\n *\n * The values for all configured preferences are present even if the user didn't change their values.\n */\n onConfirm?: NonCancelableEventHandler<CollectionPreferencesProps.Preferences<CustomPreferenceType>>;\n}\n\nexport namespace CollectionPreferencesProps {\n export interface Preferences<CustomPreferenceType = any> {\n pageSize?: number;\n wrapLines?: boolean;\n stripedRows?: boolean;\n contentDensity?: 'comfortable' | 'compact';\n visibleContent?: ReadonlyArray<string>;\n contentDisplay?: ReadonlyArray<ContentDisplayItem>;\n custom?: CustomPreferenceType;\n }\n\n export interface ContentDisplayPreference {\n title: string;\n description?: string;\n options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;\n liveAnnouncementDndStarted?: (position: number, total: number) => string;\n liveAnnouncementDndItemReordered?: (initialPosition: number, currentPosition: number, total: number) => string;\n liveAnnouncementDndItemCommitted?: (initialPosition: number, finalPosition: number, total: number) => string;\n liveAnnouncementDndDiscarded?: string;\n dragHandleAriaLabel?: string;\n dragHandleAriaDescription?: string;\n }\n\n export interface ContentDisplayOption {\n id: string;\n label: string;\n alwaysVisible?: boolean;\n }\n\n export interface ContentDisplayItem {\n id: string;\n visible: boolean;\n }\n\n export interface VisibleContentPreference {\n title: string;\n options: ReadonlyArray<CollectionPreferencesProps.VisibleContentOptionsGroup>;\n }\n\n export interface VisibleContentOptionsGroup {\n label: string;\n options: ReadonlyArray<CollectionPreferencesProps.VisibleContentOption>;\n }\n\n export interface VisibleContentOption {\n id: string;\n label: string;\n editable?: boolean;\n }\n\n export interface PageSizePreference {\n title: string;\n options: ReadonlyArray<PageSizeOption>;\n }\n\n export interface PageSizeOption {\n value: number;\n label: string;\n }\n\n export interface WrapLinesPreference {\n label: string;\n description: string;\n }\n\n export interface StripedRowsPreference {\n label: string;\n description: string;\n }\n\n export interface ContentDensityPreference {\n label: string;\n description: string;\n }\n}\n"]}