@momentum-design/components 0.32.0 → 0.33.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.
@@ -138,7 +138,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
138
138
  }
139
139
  }
140
140
  setInputValidity() {
141
- if (this.validationMessage && this.value === '') {
141
+ if (this.requiredLabel && this.validationMessage && this.value === '') {
142
142
  this.inputElement.setCustomValidity(this.validationMessage);
143
143
  }
144
144
  else {
@@ -175,6 +175,11 @@ declare class Popover extends Popover_base {
175
175
  * aria-describedby of the popover.
176
176
  */
177
177
  ariaDescribedby: string | null;
178
+ /**
179
+ * Disable aria-expanded attribute on trigger element.
180
+ * @default false
181
+ */
182
+ disableAriaExpanded: boolean;
178
183
  arrowElement: HTMLElement | null;
179
184
  /** @internal */
180
185
  triggerElement: HTMLElement | null;
@@ -193,6 +193,11 @@ class Popover extends FocusTrapMixin(Component) {
193
193
  * aria-describedby of the popover.
194
194
  */
195
195
  this.ariaDescribedby = null;
196
+ /**
197
+ * Disable aria-expanded attribute on trigger element.
198
+ * @default false
199
+ */
200
+ this.disableAriaExpanded = DEFAULTS.DISABLE_ARIA_EXPANDED;
196
201
  this.arrowElement = null;
197
202
  /** @internal */
198
203
  this.triggerElement = null;
@@ -450,7 +455,9 @@ class Popover extends FocusTrapMixin(Component) {
450
455
  if (this.hideOnEscape) {
451
456
  document.addEventListener('keydown', this.onEscapeKeydown);
452
457
  }
453
- this.triggerElement.setAttribute('aria-expanded', 'true');
458
+ if (!this.disableAriaExpanded) {
459
+ this.triggerElement.setAttribute('aria-expanded', 'true');
460
+ }
454
461
  if (this.interactive) {
455
462
  this.triggerElement.setAttribute('aria-haspopup', this.triggerElement.getAttribute('aria-haspopup') || 'dialog');
456
463
  }
@@ -475,7 +482,9 @@ class Popover extends FocusTrapMixin(Component) {
475
482
  document.removeEventListener('keydown', this.onEscapeKeydown);
476
483
  }
477
484
  (_b = this.deactivateFocusTrap) === null || _b === void 0 ? void 0 : _b.call(this);
478
- this.triggerElement.removeAttribute('aria-expanded');
485
+ if (!this.disableAriaExpanded) {
486
+ this.triggerElement.removeAttribute('aria-expanded');
487
+ }
479
488
  if (this.interactive) {
480
489
  this.triggerElement.removeAttribute('aria-haspopup');
481
490
  }
@@ -673,4 +682,8 @@ __decorate([
673
682
  property({ type: String, reflect: true, attribute: 'aria-describedby' }),
674
683
  __metadata("design:type", Object)
675
684
  ], Popover.prototype, "ariaDescribedby", void 0);
685
+ __decorate([
686
+ property({ type: Boolean, reflect: true, attribute: 'disable-aria-expanded' }),
687
+ __metadata("design:type", Boolean)
688
+ ], Popover.prototype, "disableAriaExpanded", void 0);
676
689
  export default Popover;
@@ -44,5 +44,6 @@ declare const DEFAULTS: {
44
44
  readonly DELAY: "0,0";
45
45
  readonly ROLE: "dialog";
46
46
  readonly Z_INDEX: 1000;
47
+ readonly DISABLE_ARIA_EXPANDED: false;
47
48
  };
48
49
  export { TAG_NAME, POPOVER_PLACEMENT, COLOR, TRIGGER, DEFAULTS };
@@ -45,5 +45,6 @@ const DEFAULTS = {
45
45
  DELAY: '0,0',
46
46
  ROLE: 'dialog',
47
47
  Z_INDEX: 1000,
48
+ DISABLE_ARIA_EXPANDED: false,
48
49
  };
49
50
  export { TAG_NAME, POPOVER_PLACEMENT, COLOR, TRIGGER, DEFAULTS };
@@ -0,0 +1,10 @@
1
+ import Textarea from './textarea.component';
2
+ import '../button';
3
+ import '../icon';
4
+ import '../text';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ ['mdc-textarea']: Textarea;
8
+ }
9
+ }
10
+ export default Textarea;
@@ -0,0 +1,7 @@
1
+ import Textarea from './textarea.component';
2
+ import { TAG_NAME } from './textarea.constants';
3
+ import '../button';
4
+ import '../icon';
5
+ import '../text';
6
+ Textarea.register(TAG_NAME);
7
+ export default Textarea;
@@ -0,0 +1,203 @@
1
+ import { CSSResult, nothing, PropertyValueMap } from 'lit';
2
+ import FormfieldWrapper from '../formfieldwrapper';
3
+ import type { AutoCapitalizeType } from '../input/input.types';
4
+ import type { WrapType, AutoCompleteType } from './textarea.types';
5
+ declare const Textarea_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
6
+ /**
7
+ * mdc-textarea component, which is used to get the multi-line text input from the user.
8
+ * It contains:
9
+ * - label: It is the title of the textarea field.
10
+ * - required-label: A string depicting that the textarea field is required.
11
+ * - Textarea: It is the multi-line text input field.
12
+ * - helper-text: It is the text that provides additional information about the textarea field.
13
+ * - max-character-limit: It is the text that shows the character count of the textarea field.
14
+ * - clear-button: A boolean value when marked to true represents a button that can
15
+ * clear the text value within the textarea field.
16
+ * - Error, Warning, Success, Priority Help Text type: It is the text that provides additional information
17
+ * about the textarea field based on the validation state.
18
+ * - limitexceeded: It is the event that is dispatched when the character limit exceeds or restored.
19
+ * This event exposes 3 properties:
20
+ * - currentCharacterCount - the current number of characters in the textarea field,
21
+ * - maxCharacterLimit - the maximum number of characters allowed in the textarea field,
22
+ * - value - the current value of the textarea field,
23
+ *
24
+ * **Note**: Consumers must set the help-text-type with 'error' and
25
+ * help-text attribute with the error message using limitexceeded event.
26
+ * The same help-text value will be used for the validation message to be displayed.
27
+ *
28
+ * @tagname mdc-textarea
29
+ *
30
+ * @event input - (React: onInput) This event is dispatched when the value of the textarea field changes (every press).
31
+ * @event change - (React: onChange) This event is dispatched when the value of the textarea field changes (on blur).
32
+ * @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.
33
+ * @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.
34
+ * @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit
35
+ * exceeds or restored.
36
+ *
37
+ *
38
+ * @dependency mdc-icon
39
+ * @dependency mdc-text
40
+ * @dependency mdc-button
41
+ *
42
+ * @cssproperty --mdc-textarea-disabled-border-color - Border color for the textarea container when disabled
43
+ * @cssproperty --mdc-textarea-disabled-text-color - Text color for the textarea field when disabled
44
+ * @cssproperty --mdc-textarea-disabled-background-color - Background color for the textarea field when disabled
45
+ * @cssproperty --mdc-textarea-text-color - Text color for the textarea field
46
+ * @cssproperty --mdc-textarea-background-color - Background color for the textarea field
47
+ * @cssproperty --mdc-textarea-border-color - Border color for the textarea field
48
+ * @cssproperty --mdc-textarea-text-secondary-normal - Text color for the character counter
49
+ * @cssproperty --mdc-textarea-error-border-color - Border color for the error related help text
50
+ * @cssproperty --mdc-textarea-warning-border-color - Border color for the warning related help text
51
+ * @cssproperty --mdc-textarea-success-border-color - Border color for the success related help text
52
+ * @cssproperty --mdc-textarea-primary-border-color - Border color for the priority related help text
53
+ * @cssproperty --mdc-textarea-hover-background-color - Background color for the textarea container when hover
54
+ * @cssproperty --mdc-textarea-focused-background-color - Background color for the textarea container when focused
55
+ * @cssproperty --mdc-textarea-focused-border-color - Border color for the textarea container when focused
56
+ */
57
+ declare class Textarea extends Textarea_base {
58
+ /**
59
+ * The placeholder text that is displayed when the textarea field is empty.
60
+ */
61
+ placeholder?: string;
62
+ /**
63
+ * readonly attribute of the textarea field. If true, the textarea field is read-only.
64
+ * @default false
65
+ */
66
+ readonly: boolean;
67
+ /**
68
+ * The rows attribute specifies the visible number of lines in a text area.
69
+ * @default 5
70
+ */
71
+ rows: number;
72
+ /**
73
+ * The cols attribute specifies the visible number of lines in a text area.
74
+ * @default 40
75
+ */
76
+ cols: number;
77
+ /**
78
+ * The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.
79
+ * @default 'soft'
80
+ */
81
+ wrap: WrapType;
82
+ /**
83
+ * The autocapitalize attribute of the textarea field.
84
+ * @default 'off'
85
+ */
86
+ autocapitalize: AutoCapitalizeType;
87
+ /**
88
+ * The autocomplete attribute of the textarea field.
89
+ * @default 'off'
90
+ */
91
+ autocomplete: AutoCompleteType;
92
+ /**
93
+ * If true, the textarea field is focused when the component is rendered.
94
+ * @default false
95
+ */
96
+ autofocus: boolean;
97
+ /**
98
+ * Specifies the name of the directionality of text for submission purposes (e.g., "rtl" for right-to-left).
99
+ */
100
+ dirname?: string;
101
+ /**
102
+ * The maximum number of characters that the textarea field can accept.
103
+ */
104
+ maxlength?: number;
105
+ /**
106
+ * The minimum number of characters that the textarea field can accept.
107
+ */
108
+ minlength?: number;
109
+ /**
110
+ * The clear button when set to true, shows a clear button that clears the textarea field.
111
+ * @default false
112
+ */
113
+ clearButton: boolean;
114
+ /**
115
+ * Aria label for the clear button. If clear button is set to true, this label is used for the clear button.
116
+ * @default ''
117
+ */
118
+ clearAriaLabel: string;
119
+ /**
120
+ * maximum character limit for the textarea field for character counter.
121
+ */
122
+ maxCharacterLimit?: number;
123
+ /**
124
+ * @internal
125
+ * The textarea element
126
+ */
127
+ inputElement: HTMLTextAreaElement;
128
+ private characterLimitExceedingFired;
129
+ protected get textarea(): HTMLTextAreaElement;
130
+ constructor();
131
+ connectedCallback(): void;
132
+ private setTextareaValidity;
133
+ /** @internal */
134
+ formResetCallback(): void;
135
+ /** @internal */
136
+ formStateRestoreCallback(state: string): void;
137
+ /**
138
+ * Handles the value change of the textarea field.
139
+ * Sets the form value and updates the validity of the textarea field.
140
+ * @returns void
141
+ */
142
+ handleValueChange(): void;
143
+ protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
144
+ /**
145
+ * This function is called when the attribute changes.
146
+ * It updates the validity of the textarea field based on the textarea field's validity.
147
+ *
148
+ * @param name - attribute name
149
+ * @param old - old value
150
+ * @param value - new value
151
+ */
152
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
153
+ /**
154
+ * Dispatches the character overflow state change event.
155
+ * @returns void
156
+ */
157
+ private dispatchCharacterOverflowStateChangeEvent;
158
+ /**
159
+ * Handles the character overflow state change.
160
+ * Dispatches the character overflow state change event if the character limit is exceeded or restored.
161
+ * @returns void
162
+ */
163
+ private handleCharacterOverflowStateChange;
164
+ /**
165
+ * Updates the value of the textarea field.
166
+ * Sets the form value.
167
+ * @returns void
168
+ */
169
+ private updateValue;
170
+ /**
171
+ * Handles the change event of the textarea field.
172
+ * Updates the value and sets the validity of the textarea field.
173
+ *
174
+ * The 'change' event does not bubble up through the shadow DOM as it was not composed.
175
+ * Therefore, we need to re-dispatch the same event to ensure it is propagated correctly.
176
+ * Read more: https://developer.mozilla.org/en-US/docs/Web/API/Event/composed
177
+ *
178
+ * @param event - Event which contains information about the value change.
179
+ */
180
+ private onChange;
181
+ /**
182
+ * Handles the keydown event of the textarea field.
183
+ * Clears the textarea field when the 'Enter' key is pressed.
184
+ * @param event - Keyboard event
185
+ * @returns void
186
+ */
187
+ private handleKeyDown;
188
+ /**
189
+ * Clears the textarea field.
190
+ * @returns void
191
+ */
192
+ private clearInputText;
193
+ /**
194
+ * Renders the clear button to clear the textarea field if the clearButton is set to true.
195
+ * @returns void
196
+ */
197
+ protected renderClearButton(): import("lit-html").TemplateResult<1> | typeof nothing;
198
+ protected renderCharacterCounter(): import("lit-html").TemplateResult<1> | typeof nothing;
199
+ protected renderTextareaFooter(): import("lit-html").TemplateResult<1> | typeof nothing;
200
+ render(): import("lit-html").TemplateResult<1>;
201
+ static styles: Array<CSSResult>;
202
+ }
203
+ export default Textarea;