@aurelia-mdc-web/all 9.3.0-au2 → 9.3.1-au2
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/chips/mdc-chip/mdc-chip.js.map +1 -1
- package/dist/data-table/mdc-data-table.js.map +1 -1
- package/dist/dialog/mdc-dialog-service.js.map +1 -1
- package/dist/expandable/mdc-expandable.js.map +1 -1
- package/dist/form-field/mdc-form-field.js.map +1 -1
- package/dist/list/mdc-deprecated-list/mdc-deprecated-list-item/mdc-deprecated-list-item.js.map +1 -1
- package/dist/list/mdc-list-item/mdc-list-item.js.map +1 -1
- package/dist/menu/mdc-menu.js.map +1 -1
- package/dist/segmented-button/mdc-segmented-button-segment/mdc-segmented-button-segment.js.map +1 -1
- package/dist/select/mdc-select-value-observer.js.map +1 -1
- package/dist/select/mdc-select.js.map +1 -1
- package/dist/text-field/mdc-text-field.js.map +1 -1
- package/dist/tree-view/mdc-tree-view.js.map +1 -1
- package/package.json +2 -2
- package/src/chips/mdc-chip/mdc-chip.ts +290 -290
- package/src/data-table/mdc-data-table.ts +432 -432
- package/src/dialog/mdc-dialog-service.ts +80 -80
- package/src/expandable/mdc-expandable.ts +104 -104
- package/src/form-field/mdc-form-field.ts +60 -60
- package/src/list/mdc-deprecated-list/mdc-deprecated-list-item/mdc-deprecated-list-item.ts +108 -108
- package/src/list/mdc-list-item/mdc-list-item.ts +136 -136
- package/src/menu/mdc-menu.ts +340 -340
- package/src/segmented-button/mdc-segmented-button-segment/mdc-segmented-button-segment.ts +170 -170
- package/src/select/mdc-select-value-observer.ts +346 -346
- package/src/select/mdc-select.ts +480 -480
- package/src/text-field/mdc-text-field.ts +535 -535
- package/src/tree-view/mdc-tree-view.ts +147 -147
|
@@ -1,170 +1,170 @@
|
|
|
1
|
-
import { booleanAttr, MdcComponent } from '../../base';
|
|
2
|
-
import { CustomElement } from '@aurelia/runtime-html';
|
|
3
|
-
import { inject, customElement, bindable } from 'aurelia';
|
|
4
|
-
import { MDCSegmentedButtonSegmentAdapter, MDCSegmentedButtonSegmentFoundation, SegmentDetail } from '@material/segmented-button';
|
|
5
|
-
import { events } from '@material/segmented-button/segmented-button/constants';
|
|
6
|
-
import template from './mdc-segmented-button-segment.html?raw';
|
|
7
|
-
import { MdcSegmentedButton } from '../mdc-segmented-button';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @selector button[mdc-segmented-button-segment]
|
|
11
|
-
*/
|
|
12
|
-
@inject(Element, MdcSegmentedButton)
|
|
13
|
-
@customElement({ name: 'mdc-segmented-button-segment', template })
|
|
14
|
-
export class MdcSegmentedButtonSegment extends MdcComponent<MDCSegmentedButtonSegmentFoundation> {
|
|
15
|
-
constructor(root: IMdcSegmentedButtonSegmentElement) {
|
|
16
|
-
super(root);
|
|
17
|
-
defineMdcSegmentedButtonSegmentElementApis(root);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private isSingleSelect: boolean;
|
|
21
|
-
private index: number;
|
|
22
|
-
|
|
23
|
-
/** Indicates the segment has touch target support */
|
|
24
|
-
@bindable({ set: booleanAttr })
|
|
25
|
-
touch: boolean;
|
|
26
|
-
|
|
27
|
-
/** Sets an icon in the segment */
|
|
28
|
-
@bindable()
|
|
29
|
-
icon: string;
|
|
30
|
-
|
|
31
|
-
private _checked?: boolean;
|
|
32
|
-
/** Use to verify the checked value */
|
|
33
|
-
get checked(): boolean {
|
|
34
|
-
if (this.foundation) {
|
|
35
|
-
return this.foundation?.isSelected();
|
|
36
|
-
} else {
|
|
37
|
-
return this._checked ?? false;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Whether the segment is checked.
|
|
43
|
-
*/
|
|
44
|
-
set checked(value: boolean) {
|
|
45
|
-
this._checked = value;
|
|
46
|
-
if (value) {
|
|
47
|
-
this.foundation?.setSelected();
|
|
48
|
-
} else {
|
|
49
|
-
this.foundation?.setUnselected();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
handleClick() {
|
|
54
|
-
this.foundation?.handleClick();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
58
|
-
async beforeFoundationCreated() {
|
|
59
|
-
if (this.root.hasAttribute('checked')) {
|
|
60
|
-
const attributeValue = this.root.getAttribute('checked');
|
|
61
|
-
|
|
62
|
-
if (attributeValue || attributeValue === '') {
|
|
63
|
-
this.checked = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
initialSyncWithDOM() {
|
|
69
|
-
if (this._checked !== undefined) {
|
|
70
|
-
this.checked = this._checked;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getDefaultFoundation(): MDCSegmentedButtonSegmentFoundation {
|
|
75
|
-
// DO NOT INLINE this variable. For backward compatibility, foundations take
|
|
76
|
-
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
|
|
77
|
-
// methods, we need a separate, strongly typed adapter variable.
|
|
78
|
-
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
79
|
-
const adapter: MDCSegmentedButtonSegmentAdapter = {
|
|
80
|
-
isSingleSelect: () => {
|
|
81
|
-
return this.isSingleSelect;
|
|
82
|
-
},
|
|
83
|
-
getAttr: (attrName) => {
|
|
84
|
-
return this.root.getAttribute(attrName);
|
|
85
|
-
},
|
|
86
|
-
setAttr: (attrName, value) => {
|
|
87
|
-
this.root.setAttribute(attrName, value);
|
|
88
|
-
},
|
|
89
|
-
addClass: (className) => {
|
|
90
|
-
this.root.classList.add(className);
|
|
91
|
-
},
|
|
92
|
-
removeClass: (className) => {
|
|
93
|
-
this.root.classList.remove(className);
|
|
94
|
-
},
|
|
95
|
-
hasClass: (className) => {
|
|
96
|
-
return this.root.classList.contains(className);
|
|
97
|
-
},
|
|
98
|
-
notifySelectedChange: selected => this.notifySelectedChange(events.SELECTED, selected),
|
|
99
|
-
getRootBoundingClientRect: () => {
|
|
100
|
-
return this.root.getBoundingClientRect();
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
return new MDCSegmentedButtonSegmentFoundation(adapter);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
notifySelectedChange(event: string, selected: boolean) {
|
|
107
|
-
this.emit<SegmentDetail>(
|
|
108
|
-
event, {
|
|
109
|
-
index: this.index,
|
|
110
|
-
selected,
|
|
111
|
-
segmentId: this.getSegmentId()
|
|
112
|
-
}, true /* shouldBubble */);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setIsSingleSelect(isSingleSelect: boolean) {
|
|
116
|
-
this.isSingleSelect = isSingleSelect;
|
|
117
|
-
this.root.setAttribute('role', isSingleSelect ? 'radio' : '');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Sets segment's index value
|
|
122
|
-
*
|
|
123
|
-
* @hidden
|
|
124
|
-
* @param index Segment's index within wrapping segmented button
|
|
125
|
-
*/
|
|
126
|
-
setIndex(index: number) {
|
|
127
|
-
this.index = index;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @hidden
|
|
132
|
-
* @return Returns segment's segmentId if it was set by client
|
|
133
|
-
*/
|
|
134
|
-
getSegmentId(): string | undefined {
|
|
135
|
-
return this.foundation?.getSegmentId();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/** @hidden */
|
|
140
|
-
export interface IMdcSegmentedButtonSegmentElement extends HTMLElement {
|
|
141
|
-
checked: boolean;
|
|
142
|
-
indeterminate: boolean;
|
|
143
|
-
$au: {
|
|
144
|
-
'au:resource:custom-element': {
|
|
145
|
-
viewModel: MdcSegmentedButtonSegment;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function defineMdcSegmentedButtonSegmentElementApis(element: IMdcSegmentedButtonSegmentElement) {
|
|
151
|
-
Object.defineProperties(element, {
|
|
152
|
-
type: {
|
|
153
|
-
value: 'checkbox'
|
|
154
|
-
},
|
|
155
|
-
tagName: {
|
|
156
|
-
get() {
|
|
157
|
-
return 'MDC-SEGMENTED-BUTTON-SEGMENT';
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
checked: {
|
|
161
|
-
get(this: IMdcSegmentedButtonSegmentElement) {
|
|
162
|
-
return CustomElement.for<MdcSegmentedButtonSegment>(this).viewModel.checked;
|
|
163
|
-
},
|
|
164
|
-
set(this: IMdcSegmentedButtonSegmentElement, value: boolean) {
|
|
165
|
-
CustomElement.for<MdcSegmentedButtonSegment>(this).viewModel.checked = value;
|
|
166
|
-
},
|
|
167
|
-
configurable: true
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
1
|
+
import { booleanAttr, MdcComponent } from '../../base';
|
|
2
|
+
import { CustomElement } from '@aurelia/runtime-html';
|
|
3
|
+
import { inject, customElement, bindable } from 'aurelia';
|
|
4
|
+
import { MDCSegmentedButtonSegmentAdapter, MDCSegmentedButtonSegmentFoundation, SegmentDetail } from '@material/segmented-button';
|
|
5
|
+
import { events } from '@material/segmented-button/segmented-button/constants';
|
|
6
|
+
import template from './mdc-segmented-button-segment.html?raw';
|
|
7
|
+
import { MdcSegmentedButton } from '../mdc-segmented-button';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @selector button[mdc-segmented-button-segment]
|
|
11
|
+
*/
|
|
12
|
+
@inject(Element, MdcSegmentedButton)
|
|
13
|
+
@customElement({ name: 'mdc-segmented-button-segment', template })
|
|
14
|
+
export class MdcSegmentedButtonSegment extends MdcComponent<MDCSegmentedButtonSegmentFoundation> {
|
|
15
|
+
constructor(root: IMdcSegmentedButtonSegmentElement) {
|
|
16
|
+
super(root);
|
|
17
|
+
defineMdcSegmentedButtonSegmentElementApis(root);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private isSingleSelect: boolean;
|
|
21
|
+
private index: number;
|
|
22
|
+
|
|
23
|
+
/** Indicates the segment has touch target support */
|
|
24
|
+
@bindable({ set: booleanAttr })
|
|
25
|
+
touch: boolean;
|
|
26
|
+
|
|
27
|
+
/** Sets an icon in the segment */
|
|
28
|
+
@bindable()
|
|
29
|
+
icon: string;
|
|
30
|
+
|
|
31
|
+
private _checked?: boolean;
|
|
32
|
+
/** Use to verify the checked value */
|
|
33
|
+
get checked(): boolean {
|
|
34
|
+
if (this.foundation) {
|
|
35
|
+
return this.foundation?.isSelected();
|
|
36
|
+
} else {
|
|
37
|
+
return this._checked ?? false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether the segment is checked.
|
|
43
|
+
*/
|
|
44
|
+
set checked(value: boolean) {
|
|
45
|
+
this._checked = value;
|
|
46
|
+
if (value) {
|
|
47
|
+
this.foundation?.setSelected();
|
|
48
|
+
} else {
|
|
49
|
+
this.foundation?.setUnselected();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleClick() {
|
|
54
|
+
this.foundation?.handleClick();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
58
|
+
async beforeFoundationCreated() {
|
|
59
|
+
if (this.root.hasAttribute('checked')) {
|
|
60
|
+
const attributeValue = this.root.getAttribute('checked');
|
|
61
|
+
|
|
62
|
+
if (attributeValue || attributeValue === '') {
|
|
63
|
+
this.checked = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
initialSyncWithDOM() {
|
|
69
|
+
if (this._checked !== undefined) {
|
|
70
|
+
this.checked = this._checked;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getDefaultFoundation(): MDCSegmentedButtonSegmentFoundation {
|
|
75
|
+
// DO NOT INLINE this variable. For backward compatibility, foundations take
|
|
76
|
+
// a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
|
|
77
|
+
// methods, we need a separate, strongly typed adapter variable.
|
|
78
|
+
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
|
|
79
|
+
const adapter: MDCSegmentedButtonSegmentAdapter = {
|
|
80
|
+
isSingleSelect: () => {
|
|
81
|
+
return this.isSingleSelect;
|
|
82
|
+
},
|
|
83
|
+
getAttr: (attrName) => {
|
|
84
|
+
return this.root.getAttribute(attrName);
|
|
85
|
+
},
|
|
86
|
+
setAttr: (attrName, value) => {
|
|
87
|
+
this.root.setAttribute(attrName, value);
|
|
88
|
+
},
|
|
89
|
+
addClass: (className) => {
|
|
90
|
+
this.root.classList.add(className);
|
|
91
|
+
},
|
|
92
|
+
removeClass: (className) => {
|
|
93
|
+
this.root.classList.remove(className);
|
|
94
|
+
},
|
|
95
|
+
hasClass: (className) => {
|
|
96
|
+
return this.root.classList.contains(className);
|
|
97
|
+
},
|
|
98
|
+
notifySelectedChange: selected => this.notifySelectedChange(events.SELECTED, selected),
|
|
99
|
+
getRootBoundingClientRect: () => {
|
|
100
|
+
return this.root.getBoundingClientRect();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return new MDCSegmentedButtonSegmentFoundation(adapter);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
notifySelectedChange(event: string, selected: boolean) {
|
|
107
|
+
this.emit<SegmentDetail>(
|
|
108
|
+
event, {
|
|
109
|
+
index: this.index,
|
|
110
|
+
selected,
|
|
111
|
+
segmentId: this.getSegmentId()
|
|
112
|
+
}, true /* shouldBubble */);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
setIsSingleSelect(isSingleSelect: boolean) {
|
|
116
|
+
this.isSingleSelect = isSingleSelect;
|
|
117
|
+
this.root.setAttribute('role', isSingleSelect ? 'radio' : '');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sets segment's index value
|
|
122
|
+
*
|
|
123
|
+
* @hidden
|
|
124
|
+
* @param index Segment's index within wrapping segmented button
|
|
125
|
+
*/
|
|
126
|
+
setIndex(index: number) {
|
|
127
|
+
this.index = index;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @hidden
|
|
132
|
+
* @return Returns segment's segmentId if it was set by client
|
|
133
|
+
*/
|
|
134
|
+
getSegmentId(): string | undefined {
|
|
135
|
+
return this.foundation?.getSegmentId();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @hidden */
|
|
140
|
+
export interface IMdcSegmentedButtonSegmentElement extends HTMLElement {
|
|
141
|
+
checked: boolean;
|
|
142
|
+
indeterminate: boolean;
|
|
143
|
+
$au: {
|
|
144
|
+
'au:resource:custom-element': {
|
|
145
|
+
viewModel: MdcSegmentedButtonSegment;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function defineMdcSegmentedButtonSegmentElementApis(element: IMdcSegmentedButtonSegmentElement) {
|
|
151
|
+
Object.defineProperties(element, {
|
|
152
|
+
type: {
|
|
153
|
+
value: 'checkbox'
|
|
154
|
+
},
|
|
155
|
+
tagName: {
|
|
156
|
+
get() {
|
|
157
|
+
return 'MDC-SEGMENTED-BUTTON-SEGMENT';
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
checked: {
|
|
161
|
+
get(this: IMdcSegmentedButtonSegmentElement) {
|
|
162
|
+
return CustomElement.for<MdcSegmentedButtonSegment>(this).viewModel.checked;
|
|
163
|
+
},
|
|
164
|
+
set(this: IMdcSegmentedButtonSegmentElement, value: boolean) {
|
|
165
|
+
CustomElement.for<MdcSegmentedButtonSegment>(this).viewModel.checked = value;
|
|
166
|
+
},
|
|
167
|
+
configurable: true
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|