@abyss-project/commons-front-core 18.1.0 → 18.1.2

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 (41) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/catalog/pages/CookieConsent.tsx +51 -0
  3. package/catalog/specs/cookie-consent-modal.spec.ts +145 -5
  4. package/dist/CookieConsentSettings-CLB1Mlv5.js +687 -0
  5. package/dist/{Surface-z5TuQzlh.js → Surface-B_wIEB3b.js} +9 -9
  6. package/dist/{Tabs-C4K0mLME.js → Tabs-MVmpclcZ.js} +1 -1
  7. package/dist/components/business/CookieConsent/containing-block.d.ts +19 -0
  8. package/dist/components/business/CookieConsent/containing-block.spec.d.ts +1 -0
  9. package/dist/components/business/CookieConsent/use-banner-portal.d.ts +9 -0
  10. package/dist/cookie-consent.js +2 -2
  11. package/dist/{design-theme-BFkCN7Nz.js → design-theme-Bcu3EMIB.js} +1 -1
  12. package/dist/{editors-Eb3PHnxn.js → editors-D0JP2AdM.js} +27 -27
  13. package/dist/editors.js +1 -1
  14. package/dist/{index-CWD0waD8.js → index-B7TbdCxd.js} +2 -2
  15. package/dist/{index-z5ZOXlY8.js → index-BTQOcRMg.js} +4 -4
  16. package/dist/{index-BlOP01yA.js → index-BXwVo31B.js} +2 -2
  17. package/dist/{index-CtVoDSIn.js → index-BgK7ZufI.js} +2 -2
  18. package/dist/{index-2lNOK7eK.js → index-BhfgX3oc.js} +2 -2
  19. package/dist/{index-Ckzcg8qD.js → index-BiBtwp14.js} +4 -4
  20. package/dist/{index-BaL2x2GW.js → index-COEwfkxf.js} +3 -3
  21. package/dist/{index-CFDEfvCD.js → index-CTbeT-N0.js} +1 -1
  22. package/dist/{index-CQ7z2zKY.js → index-CTmmM3bQ.js} +4 -4
  23. package/dist/{index-CRFGogWn.js → index-CVRa0oBj.js} +2 -2
  24. package/dist/{index-Ckzmgx9X.js → index-CorW4VOJ.js} +3 -3
  25. package/dist/{index-BcO-JFrs.js → index-CxQaYgoB.js} +2 -2
  26. package/dist/{index-Dqm1dC1j.js → index-DB03r0_G.js} +2 -2
  27. package/dist/{index-Bw4XnSa0.js → index-DHwatinf.js} +2 -2
  28. package/dist/{index-DRtBc440.js → index-DOniqiUF.js} +2 -2
  29. package/dist/{index-CYBvIQsH.js → index-DS7PaGaq.js} +3 -3
  30. package/dist/{index-CrZZo4r1.js → index-DWOXLAjk.js} +2 -2
  31. package/dist/{index-CtkfWhK1.js → index-P3mYGVW9.js} +2 -2
  32. package/dist/{index-CUhMNEUo.js → index-WbhbeBj8.js} +3 -3
  33. package/dist/{index-B76nCWpd.js → index-WnQHBsCS.js} +2 -2
  34. package/dist/{index-BKRudpMw.js → index-tTzlUmYK.js} +2 -2
  35. package/dist/index.js +1312 -1301
  36. package/dist/legacy.js +6 -6
  37. package/dist/test/vitest-workers.d.ts +18 -0
  38. package/dist/test/vitest-workers.spec.d.ts +1 -0
  39. package/package.json +1 -1
  40. package/vitest.config.ts +6 -0
  41. package/dist/CookieConsentSettings-DUoKKRMZ.js +0 -595
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog — @abyss-project/commons-front-core
2
2
 
3
+ ## 18.1.2
4
+
5
+ - `DeliverySubscriptions`: on the mobile card the URL is shown whole and wraps (no middle ellipsis); the history column header « Code de réponse » / « Response code » becomes « Code HTTP » / « HTTP code » so it is no longer cut.
6
+
7
+ ## 18.1.1
8
+
9
+ - **Fix #747: the cookie banner no longer covers the main button of a modal whose surface creates a containing block** (the `backdrop-filter` of the legacy theme's dialog paper, but also `filter`, `transform`, `contain: paint`, `will-change: transform`, `container-type`...). The banner, `position: fixed`, stuck to the bottom of that surface instead of the window, over « Suivant ». While the surface hosts the banner, the properties a stylesheet gives to the surface and to its ancestors up to the modal root that create such a block are switched off by an inline style (properties an element carries inline, such as the translate of a sheet being dragged or the exit transform of a drawer, are never touched), and that style is removed when the banner leaves or the modal closes. Visible cost: the surface loses the blur or the filter, and an `@container` query defined on it or on an ancestor stops applying, for as long as the banner is shown in it. No API change; a front gets it by upgrading.
10
+
3
11
  ## 18.1.0
