@momentum-design/components 0.142.4 → 0.142.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 +97 -94
- package/dist/browser/index.js.map +4 -4
- package/dist/components/calendar/calendar.component.js +8 -1
- package/dist/components/datepicker/datepicker.component.d.ts +1 -0
- package/dist/components/datepicker/datepicker.component.js +49 -8
- package/dist/components/textarea/textarea.component.d.ts +2 -2
- package/dist/components/textarea/textarea.component.js +2 -2
- package/dist/custom-elements.json +37 -5
- package/dist/react/textarea/index.d.ts +2 -2
- package/dist/react/textarea/index.js +2 -2
- package/package.json +1 -1
|
@@ -105,6 +105,8 @@ class Calendar extends KeyDownHandledMixin(KeyToActionMixin(Component)) {
|
|
|
105
105
|
if (dt) {
|
|
106
106
|
this.displayMonth = dt.getMonth() + 1;
|
|
107
107
|
this.displayYear = dt.getFullYear();
|
|
108
|
+
if (!this.gridHasFocus)
|
|
109
|
+
this.focusedDate = this.value;
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
@@ -294,6 +296,8 @@ class Calendar extends KeyDownHandledMixin(KeyToActionMixin(Component)) {
|
|
|
294
296
|
}));
|
|
295
297
|
}
|
|
296
298
|
handleGridKeydown(event) {
|
|
299
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
300
|
+
return;
|
|
297
301
|
const focusDt = this.focusedDate ? parseISO(this.focusedDate) : today();
|
|
298
302
|
if (!focusDt)
|
|
299
303
|
return;
|
|
@@ -443,8 +447,11 @@ class Calendar extends KeyDownHandledMixin(KeyToActionMixin(Component)) {
|
|
|
443
447
|
</div>
|
|
444
448
|
`;
|
|
445
449
|
}
|
|
446
|
-
handleGridFocusIn() {
|
|
450
|
+
handleGridFocusIn(event) {
|
|
447
451
|
this.gridHasFocus = true;
|
|
452
|
+
const target = event.target;
|
|
453
|
+
if (target.dataset.date)
|
|
454
|
+
this.focusedDate = target.dataset.date;
|
|
448
455
|
}
|
|
449
456
|
handleGridFocusOut() {
|
|
450
457
|
this.gridHasFocus = false;
|
|
@@ -201,6 +201,7 @@ declare class DatePicker extends DatePicker_base implements AssociatedFormContro
|
|
|
201
201
|
private getFieldValue;
|
|
202
202
|
private setFieldValue;
|
|
203
203
|
private handleSpinbuttonKeydown;
|
|
204
|
+
private handleSpinbuttonInput;
|
|
204
205
|
private handleDigitInput;
|
|
205
206
|
private advanceToNextField;
|
|
206
207
|
private advanceToPrevField;
|
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { html, nothing } from 'lit';
|
|
11
11
|
import { property, query, state } from 'lit/decorators.js';
|
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
|
+
import { live } from 'lit/directives/live.js';
|
|
13
14
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
|
14
15
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
|
15
16
|
import { parseISO, isBefore, isAfter } from '../../utils/date-utils';
|
|
@@ -187,7 +188,8 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
if (changedProperties.has('value') && !this.displayPopover) {
|
|
190
|
-
this.
|
|
191
|
+
if (this.value !== this.internalToValue())
|
|
192
|
+
this.parseValueToInternal();
|
|
191
193
|
this.syncFormValue();
|
|
192
194
|
}
|
|
193
195
|
else if (changedProperties.has('endValue') && !this.displayPopover) {
|
|
@@ -313,6 +315,11 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
313
315
|
this.syncFormValue();
|
|
314
316
|
this.notifyValueChange();
|
|
315
317
|
}
|
|
318
|
+
else if (this.value) {
|
|
319
|
+
this.value = '';
|
|
320
|
+
this.syncFormValue();
|
|
321
|
+
this.notifyValueChange();
|
|
322
|
+
}
|
|
316
323
|
}
|
|
317
324
|
notifyValueChange() {
|
|
318
325
|
const detail = { value: this.value, endValue: this.endValue };
|
|
@@ -449,7 +456,7 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
449
456
|
}
|
|
450
457
|
setFieldValue(field, val) {
|
|
451
458
|
const maxDigits = field === 'year' ? 4 : 2;
|
|
452
|
-
const padded = String(val).padStart(maxDigits, '0');
|
|
459
|
+
const padded = val === '' ? '' : String(val).padStart(maxDigits, '0');
|
|
453
460
|
switch (field) {
|
|
454
461
|
case 'month':
|
|
455
462
|
this.internalMonth = padded;
|
|
@@ -466,6 +473,8 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
466
473
|
this.requestUpdate();
|
|
467
474
|
}
|
|
468
475
|
handleSpinbuttonKeydown(event, field) {
|
|
476
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
477
|
+
return;
|
|
469
478
|
if (this.disabled || this.softDisabled || this.readonly) {
|
|
470
479
|
if (event.key === KEYS.ARROW_UP || event.key === KEYS.ARROW_DOWN)
|
|
471
480
|
event.preventDefault();
|
|
@@ -501,16 +510,45 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
501
510
|
case KEYS.TAB:
|
|
502
511
|
break;
|
|
503
512
|
default: {
|
|
504
|
-
if (
|
|
513
|
+
if (event.key.length === 1 && !/^\d$/.test(event.key)) {
|
|
505
514
|
event.preventDefault();
|
|
506
|
-
|
|
515
|
+
}
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
handleSpinbuttonInput(event, field) {
|
|
521
|
+
var _a;
|
|
522
|
+
if (this.preventSoftDisabledChange(event, this.getFieldValue(field)))
|
|
523
|
+
return;
|
|
524
|
+
event.stopPropagation();
|
|
525
|
+
if (this.disabled || this.readonly || event.isComposing)
|
|
526
|
+
return;
|
|
527
|
+
const input = event.target;
|
|
528
|
+
const range = this.getFieldRange(field);
|
|
529
|
+
if (event.data && /^\d+$/.test(event.data)) {
|
|
530
|
+
if (event.inputType === 'insertReplacementText')
|
|
531
|
+
this.pendingDigits = '';
|
|
532
|
+
this.handleDigitInput(event.data, field, range.min, range.max);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
if (this.pendingDigitTimeout)
|
|
536
|
+
clearTimeout(this.pendingDigitTimeout);
|
|
537
|
+
this.pendingDigits = '';
|
|
538
|
+
if (/^\d*$/.test(input.value)) {
|
|
539
|
+
const digits = input.value.slice(0, field === 'year' ? 4 : 2);
|
|
540
|
+
if (digits && !((_a = event.inputType) === null || _a === void 0 ? void 0 : _a.startsWith('delete'))) {
|
|
541
|
+
this.handleDigitInput(digits, field, range.min, range.max);
|
|
507
542
|
}
|
|
508
543
|
else {
|
|
509
|
-
|
|
544
|
+
const value = digits ? Math.min(range.max, Math.max(range.min, parseInt(digits, 10))) : '';
|
|
545
|
+
this.setFieldValue(field, value);
|
|
546
|
+
this.commitValue();
|
|
510
547
|
}
|
|
511
|
-
break;
|
|
512
548
|
}
|
|
513
549
|
}
|
|
550
|
+
// Native input can change the DOM even when the reactive value stays the same.
|
|
551
|
+
this.requestUpdate();
|
|
514
552
|
}
|
|
515
553
|
handleDigitInput(digit, field, minVal, maxVal) {
|
|
516
554
|
if (this.pendingDigitTimeout) {
|
|
@@ -673,17 +711,20 @@ class DatePicker extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)
|
|
|
673
711
|
aria-valuemin="${range.min}"
|
|
674
712
|
aria-valuemax="${range.max}"
|
|
675
713
|
aria-valuenow="${ifDefined(value ? parseInt(value, 10) : undefined)}"
|
|
714
|
+
aria-valuetext="${ifDefined(value ? String(parseInt(value, 10)) : undefined)}"
|
|
676
715
|
aria-description="${this.localeSpinbuttonDescription}"
|
|
677
|
-
.value="${value}"
|
|
716
|
+
.value="${live(value)}"
|
|
717
|
+
inputmode="numeric"
|
|
678
718
|
placeholder="${placeholderMap[field]}"
|
|
679
719
|
autocomplete="off"
|
|
680
720
|
?disabled="${this.disabled}"
|
|
681
721
|
?readonly="${this.readonly}"
|
|
682
722
|
aria-disabled="${this.disabled || this.softDisabled}"
|
|
683
723
|
@beforeinput="${this.preventSoftDisabledInput}"
|
|
684
|
-
@input="${(event) => this.preventSoftDisabledChange(event, value)}"
|
|
685
724
|
tabindex="${this.disabled ? '-1' : '0'}"
|
|
686
725
|
@keydown="${(e) => this.handleSpinbuttonKeydown(e, field)}"
|
|
726
|
+
@input="${(e) => this.handleSpinbuttonInput(e, field)}"
|
|
727
|
+
@change="${(e) => e.stopPropagation()}"
|
|
687
728
|
@focus="${this.handleSpinbuttonFocus}"
|
|
688
729
|
/>
|
|
689
730
|
`;
|
|
@@ -18,8 +18,8 @@ declare const Textarea_base: import("../../utils/mixins/index.types").Constructo
|
|
|
18
18
|
*
|
|
19
19
|
* @tagname mdc-textarea
|
|
20
20
|
*
|
|
21
|
-
* @event input - (React: onInput)
|
|
22
|
-
* @event change - (React: onChange)
|
|
21
|
+
* @event input - (React: onInput) Dispatched for each edit after the component and form values are updated.
|
|
22
|
+
* @event change - (React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.
|
|
23
23
|
* @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.
|
|
24
24
|
* @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.
|
|
25
25
|
* @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit
|
|
@@ -24,8 +24,8 @@ import styles from './textarea.styles';
|
|
|
24
24
|
/**
|
|
25
25
|
* @tagname mdc-textarea
|
|
26
26
|
*
|
|
27
|
-
* @event input - (React: onInput)
|
|
28
|
-
* @event change - (React: onChange)
|
|
27
|
+
* @event input - (React: onInput) Dispatched for each edit after the component and form values are updated.
|
|
28
|
+
* @event change - (React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.
|
|
29
29
|
* @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.
|
|
30
30
|
* @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.
|
|
31
31
|
* @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit
|
|
@@ -7646,7 +7646,15 @@
|
|
|
7646
7646
|
"type": {
|
|
7647
7647
|
"text": "void"
|
|
7648
7648
|
}
|
|
7649
|
-
}
|
|
7649
|
+
},
|
|
7650
|
+
"parameters": [
|
|
7651
|
+
{
|
|
7652
|
+
"name": "event",
|
|
7653
|
+
"type": {
|
|
7654
|
+
"text": "FocusEvent"
|
|
7655
|
+
}
|
|
7656
|
+
}
|
|
7657
|
+
]
|
|
7650
7658
|
},
|
|
7651
7659
|
{
|
|
7652
7660
|
"kind": "method",
|
|
@@ -16656,6 +16664,30 @@
|
|
|
16656
16664
|
}
|
|
16657
16665
|
]
|
|
16658
16666
|
},
|
|
16667
|
+
{
|
|
16668
|
+
"kind": "method",
|
|
16669
|
+
"name": "handleSpinbuttonInput",
|
|
16670
|
+
"privacy": "private",
|
|
16671
|
+
"return": {
|
|
16672
|
+
"type": {
|
|
16673
|
+
"text": "void"
|
|
16674
|
+
}
|
|
16675
|
+
},
|
|
16676
|
+
"parameters": [
|
|
16677
|
+
{
|
|
16678
|
+
"name": "event",
|
|
16679
|
+
"type": {
|
|
16680
|
+
"text": "InputEvent"
|
|
16681
|
+
}
|
|
16682
|
+
},
|
|
16683
|
+
{
|
|
16684
|
+
"name": "field",
|
|
16685
|
+
"type": {
|
|
16686
|
+
"text": "'month' | 'day' | 'year'"
|
|
16687
|
+
}
|
|
16688
|
+
}
|
|
16689
|
+
]
|
|
16690
|
+
},
|
|
16659
16691
|
{
|
|
16660
16692
|
"kind": "method",
|
|
16661
16693
|
"name": "handleSpinbuttonKeydown",
|
|
@@ -17091,7 +17123,7 @@
|
|
|
17091
17123
|
{
|
|
17092
17124
|
"name": "val",
|
|
17093
17125
|
"type": {
|
|
17094
|
-
"text": "number"
|
|
17126
|
+
"text": "number | ''"
|
|
17095
17127
|
}
|
|
17096
17128
|
}
|
|
17097
17129
|
]
|
|
@@ -52024,12 +52056,12 @@
|
|
|
52024
52056
|
}
|
|
52025
52057
|
},
|
|
52026
52058
|
{
|
|
52027
|
-
"description": "(React: onInput)
|
|
52059
|
+
"description": "(React: onInput) Dispatched for each edit after the component and form values are updated.",
|
|
52028
52060
|
"name": "input",
|
|
52029
52061
|
"reactName": "onInput"
|
|
52030
52062
|
},
|
|
52031
52063
|
{
|
|
52032
|
-
"description": "(React: onChange)
|
|
52064
|
+
"description": "(React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.",
|
|
52033
52065
|
"name": "change",
|
|
52034
52066
|
"reactName": "onChange"
|
|
52035
52067
|
},
|
|
@@ -52411,7 +52443,7 @@
|
|
|
52411
52443
|
"module": "/src/components/formfieldwrapper"
|
|
52412
52444
|
},
|
|
52413
52445
|
"tagName": "mdc-textarea",
|
|
52414
|
-
"jsDoc": "/**\n * @tagname mdc-textarea\n *\n * @event input - (React: onInput)
|
|
52446
|
+
"jsDoc": "/**\n * @tagname mdc-textarea\n *\n * @event input - (React: onInput) Dispatched for each edit after the component and form values are updated.\n * @event change - (React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.\n * @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.\n * @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.\n * @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit\n * exceeds or restored.\n *\n * @dependency mdc-button\n * @dependency mdc-icon\n * @dependency mdc-text\n * @dependency mdc-toggletip\n *\n * @slot label - Slot for the label element. If not provided, the `label` property will be used to render the label.\n * @slot toggletip - Slot for the toggletip info icon button. If not provided, the `toggletip-text` property will be used to render the info icon button and toggletip.\n * @slot help-icon - Slot for the helper/validation icon. If not provided, the icon will be rendered based on the `helpTextType` property.\n * @slot help-text - Slot for the helper/validation text. If not provided, the `helpText` property will be used to render the helper/validation text.\n *\n * @csspart label - The label element.\n * @csspart label-text - The container for the label and required indicator elements.\n * @csspart required-indicator - The required indicator element that is displayed next to the label when the `required` property is set to true.\n * @csspart info-icon-btn - The info icon button element that is displayed next to the label when the `toggletip-text` property is set.\n * @csspart label-toggletip - The toggletip element that is displayed when the info icon button is clicked.\n * @csspart textarea - The textarea element.\n * @csspart textarea-container - The container element that wraps the textarea and resize button.\n * @csspart textarea-footer - The footer element that contains the character counter.\n * @csspart character-counter - The character counter element.\n * @csspart resize-button - The resize button element (shown when `resizable` is true).\n * @csspart help-text - The helper/validation text element.\n * @csspart helper-icon - The helper/validation icon element that is displayed next to the helper/validation text.\n * @csspart help-text-container - The container for the helper/validation icon and text elements.\n *\n * @cssproperty --mdc-label-font-size - Font size for the label text.\n * @cssproperty --mdc-label-font-weight - Font weight for the label text.\n * @cssproperty --mdc-label-line-height - Line height for the label text.\n * @cssproperty --mdc-label-color - Color for the label text.\n * @cssproperty --mdc-help-text-font-size - Font size for the help text.\n * @cssproperty --mdc-help-text-font-weight - Font weight for the help text.\n * @cssproperty --mdc-help-text-line-height - Line height for the help text.\n * @cssproperty --mdc-help-text-color - Color for the help text.\n * @cssproperty --mdc-required-indicator-color - Color for the required indicator text.\n * @cssproperty --mdc-textarea-text-color - Text color for the textarea field\n * @cssproperty --mdc-textarea-background-color - Background color for the textarea field\n * @cssproperty --mdc-textarea-border-color - Border color for the textarea field\n * @cssproperty --mdc-textarea-text-secondary-normal - Text color for the character counter\n * @cssproperty --mdc-textarea-text-font-size - Font size for the textarea field\n * @cssproperty --mdc-textarea-text-line-height - Line height for the textarea field\n * @cssproperty --mdc-textarea-container-background-color - Background color for the textarea container\n */",
|
|
52415
52447
|
"customElement": true
|
|
52416
52448
|
}
|
|
52417
52449
|
],
|
|
@@ -17,8 +17,8 @@ import type { Events as EventsInherited } from '../../utils/mixins/CharacterLimi
|
|
|
17
17
|
*
|
|
18
18
|
* @tagname mdc-textarea
|
|
19
19
|
*
|
|
20
|
-
* @event input - (React: onInput)
|
|
21
|
-
* @event change - (React: onChange)
|
|
20
|
+
* @event input - (React: onInput) Dispatched for each edit after the component and form values are updated.
|
|
21
|
+
* @event change - (React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.
|
|
22
22
|
* @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.
|
|
23
23
|
* @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.
|
|
24
24
|
* @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit
|
|
@@ -5,8 +5,8 @@ import { TAG_NAME } from '../../components/textarea/textarea.constants';
|
|
|
5
5
|
/**
|
|
6
6
|
* @tagname mdc-textarea
|
|
7
7
|
*
|
|
8
|
-
* @event input - (React: onInput)
|
|
9
|
-
* @event change - (React: onChange)
|
|
8
|
+
* @event input - (React: onInput) Dispatched for each edit after the component and form values are updated.
|
|
9
|
+
* @event change - (React: onChange) Re-dispatched when the native textarea commits a value change, usually on blur. In the React wrapper, this differs from React's native textarea onChange, which fires for each edit.
|
|
10
10
|
* @event focus - (React: onFocus) This event is dispatched when the textarea receives focus.
|
|
11
11
|
* @event blur - (React: onBlur) This event is dispatched when the textarea loses focus.
|
|
12
12
|
* @event limitexceeded - (React: onLimitExceeded) This event is dispatched once when the character limit
|