@poadio/ui-elements 0.1.0 → 0.3.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 +42 -0
- package/README.md +47 -1
- package/dist/accordion.d.ts +31 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +67 -0
- package/dist/accordion.js.map +1 -0
- package/dist/checkbox.d.ts +15 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +18 -0
- package/dist/checkbox.js.map +1 -1
- package/dist/combo.d.ts +88 -0
- package/dist/combo.d.ts.map +1 -0
- package/dist/combo.js +238 -0
- package/dist/combo.js.map +1 -0
- package/dist/confirm.d.ts +35 -0
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +94 -0
- package/dist/confirm.js.map +1 -0
- package/dist/datepicker.d.ts +146 -0
- package/dist/datepicker.d.ts.map +1 -0
- package/dist/datepicker.js +468 -0
- package/dist/datepicker.js.map +1 -0
- package/dist/declaration.d.ts +25 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +35 -0
- package/dist/declaration.js.map +1 -0
- package/dist/dialog.d.ts +137 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +174 -0
- package/dist/dialog.js.map +1 -0
- package/dist/element.d.ts +4 -0
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +5 -2
- package/dist/element.js.map +1 -1
- package/dist/index.d.ts +40 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -1
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +121 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +245 -0
- package/dist/menu.js.map +1 -0
- package/dist/meter.d.ts +1 -0
- package/dist/meter.d.ts.map +1 -1
- package/dist/meter.js +1 -2
- package/dist/meter.js.map +1 -1
- package/dist/multiselect.d.ts +133 -0
- package/dist/multiselect.d.ts.map +1 -0
- package/dist/multiselect.js +230 -0
- package/dist/multiselect.js.map +1 -0
- package/dist/option-list.d.ts +28 -0
- package/dist/option-list.d.ts.map +1 -0
- package/dist/option-list.js +31 -0
- package/dist/option-list.js.map +1 -0
- package/dist/paginator.d.ts +65 -0
- package/dist/paginator.d.ts.map +1 -0
- package/dist/paginator.js +110 -0
- package/dist/paginator.js.map +1 -0
- package/dist/segmented.d.ts +1 -0
- package/dist/segmented.d.ts.map +1 -1
- package/dist/segmented.js +1 -2
- package/dist/segmented.js.map +1 -1
- package/dist/select.d.ts +3 -6
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +8 -24
- package/dist/select.js.map +1 -1
- package/dist/services.d.ts +3 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +10 -0
- package/dist/services.js.map +1 -0
- package/dist/slider.d.ts +1 -0
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +1 -2
- package/dist/slider.js.map +1 -1
- package/dist/split-button.d.ts +47 -0
- package/dist/split-button.d.ts.map +1 -0
- package/dist/split-button.js +64 -0
- package/dist/split-button.js.map +1 -0
- package/dist/stepper.d.ts +56 -0
- package/dist/stepper.d.ts.map +1 -0
- package/dist/stepper.js +69 -0
- package/dist/stepper.js.map +1 -0
- package/dist/table.d.ts +176 -0
- package/dist/table.d.ts.map +1 -0
- package/dist/table.js +293 -0
- package/dist/table.js.map +1 -0
- package/dist/tabs.d.ts +62 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +118 -0
- package/dist/tabs.js.map +1 -0
- package/dist/toast.d.ts +79 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +176 -0
- package/dist/toast.js.map +1 -0
- package/package.json +3 -3
- package/src/accordion.ts +80 -0
- package/src/checkbox.ts +21 -1
- package/src/combo.ts +220 -0
- package/src/confirm.ts +106 -0
- package/src/datepicker.ts +413 -0
- package/src/declaration.ts +37 -0
- package/src/dialog.ts +217 -0
- package/src/element.ts +7 -2
- package/src/index.ts +33 -2
- package/src/menu.ts +281 -0
- package/src/meter.ts +2 -1
- package/src/multiselect.ts +273 -0
- package/src/option-list.ts +51 -0
- package/src/paginator.ts +151 -0
- package/src/segmented.ts +2 -1
- package/src/select.ts +14 -30
- package/src/services.ts +10 -0
- package/src/slider.ts +2 -1
- package/src/split-button.ts +76 -0
- package/src/stepper.ts +86 -0
- package/src/table.ts +364 -0
- package/src/tabs.ts +129 -0
- package/src/toast.ts +203 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog — @poadio/ui-elements
|
|
2
2
|
|
|
3
|
+
## 0.3.0 — 2026-11-24
|
|
4
|
+
|
|
5
|
+
### Plus de `<select>` natif dans le paginateur
|
|
6
|
+
|
|
7
|
+
- `<poad-paginator>` (seul ou au pied de `<poad-table>`) : la taille de page est un `<poad-select>` de la même
|
|
8
|
+
définition (taille `sm`), même nom accessible ; ses évènements `input`, `change`, `openchange` s'arrêtent à lui
|
|
9
|
+
(seul `pagechange` sort). `label.poad-paginator__rpp` devient `span.poad-paginator__rpp`. Feuilles en plus :
|
|
10
|
+
`select.css`, `option-list.css`, `floating.css`. Le scénario du paginateur choisit la taille à la souris et au
|
|
11
|
+
clavier.
|
|
12
|
+
|
|
13
|
+
### Niveau 5 : la table, tranche 1
|
|
14
|
+
|
|
15
|
+
- `<poad-table>` sur le modèle `table` du socle : `value` et `columns` en propriétés ou en JSON, `renderCell` /
|
|
16
|
+
`renderHeader` (et `cell` / `headerCell` d'une colonne posée en propriété), tri simple et multiple, pagination,
|
|
17
|
+
données serveur (`lazy`, `lazyload`), sélection simple / multiple / cases avec plage à la Maj, grille WAI-ARIA dont
|
|
18
|
+
la ligne a le focus, états vide et chargement, contenu de la page en `slot="toolbar"`, `"toolbar-end"`,
|
|
19
|
+
`"selection-bar"`, `"empty"`, `"caption"`. Évènements `sortchange`, `pagechange`, `selectionchange`, `rowselect`,
|
|
20
|
+
`rowunselect`, `rowclick`, `rowdblclick`. `heading` et `body-max-height` remplacent `title` et `scrollHeight`
|
|
21
|
+
(propriétés de tout élément du DOM).
|
|
22
|
+
- `<poad-paginator>` (`first`, `rows` tenus par l'élément, `pagechange`) sur la machine `paginator`.
|
|
23
|
+
- Les 3 scénarios de la table et celui du paginateur passent sur les composants web ; mesure sur 10 000 lignes
|
|
24
|
+
(`table.perf.test.ts`, pas une barrière de CI).
|
|
25
|
+
|
|
26
|
+
## 0.2.0 — 2026-11-24
|
|
27
|
+
|
|
28
|
+
### Niveau 4 : les composites
|
|
29
|
+
|
|
30
|
+
- `<poad-tabs>` / `<poad-tab>`, `<poad-accordion>` / `<poad-accordion-panel>`, `<poad-stepper>` / `<poad-step>` : des
|
|
31
|
+
déclarations lues par leur groupe, qui pose leur contenu dans son panneau.
|
|
32
|
+
- `<poad-menu>` (en ligne, `slot="trigger"`, `anchor`, `point` contextuel, feuille basse) et `<poad-split-button>`.
|
|
33
|
+
- `<poad-multiselect>`, `<poad-combo>` (tableau ou fonction de recherche), `<poad-datepicker>` : formulaires par
|
|
34
|
+
ElementInternals. La liste d'options devient une fonction interne partagée avec `<poad-select>`.
|
|
35
|
+
- `<poad-dialog>`, `<poad-drawer>` (couche rendue dans l'élément), `poadConfirm()` (promesse ; `<poad-confirm-dialog>`
|
|
36
|
+
posé à la première demande), `poadToast()` / `createPoadToastService()` / `<poad-toast>` (posé au premier message
|
|
37
|
+
s'il manque). Mêmes scénarios de conformité qu'Angular, React et Vue (12).
|
|
38
|
+
|
|
39
|
+
- Correctif : une fonction posée sur un élément APRÈS sa connexion (`formatValue` du curseur, `renderOption`,
|
|
40
|
+
`renderValue`, `renderEmpty`, `compareWith` de la liste, `renderOption` du choix segmenté, `renderLabel` de la jauge)
|
|
41
|
+
le redessine. Le curseur gardait ses graduations, ses repères, ses bulles et `aria-valuetext` sans la mise en forme
|
|
42
|
+
(vu sur le site : « 0 50 Max » sans « € »). Ces propriétés sont déclarées dans `static functions` et reprises, comme
|
|
43
|
+
les autres, quand elles sont posées avant la définition de l'élément.
|
|
44
|
+
|
|
3
45
|
## 0.1.0 — 2026-11-23
|
|
4
46
|
|
|
5
47
|
### Niveau 3 : les flottants
|
package/README.md
CHANGED
|
@@ -72,6 +72,19 @@ propriété. `aria-label` posé sur l'hôte passe au contrôle intérieur.
|
|
|
72
72
|
| `poad-tooltip` (+ l'élément décrit) | — | — | — (texte : attribut `text`) |
|
|
73
73
|
| `poad-popover` (+ `slot="trigger"` ou `anchor`) | `open` | `openchange` (detail) | — (fermé, le contenu reste dans l'élément, caché) |
|
|
74
74
|
| `poad-colorpicker` | `value` (texte CSS) | `input`, `change`, `openchange` | `name`, `required` |
|
|
75
|
+
| `poad-tabs` (+ `poad-tab` déclarés : `value`, `label`, `count`, `icon`, `disabled`, `closable` ; leurs enfants = le panneau ; `slot="end"`) | `value`, `activeIndex` | `change` (detail : la valeur choisie, ou le rang), `tabclose` | — |
|
|
76
|
+
| `poad-accordion` (+ `poad-accordion-panel` déclarés : `value`, `header`, `icon`, `disabled`) | `value` (tableau avec `multiple`) | `change` (detail) | — |
|
|
77
|
+
| `poad-stepper` (+ `poad-step` déclarés : `label`, `description`, `icon`, `optional`, `disabled`, `completed`, `state`) | `activeIndex` | `change` (detail : le rang), `stepclick` | — |
|
|
78
|
+
| `poad-menu` (`items` ; `slot="trigger"`, `anchor` ou `point` ; sans cible : en ligne) | `open` | `itemclick` (detail `{ item, originalEvent }`), `openchange` | — |
|
|
79
|
+
| `poad-split-button` (`label`, `icon`, `items`) | — | `press` (bouton principal), `itemclick`, `openchange` | — |
|
|
80
|
+
| `poad-multiselect` | `value` (tableau) | `input`, `change`, `openchange`, `remove`, `clear`, `filter` | `name` (une entrée par valeur), `required` |
|
|
81
|
+
| `poad-combo` (`suggestions` : tableau, ou fonction de la requête en propriété) | `value` (texte, suggestion ou tableau avec `multiple`) | `change` (choix, effacement, sortie du champ), `input` (et à chaque frappe en texte libre), `search`, `openchange` | `name` (le libellé ; une entrée par puce), `required` |
|
|
82
|
+
| `poad-datepicker` | `value` (ISO local, `Date` avec `data-type="date"`, tableau en intervalle ou plusieurs) | `input`, `change`, `openchange`, `clear`, `monthchange`, `yearchange`, `todayclick` | `name` (ISO ; une entrée par date), `required` |
|
|
83
|
+
| `poad-dialog`, `poad-drawer` (enfants = corps ; `slot="footer"`, `slot="header"`) | `open` | `openchange` (detail `false`, `event.reason` : `close`, `escape`, `backdrop`), `maximizechange` | — (fermé, le contenu reste dans l'élément, caché) |
|
|
84
|
+
| `poad-confirm-dialog` (posé par `poadConfirm()`) | — | — | — |
|
|
85
|
+
| `poad-toast` (`service`, défaut `poadToast`) | — | `close` (detail : le message), `toastclick` | — |
|
|
86
|
+
| `poad-table` (`value`, `columns` en propriétés ou JSON ; `slot="toolbar"`, `"toolbar-end"`, `"selection-bar"`, `"empty"`, `"caption"`) | `sort`, `first`, `rows`, `selection` | `sortchange`, `pagechange`, `selectionchange` (detail : la sélection), `lazyload`, `rowselect`, `rowunselect`, `rowclick`, `rowdblclick` | — |
|
|
87
|
+
| `poad-paginator` | `first`, `rows` | `pagechange` (detail `{ first, rows, page, pageCount }`) | — |
|
|
75
88
|
| `poad-icon`, `poad-badge`, `poad-tag`, `poad-avatar`, `poad-avatar-group`, `poad-divider`, `poad-skeleton`, `poad-progress`, `poad-spinner`, `poad-meter` | — | — | — |
|
|
76
89
|
|
|
77
90
|
**Masque et filtre** : `<poad-mask preset="phone"><input name="tel"></poad-mask>` et `<poad-key-filter filter="int">`
|
|
@@ -90,8 +103,41 @@ Limite : un ancêtre `transform` / `filter` devient le bloc conteneur (écart co
|
|
|
90
103
|
cible qui est un de nos éléments (`<poad-button>`) est mesurée, focalisée et nommée par son contrôle intérieur. Feuilles :
|
|
91
104
|
`floating.css`, `sheet.css`, `tooltip.css`, `popover.css`, `colorpicker.css`.
|
|
92
105
|
|
|
106
|
+
**Déclarations** : `<poad-tab>`, `<poad-accordion-panel>`, `<poad-step>` ne dessinent rien ; leur groupe lit leurs
|
|
107
|
+
attributs (ou propriétés) et pose leurs enfants dans son panneau. Changer une de leurs propriétés redessine le groupe.
|
|
108
|
+
|
|
109
|
+
**Superpositions et services** (niveau 4) : `<poad-dialog>` / `<poad-drawer>` rendent leur couche (fond, boîte) DANS
|
|
110
|
+
l'élément, en `position: fixed`, comme les flottants ; piège à focus, défilement bloqué, focus rendu, animations du
|
|
111
|
+
socle. Deux services en fonctions, sans framework pour les fournir :
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import { poadConfirm, poadToast } from '@poadio/ui-elements';
|
|
115
|
+
if (await poadConfirm({ header: 'Delete?', message: 'This cannot be undone.', severity: 'danger', requireTyping: 'prod' })) remove();
|
|
116
|
+
poadToast.success('Deployed', 'api v1.4 is live'); // ou poadToast({ severity: 'warn', summary: 'Careful' })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`poadConfirm(options)` rend une promesse de `true` / `false` (croix, Échap, fond : `false`) ; il se sert du premier
|
|
120
|
+
`<poad-confirm-dialog>` de la page, sinon en pose un en fin de `body` (préfixe : celui du premier `defineElements()`).
|
|
121
|
+
`poadToast` est une fonction ET une file (`add`, `success`, `info`, `warn`, `error`, `remove`, `clear`, `messages`,
|
|
122
|
+
`subscribe`) ; sans `<poad-toast>` sans clé dans la page, le premier message en fait poser un (en haut à droite). Pour
|
|
123
|
+
choisir la position ou montrer une autre file : `<poad-toast position="bottom-right">`, `createPoadToastService()` et la
|
|
124
|
+
propriété `service`. Feuilles : `tabs.css`, `accordion.css`, `stepper.css`, `menu.css`, `multiselect.css`, `combo.css`,
|
|
125
|
+
`datepicker.css`, `dialog.css`, `toast.css`.
|
|
126
|
+
|
|
127
|
+
**Table** (niveau 5, tranche 1) : le modèle est dans le socle (`src/table/` d'ui-core). Colonnes et lignes en
|
|
128
|
+
propriétés (`table.value = rows`), ou en JSON dans la page ; `data-key` pour reconnaître une ligne (sans lui, l'objet
|
|
129
|
+
lui-même : une sélection écrite en JSON ne retrouverait pas ses lignes). Le tri, la page et la sélection sont tenus par
|
|
130
|
+
l'élément, comme la valeur d'un champ natif. Une cellule se dessine par `renderCell({ row, value, rowIndex, column })`
|
|
131
|
+
(texte, nœud, ou `undefined` pour le texte mis en forme dans la langue) ou par `cell` d'une colonne posée en
|
|
132
|
+
propriété ; `renderHeader(column)` pour un en-tête. Deux noms changent pour ne pas masquer une propriété de tout
|
|
133
|
+
élément du DOM : `heading` (et non `title`, qui donnerait une info-bulle à toute la table) et `body-max-height` (et non
|
|
134
|
+
`scrollHeight`, la hauteur mesurée). Attention : `selectionchange` est aussi un évènement natif (sélection de texte
|
|
135
|
+
dans un `<input>` d'une cellule, qui remonte) ; lire `event.detail` sur un `CustomEvent`. Feuilles : `table.css`,
|
|
136
|
+
`paginator.css`, `checkbox.css`, `icon.css`, et pour la taille de page (un `<poad-select>`, pas de `<select>` natif ;
|
|
137
|
+
ses évènements `input` / `change` ne sortent pas du paginateur) `select.css`, `option-list.css`, `floating.css`.
|
|
138
|
+
|
|
93
139
|
Gabarits : propriétés fonctions qui rendent un texte ou un nœud — `renderOption`, `renderValue`, `renderEmpty`
|
|
94
|
-
(liste), `renderOption` (choix segmenté), `renderLabel` (jauge).
|
|
140
|
+
(liste), `renderOption` (choix segmenté), `renderLabel` (jauge), `renderCell`, `renderHeader` (table).
|
|
95
141
|
|
|
96
142
|
## Langue et icônes
|
|
97
143
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PoadDeclarationElement } from './declaration.js';
|
|
2
|
+
import { PoadElement } from './element.js';
|
|
3
|
+
export interface AccordionPanelData {
|
|
4
|
+
readonly value?: string;
|
|
5
|
+
readonly header?: string;
|
|
6
|
+
readonly icon?: string;
|
|
7
|
+
readonly disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Déclaration d'un panneau dans un `<poad-accordion>` ; ses enfants sont son contenu. */
|
|
10
|
+
export declare class PoadAccordionPanelElement extends PoadDeclarationElement {
|
|
11
|
+
static props: {
|
|
12
|
+
readonly value: "string";
|
|
13
|
+
readonly header: "string";
|
|
14
|
+
readonly icon: "string";
|
|
15
|
+
readonly disabled: "boolean";
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare class PoadAccordionElement extends PoadElement {
|
|
19
|
+
static props: {
|
|
20
|
+
readonly value: "json";
|
|
21
|
+
readonly multiple: "boolean";
|
|
22
|
+
readonly expandIcon: "string";
|
|
23
|
+
readonly flush: "boolean";
|
|
24
|
+
};
|
|
25
|
+
value?: string | string[] | null;
|
|
26
|
+
multiple?: boolean;
|
|
27
|
+
expandIcon?: string;
|
|
28
|
+
flush?: boolean;
|
|
29
|
+
protected render(): import("./dom.js").VNode;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=accordion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../src/accordion.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAgB,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,0FAA0F;AAC1F,qBAAa,yBAA0B,SAAQ,sBAAsB;IACnE,OAAgB,KAAK;;;;;MAAuF;CAC7G;AAED,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,OAAgB,KAAK;;;;;MAA2F;IACxG,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAExB,SAAS,CAAC,MAAM;CAuCjB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-accordion value="db">
|
|
3
|
+
* <poad-accordion-panel value="db" header="Database" icon="database">…contenu…</poad-accordion-panel>
|
|
4
|
+
* <poad-accordion-panel value="net" header="Network" disabled>…</poad-accordion-panel>
|
|
5
|
+
* </poad-accordion>
|
|
6
|
+
* <poad-accordion multiple value='["db"]'>…</poad-accordion>
|
|
7
|
+
*
|
|
8
|
+
* Accordéon : machine `accordion` de @poadio/ui-core (un panneau ouvert, ou plusieurs avec `multiple` ; ↓ ↑ Début Fin
|
|
9
|
+
* entre en-têtes ; attributs `aria-expanded` / `region` ; panneau fermé `inert`). Les `<poad-accordion-panel>` sont
|
|
10
|
+
* des DÉCLARATIONS (sans `value`, un panneau vaut son rang : `"0"`, `"1"`…). Propriété `value` (valeur d'un panneau, un
|
|
11
|
+
* tableau en `multiple`, ou `null`) ; évènement `change` (detail : la nouvelle valeur) quand l'utilisateur ouvre ou
|
|
12
|
+
* ferme. Même DOM, mêmes classes, même ARIA que `poad-accordion` d'ui-angular. Style : `accordion.css`, `icon.css`.
|
|
13
|
+
*/
|
|
14
|
+
import { accordionHeaderProps, accordionIsOpen, accordionKeydown, accordionPanelClasses, accordionRegionProps, accordionRootClasses, accordionSet, } from '@poadio/ui-core';
|
|
15
|
+
import { PoadDeclarationElement, declarations } from './declaration.js';
|
|
16
|
+
import { h } from './dom.js';
|
|
17
|
+
import { PoadElement } from './element.js';
|
|
18
|
+
import { icon } from './icon.js';
|
|
19
|
+
/** Déclaration d'un panneau dans un `<poad-accordion>` ; ses enfants sont son contenu. */
|
|
20
|
+
export class PoadAccordionPanelElement extends PoadDeclarationElement {
|
|
21
|
+
static props = { value: 'string', header: 'string', icon: 'string', disabled: 'boolean' };
|
|
22
|
+
}
|
|
23
|
+
export class PoadAccordionElement extends PoadElement {
|
|
24
|
+
static props = { value: 'json', multiple: 'boolean', expandIcon: 'string', flush: 'boolean' };
|
|
25
|
+
render() {
|
|
26
|
+
const registry = this.icons();
|
|
27
|
+
const panels = declarations(this, this.content, this.tag('accordion-panel'), PoadAccordionPanelElement.props);
|
|
28
|
+
const keyOf = (p, i) => p.value ?? String(i);
|
|
29
|
+
const toggle = (p, i) => {
|
|
30
|
+
if (p.disabled)
|
|
31
|
+
return;
|
|
32
|
+
const v = keyOf(p, i);
|
|
33
|
+
const open = !accordionIsOpen(this.value, v);
|
|
34
|
+
const next = accordionSet((this.value ?? null), v, open, this.multiple);
|
|
35
|
+
if (next === this.value)
|
|
36
|
+
return;
|
|
37
|
+
this.value = next;
|
|
38
|
+
this.emit('change', next);
|
|
39
|
+
};
|
|
40
|
+
const onkeydown = (e, i) => {
|
|
41
|
+
const to = accordionKeydown(panels.map((p) => ({ disabled: !!p.data.disabled })), i, e.key);
|
|
42
|
+
if (to === null)
|
|
43
|
+
return;
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
this.querySelectorAll(':scope > .poad-accordion > .poad-accordion-panel > h3 > button')[to]?.focus();
|
|
46
|
+
};
|
|
47
|
+
return h('div', { class: ['poad-accordion', accordionRootClasses(this.flush)] }, panels.map(({ data: p, content }, i) => {
|
|
48
|
+
const id = `${this.uid}-acc-${i}`;
|
|
49
|
+
const open = accordionIsOpen(this.value, keyOf(p, i));
|
|
50
|
+
const hd = accordionHeaderProps(id, open, !!p.disabled);
|
|
51
|
+
const rg = accordionRegionProps(id, open);
|
|
52
|
+
return h('div', { class: ['poad-accordion-panel', accordionPanelClasses(open, !!p.disabled)] }, [
|
|
53
|
+
h('h3', { class: 'poad-acc__h' }, h('button', {
|
|
54
|
+
type: 'button', class: 'poad-acc__hd', id: hd.id, 'aria-expanded': hd['aria-expanded'], 'aria-controls': hd['aria-controls'], disabled: hd.disabled,
|
|
55
|
+
onclick: () => toggle(p, i), onkeydown: (e) => onkeydown(e, i),
|
|
56
|
+
}, [
|
|
57
|
+
icon(registry, this.expandIcon ?? 'chevron-right', { size: 13, class: 'poad-acc__chev' }),
|
|
58
|
+
p.icon && icon(registry, p.icon, { size: 14 }),
|
|
59
|
+
h('span', { class: 'poad-acc__title' }, p.header ?? ''),
|
|
60
|
+
h('span', { class: 'poad-acc__extra' }),
|
|
61
|
+
])),
|
|
62
|
+
h('div', { class: 'poad-acc__wrap', role: rg.role, id: rg.id, 'aria-labelledby': rg['aria-labelledby'], inert: rg.inert }, h('div', { class: 'poad-acc__inner' }, h('div', { class: 'poad-acc__bd' }, content))),
|
|
63
|
+
]);
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=accordion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.js","sourceRoot":"","sources":["../src/accordion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,oBAAoB,EAAE,eAAe,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,YAAY,GACzI,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC,0FAA0F;AAC1F,MAAM,OAAO,yBAA0B,SAAQ,sBAAsB;IACnE,MAAM,CAAU,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAW,CAAC;;AAG9G,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,MAAM,CAAU,KAAK,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAW,CAAC;IAMtG,MAAM;QACd,M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,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;iBAC9E,EAAE;oBACD,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,IAAI,eAAe,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;oBACzF,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;oBAC9C,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC;oBACvD,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;iBACxC,CAAC,CAAC;gBACH,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,EACvH,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;aACxF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC,CAAC;IACN,CAAC"}
|
package/dist/checkbox.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import type { IconRegistry } from '@poadio/ui-core';
|
|
2
|
+
import { type VNode } from './dom.js';
|
|
1
3
|
import { PoadFormElement } from './element.js';
|
|
4
|
+
/**
|
|
5
|
+
* Une case dessinée DANS un autre élément (cases de la table), sans élément `<poad-checkbox>` à elle : même DOM, mêmes
|
|
6
|
+
* classes, même ARIA ; `onToggle` reçoit l'état suivant (geste refusé : rien). Interne au paquet.
|
|
7
|
+
*/
|
|
8
|
+
export declare function checkboxNode(registry: IconRegistry, o: {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly checked: boolean;
|
|
11
|
+
readonly indeterminate?: boolean;
|
|
12
|
+
readonly ariaLabel: string;
|
|
13
|
+
readonly disabled?: boolean;
|
|
14
|
+
readonly onToggle: (checked: boolean) => void;
|
|
15
|
+
}): VNode;
|
|
2
16
|
export declare class PoadCheckboxElement extends PoadFormElement {
|
|
3
17
|
static props: {
|
|
4
18
|
readonly checked: "boolean";
|
|
@@ -27,6 +41,6 @@ export declare class PoadCheckboxElement extends PoadFormElement {
|
|
|
27
41
|
value: string | null;
|
|
28
42
|
missing: boolean;
|
|
29
43
|
};
|
|
30
|
-
protected render():
|
|
44
|
+
protected render(): VNode;
|
|
31
45
|
}
|
|
32
46
|
//# sourceMappingURL=checkbox.d.ts.map
|
package/dist/checkbox.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../src/checkbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../src/checkbox.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAK,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,GAAG,KAAK,CAa3P;AAED,qBAAa,mBAAoB,SAAQ,eAAe;IACtD,OAAgB,KAAK;;;;;;;;;;;MAGV;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,QAAQ,CAAC,UAAU,WAAgC;IAE7D,SAAS,CAAC,SAAS;;;;IAGnB,SAAS,CAAC,MAAM;CAuBjB"}
|
package/dist/checkbox.js
CHANGED
|
@@ -10,6 +10,24 @@ import { checkboxControlProps, checkboxLabelProps, checkboxMark, checkboxRootCla
|
|
|
10
10
|
import { h } from './dom.js';
|
|
11
11
|
import { PoadFormElement } from './element.js';
|
|
12
12
|
import { icon } from './icon.js';
|
|
13
|
+
/**
|
|
14
|
+
* Une case dessinée DANS un autre élément (cases de la table), sans élément `<poad-checkbox>` à elle : même DOM, mêmes
|
|
15
|
+
* classes, même ARIA ; `onToggle` reçoit l'état suivant (geste refusé : rien). Interne au paquet.
|
|
16
|
+
*/
|
|
17
|
+
export function checkboxNode(registry, o) {
|
|
18
|
+
const state = { checked: o.checked, indeterminate: !!o.indeterminate, disabled: !!o.disabled, readonly: false };
|
|
19
|
+
const element = { id: o.id, label: '', ariaLabel: o.ariaLabel, invalid: false };
|
|
20
|
+
const control = checkboxControlProps(state, element);
|
|
21
|
+
const mark = checkboxMark(state);
|
|
22
|
+
const toggle = () => {
|
|
23
|
+
const next = checkboxTransition(state, { type: 'toggle' });
|
|
24
|
+
if (next !== state)
|
|
25
|
+
o.onToggle(next.checked);
|
|
26
|
+
};
|
|
27
|
+
return h('span', { class: ['poad-checkbox', checkboxRootClasses(state, element)] }, h('button', {
|
|
28
|
+
type: 'button', role: control.role, id: control.id, 'aria-checked': control['aria-checked'], disabled: control.disabled, 'aria-label': control['aria-label'], onclick: toggle,
|
|
29
|
+
}, h('span', { class: 'poad-checkbox__box' }, mark === 'dash' ? h('span', { class: 'poad-checkbox__dash' }) : mark === 'check' && icon(registry, 'check', { size: 11, strokeWidth: 3.2 }))));
|
|
30
|
+
}
|
|
13
31
|
export class PoadCheckboxElement extends PoadFormElement {
|
|
14
32
|
static props = {
|
|
15
33
|
checked: 'boolean', indeterminate: 'boolean', disabled: 'boolean', readonly: 'boolean', invalid: 'boolean', label: 'string', ariaLabel: 'string',
|
package/dist/checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../src/checkbox.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAsB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../src/checkbox.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAsB,MAAM,iBAAiB,CAAC;AAEtJ,OAAO,EAAE,CAAC,EAAc,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CA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,EAC1C,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YACnJ,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC;YAChG,IAAI,CAAC,OAAO;SACb,CAAC,CAAC;IACL,CAAC"}
|
package/dist/combo.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PoadFormElement } from './element.js';
|
|
2
|
+
export type PoadComboSource = readonly unknown[] | ((query: string) => readonly unknown[] | Promise<readonly unknown[]>);
|
|
3
|
+
export declare class PoadComboElement extends PoadFormElement {
|
|
4
|
+
static props: {
|
|
5
|
+
readonly value: "json";
|
|
6
|
+
readonly suggestions: "json";
|
|
7
|
+
readonly optionLabel: "string";
|
|
8
|
+
readonly minLength: "number";
|
|
9
|
+
readonly delay: "number";
|
|
10
|
+
readonly dropdown: "boolean";
|
|
11
|
+
readonly forceSelection: "boolean";
|
|
12
|
+
readonly multiple: "boolean";
|
|
13
|
+
readonly clearable: "boolean";
|
|
14
|
+
readonly readonly: "boolean";
|
|
15
|
+
readonly disabled: "boolean";
|
|
16
|
+
readonly invalid: "boolean";
|
|
17
|
+
readonly placeholder: "string";
|
|
18
|
+
readonly emptyMessage: "string";
|
|
19
|
+
readonly size: "string";
|
|
20
|
+
readonly panelMaxHeight: "number";
|
|
21
|
+
readonly ariaLabel: "string";
|
|
22
|
+
readonly name: "string";
|
|
23
|
+
readonly required: "boolean";
|
|
24
|
+
};
|
|
25
|
+
static functions: readonly ["renderOption"];
|
|
26
|
+
value?: unknown;
|
|
27
|
+
suggestions?: PoadComboSource;
|
|
28
|
+
/** Chemin du libellé d'une suggestion objet (défaut `label`). */
|
|
29
|
+
optionLabel?: string;
|
|
30
|
+
minLength?: number;
|
|
31
|
+
/** Délai avant la recherche (ms, défaut 250). */
|
|
32
|
+
delay?: number;
|
|
33
|
+
dropdown?: boolean;
|
|
34
|
+
forceSelection?: boolean;
|
|
35
|
+
multiple?: boolean;
|
|
36
|
+
clearable?: boolean;
|
|
37
|
+
readonly?: boolean;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
invalid?: boolean;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
emptyMessage?: string;
|
|
42
|
+
size?: 'sm' | 'md' | 'lg';
|
|
43
|
+
panelMaxHeight?: number;
|
|
44
|
+
ariaLabel: string | null;
|
|
45
|
+
name?: string;
|
|
46
|
+
required?: boolean;
|
|
47
|
+
/** Rendu d'une suggestion. */
|
|
48
|
+
renderOption?: (option: unknown, context: {
|
|
49
|
+
readonly selected: boolean;
|
|
50
|
+
readonly index: number;
|
|
51
|
+
readonly label: string;
|
|
52
|
+
}) => string | Node;
|
|
53
|
+
protected readonly resetProps: string[];
|
|
54
|
+
private text;
|
|
55
|
+
/** Valeur dont le texte du champ est tiré (choix unique) : une autre valeur posée par la page récrit le texte. */
|
|
56
|
+
private shown;
|
|
57
|
+
private open;
|
|
58
|
+
private loading;
|
|
59
|
+
private items;
|
|
60
|
+
private active;
|
|
61
|
+
private width;
|
|
62
|
+
private timer;
|
|
63
|
+
private seq;
|
|
64
|
+
private readonly tracker;
|
|
65
|
+
private readonly outside;
|
|
66
|
+
private get path();
|
|
67
|
+
private get values();
|
|
68
|
+
private input;
|
|
69
|
+
protected formValue(): {
|
|
70
|
+
value: FormData;
|
|
71
|
+
missing: boolean;
|
|
72
|
+
} | {
|
|
73
|
+
value: string | null;
|
|
74
|
+
missing: boolean;
|
|
75
|
+
};
|
|
76
|
+
disconnectedCallback(): void;
|
|
77
|
+
private write;
|
|
78
|
+
private setOpen;
|
|
79
|
+
private close;
|
|
80
|
+
private search;
|
|
81
|
+
private onInput;
|
|
82
|
+
private pick;
|
|
83
|
+
private onBlur;
|
|
84
|
+
private readonly onKeydown;
|
|
85
|
+
protected updated(): void;
|
|
86
|
+
protected render(): import("./dom.js").VNode;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=combo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combo.d.ts","sourceRoot":"","sources":["../src/combo.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,MAAM,MAAM,eAAe,GAAG,SAAS,OAAO,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;AAEzH,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,OAAgB,KAAK;;;;;;;;;;;;;;;;;;;;MAIV;IACX,OAAgB,SAAS,4BAA6B;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,eAAe,CAAC;IACtC,iEAAiE;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YA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AAC,QAAQ,CAAC,SAAS,CAUxB;cACiB,OAAO,IAAI,IAAI;IAOlC,SAAS,CAAC,MAAM;CAsDjB"}
|
package/dist/combo.js
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <poad-combo name="city" placeholder="City…" min-length="2" force-selection suggestions='[{"label":"Lyon"},{"label":"Lens"}]'></poad-combo>
|
|
3
|
+
* combo.suggestions = async (query) => (await fetch(`/cities?q=${query}`)).json(); une source qui cherche
|
|
4
|
+
* <poad-combo multiple dropdown suggestions='["Concrete","Steel","Wood"]'></poad-combo>
|
|
5
|
+
*
|
|
6
|
+
* Saisie avec suggestions (« autocomplete ») : machine `combo` de @poadio/ui-core (filtre sans accents ni casse, clavier
|
|
7
|
+
* ↓ ↑ Entrée Échap Tab et Retour arrière en choix multiple, choix, sortie du champ — texte libre ou `force-selection` —,
|
|
8
|
+
* attributs `combobox` / `listbox`). `suggestions` : un tableau (filtré ici) ou, en propriété, une fonction de la requête
|
|
9
|
+
* qui rend un tableau ou une promesse (la dernière réponse gagne). Propriété `value` : texte libre (chaîne), suggestion
|
|
10
|
+
* (objet) ou, en `multiple`, tableau (puces). Évènements : `change` (et `input`) quand l'utilisateur choisit, efface ou
|
|
11
|
+
* quitte le champ ; en texte libre, `input` seul à chaque frappe (la valeur suit) ; `search` (detail : la requête),
|
|
12
|
+
* `openchange`. Formulaire : `name` (le libellé ; une entrée par puce en `multiple`), `required`. Même DOM, mêmes
|
|
13
|
+
* classes, même ARIA que `poad-combo` d'ui-angular. Styles : `combo.css`, `icon.css`, `floating.css`.
|
|
14
|
+
*/
|
|
15
|
+
import { SELECT_PLACEMENTS, comboBlur, comboFilter, comboInput, comboInputProps, comboIsSelected, comboKeydown, comboLabel, comboOptionProps, comboPick, comboResults, comboRootClasses, comboTextOf, comboValues, } from '@poadio/ui-core';
|
|
16
|
+
import { classOf, h } from './dom.js';
|
|
17
|
+
import { PoadFormElement } from './element.js';
|
|
18
|
+
import { FloatingTracker, Listening, listenOutside } from './floating.js';
|
|
19
|
+
import { icon } from './icon.js';
|
|
20
|
+
export class PoadComboElement extends PoadFormElement {
|
|
21
|
+
static props = {
|
|
22
|
+
value: 'json', suggestions: 'json', optionLabel: 'string', minLength: 'number', delay: 'number', dropdown: 'boolean', forceSelection: 'boolean',
|
|
23
|
+
multiple: 'boolean', clearable: 'boolean', readonly: 'boolean', disabled: 'boolean', invalid: 'boolean', placeholder: 'string', emptyMessage: 'string',
|
|
24
|
+
size: 'string', panelMaxHeight: 'number', ariaLabel: 'string', name: 'string', required: 'boolean',
|
|
25
|
+
};
|
|
26
|
+
static functions = ['renderOption'];
|
|
27
|
+
resetProps = ['value'];
|
|
28
|
+
text = '';
|
|
29
|
+
/** Valeur dont le texte du champ est tiré (choix unique) : une autre valeur posée par la page récrit le texte. */
|
|
30
|
+
shown = undefined;
|
|
31
|
+
open = false;
|
|
32
|
+
loading = false;
|
|
33
|
+
items = [];
|
|
34
|
+
active = -1;
|
|
35
|
+
width = 0;
|
|
36
|
+
timer = null;
|
|
37
|
+
seq = 0;
|
|
38
|
+
tracker = new FloatingTracker(() => this.update());
|
|
39
|
+
outside = new Listening(() => listenOutside(() => [this], () => this.close()));
|
|
40
|
+
get path() { return this.optionLabel ?? 'label'; }
|
|
41
|
+
get values() { return comboValues(this.value, !!this.multiple); }
|
|
42
|
+
input() { return this.querySelector(':scope > .poad-combo input.st__input'); }
|
|
43
|
+
formValue() {
|
|
44
|
+
if (this.multiple) {
|
|
45
|
+
const values = this.values;
|
|
46
|
+
if (!this.name || !values.length)
|
|
47
|
+
return { value: null, missing: !values.length };
|
|
48
|
+
const data = new FormData();
|
|
49
|
+
for (const v of values)
|
|
50
|
+
data.append(this.name, comboLabel(v, this.path));
|
|
51
|
+
return { value: data, missing: false };
|
|
52
|
+
}
|
|
53
|
+
const text = comboTextOf(this.value, this.path);
|
|
54
|
+
return { value: text || null, missing: !text };
|
|
55
|
+
}
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
super.disconnectedCallback();
|
|
58
|
+
if (this.timer)
|
|
59
|
+
clearTimeout(this.timer);
|
|
60
|
+
this.open = false;
|
|
61
|
+
this.tracker.sync(null, null);
|
|
62
|
+
this.outside.toggle(false);
|
|
63
|
+
}
|
|
64
|
+
write(next, commit = true) {
|
|
65
|
+
if (!this.multiple)
|
|
66
|
+
this.shown = next;
|
|
67
|
+
this.value = next;
|
|
68
|
+
if (commit)
|
|
69
|
+
this.changed(next);
|
|
70
|
+
else
|
|
71
|
+
this.emit('input', next);
|
|
72
|
+
}
|
|
73
|
+
setOpen(next) {
|
|
74
|
+
if (next === this.open)
|
|
75
|
+
return;
|
|
76
|
+
this.open = next;
|
|
77
|
+
if (next)
|
|
78
|
+
this.width = this.querySelector(':scope > .poad-combo > .st')?.getBoundingClientRect().width ?? 0;
|
|
79
|
+
this.update();
|
|
80
|
+
this.emit('openchange', next);
|
|
81
|
+
}
|
|
82
|
+
close() {
|
|
83
|
+
if (!this.open)
|
|
84
|
+
return;
|
|
85
|
+
this.active = -1;
|
|
86
|
+
this.setOpen(false);
|
|
87
|
+
}
|
|
88
|
+
async search(q) {
|
|
89
|
+
this.emit('search', q);
|
|
90
|
+
const my = ++this.seq;
|
|
91
|
+
const source = this.suggestions ?? [];
|
|
92
|
+
let res = [];
|
|
93
|
+
if (typeof source === 'function') {
|
|
94
|
+
this.loading = true;
|
|
95
|
+
this.update();
|
|
96
|
+
try {
|
|
97
|
+
res = await source(q);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
res = [];
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
if (my === this.seq) {
|
|
104
|
+
this.loading = false;
|
|
105
|
+
this.update();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else
|
|
110
|
+
res = comboFilter(source, q, this.path);
|
|
111
|
+
if (my !== this.seq)
|
|
112
|
+
return;
|
|
113
|
+
this.items = res;
|
|
114
|
+
this.active = comboResults(res.length).active;
|
|
115
|
+
if (!this.open)
|
|
116
|
+
this.setOpen(true);
|
|
117
|
+
else
|
|
118
|
+
this.update();
|
|
119
|
+
}
|
|
120
|
+
onInput(v) {
|
|
121
|
+
this.text = v;
|
|
122
|
+
// texte libre : la valeur suit la frappe (évènement `input` seul, comme un champ natif)
|
|
123
|
+
if (!this.multiple && !this.forceSelection)
|
|
124
|
+
this.write(v || null, false);
|
|
125
|
+
if (comboInput(v, this.minLength ?? 1) === 'close') {
|
|
126
|
+
this.close();
|
|
127
|
+
this.update();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (this.timer)
|
|
131
|
+
clearTimeout(this.timer);
|
|
132
|
+
this.timer = setTimeout(() => void this.search(v), this.delay ?? 250);
|
|
133
|
+
}
|
|
134
|
+
pick(o) {
|
|
135
|
+
const r = comboPick(this.value, o, { multiple: this.multiple, labelPath: this.path });
|
|
136
|
+
this.text = r.text;
|
|
137
|
+
if (r.changed)
|
|
138
|
+
this.write(r.value);
|
|
139
|
+
this.close();
|
|
140
|
+
this.update();
|
|
141
|
+
}
|
|
142
|
+
onBlur() {
|
|
143
|
+
const r = comboBlur(this.value, this.text, { forceSelection: this.forceSelection, multiple: this.multiple, labelPath: this.path });
|
|
144
|
+
if (!r)
|
|
145
|
+
return;
|
|
146
|
+
if (r.text !== undefined)
|
|
147
|
+
this.text = r.text;
|
|
148
|
+
if ('value' in r)
|
|
149
|
+
this.write(r.value);
|
|
150
|
+
this.update();
|
|
151
|
+
}
|
|
152
|
+
onKeydown = (e) => {
|
|
153
|
+
const values = this.values;
|
|
154
|
+
const r = comboKeydown({ open: this.open, active: this.active, count: this.items.length, multiple: !!this.multiple, text: this.text, valuesCount: values.length }, e.key);
|
|
155
|
+
if (r.preventDefault)
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
const a = r.action;
|
|
158
|
+
if (a.type === 'search')
|
|
159
|
+
void this.search(this.text);
|
|
160
|
+
else if (a.type === 'move') {
|
|
161
|
+
this.active = a.active;
|
|
162
|
+
this.update();
|
|
163
|
+
}
|
|
164
|
+
else if (a.type === 'pick')
|
|
165
|
+
this.pick(this.items[a.index]);
|
|
166
|
+
else if (a.type === 'close')
|
|
167
|
+
this.close();
|
|
168
|
+
else if (a.type === 'remove-last')
|
|
169
|
+
this.write(values.slice(0, -1));
|
|
170
|
+
};
|
|
171
|
+
updated() {
|
|
172
|
+
super.updated();
|
|
173
|
+
const pane = this.open ? this.querySelector(':scope > .poad-combo > .poad-combo-pane') : null;
|
|
174
|
+
this.tracker.sync(pane ? this.querySelector(':scope > .poad-combo > .st') : null, pane, { candidates: SELECT_PLACEMENTS, offset: 4, shift: true });
|
|
175
|
+
this.outside.toggle(this.open);
|
|
176
|
+
}
|
|
177
|
+
render() {
|
|
178
|
+
const { t, text: tx } = this.i18n();
|
|
179
|
+
const registry = this.icons();
|
|
180
|
+
const multiple = !!this.multiple;
|
|
181
|
+
// valeur posée par la page (choix unique) → texte du champ
|
|
182
|
+
if (!multiple && this.value !== this.shown) {
|
|
183
|
+
this.shown = this.value;
|
|
184
|
+
this.text = comboTextOf(this.value, this.path);
|
|
185
|
+
}
|
|
186
|
+
const values = this.values;
|
|
187
|
+
const listId = `${this.uid}-list`;
|
|
188
|
+
const ia = comboInputProps({ open: this.open, listId, active: this.active, invalid: this.invalid });
|
|
189
|
+
const disabled = this.inactive;
|
|
190
|
+
const input = h('input', {
|
|
191
|
+
class: 'st__input', role: ia.role, placeholder: multiple && values.length ? '' : (this.placeholder ?? ''), value: this.text, disabled,
|
|
192
|
+
readonly: !multiple && this.readonly, autocomplete: 'off', spellcheck: 'false', 'aria-autocomplete': ia['aria-autocomplete'], 'aria-expanded': ia['aria-expanded'],
|
|
193
|
+
'aria-controls': ia['aria-controls'], 'aria-activedescendant': ia['aria-activedescendant'], 'aria-invalid': multiple ? undefined : ia['aria-invalid'],
|
|
194
|
+
'aria-label': this.ariaLabel || undefined, oninput: (e) => this.onInput(e.target.value), onkeydown: this.onKeydown,
|
|
195
|
+
onblur: () => this.onBlur(),
|
|
196
|
+
});
|
|
197
|
+
const clear = (e) => { e.stopPropagation(); this.text = ''; this.write(multiple ? [] : null); this.close(); this.update(); };
|
|
198
|
+
const removeAt = (i, e) => { e.stopPropagation(); if (disabled)
|
|
199
|
+
return; this.write(values.filter((_, k) => k !== i)); };
|
|
200
|
+
return h('div', { class: ['poad-combo', comboRootClasses({ open: this.open, disabled, invalid: this.invalid, size: this.size ?? 'md' })] }, [
|
|
201
|
+
h('div', { class: ['st', { 'st--multi': multiple }], onclick: () => this.input()?.focus() }, [
|
|
202
|
+
multiple ? h('span', { class: 'st__chips' }, [
|
|
203
|
+
values.map((v, i) => h('span', { class: 'st__chip' }, [
|
|
204
|
+
comboLabel(v, this.path),
|
|
205
|
+
h('button', { type: 'button', tabindex: -1, 'aria-label': t('common.remove'), onclick: (e) => removeAt(i, e) }, icon(registry, 'x', { size: 10 })),
|
|
206
|
+
])),
|
|
207
|
+
input,
|
|
208
|
+
]) : input,
|
|
209
|
+
this.loading && icon(registry, 'loader', { size: 14, spin: true, class: 'st__spin' }),
|
|
210
|
+
this.clearable && (this.text || values.length > 0) && !disabled && h('button', {
|
|
211
|
+
type: 'button', class: 'st__clear', tabindex: -1, 'aria-label': t('common.clear'), onclick: clear,
|
|
212
|
+
}, icon(registry, 'x', { size: 12 })),
|
|
213
|
+
this.dropdown && h('button', {
|
|
214
|
+
type: 'button', class: 'st__dd', tabindex: -1, 'aria-label': t('select.showSuggestions'),
|
|
215
|
+
onclick: (e) => {
|
|
216
|
+
e.stopPropagation();
|
|
217
|
+
if (disabled)
|
|
218
|
+
return;
|
|
219
|
+
if (this.open) {
|
|
220
|
+
this.close();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
this.input()?.focus();
|
|
224
|
+
void this.search('');
|
|
225
|
+
},
|
|
226
|
+
}, icon(registry, 'chevron-down', { size: 13, class: 'st__chev' })),
|
|
227
|
+
]),
|
|
228
|
+
this.open && h('div', { class: 'poad-floating poad-combo-pane', style: this.tracker.style }, h('div', { class: 'sp', style: { minWidth: `${this.width}px` } }, h('ul', { class: 'cb__list', role: 'listbox', id: listId, style: { maxHeight: `${this.panelMaxHeight ?? 260}px` } }, this.items.length ? this.items.map((o, i) => {
|
|
229
|
+
const op = comboOptionProps(listId, i, i === this.active, comboIsSelected(this.value, o, multiple));
|
|
230
|
+
return h('li', {
|
|
231
|
+
role: op.role, id: op.id, class: classOf(op.classes) || undefined, 'aria-selected': op['aria-selected'],
|
|
232
|
+
onmousedown: (e) => e.preventDefault(), onmouseenter: () => { this.active = i; this.update(); }, onclick: () => this.pick(o),
|
|
233
|
+
}, this.renderOption ? this.renderOption(o, { selected: op.classes['is-on'], index: i, label: comboLabel(o, this.path) }) : comboLabel(o, this.path));
|
|
234
|
+
}) : !this.loading && h('li', { class: 'sp__empty' }, tx(this.emptyMessage, 'select.noSuggestions'))))),
|
|
235
|
+
]);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=combo.js.map
|