4
12
 
5
13
  Fixes of the P5 #792 L1 review. No export removed; two props become optional, one is added.
@@ -13,7 +21,7 @@ Fixes of the P5 #792 L1 review. No export removed; two props become optional, on
13
21
 
14
22
  ## 18.0.0
15
23
 
16
- Cards #753 and #747 (ADR-0261), plus the #286 admin additions. One export removed, `VALIDITY_DAYS` (replaced below, no consumer outside the core); no signature narrowed.
24
+ Breaking: `VALIDITY_DAYS` is removed from the root, `./cookie-consent` and `./legacy`; read `CONSENT_VALIDITY_DAYS` instead (no consumer outside the core used it). Cards #753 and #747 (ADR-0261), plus the #286 admin additions. No signature narrowed.
17
25
 
18
26
  - **Validity of the choice: six months instead of 365 days.** `CONSENT_VALIDITY_DAYS` (183), `CONSENT_VALIDITY_MS` and `COOKIE_MAX_AGE_SECONDS` replace `VALIDITY_DAYS`: one constant for the cookie's `Max-Age` and for the validity check. Every stored choice older than six months asks again.
19
27
  - **`cookie-consent-contract`** (leaf file, no import) exports what a reader or writer of the apex cookie must agree on: `COOKIE_NAME`, `COOKIE_PATH`, `COOKIE_SAME_SITE`, the validity constants, `StoredConsent`, `encodeStoredConsent`, `decodeStoredConsent`, `isStoredConsentValid`. `COOKIE_NAME` and `StoredConsent` moved there from `cookie-storage.utils` (still exported by the root and by `./cookie-consent`).
@@ -1,6 +1,10 @@
1
1
  import { useState } from 'react';
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
3
  import Button from '@mui/material/Button';
4
+ import Dialog from '@mui/material/Dialog';
5
+ import DialogActions from '@mui/material/DialogActions';
6
+ import DialogContent from '@mui/material/DialogContent';
7
+ import DialogTitle from '@mui/material/DialogTitle';
4
8
  import { AbyssCookieConsentProvider } from '../../src/components/business/CookieConsent/AbyssCookieConsentProvider';
5
9
  import { Drawer } from '../../src/components/layers/Drawer/Drawer';
6
10
  import { Modal } from '../../src/components/layers/Modal/Modal';
@@ -10,12 +14,25 @@ import { Example, Showcase } from '../frame';
10
14
 
11
15
  const queryClient = new QueryClient();
12
16
 
17
+ /** A property that makes the surface the containing block of what is `position: fixed` inside it. */
18
+ enum SurfaceEffect {
19
+ BackdropFilter = 'backdrop-filter',
20
+ Filter = 'filter',
21
+ }
22
+
23
+ const SURFACE_STYLES: Record<SurfaceEffect, Record<string, string>> = {
24
+ // The legacy theme's dialog paper (frosted glass).
25
+ [SurfaceEffect.BackdropFilter]: { backdropFilter: 'blur(12px)' },
26
+ [SurfaceEffect.Filter]: { filter: 'drop-shadow(0 2px 4px rgba(0,0,0,0.3))' },
27
+ };
28
+
13
29
  /** The real provider and banner, on the page: a visitor who has not chosen yet sees the banner. */
