@redvars/peacock 4.7.0 → 4.8.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 (277) hide show
  1. package/dist/accordion-item.js +4 -4
  2. package/dist/app-bar.js +1 -1
  3. package/dist/app-shell.js +2 -2
  4. package/dist/assets/styles.css +1 -1
  5. package/dist/assets/styles.css.map +1 -1
  6. package/dist/assets/theme.d.ts +2 -0
  7. package/dist/assets/theme.js +49 -29
  8. package/dist/assets/tokens.css +1 -1
  9. package/dist/assets/tokens.css.map +1 -1
  10. package/dist/bottom-sheet.js +3 -3
  11. package/dist/breadcrumb-item.js +1 -1
  12. package/dist/button-group.js +79 -0
  13. package/dist/button-group.js.map +1 -1
  14. package/dist/button.js +26 -25
  15. package/dist/button.js.map +1 -1
  16. package/dist/calendar-column-view.js +3 -3
  17. package/dist/calendar-month-view.js +3 -3
  18. package/dist/calendar-timeline.js +3 -3
  19. package/dist/card.js +2 -1
  20. package/dist/card.js.map +1 -1
  21. package/dist/carousel.js +182 -7
  22. package/dist/carousel.js.map +1 -1
  23. package/dist/{cartesian-chart-C8qKDXo8.js → cartesian-chart-UW1CYKRS.js} +2 -2
  24. package/dist/{cartesian-chart-C8qKDXo8.js.map → cartesian-chart-UW1CYKRS.js.map} +1 -1
  25. package/dist/cb-group.js +1 -1
  26. package/dist/chart-area.js +2 -2
  27. package/dist/chart-bar.js +2 -2
  28. package/dist/{chart-base-BpQMZZsw.js → chart-base-D5ujPGcl.js} +3 -3
  29. package/dist/{chart-base-BpQMZZsw.js.map → chart-base-D5ujPGcl.js.map} +1 -1
  30. package/dist/chart-doughnut.js +1 -1
  31. package/dist/chart-line.js +2 -2
  32. package/dist/chart-pie.js +2 -2
  33. package/dist/checkbox.js +5 -5
  34. package/dist/chip.js +34 -8
  35. package/dist/chip.js.map +1 -1
  36. package/dist/circular-progress.js +46 -15
  37. package/dist/circular-progress.js.map +1 -1
  38. package/dist/code-highlighter.js +1 -1
  39. package/dist/color-picker.js +1 -1
  40. package/dist/command-palette.js +2 -2
  41. package/dist/comment-composer.js +5 -5
  42. package/dist/condition-builder.js +1 -1
  43. package/dist/{condition-group-base-NcvOY-Zv.js → condition-group-base-DS76sprm.js} +2 -2
  44. package/dist/{condition-group-base-NcvOY-Zv.js.map → condition-group-base-DS76sprm.js.map} +1 -1
  45. package/dist/confirm-dialog.js +2 -2
  46. package/dist/custom-elements-jsdocs.json +302 -10
  47. package/dist/custom-elements.json +1128 -16
  48. package/dist/dependency-map.js +2 -2
  49. package/dist/{diagram-hv7hCgzx.js → diagram-DFO-X7yq.js} +2 -2
  50. package/dist/{diagram-hv7hCgzx.js.map → diagram-DFO-X7yq.js.map} +1 -1
  51. package/dist/diagram.js +1 -1
  52. package/dist/discussion.js +3 -3
  53. package/dist/{document-editor-CZBlz3ai.js → document-editor-CSS-wACs.js} +7 -7
  54. package/dist/{document-editor-CZBlz3ai.js.map → document-editor-CSS-wACs.js.map} +1 -1
  55. package/dist/document-editor.js +3 -3
  56. package/dist/dropdown-button.js +1 -1
  57. package/dist/erd.js +4 -4
  58. package/dist/fab-menu-item.js +189 -0
  59. package/dist/fab-menu-item.js.map +1 -0
  60. package/dist/fab-menu.js +326 -0
  61. package/dist/fab-menu.js.map +1 -0
  62. package/dist/fab.js +28 -17
  63. package/dist/fab.js.map +1 -1
  64. package/dist/field.js +1 -1
  65. package/dist/file-upload.js +1 -1
  66. package/dist/flow.js +1 -1
  67. package/dist/hover-card.js +5 -3
  68. package/dist/hover-card.js.map +1 -1
  69. package/dist/html-editor.js +4 -4
  70. package/dist/icon-button.js +26 -25
  71. package/dist/icon-button.js.map +1 -1
  72. package/dist/{index-DK3fREuj.js → index-BBxpsqx8.js} +4 -4
  73. package/dist/{index-DK3fREuj.js.map → index-BBxpsqx8.js.map} +1 -1
  74. package/dist/{index-CTEt3LtO.js → index-CDtKB0In.js} +4 -4
  75. package/dist/{index-CTEt3LtO.js.map → index-CDtKB0In.js.map} +1 -1
  76. package/dist/{index-Bag4vtx-.js → index-Tb0ky27z.js} +3 -3
  77. package/dist/{index-Bag4vtx-.js.map → index-Tb0ky27z.js.map} +1 -1
  78. package/dist/index.js +15 -12
  79. package/dist/index.js.map +1 -1
  80. package/dist/{indicator-navigation-item-BG0TrdDE.js → indicator-navigation-item-aZsm-RpR.js} +17 -5
  81. package/dist/{indicator-navigation-item-BG0TrdDE.js.map → indicator-navigation-item-aZsm-RpR.js.map} +1 -1
  82. package/dist/inline-edit.js +1 -1
  83. package/dist/json-viewer.js +1 -1
  84. package/dist/linear-progress.js +51 -4
  85. package/dist/linear-progress.js.map +1 -1
  86. package/dist/link-button.js +26 -25
  87. package/dist/link-button.js.map +1 -1
  88. package/dist/loader-full.js +8 -5
  89. package/dist/loader-full.js.map +1 -1
  90. package/dist/loader.js +17 -5
  91. package/dist/loader.js.map +1 -1
  92. package/dist/loading-indicator.js +301 -0
  93. package/dist/loading-indicator.js.map +1 -0
  94. package/dist/markdown-editor.js +4 -4
  95. package/dist/mention-input.js +1 -1
  96. package/dist/menu.js +8 -6
  97. package/dist/menu.js.map +1 -1
  98. package/dist/{modal-Dds0rXAG.js → modal-ClWCCbxD.js} +7 -5
  99. package/dist/{modal-Dds0rXAG.js.map → modal-ClWCCbxD.js.map} +1 -1
  100. package/dist/modal.js +2 -2
  101. package/dist/navigation-bar-item.js +1 -1
  102. package/dist/navigation-bar.js +1 -1
  103. package/dist/navigation-drawer-group.js +1 -1
  104. package/dist/navigation-drawer.js +1 -1
  105. package/dist/navigation-rail-item.js +1 -1
  106. package/dist/navigation-rail.js +1 -1
  107. package/dist/notification-center.js +1 -1
  108. package/dist/number-counter.js +1 -1
  109. package/dist/{overlay-controller-BOk-kfil.js → overlay-controller-iVaiUqos.js} +20 -10
  110. package/dist/{overlay-controller-BOk-kfil.js.map → overlay-controller-iVaiUqos.js.map} +1 -1
  111. package/dist/pagination.js +1 -1
  112. package/dist/popover-content.js +4 -2
  113. package/dist/popover-content.js.map +1 -1
  114. package/dist/popover.js +1 -1
  115. package/dist/{progress-base-BhJK__VP.js → progress-base-BeLu9-Tq.js} +13 -1
  116. package/dist/progress-base-BeLu9-Tq.js.map +1 -0
  117. package/dist/prompt-input.js +5 -5
  118. package/dist/radio.js +3 -3
  119. package/dist/resizable-panels.js +1 -1
  120. package/dist/{rich-text-input-base-SrsPvc-j.js → rich-text-input-base-BCmnkpuV.js} +2 -2
  121. package/dist/{rich-text-input-base-SrsPvc-j.js.map → rich-text-input-base-BCmnkpuV.js.map} +1 -1
  122. package/dist/scroll-area.js +1 -1
  123. package/dist/search.js +1 -1
  124. package/dist/segmented-button.js +7 -2
  125. package/dist/segmented-button.js.map +1 -1
  126. package/dist/select.js +1 -1
  127. package/dist/side-sheet.js +3 -3
  128. package/dist/site-header.js +3 -3
  129. package/dist/site-nav-menu.js +1 -1
  130. package/dist/{slash-controller-DwL0nkqv.js → slash-controller-BFhzSjiR.js} +2 -2
  131. package/dist/{slash-controller-DwL0nkqv.js.map → slash-controller-BFhzSjiR.js.map} +1 -1
  132. package/dist/slider.js +163 -68
  133. package/dist/slider.js.map +1 -1
  134. package/dist/snackbar.js +2 -2
  135. package/dist/sparkline.js +2 -2
  136. package/dist/split-button.js +1 -1
  137. package/dist/src/button/button-group/button-group.d.ts +12 -0
  138. package/dist/src/button/fab/fab.d.ts +1 -0
  139. package/dist/src/carousel/carousel.d.ts +22 -0
  140. package/dist/src/chip/chip/chip.d.ts +4 -0
  141. package/dist/src/fab-menu/fab-menu-item.d.ts +30 -0
  142. package/dist/src/fab-menu/fab-menu.d.ts +64 -0
  143. package/dist/src/fab-menu/index.d.ts +2 -0
  144. package/dist/src/index.d.ts +3 -0
  145. package/dist/src/loading-indicator/index.d.ts +1 -0
  146. package/dist/src/loading-indicator/loading-indicator.d.ts +44 -0
  147. package/dist/src/loading-indicator/shapes.d.ts +29 -0
  148. package/dist/src/progress/circular-progress/circular-progress.d.ts +3 -1
  149. package/dist/src/progress/linear-progress/linear-progress.d.ts +2 -1
  150. package/dist/src/progress/progress-base.d.ts +7 -0
  151. package/dist/src/slider/slider.d.ts +23 -3
  152. package/dist/src/toolbar/toolbar.d.ts +20 -0
  153. package/dist/step.js +1 -1
  154. package/dist/switch.js +5 -2
  155. package/dist/switch.js.map +1 -1
  156. package/dist/tab-group.js +13 -2
  157. package/dist/tab-group.js.map +1 -1
  158. package/dist/tab-panel.js +26 -0
  159. package/dist/tab-panel.js.map +1 -1
  160. package/dist/tab.js +23 -5
  161. package/dist/tab.js.map +1 -1
  162. package/dist/table.js +4 -4
  163. package/dist/tag.js +2 -1
  164. package/dist/tag.js.map +1 -1
  165. package/dist/test/button-group-press.test.d.ts +1 -0
  166. package/dist/test/fab-menu.test.d.ts +1 -0
  167. package/dist/test/loading-indicator.test.d.ts +1 -0
  168. package/dist/toolbar.js +102 -0
  169. package/dist/toolbar.js.map +1 -1
  170. package/dist/tooltip.js +5 -2
  171. package/dist/tooltip.js.map +1 -1
  172. package/dist/tour.js +3 -3
  173. package/dist/tree-chart.js +3 -3
  174. package/dist/tree-item.js +1 -1
  175. package/dist/tsconfig.tsbuildinfo +1 -1
  176. package/dist/{video-DgtGGvrk.js → video-DSQ07o3h.js} +2 -2
  177. package/dist/{video-DgtGGvrk.js.map → video-DSQ07o3h.js.map} +1 -1
  178. package/dist/video.js +1 -1
  179. package/dist/workflow.js +5 -5
  180. package/package.json +1 -1
  181. package/scss/tokens.css +364 -0
  182. package/src/__internal/chart/chart-base.scss +4 -2
  183. package/src/__internal/controllers/overlay-controller.ts +19 -9
  184. package/src/__internal/rich-text/editor-chrome.scss +2 -1
  185. package/src/accordion/accordion-item.scss +10 -6
  186. package/src/app-bar/app-bar.scss +2 -1
  187. package/src/app-shell/app-shell.scss +2 -2
  188. package/src/bottom-sheet/bottom-sheet.scss +4 -2
  189. package/src/breadcrumb/breadcrumb-item/breadcrumb-item.scss +4 -2
  190. package/src/button/button/button-base.scss +14 -12
  191. package/src/button/button/button-layers.scss +27 -5
  192. package/src/button/button-group/button-group.scss +6 -0
  193. package/src/button/button-group/button-group.ts +105 -0
  194. package/src/button/fab/fab-sizes.scss +2 -0
  195. package/src/button/fab/fab.scss +32 -17
  196. package/src/button/fab/fab.ts +1 -0
  197. package/src/calendar/calendar-column-view.scss +3 -3
  198. package/src/calendar/calendar-month-view.scss +3 -3
  199. package/src/calendar-timeline/calendar-timeline.scss +6 -3
  200. package/src/card/card.scss +2 -1
  201. package/src/carousel/carousel.scss +71 -2
  202. package/src/carousel/carousel.ts +159 -7
  203. package/src/chart-pie/chart-pie.scss +4 -2
  204. package/src/checkbox/checkbox.scss +13 -7
  205. package/src/chip/chip/chip.scss +41 -8
  206. package/src/chip/chip/chip.ts +4 -0
  207. package/src/chip/tag/tag.scss +2 -1
  208. package/src/code-highlighter/code-highlighter.scss +2 -1
  209. package/src/color-picker/color-picker.scss +1 -1
  210. package/src/comment-composer/comment-composer.scss +2 -1
  211. package/src/components.manifest.json +21 -0
  212. package/src/condition-builder/condition-group-base.scss +1 -1
  213. package/src/dependency-map/dependency-map.scss +4 -2
  214. package/src/diagram/diagram.scss +2 -1
  215. package/src/document-editor/document-editor.scss +1 -1
  216. package/src/dropdown-button/dropdown-button.scss +2 -1
  217. package/src/erd/erd.scss +8 -4
  218. package/src/fab-menu/fab-menu-item.scss +99 -0
  219. package/src/fab-menu/fab-menu-item.ts +58 -0
  220. package/src/fab-menu/fab-menu.scss +119 -0
  221. package/src/fab-menu/fab-menu.ts +193 -0
  222. package/src/fab-menu/index.ts +2 -0
  223. package/src/field/field.scss +1 -1
  224. package/src/file-upload/file-upload.scss +2 -2
  225. package/src/hover-card/hover-card.scss +9 -2
  226. package/src/index.ts +3 -0
  227. package/src/inline-edit/inline-edit.scss +2 -2
  228. package/src/json-viewer/json-viewer.scss +2 -1
  229. package/src/loader.ts +12 -0
  230. package/src/loading-indicator/index.ts +1 -0
  231. package/src/loading-indicator/loading-indicator.scss +52 -0
  232. package/src/loading-indicator/loading-indicator.ts +164 -0
  233. package/src/loading-indicator/shapes.ts +104 -0
  234. package/src/menu/menu/menu.scss +10 -6
  235. package/src/modal/modal.scss +8 -4
  236. package/src/navigation-drawer/navigation-drawer-group.scss +2 -2
  237. package/src/navigation-drawer/navigation-drawer.scss +3 -2
  238. package/src/navigation-rail/navigation-rail-item.scss +27 -5
  239. package/src/number-counter/number-counter.scss +1 -1
  240. package/src/pagination/pagination.scss +2 -1
  241. package/src/popover/popover-content.scss +7 -2
  242. package/src/progress/circular-progress/circular-progress.scss +3 -2
  243. package/src/progress/circular-progress/circular-progress.ts +43 -12
  244. package/src/progress/linear-progress/linear-progress.scss +70 -2
  245. package/src/progress/linear-progress/linear-progress.ts +4 -1
  246. package/src/progress/progress-base.ts +11 -0
  247. package/src/prompt-input/prompt-input.scss +2 -1
  248. package/src/radio/radio.scss +8 -4
  249. package/src/resizable-panels/resizable-panels.scss +2 -1
  250. package/src/scroll-area/scroll-area.scss +2 -1
  251. package/src/search/search.scss +2 -1
  252. package/src/segmented-button/segmented-button.scss +8 -3
  253. package/src/select/select.scss +2 -1
  254. package/src/side-sheet/side-sheet.scss +4 -2
  255. package/src/site-header/site-header.scss +4 -4
  256. package/src/site-header/site-nav-menu.scss +2 -2
  257. package/src/slider/slider.scss +127 -64
  258. package/src/slider/slider.ts +74 -9
  259. package/src/snackbar/snackbar.scss +5 -2
  260. package/src/sparkline/sparkline.scss +6 -3
  261. package/src/split-button/split-button.scss +4 -2
  262. package/src/stepper/step.scss +2 -1
  263. package/src/switch/switch.scss +21 -2
  264. package/src/table/table.scss +8 -4
  265. package/src/tabs/tab-group.ts +12 -2
  266. package/src/tabs/tab-panel.scss +31 -0
  267. package/src/tabs/tab.scss +28 -17
  268. package/src/toolbar/toolbar-colors.scss +11 -0
  269. package/src/toolbar/toolbar.scss +28 -0
  270. package/src/toolbar/toolbar.ts +74 -1
  271. package/src/tooltip/tooltip.scss +9 -3
  272. package/src/tour/tour.scss +2 -2
  273. package/src/tree/tree-item.scss +2 -1
  274. package/src/tree-chart/tree-chart.scss +3 -3
  275. package/src/video/video.scss +2 -1
  276. package/src/workflow/workflow.scss +5 -5
  277. package/dist/progress-base-BhJK__VP.js.map +0 -1
