@momentum-design/components 0.51.3 → 0.52.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.
@@ -16,6 +16,10 @@ declare const AvatarButton_base: import("../../utils/mixins/index.types").Constr
16
16
  * @event focus - (React: onFocus) This event is dispatched when the avatarbutton receives focus.
17
17
  *
18
18
  * @tagname mdc-avatarbutton
19
+ *
20
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-rest - Background color of the overlay in rest state
21
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-hover - Background color of the overlay in hover state
22
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-active - Background color of the overlay in active state
19
23
  */
20
24
  declare class AvatarButton extends AvatarButton_base {
21
25
  /**
@@ -30,6 +30,10 @@ import styles from './avatarbutton.styles';
30
30
  * @event focus - (React: onFocus) This event is dispatched when the avatarbutton receives focus.
31
31
  *
32
32
  * @tagname mdc-avatarbutton
33
+ *
34
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-rest - Background color of the overlay in rest state
35
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-hover - Background color of the overlay in hover state
36
+ * @cssproperty --mdc-avatarbutton-overlay-background-color-active - Background color of the overlay in active state
33
37
  */
34
38
  class AvatarButton extends AvatarComponentMixin(IconNameMixin(Buttonsimple)) {
35
39
  constructor() {
@@ -58,8 +62,8 @@ class AvatarButton extends AvatarComponentMixin(IconNameMixin(Buttonsimple)) {
58
62
  }
59
63
  render() {
60
64
  return html `
65
+ <div part="overlay" aria-hidden="true"></div>
61
66
  <mdc-avatar
62
- slot="prefixIcon"
63
67
  ?is-typing="${this.isTyping}"
64
68
  counter="${ifDefined(this.counter)}"
65
69
  icon-name="${ifDefined(this.iconName)}"
@@ -2,10 +2,32 @@ import { css } from 'lit';
2
2
  import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
3
3
  const styles = [hostFitContentStyles, css `
4
4
  :host {
5
+ --mdc-avatarbutton-overlay-background-color-rest: var(--mds-color-theme-avatar-ghost);
6
+ --mdc-avatarbutton-overlay-background-color-hover: var(--mds-color-theme-avatar-hover);
7
+ --mdc-avatarbutton-overlay-background-color-active: var(--mds-color-theme-avatar-pressed);
5
8
  padding: unset;
6
9
  margin: unset;
7
10
  outline: none;
8
11
  border-radius: 0.25rem;
12
+ position: relative;
13
+ cursor: pointer;
14
+ }
15
+ :host::part(overlay) {
16
+ position: absolute;
17
+ border-radius: 100vh;
18
+ height: 100%;
19
+ width: 100%;
20
+ z-index: 1;
21
+ background-color: var(--mdc-avatarbutton-overlay-background-color-rest);
22
+ }
23
+ :host(:not([is-typing]):hover)::part(overlay) {
24
+ background-color: var(--mdc-avatarbutton-overlay-background-color-hover);
25
+ }
26
+ :host(:not([is-typing]):active)::part(overlay) {
27
+ background-color: var(--mdc-avatarbutton-overlay-background-color-active);
28
+ }
29
+ :host::part(presence) {
30
+ z-index: 2;
9
31
  }
10
32
  `, ...hostFocusRingStyles()];
11
33
  export default styles;
@@ -57,7 +57,7 @@ declare class Progressbar extends Progressbar_base {
57
57
  * @returns The clamped value
58
58
  * @internal
59
59
  */
60
- private get clampedValue();
60
+ protected get clampedValue(): number;
61
61
  /**
62
62
  * Determines the validation state (success, error, or default) based on progress value and error state.
63
63
  * @returns The appropriate validation state for the progressbar.
@@ -0,0 +1,8 @@
1
+ import Progressspinner from './progressspinner.component';
2
+ import '../icon';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ ['mdc-progressspinner']: Progressspinner;
6
+ }
7
+ }
8
+ export default Progressspinner;
@@ -0,0 +1,5 @@
1
+ import Progressspinner from './progressspinner.component';
2
+ import { TAG_NAME } from './progressspinner.constants';
3
+ import '../icon';
4
+ Progressspinner.register(TAG_NAME);
5
+ export default Progressspinner;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Calculates the progress arc length based on the percentage.
3
+ *
4
+ * The arc length is calculated using the formula:
5
+ * Arc Length = (Percentage / 100) * Circumference - Gap Size
6
+ *
7
+ * Example:
8
+ * If the circumference is 100 and the percentage is 25,
9
+ * and there is no gap, then the progress would cover the first quarter of the circle.
10
+ *
11
+ * However, with a gap, the progress arc starts after a gap of gapSize / 2 at the top (12 o'clock),
12
+ * and ends before the quarter by another gapSize / 2 (just before 3 o'clock).
13
+ *
14
+ * Therefore, the total arc length becomes:
15
+ * 25% of 100 = 25
16
+ * Subtract the two half-gaps: 25 - (2 * (gapSize / 2)) = 25 - gapSize
17
+ *
18
+ * For example, if gapSize is 4:
19
+ * Final arc length = 25 - 4 = 21
20
+ *
21
+ * This adjustment ensures the visual gaps are maintained between the progress and the remaining track.
22
+ *
23
+ * @param percentage - The percentage value (0 to 100)
24
+ * @returns The progress arc length
25
+ */
26
+ declare const getProgressArc: (percentage: number) => number;
27
+ /**
28
+ * Calculates the remaining arc length based on the percentage.
29
+ *
30
+ * The remaining arc is calculated using the formula:
31
+ * Remaining Arc = Circumference - Progress Arc - 2 * Gap Size
32
+ *
33
+ * Example:
34
+ * If the total circumference is 100, the progress arc is 50, and each gap is 2 units,
35
+ * then with two gaps (one before and one after the progress arc), the calculation becomes:
36
+ * Remaining Arc = 100 - 50 - (2 * 2) = 46
37
+ *
38
+ * This ensures the gap between the progress and remaining arcs is visually preserved.
39
+ *
40
+ * @param percentage - The percentage value (0 to 100)
41
+ * @returns The remaining arc length
42
+ */
43
+ declare const getRemainingArc: (percentage: number) => number;
44
+ /**
45
+ * Calculates the offset for the progress arc based on the percentage.
46
+ *
47
+ * The offset is adjusted to maintain a visual gap between the progress and track arcs.
48
+ * The progress arc begins slightly ahead of the 12 o’clock position, by half the gap size to account for spacing.
49
+ *
50
+ * @param percentage - The percentage value (0 to 100)
51
+ * @returns The offset for the progress arc
52
+ */
53
+ declare const getProgressOffset: (percentage: number) => number;
54
+ /**
55
+ * Calculates the remaining offset for the remaining arc based on the percentage and progress arc.
56
+ *
57
+ * Adjusts the offset to maintain a consistent visual gap between the progress and track arcs.
58
+ * The remaining arc begins where the progress arc ends, we have to consider the gap before progress arc(12'o clock)
59
+ * i.e. half the gap size, plus an additional gap between the two arcs.
60
+ *
61
+ * @param percentage - The percentage value (0 to 100)
62
+ * @param progressArc - The length of the progress arc
63
+ * @returns The remaining offset for the remaining arc
64
+ */
65
+ declare const getRemainingOffset: (percentage: number, progressArc: number) => number;
66
+ export { getProgressArc, getRemainingArc, getProgressOffset, getRemainingOffset };
@@ -0,0 +1,102 @@
1
+ import { DEFAULTS } from './progressspinner.constants';
2
+ /**
3
+ * Calculates the progress arc length based on the percentage.
4
+ *
5
+ * The arc length is calculated using the formula:
6
+ * Arc Length = (Percentage / 100) * Circumference - Gap Size
7
+ *
8
+ * Example:
9
+ * If the circumference is 100 and the percentage is 25,
10
+ * and there is no gap, then the progress would cover the first quarter of the circle.
11
+ *
12
+ * However, with a gap, the progress arc starts after a gap of gapSize / 2 at the top (12 o'clock),
13
+ * and ends before the quarter by another gapSize / 2 (just before 3 o'clock).
14
+ *
15
+ * Therefore, the total arc length becomes:
16
+ * 25% of 100 = 25
17
+ * Subtract the two half-gaps: 25 - (2 * (gapSize / 2)) = 25 - gapSize
18
+ *
19
+ * For example, if gapSize is 4:
20
+ * Final arc length = 25 - 4 = 21
21
+ *
22
+ * This adjustment ensures the visual gaps are maintained between the progress and the remaining track.
23
+ *
24
+ * @param percentage - The percentage value (0 to 100)
25
+ * @returns The progress arc length
26
+ */
27
+ const getProgressArc = (percentage) => {
28
+ if (percentage === 0) {
29
+ return 0;
30
+ }
31
+ const progressArc = (percentage / 100) * DEFAULTS.CIRCUMFERENCE - DEFAULTS.GAP_SIZE;
32
+ /** Ensure the progress arc is not negative due to gap size
33
+ * The 0.1% is a minimum threshold to ensure the arc is visible.
34
+ * This is especially useful for very small percentages.
35
+ * This is particularly important for accessibility and visual clarity.
36
+ */
37
+ return Math.max(progressArc, 0.1 * percentage);
38
+ };
39
+ /**
40
+ * Calculates the remaining arc length based on the percentage.
41
+ *
42
+ * The remaining arc is calculated using the formula:
43
+ * Remaining Arc = Circumference - Progress Arc - 2 * Gap Size
44
+ *
45
+ * Example:
46
+ * If the total circumference is 100, the progress arc is 50, and each gap is 2 units,
47
+ * then with two gaps (one before and one after the progress arc), the calculation becomes:
48
+ * Remaining Arc = 100 - 50 - (2 * 2) = 46
49
+ *
50
+ * This ensures the gap between the progress and remaining arcs is visually preserved.
51
+ *
52
+ * @param percentage - The percentage value (0 to 100)
53
+ * @returns The remaining arc length
54
+ */
55
+ const getRemainingArc = (percentage) => {
56
+ const remainingArc = DEFAULTS.CIRCUMFERENCE - getProgressArc(percentage) - 2 * DEFAULTS.GAP_SIZE;
57
+ if (percentage === 0) {
58
+ return DEFAULTS.CIRCUMFERENCE;
59
+ }
60
+ /**
61
+ * Ensures that the remaining arc is never negative due to the gap size.
62
+ * In the final state (when the progress arc is nearly complete), the remaining arc should be 0.
63
+ */
64
+ if (remainingArc < 0) {
65
+ return 0;
66
+ }
67
+ return remainingArc;
68
+ };
69
+ /**
70
+ * Calculates the offset for the progress arc based on the percentage.
71
+ *
72
+ * The offset is adjusted to maintain a visual gap between the progress and track arcs.
73
+ * The progress arc begins slightly ahead of the 12 o’clock position, by half the gap size to account for spacing.
74
+ *
75
+ * @param percentage - The percentage value (0 to 100)
76
+ * @returns The offset for the progress arc
77
+ */
78
+ const getProgressOffset = (percentage) => {
79
+ if (percentage === 0) {
80
+ return 0;
81
+ }
82
+ return DEFAULTS.GAP_SIZE * 0.5;
83
+ };
84
+ /**
85
+ * Calculates the remaining offset for the remaining arc based on the percentage and progress arc.
86
+ *
87
+ * Adjusts the offset to maintain a consistent visual gap between the progress and track arcs.
88
+ * The remaining arc begins where the progress arc ends, we have to consider the gap before progress arc(12'o clock)
89
+ * i.e. half the gap size, plus an additional gap between the two arcs.
90
+ *
91
+ * @param percentage - The percentage value (0 to 100)
92
+ * @param progressArc - The length of the progress arc
93
+ * @returns The remaining offset for the remaining arc
94
+ */
95
+ const getRemainingOffset = (percentage, progressArc) => {
96
+ const remainingOffset = progressArc + DEFAULTS.GAP_SIZE * 1.5;
97
+ if (percentage === 0) {
98
+ return 0;
99
+ }
100
+ return remainingOffset;
101
+ };
102
+ export { getProgressArc, getRemainingArc, getProgressOffset, getRemainingOffset };
@@ -0,0 +1,46 @@
1
+ import { CSSResult } from 'lit';
2
+ import Progressbar from '../progressbar/progressbar.component';
3
+ /**
4
+ * `mdc-progressspinner` is a customizable, circular progress indicator component.
5
+ * It visually represents the current completion state of a process, such as loading,
6
+ * syncing, uploading, or any ongoing task that has a measurable percentage.
7
+ *
8
+ * The spinner is built using SVG with two concentric `<circle>` elements:
9
+ * - The `progress` arc represents the portion of work completed.
10
+ * - The `track` arc represents the remaining part.
11
+ *
12
+ * A visual gap is maintained between the progress and track arcs to clearly
13
+ * distinguish the two segments. The component smoothly animates arc length
14
+ * and respects accessibility best practices with ARIA attributes.
15
+ *
16
+ * The component supports different states:
17
+ * - **Default**: Circular spinner shows the progress.
18
+ * - **Success**: Displays a checkmark icon when progress reaches 100%.
19
+ * - **Error**: Displays an error icon when in an error state.
20
+ *
21
+ * @tagname mdc-progressspinner
22
+ *
23
+ * @cssproperty --mdc-spinner-size - The size of the spinner.
24
+ * @cssproperty --mdc-track-color - The color of the spinner track.
25
+ * @cssproperty --mdc-progress-color - The color of the spinner progress.
26
+ * @cssproperty --mdc-progress-success-color - The color of the spinner when in success state.
27
+ * @cssproperty --mdc-progress-error-color - The color of the spinner when in error state.
28
+ *
29
+ */
30
+ declare class Progressspinner extends Progressbar {
31
+ connectedCallback(): void;
32
+ private renderProgressSpinner;
33
+ /**
34
+ * Renders the error state of the progress spinner.
35
+ * @returns The rendered HTML for the error state.
36
+ */
37
+ private renderErrorState;
38
+ /**
39
+ * Renders the success state of the progress spinner.
40
+ * @returns The rendered HTML for the success state.
41
+ */
42
+ private renderSuccessState;
43
+ render(): import("lit-html").TemplateResult<1>;
44
+ static styles: Array<CSSResult>;
45
+ }
46
+ export default Progressspinner;
@@ -0,0 +1,125 @@
1
+ import { html } from 'lit';
2
+ import styles from './progressspinner.styles';
3
+ import { Component } from '../../models';
4
+ import Progressbar from '../progressbar/progressbar.component';
5
+ import { DEFAULTS, ICON_NAME } from './progressspinner.constants';
6
+ import { getProgressArc, getProgressOffset, getRemainingArc, getRemainingOffset } from './progressspiner.utils';
7
+ /**
8
+ * `mdc-progressspinner` is a customizable, circular progress indicator component.
9
+ * It visually represents the current completion state of a process, such as loading,
10
+ * syncing, uploading, or any ongoing task that has a measurable percentage.
11
+ *
12
+ * The spinner is built using SVG with two concentric `<circle>` elements:
13
+ * - The `progress` arc represents the portion of work completed.
14
+ * - The `track` arc represents the remaining part.
15
+ *
16
+ * A visual gap is maintained between the progress and track arcs to clearly
17
+ * distinguish the two segments. The component smoothly animates arc length
18
+ * and respects accessibility best practices with ARIA attributes.
19
+ *
20
+ * The component supports different states:
21
+ * - **Default**: Circular spinner shows the progress.
22
+ * - **Success**: Displays a checkmark icon when progress reaches 100%.
23
+ * - **Error**: Displays an error icon when in an error state.
24
+ *
25
+ * @tagname mdc-progressspinner
26
+ *
27
+ * @cssproperty --mdc-spinner-size - The size of the spinner.
28
+ * @cssproperty --mdc-track-color - The color of the spinner track.
29
+ * @cssproperty --mdc-progress-color - The color of the spinner progress.
30
+ * @cssproperty --mdc-progress-success-color - The color of the spinner when in success state.
31
+ * @cssproperty --mdc-progress-error-color - The color of the spinner when in error state.
32
+ *
33
+ */
34
+ class Progressspinner extends Progressbar {
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ this.id = '';
38
+ this.disabled = undefined;
39
+ this.helpTextType = undefined;
40
+ this.helpText = undefined;
41
+ this.requiredLabel = undefined;
42
+ this.variant = undefined;
43
+ this.label = undefined;
44
+ }
45
+ renderProgressSpinner() {
46
+ var _a;
47
+ const progressArc = getProgressArc(this.clampedValue);
48
+ const remainingArc = getRemainingArc(this.clampedValue);
49
+ const progressOffset = getProgressOffset(this.clampedValue);
50
+ const remainingOffset = getRemainingOffset(this.clampedValue, progressArc);
51
+ return html `
52
+ <div
53
+ part="spinner-container ${this.variant}"
54
+ role="progressbar"
55
+ aria-valuenow="${this.clampedValue}"
56
+ aria-valuemin="0"
57
+ aria-valuemax="100"
58
+ aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
59
+ >
60
+ <svg part="spinner-base">
61
+ <circle
62
+ part="spinner-track"
63
+ cx="24"
64
+ cy="24"
65
+ r="${DEFAULTS.RADIUS}"
66
+ stroke-width="${remainingArc === 0 ? 0 : DEFAULTS.STROKE_WIDTH}"
67
+ stroke-dasharray="${remainingArc} ${DEFAULTS.CIRCUMFERENCE}"
68
+ stroke-dashoffset="-${remainingOffset}"
69
+ />
70
+ <circle
71
+ part="spinner-progress"
72
+ cx="24"
73
+ cy="24"
74
+ r="${DEFAULTS.RADIUS}"
75
+ stroke-width="${progressArc === 0 ? 0 : DEFAULTS.STROKE_WIDTH}"
76
+ stroke-dasharray="${progressArc} ${DEFAULTS.CIRCUMFERENCE}"
77
+ stroke-dashoffset="-${progressOffset}"
78
+ />
79
+ </svg>
80
+ </div>
81
+ `;
82
+ }
83
+ /**
84
+ * Renders the error state of the progress spinner.
85
+ * @returns The rendered HTML for the error state.
86
+ */
87
+ renderErrorState() {
88
+ var _a;
89
+ return html `
90
+ <mdc-icon
91
+ part="error-icon"
92
+ aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
93
+ name="${ICON_NAME.ERROR_LEGACY_FILLED}"
94
+ size="${DEFAULTS.ERROR_ICON_SIZE}"
95
+ length-unit="${DEFAULTS.ICON_LENGTH_UNIT}"></mdc-icon>
96
+ `;
97
+ }
98
+ /**
99
+ * Renders the success state of the progress spinner.
100
+ * @returns The rendered HTML for the success state.
101
+ */
102
+ renderSuccessState() {
103
+ var _a;
104
+ return html `
105
+ <mdc-icon
106
+ part="success-icon"
107
+ aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
108
+ name="${ICON_NAME.CHECK_CIRCLE_BOLD}"
109
+ size="${DEFAULTS.SUCCESS_ICON_SIZE}"
110
+ length-unit="${DEFAULTS.ICON_LENGTH_UNIT}"></mdc-icon>
111
+ `;
112
+ }
113
+ render() {
114
+ if (this.error) {
115
+ return this.renderErrorState();
116
+ }
117
+ if (this.clampedValue === 100) {
118
+ return this.renderSuccessState();
119
+ }
120
+ return html `
121
+ ${this.renderProgressSpinner()}`;
122
+ }
123
+ }
124
+ Progressspinner.styles = [...Component.styles, ...styles];
125
+ export default Progressspinner;
@@ -0,0 +1,15 @@
1
+ declare const TAG_NAME: "mdc-progressspinner";
2
+ declare const DEFAULTS: {
3
+ readonly RADIUS: 20;
4
+ readonly CIRCUMFERENCE: number;
5
+ readonly STROKE_WIDTH: 4;
6
+ readonly GAP_SIZE: 7.5;
7
+ readonly ERROR_ICON_SIZE: 2;
8
+ readonly SUCCESS_ICON_SIZE: 3;
9
+ readonly ICON_LENGTH_UNIT: "em";
10
+ };
11
+ declare const ICON_NAME: {
12
+ readonly CHECK_CIRCLE_BOLD: "check-circle-bold";
13
+ readonly ERROR_LEGACY_FILLED: "error-legacy-filled";
14
+ };
15
+ export { TAG_NAME, DEFAULTS, ICON_NAME };
@@ -0,0 +1,16 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('progressspinner');
3
+ const DEFAULTS = {
4
+ RADIUS: 20,
5
+ CIRCUMFERENCE: 2 * Math.PI * 20,
6
+ STROKE_WIDTH: 4,
7
+ GAP_SIZE: 7.5,
8
+ ERROR_ICON_SIZE: 2,
9
+ SUCCESS_ICON_SIZE: 3,
10
+ ICON_LENGTH_UNIT: 'em',
11
+ };
12
+ const ICON_NAME = {
13
+ CHECK_CIRCLE_BOLD: 'check-circle-bold',
14
+ ERROR_LEGACY_FILLED: 'error-legacy-filled',
15
+ };
16
+ export { TAG_NAME, DEFAULTS, ICON_NAME };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,47 @@
1
+ import { css } from 'lit';
2
+ const styles = css `
3
+ :host {
4
+ --mdc-spinner-size: 3rem;
5
+ --mdc-track-color: var(--mds-color-theme-control-indicator-inactive-normal);
6
+ --mdc-progress-color: var(--mds-color-theme-control-active-normal);
7
+ --mdc-progress-success-color: var(--mds-color-theme-text-success-normal);
8
+ --mdc-progress-error-color: var(--mds-color-theme-text-error-normal);
9
+
10
+ display: block;
11
+ }
12
+
13
+ :host::part(spinner-container) {
14
+ width: 3rem;
15
+ height: 3rem;
16
+ position: relative;
17
+ }
18
+
19
+ :host::part(spinner-base) {
20
+ width: var(--mdc-spinner-size);
21
+ height: var(--mdc-spinner-size);
22
+ rotate: -90deg;
23
+ }
24
+
25
+ :host::part(spinner-track) {
26
+ stroke: var(--mdc-track-color);
27
+ stroke-linecap: round;
28
+ fill: none;
29
+ }
30
+
31
+ :host::part(spinner-progress) {
32
+ stroke: var(--mdc-progress-color);
33
+ stroke-linecap: round;
34
+ fill: none;
35
+ transition: stroke-dasharray 0.3s ease-in-out;
36
+ }
37
+
38
+ :host::part(success-icon) {
39
+ color: var(--mdc-progress-success-color);
40
+ }
41
+
42
+ :host::part(error-icon) {
43
+ color: var(--mdc-progress-error-color);
44
+ margin: 0.5rem;
45
+ }
46
+ `;
47
+ export default [styles];