@donotdev/components 0.3.3 → 0.3.5

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 (88) hide show
  1. package/dist/advanced/ImageGallery/ImageGallery.d.ts +16 -4
  2. package/dist/advanced/ImageGallery/ImageGallery.d.ts.map +1 -1
  3. package/dist/advanced/ImageGallery/ImageGallery.js +1 -1
  4. package/dist/advanced/ImageGallery/snapStrip.d.ts +6 -0
  5. package/dist/advanced/ImageGallery/snapStrip.d.ts.map +1 -1
  6. package/dist/advanced/ImageGallery/snapStrip.js +1 -1
  7. package/dist/atomic/Accordion/AccordionPrimitive.d.ts +7 -0
  8. package/dist/atomic/Accordion/AccordionPrimitive.d.ts.map +1 -1
  9. package/dist/atomic/Accordion/AccordionPrimitive.js +1 -1
  10. package/dist/atomic/Accordion/index.d.ts +18 -2
  11. package/dist/atomic/Accordion/index.d.ts.map +1 -1
  12. package/dist/atomic/Accordion/index.js +1 -1
  13. package/dist/atomic/ActionBar/index.d.ts +66 -0
  14. package/dist/atomic/ActionBar/index.d.ts.map +1 -0
  15. package/dist/atomic/ActionBar/index.js +1 -0
  16. package/dist/atomic/Button/IconBadge.d.ts +18 -0
  17. package/dist/atomic/Button/IconBadge.d.ts.map +1 -0
  18. package/dist/atomic/Button/IconBadge.js +1 -0
  19. package/dist/atomic/Button/index.d.ts +10 -7
  20. package/dist/atomic/Button/index.d.ts.map +1 -1
  21. package/dist/atomic/Button/index.js +1 -1
  22. package/dist/atomic/Card/cover.d.ts +11 -3
  23. package/dist/atomic/Card/cover.d.ts.map +1 -1
  24. package/dist/atomic/Card/cover.js +1 -1
  25. package/dist/atomic/Card/index.d.ts +16 -1
  26. package/dist/atomic/Card/index.d.ts.map +1 -1
  27. package/dist/atomic/Card/index.js +1 -1
  28. package/dist/atomic/Collapsible/CollapsiblePrimitive.d.ts +6 -0
  29. package/dist/atomic/Collapsible/CollapsiblePrimitive.d.ts.map +1 -1
  30. package/dist/atomic/Collapsible/CollapsiblePrimitive.js +1 -1
  31. package/dist/atomic/Collapsible/index.d.ts +3 -1
  32. package/dist/atomic/Collapsible/index.d.ts.map +1 -1
  33. package/dist/atomic/Collapsible/index.js +1 -1
  34. package/dist/atomic/Floating/index.d.ts +67 -0
  35. package/dist/atomic/Floating/index.d.ts.map +1 -0
  36. package/dist/atomic/Floating/index.js +1 -0
  37. package/dist/atomic/Grid/index.d.ts +12 -0
  38. package/dist/atomic/Grid/index.d.ts.map +1 -1
  39. package/dist/atomic/Grid/index.js +1 -1
  40. package/dist/atomic/List/index.d.ts +10 -1
  41. package/dist/atomic/List/index.d.ts.map +1 -1
  42. package/dist/atomic/List/index.js +1 -1
  43. package/dist/atomic/PasswordInput/index.d.ts +10 -1
  44. package/dist/atomic/PasswordInput/index.d.ts.map +1 -1
  45. package/dist/atomic/PasswordInput/index.js +1 -1
  46. package/dist/atomic/PinInput/index.d.ts +26 -18
  47. package/dist/atomic/PinInput/index.d.ts.map +1 -1
  48. package/dist/atomic/PinInput/index.js +1 -1
  49. package/dist/atomic/QuantityStepper/index.d.ts +42 -4
  50. package/dist/atomic/QuantityStepper/index.d.ts.map +1 -1
  51. package/dist/atomic/QuantityStepper/index.js +1 -1
  52. package/dist/atomic/Section/index.d.ts +15 -1
  53. package/dist/atomic/Section/index.d.ts.map +1 -1
  54. package/dist/atomic/Section/index.js +1 -1
  55. package/dist/atomic/Sheet/index.d.ts +7 -1
  56. package/dist/atomic/Sheet/index.d.ts.map +1 -1
  57. package/dist/atomic/Sheet/index.js +1 -1
  58. package/dist/atomic/Text/index.d.ts +15 -2
  59. package/dist/atomic/Text/index.d.ts.map +1 -1
  60. package/dist/atomic/Text/index.js +2 -2
  61. package/dist/atomic/Tooltip/TooltipPrimitive.d.ts +5 -0
  62. package/dist/atomic/Tooltip/TooltipPrimitive.d.ts.map +1 -1
  63. package/dist/atomic/Tooltip/TooltipPrimitive.js +1 -1
  64. package/dist/atomic/index.d.ts +4 -2
  65. package/dist/atomic/index.d.ts.map +1 -1
  66. package/dist/atomic/index.js +1 -1
  67. package/dist/index.js +1 -1
  68. package/dist/styles/index.css +689 -119
  69. package/dist/symbol-index.json +1 -1
  70. package/dist/utils/flights.d.ts +30 -0
  71. package/dist/utils/flights.d.ts.map +1 -0
  72. package/dist/utils/flights.js +1 -0
  73. package/dist/utils/flyTo.d.ts +45 -0
  74. package/dist/utils/flyTo.d.ts.map +1 -0
  75. package/dist/utils/flyTo.js +1 -0
  76. package/dist/utils/index.d.ts +1 -0
  77. package/dist/utils/index.d.ts.map +1 -1
  78. package/dist/utils/index.js +1 -1
  79. package/dist/utils/responsiveImage.d.ts +64 -9
  80. package/dist/utils/responsiveImage.d.ts.map +1 -1
  81. package/dist/utils/responsiveImage.js +1 -1
  82. package/guidelines/API_REFERENCE.md +5 -2
  83. package/guidelines/COMPONENTS.md +15 -11
  84. package/guidelines/QUANTITY_STEPPER.md +25 -3
  85. package/package.json +1 -1
  86. package/dist/atomic/PortalButton/index.d.ts +0 -32
  87. package/dist/atomic/PortalButton/index.d.ts.map +0 -1
  88. package/dist/atomic/PortalButton/index.js +0 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Running fly-to flights