@@ -0,0 +1,52 @@
1
+ @use '../../scss/mixin';
2
+
3
+ @include mixin.base-styles;
4
+
5
+ :host {
6
+ display: inline-block;
7
+ vertical-align: middle;
8
+ --loading-indicator-size: 3rem;
9
+ }
10
+
11
+ .loading-indicator {
12
+ display: block;
13
+ width: var(--loading-indicator-size);
14
+ height: var(--loading-indicator-size);
15
+ border-radius: var(--shape-corner-full);
16
+ --_color: var(--loading-indicator-color, var(--color-primary));
17
+
18
+ &.contained {
19
+ background: var(
20
+ --loading-indicator-container-color,
21
+ var(--color-primary-container)
22
+ );
23
+ --_color: var(
24
+ --loading-indicator-color,
25
+ var(--color-on-primary-container)
26
+ );
27
+
28
+ // Keep some room between the shape and the container's edge.
29
+ svg {
30
+ scale: 0.84;
31
+ }
32
+ }
33
+
34
+ svg {
35
+ display: block;
36
+ width: 100%;
37
+ height: 100%;
38
+ overflow: visible;
39
+ }
40
+
41
+ .shape {
42
+ fill: var(--_color);
43
+ transform-origin: 50% 50%;
44
+ transform-box: view-box;
45
+ }
46
+ }
47
+
48
+ @media (forced-colors: active) {
49
+ .loading-indicator .shape {
50
+ fill: CanvasText;
51
+ }
52
+ }
@@ -0,0 +1,164 @@
1
+ import { html, LitElement } from 'lit';
2
+ import { property, query } from 'lit/decorators.js';
3
+ import { classMap } from 'lit/directives/class-map.js';
4
+ import styles from './loading-indicator.scss';
5
+ import { I18nController } from '@/__internal/i18n/i18n-controller.js';
6
+ import { mixinDelegatesAria } from '@/__internal/aria/delegate.js';
7
+ import type { ARIAMixinStrict } from '@/__internal/aria/aria.js';
8
+ import {
9
+ blendPath,
10
+ PAIR_OFFSETS,
11
+ SHAPE_POINTS,
12
+ SHAPE_RADII,
13
+ } from './shapes.js';
14
+
15
+ // One shape change every STEP_MS. Each morph eases in and out over the whole step, so the shape
16
+ // never snaps and never stops.
17
+ const STEP_MS = 650;
18
+ // A steady turn carries the motion; each morph adds a little more, eased like the morph, so the
19
+ // speed swells gently instead of jerking forward on every step.
20
+ const BASE_DEG_PER_S = 150;
21
+ const STEP_TURN_DEG = 45;
22
+
23
+ /** Ease in and out over 0..1, with zero speed at both ends. */
24
+ const easeInOut = (t: number) => 0.5 - 0.5 * Math.cos(Math.PI * t);
25
+
26
+ const DEG_PER_SAMPLE = 360 / SHAPE_POINTS;
27
+ const CYCLE_OFFSET = PAIR_OFFSETS.reduce((sum, k) => sum + k, 0);
28
+
29
+ /**
30
+ * Degrees to turn the drawing by at the start of `step`: the morphs before it each ended on the
31
+ * next shape turned back by its pair offset, and this keeps the next morph starting from there.
32
+ */
33
+ function offsetTurn(step: number): number {
34
+ const count = PAIR_OFFSETS.length;
35
+ let samples = Math.floor(step / count) * CYCLE_OFFSET;
36
+ for (let i = 0; i < step % count; i += 1) samples += PAIR_OFFSETS[i];
37
+ return -samples * DEG_PER_SAMPLE;
38
+ }
39
+
40
+ const VIEWBOX = 100;
41
+ const CENTER = VIEWBOX / 2;
42
+ // The shape fills about 38/48 of the box, as in M3.
43
+ const SHAPE_RADIUS = VIEWBOX * 0.395;
44
+
45
+ // Reduced motion keeps the morph, since the changing shape is what says "still loading", but
46
+ // slower and with a slow steady turn instead of the swelling spin.
47
+ const REDUCED_STEP_MS = 1200;
48
+ const REDUCED_DEG_PER_S = 30;
49
+
50
+ const REDUCED_MOTION =
51
+ typeof window !== 'undefined' && window.matchMedia
52
+ ? window.matchMedia('(prefers-reduced-motion: reduce)')
53
+ : undefined;
54
+
55
+ /**
56
+ * @label Loading Indicator
57
+ * @tag wc-loading-indicator
58
+ * @rawTag loading-indicator
59
+ * @summary An expressive spinner that morphs between rounded shapes while it turns, for short waits of unknown length.
60
+ * @overview
61
+ * <p>Use it for waits of a few seconds whose length is unknown, such as loading a page or
62
+ * refreshing content. For longer work, or when progress is known, use
63
+ * <code>wc-circular-progress</code> or <code>wc-linear-progress</code>.</p>
64
+ * <p><code>contained</code> draws it on a round container, for use over content such as
65
+ * pull-to-refresh. Set the size with <code>--loading-indicator-size</code> (48px by default).</p>
66
+ * <p>It is named "Loading" unless an <code>aria-label</code> on the element names it. With
67
+ * reduced motion it morphs more slowly and turns at a slow, steady speed.</p>
68
+ * @tags display
69
+ *
70
+ * @cssprop --loading-indicator-size - Width and height. Defaults to 3rem.
71
+ * @cssprop --loading-indicator-color - Shape color. Defaults to var(--color-primary), or var(--color-on-primary-container) when contained.
72
+ * @cssprop --loading-indicator-container-color - Container color when `contained`. Defaults to var(--color-primary-container).
73
+ *
74
+ * @example
75
+ * ```html
76
+ * <wc-loading-indicator></wc-loading-indicator>
77
+ * <wc-loading-indicator contained></wc-loading-indicator>
78
+ * ```
79
+ */
80
+ export class LoadingIndicator extends mixinDelegatesAria(LitElement) {
81
+ static styles = [styles];
82
+
83
+ /** Draws the indicator on a round container. */
84
+ @property({ type: Boolean, reflect: true }) contained = false;
85
+
86
+ @query('.shape') private _shape?: SVGPathElement;
87
+
88
+ private readonly _i18n = new I18nController(this);
89
+
90
+ private _frame = 0;
91
+
92
+ private _start = 0;
93
+
94
+ override connectedCallback() {
95
+ super.connectedCallback();
96
+ this._start = performance.now();
97
+ this._frame = requestAnimationFrame(this._tick);
98
+ }
99
+
100
+ override disconnectedCallback() {
101
+ super.disconnectedCallback();
102
+ cancelAnimationFrame(this._frame);
103
+ }
104
+
105
+ private _tick = (now: number) => {
106
+ this._draw(now - this._start);
107
+ this._frame = requestAnimationFrame(this._tick);
108
+ };
109
+
110
+ /** Draws the frame `elapsed` ms after the indicator appeared. */
111
+ private _draw(sinceStart: number) {
112
+ // A frame's timestamp can be a little older than the moment the indicator connected.
113
+ const elapsed = Math.max(0, sinceStart);
114
+ const shape = this._shape;
115
+ if (!shape) return;
116
+
117
+ const reduced = REDUCED_MOTION?.matches ?? false;
118
+ const stepMs = reduced ? REDUCED_STEP_MS : STEP_MS;
119
+ const count = SHAPE_RADII.length;
120
+ const step = Math.floor(elapsed / stepMs);
121
+ const from = SHAPE_RADII[step % count];
122
+ const to = SHAPE_RADII[(step + 1) % count];
123
+ const progress = easeInOut((elapsed - step * stepMs) / stepMs);
124
+
125
+ shape.setAttribute(
126
+ 'd',
127
+ blendPath(
128
+ from,
129
+ to,
130
+ progress,
131
+ SHAPE_RADIUS,
132
+ CENTER,
133
+ PAIR_OFFSETS[step % count],
134
+ ),
135
+ );
136
+ const base = reduced
137
+ ? (elapsed / 1000) * REDUCED_DEG_PER_S
138
+ : (elapsed / 1000) * BASE_DEG_PER_S + (step + progress) * STEP_TURN_DEG;
139
+ const turn = base + offsetTurn(step);
140
+ shape.style.transform = `rotate(${((turn % 360) + 360) % 360}deg)`;
141
+ }
142
+
143
+ override firstUpdated() {
144
+ this._draw(performance.now() - this._start);
145
+ }
146
+
147
+ override render() {
148
+ return html`
149
+ <div
150
+ class=${classMap({
151
+ 'loading-indicator': true,
152
+ contained: this.contained,
153
+ })}
154
+ role="progressbar"
155
+ aria-label=${(this as ARIAMixinStrict).ariaLabel ||
156
+ this._i18n.t('loading')}
157
+ >
158
+ <svg viewBox="0 0 ${VIEWBOX} ${VIEWBOX}" aria-hidden="true">
159
+ <path class="shape"></path>
160
+ </svg>
161
+ </div>
162
+ `;
163
+ }
164
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The shapes wc-loading-indicator morphs through, after the M3 Expressive loading indicator:
3
+ * soft burst, 9-sided cookie, pentagon, pill, sunny, 4-sided cookie and oval.
4
+ *
5
+ * Every shape is a polar function sampled at the same angles, so morphing is a per-point blend
6
+ * of radii. Radii are normalised so each shape's furthest point is 1.
7
+ */
8
+
9
+ /** Points per shape. Enough to look smooth at large sizes, cheap enough to blend every frame. */
10
+ export const SHAPE_POINTS = 180;
11
+
12
+ type PolarShape = (theta: number) => number;
13
+
14
+ const wavy =
15
+ (lobes: number, depth: number): PolarShape =>
16
+ theta =>
17
+ 1 + depth * Math.cos(lobes * theta);
18
+
19
+ const superellipse =
20
+ (ry: number, power: number, rotate = 0): PolarShape =>
21
+ theta => {
22
+ const t = theta + rotate;
23
+ const c = Math.abs(Math.cos(t)) ** power;
24
+ const s = Math.abs(Math.sin(t) / ry) ** power;
25
+ return (c + s) ** (-1 / power);
26
+ };
27
+
28
+ const SHAPES: PolarShape[] = [
29
+ wavy(10, 0.12), // soft burst
30
+ wavy(9, 0.07), // 9-sided cookie
31
+ wavy(5, 0.14), // pentagon
32
+ superellipse(0.62, 4, Math.PI / 4), // pill, on the diagonal
33
+ wavy(8, 0.05), // sunny
34
+ wavy(4, 0.1), // 4-sided cookie
35
+ superellipse(0.78, 2, -Math.PI / 4), // oval
36
+ ];
37
+
38
+ function sample(shape: PolarShape): Float32Array {
39
+ const radii = new Float32Array(SHAPE_POINTS);
40
+ for (let i = 0; i < SHAPE_POINTS; i += 1) {
41
+ radii[i] = shape((i / SHAPE_POINTS) * Math.PI * 2);
42
+ }
43
+ const max = Math.max(...radii);
44
+ return radii.map(r => r / max);
45
+ }
46
+
47
+ /** Every shape as normalised radii, in the order they morph. */
48
+ export const SHAPE_RADII: readonly Float32Array[] = SHAPES.map(sample);
49
+
50
+ /**
51
+ * For each shape, the turn (in samples) that best lines the next shape up with it, so matching
52
+ * lobes travel the shortest way during the morph. `PAIR_OFFSETS[i]` is for shape i to shape i + 1.
53
+ */
54
+ export const PAIR_OFFSETS: readonly number[] = SHAPE_RADII.map((from, i) => {
55
+ const to = SHAPE_RADII[(i + 1) % SHAPE_RADII.length];
56
+ let best = 0;
57
+ let bestError = Infinity;
58
+ for (let k = 0; k < SHAPE_POINTS; k += 1) {
59
+ let error = 0;
60
+ for (let j = 0; j < SHAPE_POINTS; j += 1) {
61
+ const d = from[j] - to[(j + k) % SHAPE_POINTS];
62
+ error += d * d;
63
+ }
64
+ if (error < bestError) {
65
+ bestError = error;
66
+ best = k;
67
+ }
68
+ }
69
+ // The shorter way round.
70
+ return best > SHAPE_POINTS / 2 ? best - SHAPE_POINTS : best;
71
+ });
72
+
73
+ /**
74
+ * An SVG path for a shape on its way from `from` to `to`: a per-point blend of radii, so the
75
+ * outline stays a recognisable shape the whole way through.
76
+ *
77
+ * @param from Radii of the shape being left.
78
+ * @param to Radii of the shape being reached.
79
+ * @param progress 0 at `from`, 1 at `to`.
80
+ * @param size Radius in viewBox units of a point whose normalised radius is 1.
81
+ * @param center Centre of the shape in viewBox units.
82
+ * @param offset Samples to turn `to` by before blending (see PAIR_OFFSETS). At 1 the path is
83
+ * `to` turned back by `offset` samples, which the caller makes up with its rotation.
84
+ */
85
+ export function blendPath(
86
+ from: Float32Array,
87
+ to: Float32Array,
88
+ progress: number,
89
+ size: number,
90
+ center: number,
91
+ offset = 0,
92
+ ): string {
93
+ let d = '';
94
+ for (let i = 0; i < SHAPE_POINTS; i += 1) {
95
+ const target =
96
+ to[(((i + offset) % SHAPE_POINTS) + SHAPE_POINTS) % SHAPE_POINTS];
97
+ const r = (from[i] + (target - from[i]) * progress) * size;
98
+ const theta = (i / SHAPE_POINTS) * Math.PI * 2;
99
+ const x = (center + r * Math.cos(theta)).toFixed(2);
100
+ const y = (center + r * Math.sin(theta)).toFixed(2);
101
+ d += `${i === 0 ? 'M' : 'L'}${x} ${y}`;
102
+ }
103
+ return `${d}Z`;
104
+ }
@@ -54,10 +54,14 @@
54
54
  );
