@xdam/ember-partials 2.0.3 → 3.0.1

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