3
+ * @description Internal registry of the {@link flyTo} flights in the air, per landing
4
+ * element, so a component inside the target (Button's count bubble) can hold its update
5
+ * until the image lands. Not exported from the package.
6
+ *
7
+ * @version 0.1.0
8
+ * @since 0.3.5
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ /** How a flight ended: on its target (`finish`) or cut short (`cancel`). */
12
+ export type FlightOutcome = 'landed' | 'cancelled';
13
+ /**
14
+ * Records `animation` as a flight landing on `target` until it finishes or is cancelled.
15
+ * Called by {@link flyTo} for every flight it starts.
16
+ */
17
+ export declare function trackFlight(target: Element, animation: Animation): void;
18
+ /**
19
+ * The landing of the latest running flight whose target is `node` or contains it: a
20
+ * promise resolving `'landed'` when that flight finishes, `'cancelled'` when it is
21
+ * cancelled (never rejects). `null` when no flight is heading to `node`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const flight = landing(anchor);
26
+ * if (flight) flight.then((outcome) => show(outcome === 'landed'));
27
+ * ```
28
+ */
29
+ export declare function landing(node: Element): Promise<FlightOutcome> | null;
30
+ //# sourceMappingURL=flights.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flights.d.ts","sourceRoot":"","sources":["../../src/utils/flights.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC;AAInD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAWvE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAWpE"}
@@ -0,0 +1 @@
1
+ var l=new Map;function c(t,n){let i=l.get(t);i||l.set(t,i=new Set),i.add(n);let e=i,d=()=>{e.delete(n),e.size===0&&l.get(t)===e&&l.delete(t)};n.addEventListener("finish",d),n.addEventListener("cancel",d)}function s(t){let n;for(let[e,d]of l)if(e===t||e.contains(t))for(let o of d)n=o;if(!n)return null;let i=n;return new Promise(e=>{i.addEventListener("finish",()=>e("landed")),i.addEventListener("cancel",()=>e("cancelled"))})}export{s as landing,c as trackFlight};
@@ -0,0 +1,45 @@
1
+ /** Options of {@link flyTo}. */
2
+ export interface FlyToOptions {
3
+ /** Flight time in ms. @default 650 */
4
+ duration?: number;
5
+ }
6
+ /**
7
+ * Callback ref that registers its element as the fly target `name` (React 19: unregistered
8
+ * by the ref cleanup). Stable per name, so it never re-registers on re-render. Several
9
+ * elements may share a name (e.g. a mobile and a desktop header cart): {@link flyTo} picks
10
+ * the first one on screen. Plain function, no hook: usable anywhere a ref is.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <Button icon={ShoppingCart} badge={count} ref={flyTarget('cart')} aria-label={label} />
15
+ * ```
16
+ */
17
+ export declare function flyTarget(name: string): (element: Element | null) => (() => void) | undefined;
18
+ /**
19
+ * Flies a copy of `source` from its box onto the target (a {@link flyTarget} name or an
20
+ * element), shrinking and fading on the way: a fixed-position clone in `<body>`, animated
21
+ * with the Web Animations API on transform and opacity only (compositor, no layout shift),
22
+ * removed when the flight finishes or is cancelled. An `<img>` source flies its displayed
23
+ * rendition (`currentSrc`, already decoded: no new request) with the same `object-fit`.
24
+ *
25
+ * A source scrolled off screen still flies: the clone starts from its box clamped just
26
+ * beyond the nearest viewport edge(s), entering from the source's side for the whole flight.
27
+ *
28
+ * While the flight is in the air, a Button `badge` inside the target holds its update: it
29
+ * shows the new count and pops when the image lands (or shows it without a pop when the
30
+ * flight is cancelled). QuantityStepper flies for you with `flyFrom` / `flyTo`.
31
+ *
32
+ * Call it from an interaction (it reads both boxes then), never during render. Returns the
33
+ * animation (cancel it to abort the flight), or `null` and does nothing when motion is
34
+ * reduced (`prefers-reduced-motion: reduce`), the Web Animations API is missing, the source
35
+ * is missing, detached or unrendered (0 × 0, `display: none`), or the target is missing,
36
+ * detached, unrendered or off-screen.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // From the add-to-cart click, before the write
41
+ * flyTo(coverRef.current, 'cart');
42
+ * ```
43
+ */
44
+ export declare function flyTo(source: Element | null | undefined, target: string | Element | null | undefined, { duration }?: FlyToOptions): Animation | null;
45
+ //# sourceMappingURL=flyTo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flyTo.d.ts","sourceRoot":"","sources":["../../src/utils/flyTo.ts"],"names":[],"mappings":"AAcA,gCAAgC;AAChC,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAgB7F;AA0CD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,KAAK,CACnB,MAAM,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,EAClC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EAC3C,EAAE,QAAc,EAAE,GAAE,YAAiB,GACpC,SAAS,GAAG,IAAI,CAwDlB"}
@@ -0,0 +1 @@
1
+ import{trackFlight as w}from"./flights.js";var f=new Map,c=new Map;function M(e){let n=c.get(e);return n||(n=i=>{if(!i)return;let r=f.get(e);r||f.set(e,r=new Set),r.add(i);let o=r;return()=>{o.delete(i)}},c.set(e,n)),n}function m(e){return e.width>0&&e.height>0}function a(e){return m(e)&&e.bottom>0&&e.right>0&&e.top<window.innerHeight&&e.left<window.innerWidth}function b(e){let n=f.get(e);if(n){for(let i of n)if(!i.isConnected)n.delete(i);else if(a(i.getBoundingClientRect()))return i}}function x(e){return a(e)?{top:e.top,left:e.left}:{top:Math.min(Math.max(e.top,-e.height),window.innerHeight),left:Math.min(Math.max(e.left,-e.width),window.innerWidth)}}function v(e,n,{duration:i=650}={}){if(typeof window>"u"||!e?.isConnected||!n||window.matchMedia("(prefers-reduced-motion: reduce)").matches)return null;let r=typeof n=="string"?b(n):n;if(!r?.isConnected)return null;let o=e.getBoundingClientRect(),d=r.getBoundingClientRect();if(!m(o)||!a(d))return null;let l=x(o),t=e.cloneNode(!0);if(typeof t.animate!="function")return null;e instanceof HTMLImageElement&&t instanceof HTMLImageElement&&(t.removeAttribute("srcset"),t.removeAttribute("sizes"),t.removeAttribute("loading"),t.src=e.currentSrc||e.src,t.alt="",t.removeAttribute("class"),t.style.objectFit=getComputedStyle(e).objectFit),t.removeAttribute("id"),t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"fixed",top:`${l.top}px`,left:`${l.left}px`,width:`${o.width}px`,height:`${o.height}px`,margin:"0",boxSizing:"border-box",pointerEvents:"none",zIndex:"2147483647",transformOrigin:"center",willChange:"transform, opacity"}),document.body.append(t);let g=d.left+d.width/2-(l.left+o.width/2),h=d.top+d.height/2-(l.top+o.height/2),p=Math.min(d.width/o.width,d.height/o.height),s=t.animate([{transform:"translate(0, 0) scale(1)",opacity:1},{transform:`translate(${g}px, ${h}px) scale(${p})`,opacity:.2}],{duration:i,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}),u=()=>t.remove();return s.addEventListener("finish",u),s.addEventListener("cancel",u),w(r,s),s}export{M as flyTarget,v as flyTo};
@@ -9,6 +9,7 @@
9
9
  export * from './constants';
