@poadio/ui-elements 0.3.0 → 0.5.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.
Files changed (292) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +19 -2
  3. package/dist/accordion.d.ts +17 -1
  4. package/dist/accordion.d.ts.map +1 -1
  5. package/dist/accordion.js +19 -2
  6. package/dist/accordion.js.map +1 -1
  7. package/dist/avatar.d.ts +26 -2
  8. package/dist/avatar.d.ts.map +1 -1
  9. package/dist/avatar.js +1 -0
  10. package/dist/avatar.js.map +1 -1
  11. package/dist/badge.d.ts +15 -0
  12. package/dist/badge.d.ts.map +1 -1
  13. package/dist/badge.js.map +1 -1
  14. package/dist/block.d.ts +22 -0
  15. package/dist/block.d.ts.map +1 -0
  16. package/dist/block.js +40 -0
  17. package/dist/block.js.map +1 -0
  18. package/dist/breadcrumb.d.ts +45 -0
  19. package/dist/breadcrumb.d.ts.map +1 -0
  20. package/dist/breadcrumb.js +60 -0
  21. package/dist/breadcrumb.js.map +1 -0
  22. package/dist/button-group.d.ts +12 -0
  23. package/dist/button-group.d.ts.map +1 -1
  24. package/dist/button-group.js +5 -0
  25. package/dist/button-group.js.map +1 -1
  26. package/dist/button.d.ts +16 -1
  27. package/dist/button.d.ts.map +1 -1
  28. package/dist/button.js +4 -0
  29. package/dist/button.js.map +1 -1
  30. package/dist/card.d.ts +34 -0
  31. package/dist/card.d.ts.map +1 -0
  32. package/dist/card.js +40 -0
  33. package/dist/card.js.map +1 -0
  34. package/dist/carousel.d.ts +95 -0
  35. package/dist/carousel.d.ts.map +1 -0
  36. package/dist/carousel.js +172 -0
  37. package/dist/carousel.js.map +1 -0
  38. package/dist/checkbox.d.ts +15 -0
  39. package/dist/checkbox.d.ts.map +1 -1
  40. package/dist/checkbox.js +5 -0
  41. package/dist/checkbox.js.map +1 -1
  42. package/dist/chip.d.ts +18 -0
  43. package/dist/chip.d.ts.map +1 -1
  44. package/dist/chip.js +5 -0
  45. package/dist/chip.js.map +1 -1
  46. package/dist/colorpicker.d.ts +21 -0
  47. package/dist/colorpicker.d.ts.map +1 -1
  48. package/dist/colorpicker.js +5 -0
  49. package/dist/colorpicker.js.map +1 -1
  50. package/dist/combo.d.ts +24 -1
  51. package/dist/combo.d.ts.map +1 -1
  52. package/dist/combo.js +6 -0
  53. package/dist/combo.js.map +1 -1
  54. package/dist/confirm.d.ts +2 -0
  55. package/dist/confirm.d.ts.map +1 -1
  56. package/dist/confirm.js.map +1 -1
  57. package/dist/datepicker.d.ts +35 -1
  58. package/dist/datepicker.d.ts.map +1 -1
  59. package/dist/datepicker.js +9 -0
  60. package/dist/datepicker.js.map +1 -1
  61. package/dist/dialog.d.ts +35 -2
  62. package/dist/dialog.d.ts.map +1 -1
  63. package/dist/dialog.js +14 -0
  64. package/dist/dialog.js.map +1 -1
  65. package/dist/divider.d.ts +8 -0
  66. package/dist/divider.d.ts.map +1 -1
  67. package/dist/divider.js +1 -0
  68. package/dist/divider.js.map +1 -1
  69. package/dist/field.d.ts +14 -2
  70. package/dist/field.d.ts.map +1 -1
  71. package/dist/field.js +3 -0
  72. package/dist/field.js.map +1 -1
  73. package/dist/fieldset.d.ts +23 -0
  74. package/dist/fieldset.d.ts.map +1 -0
  75. package/dist/fieldset.js +50 -0
  76. package/dist/fieldset.js.map +1 -0
  77. package/dist/filter-chip.d.ts +34 -0
  78. package/dist/filter-chip.d.ts.map +1 -0
  79. package/dist/filter-chip.js +41 -0
  80. package/dist/filter-chip.js.map +1 -0
  81. package/dist/held.d.ts +20 -0
  82. package/dist/held.d.ts.map +1 -0
  83. package/dist/held.js +61 -0
  84. package/dist/held.js.map +1 -0
  85. package/dist/icon.d.ts +14 -0
  86. package/dist/icon.d.ts.map +1 -1
  87. package/dist/icon.js.map +1 -1
  88. package/dist/image.d.ts +63 -0
  89. package/dist/image.d.ts.map +1 -0
  90. package/dist/image.js +134 -0
  91. package/dist/image.js.map +1 -0
  92. package/dist/index.d.ts +41 -2
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +22 -3
  95. package/dist/index.js.map +1 -1
  96. package/dist/inplace.d.ts +20 -1
  97. package/dist/inplace.d.ts.map +1 -1
  98. package/dist/inplace.js +6 -0
  99. package/dist/inplace.js.map +1 -1
  100. package/dist/listbox.d.ts +126 -0
  101. package/dist/listbox.d.ts.map +1 -0
  102. package/dist/listbox.js +195 -0
  103. package/dist/listbox.js.map +1 -0
  104. package/dist/mask.d.ts +26 -0
  105. package/dist/mask.d.ts.map +1 -1
  106. package/dist/mask.js +9 -0
  107. package/dist/mask.js.map +1 -1
  108. package/dist/menu.d.ts +29 -0
  109. package/dist/menu.d.ts.map +1 -1
  110. package/dist/menu.js +11 -1
  111. package/dist/menu.js.map +1 -1
  112. package/dist/message.d.ts +23 -1
  113. package/dist/message.d.ts.map +1 -1
  114. package/dist/message.js +4 -0
  115. package/dist/message.js.map +1 -1
  116. package/dist/meter.d.ts +18 -2
  117. package/dist/meter.d.ts.map +1 -1
  118. package/dist/meter.js.map +1 -1
  119. package/dist/multiselect.d.ts +57 -2
  120. package/dist/multiselect.d.ts.map +1 -1
  121. package/dist/multiselect.js +8 -0
  122. package/dist/multiselect.js.map +1 -1
  123. package/dist/number.d.ts +20 -1
  124. package/dist/number.d.ts.map +1 -1
  125. package/dist/number.js +4 -0
  126. package/dist/number.js.map +1 -1
  127. package/dist/paginator.d.ts +14 -1
  128. package/dist/paginator.d.ts.map +1 -1
  129. package/dist/paginator.js +4 -0
  130. package/dist/paginator.js.map +1 -1
  131. package/dist/panel.d.ts +34 -0
  132. package/dist/panel.d.ts.map +1 -0
  133. package/dist/panel.js +57 -0
  134. package/dist/panel.js.map +1 -0
  135. package/dist/password.d.ts +18 -1
  136. package/dist/password.d.ts.map +1 -1
  137. package/dist/password.js +4 -0
  138. package/dist/password.js.map +1 -1
  139. package/dist/popover.d.ts +19 -0
  140. package/dist/popover.d.ts.map +1 -1
  141. package/dist/popover.js +6 -0
  142. package/dist/popover.js.map +1 -1
  143. package/dist/progress.d.ts +33 -0
  144. package/dist/progress.d.ts.map +1 -1
  145. package/dist/progress.js.map +1 -1
  146. package/dist/radio.d.ts +15 -0
  147. package/dist/radio.d.ts.map +1 -1
  148. package/dist/radio.js +15 -1
  149. package/dist/radio.js.map +1 -1
  150. package/dist/rating.d.ts +26 -1
  151. package/dist/rating.d.ts.map +1 -1
  152. package/dist/rating.js +4 -0
  153. package/dist/rating.js.map +1 -1
  154. package/dist/scroll-top.d.ts +51 -0
  155. package/dist/scroll-top.d.ts.map +1 -0
  156. package/dist/scroll-top.js +65 -0
  157. package/dist/scroll-top.js.map +1 -0
  158. package/dist/segmented.d.ts +17 -0
  159. package/dist/segmented.d.ts.map +1 -1
  160. package/dist/segmented.js +4 -0
  161. package/dist/segmented.js.map +1 -1
  162. package/dist/select.d.ts +51 -1
  163. package/dist/select.d.ts.map +1 -1
  164. package/dist/select.js +7 -0
  165. package/dist/select.js.map +1 -1
  166. package/dist/skeleton.d.ts +24 -0
  167. package/dist/skeleton.d.ts.map +1 -1
  168. package/dist/skeleton.js.map +1 -1
  169. package/dist/slider.d.ts +37 -0
  170. package/dist/slider.d.ts.map +1 -1
  171. package/dist/slider.js +4 -0
  172. package/dist/slider.js.map +1 -1
  173. package/dist/speed-dial.d.ts +86 -0
  174. package/dist/speed-dial.d.ts.map +1 -0
  175. package/dist/speed-dial.js +108 -0
  176. package/dist/speed-dial.js.map +1 -0
  177. package/dist/split-button.d.ts +17 -0
  178. package/dist/split-button.d.ts.map +1 -1
  179. package/dist/split-button.js +6 -0
  180. package/dist/split-button.js.map +1 -1
  181. package/dist/splitter.d.ts +77 -0
  182. package/dist/splitter.d.ts.map +1 -0
  183. package/dist/splitter.js +130 -0
  184. package/dist/splitter.js.map +1 -0
  185. package/dist/stepper.d.ts +23 -1
  186. package/dist/stepper.d.ts.map +1 -1
  187. package/dist/stepper.js +24 -2
  188. package/dist/stepper.js.map +1 -1
  189. package/dist/switch.d.ts +15 -0
  190. package/dist/switch.d.ts.map +1 -1
  191. package/dist/switch.js +5 -0
  192. package/dist/switch.js.map +1 -1
  193. package/dist/table-filters.d.ts +66 -0
  194. package/dist/table-filters.d.ts.map +1 -0
  195. package/dist/table-filters.js +174 -0
  196. package/dist/table-filters.js.map +1 -0
  197. package/dist/table-panel.d.ts +86 -0
  198. package/dist/table-panel.d.ts.map +1 -0
  199. package/dist/table-panel.js +349 -0
  200. package/dist/table-panel.js.map +1 -0
  201. package/dist/table.d.ts +276 -7
  202. package/dist/table.d.ts.map +1 -1
  203. package/dist/table.js +433 -40
  204. package/dist/table.js.map +1 -1
  205. package/dist/tabs.d.ts +24 -1
  206. package/dist/tabs.d.ts.map +1 -1
  207. package/dist/tabs.js +25 -2
  208. package/dist/tabs.js.map +1 -1
  209. package/dist/tag.d.ts +13 -1
  210. package/dist/tag.d.ts.map +1 -1
  211. package/dist/tag.js +1 -0
  212. package/dist/tag.js.map +1 -1
  213. package/dist/timeline.d.ts +50 -0
  214. package/dist/timeline.d.ts.map +1 -0
  215. package/dist/timeline.js +39 -0
  216. package/dist/timeline.js.map +1 -0
  217. package/dist/toast.d.ts +17 -0
  218. package/dist/toast.d.ts.map +1 -1
  219. package/dist/toast.js +4 -0
  220. package/dist/toast.js.map +1 -1
  221. package/dist/toggle-button.d.ts +17 -1
  222. package/dist/toggle-button.d.ts.map +1 -1
  223. package/dist/toggle-button.js +5 -0
  224. package/dist/toggle-button.js.map +1 -1
  225. package/dist/tooltip.d.ts +9 -0
  226. package/dist/tooltip.d.ts.map +1 -1
  227. package/dist/tooltip.js +4 -0
  228. package/dist/tooltip.js.map +1 -1
  229. package/dist/upload.d.ts +196 -0
  230. package/dist/upload.d.ts.map +1 -0
  231. package/dist/upload.js +269 -0
  232. package/dist/upload.js.map +1 -0
  233. package/package.json +2 -2
  234. package/src/accordion.ts +23 -2
  235. package/src/avatar.ts +26 -2
  236. package/src/badge.ts +15 -0
  237. package/src/block.ts +48 -0
  238. package/src/breadcrumb.ts +85 -0
  239. package/src/button-group.ts +12 -0
  240. package/src/button.ts +16 -1
  241. package/src/card.ts +54 -0
  242. package/src/carousel.ts +212 -0
  243. package/src/checkbox.ts +15 -0
  244. package/src/chip.ts +18 -0
  245. package/src/colorpicker.ts +21 -0
  246. package/src/combo.ts +24 -1
  247. package/src/confirm.ts +2 -0
  248. package/src/datepicker.ts +35 -1
  249. package/src/dialog.ts +35 -2
  250. package/src/divider.ts +8 -0
  251. package/src/field.ts +14 -2
  252. package/src/fieldset.ts +57 -0
  253. package/src/filter-chip.ts +57 -0
  254. package/src/held.ts +57 -0
  255. package/src/icon.ts +14 -0
  256. package/src/image.ts +149 -0
  257. package/src/index.ts +31 -4
  258. package/src/inplace.ts +20 -1
  259. package/src/listbox.ts +236 -0
  260. package/src/mask.ts +26 -0
  261. package/src/menu.ts +33 -1
  262. package/src/message.ts +23 -1
  263. package/src/meter.ts +18 -2
  264. package/src/multiselect.ts +57 -2
  265. package/src/number.ts +20 -1
  266. package/src/paginator.ts +14 -1
  267. package/src/panel.ts +71 -0
  268. package/src/password.ts +18 -1
  269. package/src/popover.ts +19 -0
  270. package/src/progress.ts +33 -0
  271. package/src/radio.ts +21 -1
  272. package/src/rating.ts +26 -1
  273. package/src/scroll-top.ts +81 -0
  274. package/src/segmented.ts +17 -0
  275. package/src/select.ts +51 -1
  276. package/src/skeleton.ts +24 -0
  277. package/src/slider.ts +37 -0
  278. package/src/speed-dial.ts +140 -0
  279. package/src/split-button.ts +17 -0
  280. package/src/splitter.ts +151 -0
  281. package/src/stepper.ts +30 -2
  282. package/src/switch.ts +15 -0
  283. package/src/table-filters.ts +179 -0
  284. package/src/table-panel.ts +378 -0
  285. package/src/table.ts +557 -41
  286. package/src/tabs.ts +32 -2
  287. package/src/tag.ts +13 -1
  288. package/src/timeline.ts +66 -0
  289. package/src/toast.ts +17 -0
  290. package/src/toggle-button.ts +17 -1
  291. package/src/tooltip.ts +9 -0
  292. package/src/upload.ts +351 -0