55
55
  transform-origin: top center;
56
56
 
57
- --_menu-enter-duration: var(--duration-medium1);
58
- --_menu-exit-duration: var(--duration-short4);
59
- --_menu-enter-easing: var(--easing-emphasized-decelerate);
60
- --_menu-exit-easing: var(--easing-standard);
57
+ // M3 Expressive: the menu grows open on the default spatial spring and fades away on the
58
+ // effects spring, which never overshoots. Lists follow `transition-property`.
59
+ --_menu-enter-duration: var(--motion-spring-fast-effects-duration),
60
+ var(--motion-spring-default-spatial-duration);
61
+ --_menu-exit-duration: var(--motion-spring-fast-effects-duration);
62
+ --_menu-enter-easing: var(--motion-spring-fast-effects-easing),
63
+ var(--motion-spring-default-spatial-easing);
64
+ --_menu-exit-easing: var(--motion-spring-fast-effects-easing);
61
65
 
62
66
  transition-property: opacity, transform;
63
67
  transition-duration: var(--_menu-exit-duration);
@@ -66,7 +70,7 @@
66
70
  &.closed {
67
71
  opacity: 0;
68
72
  pointer-events: none;
69
- transform: translateY(-4px) scale(0.97);
73
+ transform: translateY(-4px) scale(0.92);
70
74
  }
