@momentum-design/components 0.39.4 → 0.39.6
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.
- package/dist/browser/index.js +227 -123
- package/dist/browser/index.js.map +4 -4
- package/dist/components/alertchip/alertchip.component.d.ts +1 -1
- package/dist/components/alertchip/alertchip.component.js +4 -1
- package/dist/components/avatarbutton/avatarbutton.component.d.ts +1 -1
- package/dist/components/avatarbutton/avatarbutton.component.js +4 -1
- package/dist/components/checkbox/checkbox.component.d.ts +1 -1
- package/dist/components/checkbox/checkbox.component.js +4 -1
- package/dist/components/chip/chip.component.d.ts +1 -1
- package/dist/components/chip/chip.component.js +4 -1
- package/dist/components/coachmark/coachmark.component.d.ts +1 -1
- package/dist/components/coachmark/coachmark.component.js +4 -1
- package/dist/components/divider/divider.component.d.ts +1 -1
- package/dist/components/divider/divider.component.js +39 -36
- package/dist/components/filterchip/filterchip.component.d.ts +1 -1
- package/dist/components/filterchip/filterchip.component.js +4 -1
- package/dist/components/formfieldgroup/formfieldgroup.component.d.ts +1 -1
- package/dist/components/formfieldgroup/formfieldgroup.component.js +4 -1
- package/dist/components/listitem/listitem.component.d.ts +1 -1
- package/dist/components/listitem/listitem.component.js +4 -1
- package/dist/components/option/option.component.d.ts +1 -1
- package/dist/components/option/option.component.js +4 -1
- package/dist/components/progressbar/index.d.ts +9 -0
- package/dist/components/progressbar/index.js +6 -0
- package/dist/components/progressbar/progressbar.component.d.ts +79 -0
- package/dist/components/progressbar/progressbar.component.js +160 -0
- package/dist/components/progressbar/progressbar.constants.d.ts +11 -0
- package/dist/components/progressbar/progressbar.constants.js +12 -0
- package/dist/components/progressbar/progressbar.styles.d.ts +2 -0
- package/dist/components/progressbar/progressbar.styles.js +86 -0
- package/dist/components/progressbar/progressbar.types.d.ts +3 -0
- package/dist/components/progressbar/progressbar.types.js +1 -0
- package/dist/components/radio/radio.component.d.ts +1 -1
- package/dist/components/radio/radio.component.js +4 -1
- package/dist/components/tab/tab.component.d.ts +1 -1
- package/dist/components/tab/tab.component.js +4 -1
- package/dist/components/textarea/textarea.component.d.ts +0 -1
- package/dist/components/textarea/textarea.component.js +7 -7
- package/dist/components/toggle/toggle.component.d.ts +1 -1
- package/dist/components/toggle/toggle.component.js +4 -1
- package/dist/components/tooltip/tooltip.component.d.ts +1 -1
- package/dist/components/tooltip/tooltip.component.js +4 -3
- package/dist/components/tooltip/tooltip.constants.d.ts +0 -1
- package/dist/components/tooltip/tooltip.constants.js +1 -2
- package/dist/custom-elements.json +3155 -2750
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +3 -2
- package/dist/react/progressbar/index.d.ts +30 -0
- package/dist/react/progressbar/index.js +39 -0
- package/package.json +1 -1
@@ -35,7 +35,7 @@ import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
|
35
35
|
*/
|
36
36
|
class AlertChip extends Buttonsimple {
|
37
37
|
constructor() {
|
38
|
-
super();
|
38
|
+
super(...arguments);
|
39
39
|
/**
|
40
40
|
* The variant of the alertchip. It supports 5 variants
|
41
41
|
* - neutral
|
@@ -54,6 +54,9 @@ class AlertChip extends Buttonsimple {
|
|
54
54
|
* including empty spaces to split words.
|
55
55
|
*/
|
56
56
|
this.label = '';
|
57
|
+
}
|
58
|
+
connectedCallback() {
|
59
|
+
super.connectedCallback();
|
57
60
|
this.disabled = undefined;
|
58
61
|
this.softDisabled = undefined;
|
59
62
|
this.active = undefined;
|
@@ -22,7 +22,7 @@ declare class AvatarButton extends AvatarButton_base {
|
|
22
22
|
* Aria-label attribute to be set for accessibility
|
23
23
|
*/
|
24
24
|
ariaLabel: string | null;
|
25
|
-
|
25
|
+
connectedCallback(): void;
|
26
26
|
update(changedProperties: PropertyValues): void;
|
27
27
|
private setSize;
|
28
28
|
render(): import("lit-html").TemplateResult<1>;
|
@@ -33,11 +33,14 @@ import styles from './avatarbutton.styles';
|
|
33
33
|
*/
|
34
34
|
class AvatarButton extends AvatarComponentMixin(IconNameMixin(Buttonsimple)) {
|
35
35
|
constructor() {
|
36
|
-
super();
|
36
|
+
super(...arguments);
|
37
37
|
/**
|
38
38
|
* Aria-label attribute to be set for accessibility
|
39
39
|
*/
|
40
40
|
this.ariaLabel = null;
|
41
|
+
}
|
42
|
+
connectedCallback() {
|
43
|
+
super.connectedCallback();
|
41
44
|
this.active = undefined;
|
42
45
|
this.disabled = undefined;
|
43
46
|
this.softDisabled = undefined;
|
@@ -52,7 +52,7 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
|
52
52
|
* @default false
|
53
53
|
*/
|
54
54
|
autofocus: boolean;
|
55
|
-
|
55
|
+
connectedCallback(): void;
|
56
56
|
/**
|
57
57
|
* Updates the form value to reflect the current state of the checkbox.
|
58
58
|
* If checked, the value is set to either the user-provided value or 'on' if no value is provided.
|
@@ -47,7 +47,7 @@ import styles from './checkbox.styles';
|
|
47
47
|
*/
|
48
48
|
class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
49
49
|
constructor() {
|
50
|
-
super();
|
50
|
+
super(...arguments);
|
51
51
|
/**
|
52
52
|
* Determines whether the checkbox is selected or unselected.
|
53
53
|
*
|
@@ -76,6 +76,9 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
76
76
|
${this.renderHelperText()}
|
77
77
|
</div>`;
|
78
78
|
};
|
79
|
+
}
|
80
|
+
connectedCallback() {
|
81
|
+
super.connectedCallback();
|
79
82
|
// Checkbox does not contain helpTextType property.
|
80
83
|
this.helpTextType = undefined;
|
81
84
|
}
|
@@ -45,7 +45,7 @@ declare class Chip extends Chip_base {
|
|
45
45
|
* including empty spaces to split words.
|
46
46
|
*/
|
47
47
|
label: string;
|
48
|
-
|
48
|
+
connectedCallback(): void;
|
49
49
|
/**
|
50
50
|
* Renders the icon element if available.
|
51
51
|
* @returns The icon element if available, otherwise nothing.
|
@@ -36,7 +36,7 @@ import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
|
36
36
|
*/
|
37
37
|
class Chip extends IconNameMixin(Buttonsimple) {
|
38
38
|
constructor() {
|
39
|
-
super();
|
39
|
+
super(...arguments);
|
40
40
|
/**
|
41
41
|
* The color of the chip. It supports the following colors
|
42
42
|
* - default
|
@@ -59,6 +59,9 @@ class Chip extends IconNameMixin(Buttonsimple) {
|
|
59
59
|
* including empty spaces to split words.
|
60
60
|
*/
|
61
61
|
this.label = '';
|
62
|
+
}
|
63
|
+
connectedCallback() {
|
64
|
+
super.connectedCallback();
|
62
65
|
this.role = DEFAULTS.ROLE;
|
63
66
|
this.size = DEFAULTS.SIZE;
|
64
67
|
this.active = undefined;
|
@@ -38,7 +38,7 @@ import { DEFAULTS } from './coachmark.constants';
|
|
38
38
|
*/
|
39
39
|
class Coachmark extends Popover {
|
40
40
|
constructor() {
|
41
|
-
super();
|
41
|
+
super(...arguments);
|
42
42
|
/**
|
43
43
|
* Determines the events that cause the Coachmark to show.
|
44
44
|
* Multiple event names should be separated by spaces.
|
@@ -65,6 +65,9 @@ class Coachmark extends Popover {
|
|
65
65
|
* @default true
|
66
66
|
*/
|
67
67
|
this.disableAriaExpanded = DEFAULTS.DISABLE_ARIA_EXPANDED;
|
68
|
+
}
|
69
|
+
connectedCallback() {
|
70
|
+
super.connectedCallback();
|
68
71
|
this.color = DEFAULTS.COLOR;
|
69
72
|
this.showArrow = DEFAULTS.ARROW;
|
70
73
|
}
|
@@ -130,7 +130,7 @@ declare class Divider extends Component {
|
|
130
130
|
* @param slot - default slot of divider
|
131
131
|
*/
|
132
132
|
private inferDividerType;
|
133
|
-
|
133
|
+
connectedCallback(): void;
|
134
134
|
protected render(): import("lit-html").TemplateResult<1>;
|
135
135
|
static styles: Array<CSSResult>;
|
136
136
|
}
|
@@ -60,6 +60,43 @@ import styles from './divider.styles';
|
|
60
60
|
* @cssproperty --mdc-divider-grabber-button-border-radius - border radius of the grabber button
|
61
61
|
*/
|
62
62
|
class Divider extends Component {
|
63
|
+
constructor() {
|
64
|
+
super(...arguments);
|
65
|
+
/**
|
66
|
+
* Two orientations of divider
|
67
|
+
* - **horizontal**: A thin, horizontal line with 0.0625rem width.
|
68
|
+
* - **vertical**: A thin, vertical line with 0.0625rem width.
|
69
|
+
*
|
70
|
+
* Note: We do not support "Vertical Text Divider" as of now.
|
71
|
+
* @default horizontal
|
72
|
+
*/
|
73
|
+
this.orientation = DEFAULTS.ORIENTATION;
|
74
|
+
/**
|
75
|
+
* Two variants of divider
|
76
|
+
* - **solid**: Solid line.
|
77
|
+
* - **gradient**: Gradient Line that fades on either sides of the divider.
|
78
|
+
* @default solid
|
79
|
+
*/
|
80
|
+
this.variant = DEFAULTS.VARIANT;
|
81
|
+
/**
|
82
|
+
* Direction of the arrow icon, if applicable.
|
83
|
+
* - **positive**
|
84
|
+
* - **negative**
|
85
|
+
*
|
86
|
+
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
87
|
+
* @default 'negative'
|
88
|
+
*/
|
89
|
+
this.arrowDirection = DEFAULTS.ARROW_DIRECTION;
|
90
|
+
/**
|
91
|
+
* Position of the button, if applicable.
|
92
|
+
* - **positive**
|
93
|
+
* - **negative**
|
94
|
+
*
|
95
|
+
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
96
|
+
* @default 'negative'
|
97
|
+
*/
|
98
|
+
this.buttonPosition = DEFAULTS.BUTTON_DIRECTION;
|
99
|
+
}
|
63
100
|
/**
|
64
101
|
* Sets the variant attribute for the divider component.
|
65
102
|
* If the provided variant is not included in the DIVIDER_VARIANT,
|
@@ -163,42 +200,8 @@ class Divider extends Component {
|
|
163
200
|
this.setGrabberButton();
|
164
201
|
}
|
165
202
|
}
|
166
|
-
|
167
|
-
super();
|
168
|
-
/**
|
169
|
-
* Two orientations of divider
|
170
|
-
* - **horizontal**: A thin, horizontal line with 0.0625rem width.
|
171
|
-
* - **vertical**: A thin, vertical line with 0.0625rem width.
|
172
|
-
*
|
173
|
-
* Note: We do not support "Vertical Text Divider" as of now.
|
174
|
-
* @default horizontal
|
175
|
-
*/
|
176
|
-
this.orientation = DEFAULTS.ORIENTATION;
|
177
|
-
/**
|
178
|
-
* Two variants of divider
|
179
|
-
* - **solid**: Solid line.
|
180
|
-
* - **gradient**: Gradient Line that fades on either sides of the divider.
|
181
|
-
* @default solid
|
182
|
-
*/
|
183
|
-
this.variant = DEFAULTS.VARIANT;
|
184
|
-
/**
|
185
|
-
* Direction of the arrow icon, if applicable.
|
186
|
-
* - **positive**
|
187
|
-
* - **negative**
|
188
|
-
*
|
189
|
-
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
190
|
-
* @default 'negative'
|
191
|
-
*/
|
192
|
-
this.arrowDirection = DEFAULTS.ARROW_DIRECTION;
|
193
|
-
/**
|
194
|
-
* Position of the button, if applicable.
|
195
|
-
* - **positive**
|
196
|
-
* - **negative**
|
197
|
-
*
|
198
|
-
* Note: Positive and Negative directions are defined based on Cartesian plane.
|
199
|
-
* @default 'negative'
|
200
|
-
*/
|
201
|
-
this.buttonPosition = DEFAULTS.BUTTON_DIRECTION;
|
203
|
+
connectedCallback() {
|
204
|
+
super.connectedCallback();
|
202
205
|
this.setAttribute('data-type', 'mdc-primary-divider');
|
203
206
|
}
|
204
207
|
render() {
|
@@ -16,7 +16,7 @@ declare class FilterChip extends Chip {
|
|
16
16
|
* @default false
|
17
17
|
*/
|
18
18
|
selected: boolean;
|
19
|
-
|
19
|
+
connectedCallback(): void;
|
20
20
|
/**
|
21
21
|
* Sets the selected state of the filterchip along with the icon.
|
22
22
|
* aria-pressed attribute is also set to true or false.
|
@@ -22,13 +22,16 @@ import { DEFAULTS } from './filterchip.constants';
|
|
22
22
|
*/
|
23
23
|
class FilterChip extends Chip {
|
24
24
|
constructor() {
|
25
|
-
super();
|
25
|
+
super(...arguments);
|
26
26
|
/**
|
27
27
|
* The selected state of the filterchip.
|
28
28
|
*
|
29
29
|
* @default false
|
30
30
|
*/
|
31
31
|
this.selected = false;
|
32
|
+
}
|
33
|
+
connectedCallback() {
|
34
|
+
super.connectedCallback();
|
32
35
|
this.color = DEFAULTS.COLOR;
|
33
36
|
}
|
34
37
|
/**
|
@@ -27,7 +27,7 @@ declare class FormfieldGroup extends FormfieldGroup_base {
|
|
27
27
|
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
28
28
|
*/
|
29
29
|
protected isRadio: boolean;
|
30
|
-
|
30
|
+
connectedCallback(): void;
|
31
31
|
render(): import("lit-html").TemplateResult<1>;
|
32
32
|
static styles: Array<CSSResult>;
|
33
33
|
}
|
@@ -27,12 +27,15 @@ import styles from './formfieldgroup.styles';
|
|
27
27
|
*/
|
28
28
|
class FormfieldGroup extends DataAriaLabelMixin(FormfieldWrapper) {
|
29
29
|
constructor() {
|
30
|
-
super();
|
30
|
+
super(...arguments);
|
31
31
|
/**
|
32
32
|
* @internal
|
33
33
|
* This is used to set the role of the component as `radiogroup` if this is true and to 'group' if it is false.
|
34
34
|
*/
|
35
35
|
this.isRadio = false;
|
36
|
+
}
|
37
|
+
connectedCallback() {
|
38
|
+
super.connectedCallback();
|
36
39
|
/** @internal */
|
37
40
|
this.shouldRenderLabel = false;
|
38
41
|
this.id = '';
|
@@ -76,7 +76,7 @@ declare class ListItem extends ListItem_base {
|
|
76
76
|
* This appears on the trailing side of the list item.
|
77
77
|
*/
|
78
78
|
sublineText?: string;
|
79
|
-
|
79
|
+
connectedCallback(): void;
|
80
80
|
/**
|
81
81
|
* Generates a template for a text slot with the specified content.
|
82
82
|
*
|
@@ -55,12 +55,15 @@ import styles from './listitem.styles';
|
|
55
55
|
*/
|
56
56
|
class ListItem extends DataAriaLabelMixin(DisabledMixin(TabIndexMixin(Component))) {
|
57
57
|
constructor() {
|
58
|
-
super();
|
58
|
+
super(...arguments);
|
59
59
|
/**
|
60
60
|
* The variant of the list item. It can be a pill, rectangle or a full-width.
|
61
61
|
* @default 'full-width'
|
62
62
|
*/
|
63
63
|
this.variant = DEFAULTS.VARIANT;
|
64
|
+
}
|
65
|
+
connectedCallback() {
|
66
|
+
super.connectedCallback();
|
64
67
|
this.role = this.role || 'listitem';
|
65
68
|
}
|
66
69
|
/**
|
@@ -28,7 +28,7 @@ declare class Option extends Option_base {
|
|
28
28
|
* Any additional description can be provided here for screen readers.
|
29
29
|
*/
|
30
30
|
ariaLabel: string | null;
|
31
|
-
|
31
|
+
connectedCallback(): void;
|
32
32
|
/**
|
33
33
|
* Listens to changes in the default slot and updates the label of the option accordingly.
|
34
34
|
* This is used to set the label of the option when it is not explicitly set.
|
@@ -31,7 +31,7 @@ import styles from './option.styles';
|
|
31
31
|
*/
|
32
32
|
class Option extends FormInternalsMixin(ListItem) {
|
33
33
|
constructor() {
|
34
|
-
super();
|
34
|
+
super(...arguments);
|
35
35
|
/**
|
36
36
|
* The selected attribute is used to indicate that the option is selected.
|
37
37
|
*/
|
@@ -40,6 +40,9 @@ class Option extends FormInternalsMixin(ListItem) {
|
|
40
40
|
* Any additional description can be provided here for screen readers.
|
41
41
|
*/
|
42
42
|
this.ariaLabel = null;
|
43
|
+
}
|
44
|
+
connectedCallback() {
|
45
|
+
super.connectedCallback();
|
43
46
|
this.role = 'option';
|
44
47
|
this.variant = LISTITEM_VARIANTS.INSET_RECTANGLE;
|
45
48
|
this.updateAttribute('aria-selected', `${this.selected}`);
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { CSSResult } from 'lit';
|
2
|
+
import FormfieldWrapper from '../formfieldwrapper';
|
3
|
+
import type { Variant } from './progressbar.types';
|
4
|
+
declare const Progressbar_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
5
|
+
/**
|
6
|
+
* mdc-progressbar component visually represents a progress indicator, typically used to show
|
7
|
+
* the completion state of an ongoing process (e.g., loading, file upload, etc.).
|
8
|
+
* It contains an optional label and an optional helper text.
|
9
|
+
*
|
10
|
+
* - It supports mainly two types: Default and Inline
|
11
|
+
* - It supports three validation variants: Default, Success and Error.
|
12
|
+
*
|
13
|
+
* This component is created by extending FormfieldWrapper.
|
14
|
+
*
|
15
|
+
* @tagname mdc-progressbar
|
16
|
+
*
|
17
|
+
* @dependency mdc-icon
|
18
|
+
* @dependency mdc-text
|
19
|
+
*
|
20
|
+
* @cssproperty --mdc-progressbar-default-background-color - Background color of the progressbar when inactive.
|
21
|
+
* @cssproperty --mdc-progressbar-default-active-background-color - Background color of the progressbar when active.
|
22
|
+
* @cssproperty --mdc-progressbar-success-background-color - Background color of the progressbar when in success state.
|
23
|
+
* @cssproperty --mdc-progressbar-error-background-color - Background color of the progressbar when in error state.
|
24
|
+
* @cssproperty --mdc-progressbar-height - The height of the progressbar.
|
25
|
+
* @cssproperty --mdc-progressbar-border-radius - The border radius of the progressbar.
|
26
|
+
* @cssproperty --mdc-progressbar-label-color - Color of the progressbar label text.
|
27
|
+
* @cssproperty --mdc-progressbar-label-lineheight - Line height of the label text.
|
28
|
+
* @cssproperty --mdc-progressbar-label-fontsize - Font size of the label text.
|
29
|
+
* @cssproperty --mdc-progressbar-label-fontweight - Font weight of the label text.
|
30
|
+
* @cssproperty --mdc-progressbar-help-text-color - Color of the help text.
|
31
|
+
*/
|
32
|
+
declare class Progressbar extends Progressbar_base {
|
33
|
+
/**
|
34
|
+
* Types of the progressbar
|
35
|
+
* - **Default**
|
36
|
+
* - **Inline**
|
37
|
+
*
|
38
|
+
* @default default
|
39
|
+
*/
|
40
|
+
variant: Variant;
|
41
|
+
/**
|
42
|
+
* The current progress as a percentage, 0 to 100.
|
43
|
+
* The value will be clamped between 0 and 100.
|
44
|
+
* @default 0
|
45
|
+
*/
|
46
|
+
value: string;
|
47
|
+
/**
|
48
|
+
* Define error state of the progressbar
|
49
|
+
* - **true**
|
50
|
+
* - **false**
|
51
|
+
* @default false
|
52
|
+
*/
|
53
|
+
error: boolean;
|
54
|
+
connectedCallback(): void;
|
55
|
+
/**
|
56
|
+
* Ensures that the value is clamped between 0 and 100
|
57
|
+
* @returns The clamped value
|
58
|
+
* @internal
|
59
|
+
*/
|
60
|
+
private get clampedValue();
|
61
|
+
/**
|
62
|
+
* Determines the validation state (success, error, or default) based on progress value and error state.
|
63
|
+
* @returns The appropriate validation state for the progressbar.
|
64
|
+
*/
|
65
|
+
private getValidationVariant;
|
66
|
+
/**
|
67
|
+
* Renders the progress bar with dynamic width and variant styles.
|
68
|
+
* @returns The rendered HTML for the progress bar.
|
69
|
+
* @internal
|
70
|
+
*/
|
71
|
+
private renderProgressbar;
|
72
|
+
/**
|
73
|
+
* Renders the component based on the variant (inline or default).
|
74
|
+
* @returns The rendered HTML for the component.
|
75
|
+
*/
|
76
|
+
render(): import("lit-html").TemplateResult<1>;
|
77
|
+
static styles: Array<CSSResult>;
|
78
|
+
}
|
79
|
+
export default Progressbar;
|
@@ -0,0 +1,160 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html } from 'lit';
|
11
|
+
import { property } from 'lit/decorators.js';
|
12
|
+
import { v4 as uuidv4 } from 'uuid';
|
13
|
+
import styles from './progressbar.styles';
|
14
|
+
import FormfieldWrapper from '../formfieldwrapper';
|
15
|
+
import { DEFAULTS, VARIANT } from './progressbar.constants';
|
16
|
+
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
17
|
+
import { VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
|
18
|
+
/**
|
19
|
+
* mdc-progressbar component visually represents a progress indicator, typically used to show
|
20
|
+
* the completion state of an ongoing process (e.g., loading, file upload, etc.).
|
21
|
+
* It contains an optional label and an optional helper text.
|
22
|
+
*
|
23
|
+
* - It supports mainly two types: Default and Inline
|
24
|
+
* - It supports three validation variants: Default, Success and Error.
|
25
|
+
*
|
26
|
+
* This component is created by extending FormfieldWrapper.
|
27
|
+
*
|
28
|
+
* @tagname mdc-progressbar
|
29
|
+
*
|
30
|
+
* @dependency mdc-icon
|
31
|
+
* @dependency mdc-text
|
32
|
+
*
|
33
|
+
* @cssproperty --mdc-progressbar-default-background-color - Background color of the progressbar when inactive.
|
34
|
+
* @cssproperty --mdc-progressbar-default-active-background-color - Background color of the progressbar when active.
|
35
|
+
* @cssproperty --mdc-progressbar-success-background-color - Background color of the progressbar when in success state.
|
36
|
+
* @cssproperty --mdc-progressbar-error-background-color - Background color of the progressbar when in error state.
|
37
|
+
* @cssproperty --mdc-progressbar-height - The height of the progressbar.
|
38
|
+
* @cssproperty --mdc-progressbar-border-radius - The border radius of the progressbar.
|
39
|
+
* @cssproperty --mdc-progressbar-label-color - Color of the progressbar label text.
|
40
|
+
* @cssproperty --mdc-progressbar-label-lineheight - Line height of the label text.
|
41
|
+
* @cssproperty --mdc-progressbar-label-fontsize - Font size of the label text.
|
42
|
+
* @cssproperty --mdc-progressbar-label-fontweight - Font weight of the label text.
|
43
|
+
* @cssproperty --mdc-progressbar-help-text-color - Color of the help text.
|
44
|
+
*/
|
45
|
+
class Progressbar extends DataAriaLabelMixin(FormfieldWrapper) {
|
46
|
+
constructor() {
|
47
|
+
super(...arguments);
|
48
|
+
/**
|
49
|
+
* Types of the progressbar
|
50
|
+
* - **Default**
|
51
|
+
* - **Inline**
|
52
|
+
*
|
53
|
+
* @default default
|
54
|
+
*/
|
55
|
+
this.variant = DEFAULTS.VARIANT;
|
56
|
+
/**
|
57
|
+
* The current progress as a percentage, 0 to 100.
|
58
|
+
* The value will be clamped between 0 and 100.
|
59
|
+
* @default 0
|
60
|
+
*/
|
61
|
+
this.value = '0';
|
62
|
+
/**
|
63
|
+
* Define error state of the progressbar
|
64
|
+
* - **true**
|
65
|
+
* - **false**
|
66
|
+
* @default false
|
67
|
+
*/
|
68
|
+
this.error = false;
|
69
|
+
/**
|
70
|
+
* Renders the progress bar with dynamic width and variant styles.
|
71
|
+
* @returns The rendered HTML for the progress bar.
|
72
|
+
* @internal
|
73
|
+
*/
|
74
|
+
this.renderProgressbar = () => {
|
75
|
+
var _a;
|
76
|
+
const variant = this.getValidationVariant();
|
77
|
+
const isGap = this.clampedValue > 0 && this.clampedValue < 100;
|
78
|
+
const progressWidth = this.error ? '100' : `${this.clampedValue}`;
|
79
|
+
return html `
|
80
|
+
<div
|
81
|
+
part="progress-container ${isGap ? 'gap' : ''}"
|
82
|
+
role="progressbar"
|
83
|
+
aria-valuenow="${this.clampedValue}"
|
84
|
+
aria-valuemin="0"
|
85
|
+
aria-valuemax="100"
|
86
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
87
|
+
>
|
88
|
+
<div part="progress-bar ${variant}" style="width: ${progressWidth}%"></div>
|
89
|
+
<div part="remaining"></div>
|
90
|
+
</div>
|
91
|
+
`;
|
92
|
+
};
|
93
|
+
}
|
94
|
+
connectedCallback() {
|
95
|
+
super.connectedCallback();
|
96
|
+
this.id = `mdc-progressbar-${uuidv4()}`;
|
97
|
+
this.disabled = undefined;
|
98
|
+
}
|
99
|
+
/**
|
100
|
+
* Ensures that the value is clamped between 0 and 100
|
101
|
+
* @returns The clamped value
|
102
|
+
* @internal
|
103
|
+
*/
|
104
|
+
get clampedValue() {
|
105
|
+
const value = Number(this.value);
|
106
|
+
const clampedValue = Number.isNaN(value) ? 0 : Math.max(0, Math.min(100, value));
|
107
|
+
return clampedValue;
|
108
|
+
}
|
109
|
+
/**
|
110
|
+
* Determines the validation state (success, error, or default) based on progress value and error state.
|
111
|
+
* @returns The appropriate validation state for the progressbar.
|
112
|
+
*/
|
113
|
+
getValidationVariant() {
|
114
|
+
if (this.error) {
|
115
|
+
this.helpTextType = VALIDATION.ERROR;
|
116
|
+
}
|
117
|
+
else if (this.clampedValue === 100) {
|
118
|
+
this.helpTextType = VALIDATION.SUCCESS;
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
this.helpTextType = VALIDATION.DEFAULT;
|
122
|
+
}
|
123
|
+
return this.helpTextType;
|
124
|
+
}
|
125
|
+
/**
|
126
|
+
* Renders the component based on the variant (inline or default).
|
127
|
+
* @returns The rendered HTML for the component.
|
128
|
+
*/
|
129
|
+
render() {
|
130
|
+
const isInline = this.variant === VARIANT.INLINE;
|
131
|
+
return html `
|
132
|
+
${isInline
|
133
|
+
? html `<div part="inline-label-container">${this.renderLabelElement()} ${this.renderProgressbar()}</div>`
|
134
|
+
: html `
|
135
|
+
<div part="label-container">
|
136
|
+
${this.renderLabelElement()}
|
137
|
+
${this.variant === VARIANT.DEFAULT && this.label
|
138
|
+
? html `<span part="percentage">${this.clampedValue}%</span>`
|
139
|
+
: ''}
|
140
|
+
</div>
|
141
|
+
${this.renderProgressbar()}
|
142
|
+
${this.renderHelperText()}
|
143
|
+
`}
|
144
|
+
`;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
Progressbar.styles = [...FormfieldWrapper.styles, ...styles];
|
148
|
+
__decorate([
|
149
|
+
property({ type: String, reflect: true }),
|
150
|
+
__metadata("design:type", String)
|
151
|
+
], Progressbar.prototype, "variant", void 0);
|
152
|
+
__decorate([
|
153
|
+
property({ type: String, reflect: true }),
|
154
|
+
__metadata("design:type", String)
|
155
|
+
], Progressbar.prototype, "value", void 0);
|
156
|
+
__decorate([
|
157
|
+
property({ type: Boolean, attribute: 'error' }),
|
158
|
+
__metadata("design:type", Object)
|
159
|
+
], Progressbar.prototype, "error", void 0);
|
160
|
+
export default Progressbar;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
|
2
|
+
declare const TAG_NAME: "mdc-progressbar";
|
3
|
+
declare const VARIANT: {
|
4
|
+
readonly DEFAULT: "default";
|
5
|
+
readonly INLINE: "inline";
|
6
|
+
};
|
7
|
+
declare const DEFAULTS: {
|
8
|
+
readonly VARIANT: "default";
|
9
|
+
readonly VALIDATION: "default";
|
10
|
+
};
|
11
|
+
export { TAG_NAME, VARIANT, VALIDATION, DEFAULTS };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
|
3
|
+
const TAG_NAME = utils.constructTagName('progressbar');
|
4
|
+
const VARIANT = {
|
5
|
+
DEFAULT: 'default',
|
6
|
+
INLINE: 'inline',
|
7
|
+
};
|
8
|
+
const DEFAULTS = {
|
9
|
+
VARIANT: VARIANT.DEFAULT,
|
10
|
+
VALIDATION: VALIDATION.DEFAULT,
|
11
|
+
};
|
12
|
+
export { TAG_NAME, VARIANT, VALIDATION, DEFAULTS };
|