@redvars/peacock 3.15.0 → 3.17.0

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 (157) hide show
  1. package/dist/assets/styles.css +1 -1
  2. package/dist/assets/styles.css.map +1 -1
  3. package/dist/assets/theme.js +19 -19
  4. package/dist/assets/tokens.css +1 -1
  5. package/dist/assets/tokens.css.map +1 -1
  6. package/dist/card-content.js +8 -7
  7. package/dist/card-content.js.map +1 -1
  8. package/dist/card.js +142 -98
  9. package/dist/card.js.map +1 -1
  10. package/dist/{chart-bar-D5dGFJfK.js → cartesian-chart-DgE4USyC.js} +529 -312
  11. package/dist/cartesian-chart-DgE4USyC.js.map +1 -0
  12. package/dist/chart-area.js +78 -0
  13. package/dist/chart-area.js.map +1 -0
  14. package/dist/chart-bar.js +283 -213
  15. package/dist/chart-bar.js.map +1 -1
  16. package/dist/{transform-DSwFSqzD.js → chart-base-C2qRMF48.js} +771 -102
  17. package/dist/chart-base-C2qRMF48.js.map +1 -0
  18. package/dist/chart-doughnut.js +55 -287
  19. package/dist/chart-doughnut.js.map +1 -1
  20. package/dist/chart-line.js +626 -0
  21. package/dist/chart-line.js.map +1 -0
  22. package/dist/chart-pie.js +637 -195
  23. package/dist/chart-pie.js.map +1 -1
  24. package/dist/code-editor.js +704 -131
  25. package/dist/code-editor.js.map +1 -1
  26. package/dist/code-group.js +188 -0
  27. package/dist/code-group.js.map +1 -0
  28. package/dist/code-highlighter.js +895 -257
  29. package/dist/code-highlighter.js.map +1 -1
  30. package/dist/custom-elements-jsdocs.json +2278 -677
  31. package/dist/custom-elements.json +13962 -3690
  32. package/dist/image.js +5 -1
  33. package/dist/image.js.map +1 -1
  34. package/dist/index.js +8 -7
  35. package/dist/index.js.map +1 -1
  36. package/dist/loader-full.js +1 -1
  37. package/dist/loader.js +9 -3
  38. package/dist/loader.js.map +1 -1
  39. package/dist/{is-dark-mode-DOcaw4Yq.js → observe-theme-change-DCifz1uv.js} +2 -6
  40. package/dist/observe-theme-change-DCifz1uv.js.map +1 -0
  41. package/dist/pagination.js +408 -110
  42. package/dist/pagination.js.map +1 -1
  43. package/dist/path-CJ0Arqcy.js +166 -0
  44. package/dist/path-CJ0Arqcy.js.map +1 -0
  45. package/dist/snackbar.js +89 -34
  46. package/dist/snackbar.js.map +1 -1
  47. package/dist/src/__internal/chart/cartesian-chart.d.ts +80 -0
  48. package/dist/src/__internal/chart/chart-base.d.ts +113 -0
  49. package/dist/src/__internal/chart/paths.d.ts +5 -0
  50. package/dist/src/__internal/chart/types.d.ts +42 -0
  51. package/dist/src/card/card-content.d.ts +2 -3
  52. package/dist/src/card/card.d.ts +31 -17
  53. package/dist/src/chart-area/chart-area.d.ts +54 -0
  54. package/dist/src/chart-area/index.d.ts +1 -0
  55. package/dist/src/chart-bar/chart-bar.d.ts +44 -33
  56. package/dist/src/chart-bar/index.d.ts +0 -1
  57. package/dist/src/chart-doughnut/chart-doughnut.d.ts +33 -39
  58. package/dist/src/chart-line/chart-line.d.ts +69 -0
  59. package/dist/src/chart-line/index.d.ts +1 -0
  60. package/dist/src/chart-pie/chart-pie.d.ts +63 -28
  61. package/dist/src/code-editor/code-editor.d.ts +52 -13
  62. package/dist/src/code-editor/editor-theme.d.ts +60 -0
  63. package/dist/src/code-highlighter/code-group.d.ts +52 -0
  64. package/dist/src/code-highlighter/code-highlighter.d.ts +122 -15
  65. package/dist/src/code-highlighter/index.d.ts +1 -0
  66. package/dist/src/code-highlighter/line-ranges.d.ts +24 -0
  67. package/dist/src/code-highlighter/local.d.ts +4 -1
  68. package/dist/src/code-highlighter/token-colors.d.ts +8 -0
  69. package/dist/src/index.d.ts +4 -2
  70. package/dist/src/pagination/page-items.d.ts +14 -0
  71. package/dist/src/pagination/pagination.d.ts +46 -7
  72. package/dist/src/snackbar/snackbar.d.ts +13 -1
  73. package/dist/src/table/table.d.ts +125 -27
  74. package/dist/src/toolbar/toolbar.d.ts +56 -51
  75. package/dist/table.js +1007 -338
  76. package/dist/table.js.map +1 -1
  77. package/dist/test/chart.test.d.ts +1 -0
  78. package/dist/test/code-highlighter.test.d.ts +1 -0
  79. package/dist/test/pagination.test.d.ts +1 -0
  80. package/dist/test/table.test.d.ts +1 -0
  81. package/dist/token-colors-0TFHWbcq.js +81 -0
  82. package/dist/token-colors-0TFHWbcq.js.map +1 -0
  83. package/dist/toolbar.js +195 -184
  84. package/dist/toolbar.js.map +1 -1
  85. package/dist/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +1 -2
  87. package/readme.md +7 -6
  88. package/scss/_code-block.scss +139 -0
  89. package/scss/tokens.css +24 -0
  90. package/src/__internal/chart/cartesian-chart.ts +404 -0
  91. package/src/__internal/chart/chart-base.scss +252 -0
  92. package/src/__internal/chart/chart-base.ts +474 -0
  93. package/src/__internal/chart/paths.ts +28 -0
  94. package/src/__internal/chart/types.ts +49 -0
  95. package/src/card/card-content.ts +12 -9
  96. package/src/card/card.scss +66 -54
  97. package/src/card/card.ts +109 -73
  98. package/src/chart-area/chart-area.ts +82 -0
  99. package/src/chart-area/index.ts +1 -0
  100. package/src/chart-bar/chart-bar.ts +336 -250
  101. package/src/chart-bar/index.ts +0 -1
  102. package/src/chart-doughnut/chart-doughnut.ts +62 -262
  103. package/src/chart-doughnut/demo/index.html +14 -22
  104. package/src/chart-line/chart-line.scss +25 -0
  105. package/src/chart-line/chart-line.ts +346 -0
  106. package/src/chart-line/index.ts +1 -0
  107. package/src/chart-pie/chart-pie.scss +35 -16
  108. package/src/chart-pie/chart-pie.ts +282 -188
  109. package/src/chart-pie/demo/index.html +13 -21
  110. package/src/code-editor/code-editor.scss +132 -36
  111. package/src/code-editor/code-editor.ts +308 -88
  112. package/src/code-editor/demo/index.html +39 -12
  113. package/src/code-editor/editor-theme.ts +213 -0
  114. package/src/code-highlighter/code-group.scss +34 -0
  115. package/src/code-highlighter/code-group.ts +173 -0
  116. package/src/code-highlighter/code-highlighter.scss +226 -111
  117. package/src/code-highlighter/code-highlighter.ts +554 -199
  118. package/src/code-highlighter/demo/index.html +68 -4
  119. package/src/code-highlighter/index.ts +1 -0
  120. package/src/code-highlighter/line-ranges.ts +81 -0
  121. package/src/code-highlighter/local.ts +9 -3
  122. package/src/code-highlighter/token-colors.ts +42 -0
  123. package/src/index.ts +4 -2
  124. package/src/loader.ts +8 -2
  125. package/src/pagination/page-items.ts +50 -0
  126. package/src/pagination/pagination.scss +159 -44
  127. package/src/pagination/pagination.ts +275 -74
  128. package/src/snackbar/demo/index.html +39 -4
  129. package/src/snackbar/snackbar.scss +27 -10
  130. package/src/snackbar/snackbar.ts +80 -37
  131. package/src/table/table.scss +337 -109
  132. package/src/table/table.ts +812 -272
  133. package/src/toolbar/toolbar-colors.scss +6 -7
  134. package/src/toolbar/toolbar.scss +35 -106
  135. package/src/toolbar/toolbar.ts +180 -80
  136. package/dist/array-D5vjT2Xm.js +0 -14
  137. package/dist/array-D5vjT2Xm.js.map +0 -1
  138. package/dist/chart-bar-D5dGFJfK.js.map +0 -1
  139. package/dist/chart-stacked-bar.js +0 -403
  140. package/dist/chart-stacked-bar.js.map +0 -1
  141. package/dist/copy-to-clipboard-upGx-Ueo.js +0 -39
  142. package/dist/copy-to-clipboard-upGx-Ueo.js.map +0 -1
  143. package/dist/is-dark-mode-DOcaw4Yq.js.map +0 -1
  144. package/dist/pie-Dz0IDiPt.js +0 -537
  145. package/dist/pie-Dz0IDiPt.js.map +0 -1
  146. package/dist/pierre-dark-DFWl0m-C.js +0 -4
  147. package/dist/pierre-dark-DFWl0m-C.js.map +0 -1
  148. package/dist/pierre-light-BEkAPImt.js +0 -4
  149. package/dist/pierre-light-BEkAPImt.js.map +0 -1
  150. package/dist/src/chart-bar/chart-stacked-bar.d.ts +0 -78
  151. package/dist/src/code-highlighter/constants.d.ts +0 -1
  152. package/dist/transform-DSwFSqzD.js.map +0 -1
  153. package/src/chart-bar/chart-bar.scss +0 -58
  154. package/src/chart-bar/chart-stacked-bar.ts +0 -398
  155. package/src/chart-doughnut/chart-donut.scss +0 -37
  156. package/src/code-highlighter/constants.ts +0 -117
  157. /package/dist/test/{chart-bar.test.d.ts → card.test.d.ts} +0 -0