71
75
 
72
76
  &.open {
@@ -77,7 +81,7 @@
77
81
 
78
82
  @starting-style {
79
83
  opacity: 0;
80
- transform: translateY(-4px) scale(0.97);
84
+ transform: translateY(-4px) scale(0.92);
81
85
  }
82
86
  }
83
87
 
@@ -11,8 +11,12 @@
11
11
  --modal-min-width: 280px;
12
12
  --modal-max-width: 560px;
13
13
  --modal-max-height: 90dvh;
14
- --modal-transition-duration: var(--duration-medium2);
15
- --modal-transition-easing: var(--easing-emphasized);
14
+ // M3 Expressive: the dialog grows in on the default spatial spring; the scrim and the exit use
15
+ // the effects spring, which never overshoots.
16
+ --modal-transition-duration: var(--motion-spring-default-spatial-duration);
17
+ --modal-transition-easing: var(--motion-spring-default-spatial-easing);
18
+ --_modal-fade-duration: var(--motion-spring-default-effects-duration);
19
+ --_modal-fade-easing: var(--motion-spring-default-effects-easing);
16
20
  --modal-heading-color: var(--color-on-surface);
17
21
  --modal-subheading-color: var(--color-on-surface-variant);
18
22
  --modal-content-color: var(--color-on-surface-variant);