@@ -0,0 +1,151 @@
1
+ /**
2
+ * <poad-splitter layout="horizontal" panel-sizes="[30,70]" state-key="files">
3
+ * <poad-splitter-panel min-size="10">…</poad-splitter-panel>
4
+ * <poad-splitter-panel>…</poad-splitter-panel>
5
+ * </poad-splitter>
6
+ *
7
+ * Séparateur redimensionnable (motif WAI-ARIA « window splitter ») : entre deux panneaux, une gouttière
8
+ * `role="separator"` nommée (`display.resizePanels`), qui porte la taille du panneau précédent et le désigne
9
+ * (`aria-controls`) ; glisser au pointeur, ← → (↑ ↓ en vertical) ±2 %, Début / Fin aux minimums, Entrée ou double-clic
10
+ * aux tailles initiales ; tailles gardées dans `localStorage` avec `stateKey`. Les `<poad-splitter-panel>` sont des
11
+ * déclarations : le splitter pose leur contenu dans ses panneaux. Tailles, clavier et attributs de @poadio/ui-core —
12
+ * même DOM que `poad-splitter` d'ui-angular. Style : `@poadio/ui-core/splitter.css`.
13
+ */
14
+ import {
15
+ SPLITTER_STORAGE_PREFIX, splitterClasses, splitterDragDelta, splitterGutterProps, splitterGutterTrack, splitterInitial, splitterKey, splitterNormalize,
16
+ splitterPanelTrack, splitterParseSaved, splitterPlacement, splitterResize, splitterTemplate, type SplitterLayout,
17
+ } from '@poadio/ui-core';
18
+ import { PoadDeclarationElement, declarations } from './declaration.js';
19
+ import { h, type Child } from './dom.js';
20
+ import { PoadElement } from './element.js';
21
+
22
+ /** Données d'un panneau déclaré. */
23
+ export interface SplitterPanelData {
24
+ readonly size?: number | null;
25
+ readonly minSize?: number;
26
+ }
27
+
28
+ /**
29
+ * Un panneau de `<poad-splitter>` (déclaration : le splitter pose son contenu à sa place).
30
+ * @slot default Le contenu du panneau (il défile s'il déborde).
31
+ */
32
+ export class PoadSplitterPanelElement extends PoadDeclarationElement {
33
+ static override props = {
34
+ /** Taille de départ, en % (sans `panel-sizes` sur le splitter). */
35
+ size: 'number',
36
+ /** Taille minimale, en %. */
37
+ minSize: 'number',
38
+ } as const;
39
+ }
40
+
41
+ /**
42
+ * Séparateur redimensionnable.
43
+ * @slot default Les panneaux : des `<poad-splitter-panel>`.
44
+ * @fires resizestart Début d'un glisser ; `detail` : les tailles de départ.
45
+ * @fires resizeend Fin d'un redimensionnement (glisser, clavier, retour) ; `detail` : les nouvelles tailles, en %.
46
+ */
47
+ export class PoadSplitterElement extends PoadElement {
48
+ static override props = { layout: 'string', panelSizes: 'json', minSizes: 'json', gutterSize: 'number', stateKey: 'string' } as const;
49
+ /**
50
+ * Panneaux côte à côte (`horizontal`) ou empilés (`vertical`).
51
+ * @default 'horizontal'
52
+ */
53
+ declare layout?: SplitterLayout;
54
+ /** Tailles de départ des panneaux, en % (sinon celles des panneaux, sinon parts égales). */
55
+ declare panelSizes?: readonly number[];
56
+ /** Tailles minimales des panneaux, en % (sinon le `min-size` de chaque panneau). */
57
+ declare minSizes?: readonly number[];
58
+ /**
59
+ * Largeur des gouttières, en px.
60
+ * @default 6
61
+ */
62
+ declare gutterSize?: number;
63
+ /** Clé de sauvegarde des tailles dans `localStorage` (`poad-splitter:<clé>`) ; vide : rien n'est gardé. */
64
+ declare stateKey?: string;
65
+ private sizes: number[] = [];
66
+ private initial: number[] = [];
67
+ private startKey = '';
68
+
69
+ private get panels() {
70
+ return declarations<SplitterPanelData>(this, this.content, this.tag('splitter-panel'), PoadSplitterPanelElement.props);
71
+ }
72
+ private sync(panels: readonly { data: SplitterPanelData }[]): void {
73
+ const n = panels.length;
74
+ const ps = Array.isArray(this.panelSizes) ? this.panelSizes : [];
75
+ const declared = ps.length === n ? ps : panels.map((p) => p.data.size);
76
+ const key = JSON.stringify([n, declared, this.stateKey ?? '']);
77
+ if (key === this.startKey) return;
78
+ this.startKey = key;
79
+ const saved = this.stateKey && typeof localStorage !== 'undefined' ? splitterParseSaved(localStorage.getItem(SPLITTER_STORAGE_PREFIX + this.stateKey), n) : null;
80
+ const s = splitterInitial(n, declared, saved);
81
+ this.initial = s.initial;
82
+ this.sizes = s.sizes;
83
+ }
84
+ private mins(panels: readonly { data: SplitterPanelData }[]): number[] {
85
+ const ms = Array.isArray(this.minSizes) ? this.minSizes : [];
86
+ return panels.map((p, i) => ms[i] ?? p.data.minSize ?? 0);
87
+ }
88
+ private end(): void {
89
+ if (this.stateKey && typeof localStorage !== 'undefined') localStorage.setItem(SPLITTER_STORAGE_PREFIX + this.stateKey, JSON.stringify(this.sizes));
90
+ this.emit('resizeend', [...this.sizes]);
91
+ }
92
+ /** Revient aux tailles initiales (comme Entrée ou un double-clic sur une gouttière). */
93
+ reset(): void {
94
+ this.sizes = splitterNormalize(this.initial);
95
+ this.update();
96
+ this.end();
97
+ }
98
+ private onKey(e: KeyboardEvent, g: number, mins: number[]): void {
99
+ const action = splitterKey(e.key, this.layout || 'horizontal');
100
+ if (!action) return;
101
+ e.preventDefault();
102
+ if (action.kind === 'reset') { this.reset(); return; }
103
+ this.sizes = splitterResize(this.sizes, mins, g, action.delta);
104
+ this.update();
105
+ this.end();
106
+ }
107
+ private onDown(e: PointerEvent, g: number, mins: number[]): void {
108
+ e.preventDefault();
109
+ const el = e.currentTarget as HTMLElement;
110
+ el.setPointerCapture?.(e.pointerId);
111
+ el.classList.add('is-active');
112
+ const root = this.querySelector('.poad-splitter')!.getBoundingClientRect();
113
+ const hz = (this.layout || 'horizontal') === 'horizontal';
114
+ const total = hz ? root.width : root.height;
115
+ const from = hz ? e.clientX : e.clientY;
116
+ const startSizes = [...this.sizes];
117
+ this.emit('resizestart', startSizes);
118
+ const move = (ev: PointerEvent) => { this.sizes = splitterResize(startSizes, mins, g, splitterDragDelta(from, hz ? ev.clientX : ev.clientY, total)); this.update(); };
119
+ const up = () => {
120
+ el.releasePointerCapture?.(e.pointerId);
121
+ el.classList.remove('is-active');
122
+ el.removeEventListener('pointermove', move);
123
+ el.removeEventListener('pointerup', up);
124
+ this.end();
125
+ };
126
+ el.addEventListener('pointermove', move);
127
+ el.addEventListener('pointerup', up);
128
+ }
129
+
130
+ protected render() {
131
+ const panels = this.panels;
132
+ this.sync(panels);
133
+ const layout = this.layout || 'horizontal';
134
+ const mins = this.mins(panels);
135
+ const n = panels.length;
136
+ const id = (i: number) => `${this.uid}-p${i}`;
137
+ const t = this.i18n().t;
138
+ return h('div', {
139
+ class: splitterClasses(layout),
140
+ style: { '--_g': `${this.gutterSize ?? 6}px`, [layout === 'vertical' ? 'gridTemplateRows' : 'gridTemplateColumns']: splitterTemplate(this.sizes) },
141
+ }, panels.flatMap((p, i): Child[] => {
142
+ const panel = h('div', { class: 'poad-splitter-panel', id: id(i), style: splitterPlacement(layout, splitterPanelTrack(i)) }, p.content);
143
+ if (i === n - 1) return [panel];
144
+ const gp = splitterGutterProps(layout, this.sizes[i] ?? 0, mins[i] ?? 0, id(i));
145
+ return [panel, h('div', {
146
+ class: 'poad-splitter__gutter', ...gp, tabindex: String(gp.tabindex), 'aria-label': t('display.resizePanels'), style: splitterPlacement(layout, splitterGutterTrack(i)),
147
+ onpointerdown: (e: PointerEvent) => this.onDown(e, i, mins), ondblclick: () => this.reset(), onkeydown: (e: KeyboardEvent) => this.onKey(e, i, mins),
148
+ }, h('i'))];
149
+ }));
150
+ }
151
+ }
package/src/stepper.ts CHANGED
@@ -28,22 +28,50 @@ export interface StepData {
28
28
  readonly state?: StepState | null;
29
29
  }
