@cloudscape-design/components-themeable 3.0.1308 → 3.0.1310

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 (195) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/badge/styles.scss +19 -6
  3. package/lib/internal/scss/collection-preferences/content-display/content-display-list.scss +10 -0
  4. package/lib/internal/scss/collection-preferences/content-display/content-display-option.scss +12 -0
  5. package/lib/internal/scss/expandable-section/styles.scss +2 -2
  6. package/lib/internal/scss/icon/mixins.scss +7 -0
  7. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  8. package/lib/internal/scss/table/header-cell/styles.scss +42 -5
  9. package/lib/internal/scss/table/resizer/styles.scss +26 -13
  10. package/lib/internal/scss/table/styles.scss +9 -0
  11. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.d.ts.map +1 -1
  12. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js +4 -2
  13. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-ai-drawer.js.map +1 -1
  14. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.d.ts.map +1 -1
  15. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.js +4 -2
  16. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-bottom-drawer.js.map +1 -1
  17. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.d.ts.map +1 -1
  18. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js +3 -2
  19. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/global-drawer.js.map +1 -1
  20. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.d.ts.map +1 -1
  21. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js +2 -2
  22. package/lib/internal/template/app-layout/visual-refresh-toolbar/drawer/local-drawer.js.map +1 -1
  23. package/lib/internal/template/app-layout/visual-refresh-toolbar/interfaces.d.ts +1 -0
  24. package/lib/internal/template/app-layout/visual-refresh-toolbar/interfaces.d.ts.map +1 -1
  25. package/lib/internal/template/app-layout/visual-refresh-toolbar/interfaces.js.map +1 -1
  26. package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-app-layout.d.ts.map +1 -1
  27. package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-app-layout.js +12 -1
  28. package/lib/internal/template/app-layout/visual-refresh-toolbar/state/use-app-layout.js.map +1 -1
  29. package/lib/internal/template/badge/styles.css.js +10 -10
  30. package/lib/internal/template/badge/styles.scoped.css +29 -16
  31. package/lib/internal/template/badge/styles.selectors.js +10 -10
  32. package/lib/internal/template/collection-preferences/content-display/content-display-option.js +1 -1
  33. package/lib/internal/template/collection-preferences/content-display/content-display-option.js.map +1 -1
  34. package/lib/internal/template/collection-preferences/content-display/index.d.ts +1 -1
  35. package/lib/internal/template/collection-preferences/content-display/index.d.ts.map +1 -1
  36. package/lib/internal/template/collection-preferences/content-display/index.js +63 -27
  37. package/lib/internal/template/collection-preferences/content-display/index.js.map +1 -1
  38. package/lib/internal/template/collection-preferences/content-display/utils.d.ts +40 -1
  39. package/lib/internal/template/collection-preferences/content-display/utils.d.ts.map +1 -1
  40. package/lib/internal/template/collection-preferences/content-display/utils.js +107 -13
  41. package/lib/internal/template/collection-preferences/content-display/utils.js.map +1 -1
  42. package/lib/internal/template/collection-preferences/index.d.ts.map +1 -1
  43. package/lib/internal/template/collection-preferences/index.js +2 -2
  44. package/lib/internal/template/collection-preferences/index.js.map +1 -1
  45. package/lib/internal/template/collection-preferences/interfaces.d.ts +30 -2
  46. package/lib/internal/template/collection-preferences/interfaces.d.ts.map +1 -1
  47. package/lib/internal/template/collection-preferences/interfaces.js.map +1 -1
  48. package/lib/internal/template/collection-preferences/styles.css.js +38 -36
  49. package/lib/internal/template/collection-preferences/styles.scoped.css +81 -37
  50. package/lib/internal/template/collection-preferences/styles.selectors.js +38 -36
  51. package/lib/internal/template/collection-preferences/utils.d.ts +1 -0
  52. package/lib/internal/template/collection-preferences/utils.d.ts.map +1 -1
  53. package/lib/internal/template/collection-preferences/utils.js +14 -0
  54. package/lib/internal/template/collection-preferences/utils.js.map +1 -1
  55. package/lib/internal/template/expandable-section/styles.css.js +35 -35
  56. package/lib/internal/template/expandable-section/styles.scoped.css +68 -68
  57. package/lib/internal/template/expandable-section/styles.selectors.js +35 -35
  58. package/lib/internal/template/i18n/messages/all.all.js +1 -1
  59. package/lib/internal/template/i18n/messages/all.all.json +1 -1
  60. package/lib/internal/template/i18n/messages/all.en.js +1 -1
  61. package/lib/internal/template/i18n/messages/all.en.json +1 -1
  62. package/lib/internal/template/i18n/messages-types.d.ts +4 -0
  63. package/lib/internal/template/i18n/messages-types.d.ts.map +1 -1
  64. package/lib/internal/template/i18n/messages-types.js.map +1 -1
  65. package/lib/internal/template/icon/interfaces.d.ts +1 -1
  66. package/lib/internal/template/icon/interfaces.d.ts.map +1 -1
  67. package/lib/internal/template/icon/interfaces.js.map +1 -1
  68. package/lib/internal/template/icon/internal.js +2 -2
  69. package/lib/internal/template/icon/internal.js.map +1 -1
  70. package/lib/internal/template/icon/styles.css.js +41 -39
  71. package/lib/internal/template/icon/styles.scoped.css +104 -85
  72. package/lib/internal/template/icon/styles.selectors.js +41 -39
  73. package/lib/internal/template/internal/base-component/styles.scoped.css +57 -5
  74. package/lib/internal/template/internal/environment.js +2 -2
  75. package/lib/internal/template/internal/environment.json +2 -2
  76. package/lib/internal/template/internal/generated/styles/tokens.d.ts +23 -1
  77. package/lib/internal/template/internal/generated/styles/tokens.js +23 -1
  78. package/lib/internal/template/internal/generated/theming/index.cjs +476 -4
  79. package/lib/internal/template/internal/generated/theming/index.cjs.d.ts +216 -0
  80. package/lib/internal/template/internal/generated/theming/index.d.ts +216 -0
  81. package/lib/internal/template/internal/generated/theming/index.js +476 -4
  82. package/lib/internal/template/internal/hooks/use-width-change/index.d.ts +13 -0
  83. package/lib/internal/template/internal/hooks/use-width-change/index.d.ts.map +1 -0
  84. package/lib/internal/template/internal/hooks/use-width-change/index.js +33 -0
  85. package/lib/internal/template/internal/hooks/use-width-change/index.js.map +1 -0
  86. package/lib/internal/template/pagination/internal.d.ts.map +1 -1
  87. package/lib/internal/template/pagination/internal.js +4 -1
  88. package/lib/internal/template/pagination/internal.js.map +1 -1
  89. package/lib/internal/template/prompt-input/internal.d.ts.map +1 -1
  90. package/lib/internal/template/prompt-input/internal.js +9 -2
  91. package/lib/internal/template/prompt-input/internal.js.map +1 -1
  92. package/lib/internal/template/prompt-input/tokens/use-token-mode.d.ts.map +1 -1
  93. package/lib/internal/template/prompt-input/tokens/use-token-mode.js +0 -9
  94. package/lib/internal/template/prompt-input/tokens/use-token-mode.js.map +1 -1
  95. package/lib/internal/template/table/column-groups/col-group.d.ts +8 -0
  96. package/lib/internal/template/table/column-groups/col-group.d.ts.map +1 -0
  97. package/lib/internal/template/table/column-groups/col-group.js +24 -0
  98. package/lib/internal/template/table/column-groups/col-group.js.map +1 -0
  99. package/lib/internal/template/table/column-groups/split-utils.d.ts +27 -0
  100. package/lib/internal/template/table/column-groups/split-utils.d.ts.map +1 -0
  101. package/lib/internal/template/table/column-groups/split-utils.js +43 -0
  102. package/lib/internal/template/table/column-groups/split-utils.js.map +1 -0
  103. package/lib/internal/template/table/column-groups/use-column-groups.d.ts +8 -0
  104. package/lib/internal/template/table/column-groups/use-column-groups.d.ts.map +1 -0
  105. package/lib/internal/template/table/column-groups/use-column-groups.js +23 -0
  106. package/lib/internal/template/table/column-groups/use-column-groups.js.map +1 -0
  107. package/lib/internal/template/table/column-groups/utils.d.ts +55 -0
  108. package/lib/internal/template/table/column-groups/utils.d.ts.map +1 -0
  109. package/lib/internal/template/table/column-groups/utils.js +204 -0
  110. package/lib/internal/template/table/column-groups/utils.js.map +1 -0
  111. package/lib/internal/template/table/header-cell/common-props.d.ts +24 -0
  112. package/lib/internal/template/table/header-cell/common-props.d.ts.map +1 -0
  113. package/lib/internal/template/table/header-cell/common-props.js +4 -0
  114. package/lib/internal/template/table/header-cell/common-props.js.map +1 -0
  115. package/lib/internal/template/table/header-cell/group-header-cell.d.ts +18 -0
  116. package/lib/internal/template/table/header-cell/group-header-cell.d.ts.map +1 -0
  117. package/lib/internal/template/table/header-cell/group-header-cell.js +44 -0
  118. package/lib/internal/template/table/header-cell/group-header-cell.js.map +1 -0
  119. package/lib/internal/template/table/header-cell/index.d.ts +8 -23
  120. package/lib/internal/template/table/header-cell/index.d.ts.map +1 -1
  121. package/lib/internal/template/table/header-cell/index.js +3 -3
  122. package/lib/internal/template/table/header-cell/index.js.map +1 -1
  123. package/lib/internal/template/table/header-cell/styles.css.js +33 -30
  124. package/lib/internal/template/table/header-cell/styles.scoped.css +92 -68
  125. package/lib/internal/template/table/header-cell/styles.selectors.js +33 -30
  126. package/lib/internal/template/table/header-cell/th-element.d.ts +10 -1
  127. package/lib/internal/template/table/header-cell/th-element.d.ts.map +1 -1
  128. package/lib/internal/template/table/header-cell/th-element.js +6 -4
  129. package/lib/internal/template/table/header-cell/th-element.js.map +1 -1
  130. package/lib/internal/template/table/index.d.ts.map +1 -1
  131. package/lib/internal/template/table/index.js +5 -2
  132. package/lib/internal/template/table/index.js.map +1 -1
  133. package/lib/internal/template/table/interfaces.d.ts +37 -1
  134. package/lib/internal/template/table/interfaces.d.ts.map +1 -1
  135. package/lib/internal/template/table/interfaces.js.map +1 -1
  136. package/lib/internal/template/table/internal.d.ts.map +1 -1
  137. package/lib/internal/template/table/internal.js +17 -5
  138. package/lib/internal/template/table/internal.js.map +1 -1
  139. package/lib/internal/template/table/resizer/index.d.ts +6 -2
  140. package/lib/internal/template/table/resizer/index.d.ts.map +1 -1
  141. package/lib/internal/template/table/resizer/index.js +5 -5
  142. package/lib/internal/template/table/resizer/index.js.map +1 -1
  143. package/lib/internal/template/table/resizer/styles.css.js +16 -13
  144. package/lib/internal/template/table/resizer/styles.scoped.css +36 -26
  145. package/lib/internal/template/table/resizer/styles.selectors.js +16 -13
  146. package/lib/internal/template/table/sticky-header.d.ts +3 -0
  147. package/lib/internal/template/table/sticky-header.d.ts.map +1 -1
  148. package/lib/internal/template/table/sticky-header.js +7 -2
  149. package/lib/internal/template/table/sticky-header.js.map +1 -1
  150. package/lib/internal/template/table/sticky-scrolling.d.ts.map +1 -1
  151. package/lib/internal/template/table/sticky-scrolling.js +6 -1
  152. package/lib/internal/template/table/sticky-scrolling.js.map +1 -1
  153. package/lib/internal/template/table/styles.css.js +35 -34
  154. package/lib/internal/template/table/styles.scoped.css +47 -41
  155. package/lib/internal/template/table/styles.selectors.js +35 -34
  156. package/lib/internal/template/table/table-role/grid-navigation.d.ts.map +1 -1
  157. package/lib/internal/template/table/table-role/grid-navigation.js +5 -7
  158. package/lib/internal/template/table/table-role/grid-navigation.js.map +1 -1
  159. package/lib/internal/template/table/table-role/table-role-helper.d.ts +3 -0
  160. package/lib/internal/template/table/table-role/table-role-helper.d.ts.map +1 -1
  161. package/lib/internal/template/table/table-role/table-role-helper.js +9 -4
  162. package/lib/internal/template/table/table-role/table-role-helper.js.map +1 -1
  163. package/lib/internal/template/table/table-role/utils.d.ts +19 -0
  164. package/lib/internal/template/table/table-role/utils.d.ts.map +1 -1
  165. package/lib/internal/template/table/table-role/utils.js +86 -7
  166. package/lib/internal/template/table/table-role/utils.js.map +1 -1
  167. package/lib/internal/template/table/thead.d.ts +5 -0
  168. package/lib/internal/template/table/thead.d.ts.map +1 -1
  169. package/lib/internal/template/table/thead.js +145 -18
  170. package/lib/internal/template/table/thead.js.map +1 -1
  171. package/lib/internal/template/table/use-column-widths.d.ts +4 -1
  172. package/lib/internal/template/table/use-column-widths.d.ts.map +1 -1
  173. package/lib/internal/template/table/use-column-widths.js +68 -18
  174. package/lib/internal/template/table/use-column-widths.js.map +1 -1
  175. package/lib/internal/template/table/use-sticky-header.d.ts.map +1 -1
  176. package/lib/internal/template/table/use-sticky-header.js +4 -1
  177. package/lib/internal/template/table/use-sticky-header.js.map +1 -1
  178. package/lib/internal/template/table/utils.d.ts.map +1 -1
  179. package/lib/internal/template/table/utils.js +14 -4
  180. package/lib/internal/template/table/utils.js.map +1 -1
  181. package/lib/internal/template/test-utils/dom/collection-preferences/content-display-preference.d.ts +28 -2
  182. package/lib/internal/template/test-utils/dom/collection-preferences/content-display-preference.js +60 -2
  183. package/lib/internal/template/test-utils/dom/collection-preferences/content-display-preference.js.map +1 -1
  184. package/lib/internal/template/test-utils/dom/table/index.d.ts +18 -1
  185. package/lib/internal/template/test-utils/dom/table/index.js +22 -3
  186. package/lib/internal/template/test-utils/dom/table/index.js.map +1 -1
  187. package/lib/internal/template/test-utils/selectors/collection-preferences/content-display-preference.d.ts +28 -2
  188. package/lib/internal/template/test-utils/selectors/collection-preferences/content-display-preference.js +52 -2
  189. package/lib/internal/template/test-utils/selectors/collection-preferences/content-display-preference.js.map +1 -1
  190. package/lib/internal/template/test-utils/selectors/table/index.d.ts +18 -1
  191. package/lib/internal/template/test-utils/selectors/table/index.js +22 -3
  192. package/lib/internal/template/test-utils/selectors/table/index.js.map +1 -1
  193. package/lib/internal/template/wizard/wizard-step-list.js +4 -4
  194. package/lib/internal/template/wizard/wizard-step-list.js.map +1 -1
  195. package/package.json +1 -1
