@charcuterie/ui 4.28.1 → 4.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Avatar/Avatar.d.ts.map +1 -1
- package/dist/Avatar/Avatar.js +6 -15
- package/dist/Avatar/Avatar.js.map +1 -1
- package/dist/Board/useBoardDrag.d.ts.map +1 -1
- package/dist/Board/useBoardDrag.js +101 -11
- package/dist/Board/useBoardDrag.js.map +1 -1
- package/dist/CopyButton/copyText.d.ts +1 -1
- package/dist/CopyButton/copyText.js +1 -1
- package/dist/PortraitTiles/PortraitAvatar.d.ts +5 -0
- package/dist/PortraitTiles/PortraitAvatar.d.ts.map +1 -1
- package/dist/PortraitTiles/PortraitAvatar.js +9 -6
- package/dist/PortraitTiles/PortraitAvatar.js.map +1 -1
- package/dist/Shell/contentWidth.d.ts +1 -1
- package/dist/Shell/contentWidth.js +1 -1
- package/dist/markdownEditorCodeMirror/finishParsing.testHelpers.d.ts +29 -0
- package/dist/markdownEditorCodeMirror/finishParsing.testHelpers.d.ts.map +1 -0
- package/dist/markdownEditorCodeMirror/finishParsing.testHelpers.js +38 -0
- package/dist/markdownEditorCodeMirror/finishParsing.testHelpers.js.map +1 -0
- package/dist/motion.testHelpers.d.ts +35 -0
- package/dist/motion.testHelpers.d.ts.map +1 -0
- package/dist/motion.testHelpers.js +44 -0
- package/dist/motion.testHelpers.js.map +1 -0
- package/dist/useImageFailure.d.ts +52 -0
- package/dist/useImageFailure.d.ts.map +1 -0
- package/dist/useImageFailure.js +71 -0
- package/dist/useImageFailure.js.map +1 -0
- package/dist/waitForImages.testHelpers.d.ts +33 -0
- package/dist/waitForImages.testHelpers.d.ts.map +1 -0
- package/dist/waitForImages.testHelpers.js +48 -0
- package/dist/waitForImages.testHelpers.js.map +1 -0
- package/package.json +1 -1
- package/src/Avatar/Avatar.test.tsx +54 -1
- package/src/Avatar/Avatar.tsx +7 -19
- package/src/Board/useBoardDrag.test.tsx +395 -0
- package/src/Board/useBoardDrag.ts +129 -16
- package/src/CopyButton/copyText.ts +1 -1
- package/src/GroupedList/GroupedList.test.tsx +22 -17
- package/src/Main/Main.mdx +1 -1
- package/src/Motion/useListMotion.test.tsx +21 -15
- package/src/Motion/usePresence.test.tsx +76 -24
- package/src/Motion/useValueChangeMotion.test.tsx +12 -9
- package/src/Nav/Nav.mdx +1 -1
- package/src/Nav/Nav.stories.tsx +1 -1
- package/src/Overlay/overlayReturnFocus.test.tsx +18 -20
- package/src/PortraitTiles/PortraitAvatar.tsx +10 -5
- package/src/PortraitTiles/PortraitTiles.test.tsx +219 -17
- package/src/Shell/contentWidth.ts +1 -1
- package/src/markdownEditorCodeMirror/MarkdownView.test.tsx +32 -11
- package/src/markdownEditorCodeMirror/finishParsing.testHelpers.ts +47 -0
- package/src/motion.testHelpers.ts +46 -0
- package/src/sourceRules.test.ts +1 -1
- package/src/useImageFailure.ts +93 -0
- package/src/waitForImages.testHelpers.ts +61 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../src/Avatar/Avatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAGd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI1D,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,iBAAiB,CAAA;AAEvD,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,qBAAqB,CAAC,MAAM,CAAC,EAC7B,UAAU,CACX,GAAG;IACF;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAC/C;;;;OAIG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAA;IAC9B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;;;;OAOG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IAC/B,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,QAAA,MAAM,iBAAiB;;;;CAIb,CAAA;AAkBV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AACH,eAAO,MAAM,MAAM,GAAI,mHAYpB,WAAW,KAAG,SAsDhB,CAAA"}
|
package/dist/Avatar/Avatar.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { getCategoricalIndex } from "@charcuterie/tokens";
|
|
3
|
-
import { useState } from "react";
|
|
4
3
|
import { CATEGORICAL_APPEARANCE_CLASS } from "../categoricalStyles.js";
|
|
5
4
|
import { toClassName } from "../toClassName.js";
|
|
5
|
+
import { useImageFailure } from "../useImageFailure.js";
|
|
6
6
|
/**
|
|
7
7
|
* One rule: **the circle is 1.9 x its own type size**, and `size`
|
|
8
8
|
* picks which step of the type scale that is.
|
|
@@ -113,18 +113,11 @@ const toInitials = (name) => name
|
|
|
113
113
|
*/
|
|
114
114
|
export const Avatar = ({ appearance = "soft", categorical, categoricalKey, className, icon, imageUrl, initials, name, size = "md", title, ...spanProps }) => {
|
|
115
115
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* effect syncing a prop into state — the shape this library
|
|
120
|
-
* refuses everywhere else
|
|
121
|
-
* ([decision](../../../docs/decisions/2026-07-29-logic-hooks-are-uncontrolled.md)).
|
|
122
|
-
* Storing the URL makes the comparison below derive the answer, so
|
|
123
|
-
* a second photo gets its own attempt and a re-render never
|
|
124
|
-
* resurrects a dead one.
|
|
116
|
+
* Keyed by the URL that failed, so a second photo gets its own
|
|
117
|
+
* attempt, and it also notices a photo that failed before a
|
|
118
|
+
* server render hydrated — see `useImageFailure`.
|
|
125
119
|
*/
|
|
126
|
-
const
|
|
127
|
-
const hasImageError = imageUrl !== undefined && failedImageUrl === imageUrl;
|
|
120
|
+
const { hasFailed: hasImageError, imageProps } = useImageFailure(imageUrl);
|
|
128
121
|
const trimmedName = name?.trim();
|
|
129
122
|
if (!trimmedName) {
|
|
130
123
|
return null;
|
|
@@ -132,8 +125,6 @@ export const Avatar = ({ appearance = "soft", categorical, categoricalKey, class
|
|
|
132
125
|
const resolvedInitials = initials ?? toInitials(trimmedName);
|
|
133
126
|
const resolvedCategorical = categorical ??
|
|
134
127
|
getCategoricalIndex(categoricalKey ?? trimmedName);
|
|
135
|
-
return (_jsx("span", { ...spanProps, "aria-label": trimmedName, className: toClassName("inline-grid shrink-0 place-items-center overflow-hidden rounded-full border font-medium leading-none", AVATAR_SIZE_CLASS[size], CATEGORICAL_APPEARANCE_CLASS[resolvedCategorical][appearance], className), role: "img", title: title ?? trimmedName, children: imageUrl !== undefined && !hasImageError ? (_jsx("img", { alt: "", className: "size-full object-cover",
|
|
136
|
-
setFailedImageUrl(imageUrl);
|
|
137
|
-
}, src: imageUrl })) : (_jsx("span", { "aria-hidden": "true", children: icon ?? resolvedInitials })) }));
|
|
128
|
+
return (_jsx("span", { ...spanProps, "aria-label": trimmedName, className: toClassName("inline-grid shrink-0 place-items-center overflow-hidden rounded-full border font-medium leading-none", AVATAR_SIZE_CLASS[size], CATEGORICAL_APPEARANCE_CLASS[resolvedCategorical][appearance], className), role: "img", title: title ?? trimmedName, children: imageUrl !== undefined && !hasImageError ? (_jsx("img", { ...imageProps, alt: "", className: "size-full object-cover", src: imageUrl })) : (_jsx("span", { "aria-hidden": "true", children: icon ?? resolvedInitials })) }));
|
|
138
129
|
};
|
|
139
130
|
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../src/Avatar/Avatar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"Avatar.js","sourceRoot":"","sources":["../../src/Avatar/Avatar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAMzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAsEvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,iBAAiB,GAAG;IACxB,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,sBAAsB;IAC1B,EAAE,EAAE,sBAAsB;CAClB,CAAA;AAEV;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAC1C,IAAI;KACD,IAAI,EAAE;KACN,KAAK,CAAC,KAAK,CAAC;KACZ,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;KACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;KACxC,IAAI,CAAC,EAAE,CAAC;KAC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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBoardDrag.d.ts","sourceRoot":"","sources":["../../src/Board/useBoardDrag.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,MAAM,gBAAgB,CAAA;AAwDvB,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C;;;;OAIG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,eAAe,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED,KAAK,YAAY,GAAG,aAAa,GAAG;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAaD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,YAAY,EAClB,OAAO,MAAM,KACZ,MA2BF,CAAA;
|
|
1
|
+
{"version":3,"file":"useBoardDrag.d.ts","sourceRoot":"","sources":["../../src/Board/useBoardDrag.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAEhB,MAAM,gBAAgB,CAAA;AAwDvB,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG;IAC7C;;;;OAIG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,eAAe,GAAG,IAAI,CAAA;CAC/B,CAAA;AAED,KAAK,YAAY,GAAG,aAAa,GAAG;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAaD;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,YAAY,EAClB,OAAO,MAAM,KACZ,MA2BF,CAAA;AA8ED,eAAO,MAAM,YAAY,GAAI,2BAG1B;IACD;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,CACN,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,KACpB,IAAI,CAAA;CACV,KAAG;IACF,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;IAC3B,YAAY,EAAE,CACZ,OAAO,EAAE,MAAM,KACZ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;IAC1C,SAAS,EAAE,CACT,YAAY,EAAE;QACZ,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,aAAa,EAAE,WAAW,GAAG,OAAO,CAAA;QACpC,SAAS,EAAE,MAAM,CAAA;KAClB,EACD,MAAM,EAAE,eAAe,KACpB,IAAI,CAAA;CAgSV,CAAA"}
|
|
@@ -86,6 +86,66 @@ export const getIndicatorOffset = (lane, index) => {
|
|
|
86
86
|
return ((previous.top + previous.height + next.top) / 2 -
|
|
87
87
|
listTop);
|
|
88
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Swallows the one synthetic `click` that a finished drag produces.
|
|
91
|
+
*
|
|
92
|
+
* Swallowed in the **capture** phase, so it consumes the click this
|
|
93
|
+
* gesture produced before the handle's own listener sees it. A
|
|
94
|
+
* `hasDragged` flag on the card would be the same idea with a
|
|
95
|
+
* lifetime nobody owns.
|
|
96
|
+
*
|
|
97
|
+
* The blocker must not outlive that click, and a drag does not
|
|
98
|
+
* always produce one: a touch that travelled is not a tap, and a
|
|
99
|
+
* `pointerup` outside the handle without pointer capture lands its
|
|
100
|
+
* click on an ancestor or nowhere. So it also disarms on the next
|
|
101
|
+
* `pointerdown` or `keydown` (a new gesture has begun, and the old
|
|
102
|
+
* one's click would already have arrived) and after a short timer
|
|
103
|
+
* (for a click with no gesture in front of it, such as a screen
|
|
104
|
+
* reader's activation).
|
|
105
|
+
*
|
|
106
|
+
* And it swallows only a click that could be the gesture's own: one
|
|
107
|
+
* on the handle (where pointer capture sends it), or on an ancestor
|
|
108
|
+
* of the handle (where a `pointerup` that left the handle without
|
|
109
|
+
* capture sends it). A click on any other control passes, so a
|
|
110
|
+
* bystander is never the one that pays.
|
|
111
|
+
*/
|
|
112
|
+
const CLICK_BLOCK_MS = 400;
|
|
113
|
+
const blockNextClick = (handle) => {
|
|
114
|
+
const swallow = (clickEvent) => {
|
|
115
|
+
const { target } = clickEvent;
|
|
116
|
+
if (!(target instanceof Node) ||
|
|
117
|
+
!target.contains(handle)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
clickEvent.preventDefault();
|
|
121
|
+
clickEvent.stopPropagation();
|
|
122
|
+
disarm();
|
|
123
|
+
};
|
|
124
|
+
const timer = globalThis.setTimeout(() => {
|
|
125
|
+
disarm();
|
|
126
|
+
}, CLICK_BLOCK_MS);
|
|
127
|
+
function disarm() {
|
|
128
|
+
globalThis.clearTimeout(timer);
|
|
129
|
+
globalThis.removeEventListener("click", swallow, {
|
|
130
|
+
capture: true,
|
|
131
|
+
});
|
|
132
|
+
globalThis.removeEventListener("pointerdown", disarm, {
|
|
133
|
+
capture: true,
|
|
134
|
+
});
|
|
135
|
+
globalThis.removeEventListener("keydown", disarm, {
|
|
136
|
+
capture: true,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
globalThis.addEventListener("click", swallow, {
|
|
140
|
+
capture: true,
|
|
141
|
+
});
|
|
142
|
+
globalThis.addEventListener("pointerdown", disarm, {
|
|
143
|
+
capture: true,
|
|
144
|
+
});
|
|
145
|
+
globalThis.addEventListener("keydown", disarm, {
|
|
146
|
+
capture: true,
|
|
147
|
+
});
|
|
148
|
+
};
|
|
89
149
|
export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) => {
|
|
90
150
|
const laneElements = useRef(new Map());
|
|
91
151
|
const snapshot = useRef([]);
|
|
@@ -98,6 +158,15 @@ export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) =>
|
|
|
98
158
|
* cannot close over `drag` itself.
|
|
99
159
|
*/
|
|
100
160
|
const dragRef = useRef(null);
|
|
161
|
+
/**
|
|
162
|
+
* Removes the listeners of the gesture in progress, if there is
|
|
163
|
+
* one. Kept in a ref so an unmount can call it: the pointer
|
|
164
|
+
* listeners live on `globalThis`, and a component that unmounts
|
|
165
|
+
* mid-drag (a route change, a lane that closes) would otherwise
|
|
166
|
+
* leave them there, and the next `pointerup` anywhere on the page
|
|
167
|
+
* would commit a drop for a board that no longer exists.
|
|
168
|
+
*/
|
|
169
|
+
const stopGestureRef = useRef(null);
|
|
101
170
|
const setDragState = useCallback((next) => {
|
|
102
171
|
dragRef.current = next;
|
|
103
172
|
setDrag(next);
|
|
@@ -172,10 +241,16 @@ export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) =>
|
|
|
172
241
|
y: moveEvent.clientY,
|
|
173
242
|
});
|
|
174
243
|
};
|
|
175
|
-
const
|
|
244
|
+
const stopGesture = () => {
|
|
176
245
|
globalThis.removeEventListener("pointermove", onPointerMove);
|
|
177
246
|
globalThis.removeEventListener("pointerup", onUp);
|
|
178
247
|
globalThis.removeEventListener("pointercancel", onCancel);
|
|
248
|
+
if (stopGestureRef.current === stopGesture) {
|
|
249
|
+
stopGestureRef.current = null;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
const finish = (isCommitted) => {
|
|
253
|
+
stopGesture();
|
|
179
254
|
const live = dragRef.current;
|
|
180
255
|
setDragState(null);
|
|
181
256
|
if (!live) {
|
|
@@ -188,15 +263,14 @@ export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) =>
|
|
|
188
263
|
* every completed drag lands the card and then opens a menu
|
|
189
264
|
* on top of it.
|
|
190
265
|
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
266
|
+
* Only a `pointerup` gets the blocker. A `pointercancel`
|
|
267
|
+
* produces no `click` at all — the browser took the
|
|
268
|
+
* gesture — so a blocker installed there waits for the
|
|
269
|
+
* next REAL click, anywhere on the page, and eats it.
|
|
195
270
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, { capture: true, once: true });
|
|
271
|
+
if (isCommitted) {
|
|
272
|
+
blockNextClick(handle);
|
|
273
|
+
}
|
|
200
274
|
if (isCommitted && live.target) {
|
|
201
275
|
onDrop(origin, live.target);
|
|
202
276
|
}
|
|
@@ -206,9 +280,22 @@ export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) =>
|
|
|
206
280
|
finish(true);
|
|
207
281
|
}
|
|
208
282
|
};
|
|
209
|
-
const onCancel = () => {
|
|
210
|
-
|
|
283
|
+
const onCancel = (cancelEvent) => {
|
|
284
|
+
if (cancelEvent.pointerId === pointerEvent.pointerId) {
|
|
285
|
+
finish(false);
|
|
286
|
+
}
|
|
211
287
|
};
|
|
288
|
+
// A second press while a gesture is live (another finger, or
|
|
289
|
+
// a pointer whose `pointerup` never arrived) replaces the
|
|
290
|
+
// first gesture rather than stacking listeners beside it. Its
|
|
291
|
+
// drag state goes with it: otherwise this press, released
|
|
292
|
+
// without moving, would drop ITS card on the first gesture's
|
|
293
|
+
// target.
|
|
294
|
+
if (stopGestureRef.current) {
|
|
295
|
+
stopGestureRef.current();
|
|
296
|
+
setDragState(null);
|
|
297
|
+
}
|
|
298
|
+
stopGestureRef.current = stopGesture;
|
|
212
299
|
globalThis.addEventListener("pointermove", onPointerMove, { passive: false });
|
|
213
300
|
globalThis.addEventListener("pointerup", onUp);
|
|
214
301
|
globalThis.addEventListener("pointercancel", onCancel);
|
|
@@ -220,6 +307,9 @@ export const useBoardDrag = ({ itemSelector = "[data-board-card]", onDrop, }) =>
|
|
|
220
307
|
* component unmounts mid-drag — which is exactly what a route
|
|
221
308
|
* change during a drag does.
|
|
222
309
|
*/
|
|
310
|
+
useEffect(() => () => {
|
|
311
|
+
stopGestureRef.current?.();
|
|
312
|
+
}, []);
|
|
223
313
|
useEffect(() => {
|
|
224
314
|
const onKeyDown = (keyEvent) => {
|
|
225
315
|
if (keyEvent.key === "Escape" && dragRef.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBoardDrag.js","sourceRoot":"","sources":["../../src/Board/useBoardDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAA;AAOd,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH;;;;;;;;GAQG;AACH,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAuB3B,MAAM,MAAM,GAAG,CAAC,OAAgB,EAAa,EAAE;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAA;IAE5C,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,IAAkB,EAClB,KAAa,EACL,EAAE;IACV,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAExC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,QAAQ,GAAG,SAAS,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IAErC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CA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. **`navigator.clipboard.writeText`.** The real API. It exists
|
|
8
8
|
* only in a *secure context*, which a `devshare` URL and
|
|
9
|
-
* `localhost` both are — and a plain `http://
|
|
9
|
+
* `localhost` both are — and a plain `http://truenas-host:8080`
|
|
10
10
|
* dev server is not.
|
|
11
11
|
* 2. **A hidden `<textarea>` plus `document.execCommand("copy")`.**
|
|
12
12
|
* Deprecated, and kept anyway: it is the only thing that works in
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* 1. **`navigator.clipboard.writeText`.** The real API. It exists
|
|
8
8
|
* only in a *secure context*, which a `devshare` URL and
|
|
9
|
-
* `localhost` both are — and a plain `http://
|
|
9
|
+
* `localhost` both are — and a plain `http://truenas-host:8080`
|
|
10
10
|
* dev server is not.
|
|
11
11
|
* 2. **A hidden `<textarea>` plus `document.execCommand("copy")`.**
|
|
12
12
|
* Deprecated, and kept anyway: it is the only thing that works in
|
|
@@ -9,6 +9,11 @@ import type { ReactNode } from "react";
|
|
|
9
9
|
* network stripped — so the fallback the caller already supplied for
|
|
10
10
|
* "no picture" covers "no picture *today*" as well.
|
|
11
11
|
*
|
|
12
|
+
* The failure is keyed by URL, so a tile whose photo failed tries
|
|
13
|
+
* again when the caller passes a new one, and a photo that failed
|
|
14
|
+
* before a server render hydrated is noticed too — see
|
|
15
|
+
* `useImageFailure`.
|
|
16
|
+
*
|
|
12
17
|
* Its own component because the state is per portrait. Hoisting it
|
|
13
18
|
* to a `Record<string, boolean>` in the set would re-render every
|
|
14
19
|
* tile whenever any one image failed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortraitAvatar.d.ts","sourceRoot":"","sources":["../../src/PortraitTiles/PortraitAvatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"PortraitAvatar.d.ts","sourceRoot":"","sources":["../../src/PortraitTiles/PortraitAvatar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,cAAc,GAAI,oCAI5B;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,QAAQ,EAAE,SAAS,CAAA;CACpB,KAAG,SAsBH,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useImageFailure } from "../useImageFailure.js";
|
|
3
3
|
/**
|
|
4
4
|
* The face, and the one piece of this component that holds state.
|
|
5
5
|
*
|
|
@@ -10,20 +10,23 @@ import { useState } from "react";
|
|
|
10
10
|
* network stripped — so the fallback the caller already supplied for
|
|
11
11
|
* "no picture" covers "no picture *today*" as well.
|
|
12
12
|
*
|
|
13
|
+
* The failure is keyed by URL, so a tile whose photo failed tries
|
|
14
|
+
* again when the caller passes a new one, and a photo that failed
|
|
15
|
+
* before a server render hydrated is noticed too — see
|
|
16
|
+
* `useImageFailure`.
|
|
17
|
+
*
|
|
13
18
|
* Its own component because the state is per portrait. Hoisting it
|
|
14
19
|
* to a `Record<string, boolean>` in the set would re-render every
|
|
15
20
|
* tile whenever any one image failed.
|
|
16
21
|
*/
|
|
17
22
|
export const PortraitAvatar = ({ className, imageSrc, initials, }) => {
|
|
18
|
-
const
|
|
23
|
+
const { hasFailed: isImageBroken, imageProps } = useImageFailure(imageSrc);
|
|
19
24
|
if (imageSrc === undefined || isImageBroken) {
|
|
20
25
|
return (_jsx("span", { "aria-hidden": true, className: className, children: initials }));
|
|
21
26
|
}
|
|
22
|
-
return (_jsx("img", {
|
|
27
|
+
return (_jsx("img", { ...imageProps,
|
|
23
28
|
// The name is beside it, inside the same tile, so an alt here
|
|
24
29
|
// is the name announced twice.
|
|
25
|
-
alt: "", className: className,
|
|
26
|
-
setIsImageBroken(true);
|
|
27
|
-
}, src: imageSrc }));
|
|
30
|
+
alt: "", className: className, src: imageSrc }));
|
|
28
31
|
};
|
|
29
32
|
//# sourceMappingURL=PortraitAvatar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortraitAvatar.js","sourceRoot":"","sources":["../../src/PortraitTiles/PortraitAvatar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PortraitAvatar.js","sourceRoot":"","sources":["../../src/PortraitTiles/PortraitAvatar.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,QAAQ,GAKT,EAAa,EAAE;IACd,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,GAC5C,eAAe,CAAC,QAAQ,CAAC,CAAA;IAE3B,IAAI,QAAQ,KAAK,SAAS,IAAI,aAAa,EAAE,CAAC;QAC5C,OAAO,CACL,oCAAkB,SAAS,EAAE,SAAS,YACnC,QAAQ,GACJ,CACR,CAAA;IACH,CAAC;IAED,OAAO,CACL,iBACM,UAAU;QACd,8DAA8D;QAC9D,+BAA+B;QAC/B,GAAG,EAAC,EAAE,EACN,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,QAAQ,GACb,CACH,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Ten repos hand-roll their page chrome and **no two of them cap
|
|
6
6
|
* the column at the same width**: `max-w-5xl` (board-games,
|
|
7
|
-
*
|
|
7
|
+
* sibling-app), `max-w-6xl` and `max-w-3xl` mixed inside one app
|
|
8
8
|
* (mux-magic), `max-w-7xl` (gallery-downloader, spoolbuddy),
|
|
9
9
|
* `max-w-[90rem]` (mail-sifter), `80rem` (points-market), a raw
|
|
10
10
|
* `1400px` in plain CSS (plex-channels), a JS-computed one
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Ten repos hand-roll their page chrome and **no two of them cap
|
|
6
6
|
* the column at the same width**: `max-w-5xl` (board-games,
|
|
7
|
-
*
|
|
7
|
+
* sibling-app), `max-w-6xl` and `max-w-3xl` mixed inside one app
|
|
8
8
|
* (mux-magic), `max-w-7xl` (gallery-downloader, spoolbuddy),
|
|
9
9
|
* `max-w-[90rem]` (mail-sifter), `80rem` (points-market), a raw
|
|
10
10
|
* `1400px` in plain CSS (plex-channels), a JS-computed one
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse every CodeMirror document under `root` to its end, now, so the
|
|
3
|
+
* decorations a test asserts on are drawn before it looks.
|
|
4
|
+
*
|
|
5
|
+
* This is the readiness signal for anything CodeMirror decorates — a
|
|
6
|
+
* heading, a link, a task box, a table. Those are drawn from the
|
|
7
|
+
* syntax tree, and CodeMirror does **not** finish that tree on mount.
|
|
8
|
+
* It parses for about 20 ms when the state is created, and hands the
|
|
9
|
+
* rest to a background worker that waits at least 100 ms, and up to
|
|
10
|
+
* 500 ms, between slices. On a quiet machine the first 20 ms covers a
|
|
11
|
+
* story's document. On a shared CI runner the same 20 ms of wall time
|
|
12
|
+
* covers less of it, the worker takes over, and a `findBy` with
|
|
13
|
+
* Testing Library's 1 s default is a race against that schedule.
|
|
14
|
+
* `MarkdownView > a checkbox is inert until a consumer says where the
|
|
15
|
+
* tick goes` lost that race in the narrow window on 2026-10-13; three
|
|
16
|
+
* other tests in the file had already been given a `findBy` or a
|
|
17
|
+
* `waitFor` for the same reason.
|
|
18
|
+
*
|
|
19
|
+
* `forceParsing` runs the same parser to the end of the document and
|
|
20
|
+
* dispatches the finished tree, so the component's own decoration
|
|
21
|
+
* passes run exactly as they would after the worker — only without
|
|
22
|
+
* the wait. It is not a fake: nothing in the component is stubbed.
|
|
23
|
+
*
|
|
24
|
+
* The budget is unbounded because a story's document is a few dozen
|
|
25
|
+
* lines; a parse that does not finish is a hang the test's own
|
|
26
|
+
* timeout reports.
|
|
27
|
+
*/
|
|
28
|
+
export declare const finishCodeMirrorParsing: (root: ParentNode) => void;
|
|
29
|
+
//# sourceMappingURL=finishParsing.testHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finishParsing.testHelpers.d.ts","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/finishParsing.testHelpers.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,UAAU,KACf,IAcF,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { forceParsing } from "@codemirror/language";
|
|
2
|
+
import { EditorView } from "@codemirror/view";
|
|
3
|
+
/**
|
|
4
|
+
* Parse every CodeMirror document under `root` to its end, now, so the
|
|
5
|
+
* decorations a test asserts on are drawn before it looks.
|
|
6
|
+
*
|
|
7
|
+
* This is the readiness signal for anything CodeMirror decorates — a
|
|
8
|
+
* heading, a link, a task box, a table. Those are drawn from the
|
|
9
|
+
* syntax tree, and CodeMirror does **not** finish that tree on mount.
|
|
10
|
+
* It parses for about 20 ms when the state is created, and hands the
|
|
11
|
+
* rest to a background worker that waits at least 100 ms, and up to
|
|
12
|
+
* 500 ms, between slices. On a quiet machine the first 20 ms covers a
|
|
13
|
+
* story's document. On a shared CI runner the same 20 ms of wall time
|
|
14
|
+
* covers less of it, the worker takes over, and a `findBy` with
|
|
15
|
+
* Testing Library's 1 s default is a race against that schedule.
|
|
16
|
+
* `MarkdownView > a checkbox is inert until a consumer says where the
|
|
17
|
+
* tick goes` lost that race in the narrow window on 2026-10-13; three
|
|
18
|
+
* other tests in the file had already been given a `findBy` or a
|
|
19
|
+
* `waitFor` for the same reason.
|
|
20
|
+
*
|
|
21
|
+
* `forceParsing` runs the same parser to the end of the document and
|
|
22
|
+
* dispatches the finished tree, so the component's own decoration
|
|
23
|
+
* passes run exactly as they would after the worker — only without
|
|
24
|
+
* the wait. It is not a fake: nothing in the component is stubbed.
|
|
25
|
+
*
|
|
26
|
+
* The budget is unbounded because a story's document is a few dozen
|
|
27
|
+
* lines; a parse that does not finish is a hang the test's own
|
|
28
|
+
* timeout reports.
|
|
29
|
+
*/
|
|
30
|
+
export const finishCodeMirrorParsing = (root) => {
|
|
31
|
+
for (const element of root.querySelectorAll(".cm-editor")) {
|
|
32
|
+
const view = EditorView.findFromDOM(element);
|
|
33
|
+
if (view !== null) {
|
|
34
|
+
forceParsing(view, view.state.doc.length, Number.POSITIVE_INFINITY);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=finishParsing.testHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finishParsing.testHelpers.js","sourceRoot":"","sources":["../../src/markdownEditorCodeMirror/finishParsing.testHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,IAAgB,EACV,EAAE;IACR,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,gBAAgB,CACzC,YAAY,CACb,EAAE,CAAC;QACF,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAE5C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,YAAY,CACV,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EACrB,MAAM,CAAC,iBAAiB,CACzB,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A motion length no test outlives: an hour.
|
|
3
|
+
*
|
|
4
|
+
* The motion tests assert what is true **while** something moves — an
|
|
5
|
+
* item still entering, a row still leaving, a slide still in flight —
|
|
6
|
+
* right after a `userEvent` call. Each of those calls is a round trip
|
|
7
|
+
* to the browser driver, and on a shared CI runner one round trip has
|
|
8
|
+
* no upper bound. A 600 ms or 1 500 ms "slow" motion only made the
|
|
9
|
+
* window wider. `useListMotion > an item that moves while it is still
|
|
10
|
+
* entering slides from where it is shown` lost it in the narrow window
|
|
11
|
+
* on 2026-11-14 (run 43611154547): two clicks took longer than the
|
|
12
|
+
* 600 ms enter, and the item had finished entering before the test
|
|
13
|
+
* looked.
|
|
14
|
+
*
|
|
15
|
+
* Held this long, a motion is still running when the test reads it,
|
|
16
|
+
* whatever the machine is doing. A test that needs the motion **over**
|
|
17
|
+
* says so with `finishMotion`, rather than waiting for a clock.
|
|
18
|
+
*/
|
|
19
|
+
export declare const HELD_MOTION = "3600s";
|
|
20
|
+
/**
|
|
21
|
+
* End every finite animation and transition on `element` and beneath
|
|
22
|
+
* it, now.
|
|
23
|
+
*
|
|
24
|
+
* `Animation.finish()` jumps the animation to its end, and the browser
|
|
25
|
+
* then dispatches the same `animationend` or `transitionend` it would
|
|
26
|
+
* have dispatched at the natural end. The hooks under test listen for
|
|
27
|
+
* exactly those, so this exercises their real path — it only removes
|
|
28
|
+
* the wait. The events arrive on the next animation frame, so assert
|
|
29
|
+
* on what they cause with `waitFor`.
|
|
30
|
+
*
|
|
31
|
+
* Infinite animations, such as a spinner's, are skipped, because
|
|
32
|
+
* `finish()` throws on them and nothing waits for them to end.
|
|
33
|
+
*/
|
|
34
|
+
export declare const finishMotion: (element: Element) => void;
|
|
35
|
+
//# sourceMappingURL=motion.testHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.testHelpers.d.ts","sourceRoot":"","sources":["../src/motion.testHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,WAAW,UAAU,CAAA;AAElC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,OAAO,KAAG,IAW/C,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A motion length no test outlives: an hour.
|
|
3
|
+
*
|
|
4
|
+
* The motion tests assert what is true **while** something moves — an
|
|
5
|
+
* item still entering, a row still leaving, a slide still in flight —
|
|
6
|
+
* right after a `userEvent` call. Each of those calls is a round trip
|
|
7
|
+
* to the browser driver, and on a shared CI runner one round trip has
|
|
8
|
+
* no upper bound. A 600 ms or 1 500 ms "slow" motion only made the
|
|
9
|
+
* window wider. `useListMotion > an item that moves while it is still
|
|
10
|
+
* entering slides from where it is shown` lost it in the narrow window
|
|
11
|
+
* on 2026-11-14 (run 43611154547): two clicks took longer than the
|
|
12
|
+
* 600 ms enter, and the item had finished entering before the test
|
|
13
|
+
* looked.
|
|
14
|
+
*
|
|
15
|
+
* Held this long, a motion is still running when the test reads it,
|
|
16
|
+
* whatever the machine is doing. A test that needs the motion **over**
|
|
17
|
+
* says so with `finishMotion`, rather than waiting for a clock.
|
|
18
|
+
*/
|
|
19
|
+
export const HELD_MOTION = "3600s";
|
|
20
|
+
/**
|
|
21
|
+
* End every finite animation and transition on `element` and beneath
|
|
22
|
+
* it, now.
|
|
23
|
+
*
|
|
24
|
+
* `Animation.finish()` jumps the animation to its end, and the browser
|
|
25
|
+
* then dispatches the same `animationend` or `transitionend` it would
|
|
26
|
+
* have dispatched at the natural end. The hooks under test listen for
|
|
27
|
+
* exactly those, so this exercises their real path — it only removes
|
|
28
|
+
* the wait. The events arrive on the next animation frame, so assert
|
|
29
|
+
* on what they cause with `waitFor`.
|
|
30
|
+
*
|
|
31
|
+
* Infinite animations, such as a spinner's, are skipped, because
|
|
32
|
+
* `finish()` throws on them and nothing waits for them to end.
|
|
33
|
+
*/
|
|
34
|
+
export const finishMotion = (element) => {
|
|
35
|
+
for (const animation of element.getAnimations({
|
|
36
|
+
subtree: true,
|
|
37
|
+
})) {
|
|
38
|
+
if (animation.effect?.getComputedTiming().endTime !==
|
|
39
|
+
Number.POSITIVE_INFINITY) {
|
|
40
|
+
animation.finish();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=motion.testHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.testHelpers.js","sourceRoot":"","sources":["../src/motion.testHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAQ,EAAE;IACrD,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;QAC5C,OAAO,EAAE,IAAI;KACd,CAAC,EAAE,CAAC;QACH,IACE,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,OAAO;YAC7C,MAAM,CAAC,iBAAiB,EACxB,CAAC;YACD,SAAS,CAAC,MAAM,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RefCallback } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Whether the photo at `src` has failed, and the two props an `<img>`
|
|
4
|
+
* needs so that every failure is noticed.
|
|
5
|
+
*
|
|
6
|
+
* Shared by `Avatar` and `PortraitTiles`, whose whole promise about a
|
|
7
|
+
* photo is the same: it is never the only thing, so a 404, an expired
|
|
8
|
+
* signed URL, or a wrong content type lands on the initials rather than
|
|
9
|
+
* on a broken-image glyph.
|
|
10
|
+
*
|
|
11
|
+
* ### The failed URL, not a boolean
|
|
12
|
+
*
|
|
13
|
+
* A `hasFailed` boolean has to be *reset* when `src` changes, which is
|
|
14
|
+
* an effect syncing a prop into state — the shape this library refuses
|
|
15
|
+
* ([decision](../../../docs/decisions/2026-07-29-logic-hooks-are-uncontrolled.md)).
|
|
16
|
+
* Storing the URL that failed makes the comparison derive the answer:
|
|
17
|
+
* a new URL gets its own attempt, and a re-render never resurrects a
|
|
18
|
+
* dead one. `PortraitTiles` kept a boolean, so a tile whose photo
|
|
19
|
+
* failed showed initials for the rest of its life, even after the
|
|
20
|
+
* caller passed a working URL.
|
|
21
|
+
*
|
|
22
|
+
* ### `onError` alone misses a failure that happened first
|
|
23
|
+
*
|
|
24
|
+
* React attaches `onError` before it sets `src` on an image it creates,
|
|
25
|
+
* so a client render never misses the event. A **server-rendered**
|
|
26
|
+
* image is different. The browser starts loading it while it parses
|
|
27
|
+
* the HTML, and it can fail before `hydrateRoot` attaches the listener.
|
|
28
|
+
* React does not set `src` again when it hydrates an image, so the
|
|
29
|
+
* `error` event is never repeated, and the broken glyph stays.
|
|
30
|
+
*
|
|
31
|
+
* The ref closes that gap. When React attaches it, an image that is
|
|
32
|
+
* already `complete` has already answered, so `decode()` is asked for
|
|
33
|
+
* the answer again: it rejects for a broken image and resolves for a
|
|
34
|
+
* loaded one. An image still loading is not `complete`, and its answer
|
|
35
|
+
* arrives through `onError` as usual.
|
|
36
|
+
*
|
|
37
|
+
* ⚠️ `decode()` **also rejects when a newer `src` supersedes it**, with
|
|
38
|
+
* the same `EncodingError` a broken image gets. So a rejection counts
|
|
39
|
+
* only while this ref is still the one attached — React runs the
|
|
40
|
+
* cleanup below when the ref detaches or `src` changes — and only
|
|
41
|
+
* while the element still shows that `src` and has finished with it.
|
|
42
|
+
* Without the guard, a picture that was swapped out mid-decode was
|
|
43
|
+
* marked dead, and coming back to it showed the initials.
|
|
44
|
+
*/
|
|
45
|
+
export declare const useImageFailure: (src: string | undefined) => {
|
|
46
|
+
hasFailed: boolean;
|
|
47
|
+
imageProps: {
|
|
48
|
+
onError: () => void;
|
|
49
|
+
ref: RefCallback<HTMLImageElement>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=useImageFailure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useImageFailure.d.ts","sourceRoot":"","sources":["../src/useImageFailure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,MAAM,GAAG,SAAS,KACtB;IACD,SAAS,EAAE,OAAO,CAAA;IAClB,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,IAAI,CAAA;QACnB,GAAG,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAA;KACnC,CAAA;CAuCF,CAAA"}
|