30
30
 
31
- /** Déclaration d'une étape dans un `<poad-stepper>` ; ses enfants sont son contenu. */
31
+ /**
32
+ * Déclaration d'une étape dans un `<poad-stepper>` ; ses enfants sont son contenu.
33
+ * @slot default Contenu de l'étape, affiché quand elle est courante.
34
+ */
32
35
  export class PoadStepElement extends PoadDeclarationElement {
33
36
  static override props = {
34
- label: 'string', description: 'string', icon: 'string', optional: 'boolean', disabled: 'boolean', completed: 'boolean', state: 'string',
37
+ /** Libellé de l'étape. */
38
+ label: 'string',
39
+ /** Texte secondaire sous le libellé. */
40
+ description: 'string',
41
+ /** Icône dans la pastille, à la place du numéro. */
42
+ icon: 'string',
43
+ /** Étape facultative (mention affichée) ; elle ne bloque pas le mode `linear`. */
44
+ optional: 'boolean',
45
+ /** Étape désactivée : on ne peut pas y aller. */
46
+ disabled: 'boolean',
47
+ /** Étape validée (utilisé par `linear`). */
48
+ completed: 'boolean',
49
+ /** État forcé ; sinon dérivé de l'étape courante. */
50
+ state: 'string',
35
51
  } as const;
36
52
  }