@@ -142,7 +142,7 @@
142
142
  */
143
143
  /* Style used for links in slots/components that are text heavy, to help links stand out among
144
144
  surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
145
- .awsui_badge_1yjyg_kce2m_145:not(#\9) {
145
+ .awsui_badge_1yjyg_zpkv4_145:not(#\9) {
146
146
  border-collapse: separate;
147
147
  border-spacing: 0;
148
148
  box-sizing: border-box;
@@ -183,40 +183,53 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
183
183
  border-end-end-radius: var(--border-radius-badge-o70tla, 16px);
184
184
  border-block-style: solid;
185
185
  border-inline-style: solid;
186
- border-width: 0;
186
+ border-width: var(--border-width-badge-xsbmkz, 0px);
187
187
  padding-block: 0;
188
188
  padding-inline: var(--space-xs-kw7k3v, 8px);
189
189
  color: var(--color-text-notification-default-fmebm4, #fafafa);
190
190
  }
191
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-grey_1yjyg_kce2m_191:not(#\9) {
191
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-grey_1yjyg_zpkv4_191:not(#\9) {
192
192
  background-color: var(--color-background-notification-grey-yzex9c, #545b64);
193
+ border-color: var(--color-border-badge-grey-7x1xit, transparent);
194
+ color: var(--color-text-badge-grey-5hljh0, #fafafa);
193
195
  }
194
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-green_1yjyg_kce2m_194:not(#\9) {
196
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-green_1yjyg_zpkv4_196:not(#\9) {
195
197
  background-color: var(--color-background-notification-green-7yuv70, #1d8102);
198
+ border-color: var(--color-border-badge-green-t7n2iz, transparent);
199
+ color: var(--color-text-badge-green-i688l8, #fafafa);
196
200
  }
197
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-blue_1yjyg_kce2m_197:not(#\9) {
201
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-blue_1yjyg_zpkv4_201:not(#\9) {
198
202
  background-color: var(--color-background-notification-blue-jgc5fr, #0073bb);
203
+ border-color: var(--color-border-badge-blue-p28tag, transparent);
204
+ color: var(--color-text-badge-blue-pfnjhv, #fafafa);
199
205
  }
200
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-red_1yjyg_kce2m_200:not(#\9) {
206
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-red_1yjyg_zpkv4_206:not(#\9) {
201
207
  background-color: var(--color-background-notification-red-k51keq, #d13212);
208
+ border-color: var(--color-border-badge-red-w6mok2, transparent);
209
+ color: var(--color-text-badge-red-e7xtdk, #fafafa);
202
210
  }
203
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-severity-critical_1yjyg_kce2m_203:not(#\9) {
211
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-severity-critical_1yjyg_zpkv4_211:not(#\9) {
204
212
  background-color: var(--color-background-notification-severity-critical-gsxtat, #870303);
205
- color: var(--color-text-notification-severity-critical-h34hq6, #fafafa);
213
+ color: var(--color-text-badge-severity-critical-9m2t9l, #fafafa);
214
+ border-color: var(--color-border-badge-severity-critical-afw1t4, transparent);
206
215
  }
207
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-severity-high_1yjyg_kce2m_207:not(#\9) {
216
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-severity-high_1yjyg_zpkv4_216:not(#\9) {
208
217
  background-color: var(--color-background-notification-severity-high-hz1dy0, #ce3311);
209
- color: var(--color-text-notification-severity-high-fb28xa, #fafafa);
218
+ color: var(--color-text-badge-severity-high-yhnb3j, #fafafa);
219
+ border-color: var(--color-border-badge-severity-high-xpyb3z, transparent);
210
220
  }
211
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-severity-medium_1yjyg_kce2m_211:not(#\9) {
221
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-severity-medium_1yjyg_zpkv4_221:not(#\9) {
212
222
  background-color: var(--color-background-notification-severity-medium-f2pwwo, #f89256);
213
- color: var(--color-text-notification-severity-medium-z7mfdy, #000000);
223
+ color: var(--color-text-badge-severity-medium-seazfm, #000000);
224
+ border-color: var(--color-border-badge-severity-medium-lglq87, transparent);
214
225
  }
215
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-severity-low_1yjyg_kce2m_215:not(#\9) {
226
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-severity-low_1yjyg_zpkv4_226:not(#\9) {
216
227
  background-color: var(--color-background-notification-severity-low-11rcv3, #f2cd54);
217
- color: var(--color-text-notification-severity-low-8cm5oo, #16191f);
228
+ color: var(--color-text-badge-severity-low-ixtax4, #16191f);
229
+ border-color: var(--color-border-badge-severity-low-w6znea, transparent);
218
230
  }
219
- .awsui_badge_1yjyg_kce2m_145.awsui_badge-color-severity-neutral_1yjyg_kce2m_219:not(#\9) {
231
+ .awsui_badge_1yjyg_zpkv4_145.awsui_badge-color-severity-neutral_1yjyg_zpkv4_231:not(#\9) {
220
232
  background-color: var(--color-background-notification-severity-neutral-1tqomh, #687078);
221
- color: var(--color-text-notification-severity-neutral-bqmgv3, #fafafa);
233
+ color: var(--color-text-badge-severity-neutral-vfdy0w, #fafafa);
234
+ border-color: var(--color-border-badge-severity-neutral-kdj4l5, transparent);
222
235
  }
@@ -2,15 +2,15 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "badge": "awsui_badge_1yjyg_kce2m_145",
6
- "badge-color-grey": "awsui_badge-color-grey_1yjyg_kce2m_191",
7
- "badge-color-green": "awsui_badge-color-green_1yjyg_kce2m_194",
8
- "badge-color-blue": "awsui_badge-color-blue_1yjyg_kce2m_197",
9
- "badge-color-red": "awsui_badge-color-red_1yjyg_kce2m_200",
10
- "badge-color-severity-critical": "awsui_badge-color-severity-critical_1yjyg_kce2m_203",
11
- "badge-color-severity-high": "awsui_badge-color-severity-high_1yjyg_kce2m_207",
12
- "badge-color-severity-medium": "awsui_badge-color-severity-medium_1yjyg_kce2m_211",
13
- "badge-color-severity-low": "awsui_badge-color-severity-low_1yjyg_kce2m_215",
14
- "badge-color-severity-neutral": "awsui_badge-color-severity-neutral_1yjyg_kce2m_219"
5
+ "badge": "awsui_badge_1yjyg_zpkv4_145",
6
+ "badge-color-grey": "awsui_badge-color-grey_1yjyg_zpkv4_191",
7
+ "badge-color-green": "awsui_badge-color-green_1yjyg_zpkv4_196",
8
+ "badge-color-blue": "awsui_badge-color-blue_1yjyg_zpkv4_201",
9
+ "badge-color-red": "awsui_badge-color-red_1yjyg_zpkv4_206",
10
+ "badge-color-severity-critical": "awsui_badge-color-severity-critical_1yjyg_zpkv4_211",
11
+ "badge-color-severity-high": "awsui_badge-color-severity-high_1yjyg_zpkv4_216",
12
+ "badge-color-severity-medium": "awsui_badge-color-severity-medium_1yjyg_zpkv4_221",
13
+ "badge-color-severity-low": "awsui_badge-color-severity-low_1yjyg_zpkv4_226",
14
+ "badge-color-severity-neutral": "awsui_badge-color-severity-neutral_1yjyg_zpkv4_231"
15
15
  };
16
16
 
@@ -9,7 +9,7 @@ export const getClassName = (suffix) => styles[[componentPrefix, suffix].filter(
9
9
  const ContentDisplayOption = forwardRef(({ onToggle, option }, ref) => {
10
10
  const idPrefix = useUniqueId(componentPrefix);
11
11
  const controlId = `${idPrefix}-control-${option.id}`;
12
- return (React.createElement("div", { ref: ref, className: getClassName('content') },
12
+ return (React.createElement("div", { ref: ref, className: getClassName('content'), "data-item-type": "column" },
13
13
  React.createElement("label", { className: getClassName('label'), htmlFor: controlId }, option.label),
14
14
  React.createElement("div", { className: getClassName('toggle') },
15
15
  React.createElement(InternalToggle, { checked: !!option.visible, onChange: () => onToggle && onToggle(option), disabled: option.alwaysVisible === true, controlId: controlId }))));
@@ -1 +1 @@
1
- {"version":3,"file":"content-display-option.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/content-display-option.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAgB,UAAU,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAGnD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAO7G,MAAM,oBAAoB,GAAG,UAAU,CACrC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAA6B,EAAE,GAAiC,EAAE,EAAE;IACrF,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,GAAG,QAAQ,YAAY,MAAM,CAAC,EAAE,EAAE,CAAC;IACrD,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC;QAC/C,+BAAO,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,IACxD,MAAM,CAAC,KAAK,CACP;QACR,6BAAK,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC;YACpC,oBAAC,cAAc,IACb,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,EAC5C,QAAQ,EAAE,MAAM,CAAC,aAAa,KAAK,IAAI,EACvC,SAAS,EAAE,SAAS,GACpB,CACE,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ForwardedRef, forwardRef } from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalToggle from '../../toggle/internal';\nimport { OptionWithVisibility } from './utils';\n\nimport styles from '../styles.css.js';\n\nconst componentPrefix = 'content-display-option';\nexport const getClassName = (suffix?: string) => styles[[componentPrefix, suffix].filter(Boolean).join('-')];\n\ninterface ContentDisplayOptionProps {\n onToggle?: (option: OptionWithVisibility) => void;\n option: OptionWithVisibility;\n}\n\nconst ContentDisplayOption = forwardRef(\n ({ onToggle, option }: ContentDisplayOptionProps, ref: ForwardedRef<HTMLDivElement>) => {\n const idPrefix = useUniqueId(componentPrefix);\n const controlId = `${idPrefix}-control-${option.id}`;\n return (\n <div ref={ref} className={getClassName('content')}>\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 && onToggle(option)}\n disabled={option.alwaysVisible === true}\n controlId={controlId}\n />\n </div>\n </div>\n );\n }\n);\n\nexport default ContentDisplayOption;\n"]}
1
+ {"version":3,"file":"content-display-option.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/content-display-option.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAgB,UAAU,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,cAAc,MAAM,uBAAuB,CAAC;AAGnD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,MAAM,eAAe,GAAG,wBAAwB,CAAC;AACjD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAO7G,MAAM,oBAAoB,GAAG,UAAU,CACrC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAA6B,EAAE,GAAiC,EAAE,EAAE;IACrF,MAAM,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,GAAG,QAAQ,YAAY,MAAM,CAAC,EAAE,EAAE,CAAC;IACrD,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,oBAAiB,QAAQ;QACxE,+BAAO,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,SAAS,IACxD,MAAM,CAAC,KAAK,CACP;QACR,6BAAK,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC;YACpC,oBAAC,cAAc,IACb,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EACzB,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,EAC5C,QAAQ,EAAE,MAAM,CAAC,aAAa,KAAK,IAAI,EACvC,SAAS,EAAE,SAAS,GACpB,CACE,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ForwardedRef, forwardRef } from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalToggle from '../../toggle/internal';\nimport { OptionWithVisibility } from './utils';\n\nimport styles from '../styles.css.js';\n\nconst componentPrefix = 'content-display-option';\nexport const getClassName = (suffix?: string) => styles[[componentPrefix, suffix].filter(Boolean).join('-')];\n\ninterface ContentDisplayOptionProps {\n onToggle?: (option: OptionWithVisibility) => void;\n option: OptionWithVisibility;\n}\n\nconst ContentDisplayOption = forwardRef(\n ({ onToggle, option }: ContentDisplayOptionProps, ref: ForwardedRef<HTMLDivElement>) => {\n const idPrefix = useUniqueId(componentPrefix);\n const controlId = `${idPrefix}-control-${option.id}`;\n return (\n <div ref={ref} className={getClassName('content')} data-item-type=\"column\">\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 && onToggle(option)}\n disabled={option.alwaysVisible === true}\n controlId={controlId}\n />\n </div>\n </div>\n );\n }\n);\n\nexport default ContentDisplayOption;\n"]}
@@ -3,6 +3,6 @@ interface ContentDisplayPreferenceProps extends CollectionPreferencesProps.Conte
3
3
  onChange: (value: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>) => void;
4
4
  value?: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;
5
5
  }
6
- export default function ContentDisplayPreference({ title, description, options, value, onChange, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, dragHandleAriaDescription, dragHandleAriaLabel, enableColumnFiltering, i18nStrings, }: ContentDisplayPreferenceProps): JSX.Element;
6
+ export default function ContentDisplayPreference({ title, description, options, value, groups, onChange, enableColumnFiltering, i18nStrings, ...dndProps }: ContentDisplayPreferenceProps): JSX.Element;
7
7
  export {};
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAU3D,UAAU,6BAA8B,SAAQ,0BAA0B,CAAC,wBAAwB;IACjG,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACxF,KAAK,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CACtE;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAGG,EACH,QAAQ,EACR,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,EAChC,4BAA4B,EAC5B,yBAAyB,EACzB,mBAAmB,EACnB,qBAA6B,EAC7B,WAAW,GACZ,EAAE,6BAA6B,eAgI/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAkB3D,UAAU,6BAA8B,SAAQ,0BAA0B,CAAC,wBAAwB;IACjG,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACxF,KAAK,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC,kBAAkB,CAAC,CAAC;CACtE;AAqJD,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,KAAK,EACL,WAAW,EACX,OAAO,EACP,KAGG,EACH,MAAM,EACN,QAAQ,EACR,qBAA6B,EAC7B,WAAW,EACX,GAAG,QAAQ,EACZ,EAAE,6BAA6B,eAgJ/B"}
@@ -11,53 +11,89 @@ import InternalSpaceBetween from '../../space-between/internal';
11
11
  import InternalTextFilter from '../../text-filter/internal';
12
12
  import { getAnalyticsInnerContextAttribute } from '../analytics-metadata/utils';
13
13
  import ContentDisplayOption from './content-display-option';
14
- import { getFilteredOptions, getSortedOptions } from './utils';
14
+ import { buildOptionTree, getFilteredOptions, getFilteredTree, getSortedOptions, toContentDisplayItems, } from './utils';
15
15
  import styles from '../styles.css.js';
16
16
  const componentPrefix = 'content-display';
17
17
  const getClassName = (suffix) => styles[`${componentPrefix}-${suffix}`];
18
+ function getDndI18nStrings(i18n, props) {
19
+ return {
20
+ liveAnnouncementDndStarted: i18n('contentDisplayPreference.liveAnnouncementDndStarted', props.liveAnnouncementDndStarted, formatDndStarted),
21
+ liveAnnouncementDndItemReordered: i18n('contentDisplayPreference.liveAnnouncementDndItemReordered', props.liveAnnouncementDndItemReordered, formatDndItemReordered),
22
+ liveAnnouncementDndItemCommitted: i18n('contentDisplayPreference.liveAnnouncementDndItemCommitted', props.liveAnnouncementDndItemCommitted, formatDndItemCommitted),
23
+ liveAnnouncementDndDiscarded: i18n('contentDisplayPreference.liveAnnouncementDndDiscarded', props.liveAnnouncementDndDiscarded),
24
+ dragHandleAriaLabel: i18n('contentDisplayPreference.dragHandleAriaLabel', props.dragHandleAriaLabel),
25
+ dragHandleAriaDescription: i18n('contentDisplayPreference.dragHandleAriaDescription', props.dragHandleAriaDescription),
26
+ };
27
+ }
28
+ function GroupItem({ node, onToggle, onChildrenChange, i18nStrings, sortDisabled, groupLabelFormatter, }) {
29
+ return (React.createElement("div", { "data-item-type": "group" },
30
+ React.createElement(InternalSpaceBetween, { size: "xxs" },
31
+ React.createElement("div", { className: styles['content-display-group-header'] },
32
+ React.createElement(InternalBox, { fontWeight: "bold", display: "inline" }, node.label)),
33
+ node.children.length > 0 && (React.createElement("div", { className: styles['content-display-group-children'] },
34
+ React.createElement(HierarchicalContentDisplay, { tree: node.children, onToggle: onToggle, onTreeChange: onChildrenChange, i18nStrings: i18nStrings, sortDisabled: sortDisabled, ariaLabel: node.label, parentGroupLabel: node.label, groupLabelFormatter: groupLabelFormatter }))))));
35
+ }
36
+ function HierarchicalContentDisplay({ tree, onToggle, onTreeChange, ariaLabel, ariaLabelledby, ariaDescribedby, i18nStrings, sortDisabled, parentGroupLabel, groupLabelFormatter, }) {
37
+ return (React.createElement(InternalList, { items: tree, sortDisabled: sortDisabled, sortable: true, disableItemPaddings: true, ariaLabel: ariaLabel, ariaLabelledby: ariaLabelledby, ariaDescribedby: ariaDescribedby, i18nStrings: i18nStrings, onSortingChange: ({ detail: { items } }) => onTreeChange([...items]), renderItem: node => ({
38
+ id: node.id,
39
+ announcementLabel: node.type === 'group'
40
+ ? groupLabelFormatter(node.label, node.children.length)
41
+ : parentGroupLabel
42
+ ? `${node.label}, ${parentGroupLabel}`
43
+ : node.label,
44
+ content: node.type === 'group' ? (React.createElement(GroupItem, { node: node, onToggle: onToggle, onChildrenChange: newChildren => onTreeChange(tree.map(n => (n.id === node.id && n.type === 'group' ? { ...n, children: newChildren } : n))), i18nStrings: i18nStrings, sortDisabled: sortDisabled, groupLabelFormatter: groupLabelFormatter })) : (React.createElement(ContentDisplayOption, { option: node, onToggle: () => onToggle(node.id) })),
45
+ }) }));
46
+ }
18
47
  export default function ContentDisplayPreference({ title, description, options, value = options.map(({ id }) => ({
19
48
  id,
20
49
  visible: true,
21
- })), onChange, liveAnnouncementDndStarted, liveAnnouncementDndItemReordered, liveAnnouncementDndItemCommitted, liveAnnouncementDndDiscarded, dragHandleAriaDescription, dragHandleAriaLabel, enableColumnFiltering = false, i18nStrings, }) {
50
+ })), groups, onChange, enableColumnFiltering = false, i18nStrings, ...dndProps }) {
51
+ var _a;
22
52
  const idPrefix = useUniqueId(componentPrefix);
23
53
  const i18n = useInternalI18n('collection-preferences');
24
54
  const [columnFilteringText, setColumnFilteringText] = useState('');
25
55
  const titleId = `${idPrefix}-title`;
26
56
  const descriptionId = `${idPrefix}-description`;
27
- const [sortedOptions, sortedAndFilteredOptions] = useMemo(() => {
28
- const sorted = getSortedOptions({ options, contentDisplay: value });
29
- const filtered = getFilteredOptions(sorted, columnFilteringText);
30
- return [sorted, filtered];
31
- }, [columnFilteringText, options, value]);
32
- const onToggle = (option) => {
33
- // We use sortedOptions as base and not value because there might be options that
34
- // are not in the value yet, so they're added as non-visible after the known ones.
35
- onChange(sortedOptions.map(({ id, visible }) => ({ id, visible: id === option.id ? !option.visible : visible })));
57
+ const listI18nStrings = getDndI18nStrings(i18n, dndProps);
58
+ const groupLabelFormatter = (label, count) => {
59
+ var _a, _b;
60
+ return i18n('contentDisplayPreference.liveAnnouncementDndGroupLabel', (_b = (_a = dndProps.liveAnnouncementDndGroupLabel) === null || _a === void 0 ? void 0 : _a.call(dndProps, label, count)) !== null && _b !== void 0 ? _b : `${label}, ${count} ${count === 1 ? 'item' : 'items'}`, format => format({ label, count }));
61
+ };
62
+ const hasGroups = !!groups && groups.length > 0;
63
+ const isFiltering = columnFilteringText.trim().length > 0;
64
+ const sortedOptions = useMemo(() => getSortedOptions({ options, contentDisplay: value }), [options, value]);
65
+ const filteredOptions = useMemo(() => getFilteredOptions(sortedOptions, columnFilteringText), [sortedOptions, columnFilteringText]);
66
+ const optionTree = useMemo(() => (hasGroups ? buildOptionTree(options, groups, value) : null), [hasGroups, groups, options, value]);
67
+ const filteredTree = useMemo(() => (optionTree ? getFilteredTree(optionTree, columnFilteringText) : null), [optionTree, columnFilteringText]);
68
+ const handleToggle = (id) => {
69
+ // For flat (non-grouped) mode, rebuild from sortedOptions to handle items not in value
70
+ if (!hasGroups) {
71
+ onChange(sortedOptions.map(opt => ({ id: opt.id, visible: opt.id === id ? !opt.visible : opt.visible })));
72
+ return;
73
+ }
74
+ // For grouped mode, walk the tree and flip the matching item
75
+ const toggle = (items) => items.map(item => {
76
+ if (item.type === 'group') {
77
+ return { ...item, children: toggle(item.children) };
78
+ }
79
+ return item.id === id ? { ...item, visible: !item.visible } : item;
80
+ });
81
+ onChange(toggle(value));
36
82
  };
83
+ const noResults = filteredTree ? filteredTree.length === 0 : filteredOptions.length === 0;
37
84
  return (React.createElement("div", { role: "group", "aria-labelledby": titleId, "aria-describedby": descriptionId, className: styles[componentPrefix], ...getAnalyticsInnerContextAttribute('contentDisplay') },
38
85
  React.createElement("h3", { className: getClassName('title'), id: titleId }, i18n('contentDisplayPreference.title', title)),
39
86
  React.createElement("p", { className: getClassName('description'), id: descriptionId }, i18n('contentDisplayPreference.description', description)),
40
87
  enableColumnFiltering && (React.createElement("div", { className: getClassName('text-filter') },
41
- React.createElement(InternalTextFilter, { filteringText: columnFilteringText, filteringPlaceholder: i18n('contentDisplayPreference.i18nStrings.columnFilteringPlaceholder', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringPlaceholder), filteringAriaLabel: i18n('contentDisplayPreference.i18nStrings.columnFilteringAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringAriaLabel), filteringClearAriaLabel: i18n('contentDisplayPreference.i18nStrings.columnFilteringClearFilterText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringClearFilterText), onChange: ({ detail }) => setColumnFilteringText(detail.filteringText), countText: i18n('contentDisplayPreference.i18nStrings.columnFilteringCountText', (i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringCountText)
42
- ? i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringCountText(sortedAndFilteredOptions.length)
43
- : undefined, format => format({ count: sortedAndFilteredOptions.length })) }))),
44
- sortedAndFilteredOptions.length === 0 && (React.createElement("div", { className: getClassName('no-match') },
88
+ React.createElement(InternalTextFilter, { filteringText: columnFilteringText, filteringPlaceholder: i18n('contentDisplayPreference.i18nStrings.columnFilteringPlaceholder', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringPlaceholder), filteringAriaLabel: i18n('contentDisplayPreference.i18nStrings.columnFilteringAriaLabel', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringAriaLabel), filteringClearAriaLabel: i18n('contentDisplayPreference.i18nStrings.columnFilteringClearFilterText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringClearFilterText), onChange: ({ detail }) => setColumnFilteringText(detail.filteringText), countText: i18n('contentDisplayPreference.i18nStrings.columnFilteringCountText', (_a = i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringCountText) === null || _a === void 0 ? void 0 : _a.call(i18nStrings, filteredOptions.length), format => format({ count: filteredOptions.length })) }))),
89
+ noResults && (React.createElement("div", { className: getClassName('no-match') },
45
90
  React.createElement(InternalSpaceBetween, { size: "s", alignItems: "center" },
46
91
  React.createElement(InternalBox, { margin: { top: 'm' } }, i18n('contentDisplayPreference.i18nStrings.columnFilteringNoMatchText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringNoMatchText)),
47
92
  React.createElement(InternalButton, { onClick: () => setColumnFilteringText('') }, i18n('contentDisplayPreference.i18nStrings.columnFilteringClearFilterText', i18nStrings === null || i18nStrings === void 0 ? void 0 : i18nStrings.columnFilteringClearFilterText))))),
48
- React.createElement(InternalList, { items: sortedAndFilteredOptions, renderItem: item => ({
93
+ React.createElement("div", { role: "application", "aria-labelledby": titleId }, optionTree && filteredTree ? (React.createElement(HierarchicalContentDisplay, { tree: isFiltering ? filteredTree : optionTree, onToggle: handleToggle, onTreeChange: newTree => onChange(toContentDisplayItems(newTree)), ariaLabelledby: titleId, ariaDescribedby: descriptionId, i18nStrings: listI18nStrings, sortDisabled: isFiltering, groupLabelFormatter: groupLabelFormatter })) : (React.createElement(InternalList, { items: filteredOptions, sortable: true, sortDisabled: isFiltering, disableItemPaddings: true, ariaLabelledby: titleId, ariaDescribedby: descriptionId, i18nStrings: listI18nStrings, onSortingChange: ({ detail: { items } }) => onChange(items.map(({ id, visible }) => ({ id, visible }))), renderItem: item => ({
49
94
  id: item.id,
50
- content: React.createElement(ContentDisplayOption, { option: item, onToggle: onToggle }),
51
95
  announcementLabel: item.label,
52
- }), disableItemPaddings: true, sortable: true, sortDisabled: columnFilteringText.trim().length > 0, onSortingChange: ({ detail: { items } }) => {
53
- onChange(items);
54
- }, ariaDescribedby: descriptionId, ariaLabelledby: titleId, i18nStrings: {
55
- liveAnnouncementDndStarted: i18n('contentDisplayPreference.liveAnnouncementDndStarted', liveAnnouncementDndStarted, formatDndStarted),
56
- liveAnnouncementDndItemReordered: i18n('contentDisplayPreference.liveAnnouncementDndItemReordered', liveAnnouncementDndItemReordered, formatDndItemReordered),
57
- liveAnnouncementDndItemCommitted: i18n('contentDisplayPreference.liveAnnouncementDndItemCommitted', liveAnnouncementDndItemCommitted, formatDndItemCommitted),
58
- liveAnnouncementDndDiscarded: i18n('contentDisplayPreference.liveAnnouncementDndDiscarded', liveAnnouncementDndDiscarded),
59
- dragHandleAriaLabel: i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel),
60
- dragHandleAriaDescription: i18n('contentDisplayPreference.dragHandleAriaDescription', dragHandleAriaDescription),
61
- } })));
96
+ content: React.createElement(ContentDisplayOption, { option: item, onToggle: () => handleToggle(item.id) }),
97
+ }) })))));
62
98
  }
63
99
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,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pD,yBAAyB,CAC1B;aACF,GACD,CACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useState } from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../../box/internal';\nimport InternalButton from '../../button/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport {\n formatDndItemCommitted,\n formatDndItemReordered,\n formatDndStarted,\n} from '../../internal/components/sortable-area/use-live-announcements';\nimport InternalList from '../../list/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport InternalTextFilter from '../../text-filter/internal';\nimport { getAnalyticsInnerContextAttribute } from '../analytics-metadata/utils';\nimport { CollectionPreferencesProps } from '../interfaces';\nimport ContentDisplayOption from './content-display-option';\nimport { getFilteredOptions, getSortedOptions, OptionWithVisibility } from './utils';\n\nimport styles from '../styles.css.js';\n\nconst componentPrefix = 'content-display';\n\nconst getClassName = (suffix: string) => styles[`${componentPrefix}-${suffix}`];\n\ninterface ContentDisplayPreferenceProps extends CollectionPreferencesProps.ContentDisplayPreference {\n onChange: (value: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>) => void;\n value?: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}\n\nexport default function ContentDisplayPreference({\n title,\n description,\n options,\n value = options.map(({ id }) => ({\n id,\n visible: true,\n })),\n onChange,\n liveAnnouncementDndStarted,\n liveAnnouncementDndItemReordered,\n liveAnnouncementDndItemCommitted,\n liveAnnouncementDndDiscarded,\n dragHandleAriaDescription,\n dragHandleAriaLabel,\n enableColumnFiltering = false,\n i18nStrings,\n}: ContentDisplayPreferenceProps) {\n const idPrefix = useUniqueId(componentPrefix);\n const i18n = useInternalI18n('collection-preferences');\n const [columnFilteringText, setColumnFilteringText] = useState('');\n\n const titleId = `${idPrefix}-title`;\n const descriptionId = `${idPrefix}-description`;\n\n const [sortedOptions, sortedAndFilteredOptions] = useMemo(() => {\n const sorted = getSortedOptions({ options, contentDisplay: value });\n const filtered = getFilteredOptions(sorted, columnFilteringText);\n return [sorted, filtered];\n }, [columnFilteringText, options, value]);\n\n const onToggle = (option: OptionWithVisibility) => {\n // We use sortedOptions as base and not value because there might be options that\n // are not in the value yet, so they're added as non-visible after the known ones.\n onChange(sortedOptions.map(({ id, visible }) => ({ id, visible: id === option.id ? !option.visible : visible })));\n };\n\n return (\n <div\n role=\"group\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n className={styles[componentPrefix]}\n {...getAnalyticsInnerContextAttribute('contentDisplay')}\n >\n <h3 className={getClassName('title')} id={titleId}>\n {i18n('contentDisplayPreference.title', title)}\n </h3>\n <p className={getClassName('description')} id={descriptionId}>\n {i18n('contentDisplayPreference.description', description)}\n </p>\n\n {/* Filter input */}\n {enableColumnFiltering && (\n <div className={getClassName('text-filter')}>\n <InternalTextFilter\n filteringText={columnFilteringText}\n filteringPlaceholder={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringPlaceholder',\n i18nStrings?.columnFilteringPlaceholder\n )}\n filteringAriaLabel={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringAriaLabel',\n i18nStrings?.columnFilteringAriaLabel\n )}\n filteringClearAriaLabel={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringClearFilterText',\n i18nStrings?.columnFilteringClearFilterText\n )}\n onChange={({ detail }) => setColumnFilteringText(detail.filteringText)}\n countText={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringCountText',\n i18nStrings?.columnFilteringCountText\n ? i18nStrings?.columnFilteringCountText(sortedAndFilteredOptions.length)\n : undefined,\n format => format({ count: sortedAndFilteredOptions.length })\n )}\n />\n </div>\n )}\n\n {/* No match */}\n {sortedAndFilteredOptions.length === 0 && (\n <div className={getClassName('no-match')}>\n <InternalSpaceBetween size=\"s\" alignItems=\"center\">\n <InternalBox margin={{ top: 'm' }}>\n {i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringNoMatchText',\n i18nStrings?.columnFilteringNoMatchText\n )}\n </InternalBox>\n <InternalButton onClick={() => setColumnFilteringText('')}>\n {i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringClearFilterText',\n i18nStrings?.columnFilteringClearFilterText\n )}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n )}\n\n <InternalList\n items={sortedAndFilteredOptions}\n renderItem={item => ({\n id: item.id,\n content: <ContentDisplayOption option={item} onToggle={onToggle} />,\n announcementLabel: item.label,\n })}\n disableItemPaddings={true}\n sortable={true}\n sortDisabled={columnFilteringText.trim().length > 0}\n onSortingChange={({ detail: { items } }) => {\n onChange(items);\n }}\n ariaDescribedby={descriptionId}\n ariaLabelledby={titleId}\n i18nStrings={{\n liveAnnouncementDndStarted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndStarted',\n liveAnnouncementDndStarted,\n formatDndStarted\n ),\n liveAnnouncementDndItemReordered: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemReordered',\n liveAnnouncementDndItemReordered,\n formatDndItemReordered\n ),\n liveAnnouncementDndItemCommitted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemCommitted',\n liveAnnouncementDndItemCommitted,\n formatDndItemCommitted\n ),\n liveAnnouncementDndDiscarded: i18n(\n 'contentDisplayPreference.liveAnnouncementDndDiscarded',\n liveAnnouncementDndDiscarded\n ),\n dragHandleAriaLabel: i18n('contentDisplayPreference.dragHandleAriaLabel', dragHandleAriaLabel),\n dragHandleAriaDescription: i18n(\n 'contentDisplayPreference.dragHandleAriaDescription',\n dragHandleAriaDescription\n ),\n }}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,WAA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ACvB,eAAe,EAAE,aAAa,EAC9B,WAAW,EAAE,eAAe,EAC5B,YAAY,EAAE,WAAW,EACzB,mBAAmB,EAAE,mBAAmB,GACxC,CACH,CAAC,CAAC,CAAC,CACF,oBAAC,YAAY,IACX,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,IAAI,EACd,YAAY,EAAE,WAAW,EACzB,mBAAmB,EAAE,IAAI,EACzB,cAAc,EAAE,OAAO,EACvB,eAAe,EAAE,aAAa,EAC9B,WAAW,EAAE,eAAe,EAC5B,eAAe,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EACvG,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;gBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,iBAAiB,EAAE,IAAI,CAAC,KAAK;gBAC7B,OAAO,EAAE,oBAAC,oBAAoB,IAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,GAAI;aACvF,CAAC,GACF,CACH,CACG,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useMemo, useState } from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalBox from '../../box/internal';\nimport InternalButton from '../../button/internal';\nimport { useInternalI18n } from '../../i18n/context';\nimport { SortableAreaProps } from '../../internal/components/sortable-area/interfaces';\nimport {\n formatDndItemCommitted,\n formatDndItemReordered,\n formatDndStarted,\n} from '../../internal/components/sortable-area/use-live-announcements';\nimport InternalList from '../../list/internal';\nimport InternalSpaceBetween from '../../space-between/internal';\nimport InternalTextFilter from '../../text-filter/internal';\nimport { getAnalyticsInnerContextAttribute } from '../analytics-metadata/utils';\nimport { CollectionPreferencesProps } from '../interfaces';\nimport ContentDisplayOption from './content-display-option';\nimport {\n buildOptionTree,\n getFilteredOptions,\n getFilteredTree,\n getSortedOptions,\n OptionGroupNode,\n OptionTreeNode,\n toContentDisplayItems,\n} from './utils';\n\nimport styles from '../styles.css.js';\n\nconst componentPrefix = 'content-display';\n\nconst getClassName = (suffix: string) => styles[`${componentPrefix}-${suffix}`];\n\ninterface ContentDisplayPreferenceProps extends CollectionPreferencesProps.ContentDisplayPreference {\n onChange: (value: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>) => void;\n value?: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}\nfunction getDndI18nStrings(\n i18n: ReturnType<typeof useInternalI18n<'collection-preferences'>>,\n props: Pick<\n ContentDisplayPreferenceProps,\n | 'liveAnnouncementDndStarted'\n | 'liveAnnouncementDndItemReordered'\n | 'liveAnnouncementDndItemCommitted'\n | 'liveAnnouncementDndDiscarded'\n | 'dragHandleAriaLabel'\n | 'dragHandleAriaDescription'\n >\n) {\n return {\n liveAnnouncementDndStarted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndStarted',\n props.liveAnnouncementDndStarted,\n formatDndStarted\n ),\n liveAnnouncementDndItemReordered: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemReordered',\n props.liveAnnouncementDndItemReordered,\n formatDndItemReordered\n ),\n liveAnnouncementDndItemCommitted: i18n(\n 'contentDisplayPreference.liveAnnouncementDndItemCommitted',\n props.liveAnnouncementDndItemCommitted,\n formatDndItemCommitted\n ),\n liveAnnouncementDndDiscarded: i18n(\n 'contentDisplayPreference.liveAnnouncementDndDiscarded',\n props.liveAnnouncementDndDiscarded\n ),\n dragHandleAriaLabel: i18n('contentDisplayPreference.dragHandleAriaLabel', props.dragHandleAriaLabel),\n dragHandleAriaDescription: i18n(\n 'contentDisplayPreference.dragHandleAriaDescription',\n props.dragHandleAriaDescription\n ),\n };\n}\n\ninterface HierarchicalContentDisplayProps {\n tree: OptionTreeNode[];\n onToggle: (id: string) => void;\n onTreeChange: (newTree: OptionTreeNode[]) => void;\n ariaLabel?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n i18nStrings: SortableAreaProps.DndAreaI18nStrings;\n sortDisabled: boolean;\n parentGroupLabel?: string;\n groupLabelFormatter: (label: string, count: number) => string;\n}\n\nfunction GroupItem({\n node,\n onToggle,\n onChildrenChange,\n i18nStrings,\n sortDisabled,\n groupLabelFormatter,\n}: {\n node: OptionGroupNode;\n onToggle: (id: string) => void;\n onChildrenChange: (children: OptionTreeNode[]) => void;\n i18nStrings: SortableAreaProps.DndAreaI18nStrings;\n sortDisabled: boolean;\n groupLabelFormatter: (label: string, count: number) => string;\n}) {\n return (\n <div data-item-type=\"group\">\n <InternalSpaceBetween size=\"xxs\">\n <div className={styles['content-display-group-header']}>\n <InternalBox fontWeight=\"bold\" display=\"inline\">\n {node.label}\n </InternalBox>\n </div>\n {node.children.length > 0 && (\n <div className={styles['content-display-group-children']}>\n <HierarchicalContentDisplay\n tree={node.children}\n onToggle={onToggle}\n onTreeChange={onChildrenChange}\n i18nStrings={i18nStrings}\n sortDisabled={sortDisabled}\n ariaLabel={node.label}\n parentGroupLabel={node.label}\n groupLabelFormatter={groupLabelFormatter}\n />\n </div>\n )}\n </InternalSpaceBetween>\n </div>\n );\n}\n\nfunction HierarchicalContentDisplay({\n tree,\n onToggle,\n onTreeChange,\n ariaLabel,\n ariaLabelledby,\n ariaDescribedby,\n i18nStrings,\n sortDisabled,\n parentGroupLabel,\n groupLabelFormatter,\n}: HierarchicalContentDisplayProps) {\n return (\n <InternalList\n items={tree}\n sortDisabled={sortDisabled}\n sortable={true}\n disableItemPaddings={true}\n ariaLabel={ariaLabel}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n i18nStrings={i18nStrings}\n onSortingChange={({ detail: { items } }) => onTreeChange([...items])}\n renderItem={node => ({\n id: node.id,\n announcementLabel:\n node.type === 'group'\n ? groupLabelFormatter(node.label, node.children.length)\n : parentGroupLabel\n ? `${node.label}, ${parentGroupLabel}`\n : node.label,\n content:\n node.type === 'group' ? (\n <GroupItem\n node={node}\n onToggle={onToggle}\n onChildrenChange={newChildren =>\n onTreeChange(\n tree.map(n => (n.id === node.id && n.type === 'group' ? { ...n, children: newChildren } : n))\n )\n }\n i18nStrings={i18nStrings}\n sortDisabled={sortDisabled}\n groupLabelFormatter={groupLabelFormatter}\n />\n ) : (\n <ContentDisplayOption option={node} onToggle={() => onToggle(node.id)} />\n ),\n })}\n />\n );\n}\n\nexport default function ContentDisplayPreference({\n title,\n description,\n options,\n value = options.map(({ id }) => ({\n id,\n visible: true,\n })),\n groups,\n onChange,\n enableColumnFiltering = false,\n i18nStrings,\n ...dndProps\n}: ContentDisplayPreferenceProps) {\n const idPrefix = useUniqueId(componentPrefix);\n const i18n = useInternalI18n('collection-preferences');\n const [columnFilteringText, setColumnFilteringText] = useState('');\n\n const titleId = `${idPrefix}-title`;\n const descriptionId = `${idPrefix}-description`;\n\n const listI18nStrings = getDndI18nStrings(i18n, dndProps);\n const groupLabelFormatter = (label: string, count: number) =>\n i18n(\n 'contentDisplayPreference.liveAnnouncementDndGroupLabel',\n dndProps.liveAnnouncementDndGroupLabel?.(label, count) ?? `${label}, ${count} ${count === 1 ? 'item' : 'items'}`,\n format => format({ label, count })\n );\n const hasGroups = !!groups && groups.length > 0;\n const isFiltering = columnFilteringText.trim().length > 0;\n\n const sortedOptions = useMemo(() => getSortedOptions({ options, contentDisplay: value }), [options, value]);\n const filteredOptions = useMemo(\n () => getFilteredOptions(sortedOptions, columnFilteringText),\n [sortedOptions, columnFilteringText]\n );\n const optionTree = useMemo(\n () => (hasGroups ? buildOptionTree(options, groups, value) : null),\n [hasGroups, groups, options, value]\n );\n const filteredTree = useMemo(\n () => (optionTree ? getFilteredTree(optionTree, columnFilteringText) : null),\n [optionTree, columnFilteringText]\n );\n\n const handleToggle = (id: string) => {\n // For flat (non-grouped) mode, rebuild from sortedOptions to handle items not in value\n if (!hasGroups) {\n onChange(sortedOptions.map(opt => ({ id: opt.id, visible: opt.id === id ? !opt.visible : opt.visible })));\n return;\n }\n // For grouped mode, walk the tree and flip the matching item\n const toggle = (\n items: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>\n ): CollectionPreferencesProps.ContentDisplayItem[] =>\n items.map(item => {\n if (item.type === 'group') {\n return { ...item, children: toggle(item.children) };\n }\n return item.id === id ? { ...item, visible: !item.visible } : item;\n });\n onChange(toggle(value));\n };\n const noResults = filteredTree ? filteredTree.length === 0 : filteredOptions.length === 0;\n return (\n <div\n role=\"group\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n className={styles[componentPrefix]}\n {...getAnalyticsInnerContextAttribute('contentDisplay')}\n >\n <h3 className={getClassName('title')} id={titleId}>\n {i18n('contentDisplayPreference.title', title)}\n </h3>\n <p className={getClassName('description')} id={descriptionId}>\n {i18n('contentDisplayPreference.description', description)}\n </p>\n\n {/* Filter input */}\n {enableColumnFiltering && (\n <div className={getClassName('text-filter')}>\n <InternalTextFilter\n filteringText={columnFilteringText}\n filteringPlaceholder={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringPlaceholder',\n i18nStrings?.columnFilteringPlaceholder\n )}\n filteringAriaLabel={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringAriaLabel',\n i18nStrings?.columnFilteringAriaLabel\n )}\n filteringClearAriaLabel={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringClearFilterText',\n i18nStrings?.columnFilteringClearFilterText\n )}\n onChange={({ detail }) => setColumnFilteringText(detail.filteringText)}\n countText={i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringCountText',\n i18nStrings?.columnFilteringCountText?.(filteredOptions.length),\n format => format({ count: filteredOptions.length })\n )}\n />\n </div>\n )}\n\n {noResults && (\n <div className={getClassName('no-match')}>\n <InternalSpaceBetween size=\"s\" alignItems=\"center\">\n <InternalBox margin={{ top: 'm' }}>\n {i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringNoMatchText',\n i18nStrings?.columnFilteringNoMatchText\n )}\n </InternalBox>\n <InternalButton onClick={() => setColumnFilteringText('')}>\n {i18n(\n 'contentDisplayPreference.i18nStrings.columnFilteringClearFilterText',\n i18nStrings?.columnFilteringClearFilterText\n )}\n </InternalButton>\n </InternalSpaceBetween>\n </div>\n )}\n\n <div role=\"application\" aria-labelledby={titleId}>\n {optionTree && filteredTree ? (\n <HierarchicalContentDisplay\n tree={isFiltering ? filteredTree : optionTree}\n onToggle={handleToggle}\n onTreeChange={newTree => onChange(toContentDisplayItems(newTree))}\n ariaLabelledby={titleId}\n ariaDescribedby={descriptionId}\n i18nStrings={listI18nStrings}\n sortDisabled={isFiltering}\n groupLabelFormatter={groupLabelFormatter}\n />\n ) : (\n <InternalList\n items={filteredOptions}\n sortable={true}\n sortDisabled={isFiltering}\n disableItemPaddings={true}\n ariaLabelledby={titleId}\n ariaDescribedby={descriptionId}\n i18nStrings={listI18nStrings}\n onSortingChange={({ detail: { items } }) => onChange(items.map(({ id, visible }) => ({ id, visible })))}\n renderItem={item => ({\n id: item.id,\n announcementLabel: item.label,\n content: <ContentDisplayOption option={item} onToggle={() => handleToggle(item.id)} />,\n })}\n />\n )}\n </div>\n </div>\n );\n}\n"]}
@@ -1,10 +1,49 @@
1
1
  import { CollectionPreferencesProps } from '../interfaces';
