@1024pix/pix-ui 55.23.0 → 55.24.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.
@@ -5,6 +5,7 @@
5
5
  @disabled={{@isDisabled}}
6
6
  @query={{if @query @query this.defaultParams}}
7
7
  class={{this.className}}
8
+ aria-disabled="{{@isDisabled}}"
8
9
  ...attributes
9
10
  >
10
11
  <PixButtonContent
@@ -17,7 +18,8 @@
17
18
  </PixButtonContent>
18
19
  </LinkTo>
19
20
  {{else}}
20
- <a href={{@href}} class={{this.className}} ...attributes>
21
+ {{! template-lint-disable no-unsupported-role-attributes }}
22
+ <a href={{@href}} class={{this.className}} aria-disabled="{{@isDisabled}}" ...attributes>
21
23
  <PixButtonContent
22
24
  @iconBefore={{@iconBefore}}
23
25
  @iconAfter={{@iconAfter}}
@@ -2,7 +2,6 @@
2
2
  type={{this.type}}
3
3
  class={{this.className}}
4
4
  {{on "click" this.triggerAction}}
5
- disabled={{this.isDisabled}}
6
5
  aria-disabled="{{this.isDisabled}}"
7
6
  ...attributes
8
7
  >
@@ -1,15 +1,43 @@
1
+ import { warn } from '@ember/debug';
1
2
  import { action } from '@ember/object';
2
3
  import { tracked } from '@glimmer/tracking';
3
4
 
4
5
  import PixButtonBase from './pix-button-base';
5
-
6
6
  export default class PixButton extends PixButtonBase {
7
7
  text = 'pix-button';
8
8
  defaultModel = [];
9
9
 
10
10
  @tracked isTriggering = false;
11
11
 
12
+ constructor(...args) {
13
+ super(...args);
14
+
15
+ const isTriggerFunctionExistOnTypedifferentOfSubmit =
16
+ this.args.type !== 'submit' && typeof this.args.triggerAction === 'function';
17
+ const isTriggerFunctionExistOrNullOnTypeSubmit =
18
+ this.args.type === 'submit' &&
19
+ (typeof this.args.triggerAction === 'function' ||
20
+ this.args.triggerAction === undefined ||
21
+ this.args.triggerAction === null);
22
+
23
+ warn(
24
+ 'PixButton: @triggerAction attribute should be a function',
25
+ isTriggerFunctionExistOnTypedifferentOfSubmit || isTriggerFunctionExistOrNullOnTypeSubmit,
26
+ {
27
+ id: 'pix-ui.button.action.not-function',
28
+ },
29
+ );
30
+ }
31
+
12
32
  get isLoading() {
33
+ warn(
34
+ 'PixButton: @isLoading attribute should be a boolean.',
35
+ [true, false, undefined, null].includes(this.args.isLoading),
36
+ {
37
+ id: 'pix-ui.button.is-loading.not-boolean',
38
+ },
39
+ );
40
+
13
41
  return this.args.isLoading || this.isTriggering;
14
42
  }
15
43
 
@@ -22,7 +50,15 @@ export default class PixButton extends PixButtonBase {
22
50
  }
23
51
 
24
52
  get isDisabled() {
25
- return this.isLoading || this.args.isDisabled;
53
+ warn(
54
+ 'PixButton: @isDisabled attribute should be a boolean.',
55
+ [true, false, undefined, null].includes(this.args.isDisabled),
56
+ {
57
+ id: 'pix-ui.button.is-disabled.not-boolean',
58
+ },
59
+ );
60
+
61
+ return this.isLoading || this.args.isDisabled ? 'true' : null;
26
62
  }
27
63
 
28
64
  get className() {
@@ -32,9 +68,7 @@ export default class PixButton extends PixButtonBase {
32
68
  @action
33
69
  async triggerAction(params) {
34
70
  if (this.isDisabled || (this.type === 'submit' && !this.args.triggerAction)) return;
35
- if (!this.args.triggerAction) {
36
- throw new Error('@triggerAction params is required for PixButton !');
37
- }
71
+
38
72
  try {
39
73
  this.isTriggering = true;
40
74
  await this.args.triggerAction(params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "55.23.0",
3
+ "version": "55.24.0",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"