37
53
 
54
+ /**
55
+ * Une suite d'étapes.
56
+ * @slot default Les étapes : des `<poad-step>`.
57
+ * @fires change L'utilisateur va à une autre étape (clic) ; `detail` : son rang.
58
+ * @fires stepclick Clic sur une étape, même non atteignable ; `detail` : son rang.
59
+ */
38
60
  export class PoadStepperElement extends PoadElement {
39
61
  static override props = {
40
62
  activeIndex: 'number', linear: 'boolean', clickable: 'boolean', orientation: 'string', size: 'string', ariaLabel: 'string',
41
63
  } as const;
64
+ /** Rang de l'étape courante. */
42
65
  declare activeIndex?: number;
66
+ /** Une étape suit seulement des étapes complétées (`completed`) ou facultatives. */
43
67
  declare linear?: boolean;
68
+ /** Un clic sur une étape y va (défaut oui). */
44
69
  declare clickable?: boolean;
70
+ /** Disposition ; en vertical, le contenu s'ouvre sous l'étape courante. */
45
71
  declare orientation?: 'horizontal' | 'vertical';
72
+ /** Taille : `sm` ou `md`. */
46
73
  declare size?: 'sm' | 'md';
74
+ /** Nom accessible de la liste d'étapes. */
47
75
  declare ariaLabel: string | null;
48
76
 
49
77
  protected render() {
package/src/switch.ts CHANGED
@@ -9,20 +9,35 @@ import { switchControlProps, switchLabelProps, switchRootClasses, switchTransiti
9
9
  import { h } from './dom.js';
10
10
  import { PoadFormElement } from './element.js';
11
11
 
12
+ /**
13
+ * @fires input Nouvelle valeur, au geste de l'utilisateur seulement (une valeur imposée par l'application n'émet rien).
14
+ * @fires change Nouvelle valeur, au geste de l'utilisateur seulement (une valeur imposée par l'application n'émet rien).
15
+ * @slot default Contenu ajouté après le libellé.
16
+ */
12
17
  export class PoadSwitchElement extends PoadFormElement {
13
18
  static override props = {
14
19
  checked: 'boolean', disabled: 'boolean', readonly: 'boolean', label: 'string', ariaLabel: 'string', size: 'string', labelPosition: 'string',
15
20
  name: 'string', value: 'string', required: 'boolean',
16
21
  } as const;
22
+ /** État coché ; l'attribut donne l'état de départ et celui de `form.reset()`. */
17
23
  declare checked?: boolean;
24
+ /** Désactivé : hors tabulation, aucun geste. */
18
25
  declare disabled?: boolean;
26
+ /** Lecture seule : atteignable au clavier, mais figé. */
19
27
  declare readonly?: boolean;
28
+ /** Libellé visible ; absent : donner `aria-label`. */
20
29
  declare label?: string;
30
+ /** Nom accessible quand il n'y a pas de libellé visible. */
21
31
  declare ariaLabel: string | null;
32
+ /** Taille : `sm` ou `md`. */
22
33
  declare size?: 'sm' | 'md';
34
+ /** Côté du libellé : `left` ou `right`. */
23
35
  declare labelPosition?: 'left' | 'right';
36
+ /** Nom du champ soumis avec le `<form>`. */
24
37
  declare name?: string;
38
+ /** Valeur soumise quand le contrôle est coché ; défaut `on`. */
25
39
  declare value?: string;
40
+ /** Obligatoire : le formulaire est invalide tant que le contrôle n'est pas coché. */
26
41
  declare required?: boolean;
27
42
  protected readonly resetProps = ['checked'];
28
43
 
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Table, tranche 2 — champs de filtre de `<poad-table>` (interne) : recherche de la barre d'outils et ligne de filtres
3
+ * à opérateurs sous l'en-tête. Même DOM, mêmes classes et même ARIA que `poad-table` d'ui-angular ; la logique
4
+ * (opérateurs, valeur gardée au changement d'opérateur, bornes, valeurs multiples, état) est le modèle `table.filter`
5
+ * du socle. Ici : les champs, leurs brouillons de frappe, les menus (`MenuController`, celui de `<poad-menu>`) et les
6
+ * listes oui / non et à choix unique (`<poad-select>` posés par `HeldElements`).
7
+ */
8
+ import {
9
+ tableColumnId, tableFilterIsActive, tableFilterKind, tableFilterOperator, tableFilterOperatorLabel, tableFilterOperators, tableFilterPart, tableFilterValues,
10
+ type IconRegistry, type TableFilterMatchMode, type TableFilterOperator, type TableFilters,
11
+ } from '@poadio/ui-core';
12
+ import { h, type Child } from './dom.js';
13
+ import { HeldElements } from './held.js';
14
+ import type { UiI18nValue } from './i18n.js';
15
+ import { icon } from './icon.js';
16
+ import { MenuController, type PoadMenuItem } from './menu.js';
17
+ import type { PoadTableColumn } from './table.js';
18
+
19
+ /** Recherche globale de la barre d'outils (`.dt-bar__search`). */
20
+ export function tableSearch(i18n: UiI18nValue, registry: IconRegistry, o: { readonly text: string; readonly placeholder?: string; readonly onSearch: (text: string, immediate?: boolean) => void }): Child {
21
+ const label = i18n.text(o.placeholder, 'table.searchPlaceholder');
22
+ return h('div', { class: 'dt-bar__search' }, [
23
+ icon(registry, 'search', { size: 14 }),
24
+ h('input', { type: 'search', placeholder: label, value: o.text, 'aria-label': label, oninput: (e: Event) => o.onSearch((e.target as HTMLInputElement).value) }),
25
+ o.text && h('button', { type: 'button', class: 'dt-bar__clear', 'aria-label': i18n.t('table.clearSearch'), onclick: () => o.onSearch('', true) }, icon(registry, 'x', { size: 12 })),
26
+ ]);
27
+ }
28
+
29
+ /** Ce que la ligne de filtres demande à la table (réducteur du socle et minuteries, côté table). */
30
+ export interface TableFilterActions {
31
+ /** Pose une valeur (`delayed` : après le délai des filtres). */
32
+ set(column: PoadTableColumn, value: unknown, matchMode?: TableFilterMatchMode, delayed?: boolean): void;
33
+ /** Une borne d'un filtre « entre » (après le délai). */
34
+ part(column: PoadTableColumn, index: 0 | 1, raw: string): void;
35
+ operator(column: PoadTableColumn, op: TableFilterOperator): void;
36
+ toggleValue(column: PoadTableColumn, value: unknown): void;
37
+ clear(column: PoadTableColumn): void;
38
+ }
39
+
40
+ /** Ce que reçoit `renderFilter` (ou `filterCell` d'une colonne) : `filter(valeur, mode)` pose le filtre de la colonne. */
41
+ export interface PoadTableFilterContext {
42
+ readonly column: PoadTableColumn;
43
+ readonly value: unknown;
44
+ readonly filter: (value: unknown, matchMode?: TableFilterMatchMode) => void;
45
+ }
46
+
47
+ /**
48
+ * Cellules de la ligne de filtres (`tr.flt`) et menus (opérateurs, valeurs) d'une table. `drafts` : textes en cours
49
+ * de frappe (avant le délai), par colonne et par borne ; oubliés dès que l'état des filtres change.
50
+ */
51
+ export class TableFilterRow {
52
+ private drafts: Record<string, string> = {};
53
+ private seen: TableFilters | null = null;
54
+ private menu: { readonly type: 'op' | 'in'; readonly column: PoadTableColumn } | null = null;
55
+ private anchor: HTMLElement | null = null;
56
+ private readonly controller: MenuController;
57
+ private readonly held = new HeldElements();
58
+ private menuShown = false;
59
+ /** `uid` : identifiant de la table (menu) ; `selectTag` : balise de la liste de la même définition. */
60
+ constructor(private readonly host: { update(): void }, private readonly uid: string, private readonly selectTag: string) {
61
+ this.controller = new MenuController(host);
62
+ }
63
+
64
+ private key(c: PoadTableColumn, i: 0 | 1) { return tableColumnId(c) + '|' + i; }
65
+ private forget(c: PoadTableColumn) { delete this.drafts[this.key(c, 0)]; delete this.drafts[this.key(c, 1)]; }
66
+ private shown(filters: TableFilters, c: PoadTableColumn, i: 0 | 1): string {
67
+ const d = this.drafts[this.key(c, i)];
68
+ if (d !== undefined) return d;
69
+ const v = tableFilterPart(filters[c.field ?? '']?.value ?? null, i);
70
+ return v instanceof Date ? v.toISOString().slice(0, 10) : String(v ?? '');
71
+ }
72
+ private open(type: 'op' | 'in', column: PoadTableColumn, el: HTMLElement) {
73
+ this.anchor = el;
74
+ this.menu = { type, column };
75
+ this.host.update();
76
+ }
77
+
78
+ /** Au début de chaque rendu : l'état a changé (filtre appliqué, ou posé par la page) → les champs relisent l'état. */
79
+ begin(filters: TableFilters): void {
80
+ if (filters !== this.seen) { this.seen = filters; this.drafts = {}; }
81
+ }
82
+
83
+ cell(i18n: UiI18nValue, registry: IconRegistry, filters: TableFilters, c: PoadTableColumn, actions: TableFilterActions, custom?: (ctx: PoadTableFilterContext) => string | Node | null | undefined): Child {
84
+ if (!c.filterable) return null;
85
+ const { t } = i18n;
86
+ const label = (op: TableFilterOperator) => tableFilterOperatorLabel(op, (k) => t(k));
87
+ const field = c.field ?? '';
88
+ const value = filters[field]?.value ?? null;
89
+ if (custom) {
90
+ const out = custom({ column: c, value, filter: (v, m) => actions.set(c, v, m) });
91
+ if (out != null) return out;
92
+ }
93
+ const kind = tableFilterKind(c);
94
+ const op = tableFilterOperator(c, filters);
95
+ const active = tableFilterIsActive(filters[field]);
96
+ const name = c.header ?? '';
97
+ const type = kind === 'number' ? 'number' : kind === 'date' ? 'date' : 'search';
98
+ const any = c.filterPlaceholder || t('filter.any');
99
+ const id = tableColumnId(c);
100
+ let input: Child;
101
+ if (kind === 'boolean' || (kind === 'select' && op.mode === 'eq')) {
102
+ const options = kind === 'boolean' ? [{ label: t('common.yes'), value: true }, { label: t('common.no'), value: false }] : (c.filterOptions ?? []);
103
+ input = this.held.get('sel|' + id, this.selectTag, { size: 'sm', clearable: true, options, value, placeholder: any, ariaLabel: t('filter.column', { column: name }) },
104
+ (v) => (kind === 'boolean' ? actions.set(c, v) : actions.set(c, v, 'eq')));
105
+ } else if (kind === 'select') {
106
+ const n = tableFilterValues(filters, field).length;
107
+ input = h('button', {
108
+ type: 'button', class: ['flt-in', { 'is-ph': !n }], 'aria-label': t('filter.column', { column: name }),
109
+ onclick: (e: MouseEvent) => { e.stopPropagation(); this.open('in', c, e.currentTarget as HTMLElement); },
110
+ }, [h('span', {}, n ? t('filter.selectedCount', { n }) : any), icon(registry, 'chevron-down', { size: 11 })]);
111
+ } else if (!op.needsValue) {
112
+ input = h('span', { class: 'flt-txt' }, label(op));
113
+ } else if (op.range) {
114
+ input = ([0, 1] as const).map((i) => h('input', {
115
+ type, value: this.shown(filters, c, i), placeholder: t(i ? 'filter.max' : 'filter.min'), 'aria-label': t(i ? 'filter.columnMax' : 'filter.columnMin', { column: name }),
116
+ oninput: (e: Event) => { const v = (e.target as HTMLInputElement).value; this.drafts[this.key(c, i)] = v; actions.part(c, i, v); },
117
+ }));
118
+ } else {
119
+ input = h('input', {
120
+ type, value: this.shown(filters, c, 0), placeholder: c.filterPlaceholder || label(op), 'aria-label': t('filter.column', { column: name }),
121
+ oninput: (e: Event) => { const v = (e.target as HTMLInputElement).value; this.drafts[this.key(c, 0)] = v; actions.set(c, v, undefined, true); },
122
+ });
123
+ }
124
+ return h('div', { class: ['flt-cell', { 'is-active': active, 'is-range': !!op.range }] }, [
125
+ input,
126
+ kind !== 'boolean' && h('button', {
127
+ type: 'button', class: ['flt-op', { 'is-on': active }], 'aria-label': t('filter.operator', { label: label(op) }), title: label(op),
128
+ onclick: (e: MouseEvent) => { e.stopPropagation(); this.open('op', c, e.currentTarget as HTMLElement); },
129
+ }, icon(registry, 'filter', { size: 12 })),
130
+ active && h('button', { type: 'button', class: 'flt-x', 'aria-label': t('filter.clear'), onclick: () => { this.forget(c); actions.clear(c); } }, icon(registry, 'x', { size: 11 })),
131
+ ]);
132
+ }
133
+
134
+ /** Le menu ouvert (opérateurs ou valeurs), monté seulement ouvert : sans ancre, ce serait un menu en ligne. */
135
+ menus(i18n: UiI18nValue, registry: IconRegistry, filters: TableFilters, actions: TableFilterActions): Child {
136
+ const m = this.menu;
137
+ const open = !!m && !!this.anchor?.isConnected;
138
+ const { t } = i18n;
139
+ const items: PoadMenuItem[] = !m ? [] : m.type === 'op'
140
+ ? (() => {
141
+ const cur = tableFilterOperator(m.column, filters);
142
+ return tableFilterOperators(m.column).map((op) => ({
143
+ label: tableFilterOperatorLabel(op, (k) => t(k)), shortcut: op.short, icon: op.mode === cur.mode ? 'check' : undefined,
144
+ command: () => { this.forget(m.column); actions.operator(m.column, op); },
145
+ }));
146
+ })()
147
+ : (() => {
148
+ const sel = tableFilterValues(filters, m.column.field ?? '');
149
+ return (m.column.filterOptions ?? []).map((o) => ({ label: o.label, icon: sel.some((v) => v === o.value) ? 'check' : 'square', command: () => actions.toggleValue(m.column, o.value) }));
150
+ })();
151
+ if (!open) return null;
152
+ return this.controller.render({
153
+ id: `${this.uid}-fltmenu`, items, open: true, popup: true, anchor: () => this.anchor, contextual: false,
154
+ ariaLabel: t(m!.type === 'op' ? 'filter.operatorMenu' : 'filter.valuesMenu'), minWidth: m!.type === 'op' ? 200 : 180, closeOnSelect: m!.type === 'op',
155
+ closeLabel: t('common.close'), icons: registry,
156
+ // refermé par un choix (ou un clic dehors) : le focus, tombé sur la page, revient au bouton qui l'a ouvert
157
+ setOpen: (o) => {
158
+ if (o) return;
159
+ const from = this.anchor;
160
+ this.menu = null;
161
+ this.host.update();
162
+ const at = from?.ownerDocument.activeElement;
163
+ if (from?.isConnected && (!at || at === from.ownerDocument.body)) from.focus();
164
+ },
165
+ onItemClick: () => {},
166
+ });
167
+ }
168
+
169
+ /** Après le rendu de la table : menu placé et focalisé ; éléments posés qui n'ont plus servi oubliés. */
170
+ sync(): void {
171
+ if (this.menu) { this.menuShown = true; this.controller.sync(); }
172
+ else if (this.menuShown) { this.menuShown = false; this.controller.dispose(); }
173
+ this.held.sweep();
174
+ }
175
+ dispose(): void {
176
+ this.menu = null;
177
+ this.controller.dispose();
178
+ }
179
+ }