2
- export interface OptionWithVisibility extends CollectionPreferencesProps.ContentDisplayOption {
2
+ type ContentDisplayItem = CollectionPreferencesProps.ContentDisplayItem;
3
+ type ContentDisplayOption = CollectionPreferencesProps.ContentDisplayOption;
4
+ type ContentDisplayOptionGroup = CollectionPreferencesProps.ContentDisplayOptionGroup;
5
+ export interface OptionWithVisibility extends ContentDisplayOption {
3
6
  visible: boolean;
4
7
  }
8
+ export interface OptionGroupNode {
9
+ type: 'group';
10
+ id: string;
11
+ label: string;
12
+ visible: boolean;
13
+ children: OptionTreeNode[];
14
+ }
15
+ export interface OptionLeafNode extends OptionWithVisibility {
16
+ type: 'leaf';
17
+ }
18
+ export type OptionTreeNode = OptionGroupNode | OptionLeafNode;
19
+ /**
20
+ * Extracts a flat ordered list of leaf items from the contentDisplay tree (depth-first).
21
+ */
22
+ export declare function walkLeaves(items: ReadonlyArray<ContentDisplayItem>): {
23
+ id: string;
24
+ visible: boolean;
25
+ }[];
26
+ /**
27
+ * Returns options ordered by contentDisplay, with visibility applied.
28
+ * Options not in contentDisplay are appended as non-visible.
29
+ */
5
30
  export declare function getSortedOptions({ options, contentDisplay, }: {
6
31
  options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;
7
32
  contentDisplay: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;
8
33
  }): ReadonlyArray<OptionWithVisibility>;
34
+ /**
35
+ * Converts contentDisplay tree into an internal OptionTreeNode tree,
36
+ * resolving labels from options/groups definitions.
37
+ */
38
+ export declare function buildOptionTree(options: ReadonlyArray<ContentDisplayOption>, groups: ReadonlyArray<ContentDisplayOptionGroup>, contentDisplay: ReadonlyArray<ContentDisplayItem>): OptionTreeNode[];
39
+ /**
40
+ * Converts OptionTreeNode[] back to ContentDisplayItem[].
41
+ */
42
+ export declare function toContentDisplayItems(tree: OptionTreeNode[]): ContentDisplayItem[];
43
+ /**
44
+ * Filters tree, keeping leaves matching filterText and groups with matching descendants.
45
+ */
46
+ export declare function getFilteredTree(tree: OptionTreeNode[], filterText: string): OptionTreeNode[];
9
47
  export declare function getFilteredOptions(options: ReadonlyArray<OptionWithVisibility>, filterText: string): readonly OptionWithVisibility[];
48
+ export {};
10
49
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,e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E,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAAE,CAUvG;AAED;;;GAGG;AACH,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,CAkBtC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAC5C,MAAM,EAAE,aAAa,CAAC,yBAAyB,CAAC,EAChD,cAAc,EAAE,aAAa,CAAC,kBAAkB,CAAC,GAChD,cAAc,EAAE,CAgClB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,kBAAkB,EAAE,CAYlF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE,CAkB5F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,MAAM,mCAMlG"}
@@ -1,23 +1,117 @@
1
+ /**
2
+ * Extracts a flat ordered list of leaf items from the contentDisplay tree (depth-first).
3
+ */
4
+ export function walkLeaves(items) {
5
+ const result = [];
6
+ for (const item of items) {
7
+ if (item.type === 'group') {
8
+ result.push(...walkLeaves(item.children));
9
+ }
10
+ else {
11
+ result.push({ id: item.id, visible: item.visible });
12
+ }
13
+ }
14
+ return result;
15
+ }
16
+ /**
17
+ * Returns options ordered by contentDisplay, with visibility applied.
18
+ * Options not in contentDisplay are appended as non-visible.
19
+ */
1
20
  export function getSortedOptions({ options, contentDisplay, }) {
2
- // By using a Map, we are guaranteed to preserve insertion order on future iteration.
3
- const optionsById = new Map();
4
- // We insert contentDisplay first so we respect the currently selected order
5
- for (const { id, visible } of contentDisplay) {
6
- // If an option is provided in contentDisplay and not options, we default the label to the id
7
- optionsById.set(id, { id, label: id, visible });
21
+ const optionMap = new Map(options.map(o => [o.id, o]));
22
+ const result = new Map();
23
+ for (const { id, visible } of walkLeaves(contentDisplay)) {
24
+ const option = optionMap.get(id);
25
+ if (option) {
26
+ result.set(id, { ...option, visible });
27
+ }
8
28
  }
9
- // We merge options data, and insert any that were not in contentDisplay as non-visible
10
29
  for (const option of options) {
11
- const existing = optionsById.get(option.id);
12
- optionsById.set(option.id, { ...option, visible: !!(existing === null || existing === void 0 ? void 0 : existing.visible) });
30
+ if (!result.has(option.id)) {
31
+ result.set(option.id, { ...option, visible: false });
32
+ }
33
+ }
34
+ return Array.from(result.values());
35
+ }
36
+ /**
37
+ * Converts contentDisplay tree into an internal OptionTreeNode tree,
38
+ * resolving labels from options/groups definitions.
39
+ */
40
+ export function buildOptionTree(options, groups, contentDisplay) {
41
+ if (!groups.length) {
42
+ const sorted = getSortedOptions({ options, contentDisplay });
43
+ return sorted.map(opt => ({ ...opt, type: 'leaf' }));
44
+ }
45
+ const optionMap = new Map(options.map(o => [o.id, o]));
46
+ const groupMap = new Map(groups.map(g => [g.id, g]));
47
+ const convert = (items) => {
48
+ var _a;
49
+ const result = [];
50
+ for (const item of items) {
51
+ if (item.type === 'group') {
52
+ const group = groupMap.get(item.id);
53
+ result.push({
54
+ type: 'group',
55
+ id: item.id,
56
+ label: (_a = group === null || group === void 0 ? void 0 : group.label) !== null && _a !== void 0 ? _a : item.id,
57
+ visible: item.visible,
58
+ children: convert(item.children),
59
+ });
60
+ }
61
+ else {
62
+ const option = optionMap.get(item.id);
63
+ if (option) {
64
+ result.push({ type: 'leaf', ...option, visible: item.visible });
65
+ }
66
+ }
67
+ }
68
+ return result;
69
+ };
70
+ return convert(contentDisplay);
71
+ }
72
+ /**
73
+ * Converts OptionTreeNode[] back to ContentDisplayItem[].
74
+ */
75
+ export function toContentDisplayItems(tree) {
76
+ return tree.map(node => {
77
+ if (node.type === 'group') {
78
+ return {
79
+ type: 'group',
80
+ id: node.id,
81
+ visible: node.visible,
82
+ children: toContentDisplayItems(node.children),
83
+ };
84
+ }
85
+ return { id: node.id, visible: node.visible };
86
+ });
87
+ }
88
+ /**
89
+ * Filters tree, keeping leaves matching filterText and groups with matching descendants.
90
+ */
91
+ export function getFilteredTree(tree, filterText) {
92
+ const text = filterText.trim().toLowerCase();
93
+ if (!text) {
94
+ return tree;
95
+ }
96
+ const result = [];
97
+ for (const node of tree) {
98
+ if (node.type === 'group') {
99
+ const children = getFilteredTree(node.children, text);
100
+ if (children.length > 0) {
101
+ result.push({ ...node, children });
102
+ }
103
+ }
104
+ else if (node.label.toLowerCase().includes(text)) {
105
+ result.push(node);
106
+ }
13
107
  }
14
- return Array.from(optionsById.values());
108
+ return result;
15
109
  }
16
110
  export function getFilteredOptions(options, filterText) {
17
- filterText = filterText.trim().toLowerCase();
18
- if (!filterText) {
111
+ const text = filterText.trim().toLowerCase();
112
+ if (!text) {
19
113
  return options;
20
114
  }
21
- return options.filter(option => option.label.toLowerCase().trim().includes(filterText));
115
+ return options.filter(option => option.label.toLowerCase().includes(text));
22
116
  }
23
117
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/utils.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,cAAc,GAIf;IACC,qFAAqF;IACrF,MAAM,WAAW,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC5D,4EAA4E;IAC5E,KAAK,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,cAAc,EAAE,CAAC;QAC7C,6FAA6F;QAC7F,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,uFAAuF;IACvF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5C,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,CAAA,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAA4C,EAAE,UAAkB;IACjG,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE7C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1F,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 // By using a Map, we are guaranteed to preserve insertion order on future iteration.\n const optionsById = new Map<string, OptionWithVisibility>();\n // We insert contentDisplay first so we respect the currently selected order\n for (const { id, visible } of contentDisplay) {\n // If an option is provided in contentDisplay and not options, we default the label to the id\n optionsById.set(id, { id, label: id, visible });\n }\n // We merge options data, and insert any that were not in contentDisplay as non-visible\n for (const option of options) {\n const existing = optionsById.get(option.id);\n optionsById.set(option.id, { ...option, visible: !!existing?.visible });\n }\n return Array.from(optionsById.values());\n}\n\nexport function getFilteredOptions(options: ReadonlyArray<OptionWithVisibility>, filterText: string) {\n filterText = filterText.trim().toLowerCase();\n\n if (!filterText) {\n return options;\n }\n\n return options.filter(option => option.label.toLowerCase().trim().includes(filterText));\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/collection-preferences/content-display/utils.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAwC;IACjE,MAAM,MAAM,GAAuC,EAAE,CAAC;IACtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,cAAc,GAIf;IACC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEvD,KAAK,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE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O,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { CollectionPreferencesProps } from '../interfaces';\n\ntype ContentDisplayItem = CollectionPreferencesProps.ContentDisplayItem;\ntype ContentDisplayOption = CollectionPreferencesProps.ContentDisplayOption;\ntype ContentDisplayOptionGroup = CollectionPreferencesProps.ContentDisplayOptionGroup;\n\nexport interface OptionWithVisibility extends ContentDisplayOption {\n visible: boolean;\n}\n\nexport interface OptionGroupNode {\n type: 'group';\n id: string;\n label: string;\n visible: boolean;\n children: OptionTreeNode[];\n}\n\nexport interface OptionLeafNode extends OptionWithVisibility {\n type: 'leaf';\n}\n\nexport type OptionTreeNode = OptionGroupNode | OptionLeafNode;\n\n/**\n * Extracts a flat ordered list of leaf items from the contentDisplay tree (depth-first).\n */\nexport function walkLeaves(items: ReadonlyArray<ContentDisplayItem>): { id: string; visible: boolean }[] {\n const result: { id: string; visible: boolean }[] = [];\n for (const item of items) {\n if (item.type === 'group') {\n result.push(...walkLeaves(item.children));\n } else {\n result.push({ id: item.id, visible: item.visible });\n }\n }\n return result;\n}\n\n/**\n * Returns options ordered by contentDisplay, with visibility applied.\n * Options not in contentDisplay are appended as non-visible.\n */\nexport function getSortedOptions({\n options,\n contentDisplay,\n}: {\n options: ReadonlyArray<CollectionPreferencesProps.ContentDisplayOption>;\n contentDisplay: ReadonlyArray<CollectionPreferencesProps.ContentDisplayItem>;\n}): ReadonlyArray<OptionWithVisibility> {\n const optionMap = new Map(options.map(o => [o.id, o]));\n const result = new Map<string, OptionWithVisibility>();\n\n for (const { id, visible } of walkLeaves(contentDisplay)) {\n const option = optionMap.get(id);\n if (option) {\n result.set(id, { ...option, visible });\n }\n }\n\n for (const option of options) {\n if (!result.has(option.id)) {\n result.set(option.id, { ...option, visible: false });\n }\n }\n\n return Array.from(result.values());\n}\n\n/**\n * Converts contentDisplay tree into an internal OptionTreeNode tree,\n * resolving labels from options/groups definitions.\n */\nexport function buildOptionTree(\n options: ReadonlyArray<ContentDisplayOption>,\n groups: ReadonlyArray<ContentDisplayOptionGroup>,\n contentDisplay: ReadonlyArray<ContentDisplayItem>\n): OptionTreeNode[] {\n if (!groups.length) {\n const sorted = getSortedOptions({ options, contentDisplay });\n return sorted.map(opt => ({ ...opt, type: 'leaf' as const }));\n }\n\n const optionMap = new Map(options.map(o => [o.id, o]));\n const groupMap = new Map(groups.map(g => [g.id, g]));\n\n const convert = (items: ReadonlyArray<ContentDisplayItem>): OptionTreeNode[] => {\n const result: OptionTreeNode[] = [];\n for (const item of items) {\n if (item.type === 'group') {\n const group = groupMap.get(item.id);\n result.push({\n type: 'group',\n id: item.id,\n label: group?.label ?? item.id,\n visible: item.visible,\n children: convert(item.children),\n });\n } else {\n const option = optionMap.get(item.id);\n if (option) {\n result.push({ type: 'leaf', ...option, visible: item.visible });\n }\n }\n }\n return result;\n };\n\n return convert(contentDisplay);\n}\n\n/**\n * Converts OptionTreeNode[] back to ContentDisplayItem[].\n */\nexport function toContentDisplayItems(tree: OptionTreeNode[]): ContentDisplayItem[] {\n return tree.map(node => {\n if (node.type === 'group') {\n return {\n type: 'group' as const,\n id: node.id,\n visible: node.visible,\n children: toContentDisplayItems(node.children),\n };\n }\n return { id: node.id, visible: node.visible };\n });\n}\n\n/**\n * Filters tree, keeping leaves matching filterText and groups with matching descendants.\n */\nexport function getFilteredTree(tree: OptionTreeNode[], filterText: string): OptionTreeNode[] {\n const text = filterText.trim().toLowerCase();\n if (!text) {\n return tree;\n }\n\n const result: OptionTreeNode[] = [];\n for (const node of tree) {\n if (node.type === 'group') {\n const children = getFilteredTree(node.children, text);\n if (children.length > 0) {\n result.push({ ...node, children });\n }\n } else if (node.label.toLowerCase().includes(text)) {\n result.push(node);\n }\n }\n return result;\n}\n\nexport function getFilteredOptions(options: ReadonlyArray<OptionWithVisibility>, filterText: string) {\n const text = filterText.trim().toLowerCase();\n if (!text) {\n return options;\n }\n return options.filter(option => option.label.toLowerCase().includes(text));\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collection-preferences/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAiB1D,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAItC,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,cAAc,EACd,QAAgB,EAChB,SAAS,EACT,QAAQ,EACR,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,GAAG,IAAI,EACR,EAAE,0BAA0B,eAiO5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/collection-preferences/index.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAkB1D,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAItC,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,KAAK,EACL,YAAY,EACZ,WAAW,EACX,cAAc,EACd,QAAgB,EAChB,SAAS,EACT,QAAQ,EACR,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,aAAa,EACb,GAAG,IAAI,EACR,EAAE,0BAA0B,eAkO5B"}