package/dist/toolbar.js CHANGED
@@ -1,23 +1,8 @@
1
- import { i, _ as __decorate, I as IndividualComponent, a as i$1, b } from './IndividualComponent-Bdwyrvd6.js';
1
+ import { i, _ as __decorate, I as IndividualComponent, a as i$1, A, b } from './IndividualComponent-Bdwyrvd6.js';
2
2
  import { n } from './property-B49QQ8pS.js';
3
3
  import { e } from './class-map-DG7CA1et.js';
4
4
  import './directive-ZPhl09Yt.js';
5
5
 
6
- const LEGACY_SIZES = {
7
- small: 'sm',
8
- medium: 'md',
9
- large: 'lg',
10
- };
11
- /**
12
- * Maps a size attribute onto the `sm|md|lg` scale, accepting the deprecated long names.
13
- * Unknown values fall back to `fallback`.
14
- */
15
- function normalizeSize(size, fallback = 'md') {
16
- if (size === 'sm' || size === 'md' || size === 'lg')
17
- return size;
18
- return LEGACY_SIZES[size] ?? fallback;
19
- }
20
-
21
6
  var css_248z$1 = i`* {
22
7
  box-sizing: border-box;
23
8
  -webkit-tap-highlight-color: transparent;
@@ -32,28 +17,24 @@ var css_248z$1 = i`* {
32
17
  }
33
18
 
34
19
  :host {
35
- display: block;
20
+ display: inline-block;
21
+ vertical-align: middle;
36
22
  --toolbar-container-shape: var(--shape-corner-full);
37
- --toolbar-docked-container-shape: var(--shape-corner-extra-large) var(--shape-corner-extra-large) var(--shape-corner-none) var(--shape-corner-none);
38
- --toolbar-height: 5rem; /* 80dp - small/default docked */
39
- --toolbar-padding-inline: 0.75rem;
40
- --toolbar-gap: 0.5rem;
41
- --toolbar-shadow: none;
23
+ --toolbar-padding: 0.5rem;
24
+ --toolbar-gap: 0.25rem;
25
+ }
26
+
27
+ :host([orientation=vertical]) {
28
+ vertical-align: top;
42
29
  }
