@1024pix/pix-ui 13.4.4 → 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,23 @@
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
+
9
+ ## v13.5.1 (12/04/2022)
10
+
11
+
12
+ ### :bug: Correction
13
+ - [#211](https://github.com/1024pix/pix-ui/pull/211) [BUGFIX] Ne permettre qu'un label dans les composants Pix Input et Input Password (PIX-4125).
14
+
15
+ ## v13.5.0 (11/04/2022)
16
+
17
+
18
+ ### :rocket: Amélioration
19
+ - [#204](https://github.com/1024pix/pix-ui/pull/204) [FEATURE] Permettre de rendre Pix Input et Pix Input Password obligatoires (PIX-4138).
20
+
3
21
  ## v13.4.4 (11/04/2022)
4
22
 
5
23
 
@@ -1,9 +1,16 @@
1
1
  <div class="pix-input-password">
2
2
  {{#if this.label}}
3
- <label for={{this.id}} class="pix-input__label">{{this.label}}</label>
4
- {{/if}}
5
- {{#if @information}}
6
- <label for={{this.id}} class="pix-input__information">{{@information}}</label>
3
+ <label for={{this.id}} class="pix-input__label">
4
+ {{#if @requiredLabel}}
5
+ <abbr title={{@requiredLabel}} class="mandatory-mark" aria-hidden="true">*</abbr>
6
+ {{/if}}
7
+
8
+ {{this.label}}
9
+
10
+ {{#if @information}}
11
+ <span class="pix-input__information">{{@information}}</span>
12
+ {{/if}}
13
+ </label>
7
14
  {{/if}}
8
15
  <div
9
16
  class="pix-input-password__container
@@ -20,6 +27,9 @@
20
27
  type={{if this.isPasswordVisible "text" "password"}}
21
28
  value={{@value}}
22
29
  aria-label={{this.ariaLabel}}
30
+ aria-required="{{if @requiredLabel true false}}"
31
+ required={{if @requiredLabel true false}}
32
+ aria-describedby={{if @errorMessage "text-input-password-error"}}
23
33
  ...attributes
24
34
  />
25
35
 
@@ -37,6 +47,6 @@
37
47
  </div>
38
48
 
39
49
  {{#if @errorMessage}}
40
- <label for={{this.id}} class="pix-input__error-message">{{@errorMessage}}</label>
50
+ <p id="text-input-password-error" class="pix-input__error-message">{{@errorMessage}}</p>
41
51
  {{/if}}
42
52
  </div>
@@ -1,13 +1,29 @@
1
1
  <div class="pix-input">
2
2
  {{#if @label}}
3
- <label for={{this.id}} class="pix-input__label">{{@label}}</label>
4
- {{/if}}
5
- {{#if @information}}
6
- <label for={{this.id}} class="pix-input__information">{{@information}}</label>
3
+ <label for={{this.id}} class="pix-input__label">
4
+ {{#if @requiredLabel}}
5
+ <abbr title={{@requiredLabel}} class="mandatory-mark" aria-hidden="true">*</abbr>
6
+ {{/if}}
7
+
8
+ {{@label}}
9
+
10
+ {{#if @information}}
11
+ <span class="pix-input__information">{{@information}}</span>
12
+ {{/if}}
13
+ </label>
7
14
  {{/if}}
8
15
 
9
16
  <div class="pix-input__container">
10
- <input id={{this.id}} class={{this.className}} value={{@value}} ...attributes />
17
+ <input
18
+ id={{this.id}}
19
+ class={{this.className}}
20
+ value={{@value}}
21
+ aria-label={{this.ariaLabel}}
22
+ aria-required="{{if @requiredLabel true false}}"
23
+ required={{if @requiredLabel true false}}
24
+ aria-describedby={{if @errorMessage "text-input-error"}}
25
+ ...attributes
26
+ />
11
27
 
12
28
  {{#if @errorMessage}}
13
29
  <FaIcon @icon="times" class="pix-input__error-icon" />
@@ -19,6 +35,6 @@
19
35
  </div>
20
36
 
21
37
  {{#if @errorMessage}}
22
- <label for={{this.id}} class="pix-input__error-message">{{@errorMessage}}</label>
38
+ <p id="text-input-error" class="pix-input__error-message">{{@errorMessage}}</p>
23
39
  {{/if}}
24
40
  </div>
@@ -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
  }
@@ -6,14 +6,19 @@
6
6
  position: relative;
7
7
 
8
8
  &__label {
9
- @include label();
9
+ font-family: $font-roboto;
10
+ font-size: 0.875rem;
11
+ color: $grey-70;
12
+ margin-bottom: 4px;
10
13
  }
11
14
 
12
15
  &__information {
13
16
  font-family: $font-roboto;
14
17
  font-size: 0.75rem;
18
+ margin-top: 4px;
15
19
  color: $blue-zodiac;
16
- margin-bottom: 4px;
20
+
21
+ display: block;
17
22
  }
18
23
 
19
24
  &__container {
@@ -54,8 +59,12 @@
54
59
 
55
60
  &__error-message {
56
61
  @include errorMessage();
57
- margin-top: 4px;
62
+ margin-bottom: 0;
58
63
  bottom: calc(-4px - 1px - 0.75rem);
64
+
65
+ &.pix-input__error-message {
66
+ margin-top:4px;
67
+ }
59
68
  }
60
69
 
61
70
  input {
@@ -5,7 +5,7 @@ export const form = (args) => {
5
5
  return {
6
6
  template: hbs`
7
7
  <form>
8
- <PixInput @id='firstName' @label='Prénom' @errorMessage={{genericErrorMessage}} />
8
+ <PixInput @id='firstName' @label='Prénom' @errorMessage={{genericErrorMessage}} @requiredLabel='champ obligatoire'/>
9
9
  <br>
10
10
  <PixInputPassword @id='password' @label='Mot de passe' @errorMessage={{genericErrorMessage}} />
11
11
  <br>
@@ -13,7 +13,7 @@ export const form = (args) => {
13
13
  <PixMultiSelect
14
14
  @title="Votre notation en étoiles..."
15
15
  @id="form__pix-mutli-select"
16
- @label="A quel point aimez vous Pix-UI ?"
16
+ @label="A quel point aimez vous Pix UI ?"
17
17
  @onSelect={{onSelect}}
18
18
  @selected={{selected}}
19
19
  @options={{options}} as |star|
@@ -1,4 +1,4 @@
1
- import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
1
+ import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
2
2
  import centered from '@storybook/addon-centered/ember';
3
3
  import * as stories from './form.stories.js';
4
4
 
@@ -12,5 +12,5 @@ import * as stories from './form.stories.js';
12
12
  Un formulaire complet avec les composants Pix UI :
13
13
 
14
14
  <Canvas>
15
- <Story name="Form" story={stories.form} height={600} />
15
+ <Story name="Form" story={stories.form} height={700} />
16
16
  </Canvas>
@@ -10,6 +10,7 @@ export const Template = (args) => {
10
10
  @information={{information}}
11
11
  @errorMessage={{errorMessage}}
12
12
  @prefix={{prefix}}
13
+ @requiredLabel={{requiredLabel}}
13
14
  />
14
15
  `,
15
16
  context: args,
@@ -43,6 +44,13 @@ withPrefix.args = {
43
44
  prefix: 'C -',
44
45
  };
45
46
 
47
+ export const withRequiredLabel = Template.bind({});
48
+ withRequiredLabel.args = {
49
+ id: 'password',
50
+ label: 'Mot de passe',
51
+ requiredLabel: 'Champ obligatoire',
52
+ };
53
+
46
54
  export const argTypes = {
47
55
  id: {
48
56
  name: 'id',
@@ -64,7 +72,7 @@ export const argTypes = {
64
72
  },
65
73
  ariaLabel: {
66
74
  name: 'ariaLabel',
67
- 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.",
68
76
  type: { name: 'string', required: true },
69
77
  defaultValue: null,
70
78
  },
@@ -86,4 +94,13 @@ export const argTypes = {
86
94
  type: { name: 'string', required: false },
87
95
  defaultValue: null,
88
96
  },
97
+ requiredLabel: {
98
+ name: 'requiredLabel',
99
+ description:
100
+ 'Label indiquant que le champ est requis, le paramètre @label devient obligatoire avec ce paramètre.',
101
+ type: { name: 'string', required: false },
102
+ table: {
103
+ type: { summary: 'string' },
104
+ },
105
+ },
89
106
  };
@@ -41,7 +41,7 @@ Si vous utilisez le `PixInputPassword` sans label alors il faut renseigner le pa
41
41
  ## With error message
42
42
 
43
43
  <Canvas>
44
- <Story story={stories.withErrorMessage} height={130} />
44
+ <Story story={stories.withErrorMessage} height={100} />
45
45
  </Canvas>
46
46
 
47
47
  ## With prefix
@@ -50,16 +50,23 @@ Si vous utilisez le `PixInputPassword` sans label alors il faut renseigner le pa
50
50
  <Story story={stories.withPrefix} height={100} />
51
51
  </Canvas>
52
52
 
53
+ ## With required label
54
+
55
+ <Canvas>
56
+ <Story story={stories.withRequiredLabel} height={100} />
57
+ </Canvas>
58
+
53
59
  ## Usage
54
60
 
55
61
  ```html
56
62
  <PixInputPassword
57
- @id='{{id}}'
58
- @label='{{label}}'
59
- @information='{{information}}'
60
- @value='{{value}}'
61
- @errorMessage='{{errorMessage}}'
62
- @prefix='{{prefix}}'
63
+ @id='password'
64
+ @label='Mot de passe'
65
+ @information='8 caractères dont une majuscule...'
66
+ @value='pix123'
67
+ @errorMessage='Le mot de passe est erroné'
68
+ @prefix='C-'
69
+ @requiredLabel='Champ obligatoire'
63
70
  />
64
71
  ```
65
72
 
@@ -10,7 +10,10 @@ export const Template = (args) => {
10
10
  @errorMessage={{errorMessage}}
11
11
  @icon={{icon}}
12
12
  @isIconLeft={{isIconLeft}}
13
- placeholder='Jeanne, Pierre ...' />
13
+ placeholder='Jeanne, Pierre ...'
14
+ @requiredLabel={{requiredLabel}}
15
+ @ariaLabel={{ariaLabel}}
16
+ />
14
17
  `,
15
18
  context: args,
16
19
  };
@@ -19,6 +22,7 @@ export const Template = (args) => {
19
22
  export const Default = Template.bind({});
20
23
  Default.args = {
21
24
  id: 'firstName',
25
+ ariaLabel: 'Prénom',
22
26
  };
23
27
 
24
28
  export const withLabel = Template.bind({});
@@ -43,7 +47,20 @@ withIcon.args = {
43
47
  icon: 'eye',
44
48
  };
45
49
 
50
+ export const withRequiredLabel = Template.bind({});
51
+ withRequiredLabel.args = {
52
+ id: 'firstName',
53
+ label: 'Prénom',
54
+ requiredLabel: 'Champ obligatoire',
55
+ };
56
+
46
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
+ },
47
64
  id: {
48
65
  name: 'id',
49
66
  description: 'Identifiant du champ permettant de lui attacher un label',
@@ -91,4 +108,13 @@ export const argTypes = {
91
108
  defaultValue: { summary: 'false' },
92
109
  },
93
110
  },
111
+ requiredLabel: {
112
+ name: 'requiredLabel',
113
+ description:
114
+ 'Label indiquant que le champ est requis, le paramètre @label devient obligatoire avec ce paramètre.',
115
+ type: { name: 'string', required: false },
116
+ table: {
117
+ type: { summary: 'string' },
118
+ },
119
+ },
94
120
  };
@@ -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
 
@@ -39,6 +45,12 @@ Le PixInput permet de créer un champ de texte.
39
45
  <Story story={stories.withIcon} height={130} />
40
46
  </Canvas>
41
47
 
48
+ ## With required label
49
+
50
+ <Canvas>
51
+ <Story story={stories.withRequiredLabel} height={130} />
52
+ </Canvas>
53
+
42
54
  ## Usage
43
55
 
44
56
  ```html
@@ -46,9 +58,11 @@ Le PixInput permet de créer un champ de texte.
46
58
  @id='firstName'
47
59
  @label='Prénom'
48
60
  @information='Complément du label'
49
- @errorMessage="Un message d'erreur"
50
- @icon="eye"
51
- @isIconLeft={{false}} />
61
+ @errorMessage='Un message d`erreur'
62
+ @icon='eye'
63
+ @isIconLeft={{false}}
64
+ @requiredLabel='Champ obligatoire'
65
+ />
52
66
  ```
53
67
 
54
68
  ## Arguments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "13.4.4",
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"