@1024pix/pix-ui 45.1.5 → 45.2.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.
@@ -1,14 +1,16 @@
1
1
  <div class="pix-input {{if @inlineLabel ' pix-input--inline'}}">
2
- <PixLabel
3
- @for={{this.id}}
4
- @requiredLabel={{@requiredLabel}}
5
- @subLabel={{@subLabel}}
6
- @size={{@size}}
7
- @screenReaderOnly={{@screenReaderOnly}}
8
- @inlineLabel={{@inlineLabel}}
9
- >
10
- {{yield to="label"}}
11
- </PixLabel>
2
+ {{#if (has-block "label")}}
3
+ <PixLabel
4
+ @for={{this.id}}
5
+ @requiredLabel={{@requiredLabel}}
6
+ @subLabel={{@subLabel}}
7
+ @size={{@size}}
8
+ @screenReaderOnly={{@screenReaderOnly}}
9
+ @inlineLabel={{@inlineLabel}}
10
+ >
11
+ {{yield to="label"}}
12
+ </PixLabel>
13
+ {{/if}}
12
14
  <div>
13
15
  <div class="pix-input__container">
14
16
  <input
@@ -1,14 +1,16 @@
1
1
  <div class="pix-textarea {{if @inlineLabel ' pix-textarea--inline'}}">
2
- <PixLabel
3
- @for={{this.id}}
4
- @requiredLabel={{@requiredLabel}}
5
- @subLabel={{@subLabel}}
6
- @size={{@size}}
7
- @screenReaderOnly={{@screenReaderOnly}}
8
- @inlineLabel={{@inlineLabel}}
9
- >
10
- {{yield to="label"}}
11
- </PixLabel>
2
+ {{#if (has-block "label")}}
3
+ <PixLabel
4
+ @for={{this.id}}
5
+ @requiredLabel={{@requiredLabel}}
6
+ @subLabel={{@subLabel}}
7
+ @size={{@size}}
8
+ @screenReaderOnly={{@screenReaderOnly}}
9
+ @inlineLabel={{@inlineLabel}}
10
+ >
11
+ {{yield to="label"}}
12
+ </PixLabel>
13
+ {{/if}}
12
14
 
13
15
  <div>
14
16
  <textarea
@@ -9,8 +9,17 @@ Le PixInput permet de créer un champ de texte.
9
9
 
10
10
  ## Accessibilité
11
11
 
12
- Si vous utilisez le `PixInput` sans vouloir afficher le label, il faudra renseigner `screenReaderOnly` à `true`.
13
- Il est possible d'ajouter un label en dehors du composant en précisant bien un attribut `for` correspondant à l'`@id` passé au PixInput.
12
+ La propriété label est optionnelle pour le composant.
13
+
14
+ Mais au niveau de l'accessibilité, il est quand même nécessaire que le champ soit rattaché à un label.
15
+
16
+ Il y a alors plusieurs possibilités :
17
+
18
+ - Vous pouvez cacher le label visuellement mais le rendre disponible pour les lecteurs d'écran via la propriété `screenReaderOnly` à `true`.
19
+ - Les attributs `aria-label` et `aria-labelledby` sont utilisables.
20
+ - Un attribut `@for` pointant vers l'id de l'input peut être ajouté à un composant `<PixLabel />` extérieur.
21
+
22
+ ## Tests
14
23
 
15
24
  Pour acceder à l'élément via son label avec testing-library:
16
25
 
@@ -72,6 +81,10 @@ En readonly, l'input n'est pas modifiable, mais il est toujours focusable et est
72
81
 
73
82
  <Story of={ComponentStories.withRequiredLabel} height={100} />
74
83
 
84
+ ## Without label
85
+
86
+ <Story of={ComponentStories.withoutLabel} height={100} />
87
+
75
88
  ## Usage
76
89
 
77
90
  ```html
@@ -31,7 +31,7 @@ export default {
31
31
  label: {
32
32
  name: 'label',
33
33
  description: 'Le label du champ',
34
- type: { name: 'string', required: true },
34
+ type: { name: 'string', required: false },
35
35
  table: {
36
36
  type: { summary: 'string' },
37
37
  },
@@ -102,6 +102,24 @@ const Template = (args) => {
102
102
  };
103
103
  };
104
104
 
105
+ const TemplateWithoutLabel = (args) => {
106
+ return {
107
+ template: hbs`<PixInput
108
+ @id={{this.id}}
109
+ @errorMessage={{this.errorMessage}}
110
+ placeholder='Jeanne, Pierre ...'
111
+ @validationStatus={{this.validationStatus}}
112
+ @size={{this.size}}
113
+ disabled={{this.disabled}}
114
+ readonly={{this.readonly}}
115
+ @subLabel={{this.subLabel}}
116
+ @inlineLabel={{this.inlineLabel}}
117
+ @requiredLabel={{this.requiredLabel}}
118
+ />`,
119
+ context: args,
120
+ };
121
+ };
122
+
105
123
  export const Default = Template.bind({});
106
124
  Default.args = {
107
125
  id: 'first-name',
@@ -150,3 +168,8 @@ withRequiredLabel.args = {
150
168
  label: 'Prénom',
151
169
  requiredLabel: 'Champ obligatoire',
152
170
  };
171
+
172
+ export const withoutLabel = TemplateWithoutLabel.bind({});
173
+ withoutLabel.args = {
174
+ id: 'first-name',
175
+ };
@@ -9,12 +9,21 @@ Un textarea permettant d'avoir un champ de saisie libre.
9
9
 
10
10
  Optionellement, il peut afficher le nombre de caractères tapés ainsi que le nombre de caractères maximum.
11
11
 
12
+ <Story of={ComponentStories.textarea} height={150} />
13
+
12
14
  ## Accessibilité
13
15
 
14
- Si vous utilisez le `PixTextarea` sans vouloir afficher le label, il faudra renseigner `screenReaderOnly` à `true`.
16
+ La propriété label est optionnelle pour le composant.
17
+
18
+ Mais au niveau de l'accessibilité, il est quand même nécessaire que le champ soit rattaché à un label.
19
+
20
+ Il y a alors plusieurs possibilités :
15
21
 
16
- <Story of={ComponentStories.textarea} height={100} />
22
+ - Vous pouvez cacher le label visuellement mais le rendre disponible pour les lecteurs d'écran via la propriété `screenReaderOnly` à `true`.
23
+ - Les attributs `aria-label` et `aria-labelledby` sont utilisables.
24
+ - Un attribut `@for` pointant vers l'id du textarea peut être ajouté à un composant `<PixLabel />` extérieur.
17
25
 
26
+ <Story of={ComponentStories.textareaWithoutLabel} height={100} />
18
27
 
19
28
  ## Usage
20
29
 
@@ -11,7 +11,7 @@ export default {
11
11
  value: {
12
12
  name: 'value',
13
13
  description: 'Valeur du champ',
14
- type: { name: 'string', required: true },
14
+ type: { name: 'string', required: false },
15
15
  },
16
16
  maxlength: {
17
17
  name: 'maxlength',
@@ -23,11 +23,10 @@ export default {
23
23
  description: 'Affiche une erreur en dessous du champ.',
24
24
  type: { name: 'string', required: false },
25
25
  },
26
-
27
26
  label: {
28
27
  name: 'label',
29
28
  description: 'Donne un label au champ.',
30
- type: { name: 'string', required: true },
29
+ type: { name: 'string', required: false },
31
30
  },
32
31
  subLabel: {
33
32
  name: 'subLabel',
@@ -90,8 +89,32 @@ const Template = (args) => {
90
89
  };
91
90
  };
92
91
 
92
+ const TemplateWithoutlabel = (args) => {
93
+ return {
94
+ template: hbs`<PixTextarea
95
+ @id={{this.id}}
96
+ @value={{this.value}}
97
+ @maxlength={{this.maxlength}}
98
+ @errorMessage={{this.errorMessage}}
99
+ @size={{this.size}}
100
+ @subLabel={{this.subLabel}}
101
+ @requiredLabel={{this.requiredLabel}}
102
+ @inlineLabel={{this.inlineLabel}}
103
+ />`,
104
+ context: args,
105
+ };
106
+ };
107
+
93
108
  export const textarea = Template.bind({});
94
109
  textarea.args = {
95
110
  id: 'textarea',
111
+ label: 'Label du textarea',
112
+ subLabel: 'Sous-label',
96
113
  value: 'Contenu du textarea',
97
114
  };
115
+
116
+ export const textareaWithoutLabel = TemplateWithoutlabel.bind({});
117
+ textareaWithoutLabel.args = {
118
+ id: 'textarea-without-label',
119
+ value: 'Contenu du textarea sans label affiché',
120
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "45.1.5",
3
+ "version": "45.2.1",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"