@xdam/ember-partials 2.0.3 → 3.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.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<button
|
|
2
|
+
class={{concat
|
|
3
|
+
"xep-button mdc-button "
|
|
4
|
+
this.dense
|
|
5
|
+
" "
|
|
6
|
+
this.active
|
|
7
|
+
" "
|
|
8
|
+
this.variantClassNames
|
|
9
|
+
" "
|
|
10
|
+
this.colorClassNames
|
|
11
|
+
" "
|
|
12
|
+
this.dialogDefaultAction
|
|
13
|
+
}}
|
|
14
|
+
data-test-button={{@testSelector}}
|
|
15
|
+
data-mdc-dialog-action={{@dialogActionName}}
|
|
16
|
+
title={{@title}}
|
|
17
|
+
tabindex={{@tabindex}}
|
|
18
|
+
type={{@type}}
|
|
19
|
+
name={{@name}}
|
|
20
|
+
value={{@value}}
|
|
21
|
+
disabled={{this.disabled}}
|
|
22
|
+
{{on "click" this.onClick}}
|
|
23
|
+
>
|
|
24
|
+
{{#if this.includeRipple}}
|
|
25
|
+
<span class="mdc-button__ripple"></span>
|
|
26
|
+
{{/if}}
|
|
27
|
+
<span class="mdc-button__label">
|
|
28
|
+
{{yield
|
|
29
|
+
(hash
|
|
30
|
+
active=@active)
|
|
31
|
+
}}
|
|
32
|
+
</span>
|
|
33
|
+
</button>
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import Component from '@
|
|
2
|
-
import {
|
|
3
|
-
classNames, attribute, className, tagName, layout,
|
|
4
|
-
} from '@ember-decorators/component';
|
|
5
|
-
import EmberObject, { computed } from '@ember/object';
|
|
6
|
-
import template from '@xdam/ember-partials/templates/components/xep-button';
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import EmberObject, { action } from '@ember/object';
|
|
7
3
|
import { inject as service } from '@ember/service';
|
|
8
|
-
import classic from 'ember-classic-decorator';
|
|
9
4
|
|
|
10
5
|
const VARIANT_TYPES = {
|
|
11
6
|
// Defaults to a text button that is flush with the surface.
|
|
@@ -30,10 +25,6 @@ const VARIANT_TYPES = {
|
|
|
30
25
|
* @yield {Hash} button
|
|
31
26
|
* @yield {Boolean} button.active
|
|
32
27
|
*/
|
|
33
|
-
@classic
|
|
34
|
-
@layout(template)
|
|
35
|
-
@tagName('button')
|
|
36
|
-
@classNames('xep-button', 'mdc-button')
|
|
37
28
|
export default class XepButtonComponent extends Component {
|
|
38
29
|
@service
|
|
39
30
|
xepManager;
|
|
@@ -43,64 +34,56 @@ export default class XepButtonComponent extends Component {
|
|
|
43
34
|
* @argument [testSelector]
|
|
44
35
|
* @type {String}
|
|
45
36
|
*/
|
|
46
|
-
@attribute('data-test-button')
|
|
47
|
-
testSelector;
|
|
48
37
|
|
|
49
38
|
/**
|
|
50
39
|
* Define the buttons `title` attribute.
|
|
51
40
|
* @argument [tabindex]
|
|
52
41
|
* @type {String}
|
|
53
42
|
*/
|
|
54
|
-
@attribute
|
|
55
|
-
title;
|
|
56
43
|
|
|
57
44
|
/**
|
|
58
45
|
* Define the `tabindex` attribute.
|
|
59
46
|
* @argument [tabindex]
|
|
60
47
|
* @type {Number}
|
|
61
48
|
*/
|
|
62
|
-
@attribute
|
|
63
|
-
tabindex;
|
|
64
49
|
|
|
65
50
|
/**
|
|
66
51
|
* Define the `type` attribute.
|
|
67
52
|
* @argument [type]
|
|
68
53
|
* @type {String}
|
|
69
54
|
*/
|
|
70
|
-
@attribute
|
|
71
|
-
type;
|
|
72
55
|
|
|
73
56
|
/**
|
|
74
57
|
* Define the `name` attribute.
|
|
75
58
|
* @argument [name]
|
|
76
59
|
* @type {String}
|
|
77
60
|
*/
|
|
78
|
-
@attribute
|
|
79
|
-
name;
|
|
80
61
|
|
|
81
62
|
/**
|
|
82
63
|
* Define the `value` attribute.
|
|
83
64
|
* @argument [value]
|
|
84
65
|
* @type {*}
|
|
85
66
|
*/
|
|
86
|
-
@attribute
|
|
87
|
-
value;
|
|
88
67
|
|
|
89
68
|
/**
|
|
90
69
|
* Define the `disabled` attribute.
|
|
91
70
|
* @argument [disabled]
|
|
92
71
|
* @type {Boolean}
|
|
93
72
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
73
|
+
get disabled() {
|
|
74
|
+
const returnVal = this.args.disabled != true ? null : true;
|
|
75
|
+
|
|
76
|
+
return returnVal;
|
|
77
|
+
}
|
|
96
78
|
|
|
97
79
|
/**
|
|
98
80
|
* Makes the button text and container slightly smaller.
|
|
99
81
|
* @argument [dense]
|
|
100
82
|
* @type {Boolean}
|
|
101
83
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
get dense() {
|
|
85
|
+
return this.args.dense ? 'mdc-button--dense' : '';
|
|
86
|
+
}
|
|
104
87
|
|
|
105
88
|
/**
|
|
106
89
|
* Gives button an "xep-button--active" className for custom styling. Buttons also yield the `active` state,
|
|
@@ -108,45 +91,51 @@ export default class XepButtonComponent extends Component {
|
|
|
108
91
|
* @argument [active]
|
|
109
92
|
* @type {Boolean}
|
|
110
93
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
94
|
+
get active() {
|
|
95
|
+
return this.args.active ? 'xep-button--active' : '';
|
|
96
|
+
}
|
|
113
97
|
|
|
114
98
|
/**
|
|
115
99
|
* Define an action name for use with xep-dialog.
|
|
116
100
|
* @argument [dialogActionName]
|
|
117
101
|
* @type {String}
|
|
118
102
|
*/
|
|
119
|
-
@attribute('data-mdc-dialog-action')
|
|
120
|
-
dialogActionName;
|
|
121
103
|
|
|
122
104
|
/**
|
|
123
105
|
* Define xep-dialog default action button.
|
|
124
106
|
* @argument [dialogActionName]
|
|
125
107
|
* @type {Boolean}
|
|
126
108
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
109
|
+
get dialogDefaultAction() {
|
|
110
|
+
return this.args.dialogDefaultAction ? 'mdc-dialog__button--default' : '';
|
|
111
|
+
}
|
|
129
112
|
|
|
130
113
|
/**
|
|
131
114
|
* Specify a string which the component should be registered with xepManager. Defaults to `null`.
|
|
132
115
|
* @argument [register]
|
|
133
116
|
* @type {String}
|
|
134
117
|
*/
|
|
135
|
-
register;
|
|
136
118
|
|
|
137
119
|
/**
|
|
138
120
|
* Provide an action for when the component is clicked.
|
|
139
121
|
* @argument [click]
|
|
140
122
|
* @type {Action}
|
|
141
123
|
*/
|
|
142
|
-
|
|
124
|
+
@action
|
|
125
|
+
async onClick(evt) {
|
|
126
|
+
if (this.args.click) {
|
|
127
|
+
await this.args.click(evt);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
143
130
|
|
|
144
131
|
/**
|
|
145
132
|
* Define the variant type for the button. Defaults to `"standard"`.
|
|
146
133
|
* @argument variant
|
|
147
134
|
* @type {String}
|
|
148
135
|
*/
|
|
149
|
-
variant
|
|
136
|
+
get variant() {
|
|
137
|
+
return this.args.variant || 'standard';
|
|
138
|
+
}
|
|
150
139
|
|
|
151
140
|
// Map of classNames for each variant type
|
|
152
141
|
variantTypeMap = EmberObject.create(VARIANT_TYPES);
|
|
@@ -158,9 +147,6 @@ export default class XepButtonComponent extends Component {
|
|
|
158
147
|
* @type {String}
|
|
159
148
|
* @readOnly
|
|
160
149
|
*/
|
|
161
|
-
@className
|
|
162
|
-
// eslint-disable-next-line ember/require-computed-property-dependencies
|
|
163
|
-
@computed('variant')
|
|
164
150
|
get variantClassNames() {
|
|
165
151
|
return this.variantTypeMap[this.variant];
|
|
166
152
|
}
|
|
@@ -172,7 +158,9 @@ export default class XepButtonComponent extends Component {
|
|
|
172
158
|
* @argument color
|
|
173
159
|
* @type {String}
|
|
174
160
|
*/
|
|
175
|
-
color
|
|
161
|
+
get color() {
|
|
162
|
+
return this.args.color || 'primary';
|
|
163
|
+
}
|
|
176
164
|
|
|
177
165
|
/**
|
|
178
166
|
* Returns color classNames
|
|
@@ -181,22 +169,35 @@ export default class XepButtonComponent extends Component {
|
|
|
181
169
|
* @type {String}
|
|
182
170
|
* @readOnly
|
|
183
171
|
*/
|
|
184
|
-
@className
|
|
185
|
-
@computed('color')
|
|
186
172
|
get colorClassNames() {
|
|
187
173
|
return `xep-button--${this.color}-color`;
|
|
188
174
|
}
|
|
189
175
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Indicate whether a hover/click response ("ripple") should be
|
|
178
|
+
* included on the button. Default is to include the "ripple".
|
|
179
|
+
*
|
|
180
|
+
* @argument includeRipple
|
|
181
|
+
* @type {Boolean}
|
|
182
|
+
* @readOnly
|
|
183
|
+
*/
|
|
184
|
+
get includeRipple() {
|
|
185
|
+
if (this.args.includeRipple !== null && (this.args.includeRipple === false || this.args.includeRipple === 'false')) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
constructor() {
|
|
192
|
+
super(...arguments);
|
|
193
|
+
if (this.args.register) {
|
|
194
|
+
this.xepManager.registerComponent(this, this.args.register);
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
willDestroy() {
|
|
198
|
-
if (this.register) {
|
|
199
|
-
this.xepManager.deregisterComponent(this, this.register);
|
|
199
|
+
if (this.args.register) {
|
|
200
|
+
this.xepManager.deregisterComponent(this, this.args.register);
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
super.willDestroy(...arguments);
|
package/package.json
CHANGED