14
30
  export const CookieConsentPage = () => {
15
31
  // A choice made in an earlier visit of the catalog would hide the banner this page shows.
16
32
  useState(() => clearCookie({}));
17
33
  const [wizardOpen, setWizardOpen] = useState(false);
18
34
  const [drawerOpen, setDrawerOpen] = useState(false);
35
+ const [effect, setEffect] = useState<SurfaceEffect | null>(null);
19
36
  return (
20
37
  <QueryClientProvider client={queryClient}>
21
38
  <AbyssCookieConsentProvider
@@ -34,6 +51,18 @@ export const CookieConsentPage = () => {
34
51
  <Button variant="outlined" onClick={() => setDrawerOpen(true)}>
35
52
  Ouvrir l&apos;aperçu
36
53
  </Button>
54
+ <Button
55
+ variant="outlined"
56
+ onClick={() => setEffect(SurfaceEffect.BackdropFilter)}
57
+ >
58
+ Ouvrir la fenêtre à fond flouté
59
+ </Button>
60
+ <Button
61
+ variant="outlined"
62
+ onClick={() => setEffect(SurfaceEffect.Filter)}
63
+ >
64
+ Ouvrir la fenêtre à filtre
65
+ </Button>
37
66
  </Example>
38
67
  </Showcase>
39
68
  <Modal
@@ -48,6 +77,28 @@ export const CookieConsentPage = () => {
48
77
  >
49
78
  <p>Étape 1 sur 3</p>
50
79
  </Modal>
80
+ <Dialog
81
+ open={effect !== null}
82
+ onClose={() => setEffect(null)}
83
+ aria-labelledby="surface-dialog-title"
84
+ slotProps={{
85
+ paper: {
86
+ sx: effect === null ? undefined : SURFACE_STYLES[effect],
87
+ },
88
+ }}
89
+ >
90
+ <DialogTitle id="surface-dialog-title">
91
+ Assistant à surface spéciale
92
+ </DialogTitle>
93
+ <DialogContent>
94
+ <p>Étape 1 sur 3</p>
95
+ </DialogContent>
96
+ <DialogActions>
97
+ <Button variant="contained" onClick={() => setEffect(null)}>
98
+ Suivant
99
+ </Button>
100
+ </DialogActions>
101
+ </Dialog>
51
102
  <Drawer
52
103
  open={drawerOpen}
53
104
  onClose={() => setDrawerOpen(false)}
@@ -39,6 +39,21 @@ const boxOf = async (page: Page, name: string) => {
39
39
  return box;
40
40
  };
41
41
 
42
+ /** Whether the topmost element at the middle of `box` is, or sits in, the button of that name. */
43
+ const isButtonAt = (
44
+ page: Page,
45
+ name: string,
46
+ box: { x: number; y: number; width: number; height: number },
47
+ ): Promise<boolean> =>
48
+ page
49
+ .getByRole('button', { name, exact: true })
50
+ .evaluate(
51
+ (button, point) =>
52
+ document.elementFromPoint(point.x, point.y)?.closest('button') ===
53
+ button,
54
+ { x: box.x + box.width / 2, y: box.y + box.height / 2 },
55
+ );
56
+
42
57
  const overlaps = (
43
58
  a: { x: number; y: number; width: number; height: number },
44
59
  b: { x: number; y: number; width: number; height: number },
@@ -78,14 +93,139 @@ for (const viewport of VIEWPORTS) {
78
93
  expect(banner).not.toBeNull();
79
94
  expect(overlaps(next, banner!)).toBe(false);
80
95
  // The browser agrees: what is at the middle of « Suivant » is « Suivant ».
81
- const hit = await page.evaluate(
82
- ({ x, y }) => document.elementFromPoint(x, y)?.textContent ?? '',
83
- { x: next.x + next.width / 2, y: next.y + next.height / 2 },
84
- );
85
- expect(hit).toContain('Suivant');
96
+ expect(await isButtonAt(page, 'Suivant', next)).toBe(true);
86
97
  });
87
98
  }
88
99
 
100
+ // The banner is `position: fixed`. A surface that carries `backdrop-filter` (the legacy theme's
101
+ // dialog paper), `filter`, `transform`... becomes the box that fixed element is laid out in: the
102
+ // banner then sticks to the bottom of the surface and covers « Suivant ». The catalog's own theme
103
+ // has none, so these dialogs carry the property by hand.
104
+ const SURFACE_EFFECTS = [
105
+ { label: 'backdrop-filter', opener: 'Ouvrir la fenêtre à fond flouté' },
106
+ { label: 'filter', opener: 'Ouvrir la fenêtre à filtre' },
107
+ ] as const;
108
+
109
+ for (const effect of SURFACE_EFFECTS) {
110
+ for (const viewport of [
111
+ { width: 1440, height: 900 },
112
+ { width: 390, height: 844 },
113
+ ]) {
114
+ test(`the banner sticks to the bottom of the window and leaves « Suivant » free over a dialog with ${effect.label} at ${viewport.width}px`, async ({
115
+ page,
116
+ }) => {
117
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, viewport);
118
+ await page.getByRole('button', { name: effect.opener }).click();
119
+ await expect(
120
+ page.getByRole('dialog', { name: 'Assistant à surface spéciale' }),
121
+ ).toBeVisible();
122
+ await settle(page);
123
+
124
+ // The property that anchored the banner to the paper is switched off while it is hosted.
125
+ const computed = await page
126
+ .locator('.MuiDialog-paper')
127
+ .evaluate(
128
+ (paper, property) =>
129
+ getComputedStyle(paper).getPropertyValue(property),
130
+ effect.label,
131
+ );
132
+ expect(computed).toBe('none');
133
+
134
+ const banner = await page
135
+ .getByRole('dialog', { name: 'Vos préférences de cookies' })
136
+ .boundingBox();
137
+ expect(banner).not.toBeNull();
138
+ // Stuck to the bottom of the window (an 8 to 24 px offset), not to the bottom of the paper.
139
+ const gap = viewport.height - (banner!.y + banner!.height);
140
+ expect(gap).toBeGreaterThanOrEqual(0);
141
+ expect(gap).toBeLessThanOrEqual(32);
142
+
143
+ const next = await boxOf(page, 'Suivant');
144
+ expect(overlaps(next, banner!)).toBe(false);
145
+ expect(await isButtonAt(page, 'Suivant', next)).toBe(true);
146
+ });
147
+ }
148
+ }
149
+
150
+ // The panel of a bottom sheet follows the finger with an inline `translateY` and no transition.
151
+ // The banner must not freeze it: only what a stylesheet gives is switched off, never an inline style.
152
+ test('the sheet keeps following the finger while the banner is shown', async ({
153
+ page,
154
+ }) => {
155
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
156
+ width: 390,
157
+ height: 844,
158
+ });
159
+ await page.getByRole('button', { name: "Ouvrir l'assistant" }).click();
160
+ const panel = page.getByRole('dialog', { name: 'Assistant de démarrage' });
161
+ await expect(panel).toBeVisible();
162
+ await settle(page);
163
+
164
+ const before = await panel.boundingBox();
165
+ const grip = await page.getByTestId('bottom-sheet-drag-zone').boundingBox();
166
+ expect(before).not.toBeNull();
167
+ expect(grip).not.toBeNull();
168
+ const x = grip!.x + grip!.width / 2;
169
+ const y = grip!.y + grip!.height / 2;
170
+ await page.mouse.move(x, y);
171
+ await page.mouse.down();
172
+ // Less than the commit ratio, so that the sheet stays open under the finger.
173
+ for (let step = 1; step <= 4; step += 1) {
174
+ await page.mouse.move(x, y + step * 10);
175
+ await page.waitForTimeout(30);
176
+ }
177
+ const dragged = await panel.boundingBox();
178
+ expect(dragged).not.toBeNull();
179
+ expect(dragged!.y - before!.y).toBeGreaterThan(30);
180
+ await page.mouse.up();
181
+ });
182
+
183
+ // A drawer closes by sliding out. The banner must not hold it on screen: nothing writes over the
184
+ // transform the exit transition drives.
185
+ test('a drawer closes by sliding out while the banner is shown, and does not come back', async ({
186
+ page,
187
+ }) => {
188
+ await openCatalogPage(page, 'CookieConsent', ThemeMode.Dark, {
189
+ width: 1440,
190
+ height: 900,
191
+ });
192
+ await page.getByRole('button', { name: "Ouvrir l'aperçu" }).click();
193
+ const drawer = page.getByRole('dialog', { name: 'Aperçu' });
194
+ await expect(drawer).toBeVisible();
195
+ await settle(page);
196
+ expect(await inAccessibilityTree(page, BANNER_BUTTON)).toBe(true);
197
+
198
+ // Every inline transform the drawer paper goes through. A frame sampler would depend on the
199
+ // runner's load: a starved main thread paints no frame between the exit and the unmount.
200
+ await page.evaluate(() => {
201
+ const transforms: string[] = [];
202
+ (window as unknown as { drawerTransforms: string[] }).drawerTransforms =
203
+ transforms;
204
+ const paper = document.querySelector<HTMLElement>('.MuiDrawer-paper');
205
+ if (paper === null) {
206
+ return;
207
+ }
208
+ new MutationObserver(() => {
209
+ transforms.push(paper.style.transform);
210
+ }).observe(paper, { attributes: true, attributeFilter: ['style'] });
211
+ });
212
+ await page.keyboard.press('Escape');
213
+ await expect(drawer).toHaveCount(0);
214
+
215
+ const transforms = await page.evaluate(
216
+ () =>
217
+ (window as unknown as { drawerTransforms: string[] }).drawerTransforms,
218
+ );
219
+ // MUI wrote the exit transform, and nothing wrote over it afterwards.
220
+ const firstExit = transforms.findIndex((value) =>
221
+ value.startsWith('translate'),
222
+ );
223
+ expect(firstExit).toBeGreaterThanOrEqual(0);
224
+ transforms.slice(firstExit).forEach((value) => {
225
+ expect(value).toMatch(/^translate/);
226
+ });
227
+ });
228
+
89
229
  test('the banner is not aria-hidden over a drawer and the drawer stops above it', async ({
90
230
  page,
91
231
  }) => {