qc-trousse-sdg 1.4.7 → 1.4.8

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.
@@ -2,12 +2,15 @@
2
2
  import IconButton from "../IconButton/IconButton.svelte";
3
3
  import {Utils} from "../utils";
4
4
  import Icon from "../../bases/Icon/Icon.svelte";
5
+ import Label from "../Label/Label.svelte";
5
6
 
6
7
  const lang = Utils.getPageLanguage();
7
8
 
8
9
 
9
10
  let {
10
11
  value = $bindable(''),
12
+ label = '',
13
+ size = '',
11
14
  ariaLabel = lang === "fr" ? "Rechercher..." : "Search...",
12
15
  clearAriaLabel = lang === "fr" ? "Effacer le texte" : "Clear text",
13
16
  leftIcon = false,
@@ -25,11 +28,20 @@
25
28
  }
26
29
  </script>
27
30
 
31
+ {#if label}
32
+ <Label
33
+ disabled={isDisabled}
34
+ text={label}
35
+ forId={id}
36
+ />
37
+ {/if}
28
38
  <div class={[
29
39
  "qc-search-input",
30
40
  leftIcon && "qc-search-left-icon",
31
41
  leftIcon && isDisabled && "qc-search-left-icon-disabled"
32
- ]} >
42
+ ]}
43
+ size={size}>
44
+
33
45
  {#if leftIcon}
34
46
  <Icon type="search-thin"
35
47
  iconColor="grey-regular"
@@ -40,7 +52,7 @@
40
52
  bind:value
41
53
  type="search"
42
54
  autocomplete="off"
43
- aria-label={ariaLabel}
55
+ aria-label={label ? undefined : ariaLabel}
44
56
  class={isDisabled ? "qc-disabled" : ""}
45
57
  id={id}
46
58
  {...rest}
@@ -5,6 +5,8 @@
5
5
  id: {attribute: 'id'},
6
6
  ariaLabel: {attribute:'aria-label'},
7
7
  clearAriaLabel: {attribute: 'clear-aria-label'},
8
+ label: {attribute: 'label'},
9
+ size: {attribute: 'size'},
8
10
  leftIcon: {attribute: 'left-icon'}
9
11
  }
10
12
  }}" />
@@ -28,6 +28,16 @@
28
28
  left-icon
29
29
  clear-aria-label="Effacer le texte"
30
30
  ></qc-search-input>
31
+
32
+ <br>
33
+
34
+ <qc-search-input
35
+ label="Nom de l'article"
36
+ size="md"
37
+ placeholder="Rechercher un article"
38
+ clear-aria-label="Effacer le texte"
39
+ left-icon
40
+ ></qc-search-input>
31
41
  </qc-doc-exemple>
32
42
 
33
43
  <h3>Documentation technique</h3>
@@ -75,10 +85,16 @@
75
85
  <td>Désactive le champ.</td>
76
86
  </tr>
77
87
  <tr>
78
- <td>name</td>
88
+ <td>label</td>
79
89
  <td>Texte</td>
80
90
  <td>""</td>
81
- <td>Nom du champ utilisé lors de la soumission du formulaire.</td>
91
+ <td>Texte du libellé du champ. Remplace automatiquement l'aria-label lorsqu'il est défini.</td>
92
+ </tr>
93
+ <tr>
94
+ <td>size</td>
95
+ <td>"xs", "sm", "md", "lg", "xl"</td>
96
+ <td>""</td>
97
+ <td>Largeur du champ</td>
82
98
  </tr>
83
99
  </tbody>
84
100
  </table>
@@ -1,10 +1,19 @@
1
- @use "../../scss/qc-sdg-lib" as *;
1
+ @use "qc-sdg-lib" as *;
2
+ @use "sass:map";
2
3
 
3
4
  qc-search-input {
4
5
  display: block;
5
6
  width: 100%;
6
7
  // TODO mettre un token
7
8
  max-width: rem(548);
9
+
10
+ $sizes: map.get($lg-tokens, size, max-width);
11
+ @each $size, $width in $sizes {
12
+ &[size="#{$size}"] {
13
+ max-width: 100%;
14
+ width: $width;
15
+ }
16
+ }
8
17
  }
9
18
 
10
19
  %qc-search-wrapper {
@@ -66,6 +66,9 @@
66
66
 
67
67
  $effect(() => {
68
68
  if (!input) return;
69
+ if (labelElement) {
70
+ input.before(labelElement);
71
+ }
69
72
  if (description) {
70
73
  input.before(descriptionElement);
71
74
  }
@@ -4,10 +4,10 @@
4
4
  <qc-doc-exemple caption="Exemples 1 - différents champs de texte. Soumettre le formulaire pour voir les messages d'erreur.">
5
5
  <form id="formulaire-champs-textes">
6
6
  <qc-textfield
7
- label="Nom complet"
8
7
  size="md"
9
8
  required
10
9
  >
10
+ <label>Nom complet</label>
11
11
  <input type="text"
12
12
  name="code-postal"
13
13
  placeholder="ex : Jean Tremblay"
@@ -63,12 +63,6 @@ textarea {
63
63
 
64
64
  $sizes: map.get($lg-tokens, size, max-width);
65
65
 
66
- @each $size, $width in $sizes {
67
- [size="#{$size}"] {
68
- max-width: 100%;
69
- }
70
- }
71
-
72
66
  input,
73
67
  textarea,
74
68
  {