@1024pix/pix-ui 13.5.1 → 14.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v14.0.0 (12/04/2022)
4
+
5
+
6
+ ### :coffee: Autre
7
+ - [#212](https://github.com/1024pix/pix-ui/pull/212) [BREAKING_CHANGES][BUGFIX] Ajouter un aria-label au Pix Input (PIX-4759).
8
+
3
9
  ## v13.5.1 (12/04/2022)
4
10
 
5
11
 
@@ -18,6 +18,7 @@
18
18
  id={{this.id}}
19
19
  class={{this.className}}
20
20
  value={{@value}}
21
+ aria-label={{this.ariaLabel}}
21
22
  aria-required="{{if @requiredLabel true false}}"
22
23
  required={{if @requiredLabel true false}}
23
24
  aria-describedby={{if @errorMessage "text-input-error"}}
@@ -1,5 +1,7 @@
1
1
  import Component from '@glimmer/component';
2
2
 
3
+ const ERROR_MESSAGE = 'ERROR in PixInput component, you must provide @label or @ariaLabel params';
4
+
3
5
  export default class PixInput extends Component {
4
6
  get id() {
5
7
  if (!this.args.id || !this.args.id.toString().trim()) {
@@ -15,4 +17,18 @@ export default class PixInput extends Component {
15
17
  this.args.isIconLeft && classNames.push('pix-input__input--icon-left');
16
18
  return classNames.join(' ');
17
19
  }
20
+
21
+ get label() {
22
+ if (!this.args.label && !this.args.ariaLabel) {
23
+ throw new Error(ERROR_MESSAGE);
24
+ }
25
+ return this.args.label;
26
+ }
27
+
28
+ get ariaLabel() {
29
+ if (!this.args.label && !this.args.ariaLabel) {
30
+ throw new Error(ERROR_MESSAGE);
31
+ }
32
+ return this.args.label ? null : this.args.ariaLabel;
33
+ }
18
34
  }
@@ -72,7 +72,7 @@ export const argTypes = {
72
72
  },
73
73
  ariaLabel: {
74
74
  name: 'ariaLabel',
75
- description: "L'action du bouton, pour l'accessibilité. Requis si label n'est pas définit.",
75
+ description: "L'action du champ, pour l'accessibilité. Requis si label n'est pas définit.",
76
76
  type: { name: 'string', required: true },
77
77
  defaultValue: null,
78
78
  },
@@ -12,6 +12,7 @@ export const Template = (args) => {
12
12
  @isIconLeft={{isIconLeft}}
13
13
  placeholder='Jeanne, Pierre ...'
14
14
  @requiredLabel={{requiredLabel}}
15
+ @ariaLabel={{ariaLabel}}
15
16
  />
16
17
  `,
17
18
  context: args,
@@ -21,6 +22,7 @@ export const Template = (args) => {
21
22
  export const Default = Template.bind({});
22
23
  Default.args = {
23
24
  id: 'firstName',
25
+ ariaLabel: 'Prénom',
24
26
  };
25
27
 
26
28
  export const withLabel = Template.bind({});
@@ -53,6 +55,12 @@ withRequiredLabel.args = {
53
55
  };
54
56
 
55
57
  export const argTypes = {
58
+ ariaLabel: {
59
+ name: 'ariaLabel',
60
+ description: "L'action du champ, pour l'accessibilité. Requis si label n'est pas définit.",
61
+ type: { name: 'string', required: true },
62
+ defaultValue: null,
63
+ },
56
64
  id: {
57
65
  name: 'id',
58
66
  description: 'Identifiant du champ permettant de lui attacher un label',
@@ -14,6 +14,12 @@ import * as stories from './pix-input.stories.js';
14
14
 
15
15
  Le PixInput permet de créer un champ de texte.
16
16
 
17
+ ## Accessibilité
18
+
19
+ Si vous utilisez le `PixInput` sans label alors il faut renseigner le paramètre `ariaLabel`, sinon le composant renvoie une erreur.
20
+
21
+ > Si vous renseignez les paramètres label et ariaLabel ensemble, ariaLabel sera nullifié.
22
+
17
23
 
18
24
  ## Default
19
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "13.5.1",
3
+ "version": "14.0.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"