43
30
 
44
31
  /* ---- Shared toolbar base ---- */
45
32
  .toolbar {
46
33
  position: relative;
47
34
  display: flex;
48
- align-items: center;
49
- gap: var(--toolbar-gap);
50
- padding-inline: var(--toolbar-padding-inline);
51
- min-height: var(--toolbar-height);
52
- width: 100%;
53
35
  box-sizing: border-box;
54
- color: var(--_toolbar-title-color);
36
+ color: var(--_toolbar-content-color);
55
37
  --icon-color: var(--_toolbar-icon-color);
56
- box-shadow: var(--toolbar-shadow);
57
38
  }
58
39
 
59
40
  .toolbar-content {
@@ -61,6 +42,7 @@ var css_248z$1 = i`* {
61
42
  z-index: 1;
62
43
  display: flex;
63
44
  align-items: center;
45
+ gap: var(--toolbar-gap);
64
46
  min-width: 0;
65
47
  }
66
48
 
@@ -72,60 +54,34 @@ var css_248z$1 = i`* {
72
54
  z-index: 0;
73
55
  }
74
56
 
75
- /* ---- Docked variant ---- */
76
- .toolbar.variant-docked {
77
- width: 100%;
78
- padding-inline: var(--toolbar-padding-inline);
79
- padding-block-start: 0.5rem;
80
- padding-block-end: calc(0.5rem + env(safe-area-inset-bottom, 0px));
81
- }
82
- .toolbar.variant-docked .background {
83
- border-radius: var(--toolbar-docked-container-shape);
84
- }
85
- .toolbar.variant-docked .toolbar-content {
86
- width: 100%;
87
- justify-content: space-between;
88
- gap: var(--toolbar-gap);
89
- overflow-x: auto;
90
- overflow-y: hidden;
91
- scrollbar-width: none;
92
- }
93
- .toolbar.variant-docked .toolbar-content::-webkit-scrollbar {
94
- display: none;
95
- }
96
- .toolbar.variant-docked ::slotted(*) {
97
- position: relative;
98
- z-index: 1;
57
+ ::slotted(*) {
99
58
  flex-shrink: 0;
100
59
  }
101
- .toolbar.variant-docked ::slotted(wc-icon-button) {
60
+
61
+ ::slotted(wc-icon-button) {
102
62
  --button-container-shape: var(--shape-corner-full);
103
63
  --button-container-shape-variant: round;
104
64
  }
105
- .toolbar.variant-docked {
106
- /* Size variants */
107
- }
108
- .toolbar.variant-docked.size-sm {
109
- --toolbar-height: 5rem;
110
- }
111
- .toolbar.variant-docked.size-md {
112
- --toolbar-height: 6rem;
65
+
66
+ /* ---- Orientation ---- */
67
+ .orientation-horizontal .toolbar-content {
68
+ flex-direction: row;
113
69
  }
114
- .toolbar.variant-docked.size-lg {
115
- --toolbar-height: 7rem;
70
+
71
+ .orientation-vertical .toolbar-content {
72
+ flex-direction: column;
116
73
  }
117
- .toolbar.variant-docked.elevated {
118
- --toolbar-shadow: var(--elevation-level3);
74
+
75
+ /* Dividers separate groups of actions: a short line across the toolbar's direction. */
76
+ ::slotted(wc-divider) {
77
+ align-self: stretch;
78
+ --divider-spacing: 0.25rem;
119
79
  }
120
80
 
121
81
  /* ---- Floating variant ---- */
122
82
  .toolbar.variant-floating {
123
- --toolbar-container-shape: var(--shape-corner-full);
83
+ padding: var(--toolbar-padding);
124
84
  border-radius: var(--toolbar-container-shape);
125
- width: auto;
126
- display: inline-flex;
127
- padding: 0.75rem;
128
- gap: 0.5rem;
129
85
  }
130
86
  .toolbar.variant-floating .elevation {
131
87
  --elevation-level: 3;
@@ -135,178 +91,236 @@ var css_248z$1 = i`* {
135
91
  .toolbar.variant-floating .background {
136
92
  border-radius: var(--toolbar-container-shape);
137
93
  }
138
- .toolbar.variant-floating .toolbar-content {
139
- width: auto;
140
- gap: 0.5rem;
141
- }
142
- .toolbar.variant-floating ::slotted(*) {
143
- position: relative;
144
- z-index: 1;
145
- }
146
- .toolbar.variant-floating ::slotted(wc-icon-button) {
147
- --button-container-shape: var(--shape-corner-full);
148
- --button-container-shape-variant: round;
149
- }
150
- .toolbar.variant-floating.orientation-horizontal {
151
- min-height: auto;
152
- padding-block: 0.5rem;
153
- padding-inline: 0.75rem;
154
- }
155
- .toolbar.variant-floating.orientation-horizontal .toolbar-content {
156
- flex-direction: row;
157
- align-items: center;
158
- }
159
- .toolbar.variant-floating.orientation-vertical {
160
- min-height: auto;
161
- width: auto;
162
- padding-block: 0.75rem;
163
- padding-inline: 0.5rem;
164
- }
165
- .toolbar.variant-floating.orientation-vertical .toolbar-content {
166
- flex-direction: column;
167
- align-items: center;
168
- }
169
94
  .toolbar.variant-floating.elevated .elevation {
170
95
  --elevation-level: 4;
96
+ }
97
+
98
+ /* ---- Flat variant ---- */
99
+ .toolbar.variant-flat {
100
+ padding: 0;
171
101
  }`;
172
102
 
173
103
  var css_248z = i`:host {
174
- /* Docked toolbar */
175
- --toolbar-container-color: var(--color-surface-container);
176
- --toolbar-title-color: var(--color-on-surface);
104
+ --toolbar-container-color: var(--color-surface-container-high);
105
+ --toolbar-content-color: var(--color-on-surface);
177
106
  --toolbar-icon-color: var(--color-on-surface-variant);
178
107
  /* Internal aliases used by styles */
179
108
  --_toolbar-container-color: var(--toolbar-container-color);
180
- --_toolbar-title-color: var(--toolbar-title-color);
109
+ --_toolbar-content-color: var(--toolbar-content-color);
181
110
  --_toolbar-icon-color: var(--toolbar-icon-color);
182
111
  }
183
112
 
184
- /* Floating variant uses surface-container-high for a visible pill */
185
- :host([variant=floating]) {
186
- --toolbar-container-color: var(--color-surface-container-high);
113
+ /* The flat toolbar takes on the surface it sits on. */
114
+ :host([variant=flat]) {
115
+ --toolbar-container-color: transparent;
187
116
  }`;
188
117
 
189
- var Toolbar_1;
118
+ /** Slotted elements that separate groups and never take focus. */
119
+ const SEPARATOR_SELECTOR = 'wc-divider, hr, [role="separator"]';
190
120
  /**
191
121
  * @label Toolbar
192
122
  * @tag wc-toolbar
193
123
  * @rawTag toolbar
194
124
  *
195
- * @summary A toolbar / app bar for navigation and actions.
125
+ * @summary A group of related actions, such as editor formatting controls.
196
126
  * @overview
197
- * <p>The toolbar component implements the app bar pattern. It supports a
198
- * docked (attached) variant for bottom-panel navigation and a floating (detached pill-shaped)
199
- * variant. The floating variant supports both horizontal and vertical orientations.</p>
127
+ * <p>The toolbar groups related actions into one control. The <code>floating</code> variant
128
+ * (default) is an elevated pill that sits over content, such as a canvas or a selection. The
129
+ * <code>flat</code> variant has no container of its own, for embedding in existing chrome like a
130
+ * card or editor header. Both variants lay their actions out horizontally or vertically.</p>
200
131
  *
201
- * <p>Render toolbar actions directly as children of the component. The docked variant is
202
- * optimized for a horizontal action row, while the floating variant supports both horizontal
203
- * and vertical layouts.</p>
132
+ * <p>Render actions directly as children. Use a <code>wc-divider</code> to separate groups of
133
+ * actions; in a horizontal toolbar give it the <code>vertical</code> attribute.</p>
134
+ *
135
+ * <p>The toolbar follows the WAI-ARIA toolbar pattern: it is a single tab stop, and the arrow
136
+ * keys along its orientation move focus between actions (Home and End jump to the first and last).
137
+ * Disabled actions and dividers are skipped. Give the toolbar an <code>aria-label</code>.</p>
204
138
  *
205
139
  * @cssprop --toolbar-container-color - Background color of the toolbar.
206
- * @cssprop --toolbar-container-shape - Border radius of the toolbar. Relevant for the floating variant.
207
- * @cssprop --toolbar-height - Height of the toolbar (docked horizontal / floating horizontal).
208
- * @cssprop --toolbar-padding-inline - Inline padding of the toolbar.
209
- * @cssprop --toolbar-gap - Gap between toolbar sections.
210
- * @cssprop --toolbar-icon-color - Color of icon slots.
211
- * @cssprop --toolbar-title-color - Color of the title (default slot) text.
212
- * @cssprop --toolbar-shadow - Box-shadow of the toolbar.
140
+ * @cssprop --toolbar-container-shape - Border radius of the floating toolbar.
141
+ * @cssprop --toolbar-padding - Padding of the floating toolbar.
142
+ * @cssprop --toolbar-gap - Gap between toolbar actions.
143
+ * @cssprop --toolbar-icon-color - Color of icons inside the toolbar.
144
+ * @cssprop --toolbar-content-color - Color of text inside the toolbar.
213
145
  *
214
146
  * @example
215
147
  * ```html
216
- * <!-- Docked toolbar -->
217
- * <wc-toolbar>
218
- * <wc-icon-button variant="text" color="surface"><wc-icon name="home"></wc-icon></wc-icon-button>
219
- * <wc-icon-button variant="tonal"><wc-icon name="search"></wc-icon></wc-icon-button>
220
- * <wc-icon-button variant="text" color="surface"><wc-icon name="favorite"></wc-icon></wc-icon-button>
221
- * <wc-icon-button variant="text" color="surface"><wc-icon name="account_circle"></wc-icon></wc-icon-button>
148
+ * <!-- Floating toolbar -->
149
+ * <wc-toolbar aria-label="Formatting">
150
+ * <wc-icon-button variant="text" color="surface" aria-label="Undo"><wc-icon name="undo"></wc-icon></wc-icon-button>
151
+ * <wc-icon-button variant="text" color="surface" aria-label="Redo"><wc-icon name="redo"></wc-icon></wc-icon-button>
152
+ * <wc-divider vertical></wc-divider>
153
+ * <wc-icon-button variant="tonal" aria-label="Bold"><wc-icon name="format_bold"></wc-icon></wc-icon-button>
154
+ * <wc-icon-button variant="text" color="surface" aria-label="Italic"><wc-icon name="format_italic"></wc-icon></wc-icon-button>
222
155
  * </wc-toolbar>
223
156
  * ```
224
157
  *
225
158
  * @example
226
159
  * ```html
227
- * <!-- Floating horizontal toolbar -->
228
- * <wc-toolbar variant="floating" orientation="horizontal">
229
- * <wc-icon-button variant="tonal"><wc-icon name="home"></wc-icon></wc-icon-button>
230
- * <wc-icon-button variant="text"><wc-icon name="search"></wc-icon></wc-icon-button>
231
- * <wc-icon-button variant="text"><wc-icon name="favorite"></wc-icon></wc-icon-button>
160
+ * <!-- Vertical floating toolbar -->
161
+ * <wc-toolbar orientation="vertical" aria-label="Tools">
162
+ * <wc-icon-button variant="tonal" aria-label="Select"><wc-icon name="arrow_selector_tool"></wc-icon></wc-icon-button>
163
+ * <wc-icon-button variant="text" color="surface" aria-label="Draw"><wc-icon name="draw"></wc-icon></wc-icon-button>
164
+ * <wc-icon-button variant="text" color="surface" aria-label="Text"><wc-icon name="text_fields"></wc-icon></wc-icon-button>
232
165
  * </wc-toolbar>
233
166
  * ```
234
167
  *
235
168
  * @example
236
169
  * ```html
237
- * <!-- Floating vertical toolbar -->
238
- * <wc-toolbar variant="floating" orientation="vertical">
239
- * <wc-icon-button variant="tonal"><wc-icon name="home"></wc-icon></wc-icon-button>
240
- * <wc-icon-button variant="text"><wc-icon name="search"></wc-icon></wc-icon-button>
241
- * <wc-icon-button variant="text"><wc-icon name="favorite"></wc-icon></wc-icon-button>
170
+ * <!-- Flat toolbar inside existing chrome -->
171
+ * <wc-toolbar variant="flat" aria-label="Row actions">
172
+ * <wc-icon-button variant="text" color="surface" aria-label="Edit"><wc-icon name="edit"></wc-icon></wc-icon-button>
173
+ * <wc-icon-button variant="text" color="surface" aria-label="Delete"><wc-icon name="delete"></wc-icon></wc-icon-button>
242
174
  * </wc-toolbar>
243
175
  * ```
244
- * @tags display navigation
176
+ * @tags display
245
177
  */
246
- let Toolbar = Toolbar_1 = class Toolbar extends i$1 {
178
+ let Toolbar = class Toolbar extends i$1 {
247
179
  constructor() {
248
180
  super(...arguments);
181
+ // ── Properties
249
182
  /**
250
- * Visual and layout variant of the toolbar.
251
- * - `"docked"`: A full-width bar attached to the edge of the screen (default).
252
- * - `"floating"`: A detached pill-shaped toolbar that floats over content.
183
+ * Visual variant of the toolbar.
184
+ * - `"floating"`: An elevated pill that floats over content (default).
185
+ * - `"flat"`: No container, fill or elevation; for embedding in existing chrome.
253
186
  */
254
- this.variant = 'docked';
187
+ this.variant = 'floating';
255
188
  /**
256
- * Orientation of the toolbar content.
257
- * - `"horizontal"`: Items are laid out left to right (default).
258
- * - `"vertical"`: Items are stacked top to bottom. Primarily useful for the floating variant.
189
+ * Orientation of the toolbar. It sets the layout direction and the arrow keys that move focus
190
+ * (Left/Right for horizontal, Up/Down for vertical).
259
191
  */
260
192
  this.orientation = 'horizontal';
261
193
  /**
262
- * Size of the docked toolbar.
263
- * - `"sm"`: 80dp height (default).
264
- * - `"md"`: 96dp height.
265
- * - `"lg"`: 112dp height.
266
- *
267
- * The long names `"small"`, `"medium"` and `"large"` still work but are deprecated.
268
- */
269
- this.size = 'sm';
270
- /**
271
- * Whether the toolbar is visually elevated (adds a shadow).
194
+ * Raises the floating toolbar to a higher elevation. Has no effect on the flat variant.
272
195
  */
273
196
  this.elevated = false;
197
+ // ── Private fields
198
+ /** The item that holds the toolbar's single tab stop. */
199
+ this.__activeItem = null;
200
+ this.__handleSlotChange = () => {
201
+ this.__syncTabStops();
202
+ };
203
+ this.__handleFocusIn = (event) => {
204
+ const item = this.__itemFromEvent(event, this.__getItems());
205
+ if (item && item !== this.__activeItem) {
206
+ this.__activeItem = item;
207
+ this.__syncTabStops();
208
+ }
209
+ };
210
+ this.__handleKeyDown = (event) => {
211
+ const items = this.__getItems();
212
+ if (items.length === 0)
213
+ return;
214
+ const current = this.__itemFromEvent(event, items);
215
+ if (!current)
216
+ return;
217
+ const index = items.indexOf(current);
218
+ let nextKey = 'ArrowDown';
219
+ let prevKey = 'ArrowUp';
220
+ if (this.orientation === 'horizontal') {
221
+ const rtl = getComputedStyle(this).direction === 'rtl';
222
+ nextKey = rtl ? 'ArrowLeft' : 'ArrowRight';
223
+ prevKey = rtl ? 'ArrowRight' : 'ArrowLeft';
224
+ }
225
+ let target;
226
+ switch (event.key) {
227
+ case nextKey:
228
+ target = items[(index + 1) % items.length];
229
+ break;
230
+ case prevKey:
231
+ target = items[(index - 1 + items.length) % items.length];
232
+ break;
233
+ case 'Home':
234
+ [target] = items;
235
+ break;
236
+ case 'End':
237
+ target = items[items.length - 1];
238
+ break;
239
+ default:
240
+ return;
241
+ }
242
+ event.preventDefault();
243
+ if (target)
244
+ this.__focusItem(target);
245
+ };
246
+ }
247
+ // ── Lifecycle
248
+ connectedCallback() {
249
+ super.connectedCallback();
250
+ // The role lives on the host so the host's aria-label names the toolbar.
251
+ this.setAttribute('role', 'toolbar');
252
+ }
253
+ firstUpdated() {
254
+ this.__syncTabStops();
255
+ }
256
+ updated(changed) {
257
+ if (changed.has('orientation')) {
258
+ this.setAttribute('aria-orientation', this.orientation);
259
+ }
260
+ }
261
+ // ── Private methods
262
+ /** Actions that can take focus, in slot order. */
263
+ __getItems() {
264
+ const slot = this.shadowRoot?.querySelector('slot');
265
+ if (!slot)
266
+ return [];
267
+ return slot
268
+ .assignedElements({ flatten: true })
269
+ .filter((el) => el instanceof HTMLElement &&
270
+ !el.matches(SEPARATOR_SELECTOR) &&
271
+ !el.hasAttribute('disabled') &&
272
+ el.getAttribute('aria-disabled') !== 'true' &&
273
+ !el.hidden);
274
+ }
275
+ /** Gives the active item `tabindex="0"` and every other item `tabindex="-1"`. */
276
+ __syncTabStops() {
277
+ const items = this.__getItems();
278
+ if (!this.__activeItem || !items.includes(this.__activeItem)) {
279
+ this.__activeItem = items[0] ?? null;
280
+ }
281
+ for (const item of items) {
282
+ item.tabIndex = item === this.__activeItem ? 0 : -1;
283
+ }
274
284
  }
285
+ /** Makes `item` the tab stop and focuses it. */
286
+ __focusItem(item) {
287
+ this.__activeItem = item;
288
+ this.__syncTabStops();
289
+ item.focus();
290
+ }
291
+ /** Finds the toolbar item an event came from. */
292
+ __itemFromEvent(event, items) {
293
+ return (event
294
+ .composedPath()
295
+ .find((node) => items.includes(node)) ?? null);
296
+ }
297
+ // ── Render
275
298
  render() {
299
+ const floating = this.variant === 'floating';
276
300
  const cssClasses = {
277
301
  toolbar: true,
278
302
  [`variant-${this.variant}`]: true,
279
303
  [`orientation-${this.orientation}`]: true,
280
- [`size-${normalizeSize(this.size, 'sm')}`]: true,
281
- elevated: this.elevated,
304
+ elevated: floating && this.elevated,
282
305
  };
283
- if (this.variant === 'floating') {
284
- return Toolbar_1.__renderFloating(cssClasses);
285
- }
286
- return Toolbar_1.__renderDocked(cssClasses);
287
- }
288
- static __renderDocked(cssClasses) {
289
306
  return b `
290
- <div class=${e(cssClasses)} role="toolbar">
307
+ <div
308
+ class=${e(cssClasses)}
309
+ @keydown=${this.__handleKeyDown}
310
+ @focusin=${this.__handleFocusIn}
311
+ >
312
+ ${floating
313
+ ? b `<wc-elevation class="elevation"></wc-elevation>`
314
+ : A}
291
315
  <div class="background"></div>
292
316
  <div class="toolbar-content">
293
- <slot></slot>
294
- </div>
295
- </div>
296
- `;
297
- }
298
- static __renderFloating(cssClasses) {
299
- return b `
300
- <div class=${e(cssClasses)} role="toolbar">
301
- <wc-elevation class="elevation"></wc-elevation>
302
- <div class="background"></div>
303
- <div class="toolbar-content">
304
- <slot></slot>
317
+ <slot @slotchange=${this.__handleSlotChange}></slot>
305
318
  </div>
306
319
  </div>
307
320
  `;
308
321
  }
309
322
  };
323
+ // ── Static
310
324
  Toolbar.styles = [css_248z$1, css_248z];
311
325
  __decorate([
312
326
  n({ type: String, reflect: true })
@@ -314,13 +328,10 @@ __decorate([
314
328
  __decorate([
315
329
  n({ type: String, reflect: true })
316
330
  ], Toolbar.prototype, "orientation", void 0);
317
- __decorate([
318
- n({ type: String, reflect: true })
319
- ], Toolbar.prototype, "size", void 0);
320
331
  __decorate([
321
332
  n({ type: Boolean, reflect: true })
322
333
  ], Toolbar.prototype, "elevated", void 0);
323
- Toolbar = Toolbar_1 = __decorate([
334
+ Toolbar = __decorate([
324
335
  IndividualComponent
325
336
  ], Toolbar);
326
337
 
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.js","sources":["../../src/__internal/utils/size.ts","../../src/toolbar/toolbar.ts"],"sourcesContent":["/** The size scale components share. Only button-like components add `xs` and `xl`. */\nexport type Size = 'sm' | 'md' | 'lg';\n\n/** Long size names some components accepted before the `sm|md|lg` scale. Deprecated. */\nexport type LegacySize = 'small' | 'medium' | 'large';\n\nconst LEGACY_SIZES: Record<LegacySize, Size> = {\n small: 'sm',\n medium: 'md',\n large: 'lg',\n};\n\n/**\n * Maps a size attribute onto the `sm|md|lg` scale, accepting the deprecated long names.\n * Unknown values fall back to `fallback`.\n */\nexport function normalizeSize(\n size: string | null | undefined,\n fallback: Size = 'md',\n): Size {\n if (size === 'sm' || size === 'md' || size === 'lg') return size;\n return LEGACY_SIZES[size as LegacySize] ?? fallback;\n}\n","import { LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport {\n type LegacySize,\n normalizeSize,\n type Size,\n} from '@/__internal/utils/size.js';\nimport styles from './toolbar.scss';\nimport colorStyles from './toolbar-colors.scss';\n\n/**\n * @label Toolbar\n * @tag wc-toolbar\n * @rawTag toolbar\n *\n * @summary A toolbar / app bar for navigation and actions.\n * @overview\n * <p>The toolbar component implements the app bar pattern. It supports a\n * docked (attached) variant for bottom-panel navigation and a floating (detached pill-shaped)\n * variant. The floating variant supports both horizontal and vertical orientations.</p>\n *\n * <p>Render toolbar actions directly as children of the component. The docked variant is\n * optimized for a horizontal action row, while the floating variant supports both horizontal\n * and vertical layouts.</p>\n *\n * @cssprop --toolbar-container-color - Background color of the toolbar.\n * @cssprop --toolbar-container-shape - Border radius of the toolbar. Relevant for the floating variant.\n * @cssprop --toolbar-height - Height of the toolbar (docked horizontal / floating horizontal).\n * @cssprop --toolbar-padding-inline - Inline padding of the toolbar.\n * @cssprop --toolbar-gap - Gap between toolbar sections.\n * @cssprop --toolbar-icon-color - Color of icon slots.\n * @cssprop --toolbar-title-color - Color of the title (default slot) text.\n * @cssprop --toolbar-shadow - Box-shadow of the toolbar.\n *\n * @example\n * ```html\n * <!-- Docked toolbar -->\n * <wc-toolbar>\n * <wc-icon-button variant=\"text\" color=\"surface\"><wc-icon name=\"home\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"tonal\"><wc-icon name=\"search\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\"><wc-icon name=\"favorite\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\"><wc-icon name=\"account_circle\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n *\n * @example\n * ```html\n * <!-- Floating horizontal toolbar -->\n * <wc-toolbar variant=\"floating\" orientation=\"horizontal\">\n * <wc-icon-button variant=\"tonal\"><wc-icon name=\"home\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\"><wc-icon name=\"search\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\"><wc-icon name=\"favorite\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n *\n * @example\n * ```html\n * <!-- Floating vertical toolbar -->\n * <wc-toolbar variant=\"floating\" orientation=\"vertical\">\n * <wc-icon-button variant=\"tonal\"><wc-icon name=\"home\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\"><wc-icon name=\"search\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\"><wc-icon name=\"favorite\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n * @tags display navigation\n */\n@IndividualComponent\nexport class Toolbar extends LitElement {\n static styles = [styles, colorStyles];\n\n /**\n * Visual and layout variant of the toolbar.\n * - `\"docked\"`: A full-width bar attached to the edge of the screen (default).\n * - `\"floating\"`: A detached pill-shaped toolbar that floats over content.\n */\n @property({ type: String, reflect: true })\n variant: 'docked' | 'floating' = 'docked';\n\n /**\n * Orientation of the toolbar content.\n * - `\"horizontal\"`: Items are laid out left to right (default).\n * - `\"vertical\"`: Items are stacked top to bottom. Primarily useful for the floating variant.\n */\n @property({ type: String, reflect: true })\n orientation: 'horizontal' | 'vertical' = 'horizontal';\n\n /**\n * Size of the docked toolbar.\n * - `\"sm\"`: 80dp height (default).\n * - `\"md\"`: 96dp height.\n * - `\"lg\"`: 112dp height.\n *\n * The long names `\"small\"`, `\"medium\"` and `\"large\"` still work but are deprecated.\n */\n @property({ type: String, reflect: true })\n size: Size | LegacySize = 'sm';\n\n /**\n * Whether the toolbar is visually elevated (adds a shadow).\n */\n @property({ type: Boolean, reflect: true })\n elevated: boolean = false;\n\n override render() {\n const cssClasses = {\n toolbar: true,\n [`variant-${this.variant}`]: true,\n [`orientation-${this.orientation}`]: true,\n [`size-${normalizeSize(this.size, 'sm')}`]: true,\n elevated: this.elevated,\n };\n\n if (this.variant === 'floating') {\n return Toolbar.__renderFloating(cssClasses);\n }\n\n return Toolbar.__renderDocked(cssClasses);\n }\n\n private static __renderDocked(cssClasses: Record<string, boolean>) {\n return html`\n <div class=${classMap(cssClasses)} role=\"toolbar\">\n <div class=\"background\"></div>\n <div class=\"toolbar-content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n\n private static __renderFloating(cssClasses: Record<string, boolean>) {\n return html`\n <div class=${classMap(cssClasses)} role=\"toolbar\">\n <wc-elevation class=\"elevation\"></wc-elevation>\n <div class=\"background\"></div>\n <div class=\"toolbar-content\">\n <slot></slot>\n </div>\n </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A,OAAA,CAAA,SAAA,EAAA,UAAA,EAAA,MAAA,CAAA;AAlCf,OAAO,GAAA,SAAA,GAAA,UAAA,CAAA;IADnB;AACY,CAAA,EAAA,OAAO,CA0EnB;;;;"}
1
+ {"version":3,"file":"toolbar.js","sources":["../../src/toolbar/toolbar.ts"],"sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport IndividualComponent from '@/IndividualComponent.js';\nimport styles from './toolbar.scss';\nimport colorStyles from './toolbar-colors.scss';\n\n/** Slotted elements that separate groups and never take focus. */\nconst SEPARATOR_SELECTOR = 'wc-divider, hr, [role=\"separator\"]';\n\n/**\n * @label Toolbar\n * @tag wc-toolbar\n * @rawTag toolbar\n *\n * @summary A group of related actions, such as editor formatting controls.\n * @overview\n * <p>The toolbar groups related actions into one control. The <code>floating</code> variant\n * (default) is an elevated pill that sits over content, such as a canvas or a selection. The\n * <code>flat</code> variant has no container of its own, for embedding in existing chrome like a\n * card or editor header. Both variants lay their actions out horizontally or vertically.</p>\n *\n * <p>Render actions directly as children. Use a <code>wc-divider</code> to separate groups of\n * actions; in a horizontal toolbar give it the <code>vertical</code> attribute.</p>\n *\n * <p>The toolbar follows the WAI-ARIA toolbar pattern: it is a single tab stop, and the arrow\n * keys along its orientation move focus between actions (Home and End jump to the first and last).\n * Disabled actions and dividers are skipped. Give the toolbar an <code>aria-label</code>.</p>\n *\n * @cssprop --toolbar-container-color - Background color of the toolbar.\n * @cssprop --toolbar-container-shape - Border radius of the floating toolbar.\n * @cssprop --toolbar-padding - Padding of the floating toolbar.\n * @cssprop --toolbar-gap - Gap between toolbar actions.\n * @cssprop --toolbar-icon-color - Color of icons inside the toolbar.\n * @cssprop --toolbar-content-color - Color of text inside the toolbar.\n *\n * @example\n * ```html\n * <!-- Floating toolbar -->\n * <wc-toolbar aria-label=\"Formatting\">\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Undo\"><wc-icon name=\"undo\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Redo\"><wc-icon name=\"redo\"></wc-icon></wc-icon-button>\n * <wc-divider vertical></wc-divider>\n * <wc-icon-button variant=\"tonal\" aria-label=\"Bold\"><wc-icon name=\"format_bold\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Italic\"><wc-icon name=\"format_italic\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n *\n * @example\n * ```html\n * <!-- Vertical floating toolbar -->\n * <wc-toolbar orientation=\"vertical\" aria-label=\"Tools\">\n * <wc-icon-button variant=\"tonal\" aria-label=\"Select\"><wc-icon name=\"arrow_selector_tool\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Draw\"><wc-icon name=\"draw\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Text\"><wc-icon name=\"text_fields\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n *\n * @example\n * ```html\n * <!-- Flat toolbar inside existing chrome -->\n * <wc-toolbar variant=\"flat\" aria-label=\"Row actions\">\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Edit\"><wc-icon name=\"edit\"></wc-icon></wc-icon-button>\n * <wc-icon-button variant=\"text\" color=\"surface\" aria-label=\"Delete\"><wc-icon name=\"delete\"></wc-icon></wc-icon-button>\n * </wc-toolbar>\n * ```\n * @tags display\n */\n@IndividualComponent\nexport class Toolbar extends LitElement {\n // ── Static\n static styles = [styles, colorStyles];\n\n // ── Properties\n\n /**\n * Visual variant of the toolbar.\n * - `\"floating\"`: An elevated pill that floats over content (default).\n * - `\"flat\"`: No container, fill or elevation; for embedding in existing chrome.\n */\n @property({ type: String, reflect: true })\n variant: 'floating' | 'flat' = 'floating';\n\n /**\n * Orientation of the toolbar. It sets the layout direction and the arrow keys that move focus\n * (Left/Right for horizontal, Up/Down for vertical).\n */\n @property({ type: String, reflect: true })\n orientation: 'horizontal' | 'vertical' = 'horizontal';\n\n /**\n * Raises the floating toolbar to a higher elevation. Has no effect on the flat variant.\n */\n @property({ type: Boolean, reflect: true })\n elevated: boolean = false;\n\n // ── Private fields\n\n /** The item that holds the toolbar's single tab stop. */\n private __activeItem: HTMLElement | null = null;\n\n // ── Lifecycle\n\n override connectedCallback() {\n super.connectedCallback();\n // The role lives on the host so the host's aria-label names the toolbar.\n this.setAttribute('role', 'toolbar');\n }\n\n override firstUpdated() {\n this.__syncTabStops();\n }\n\n override updated(changed: Map<string, unknown>) {\n if (changed.has('orientation')) {\n this.setAttribute('aria-orientation', this.orientation);\n }\n }\n\n // ── Private methods\n\n /** Actions that can take focus, in slot order. */\n private __getItems(): HTMLElement[] {\n const slot = this.shadowRoot?.querySelector('slot');\n if (!slot) return [];\n return slot\n .assignedElements({ flatten: true })\n .filter(\n (el): el is HTMLElement =>\n el instanceof HTMLElement &&\n !el.matches(SEPARATOR_SELECTOR) &&\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n !el.hidden,\n );\n }\n\n /** Gives the active item `tabindex=\"0\"` and every other item `tabindex=\"-1\"`. */\n private __syncTabStops() {\n const items = this.__getItems();\n if (!this.__activeItem || !items.includes(this.__activeItem)) {\n this.__activeItem = items[0] ?? null;\n }\n for (const item of items) {\n item.tabIndex = item === this.__activeItem ? 0 : -1;\n }\n }\n\n /** Makes `item` the tab stop and focuses it. */\n private __focusItem(item: HTMLElement) {\n this.__activeItem = item;\n this.__syncTabStops();\n item.focus();\n }\n\n /** Finds the toolbar item an event came from. */\n private __itemFromEvent(event: Event, items: HTMLElement[]) {\n return (\n event\n .composedPath()\n .find((node): node is HTMLElement =>\n items.includes(node as HTMLElement),\n ) ?? null\n );\n }\n\n private __handleSlotChange = () => {\n this.__syncTabStops();\n };\n\n private __handleFocusIn = (event: FocusEvent) => {\n const item = this.__itemFromEvent(event, this.__getItems());\n if (item && item !== this.__activeItem) {\n this.__activeItem = item;\n this.__syncTabStops();\n }\n };\n\n private __handleKeyDown = (event: KeyboardEvent) => {\n const items = this.__getItems();\n if (items.length === 0) return;\n\n const current = this.__itemFromEvent(event, items);\n if (!current) return;\n\n const index = items.indexOf(current);\n let nextKey = 'ArrowDown';\n let prevKey = 'ArrowUp';\n if (this.orientation === 'horizontal') {\n const rtl = getComputedStyle(this).direction === 'rtl';\n nextKey = rtl ? 'ArrowLeft' : 'ArrowRight';\n prevKey = rtl ? 'ArrowRight' : 'ArrowLeft';\n }\n\n let target: HTMLElement | undefined;\n switch (event.key) {\n case nextKey:\n target = items[(index + 1) % items.length];\n break;\n case prevKey:\n target = items[(index - 1 + items.length) % items.length];\n break;\n case 'Home':\n [target] = items;\n break;\n case 'End':\n target = items[items.length - 1];\n break;\n default:\n return;\n }\n\n event.preventDefault();\n if (target) this.__focusItem(target);\n };\n\n // ── Render\n\n override render() {\n const floating = this.variant === 'floating';\n const cssClasses = {\n toolbar: true,\n [`variant-${this.variant}`]: true,\n [`orientation-${this.orientation}`]: true,\n elevated: floating && this.elevated,\n };\n\n return html`\n <div\n class=${classMap(cssClasses)}\n @keydown=${this.__handleKeyDown}\n @focusin=${this.__handleFocusIn}\n >\n ${floating\n ? html`<wc-elevation class=\"elevation\"></wc-elevation>`\n : nothing}\n <div class=\"background\"></div>\n <div class=\"toolbar-content\">\n <slot @slotchange=${this.__handleSlotChange}></slot>\n </div>\n </div>\n `;\n }\n}\n"],"names":["LitElement","html","classMap","nothing","styles","colorStyles","property"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACA,MAAM,kBAAkB,GAAG,oCAAoC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDG;AAEI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