@@ -50,7 +54,7 @@
50
54
  inset: 0;
51
55
  opacity: 0;
52
56
  position: absolute;
53
- transition: opacity var(--modal-transition-duration) var(--modal-transition-easing);
57
+ transition: opacity var(--_modal-fade-duration) var(--_modal-fade-easing);
54
58
  }
55
59
 
56
60
  .scrim.visible {
@@ -93,7 +97,7 @@
93
97
  }
94
98
 
95
99
  &:not(.open) {
96
- animation: modal-exit var(--modal-transition-duration) var(--modal-transition-easing) forwards;
100
+ animation: modal-exit var(--_modal-fade-duration) var(--_modal-fade-easing) forwards;
97
101
  }
98
102
  }
99
103
 
@@ -61,8 +61,8 @@
61
61
  }
62
62
 
63
63
  .expand-icon {
64
- transition: transform var(--duration-short4, 200ms)
65
- var(--easing-standard, ease);
64
+ transition: transform var(--motion-spring-fast-spatial-duration)
65
+ var(--motion-spring-fast-spatial-easing);
66
66
  }
67
67
 
68
68
  &.expanded .expand-icon {
@@ -49,8 +49,9 @@
49
49
  overflow-y: auto;
50
50
 
51
51
  &[open] {
52
- animation: slide-in var(--duration-medium2, 300ms)
53
- var(--easing-emphasized-decelerate, ease-out);
52
+ // Critically damped, like the sheets: an overshoot would open a gap at the edge.
53
+ animation: slide-in var(--motion-spring-slow-effects-duration, 300ms)
54
+ var(--motion-spring-slow-effects-easing, ease-out);
54
55
  }
55
56
 
56
57
  &::backdrop {
@@ -77,8 +77,24 @@
77
77
  border-radius: var(--_indicator-shape);
78
78
  overflow: hidden;
79
79
  flex-shrink: 0;
80
- transition: background-color var(--duration-short4, 200ms)
81
- var(--easing-standard, ease);
80
+
81
+ // The pill grows out from the centre on the default spatial spring when
82
+ // the item becomes current.
83
+ &::before {
84
+ content: '';
85
+ position: absolute;
86
+ inset: 0;
87
+ z-index: 0;
88
+ border-radius: inherit;
89
+ background-color: var(--_indicator-color);
90
+ opacity: 0;
91
+ transform: scaleX(0.32);
92
+ transition:
93
+ transform var(--motion-spring-default-spatial-duration)
94
+ var(--motion-spring-default-spatial-easing),
95
+ opacity var(--motion-spring-fast-effects-duration)
96
+ var(--motion-spring-fast-effects-easing);
97
+ }
82
98
 
83
99
  .ripple {
84
100
  inset: 0;
@@ -133,8 +149,10 @@
133
149
  pointer-events: none;
134
150
  z-index: 1;
135
151
  transition:
136
- color var(--duration-short4, 200ms) var(--easing-standard, ease),
137
- font-weight var(--duration-short4, 200ms) var(--easing-standard, ease);
152
+ color var(--motion-spring-fast-effects-duration)
153
+ var(--motion-spring-fast-effects-easing),
154
+ font-weight var(--motion-spring-fast-effects-duration)
155
+ var(--motion-spring-fast-effects-easing);
138
156
  }
139
157
 
140
158
  /* Hide label when collapsed via class */
@@ -166,7 +184,10 @@
166
184
  --_state-color: var(--_active-icon-color);
167
185
 
168
186
  .indicator {
169
- background-color: var(--_indicator-color);
187
+ &::before {
188
+ opacity: 1;
189
+ transform: scaleX(1);
190
+ }
170
191
 
171
192
  .icon-container {
172
193
  ::slotted(*) {
@@ -221,6 +242,7 @@
221
242
  @media (prefers-reduced-motion: reduce) {
222
243
  .item {
223
244
  .indicator,
245
+ .indicator::before,
224
246
  .label {
225
247
  transition: none;
226
248
  }
@@ -21,7 +21,7 @@
21
21
  .digit-content {
22
22
  display: flex;
23
23
  flex-direction: column;
24
- transition: transform var(--duration-long1) var(--easing-standard);
24
+ transition: transform var(--motion-spring-default-spatial-duration) var(--motion-spring-default-spatial-easing);
25
25
  }
26
26
 
27
27
  .each-digit, .digit-separator {
@@ -77,7 +77,8 @@
77
77
  color: var(--color-on-surface-variant);
78
78
  font-variant-numeric: tabular-nums;
79
79
  cursor: pointer;
80
- transition: background-color var(--duration-short2, 100ms) ease;
80
+ transition: background-color var(--motion-spring-fast-effects-duration)
81
+ var(--motion-spring-fast-effects-easing);
81
82
 
82
83
  &:hover {
83
84
  background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
@@ -19,8 +19,8 @@
19
19
  left: 0;
20
20
  z-index: var(--z-index-popover, 1000);
21
21
 
22
- --_popover-duration: var(--duration-short2, 0.1s);
23
- --_popover-easing: var(--easing-standard, ease-in-out);
22
+ --_popover-duration: var(--motion-spring-fast-effects-duration, 0.1s);
23
+ --_popover-easing: var(--motion-spring-fast-effects-easing, ease-in-out);
24
24
 
25
25
  /* Keep the panel in the top layer while it fades out. */
26
26
  transition:
@@ -71,6 +71,11 @@
71
71
  :host([open]:not([popover])) .popover-content {
72
72
  transform: none;
73
73
  opacity: 1;
74
+ // M3 Expressive: it grows open on the default spatial spring and fades out without overshoot.
75
+ transition-duration: var(--motion-spring-default-spatial-duration, 0.1s),
76
+ var(--_popover-duration);
77
+ transition-timing-function: var(--motion-spring-default-spatial-easing, ease-out),
78
+ var(--_popover-easing);
74
79
 
75
80
  @starting-style {
76
81
  transform: scale(0.9);
@@ -37,10 +37,11 @@
37
37
  height: 100%;
38
38
  }
39
39
 
40
- circle {
40
+ circle,
41
+ path {
41
42
  fill: none;
42
43
  stroke-linecap: round;
43
- transition: stroke-dashoffset var(--duration-medium2) var(--easing-standard);
44
+ transition: stroke-dashoffset var(--motion-spring-default-effects-duration) var(--motion-spring-default-effects-easing);
44
45
  }
45
46
 
46
47
  .track {
@@ -1,9 +1,29 @@
1
- import { html, nothing } from 'lit';
1
+ import { html, nothing, svg } from 'lit';
2
2
  import { classMap } from 'lit/directives/class-map.js';
3
3
  import { styleMap } from 'lit/directives/style-map.js';
4
4
  import styles from './circular-progress.scss';
5
5
  import { ProgressBase } from '../progress-base.js';
6
6
 
7
+ /**
8
+ * The ring for `wavy`: radius 6 around (8, 8), rippling by WAVE_AMPLITUDE with WAVE_COUNT waves.
9
+ * Its `pathLength` is set to the plain circle's circumference, so the dash maths (and the
10
+ * indeterminate keyframes) are the same for both.
11
+ */
12
+ const WAVE_COUNT = 8;
13
+ const WAVE_AMPLITUDE = 0.4;
14
+ const WAVY_RING = (() => {
15
+ const points = 240;
16
+ let d = '';
17
+ for (let i = 0; i <= points; i += 1) {
18
+ const theta = (i / points) * Math.PI * 2;
19
+ const r = 6 + WAVE_AMPLITUDE * Math.sin(WAVE_COUNT * theta);
20
+ const x = (8 + r * Math.cos(theta)).toFixed(3);
21
+ const y = (8 + r * Math.sin(theta)).toFixed(3);
22
+ d += `${i === 0 ? 'M' : 'L'}${x} ${y}`;
23
+ }
24
+ return d;
25
+ })();
26
+
7
27
  /**
8
28
  * @label Circular Progress
9
29
  * @tag wc-circular-progress
@@ -14,7 +34,9 @@ import { ProgressBase } from '../progress-base.js';
14
34
  * range. The visible <code>label</code> names the indicator through
15
35
  * <code>aria-labelledby</code>; without one, an <code>aria-label</code> on the element names it,
16
36
  * else it is named "Loading". With
17
- * <code>indeterminate</code> it spins, for a wait of unknown length.</p>
37
+ * <code>indeterminate</code> it spins, for a wait of unknown length. <code>wavy</code> draws the
38
+ * indicator as a rippling ring, the M3 Expressive style; for short waits also consider
39
+ * <code>wc-loading-indicator</code>.</p>
18
40
  * @tags display
19
41
  *
20
42
  * @example
@@ -32,6 +54,10 @@ export class CircularProgress extends ProgressBase {
32
54
  const radius = 6;
33
55
  const circumference = 2 * Math.PI * radius;
34
56
  const offset = circumference - (percentage / 100) * circumference;
57
+ const indicatorStyle = {
58
+ strokeDasharray: `${circumference}`,
59
+ strokeDashoffset: this.indeterminate ? undefined : `${offset}`,
60
+ };
35
61
 
36
62
  return html`
37
63
  <div
@@ -39,6 +65,7 @@ export class CircularProgress extends ProgressBase {
39
65
  'circular-progress': true,
40
66
  indeterminate: this.indeterminate,
41
67
  inline: this.inline,
68
+ wavy: this.wavy,
42
69
  })}"
43
70
  role="progressbar"
44
71
  aria-labelledby=${this.label ? 'label' : nothing}
@@ -52,16 +79,20 @@ export class CircularProgress extends ProgressBase {
52
79
  <div class="circular-progress-container">
53
80
  <svg viewBox="0 0 16 16">
54
81
  <circle class="track" cx="8" cy="8" r="6"></circle>
55
- <circle
56
- class="active-indicator"
57
- cx="8"
58
- cy="8"
59
- r="6"
60
- style="${styleMap({
61
- strokeDasharray: `${circumference}`,
62
- strokeDashoffset: this.indeterminate ? undefined : `${offset}`,
63
- })}"
64
- ></circle>
82
+ ${this.wavy && !this.__complete
83
+ ? svg`<path
84
+ class="active-indicator"
85
+ d=${WAVY_RING}
86
+ pathLength=${circumference}
87
+ style="${styleMap(indicatorStyle)}"
88
+ ></path>`
89
+ : svg`<circle
90
+ class="active-indicator"
91
+ cx="8"
92
+ cy="8"
93
+ r="6"
94
+ style="${styleMap(indicatorStyle)}"
95
+ ></circle>`}
65
96
  </svg>
66
97
  </div>
67
98