@limetech/lime-elements 35.0.0-next.9 → 35.0.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.
- package/dist/cjs/checkbox.template-b6c6562c.js +43 -0
- package/dist/cjs/{component-f7ef9087.js → component-66df95e7.js} +190 -132
- package/dist/cjs/{component-f532119f.js → component-67144c1c.js} +47 -3
- package/dist/cjs/{component-ed21410d.js → component-ae3bfacf.js} +367 -235
- package/dist/cjs/{component-2faaa141.js → component-cf490570.js} +213 -143
- package/dist/cjs/{component-10dbdd60.js → component-dd795ff0.js} +7 -5
- package/dist/cjs/{dateFormatter-26eac73a.js → dateFormatter-34b77ead.js} +37 -31
- package/dist/cjs/{index-e63a89d7.js → index-2a28697b.js} +27 -1
- package/dist/cjs/lime-elements.cjs.js +3 -3
- package/dist/cjs/limel-badge.cjs.entry.js +4 -4
- package/dist/cjs/limel-banner.cjs.entry.js +2 -2
- package/dist/cjs/limel-button-group.cjs.entry.js +3 -3
- package/dist/cjs/limel-button.cjs.entry.js +3 -3
- package/dist/cjs/limel-checkbox.cjs.entry.js +136 -90
- package/dist/cjs/limel-chip-set.cjs.entry.js +235 -191
- package/dist/cjs/limel-circular-progress.cjs.entry.js +3 -3
- package/dist/cjs/limel-code-editor.cjs.entry.js +50 -23
- package/dist/cjs/limel-collapsible-section.cjs.entry.js +2 -2
- package/dist/cjs/limel-color-picker-palette_2.cjs.entry.js +3 -3
- package/dist/cjs/limel-color-picker.cjs.entry.js +2 -2
- package/dist/cjs/limel-config.cjs.entry.js +2 -2
- package/dist/cjs/limel-date-picker.cjs.entry.js +8 -8
- package/dist/cjs/limel-dialog.cjs.entry.js +9 -10
- package/dist/cjs/limel-file.cjs.entry.js +11 -9
- package/dist/cjs/limel-flatpickr-adapter.cjs.entry.js +971 -657
- package/dist/cjs/limel-flex-container.cjs.entry.js +6 -2
- package/dist/cjs/limel-form.cjs.entry.js +423 -449
- package/dist/cjs/limel-grid.cjs.entry.js +2 -2
- package/dist/cjs/limel-header.cjs.entry.js +2 -2
- package/dist/cjs/limel-icon-button.cjs.entry.js +6 -6
- package/dist/cjs/limel-icon.cjs.entry.js +2 -2
- package/dist/cjs/limel-input-field.cjs.entry.js +12 -10
- package/dist/cjs/limel-linear-progress.cjs.entry.js +4 -4
- package/dist/cjs/limel-list_3.cjs.entry.js +154 -91
- package/dist/cjs/limel-menu-list.cjs.entry.js +87 -74
- package/dist/cjs/limel-menu.cjs.entry.js +2 -2
- package/dist/cjs/limel-picker.cjs.entry.js +4 -7
- package/dist/cjs/limel-popover-surface.cjs.entry.js +3 -3
- package/dist/cjs/limel-progress-flow-item.cjs.entry.js +2 -2
- package/dist/cjs/limel-progress-flow.cjs.entry.js +2 -2
- package/dist/cjs/limel-select.cjs.entry.js +6 -6
- package/dist/cjs/limel-slider.cjs.entry.js +34 -7
- package/dist/cjs/limel-snackbar.cjs.entry.js +79 -73
- package/dist/cjs/limel-spinner.cjs.entry.js +2 -2
- package/dist/cjs/limel-switch.cjs.entry.js +498 -202
- package/dist/cjs/limel-tab-bar.cjs.entry.js +263 -186
- package/dist/cjs/limel-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/limel-table.cjs.entry.js +73 -13
- package/dist/cjs/limel-tooltip_2.cjs.entry.js +3 -3
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{moment-d287c0ed.js → moment-5c6581b7.js} +94 -79
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/badge/badge.css +9 -15
- package/dist/collection/components/badge/badge.js +2 -2
- package/dist/collection/components/button/button.css +333 -145
- package/dist/collection/components/button-group/button-group.css +30 -5
- package/dist/collection/components/checkbox/checkbox.css +71 -20
- package/dist/collection/components/checkbox/checkbox.js +5 -4
- package/dist/collection/components/checkbox/checkbox.template.js +24 -20
- package/dist/collection/components/chip-set/chip-set.css +367 -34
- package/dist/collection/components/circular-progress/circular-progress.css +2 -2
- package/dist/collection/components/code-editor/code-editor.css +8 -13
- package/dist/collection/components/date-picker/flatpickr-adapter/flatpickr-adapter.css +1 -1
- package/dist/collection/components/dialog/dialog.css +153 -109
- package/dist/collection/components/dialog/dialog.js +7 -0
- package/dist/collection/components/file/icon-background-colors.js +2 -1
- package/dist/collection/components/file/icon-fill-colors.js +2 -1
- package/dist/collection/components/file/icons.js +1 -1
- package/dist/collection/components/flex-container/flex-container.js +10 -0
- package/dist/collection/components/form/fields/schema-field.js +0 -1
- package/dist/collection/components/form/form.css +5 -1
- package/dist/collection/components/form/form.js +34 -0
- package/dist/collection/components/form/form.types.js +0 -1
- package/dist/collection/components/form/templates/common.js +4 -1
- package/dist/collection/components/icon-button/icon-button.css +116 -59
- package/dist/collection/components/icon-button/icon-button.js +1 -0
- package/dist/collection/components/input-field/input-field.css +344 -29
- package/dist/collection/components/input-field/input-field.js +5 -3
- package/dist/collection/components/linear-progress/linear-progress.css +14 -2
- package/dist/collection/components/list/list-renderer.js +1 -4
- package/dist/collection/components/list/list.css +938 -93
- package/dist/collection/components/list/list.js +13 -6
- package/dist/collection/components/menu-list/menu-list-renderer.js +1 -4
- package/dist/collection/components/menu-list/menu-list.css +938 -93
- package/dist/collection/components/menu-surface/menu-surface.css +31 -7
- package/dist/collection/components/picker/picker.js +4 -6
- package/dist/collection/components/popover-surface/popover-surface.css +1 -0
- package/dist/collection/components/select/select.css +424 -17
- package/dist/collection/components/select/select.template.js +1 -1
- package/dist/collection/components/slider/slider.css +49 -2
- package/dist/collection/components/snackbar/snackbar.css +588 -301
- package/dist/collection/components/switch/switch.css +592 -222
- package/dist/collection/components/switch/switch.js +18 -12
- package/dist/collection/components/tab-bar/tab-bar.css +77 -48
- package/dist/collection/components/table/table.css +219 -165
- package/dist/collection/components/table/table.js +99 -15
- package/dist/collection/components/table/table.types.js +0 -1
- package/dist/collection/style/functions.scss +3 -1
- package/dist/collection/style/internal/lime-theme.scss +30 -31
- package/dist/collection/style/internal/lime-typography.scss +55 -56
- package/dist/esm/checkbox.template-2f1bbc98.js +41 -0
- package/dist/esm/{component-89e0ce26.js → component-19eb6e2b.js} +7 -5
- package/dist/esm/{component-2630c3d7.js → component-288691f3.js} +367 -235
- package/dist/esm/{component-d682c974.js → component-410aad5a.js} +44 -4
- package/dist/esm/{component-429e92ee.js → component-5b4ac85a.js} +213 -143
- package/dist/esm/{component-834d85a1.js → component-fffa3419.js} +190 -132
- package/dist/esm/{dateFormatter-c9b41548.js → dateFormatter-ed618478.js} +37 -31
- package/dist/esm/{index-2316f345.js → index-11cd0b60.js} +27 -1
- package/dist/esm/lime-elements.js +3 -3
- package/dist/esm/limel-badge.entry.js +4 -4
- package/dist/esm/limel-banner.entry.js +2 -2
- package/dist/esm/limel-button-group.entry.js +3 -3
- package/dist/esm/limel-button.entry.js +3 -3
- package/dist/esm/limel-checkbox.entry.js +136 -90
- package/dist/esm/limel-chip-set.entry.js +235 -191
- package/dist/esm/limel-circular-progress.entry.js +3 -3
- package/dist/esm/limel-code-editor.entry.js +50 -23
- package/dist/esm/limel-collapsible-section.entry.js +2 -2
- package/dist/esm/limel-color-picker-palette_2.entry.js +3 -3
- package/dist/esm/limel-color-picker.entry.js +2 -2
- package/dist/esm/limel-config.entry.js +2 -2
- package/dist/esm/limel-date-picker.entry.js +8 -8
- package/dist/esm/limel-dialog.entry.js +9 -10
- package/dist/esm/limel-file.entry.js +11 -9
- package/dist/esm/limel-flatpickr-adapter.entry.js +971 -657
- package/dist/esm/limel-flex-container.entry.js +6 -2
- package/dist/esm/limel-form.entry.js +424 -450
- package/dist/esm/limel-grid.entry.js +2 -2
- package/dist/esm/limel-header.entry.js +2 -2
- package/dist/esm/limel-icon-button.entry.js +6 -6
- package/dist/esm/limel-icon.entry.js +2 -2
- package/dist/esm/limel-input-field.entry.js +12 -10
- package/dist/esm/limel-linear-progress.entry.js +4 -4
- package/dist/esm/limel-list_3.entry.js +154 -91
- package/dist/esm/limel-menu-list.entry.js +87 -74
- package/dist/esm/limel-menu.entry.js +2 -2
- package/dist/esm/limel-picker.entry.js +4 -7
- package/dist/esm/limel-popover-surface.entry.js +3 -3
- package/dist/esm/limel-progress-flow-item.entry.js +2 -2
- package/dist/esm/limel-progress-flow.entry.js +2 -2
- package/dist/esm/limel-select.entry.js +6 -6
- package/dist/esm/limel-slider.entry.js +34 -7
- package/dist/esm/limel-snackbar.entry.js +79 -73
- package/dist/esm/limel-spinner.entry.js +2 -2
- package/dist/esm/limel-switch.entry.js +498 -202
- package/dist/esm/limel-tab-bar.entry.js +263 -186
- package/dist/esm/limel-tab-panel.entry.js +2 -2
- package/dist/esm/limel-table.entry.js +73 -13
- package/dist/esm/limel-tooltip_2.entry.js +3 -3
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{moment-8dadd938.js → moment-29c213b7.js} +94 -79
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/p-04b5bc13.entry.js +82 -0
- package/dist/lime-elements/p-101af376.entry.js +1 -0
- package/dist/lime-elements/p-1c284626.js +73 -0
- package/dist/lime-elements/p-1ede893b.js +1 -0
- package/dist/lime-elements/p-2639edf9.entry.js +73 -0
- package/dist/lime-elements/p-2da6e2a3.entry.js +1 -0
- package/dist/lime-elements/p-2ff40ce6.js +3 -0
- package/dist/lime-elements/{p-887d5bda.entry.js → p-358706b6.entry.js} +1 -1
- package/dist/lime-elements/p-36ecbd03.entry.js +1 -0
- package/dist/lime-elements/p-404e1465.entry.js +1 -0
- package/dist/lime-elements/p-42b67933.entry.js +1 -0
- package/dist/lime-elements/p-440454ed.entry.js +1 -0
- package/dist/lime-elements/{p-076bd4dc.js → p-48d4ef20.js} +3 -3
- package/dist/lime-elements/p-53e01330.entry.js +1 -0
- package/dist/lime-elements/p-5908c21d.entry.js +1 -0
- package/dist/lime-elements/p-5b7a8c61.entry.js +20 -0
- package/dist/lime-elements/p-63e25a0a.entry.js +1 -0
- package/dist/lime-elements/p-6e7809a6.entry.js +1 -0
- package/dist/lime-elements/p-705334c1.entry.js +1 -0
- package/dist/lime-elements/p-716a6acd.entry.js +16 -0
- package/dist/lime-elements/p-71efe2ca.entry.js +37 -0
- package/dist/lime-elements/{p-e1928c0e.js → p-72e03943.js} +1 -1
- package/dist/lime-elements/p-80327bb8.entry.js +16 -0
- package/dist/lime-elements/p-83ea517b.entry.js +1 -0
- package/dist/lime-elements/p-87a1e1cb.entry.js +1 -0
- package/dist/lime-elements/{p-8ad5e143.entry.js → p-94899019.entry.js} +1 -1
- package/dist/lime-elements/p-95f275ab.entry.js +1 -0
- package/dist/lime-elements/p-96f4b892.entry.js +131 -0
- package/dist/lime-elements/p-97d6c4a6.entry.js +1 -0
- package/dist/lime-elements/p-a465084b.entry.js +82 -0
- package/dist/lime-elements/p-a5af84a7.entry.js +1 -0
- package/dist/lime-elements/p-b91dc1ef.entry.js +1 -0
- package/dist/lime-elements/p-bd8c9384.entry.js +1 -0
- package/dist/lime-elements/p-c4b38454.entry.js +1 -0
- package/dist/lime-elements/p-c7953a05.entry.js +82 -0
- package/dist/lime-elements/p-c80acfb2.entry.js +59 -0
- package/dist/lime-elements/p-cbc43682.js +81 -0
- package/dist/lime-elements/{p-ace9affc.js → p-d0a7de87.js} +2 -2
- package/dist/lime-elements/p-d1ee4501.entry.js +37 -0
- package/dist/lime-elements/p-d74fa89e.entry.js +1 -0
- package/dist/lime-elements/p-da962c64.entry.js +1 -0
- package/dist/lime-elements/p-dfba92de.js +126 -0
- package/dist/lime-elements/p-dfbe015e.entry.js +1 -0
- package/dist/lime-elements/p-e83dddcd.entry.js +126 -0
- package/dist/lime-elements/p-e98d76e8.entry.js +59 -0
- package/dist/lime-elements/{p-92146da6.js → p-e9a95b8f.js} +1 -1
- package/dist/lime-elements/p-eae8c615.entry.js +1 -0
- package/dist/lime-elements/p-ed65468d.entry.js +1 -0
- package/dist/lime-elements/p-f0c9dadd.entry.js +1 -0
- package/dist/lime-elements/style/functions.scss +3 -1
- package/dist/lime-elements/style/internal/lime-theme.scss +30 -31
- package/dist/lime-elements/style/internal/lime-typography.scss +55 -56
- package/dist/types/components/badge/badge.d.ts +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +3 -2
- package/dist/types/components/checkbox/checkbox.template.d.ts +1 -0
- package/dist/types/components/dialog/dialog.d.ts +7 -0
- package/dist/types/components/flex-container/flex-container.d.ts +7 -0
- package/dist/types/components/form/fields/array-field.d.ts +0 -1
- package/dist/types/components/form/fields/object-field.d.ts +2 -2
- package/dist/types/components/form/form.d.ts +8 -1
- package/dist/types/components/form/form.types.d.ts +6 -0
- package/dist/types/components/picker/picker.d.ts +2 -1
- package/dist/types/components/switch/switch.d.ts +2 -2
- package/dist/types/components/table/table.d.ts +10 -1
- package/dist/types/components/table/table.types.d.ts +13 -0
- package/dist/types/components.d.ts +20 -4
- package/dist/types/stencil-public-runtime.d.ts +6 -4
- package/package.json +30 -43
- package/dist/cjs/checkbox.template-50eb8b76.js +0 -39
- package/dist/esm/checkbox.template-50f7c07b.js +0 -37
- package/dist/lime-elements/p-041ae00c.entry.js +0 -1
- package/dist/lime-elements/p-0ce9165f.entry.js +0 -1
- package/dist/lime-elements/p-0fd208f3.entry.js +0 -82
- package/dist/lime-elements/p-143705b1.entry.js +0 -1
- package/dist/lime-elements/p-1876a96a.entry.js +0 -1
- package/dist/lime-elements/p-1fb5340d.entry.js +0 -1
- package/dist/lime-elements/p-250f55be.js +0 -1
- package/dist/lime-elements/p-29f054cc.entry.js +0 -37
- package/dist/lime-elements/p-31fecf5d.entry.js +0 -1
- package/dist/lime-elements/p-34c7872e.entry.js +0 -1
- package/dist/lime-elements/p-3ae6bb75.entry.js +0 -82
- package/dist/lime-elements/p-3ae6dfba.entry.js +0 -73
- package/dist/lime-elements/p-468e940e.entry.js +0 -16
- package/dist/lime-elements/p-4932c029.entry.js +0 -1
- package/dist/lime-elements/p-4b5af81b.entry.js +0 -1
- package/dist/lime-elements/p-510bb5a4.entry.js +0 -1
- package/dist/lime-elements/p-58cbe99d.entry.js +0 -1
- package/dist/lime-elements/p-597cbe05.entry.js +0 -1
- package/dist/lime-elements/p-6003f817.entry.js +0 -1
- package/dist/lime-elements/p-668795a7.js +0 -73
- package/dist/lime-elements/p-714fde78.entry.js +0 -1
- package/dist/lime-elements/p-7476efe0.entry.js +0 -1
- package/dist/lime-elements/p-8a2c1038.entry.js +0 -16
- package/dist/lime-elements/p-902347b9.js +0 -81
- package/dist/lime-elements/p-90c6fa15.js +0 -126
- package/dist/lime-elements/p-90f3e17c.entry.js +0 -37
- package/dist/lime-elements/p-a2cf74c1.entry.js +0 -1
- package/dist/lime-elements/p-a397bab7.js +0 -3
- package/dist/lime-elements/p-a4c532a7.entry.js +0 -1
- package/dist/lime-elements/p-be56ffab.entry.js +0 -1
- package/dist/lime-elements/p-c306c953.entry.js +0 -1
- package/dist/lime-elements/p-c35874db.entry.js +0 -1
- package/dist/lime-elements/p-c8c8a946.entry.js +0 -59
- package/dist/lime-elements/p-ca664c9f.entry.js +0 -1
- package/dist/lime-elements/p-d2c74396.entry.js +0 -1
- package/dist/lime-elements/p-d48ad9f7.entry.js +0 -126
- package/dist/lime-elements/p-d93a3b07.entry.js +0 -16
- package/dist/lime-elements/p-df8faeb4.entry.js +0 -59
- package/dist/lime-elements/p-dfe0a58b.entry.js +0 -1
- package/dist/lime-elements/p-e275f502.entry.js +0 -37
- package/dist/lime-elements/p-e881e98d.entry.js +0 -1
- package/dist/lime-elements/p-f2c706b8.entry.js +0 -131
- package/dist/lime-elements/p-fc30b8e3.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MDCFoundation, a as MDCComponent } from './component-
|
|
1
|
+
import { M as MDCFoundation, a as MDCComponent } from './component-410aad5a.js';
|
|
2
2
|
import { m as matches, c as closest } from './ponyfill-30263d5e.js';
|
|
3
3
|
import { n as normalizeKey } from './keyboard-4b9e12e3.js';
|
|
4
4
|
import { g as getCorrectPropertyName } from './util-f1bde91c.js';
|
|
@@ -54,10 +54,23 @@ var numbers$1 = {
|
|
|
54
54
|
TRANSITION_OPEN_DURATION: 120,
|
|
55
55
|
/** Total duration of menu-surface close animation. */
|
|
56
56
|
TRANSITION_CLOSE_DURATION: 75,
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Margin left to the edge of the viewport when menu-surface is at maximum
|
|
59
|
+
* possible height. Also used as a viewport margin.
|
|
60
|
+
*/
|
|
58
61
|
MARGIN_TO_EDGE: 32,
|
|
59
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Ratio of anchor width to menu-surface width for switching from corner
|
|
64
|
+
* positioning to center positioning.
|
|
65
|
+
*/
|
|
60
66
|
ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
|
|
67
|
+
/**
|
|
68
|
+
* Amount of time to wait before restoring focus when closing the menu
|
|
69
|
+
* surface. This is important because if a touch event triggered the menu
|
|
70
|
+
* close, and the subsequent mouse event occurs after focus is restored, then
|
|
71
|
+
* the restored focus would be lost.
|
|
72
|
+
*/
|
|
73
|
+
TOUCH_EVENT_WAIT_MS: 30,
|
|
61
74
|
};
|
|
62
75
|
/**
|
|
63
76
|
* Enum for bits in the {@see Corner) bitmap.
|
|
@@ -556,16 +569,16 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
556
569
|
__extends$1(MDCListFoundation, _super);
|
|
557
570
|
function MDCListFoundation(adapter) {
|
|
558
571
|
var _this = _super.call(this, __assign$1(__assign$1({}, MDCListFoundation.defaultAdapter), adapter)) || this;
|
|
559
|
-
_this.
|
|
560
|
-
_this.
|
|
561
|
-
_this.
|
|
562
|
-
_this.
|
|
572
|
+
_this.wrapFocus = false;
|
|
573
|
+
_this.isVertical = true;
|
|
574
|
+
_this.isSingleSelectionList = false;
|
|
575
|
+
_this.selectedIndex = numbers.UNSET_INDEX;
|
|
563
576
|
_this.focusedItemIndex = numbers.UNSET_INDEX;
|
|
564
|
-
_this.
|
|
565
|
-
_this.
|
|
566
|
-
_this.
|
|
567
|
-
_this.
|
|
568
|
-
_this.
|
|
577
|
+
_this.useActivatedClass = false;
|
|
578
|
+
_this.useSelectedAttr = false;
|
|
579
|
+
_this.ariaCurrentAttrValue = null;
|
|
580
|
+
_this.isCheckboxList = false;
|
|
581
|
+
_this.isRadioList = false;
|
|
569
582
|
_this.hasTypeahead = false;
|
|
570
583
|
// Transiently holds current typeahead prefix from user.
|
|
571
584
|
_this.typeaheadState = initState();
|
|
@@ -624,10 +637,10 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
624
637
|
}
|
|
625
638
|
// TODO(b/172274142): consider all items when determining the list's type.
|
|
626
639
|
if (this.adapter.hasCheckboxAtIndex(0)) {
|
|
627
|
-
this.
|
|
640
|
+
this.isCheckboxList = true;
|
|
628
641
|
}
|
|
629
642
|
else if (this.adapter.hasRadioAtIndex(0)) {
|
|
630
|
-
this.
|
|
643
|
+
this.isRadioList = true;
|
|
631
644
|
}
|
|
632
645
|
else {
|
|
633
646
|
this.maybeInitializeSingleSelection();
|
|
@@ -636,25 +649,27 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
636
649
|
this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
|
|
637
650
|
}
|
|
638
651
|
};
|
|
639
|
-
/**
|
|
640
|
-
|
|
641
|
-
|
|
652
|
+
/** Returns the index of the item that was last focused. */
|
|
653
|
+
MDCListFoundation.prototype.getFocusedItemIndex = function () {
|
|
654
|
+
return this.focusedItemIndex;
|
|
655
|
+
};
|
|
656
|
+
/** Toggles focus wrapping with keyboard navigation. */
|
|
642
657
|
MDCListFoundation.prototype.setWrapFocus = function (value) {
|
|
643
|
-
this.
|
|
658
|
+
this.wrapFocus = value;
|
|
644
659
|
};
|
|
645
660
|
/**
|
|
646
|
-
*
|
|
661
|
+
* Toggles orientation direction for keyboard navigation (true for vertical,
|
|
662
|
+
* false for horizontal).
|
|
647
663
|
*/
|
|
648
664
|
MDCListFoundation.prototype.setVerticalOrientation = function (value) {
|
|
649
|
-
this.
|
|
665
|
+
this.isVertical = value;
|
|
650
666
|
};
|
|
651
|
-
/**
|
|
652
|
-
* Sets the isSingleSelectionList_ private variable.
|
|
653
|
-
*/
|
|
667
|
+
/** Toggles single-selection behavior. */
|
|
654
668
|
MDCListFoundation.prototype.setSingleSelection = function (value) {
|
|
655
|
-
this.
|
|
669
|
+
this.isSingleSelectionList = value;
|
|
656
670
|
if (value) {
|
|
657
671
|
this.maybeInitializeSingleSelection();
|
|
672
|
+
this.selectedIndex = this.getSelectedIndexFromDOM();
|
|
658
673
|
}
|
|
659
674
|
};
|
|
660
675
|
/**
|
|
@@ -662,6 +677,19 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
662
677
|
* initializes the internal state to match the selected item.
|
|
663
678
|
*/
|
|
664
679
|
MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
|
|
680
|
+
var selectedItemIndex = this.getSelectedIndexFromDOM();
|
|
681
|
+
if (selectedItemIndex === numbers.UNSET_INDEX)
|
|
682
|
+
return;
|
|
683
|
+
var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, cssClasses.LIST_ITEM_ACTIVATED_CLASS);
|
|
684
|
+
if (hasActivatedClass) {
|
|
685
|
+
this.setUseActivatedClass(true);
|
|
686
|
+
}
|
|
687
|
+
this.isSingleSelectionList = true;
|
|
688
|
+
this.selectedIndex = selectedItemIndex;
|
|
689
|
+
};
|
|
690
|
+
/** @return Index of the first selected item based on the DOM state. */
|
|
691
|
+
MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
|
|
692
|
+
var selectedIndex = numbers.UNSET_INDEX;
|
|
665
693
|
var listItemsCount = this.adapter.getListItemCount();
|
|
666
694
|
for (var i = 0; i < listItemsCount; i++) {
|
|
667
695
|
var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, cssClasses.LIST_ITEM_SELECTED_CLASS);
|
|
@@ -669,13 +697,10 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
669
697
|
if (!(hasSelectedClass || hasActivatedClass)) {
|
|
670
698
|
continue;
|
|
671
699
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
this.isSingleSelectionList_ = true;
|
|
676
|
-
this.selectedIndex_ = i;
|
|
677
|
-
return;
|
|
700
|
+
selectedIndex = i;
|
|
701
|
+
break;
|
|
678
702
|
}
|
|
703
|
+
return selectedIndex;
|
|
679
704
|
};
|
|
680
705
|
/**
|
|
681
706
|
* Sets whether typeahead is enabled on the list.
|
|
@@ -694,39 +719,39 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
694
719
|
return this.hasTypeahead &&
|
|
695
720
|
isTypingInProgress(this.typeaheadState);
|
|
696
721
|
};
|
|
697
|
-
/**
|
|
698
|
-
* Sets the useActivatedClass_ private variable.
|
|
699
|
-
*/
|
|
722
|
+
/** Toggle use of the "activated" CSS class. */
|
|
700
723
|
MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
|
|
701
|
-
this.
|
|
724
|
+
this.useActivatedClass = useActivated;
|
|
702
725
|
};
|
|
703
726
|
/**
|
|
704
|
-
*
|
|
727
|
+
* Toggles use of the selected attribute (true for aria-selected, false for
|
|
728
|
+
* aria-checked).
|
|
705
729
|
*/
|
|
706
730
|
MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
|
|
707
|
-
this.
|
|
731
|
+
this.useSelectedAttr = useSelected;
|
|
708
732
|
};
|
|
709
733
|
MDCListFoundation.prototype.getSelectedIndex = function () {
|
|
710
|
-
return this.
|
|
734
|
+
return this.selectedIndex;
|
|
711
735
|
};
|
|
712
|
-
MDCListFoundation.prototype.setSelectedIndex = function (index) {
|
|
713
|
-
|
|
736
|
+
MDCListFoundation.prototype.setSelectedIndex = function (index, _a) {
|
|
737
|
+
var _b = _a === void 0 ? {} : _a, forceUpdate = _b.forceUpdate;
|
|
738
|
+
if (!this.isIndexValid(index)) {
|
|
714
739
|
return;
|
|
715
740
|
}
|
|
716
|
-
if (this.
|
|
717
|
-
this.
|
|
741
|
+
if (this.isCheckboxList) {
|
|
742
|
+
this.setCheckboxAtIndex(index);
|
|
718
743
|
}
|
|
719
|
-
else if (this.
|
|
720
|
-
this.
|
|
744
|
+
else if (this.isRadioList) {
|
|
745
|
+
this.setRadioAtIndex(index);
|
|
721
746
|
}
|
|
722
747
|
else {
|
|
723
|
-
this.
|
|
748
|
+
this.setSingleSelectionAtIndex(index, { forceUpdate: forceUpdate });
|
|
724
749
|
}
|
|
725
750
|
};
|
|
726
751
|
/**
|
|
727
752
|
* Focus in handler for the list items.
|
|
728
753
|
*/
|
|
729
|
-
MDCListFoundation.prototype.handleFocusIn = function (
|
|
754
|
+
MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
|
|
730
755
|
if (listItemIndex >= 0) {
|
|
731
756
|
this.focusedItemIndex = listItemIndex;
|
|
732
757
|
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
|
|
@@ -736,7 +761,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
736
761
|
/**
|
|
737
762
|
* Focus out handler for the list items.
|
|
738
763
|
*/
|
|
739
|
-
MDCListFoundation.prototype.handleFocusOut = function (
|
|
764
|
+
MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
|
|
740
765
|
var _this = this;
|
|
741
766
|
if (listItemIndex >= 0) {
|
|
742
767
|
this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
|
|
@@ -765,7 +790,8 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
765
790
|
var isEnd = normalizeKey(event) === 'End';
|
|
766
791
|
var isEnter = normalizeKey(event) === 'Enter';
|
|
767
792
|
var isSpace = normalizeKey(event) === 'Spacebar';
|
|
768
|
-
// Have to check both upper and lower case, because having caps lock on
|
|
793
|
+
// Have to check both upper and lower case, because having caps lock on
|
|
794
|
+
// affects the value.
|
|
769
795
|
var isLetterA = event.key === 'A' || event.key === 'a';
|
|
770
796
|
if (this.adapter.isRootFocused()) {
|
|
771
797
|
if (isArrowUp || isEnd) {
|
|
@@ -802,12 +828,12 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
802
828
|
return;
|
|
803
829
|
}
|
|
804
830
|
}
|
|
805
|
-
if ((this.
|
|
806
|
-
(!this.
|
|
831
|
+
if ((this.isVertical && isArrowDown) ||
|
|
832
|
+
(!this.isVertical && isArrowRight)) {
|
|
807
833
|
preventDefaultEvent(event);
|
|
808
834
|
this.focusNextElement(currentIndex);
|
|
809
835
|
}
|
|
810
|
-
else if ((this.
|
|
836
|
+
else if ((this.isVertical && isArrowUp) || (!this.isVertical && isArrowLeft)) {
|
|
811
837
|
preventDefaultEvent(event);
|
|
812
838
|
this.focusPrevElement(currentIndex);
|
|
813
839
|
}
|
|
@@ -819,9 +845,11 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
819
845
|
preventDefaultEvent(event);
|
|
820
846
|
this.focusLastElement();
|
|
821
847
|
}
|
|
822
|
-
else if (isLetterA && event.ctrlKey && this.
|
|
848
|
+
else if (isLetterA && event.ctrlKey && this.isCheckboxList) {
|
|
823
849
|
event.preventDefault();
|
|
824
|
-
this.toggleAll(this.
|
|
850
|
+
this.toggleAll(this.selectedIndex === numbers.UNSET_INDEX ?
|
|
851
|
+
[] :
|
|
852
|
+
this.selectedIndex);
|
|
825
853
|
}
|
|
826
854
|
else if (isEnter || isSpace) {
|
|
827
855
|
if (isRootListItem) {
|
|
@@ -836,8 +864,8 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
836
864
|
return;
|
|
837
865
|
}
|
|
838
866
|
if (!this.isTypeaheadInProgress()) {
|
|
839
|
-
if (this.
|
|
840
|
-
this.
|
|
867
|
+
if (this.isSelectableList()) {
|
|
868
|
+
this.setSelectedIndexOnAction(currentIndex);
|
|
841
869
|
}
|
|
842
870
|
this.adapter.notifyAction(currentIndex);
|
|
843
871
|
}
|
|
@@ -867,8 +895,8 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
867
895
|
if (this.adapter.listItemAtIndexHasClass(index, cssClasses.LIST_ITEM_DISABLED_CLASS)) {
|
|
868
896
|
return;
|
|
869
897
|
}
|
|
870
|
-
if (this.
|
|
871
|
-
this.
|
|
898
|
+
if (this.isSelectableList()) {
|
|
899
|
+
this.setSelectedIndexOnAction(index, toggleCheckbox);
|
|
872
900
|
}
|
|
873
901
|
this.adapter.notifyAction(index);
|
|
874
902
|
};
|
|
@@ -879,7 +907,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
879
907
|
var count = this.adapter.getListItemCount();
|
|
880
908
|
var nextIndex = index + 1;
|
|
881
909
|
if (nextIndex >= count) {
|
|
882
|
-
if (this.
|
|
910
|
+
if (this.wrapFocus) {
|
|
883
911
|
nextIndex = 0;
|
|
884
912
|
}
|
|
885
913
|
else {
|
|
@@ -896,7 +924,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
896
924
|
MDCListFoundation.prototype.focusPrevElement = function (index) {
|
|
897
925
|
var prevIndex = index - 1;
|
|
898
926
|
if (prevIndex < 0) {
|
|
899
|
-
if (this.
|
|
927
|
+
if (this.wrapFocus) {
|
|
900
928
|
prevIndex = this.adapter.getListItemCount() - 1;
|
|
901
929
|
}
|
|
902
930
|
else {
|
|
@@ -926,7 +954,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
926
954
|
* @param isEnabled Sets the list item to enabled or disabled.
|
|
927
955
|
*/
|
|
928
956
|
MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
|
|
929
|
-
if (!this.
|
|
957
|
+
if (!this.isIndexValid(itemIndex)) {
|
|
930
958
|
return;
|
|
931
959
|
}
|
|
932
960
|
if (isEnabled) {
|
|
@@ -938,41 +966,42 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
938
966
|
this.adapter.setAttributeForElementIndex(itemIndex, strings.ARIA_DISABLED, 'true');
|
|
939
967
|
}
|
|
940
968
|
};
|
|
941
|
-
MDCListFoundation.prototype.
|
|
942
|
-
|
|
969
|
+
MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, _a) {
|
|
970
|
+
var _b = _a === void 0 ? {} : _a, forceUpdate = _b.forceUpdate;
|
|
971
|
+
if (this.selectedIndex === index && !forceUpdate) {
|
|
943
972
|
return;
|
|
944
973
|
}
|
|
945
974
|
var selectedClassName = cssClasses.LIST_ITEM_SELECTED_CLASS;
|
|
946
|
-
if (this.
|
|
975
|
+
if (this.useActivatedClass) {
|
|
947
976
|
selectedClassName = cssClasses.LIST_ITEM_ACTIVATED_CLASS;
|
|
948
977
|
}
|
|
949
|
-
if (this.
|
|
950
|
-
this.adapter.removeClassForElementIndex(this.
|
|
978
|
+
if (this.selectedIndex !== numbers.UNSET_INDEX) {
|
|
979
|
+
this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
|
|
951
980
|
}
|
|
952
|
-
this.
|
|
981
|
+
this.setAriaForSingleSelectionAtIndex(index);
|
|
953
982
|
this.setTabindexAtIndex(index);
|
|
954
983
|
if (index !== numbers.UNSET_INDEX) {
|
|
955
984
|
this.adapter.addClassForElementIndex(index, selectedClassName);
|
|
956
985
|
}
|
|
957
|
-
this.
|
|
986
|
+
this.selectedIndex = index;
|
|
958
987
|
};
|
|
959
988
|
/**
|
|
960
989
|
* Sets aria attribute for single selection at given index.
|
|
961
990
|
*/
|
|
962
|
-
MDCListFoundation.prototype.
|
|
991
|
+
MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
|
|
963
992
|
// Detect the presence of aria-current and get the value only during list
|
|
964
993
|
// initialization when it is in unset state.
|
|
965
|
-
if (this.
|
|
966
|
-
this.
|
|
994
|
+
if (this.selectedIndex === numbers.UNSET_INDEX) {
|
|
995
|
+
this.ariaCurrentAttrValue =
|
|
967
996
|
this.adapter.getAttributeForElementIndex(index, strings.ARIA_CURRENT);
|
|
968
997
|
}
|
|
969
|
-
var isAriaCurrent = this.
|
|
998
|
+
var isAriaCurrent = this.ariaCurrentAttrValue !== null;
|
|
970
999
|
var ariaAttribute = isAriaCurrent ? strings.ARIA_CURRENT : strings.ARIA_SELECTED;
|
|
971
|
-
if (this.
|
|
972
|
-
this.adapter.setAttributeForElementIndex(this.
|
|
1000
|
+
if (this.selectedIndex !== numbers.UNSET_INDEX) {
|
|
1001
|
+
this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
|
|
973
1002
|
}
|
|
974
1003
|
if (index !== numbers.UNSET_INDEX) {
|
|
975
|
-
var ariaAttributeValue = isAriaCurrent ? this.
|
|
1004
|
+
var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
|
|
976
1005
|
this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
|
|
977
1006
|
}
|
|
978
1007
|
};
|
|
@@ -980,22 +1009,22 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
980
1009
|
* Returns the attribute to use for indicating selection status.
|
|
981
1010
|
*/
|
|
982
1011
|
MDCListFoundation.prototype.getSelectionAttribute = function () {
|
|
983
|
-
return this.
|
|
1012
|
+
return this.useSelectedAttr ? strings.ARIA_SELECTED : strings.ARIA_CHECKED;
|
|
984
1013
|
};
|
|
985
1014
|
/**
|
|
986
1015
|
* Toggles radio at give index. Radio doesn't change the checked state if it
|
|
987
1016
|
* is already checked.
|
|
988
1017
|
*/
|
|
989
|
-
MDCListFoundation.prototype.
|
|
1018
|
+
MDCListFoundation.prototype.setRadioAtIndex = function (index) {
|
|
990
1019
|
var selectionAttribute = this.getSelectionAttribute();
|
|
991
1020
|
this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
|
|
992
|
-
if (this.
|
|
993
|
-
this.adapter.setAttributeForElementIndex(this.
|
|
1021
|
+
if (this.selectedIndex !== numbers.UNSET_INDEX) {
|
|
1022
|
+
this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
|
|
994
1023
|
}
|
|
995
1024
|
this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
|
|
996
|
-
this.
|
|
1025
|
+
this.selectedIndex = index;
|
|
997
1026
|
};
|
|
998
|
-
MDCListFoundation.prototype.
|
|
1027
|
+
MDCListFoundation.prototype.setCheckboxAtIndex = function (index) {
|
|
999
1028
|
var selectionAttribute = this.getSelectionAttribute();
|
|
1000
1029
|
for (var i = 0; i < this.adapter.getListItemCount(); i++) {
|
|
1001
1030
|
var isChecked = false;
|
|
@@ -1005,7 +1034,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1005
1034
|
this.adapter.setCheckedCheckboxOrRadioAtIndex(i, isChecked);
|
|
1006
1035
|
this.adapter.setAttributeForElementIndex(i, selectionAttribute, isChecked ? 'true' : 'false');
|
|
1007
1036
|
}
|
|
1008
|
-
this.
|
|
1037
|
+
this.selectedIndex = index;
|
|
1009
1038
|
};
|
|
1010
1039
|
MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
|
|
1011
1040
|
if (this.focusedItemIndex === numbers.UNSET_INDEX && index !== 0) {
|
|
@@ -1020,9 +1049,9 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1020
1049
|
// Set the previous selection's tabindex to -1. We need this because
|
|
1021
1050
|
// in selection menus that are not visible, programmatically setting an
|
|
1022
1051
|
// option will not change focus but will change where tabindex should be 0.
|
|
1023
|
-
if (!(this.
|
|
1024
|
-
this.
|
|
1025
|
-
this.adapter.setAttributeForElementIndex(this.
|
|
1052
|
+
if (!(this.selectedIndex instanceof Array) &&
|
|
1053
|
+
this.selectedIndex !== index) {
|
|
1054
|
+
this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
|
|
1026
1055
|
}
|
|
1027
1056
|
if (index !== numbers.UNSET_INDEX) {
|
|
1028
1057
|
this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
|
|
@@ -1032,53 +1061,56 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1032
1061
|
* @return Return true if it is single selectin list, checkbox list or radio
|
|
1033
1062
|
* list.
|
|
1034
1063
|
*/
|
|
1035
|
-
MDCListFoundation.prototype.
|
|
1036
|
-
return this.
|
|
1037
|
-
this.
|
|
1064
|
+
MDCListFoundation.prototype.isSelectableList = function () {
|
|
1065
|
+
return this.isSingleSelectionList || this.isCheckboxList ||
|
|
1066
|
+
this.isRadioList;
|
|
1038
1067
|
};
|
|
1039
1068
|
MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
|
|
1040
1069
|
var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
|
|
1041
1070
|
this.setTabindexAtIndex(targetIndex);
|
|
1042
1071
|
};
|
|
1043
1072
|
MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
|
|
1044
|
-
|
|
1045
|
-
if (this.
|
|
1046
|
-
|
|
1047
|
-
this.selectedIndex_ !== numbers.UNSET_INDEX) {
|
|
1048
|
-
targetIndex = this.selectedIndex_;
|
|
1049
|
-
}
|
|
1050
|
-
else if (isNumberArray(this.selectedIndex_) &&
|
|
1051
|
-
this.selectedIndex_.length > 0) {
|
|
1052
|
-
targetIndex = this.selectedIndex_.reduce(function (currentIndex, minIndex) { return Math.min(currentIndex, minIndex); });
|
|
1053
|
-
}
|
|
1073
|
+
// Action lists retain focus on the most recently focused item.
|
|
1074
|
+
if (!this.isSelectableList()) {
|
|
1075
|
+
return Math.max(this.focusedItemIndex, 0);
|
|
1054
1076
|
}
|
|
1055
|
-
|
|
1077
|
+
// Single-selection lists focus the selected item.
|
|
1078
|
+
if (typeof this.selectedIndex === 'number' &&
|
|
1079
|
+
this.selectedIndex !== numbers.UNSET_INDEX) {
|
|
1080
|
+
return this.selectedIndex;
|
|
1081
|
+
}
|
|
1082
|
+
// Multiple-selection lists focus the first selected item.
|
|
1083
|
+
if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
|
|
1084
|
+
return this.selectedIndex.reduce(function (minIndex, currentIndex) { return Math.min(minIndex, currentIndex); });
|
|
1085
|
+
}
|
|
1086
|
+
// Selection lists without a selection focus the first item.
|
|
1087
|
+
return 0;
|
|
1056
1088
|
};
|
|
1057
|
-
MDCListFoundation.prototype.
|
|
1089
|
+
MDCListFoundation.prototype.isIndexValid = function (index) {
|
|
1058
1090
|
var _this = this;
|
|
1059
1091
|
if (index instanceof Array) {
|
|
1060
|
-
if (!this.
|
|
1092
|
+
if (!this.isCheckboxList) {
|
|
1061
1093
|
throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
|
|
1062
1094
|
}
|
|
1063
1095
|
if (index.length === 0) {
|
|
1064
1096
|
return true;
|
|
1065
1097
|
}
|
|
1066
1098
|
else {
|
|
1067
|
-
return index.some(function (i) { return _this.
|
|
1099
|
+
return index.some(function (i) { return _this.isIndexInRange(i); });
|
|
1068
1100
|
}
|
|
1069
1101
|
}
|
|
1070
1102
|
else if (typeof index === 'number') {
|
|
1071
|
-
if (this.
|
|
1103
|
+
if (this.isCheckboxList) {
|
|
1072
1104
|
throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
|
|
1073
1105
|
}
|
|
1074
|
-
return this.
|
|
1075
|
-
this.
|
|
1106
|
+
return this.isIndexInRange(index) ||
|
|
1107
|
+
this.isSingleSelectionList && index === numbers.UNSET_INDEX;
|
|
1076
1108
|
}
|
|
1077
1109
|
else {
|
|
1078
1110
|
return false;
|
|
1079
1111
|
}
|
|
1080
1112
|
};
|
|
1081
|
-
MDCListFoundation.prototype.
|
|
1113
|
+
MDCListFoundation.prototype.isIndexInRange = function (index) {
|
|
1082
1114
|
var listSize = this.adapter.getListItemCount();
|
|
1083
1115
|
return index >= 0 && index < listSize;
|
|
1084
1116
|
};
|
|
@@ -1087,16 +1119,16 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1087
1119
|
* toggleCheckbox value. User interaction should not toggle list item(s) when
|
|
1088
1120
|
* disabled.
|
|
1089
1121
|
*/
|
|
1090
|
-
MDCListFoundation.prototype.
|
|
1122
|
+
MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, toggleCheckbox) {
|
|
1091
1123
|
if (toggleCheckbox === void 0) { toggleCheckbox = true; }
|
|
1092
|
-
if (this.
|
|
1093
|
-
this.
|
|
1124
|
+
if (this.isCheckboxList) {
|
|
1125
|
+
this.toggleCheckboxAtIndex(index, toggleCheckbox);
|
|
1094
1126
|
}
|
|
1095
1127
|
else {
|
|
1096
1128
|
this.setSelectedIndex(index);
|
|
1097
1129
|
}
|
|
1098
1130
|
};
|
|
1099
|
-
MDCListFoundation.prototype.
|
|
1131
|
+
MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, toggleCheckbox) {
|
|
1100
1132
|
var selectionAttribute = this.getSelectionAttribute();
|
|
1101
1133
|
var isChecked = this.adapter.isCheckboxCheckedAtIndex(index);
|
|
1102
1134
|
if (toggleCheckbox) {
|
|
@@ -1106,16 +1138,16 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1106
1138
|
this.adapter.setAttributeForElementIndex(index, selectionAttribute, isChecked ? 'true' : 'false');
|
|
1107
1139
|
// If none of the checkbox items are selected and selectedIndex is not
|
|
1108
1140
|
// initialized then provide a default value.
|
|
1109
|
-
var selectedIndexes = this.
|
|
1141
|
+
var selectedIndexes = this.selectedIndex === numbers.UNSET_INDEX ?
|
|
1110
1142
|
[] :
|
|
1111
|
-
this.
|
|
1143
|
+
this.selectedIndex.slice();
|
|
1112
1144
|
if (isChecked) {
|
|
1113
1145
|
selectedIndexes.push(index);
|
|
1114
1146
|
}
|
|
1115
1147
|
else {
|
|
1116
1148
|
selectedIndexes = selectedIndexes.filter(function (i) { return i !== index; });
|
|
1117
1149
|
}
|
|
1118
|
-
this.
|
|
1150
|
+
this.selectedIndex = selectedIndexes;
|
|
1119
1151
|
};
|
|
1120
1152
|
MDCListFoundation.prototype.focusItemAtIndex = function (index) {
|
|
1121
1153
|
this.adapter.focusItemAtIndex(index);
|
|
@@ -1125,7 +1157,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1125
1157
|
var count = this.adapter.getListItemCount();
|
|
1126
1158
|
// If all items are selected, deselect everything.
|
|
1127
1159
|
if (currentlySelectedIndexes.length === count) {
|
|
1128
|
-
this.
|
|
1160
|
+
this.setCheckboxAtIndex([]);
|
|
1129
1161
|
}
|
|
1130
1162
|
else {
|
|
1131
1163
|
// Otherwise select all enabled options.
|
|
@@ -1136,7 +1168,7 @@ var MDCListFoundation = /** @class */ (function (_super) {
|
|
|
1136
1168
|
allIndexes.push(i);
|
|
1137
1169
|
}
|
|
1138
1170
|
}
|
|
1139
|
-
this.
|
|
1171
|
+
this.setCheckboxAtIndex(allIndexes);
|
|
1140
1172
|
}
|
|
1141
1173
|
};
|
|
1142
1174
|
/**
|
|
@@ -1524,7 +1556,7 @@ var MDCList = /** @class */ (function (_super) {
|
|
|
1524
1556
|
*/
|
|
1525
1557
|
MDCList.prototype.handleFocusInEvent = function (evt) {
|
|
1526
1558
|
var index = this.getListItemIndex(evt.target);
|
|
1527
|
-
this.foundation.handleFocusIn(
|
|
1559
|
+
this.foundation.handleFocusIn(index);
|
|
1528
1560
|
};
|
|
1529
1561
|
/**
|
|
1530
1562
|
* Used to figure out which element was clicked before sending the event to
|
|
@@ -1532,7 +1564,7 @@ var MDCList = /** @class */ (function (_super) {
|
|
|
1532
1564
|
*/
|
|
1533
1565
|
MDCList.prototype.handleFocusOutEvent = function (evt) {
|
|
1534
1566
|
var index = this.getListItemIndex(evt.target);
|
|
1535
|
-
this.foundation.handleFocusOut(
|
|
1567
|
+
this.foundation.handleFocusOut(index);
|
|
1536
1568
|
};
|
|
1537
1569
|
/**
|
|
1538
1570
|
* Used to figure out which element was focused when keydown event occurred
|
|
@@ -1744,7 +1776,8 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
1744
1776
|
cancelAnimationFrame(this.animationRequestId);
|
|
1745
1777
|
};
|
|
1746
1778
|
/**
|
|
1747
|
-
* @param corner Default anchor corner alignment of top-left menu surface
|
|
1779
|
+
* @param corner Default anchor corner alignment of top-left menu surface
|
|
1780
|
+
* corner.
|
|
1748
1781
|
*/
|
|
1749
1782
|
MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
|
|
1750
1783
|
this.anchorCorner = corner;
|
|
@@ -1768,10 +1801,18 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
1768
1801
|
MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
|
|
1769
1802
|
this.isHoistedElement = isHoisted;
|
|
1770
1803
|
};
|
|
1771
|
-
/**
|
|
1804
|
+
/**
|
|
1805
|
+
* Used to set the menu-surface calculations based on a fixed position menu.
|
|
1806
|
+
*/
|
|
1772
1807
|
MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
|
|
1773
1808
|
this.isFixedPosition = isFixedPosition;
|
|
1774
1809
|
};
|
|
1810
|
+
/**
|
|
1811
|
+
* @return Returns true if menu is in fixed (`position: fixed`) position.
|
|
1812
|
+
*/
|
|
1813
|
+
MDCMenuSurfaceFoundation.prototype.isFixed = function () {
|
|
1814
|
+
return this.isFixedPosition;
|
|
1815
|
+
};
|
|
1775
1816
|
/** Sets the menu-surface position on the page. */
|
|
1776
1817
|
MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
|
|
1777
1818
|
this.position.x = this.isFinite(x) ? x : 0;
|
|
@@ -1814,9 +1855,9 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
1814
1855
|
else {
|
|
1815
1856
|
this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
|
|
1816
1857
|
this.animationRequestId = requestAnimationFrame(function () {
|
|
1817
|
-
_this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
1818
1858
|
_this.dimensions = _this.adapter.getInnerDimensions();
|
|
1819
1859
|
_this.autoposition();
|
|
1860
|
+
_this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
|
|
1820
1861
|
_this.openAnimationEndTimerId = setTimeout(function () {
|
|
1821
1862
|
_this.openAnimationEndTimerId = 0;
|
|
1822
1863
|
_this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
|
|
@@ -1892,11 +1933,14 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
1892
1933
|
_a[horizontalAlignment] = horizontalOffset,
|
|
1893
1934
|
_a[verticalAlignment] = verticalOffset,
|
|
1894
1935
|
_a);
|
|
1895
|
-
// Center align when anchor width is comparable or greater than menu
|
|
1896
|
-
|
|
1936
|
+
// Center align when anchor width is comparable or greater than menu
|
|
1937
|
+
// surface, otherwise keep corner.
|
|
1938
|
+
if (anchorSize.width / surfaceSize.width >
|
|
1939
|
+
numbers$1.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
|
|
1897
1940
|
horizontalAlignment = 'center';
|
|
1898
1941
|
}
|
|
1899
|
-
// If the menu-surface has been hoisted to the body, it's no longer relative
|
|
1942
|
+
// If the menu-surface has been hoisted to the body, it's no longer relative
|
|
1943
|
+
// to the anchor element
|
|
1900
1944
|
if (this.isHoistedElement || this.isFixedPosition) {
|
|
1901
1945
|
this.adjustPositionForHoistedElement(position);
|
|
1902
1946
|
}
|
|
@@ -2020,7 +2064,8 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2020
2064
|
};
|
|
2021
2065
|
/**
|
|
2022
2066
|
* @param corner Origin corner of the menu surface.
|
|
2023
|
-
* @return Maximum height of the menu surface, based on available space. 0
|
|
2067
|
+
* @return Maximum height of the menu surface, based on available space. 0
|
|
2068
|
+
* indicates should not be set.
|
|
2024
2069
|
*/
|
|
2025
2070
|
MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
|
|
2026
2071
|
if (this.maxHeight > 0) {
|
|
@@ -2049,7 +2094,8 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2049
2094
|
};
|
|
2050
2095
|
/**
|
|
2051
2096
|
* @param corner Origin corner of the menu surface.
|
|
2052
|
-
* @return Horizontal offset of menu surface origin corner from corresponding
|
|
2097
|
+
* @return Horizontal offset of menu surface origin corner from corresponding
|
|
2098
|
+
* anchor corner.
|
|
2053
2099
|
*/
|
|
2054
2100
|
MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
|
|
2055
2101
|
var anchorSize = this.measurements.anchorSize;
|
|
@@ -2076,7 +2122,8 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2076
2122
|
};
|
|
2077
2123
|
/**
|
|
2078
2124
|
* @param corner Origin corner of the menu surface.
|
|
2079
|
-
* @return Vertical offset of menu surface origin corner from corresponding
|
|
2125
|
+
* @return Vertical offset of menu surface origin corner from corresponding
|
|
2126
|
+
* anchor corner.
|
|
2080
2127
|
*/
|
|
2081
2128
|
MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
|
|
2082
2129
|
var anchorSize = this.measurements.anchorSize;
|
|
@@ -2094,7 +2141,10 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2094
2141
|
}
|
|
2095
2142
|
return y;
|
|
2096
2143
|
};
|
|
2097
|
-
/**
|
|
2144
|
+
/**
|
|
2145
|
+
* Calculates the offsets for positioning the menu-surface when the
|
|
2146
|
+
* menu-surface has been hoisted to the body.
|
|
2147
|
+
*/
|
|
2098
2148
|
MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
|
|
2099
2149
|
var e_1, _a;
|
|
2100
2150
|
var _b = this.measurements, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance, surfaceSize = _b.surfaceSize, viewportSize = _b.viewportSize;
|
|
@@ -2108,11 +2158,11 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2108
2158
|
position[prop] = (viewportSize.width - surfaceSize.width) / 2;
|
|
2109
2159
|
continue;
|
|
2110
2160
|
}
|
|
2111
|
-
// Hoisted surfaces need to have the anchor elements location on the page
|
|
2112
|
-
// position properties for proper alignment on the body.
|
|
2161
|
+
// Hoisted surfaces need to have the anchor elements location on the page
|
|
2162
|
+
// added to the position properties for proper alignment on the body.
|
|
2113
2163
|
value += viewportDistance[prop];
|
|
2114
|
-
// Surfaces that are absolutely positioned need to have additional
|
|
2115
|
-
// and bottom positioning.
|
|
2164
|
+
// Surfaces that are absolutely positioned need to have additional
|
|
2165
|
+
// calculations for scroll and bottom positioning.
|
|
2116
2166
|
if (!this.isFixedPosition) {
|
|
2117
2167
|
if (prop === 'top') {
|
|
2118
2168
|
value += windowScroll.y;
|
|
@@ -2139,15 +2189,23 @@ var MDCMenuSurfaceFoundation = /** @class */ (function (_super) {
|
|
|
2139
2189
|
}
|
|
2140
2190
|
};
|
|
2141
2191
|
/**
|
|
2142
|
-
* The last focused element when the menu surface was opened should regain
|
|
2143
|
-
* focused on or within the menu surface when it is
|
|
2192
|
+
* The last focused element when the menu surface was opened should regain
|
|
2193
|
+
* focus, if the user is focused on or within the menu surface when it is
|
|
2194
|
+
* closed.
|
|
2144
2195
|
*/
|
|
2145
2196
|
MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
|
|
2197
|
+
var _this = this;
|
|
2146
2198
|
var isRootFocused = this.adapter.isFocused();
|
|
2147
2199
|
var childHasFocus = document.activeElement &&
|
|
2148
2200
|
this.adapter.isElementInContainer(document.activeElement);
|
|
2149
2201
|
if (isRootFocused || childHasFocus) {
|
|
2150
|
-
|
|
2202
|
+
// Wait before restoring focus when closing the menu surface. This is
|
|
2203
|
+
// important because if a touch event triggered the menu close, and the
|
|
2204
|
+
// subsequent mouse event occurs after focus is restored, then the
|
|
2205
|
+
// restored focus would be lost.
|
|
2206
|
+
setTimeout(function () {
|
|
2207
|
+
_this.adapter.restoreFocus();
|
|
2208
|
+
}, numbers$1.TOUCH_EVENT_WAIT_MS);
|
|
2151
2209
|
}
|
|
2152
2210
|
};
|
|
2153
2211
|
MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
|