10
10
  export * from './date';
11
11
  export * from './eventListener';
12
+ export * from './flyTo';
12
13
  export * from './initRipple';
13
14
  export * from './intersectionObserver';
14
15
  export * from './isDark';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- export*from"./constants.js";export*from"./date.js";export*from"./eventListener.js";export*from"./initRipple.js";export*from"./intersectionObserver.js";export*from"./isDark.js";export*from"./linkComponent.js";export*from"./helpers.js";export*from"./measurement.js";export*from"./rtl.js";export*from"./viewportDetection.js";export*from"./variants.js";export*from"./imageRetry.js";export*from"./responsiveImage.js";export*from"./sanitizeHtml.js";
1
+ export*from"./constants.js";export*from"./date.js";export*from"./eventListener.js";export*from"./flyTo.js";export*from"./initRipple.js";export*from"./intersectionObserver.js";export*from"./isDark.js";export*from"./linkComponent.js";export*from"./helpers.js";export*from"./measurement.js";export*from"./rtl.js";export*from"./viewportDetection.js";export*from"./variants.js";export*from"./imageRetry.js";export*from"./responsiveImage.js";export*from"./sanitizeHtml.js";
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * @fileoverview Responsive image
3
- * @description Renders a full + thumbnail image pair so phones download the
4
- * thumbnail and larger screens the full image.
3
+ * @description Renders a full + thumbnail image pair. Two modes: without
4
+ * `renditions`, phones (below 768px) download the thumbnail and larger screens the
5
+ * full image (`<picture><source media>`, by viewport). With `renditions`,
6
+ * the browser picks by displayed size x device pixel ratio (`srcset` width
7
+ * descriptors).
5
8
  *
6
9
  * @version 0.1.0
7
10
  * @since 0.2.3
8
11
  * @author AMBROISE PARK Consulting
9
12
  */
10
- import type { ImgHTMLAttributes, ReactElement } from 'react';
13
+ import type { ImgHTMLAttributes, ReactElement, Ref } from 'react';
11
14
  /**
12
15
  * A stored image in two renditions. Same shape as the CRUD `Picture` value of
13
16
  * `image` / `images` fields, so a field value passes straight through.
@@ -28,28 +31,80 @@ export declare const THUMBNAIL_MEDIA = "(max-width: 767px)";
28
31
  * opposed to a URL string or a React node.
29
32
  */
30
33
  export declare function isResponsiveImage(value: unknown): value is ResponsiveImage;
34
+ /**
35
+ * Size-based rendition picking for {@link ResponsiveImg}: the browser chooses
36
+ * by displayed size x device pixel ratio (`srcset` width descriptors + `sizes`)
37
+ * instead of by viewport.
38
+ *
39
+ * `thumbWidth` / `fullWidth` are the frame widths the image field's upload
40
+ * config fits each rendition into: `thumbWidth` and `maxWidth` of
41
+ * `options.fieldSpecific.image` (see `imageProcessing.ts` in `@donotdev/crud`).
42
+ * Declared from config, not measured: nothing per image is stored. An image
43
+ * uploaded under another config gets a slightly off pick (softer or heavier),
44
+ * never a broken one. For `object-fit: contain` the frame width is the exact
45
+ * math (rendition and display are both fits of the same image into a frame);
46
+ * for `cover` crops it is approximate.
47
+ */
48
+ export interface ImageRenditions {
49
+ /** Width (px) of the frame the thumbnail is fitted into (`thumbWidth`). */
50
+ thumbWidth: number;
51
+ /** Width (px) of the frame the full rendition is fitted into (`maxWidth`). */
52
+ fullWidth: number;
53
+ /**
54
+ * Displayed width of the image per breakpoint, as the `<img sizes>` value
55
+ * (e.g. `'(min-width: 1024px) 20vw, 50vw'` or `'3.75rem'`). Replaces the
56
+ * native `sizes` attribute when `renditions` is set.
57
+ */
58
+ sizes: string;
59
+ }
31
60
  /**
32
61
  * URL of the rendition {@link ResponsiveImg} shows at the current viewport.
33
62
  * Client only (reads `matchMedia`); use it to preload the image a frame will show.
63
+ *
64
+ * Describes the media-switch mode only (no `renditions`). With `renditions` the browser
65
+ * decides by displayed size and pixel ratio: read `img.currentSrc` instead.
34
66
  */
35
67
  export declare function currentRenditionUrl(image: ResponsiveImage): string;
36
68
  /** Props of {@link ResponsiveImg}: the image pair + `<img>` attributes. */
37
69
  export interface ResponsiveImgProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src' | 'srcSet'> {
38
70
  /** The image pair (CRUD `Picture`). */
39
71
  image: ResponsiveImage;
72
+ /**
73
+ * Pick the rendition by displayed size instead of viewport (see
74
+ * {@link ImageRenditions}). With it, the rendered `sizes` comes from
75
+ * `renditions.sizes`. Absent: media-switch mode.
76
+ */
77
+ renditions?: ImageRenditions;
78
+ /** React 19: ref is a regular prop; it reaches the `<img>`. */
79
+ ref?: Ref<HTMLImageElement>;
40
80
  }
41
81
  /**
42
- * `<img>` for an image pair: phones (below 768px) get the thumbnail, larger
43
- * screens the full image, via `<picture><source media>`. The browser downloads
44
- * one rendition only. A single rendition renders a plain `<img>`.
82
+ * `<img>` for an image pair, in two modes.
83
+ *
84
+ * - No `renditions` (default): phones (below 768px) get the thumbnail, larger
85
+ * screens the full image, via `<picture><source media>`. The browser
86
+ * downloads one rendition only.
87
+ * - `renditions`: a single `<img>`
88
+ * with `srcset="thumb {thumbWidth}w, full {fullWidth}w"` and `sizes`, so
89
+ * the browser picks by displayed size x pixel ratio, not by viewport. Use it
90
+ * where the displayed size is far from the viewport class (small tiles,
91
+ * multi-column grids).
92
+ *
93
+ * A single rendition renders a plain `<img>` in both modes.
45
94
  *
46
- * `className` and `style` go on the `<img>`. The `<picture>` wrapper is an
47
- * unstyled inline box, so the `<img>` lays out against the same container.
95
+ * `className` and `style` go on the `<img>`. The `<picture>` wrapper (media
96
+ * mode) is an unstyled inline box, so the `<img>` lays out against the same
97
+ * container.
48
98
  *
49
99
  * @example
50
100
  * ```tsx
51
101
  * <ResponsiveImg image={product.images[0]} alt={product.name} loading="lazy" />
102
+ * <ResponsiveImg
103
+ * image={product.images[0]}
104
+ * renditions={{ thumbWidth: 960, fullWidth: 2400, sizes: '(min-width: 1024px) 20vw, 50vw' }}
105
+ * alt={product.name}
106
+ * />
52
107
  * ```
53
108
  */
