@cityway/basic-ui 1.1.0-beta024 → 1.1.0-beta026
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/cityway-basic-ui-1.1.0-beta026.tgz +0 -0
- package/docs/00-overview.md +39 -14
- package/docs/components/autocomplete.md +235 -234
- package/docs/components/button.md +185 -181
- package/docs/components/card.md +253 -226
- package/docs/components/divider.md +1 -0
- package/docs/components/empty-state.md +158 -157
- package/docs/components/form-field/README.md +235 -225
- package/docs/components/form-field/checkbox.md +98 -80
- package/docs/components/form-field/date.md +102 -87
- package/docs/components/form-field/radio.md +74 -56
- package/docs/components/icon.md +21 -2
- package/docs/components/modals.md +2 -1
- package/docs/components/tab.md +1 -0
- package/docs/for-claude.md +8 -2
- package/fesm2022/cityway-basic-ui.mjs +196 -61
- package/fesm2022/cityway-basic-ui.mjs.map +1 -1
- package/index.d.ts +101 -7
- package/lib/assets/i18n/common.en.json +280 -277
- package/lib/assets/i18n/common.fr.json +280 -277
- package/package.json +2 -2
- package/styles/basic-ui.styles.bo.min.css +1 -1
- package/styles/basic-ui.styles.bo.min.css.map +1 -1
- package/styles/basic-ui.styles.fo.min.css +1 -1
- package/styles/basic-ui.styles.fo.min.css.map +1 -1
- package/cityway-basic-ui-1.1.0-beta024.tgz +0 -0
|
@@ -1,157 +1,158 @@
|
|
|
1
|
-
# `cw-empty-state` — Empty state (état vide)
|
|
2
|
-
|
|
3
|
-
> Lib : `@cityway/basic-ui` · Sélecteur : `cw-empty-state` · Standalone : oui
|
|
4
|
-
> Import : `import { EmptyStateComponent } from '@cityway/basic-ui';`
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## 1. Rôle & quand l'utiliser
|
|
9
|
-
|
|
10
|
-
Bloc d'**état vide** paramétrable : illustration + titre + description + (jusqu'à) deux boutons d'action. Basé sur le DS (BOU) `Empty State / *`.
|
|
11
|
-
|
|
12
|
-
Couvre :
|
|
13
|
-
|
|
14
|
-
- **3 illustrations DS intégrées** (fichiers SVG livrés dans les assets de la lib : `no-data.svg`, `no-result.svg`, `no-upload.svg`) : `noData`, `noResult`, `noFile` ;
|
|
15
|
-
- une **image custom** (`imageSource`) qui prime sur l'illustration ;
|
|
16
|
-
- un **titre** et une **description** (clés i18n) ;
|
|
17
|
-
- **deux boutons optionnels** (`secondaryButton` + `primaryButton`) avec label, icône et action.
|
|
18
|
-
|
|
19
|
-
Cas d'usage : table/liste sans données, résultat de recherche vide, dropzone sans fichier, page « rien à afficher ». Intégré directement dans `cw-table` (voir §5).
|
|
20
|
-
|
|
21
|
-
À ne PAS utiliser pour : un message d'erreur bloquant (préférer `cw-alert`) ou un chargement (préférer `cw-loader`).
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 2. API
|
|
26
|
-
|
|
27
|
-
### Inputs
|
|
28
|
-
|
|
29
|
-
| Input | Type | Défaut | Description |
|
|
30
|
-
|-------|------|--------|-------------|
|
|
31
|
-
| `illustration` | `EmptyStateIllustrationEnum` | `noData` | Illustration intégrée (`noData` / `noResult` / `noFile` / `none`). Ignorée si `imageSource` est fourni. |
|
|
32
|
-
| `illustrationBasePath` | `string` | `/assets/images/empty-states` | Dossier des SVG d'illustration. À surcharger si l'app sert les assets ailleurs. |
|
|
33
|
-
| `imageSource` | `string` | `undefined` | Image custom (URL / data URI) ; **prime** sur `illustration`. |
|
|
34
|
-
| `imageAlt` | `string` | `''` | Texte alternatif de l'image custom (les illustrations intégrées sont décoratives, `aria-hidden`). |
|
|
35
|
-
| `title` | `string` | — (**requis**) | Titre — **clé i18n** (traduite en interne). |
|
|
36
|
-
| `titleParams` | `Record<string, unknown>` | `undefined` | Paramètres d'interpolation du titre, transmis au `translate` (ex. `{ instance: 'PFP2' }` pour « Aucune actualité pour {{instance}} »). |
|
|
37
|
-
| `titleSuffix` | `string` | `undefined` | Complément accolé au titre, séparé par une espace (ex. « pour l'instance PFP2 »). Texte **déjà traduit**, non repassé au `translate`. Le titre ne doit pas finir par un point. Utilisé par `cw-table` pour la mention de portée. |
|
|
38
|
-
| `description` | `string` | `undefined` | Description — clé i18n. |
|
|
39
|
-
| `descriptionParams` | `Record<string, unknown>` | `undefined` | Paramètres d'interpolation de la description. |
|
|
40
|
-
| `primaryButton` | `EmptyStateButton` | `undefined` | Bouton principal (style primaire). Rendu seulement si fourni. |
|
|
41
|
-
| `secondaryButton` | `EmptyStateButton` | `undefined` | Bouton secondaire. Rendu seulement si fourni. Affiché **avant** le primaire (ordre DS). |
|
|
42
|
-
| `dataTest` | `string` | `undefined` | Pose l'attribut `data-test-ctw`. |
|
|
43
|
-
|
|
44
|
-
### Outputs
|
|
45
|
-
|
|
46
|
-
| Output | Payload | Description |
|
|
47
|
-
|--------|---------|-------------|
|
|
48
|
-
| `primaryClick` | `void` | Clic sur le bouton principal. |
|
|
49
|
-
| `secondaryClick` | `void` | Clic sur le bouton secondaire. |
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## 3. Types
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
enum EmptyStateIllustrationEnum {
|
|
57
|
-
noData = 'no-data', // carte + badge « + »
|
|
58
|
-
noResult = 'no-result', // carte + badge « x »
|
|
59
|
-
noFile = 'no-file', // carte image + badge upload
|
|
60
|
-
none = 'none', // pas d'illustration
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface EmptyStateButton {
|
|
64
|
-
label: string; // clé i18n (traduite par cw-button)
|
|
65
|
-
icon?: SpriteIconEnum;
|
|
66
|
-
disabled?: boolean;
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## 4. Exemples
|
|
73
|
-
|
|
74
|
-
Les exemples supposent l'enum exposé au template : `protected readonly illustration = EmptyStateIllustrationEnum;` (et `spriteIcon = SpriteIconEnum` pour les icônes).
|
|
75
|
-
|
|
76
|
-
### Aucune donnée (avec actions)
|
|
77
|
-
|
|
78
|
-
```html
|
|
79
|
-
<cw-empty-state
|
|
80
|
-
[illustration]="illustration.noData"
|
|
81
|
-
[title]="'_USERS._EMPTY.TITLE'"
|
|
82
|
-
[description]="'_USERS._EMPTY.DESCRIPTION'"
|
|
83
|
-
[secondaryButton]="{ label: '_COMMON._ACTION.IMPORT', icon: spriteIcon.toolbarUpload }"
|
|
84
|
-
[primaryButton]="{ label: '_COMMON._ACTION.ADD', icon: spriteIcon.add }"
|
|
85
|
-
(secondaryClick)="onImport()"
|
|
86
|
-
(primaryClick)="onAdd()">
|
|
87
|
-
</cw-empty-state>
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Aucun résultat (après filtrage)
|
|
91
|
-
|
|
92
|
-
```html
|
|
93
|
-
<cw-empty-state
|
|
94
|
-
[illustration]="illustration.noResult"
|
|
95
|
-
[title]="'_COMMON._TABLE.NO_RESULT_TITLE'"
|
|
96
|
-
[description]="'_COMMON._TABLE.NO_RESULT_HINT'"
|
|
97
|
-
[secondaryButton]="{ label: '_COMMON._ACTION.RESET' }"
|
|
98
|
-
(secondaryClick)="resetFilters()">
|
|
99
|
-
</cw-empty-state>
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Image custom, sans boutons
|
|
103
|
-
|
|
104
|
-
```html
|
|
105
|
-
<cw-empty-state
|
|
106
|
-
[imageSource]="'/assets/img/all-done.svg'"
|
|
107
|
-
[imageAlt]="''"
|
|
108
|
-
[title]="'_DASHBOARD._ALL_DONE'">
|
|
109
|
-
</cw-empty-state>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
## 5. Notes d'intégration
|
|
115
|
-
|
|
116
|
-
- **i18n** : `title` / `description` et les `label` de boutons sont des **clés** (traduits en interne — `cw-button` traduit son label). Pour une donnée variable dans le texte, passer `titleParams` / `descriptionParams` plutôt qu'une chaîne déjà traduite.
|
|
117
|
-
- **Contenu projeté** : ce qui est placé entre les balises s'affiche **sous le titre**, avant la description.
|
|
118
|
-
- **Boutons optionnels** : n'apparaissent que si la config est fournie. Ordre : secondaire puis primaire (CTA à droite, conforme DS).
|
|
119
|
-
- **Illustration vs image** : `imageSource` l'emporte toujours. Pour aucune illustration, utiliser `illustration="none"`.
|
|
120
|
-
- **Accessibilité** : les illustrations intégrées sont `aria-hidden` (décoratives) ; pour une image custom porteuse de sens, renseigner `imageAlt`.
|
|
121
|
-
- **Assets** : les SVG sont servis depuis `/assets/images/empty-states/` (les assets de basic-ui y sont copiés via `angular.json`, comme le sprite d'icônes). Une **build basic-ui** est nécessaire pour que les SVG arrivent dans `dist` (Storybook les sert depuis `dist/basic-ui/lib/assets`). Surcharger `illustrationBasePath` si besoin.
|
|
122
|
-
- **Dark mode** : couleurs de texte issues des tokens DS globaux (dark-aware) ; les illustrations utilisent la palette `illustration/*` du DS.
|
|
123
|
-
- **Intégration `cw-table`** : la table accepte `emptyStateNoData` et `emptyStateNoResult` (type `TableEmptyStateConfig`) + un flag `isFiltered`. Quand `data` est vide, la table affiche le `cw-empty-state` correspondant (noResult si `isFiltered`, sinon noData) ; sans config, elle retombe sur le texte `NO_RESULT`. Les boutons de la config portent un `click` direct.
|
|
124
|
-
|
|
125
|
-
```html
|
|
126
|
-
<cw-table
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
- «
|
|
151
|
-
- «
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
- `
|
|
1
|
+
# `cw-empty-state` — Empty state (état vide)
|
|
2
|
+
|
|
3
|
+
> Lib : `@cityway/basic-ui` · Sélecteur : `cw-empty-state` · Standalone : oui
|
|
4
|
+
> Import : `import { EmptyStateComponent } from '@cityway/basic-ui';`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Rôle & quand l'utiliser
|
|
9
|
+
|
|
10
|
+
Bloc d'**état vide** paramétrable : illustration + titre + description + (jusqu'à) deux boutons d'action. Basé sur le DS (BOU) `Empty State / *`.
|
|
11
|
+
|
|
12
|
+
Couvre :
|
|
13
|
+
|
|
14
|
+
- **3 illustrations DS intégrées** (fichiers SVG livrés dans les assets de la lib : `no-data.svg`, `no-result.svg`, `no-upload.svg`) : `noData`, `noResult`, `noFile` ;
|
|
15
|
+
- une **image custom** (`imageSource`) qui prime sur l'illustration ;
|
|
16
|
+
- un **titre** et une **description** (clés i18n) ;
|
|
17
|
+
- **deux boutons optionnels** (`secondaryButton` + `primaryButton`) avec label, icône et action.
|
|
18
|
+
|
|
19
|
+
Cas d'usage : table/liste sans données, résultat de recherche vide, dropzone sans fichier, page « rien à afficher ». Intégré directement dans `cw-table` (voir §5).
|
|
20
|
+
|
|
21
|
+
À ne PAS utiliser pour : un message d'erreur bloquant (préférer `cw-alert`) ou un chargement (préférer `cw-loader`).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. API
|
|
26
|
+
|
|
27
|
+
### Inputs
|
|
28
|
+
|
|
29
|
+
| Input | Type | Défaut | Description |
|
|
30
|
+
|-------|------|--------|-------------|
|
|
31
|
+
| `illustration` | `EmptyStateIllustrationEnum` | `noData` | Illustration intégrée (`noData` / `noResult` / `noFile` / `none`). Ignorée si `imageSource` est fourni. |
|
|
32
|
+
| `illustrationBasePath` | `string` | `/assets/images/empty-states` | Dossier des SVG d'illustration. À surcharger si l'app sert les assets ailleurs. |
|
|
33
|
+
| `imageSource` | `string` | `undefined` | Image custom (URL / data URI) ; **prime** sur `illustration`. |
|
|
34
|
+
| `imageAlt` | `string` | `''` | Texte alternatif de l'image custom (les illustrations intégrées sont décoratives, `aria-hidden`). |
|
|
35
|
+
| `title` | `string` | — (**requis**) | Titre — **clé i18n** (traduite en interne). |
|
|
36
|
+
| `titleParams` | `Record<string, unknown>` | `undefined` | Paramètres d'interpolation du titre, transmis au `translate` (ex. `{ instance: 'PFP2' }` pour « Aucune actualité pour {{instance}} »). |
|
|
37
|
+
| `titleSuffix` | `string` | `undefined` | Complément accolé au titre, séparé par une espace (ex. « pour l'instance PFP2 »). Texte **déjà traduit**, non repassé au `translate`. Le titre ne doit pas finir par un point. Utilisé par `cw-table` pour la mention de portée. |
|
|
38
|
+
| `description` | `string` | `undefined` | Description — clé i18n. |
|
|
39
|
+
| `descriptionParams` | `Record<string, unknown>` | `undefined` | Paramètres d'interpolation de la description. |
|
|
40
|
+
| `primaryButton` | `EmptyStateButton` | `undefined` | Bouton principal (style primaire). Rendu seulement si fourni. |
|
|
41
|
+
| `secondaryButton` | `EmptyStateButton` | `undefined` | Bouton secondaire. Rendu seulement si fourni. Affiché **avant** le primaire (ordre DS). |
|
|
42
|
+
| `dataTest` | `string` | `undefined` | Pose l'attribut `data-test-ctw`. |
|
|
43
|
+
|
|
44
|
+
### Outputs
|
|
45
|
+
|
|
46
|
+
| Output | Payload | Description |
|
|
47
|
+
|--------|---------|-------------|
|
|
48
|
+
| `primaryClick` | `void` | Clic sur le bouton principal. |
|
|
49
|
+
| `secondaryClick` | `void` | Clic sur le bouton secondaire. |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 3. Types
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
enum EmptyStateIllustrationEnum {
|
|
57
|
+
noData = 'no-data', // carte + badge « + »
|
|
58
|
+
noResult = 'no-result', // carte + badge « x »
|
|
59
|
+
noFile = 'no-file', // carte image + badge upload
|
|
60
|
+
none = 'none', // pas d'illustration
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface EmptyStateButton {
|
|
64
|
+
label: string; // clé i18n (traduite par cw-button)
|
|
65
|
+
icon?: SpriteIconEnum;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 4. Exemples
|
|
73
|
+
|
|
74
|
+
Les exemples supposent l'enum exposé au template : `protected readonly illustration = EmptyStateIllustrationEnum;` (et `spriteIcon = SpriteIconEnum` pour les icônes).
|
|
75
|
+
|
|
76
|
+
### Aucune donnée (avec actions)
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<cw-empty-state
|
|
80
|
+
[illustration]="illustration.noData"
|
|
81
|
+
[title]="'_USERS._EMPTY.TITLE'"
|
|
82
|
+
[description]="'_USERS._EMPTY.DESCRIPTION'"
|
|
83
|
+
[secondaryButton]="{ label: '_COMMON._ACTION.IMPORT', icon: spriteIcon.toolbarUpload }"
|
|
84
|
+
[primaryButton]="{ label: '_COMMON._ACTION.ADD', icon: spriteIcon.add }"
|
|
85
|
+
(secondaryClick)="onImport()"
|
|
86
|
+
(primaryClick)="onAdd()">
|
|
87
|
+
</cw-empty-state>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Aucun résultat (après filtrage)
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<cw-empty-state
|
|
94
|
+
[illustration]="illustration.noResult"
|
|
95
|
+
[title]="'_COMMON._TABLE.NO_RESULT_TITLE'"
|
|
96
|
+
[description]="'_COMMON._TABLE.NO_RESULT_HINT'"
|
|
97
|
+
[secondaryButton]="{ label: '_COMMON._ACTION.RESET' }"
|
|
98
|
+
(secondaryClick)="resetFilters()">
|
|
99
|
+
</cw-empty-state>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Image custom, sans boutons
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<cw-empty-state
|
|
106
|
+
[imageSource]="'/assets/img/all-done.svg'"
|
|
107
|
+
[imageAlt]="''"
|
|
108
|
+
[title]="'_DASHBOARD._ALL_DONE'">
|
|
109
|
+
</cw-empty-state>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 5. Notes d'intégration
|
|
115
|
+
|
|
116
|
+
- **i18n** : `title` / `description` et les `label` de boutons sont des **clés** (traduits en interne — `cw-button` traduit son label). Pour une donnée variable dans le texte, passer `titleParams` / `descriptionParams` plutôt qu'une chaîne déjà traduite.
|
|
117
|
+
- **Contenu projeté** : ce qui est placé entre les balises s'affiche **sous le titre**, avant la description.
|
|
118
|
+
- **Boutons optionnels** : n'apparaissent que si la config est fournie. Ordre : secondaire puis primaire (CTA à droite, conforme DS).
|
|
119
|
+
- **Illustration vs image** : `imageSource` l'emporte toujours. Pour aucune illustration, utiliser `illustration="none"`.
|
|
120
|
+
- **Accessibilité** : les illustrations intégrées sont `aria-hidden` (décoratives) ; pour une image custom porteuse de sens, renseigner `imageAlt`.
|
|
121
|
+
- **Assets** : les SVG sont servis depuis `/assets/images/empty-states/` (les assets de basic-ui y sont copiés via `angular.json`, comme le sprite d'icônes). Une **build basic-ui** est nécessaire pour que les SVG arrivent dans `dist` (Storybook les sert depuis `dist/basic-ui/lib/assets`). Surcharger `illustrationBasePath` si besoin.
|
|
122
|
+
- **Dark mode** : couleurs de texte issues des tokens DS globaux (dark-aware) ; les illustrations utilisent la palette `illustration/*` du DS.
|
|
123
|
+
- **Intégration `cw-table`** : la table accepte `emptyStateNoData` et `emptyStateNoResult` (type `TableEmptyStateConfig`) + un flag `isFiltered`. Quand `data` est vide, la table affiche le `cw-empty-state` correspondant (noResult si `isFiltered`, sinon noData) ; sans config, elle retombe sur le texte `NO_RESULT`. Les boutons de la config portent un `click` direct.
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<cw-table
|
|
127
|
+
[title]="'USERS.TABLE_CAPTION'"
|
|
128
|
+
[columns]="columns"
|
|
129
|
+
[data]="rows()"
|
|
130
|
+
[isFiltered]="hasActiveFilters()"
|
|
131
|
+
[emptyStateNoData]="{
|
|
132
|
+
illustration: illustrationEnum.noData,
|
|
133
|
+
title: '_USERS._EMPTY.TITLE',
|
|
134
|
+
description: '_USERS._EMPTY.DESCRIPTION',
|
|
135
|
+
primaryButton: { label: '_COMMON._ACTION.ADD', icon: spriteIcon.add, click: () => add() }
|
|
136
|
+
}"
|
|
137
|
+
[emptyStateNoResult]="{
|
|
138
|
+
title: '_COMMON._TABLE.NO_RESULT',
|
|
139
|
+
secondaryButton: { label: '_COMMON._ACTION.RESET', click: () => resetFilters() }
|
|
140
|
+
}">
|
|
141
|
+
</cw-table>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 6. Prompts-types (génération assistée)
|
|
147
|
+
|
|
148
|
+
> Exemples de formulation pour demander à Claude de générer du code consommant ce composant.
|
|
149
|
+
|
|
150
|
+
- « Ajoute un `cw-empty-state` `noData` avec titre + description et un bouton primaire Ajouter (icône add). »
|
|
151
|
+
- « Sur ma `cw-table`, configure `emptyStateNoData` (Ajouter / Importer) et `emptyStateNoResult` (Réinitialiser) et branche `isFiltered` sur l'état de mes filtres. »
|
|
152
|
+
- « Affiche un état vide avec une image custom et sans bouton quand la liste est vide. »
|
|
153
|
+
|
|
154
|
+
**Rappels pour Claude :**
|
|
155
|
+
- Importer `EmptyStateComponent` (standalone). `title` est **requis** et c'est une **clé i18n**.
|
|
156
|
+
- Les boutons sont optionnels (`primaryButton` / `secondaryButton`) ; brancher `primaryClick` / `secondaryClick`.
|
|
157
|
+
- Dans `cw-table`, passer par `emptyStateNoData` / `emptyStateNoResult` + `isFiltered` (les boutons y portent un `click`).
|
|
158
|
+
- `imageSource` prime sur `illustration` ; pour aucune illustration, `illustration="none"`.
|