54
- export declare function ResponsiveImg({ image, ...imgProps }: ResponsiveImgProps): ReactElement;
109
+ export declare function ResponsiveImg({ image, renditions, ...imgProps }: ResponsiveImgProps): ReactElement;
55
110
  //# sourceMappingURL=responsiveImage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responsiveImage.d.ts","sourceRoot":"","sources":["../../src/utils/responsiveImage.tsx"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAM1E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAIlE;AAED,2EAA2E;AAC3E,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,iBAAiB,CAAC,gBAAgB,CAAC,EACnC,KAAK,GAAG,QAAQ,CACjB;IACC,uCAAuC;IACvC,KAAK,EAAE,eAAe,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,GAAG,QAAQ,EACZ,EAAE,kBAAkB,GAAG,YAAY,CAWnC"}
1
+ {"version":3,"file":"responsiveImage.d.ts","sourceRoot":"","sources":["../../src/utils/responsiveImage.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAM1E;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAIlE;AAED,2EAA2E;AAC3E,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAC9C,iBAAiB,CAAC,gBAAgB,CAAC,EACnC,KAAK,GAAG,QAAQ,CACjB;IACC,uCAAuC;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,+DAA+D;IAC/D,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,UAAU,EACV,GAAG,QAAQ,EACZ,EAAE,kBAAkB,GAAG,YAAY,CAqBnC"}
@@ -1 +1 @@
1
- import{jsx as s,jsxs as o}from"react/jsx-runtime";var i="(max-width: 767px)";function m(e){return typeof e=="object"&&e!==null&&typeof e.fullUrl=="string"}function l(e){let{fullUrl:r,thumbUrl:t}=e;return!t||t===r?r:window.matchMedia(i).matches?t:r}function u({image:e,...r}){let{fullUrl:t,thumbUrl:n}=e;return!n||n===t?s("img",{src:t,...r}):o("picture",{children:[s("source",{media:i,srcSet:n}),s("img",{src:t,...r})]})}export{u as ResponsiveImg,i as THUMBNAIL_MEDIA,l as currentRenditionUrl,m as isResponsiveImage};
1
+ import{jsx as s,jsxs as o}from"react/jsx-runtime";var m="(max-width: 767px)";function u(t){return typeof t=="object"&&t!==null&&typeof t.fullUrl=="string"}function l(t){let{fullUrl:e,thumbUrl:r}=t;return!r||r===e?e:window.matchMedia(m).matches?r:e}function c({image:t,renditions:e,...r}){let{fullUrl:n,thumbUrl:i}=t;return!i||i===n?s("img",{src:n,...r}):e?s("img",{...r,src:n,srcSet:`${i} ${e.thumbWidth}w, ${n} ${e.fullWidth}w`,sizes:e.sizes}):o("picture",{children:[s("source",{media:m,srcSet:i}),s("img",{src:n,...r})]})}export{c as ResponsiveImg,m as THUMBNAIL_MEDIA,l as currentRenditionUrl,u as isResponsiveImage};
@@ -17,7 +17,6 @@
17
17
  | iconEnd | `boolean` | `false` |
18
18
  | display | `'auto'` \| `'compact'` \| `'full'` | `'auto'` |
19
19
  | tooltip | `string` | - |
20
- | floating | `boolean` | `false` |
21
20
  | fullWidth | `boolean` | `false` |
22
21
  | loading | `boolean` | `false` |
23
22
  | loadingText | `string` | - |
@@ -42,6 +41,8 @@
42
41
  | variant | `'default'` \| `'muted'` \| `'primary'` \| `'secondary'` \| `'accent'` \| `'success'` \| `'warning'` \| `'destructive'` \| `'code'` | `'default'` |
43
42
  | align | `'start'` \| `'center'` \| `'end'` | `'start'` |
44
43
  | weight | `'normal'` \| `'medium'` \| `'semibold'` \| `'bold'` | - |
44
+ | underline | `boolean` | `false` |
45
+ | lines | `number` (positive integer) | - |
45
46
 
46
47
  **NO: size, tone, color**
47
48
 
@@ -121,6 +122,7 @@ Card title is a `div` unless `titleAs` (`'h2'`-`'h6'`) makes it a real heading (
121
122
  | as | `'section'` \| `'article'` \| `'aside'` \| `'div'` \| `'main'` | `'section'` |
122
123
  | title | `string` | - |
123
124
  | titleAs | `'h2'` \| `'h3'` \| `'h4'` \| `'h5'` \| `'h6'` | `'h2'` |
125
+ | actions | `ReactNode` | - |
124
126
  | separator | `boolean` | `false` |
125
127
  | tone | `'base'` \| `'muted'` \| `'elevated'` \| `'contrast'` \| `'accent'` | `'base'` |
126
128
  | align | `'start'` \| `'center'` \| `'end'` | `'center'` |
@@ -143,8 +145,9 @@ Card title is a `div` unless `titleAs` (`'h2'`-`'h6'`) makes it a real heading (
143
145
  | type | `'single'` \| `'multiple'` | `'single'` |
144
146
  | collapsible | `boolean` | `false` |
145
147
  | titleAs | `'h2'` \| `'h3'` \| `'h4'` \| `'h5'` \| `'h6'` | `'h3'` |
148
+ | gridCols | `GridCols` (as `Section`) | - (one column) |
146
149
 
147
- Each trigger sits in a heading of level `titleAs`; pick the level that keeps the page outline sequential.
150
+ Each trigger sits in a heading of level `titleAs`; pick the level that keeps the page outline sequential. `gridCols={[1, 1, 2, 2]}` lays the items in a grid (1 column mobile/tablet, 2 laptop/desktop), cells aligned to the start.
148
151
 
149
152
  ---
150
153
 
@@ -11,7 +11,7 @@
11
11
  ## Layout Components
12
12
 
13
13
  These are the only ways one should handle layout to get to quick results functionality wide.
14
- - **Section** - Layout section with title, grid, tone system, and `bleed` prop for full-viewport-width content (images, maps, galleries).
14
+ - **Section** - Layout section with title, grid, tone system, and `bleed` prop for full-viewport-width content (images, maps, galleries). `collapsible`: the title heading wraps a `<button>` trigger (Tab, Enter, Space, `aria-expanded`); closed content stays in the server HTML, hidden with `display: none`; opening fades in. A Section nested in another Section's content is flush (no own padding, max-width or auto margins; a non-`ghost` `tone` keeps its padding). Consecutive Sections share one gap: a `ghost` Section directly after a `ghost` Section has no top padding (one `--gap-lg`, not two); a toned Section keeps its padding on both sides.
15
15
  - **Grid** - CSS Grid layout primitive with responsive column control.
16
16
  - **Stack** - Flexbox layout for arranging items in rows or columns.
17
17
  - **HeroSection** - Hero banner with title (a div styled at h1 level, not an h1 element: the page provides its own h1 if it needs one), subtitle, gradient backgrounds, `bleed` for full-width, and `backgroundImage` for cover images with overlay.
@@ -24,9 +24,9 @@ These are the only ways one should handle layout to get to quick results functio
24
24
  - **Card** - Premium card component with title, content, footer, and elevation variants.
25
25
  - **Navigation with middle-click support:** Wrap Card in Link component for navigation that supports middle-click (opens in new tab). See navigation section below.
26
26
  - **DualCard** - Side-by-side card layout for comparison or feature showcases.
27
- - **Text** - Typography component with semantic text variants. `<Text as="h2" level="body">` keeps the h2 element but renders body-sized (an explicit `level` always emits `data-level`).
27
+ - **Text** - Typography component with semantic text variants. `<Text as="h2" level="body">` keeps the h2 element but renders as body text: body size and body font, no heading case or tracking (an explicit `level` always emits `data-level`; same for `small` / `caption`). `as="s"` renders a struck-through `<s>` (a former price beside the new one; no inline style).
28
28
  - **Blockquote** - Styled blockquote for citations and testimonials.
29
- - **List** - Bullet points, numbered lists, and feature lists with zero CSS. Use `icon` prop for custom icons, `icon={null}` for plain bullets.
29
+ - **List** - Bullet points, numbered lists, and feature lists with zero CSS. Use `icon` prop for custom icons, `icon={null}` for plain bullets. `ordered` numbers the items (`1.`, a CSS counter: items are flex rows, which have no native marker). Icon-less items of an unordered list draw their own bullet (`•`) for the same reason; items with an icon keep the icon.
30
30
  - **DescriptionList** - Key-value pairs and metadata using semantic HTML (dl, dt, dd).
31
31
  - **Separator** - Visual separator with semantic styling variants.
32
32
 
@@ -34,21 +34,22 @@ These are the only ways one should handle layout to get to quick results functio
34
34
 
35
35
  ## Action Components
36
36
 
37
- - **Button** - Accessible button with variants, icons, tooltips, and render prop composition.
37
+ - **Button** - Accessible button with variants, icons, tooltips, and render prop composition. `badge` puts a count bubble on the icon's corner (decorative: put the count in `aria-label`); it pops when its numeric value increases after mount (never on first render / hydration, a decrease, or under reduced motion). While a `flyTo` flight heads to the button, an increase waits: the previous count stays shown until the image lands, then the latest count shows and pops (a cancelled flight: shown, no pop).
38
38
  - **ActionButton** - Button with async action handling and loading states.
39
39
  - **Button `intent`** (`Button`, `ActionButton`) - `intent="save" | "publish" | "unpublish" | "delete" | "preview" | "reload" | "add" | "edit" | "cancel"` (`BUTTON_INTENT`) sets the action's icon, and `delete` the destructive variant; an explicit `icon` or `variant` wins. With the default `display` (auto), phones show the icon only. Equal-width action bar: a `Grid` with one column per button and `fullWidth` buttons.
40
40
  - **FileButton** - Button that triggers file input selection.
41
- - **PortalButton** - Button that opens content in a portal overlay.
42
41
  - **ButtonGroup** - Visual grouping of buttons with joined borders. Supports horizontal/vertical orientation, variant propagation, and items-based API.
43
42
  - **SwipeAction** - Touch swipe-to-reveal trailing destructive action; only explicit action-button activation invokes `onAction`. Exported with `SwipeActionProps` from `@donotdev/components`. Supply a translated `actionLabel`. See [SwipeAction](./SWIPE_ACTION.md).
43
+ - **ActionBar** - Page action bar fixed to the bottom of the viewport (e.g. price + add to cart on a phone product page); the app composes the content (`Stack`, `Text`, `Button`, `QuantityStepper`). `hideFrom="tablet" | "laptop" | "desktop"` (`ActionBarBreakpoint`) hides it from that breakpoint up (CSS). `revealAfter={ref}` shows it only while that element has scrolled up out of view (hidden while visible or not reached yet); without it, always shown. Portalled to `<body>`, `--z-header`. While shown it sets its measured height as `--action-bar-height` on `<html>` (absent while hidden, on the server and under `hideFrom`); DnDevLayout pads its bottom with it, so the end of the page and the footer scroll above the bar (a custom scroll container outside DnDevLayout: `padding-block-end: var(--action-bar-height, 0px)`). One shown bar per page. Bottom safe area padded when the app sets `viewport-fit=cover`. Hidden = slid out, `visibility: hidden` + `inert` + `aria-hidden`; no slide under reduced motion. Renders nothing on the server (no hydration mismatch). Not a landmark unless you pass `role="region"` and a translated `aria-label`.
44
+ - **Floating** - Container for one small control that stays on screen while the page scrolls (a back link, a help button); the app composes the control (`Button`, `Link`). `placement="top-start" | "top-end" | "bottom-start" | "bottom-end"` (`FloatingPlacement`, default `top-start`); no other prop. As wide as its control, `--z-header` (below sheets, modals, toasts), logical (RTL-aware). **Top**: in the page flow, `position: sticky`, rendered in the server HTML (no hydration shift); put it first in the page (first child of `PageContainer`, before the first `Section`). At rest `--gap-md` above (below the header) and `--gap-md` below; a ghost `Section` right after it drops its own top padding, so both gaps are `--gap-md` at every width. Sticks `--gap-md` below the top of the layout `<main>` (the scroll container, under the header). Inline: the Section content edge (`--section-gutter`: `--gap-md`, `--gap-lg` from 1024px). **Bottom**: fixed, portalled to `<body>`, takes no space (leave room at the page end); `--gap-md` above a shown ActionBar (`--action-bar-height`) or the bottom safe area; inline: the Section gutter after the sidebar on the start side (`--sidebar-width`), outside the side safe areas; renders nothing on the server, mounts after hydration (fixed: no shift). Its gutter reads the `<html>` spacing tokens: a theme that overrides `--gap-*` only on `[data-density]` elements does not reach a bottom Floating (declare them on `:root` too).
44
45
 
45
46
  ---
46
47
 
47
48
  ## Form Components
48
49
 
49
50
  - **Input** - Accessible input with mobile-friendly touch targets and key state styling.
50
- - **QuantityStepper** - Controlled lot-aware quantity editor via `onChange`, or legacy increment/decrement callbacks. Supports zero, collapsed presentation, and vertical orientation. Editable mode requires safe-integer lot bounds and a valid controlled quantity; reconcile invalid persisted quantities before enabling it. See [QuantityStepper](./QUANTITY_STEPPER.md).
51
- - **PasswordInput** - Password field with show/hide toggle functionality.
51
+ - **QuantityStepper** - Controlled lot-aware quantity editor via `onChange`, or legacy increment/decrement callbacks. Supports zero, collapsed presentation, and vertical orientation. `flyFrom` + `flyTo` (+ `flyEveryAdd`) fly an image to the cart on a committed add, before `onChange`; a returned rejected promise cancels the flight. Editable mode requires safe-integer lot bounds and a valid controlled quantity; reconcile invalid persisted quantities before enabling it. See [QuantityStepper](./QUANTITY_STEPPER.md).
52
+ - **PasswordInput** - Password field with show/hide toggle functionality. `revealAriaLabel={{ show, hide }}` names the toggle (pass translated strings; framework keys `auth:passwordToggle.show` / `.hide`; default English).
52
53
  - **Textarea** - Multi-line text input component.
53
54
  - **Label** - Accessible label with icon support and various positions.
54
55
  - **Field help (`info`)** - Opt-in: `info="…"` on `Input`, `PasswordInput`, `Select`, `Combobox`, `DatePicker`, `DateTimePicker`, `RangeInput`, `PinInput` or `FloatingLabel` (needs `label`) adds an (i) after the label; hover or keyboard focus shows the text, a tap pins it on touch screens. Without `info`, nothing is rendered. For a label you render yourself, place `<FieldInfo text="…" />` next to it.
@@ -77,7 +78,7 @@ These are the only ways one should handle layout to get to quick results functio
77
78
  ## Navigation Components
78
79
 
79
80
  - **Tabs** - Tabbed interface with props-based API and full keyboard navigation.
80
- - **Accordion** - Vertically stacked headings that reveal content sections.
81
+ - **Accordion** - Vertically stacked headings that reveal content sections. Closed items stay in the server HTML (crawlable), hidden with `display: none` (not focusable or announced; their effects run while closed). Opening fades in (no height slide); collapsing is instant.
81
82
  - **NavigationMenu** - Props-based navigation menu with nested menus and rich content. Item `active: true` marks the current page (`aria-current="page"` + `data-active="true"` on its link, accent background). Sub-menu lists have no bullets.
82
83
  - **Pagination** - Accessible pagination with page number generation and ellipsis.
83
84
  - **Command** - Command palette component for keyboard navigation and search.
@@ -91,7 +92,7 @@ These are the only ways one should handle layout to get to quick results functio
91
92
  - **Popover** - Accessible popover displaying rich content in a portal.
92
93
  - **Tooltip** - Tooltip component with positioning and delay controls.
93
94
  - **HoverCard** - Card that appears on hover with rich content.
94
- - **Sheet** - Slide-out panel for sidebars, mobile navigation, or editing panels.
95
+ - **Sheet** - Slide-out panel for sidebars, mobile navigation, or editing panels. `closeLabel` names the close button (pass a translated string, framework key `dndev:sheet.close`; default `Close sheet`).
95
96
  - **ContextMenu** - Right-click context menu with nested submenus.
96
97
  - **DropdownMenu** - Professional dropdown menu with props-based API.
97
98
 
@@ -101,7 +102,8 @@ These are the only ways one should handle layout to get to quick results functio
101
102
 
102
103
  - **Table** - Accessible table component with sorting and selection.
103
104
  - **DataTable** - High-level table with built-in sorting, filtering, search, and pagination. `editable` (+ `getRowId`, `pendingChanges`, `onPendingChange`) edits the columns that declare `edit: { type: 'text' | 'number' | 'select', options }` in place: checked rows take one value from the bulk bar, Excel blocks paste across cells, Enter / arrows move, Esc cancels, Ctrl+Z undoes. The table never saves; the consumer writes `pendingChanges`. `cellErrors={{ [rowId]: { [columnKey]: message } }}` (+ `getRowId`, translated messages) marks cells that break a rule, like a value that does not parse: `data-invalid`, editors `aria-invalid` + `aria-describedby` to the message shown under the value (read-only cells show the message too).
104
- - **Card / ImageGallery images** - Pass the `{ fullUrl, thumbUrl }` pair (CRUD `Picture`) as `cover` / `coverHover` / `images`: phones (below 768px) download the thumbnail, larger screens the full image (`<picture>`). No width props. The frame background is opt-in: `coverBackground` (Card) / `background` (ImageGallery) take `'transparent'` (default, paints nothing) | `'muted'` | `'primary'` | `'secondary'` | `'accent'` (theme tokens); the reserved aspect-ratio space is unchanged.
105
+ - **Card / ImageGallery images** - Pass the `{ fullUrl, thumbUrl }` pair (CRUD `Picture`) as `cover` / `coverHover` / `images`: phones (below 768px) download the thumbnail, larger screens the full image (`<picture>`, by viewport). For small tiles or multi-column grids pass `coverRenditions` (Card; `renditions` on `ResponsiveImg`; type `ImageRenditions` `{ thumbWidth, fullWidth, sizes }`): one `<img>` with `srcset="thumb {thumbWidth}w, full {fullWidth}w"` and `sizes`, so the browser picks by displayed size x pixel ratio. `thumbWidth` / `fullWidth` = the frame widths of the image field's upload config (`thumbWidth`, `maxWidth`): declared, not measured (an image uploaded under another config gets a slightly off pick, never a broken one; exact for `contain`, approximate for `cover` crops). `sizes` = displayed width per breakpoint (`'(min-width: 1024px) 20vw, 50vw'`). With `renditions`, read `img.currentSrc` (`currentRenditionUrl` describes the media mode only). The frame background is opt-in: `coverBackground` (Card) / `background` (ImageGallery) take `'transparent'` (default, paints nothing) | `'muted'` | `'primary'` | `'secondary'` | `'accent'` (theme tokens); the reserved aspect-ratio space is unchanged.
106
+ - **ImageGallery** - Swipeable main image, one-row thumbnail strip (swipe / scroll when it overflows, the selected thumbnail kept in view), lightbox. Viewport-bounded with no prop: main image + thumbnail row never exceed `100svh - --header-height - 2 × --gap-lg` (`vh` where `svh` is unsupported); past that the gallery narrows and centres at its `aspectRatio` instead of growing taller. Place it in any column or `Section bleed`, no height wrapper.
105
107
  - **Avatar** - Accessible avatar with image and fallback support.
106
108
  - **Badge** - Status indicator with semantic variants (polymorphic: div, span, mark).
107
109
  - **Tag** - Tag component for labels and categories. `removeLabel`: remove button label (default `'Remove'`).
@@ -111,13 +113,14 @@ These are the only ways one should handle layout to get to quick results functio
111
113
 
112
114
  ## Utility Components
113
115
 
114
- - **Collapsible** - Collapsible content component.
116
+ - **Collapsible** - Collapsible content component. Closed content stays in the server HTML (crawlable), hidden with `display: none` (not focusable or announced; its effects run while closed). Opening fades in (no height slide); collapsing is instant. `CollapsibleContent` always sets `dndev-collapsible-content` and `forceMount`.
115
117
  - **Toggle** - Toggle button component.
116
118
  - **ToggleGroup** - Group of toggle buttons.
117
119
  - **ScrollArea** - Scrollable area with custom scrollbars.
118
120
  - **Portal** - Portal component for rendering outside DOM hierarchy.
119
121
  - **VisuallyHidden** - Screen reader-only content component.
120
122
  - **Slot** - Slot component for composition patterns.
123
+ - **flyTo / flyTarget** - Fly-to-cart feedback. `ref={flyTarget('cart')}` registers a target (stable callback ref, any element; several per name, the first on screen wins); `flyTo(sourceElement, 'cart')`, called from an interaction, flies a fixed clone of the source (an `<img>` flies its displayed rendition) onto it, transform / opacity only, removed on finish. A source scrolled off screen flies from the nearest screen edge. No-op under reduced motion, when the source is missing or unrendered, or when the target is missing or off-screen. A Button `badge` inside the target holds its update until the image lands, then pops. QuantityStepper flies for you (`flyFrom` / `flyTo`). Image sources: Card `coverRef`, ImageGallery `imageRef` (image in view), ResponsiveImg `ref`.
121
124
  - **SkipLink** - Accessibility skip-to-content links, visible only on keyboard focus. Supports multiple targets with smooth scroll and focus management.
122
125
 
123
126
  ---
@@ -126,6 +129,7 @@ These are the only ways one should handle layout to get to quick results functio
126
129
 
127
130
  - **InfiniteScroll** - Infinite scroll component with load more functionality.
128
131
  - **Stepper** - Step-by-step workflow component with navigation controls.
132
+ - **Step change animation** - `dndev-animate-step-forward` / `dndev-animate-step-back` on the entering step of a one-step-at-a-time flow: fade + 1.5rem slide from the end side (forward) or the start side (back), mirrored in RTL, `--dur-normal` / `--ease-in-out`, no transform left once it ends; reduced motion: no slide. A step hidden and shown again (`hidden`) replays it. Used by the auth `EmailSignUpFlow`.
129
133
  - **CopyToClipboard** - Copy to clipboard with visual feedback.
130
134
  - **VideoPlayer** - Video player component with controls.
131
135
  - **FeatureFallback** - Fallback UI when features are unavailable.
@@ -29,12 +29,16 @@ For vertical controls, add `vertical`: **plus above quantity above minus**, incl
29
29
  | Prop | Default | Behavior |
30
30
  | --- | --- | --- |
31
31
  | `value: number` | required | Controlled committed quantity. |
32
- | `onChange?: (value: number) => void` | absent | Enables editable mode. Takes precedence over `onIncrement`, `onDecrement`, and `onValueClick`. |
32
+ | `onChange?: (value: number) => void \| Promise<unknown>` | absent | Enables editable mode. Takes precedence over `onIncrement`, `onDecrement`, and `onValueClick`. Return the write's promise: a rejection cancels the add's flight. Handle the error in the caller; the stepper only uses the rejection to cancel the flight (it attaches a handler, so no unhandled rejection). |
33
+ | `flyFrom?: RefObject<Element \| null>` | absent | Element flown on an add (card packshot, gallery image). Read at commit time (a fresh ref per render works). |
34
+ | `flyTo?: string \| Element` | absent | Landing target: a `flyTarget()` name (e.g. `'cart'`) or an element. Flight only with `flyFrom` too, editable mode only. |
35
+ | `flyEveryAdd?: boolean` | `false` | Off: flies on the first add only (0 → first lot). On: every committed increase. Decreases never fly. |
33
36
  | `min?: number` | `1` | First positive lot. Positive safe integer. |
34
37
  | `step?: number` | `1` | Positive safe-integer lot size. |
35
38
  | `max?: number` | `Number.MAX_SAFE_INTEGER` | Safe integer at least `min`; effective maximum rounds down to a complete lot. |
36
39
  | `allowZero?: boolean` | `false` | Allows committing zero, separate from positive lots. |
37
40
  | `collapseWhenZero?: boolean` | `false` | At zero, shows only a square accessible plus at the inline end, reserving the block size only; the first + grows the control toward the inline start. |
41
+ | `addLabel?: string` | absent | With `collapseWhenZero`: at zero, one "+ label" button over the expanded footprint (`fullWidth`: the full width) instead of the square; the first + crossfades it into [ − qty + ] with no size change. One short word (ellipsized); decorative, `incrementLabel` stays the name (include the label text in it, WCAG 2.5.3). Ignored with `vertical`. |
38
42
  | `vertical?: boolean` | `false` | Plus, quantity, minus stacked; changes visual and keyboard traversal order. |
39
43
  | `disabled?: boolean` | `false` | Disables all controls. |
40
44
  | `fullWidth?: boolean` | `false` | Fills available inline width, horizontal or vertical. |
@@ -44,6 +48,24 @@ For vertical controls, add `vertical`: **plus above quantity above minus**, incl
44
48
  | `valueLabel?: string` | absent | Accessible editor or legacy clickable-value name. |
45
49
  | `className` / div attributes | absent | Applied to the group. Component owns group role and state attributes. |
46
50
 
51
+ ### Fly to cart
52
+
53
+ ```tsx
54
+ <QuantityStepper
55
+ value={quantity}
56
+ onChange={(next) => cart.setQuantity(productId, next)} // returns the write's promise
57
+ flyFrom={coverRef}
58
+ flyTo="cart" // Button ref={flyTarget('cart')} badge={count}
59
+ flyEveryAdd
60
+ …
61
+ />
62
+ ```
63
+
64
+ - One flight per commit: a click on +, the release of a press-and-hold (a hold of 1000 lots flies once, on release), a typed or keyed higher value. The stepper calls `flyTo(flyFrom.current, flyTo)` **before** `onChange`, so the flight is in the air when the optimistic count re-renders the header.
65
+ - A Button `badge` inside the target holds the new count while the image flies; it shows the latest count and pops when the image lands. A rejected `onChange` promise cancels the flight: the badge shows the (rolled-back) count without a pop.
66
+ - A source scrolled off screen still flies, entering from the screen edge on its side. No flight (the badge updates and pops at once) under reduced motion, with an unrendered source, or an off-screen target.
67
+ - Editable mode only: legacy `onIncrement` writes on every hold tick, so the count would move during the hold; fly props are ignored there.
68
+
47
69
  ### Validation and commits
48
70
 
49
71
  - Valid positive quantities: `min + k * step`, for nonnegative integer `k`.
@@ -65,14 +87,14 @@ Without `onChange`, `onIncrement?: () => void` and `onDecrement?: () => void` dr
65
87
 
66
88
  Supply localized labels. All enabled visible buttons and the editor are keyboard reachable; boundary buttons are natively disabled outside an editing session. While editing, directions stay reachable to apply a step to a replacement draft, even when the controlled value is at a bound. Hidden collapsed controls leave the accessibility tree and tab order. The same plus DOM node survives expansion/collapse; collapsing while the editor/minus has focus transfers focus to plus, without stealing focus from outside the group.
67
89
 
68
- Touch targets use `var(--touch-target)`: each cell is exactly the token (padding and icons fit inside, so a larger `--gap-sm` never inflates it) and grows only with enlarged text (`max(target, 1lh + 2 × --gap-sm)`, WCAG 1.4.4 / 1.4.12). − and + are one cell square; the quantity field is content-sized for three tabular digits (`3ch + --gap-sm`), one cell high, and stays at the touch target when it is a clickable `onValueClick` button. Expanded minimum footprint: two cells + field + border. `fullWidth` fills the container but shrinks to that minimum, never further. Collapsed, the horizontal control is a single cell-sized square (+) aligned to the inline end with `fullWidth` (otherwise placed by its parent); rows are fixed in both states so expanding never shifts layout vertically, and the inline size is not reserved. Expansion animates only the inline size, from the inline end toward the inline start (logical properties, RTL-correct): − and the field reveal from zero-width tracks and fade in (`--dur-normal`, `--ease-in-out`); they clip their own content, so focus rings are never clipped. Vertical keeps its stacked footprint: the collapsed + spans all three cells, not animated. Density/theme tokens drive size, spacing, icons, borders, and focus. The same sizing applies on mobile, tablet, and desktop. Reduced-motion users receive no transition. Native buttons are `type="button"`; the only timers are the press-and-hold repeat, cleared on release, disable and unmount; no browser globals during render or SSR-only branches.
90
+ Touch targets use `var(--touch-target)`: each cell is exactly the token (padding and icons fit inside, so a larger `--gap-sm` never inflates it) and grows only with enlarged text (`max(target, 1lh + 2 × --gap-sm)`, WCAG 1.4.4 / 1.4.12). − and + are one cell square; the quantity field is content-sized for three tabular digits (`3ch + --gap-sm`), one cell high, and stays at the touch target when it is a clickable `onValueClick` button. Expanded minimum footprint: two cells + field + border. `fullWidth` fills the container but shrinks to that minimum, never further. Collapsed, the horizontal control is a single cell-sized square (+) aligned to the inline end with `fullWidth` (otherwise placed by its parent); rows are fixed in both states so expanding never shifts layout vertically, and the inline size is not reserved. Expansion animates only the inline size, from the inline end toward the inline start (logical properties, RTL-correct): − and the field reveal from zero-width tracks and fade in (`--dur-normal`, `--ease-in-out`); they clip their own content, so focus rings are never clipped. Vertical keeps its stacked footprint: the collapsed + spans all three cells, not animated. With `addLabel` (horizontal only) the collapsed control keeps the expanded footprint instead of the square: the + spans the three cells and shows "+ label" (a decorative overlay of the whole group); expansion resizes nothing, the label fades out while − / quantity / the + icon fade in, and the + returns to its cell (a press-and-hold started there keeps the pointer captured, so the hold continues). Density/theme tokens drive size, spacing, icons, borders, and focus. The same sizing applies on mobile, tablet, and desktop. Reduced-motion users receive no transition. Native buttons are `type="button"`; the only timers are the press-and-hold repeat, cleared on release, disable and unmount; no browser globals during render or SSR-only branches.
69
91
 
70
92
  CSS is loaded by the existing component stylesheet import and framework styles index; no new export or style-index entries are required.
71
93
 
72
94
  ## Regression tests
73
95
 
74
96
  ```sh
75
- bun test packages/components/src/atomic/QuantityStepper/__tests__/quantity.test.ts packages/components/src/atomic/QuantityStepper/__tests__/QuantityStepper.dom.test.tsx
97
+ bun test packages/components/src/atomic/QuantityStepper/__tests__/quantity.test.ts packages/components/src/atomic/QuantityStepper/__tests__/QuantityStepper.dom.test.tsx packages/components/src/atomic/QuantityStepper/__tests__/QuantityStepper.fly.dom.test.tsx
76
98
  ```
77
99
 
78
100
  DOM tests use `bun:test`, Happy DOM, and React `act`, exercising the actual component rather than a mock. They cover legacy value-button focus across collapse/expansion, horizontal and vertical, and guard the shared sizing, focus-visible, and enabled-only hover CSS. Happy DOM does not measure layout; browser regressions (`tests/quantity-cart/run.ts`) verify equal collapsed/expanded block size, the collapsed square, fullWidth, enlarged text, and target sizes across mobile/tablet/desktop.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/components",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Styled UI components for DoNotDev",
@@ -1,32 +0,0 @@
1
- /**
2
- * @fileoverview PortalButton component
3
- * @description Button component that renders in a portal (document.body) to avoid transform issues
4
- *
5
- * @version 0.1.0
6
- * @since 0.0.1
7
- * @author AMBROISE PARK Consulting
8
- */
9
- import { type ButtonProps } from '../Button';
10
- /** Props for the PortalButton component -- Button rendered in a portal to avoid transform issues. */
11
- export interface PortalButtonProps extends ButtonProps {
12
- }
13
- /**
14
- * PortalButton - Button component rendered in a portal
15
- *
16
- * Renders a Button component inside a Radix Portal to avoid transform/positioning issues.
17
- * Useful for floating buttons that need to stay fixed relative to viewport.
18
- *
19
- * @component
20
- * @example
21
- * ```tsx
22
- * <PortalButton icon={Bug} onClick={handleClick}>
23
- * Debug Tools
24
- * </PortalButton>
25
- * ```
26
- *
27
- * @param {PortalButtonProps} props - The props for the portal button
28
- * @returns {JSX.Element} The rendered portal button
29
- */
30
- declare const PortalButton: (props: PortalButtonProps) => import("react").JSX.Element;
31
- export default PortalButton;
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atomic/PortalButton/index.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAe,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAGrD,qGAAqG;AACrG,MAAM,WAAW,iBAAkB,SAAQ,WAAW;CAAG;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,iBAAiB,gCAM7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1 +0,0 @@
1
- import r from"../Button/index.js";import n from"../Portal/index.js";import{jsx as t}from"react/jsx-runtime";var p=o=>t(n,{children:t(r,{...o})}),u=p;export{u as default};