@cloudgrid-io/ui 0.65.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/badge/owner.js +1 -1
- package/dist/badge/owner.js.map +1 -1
- package/dist/blocks/avatar-picker.d.ts +50 -4
- package/dist/blocks/avatar-picker.d.ts.map +1 -1
- package/dist/blocks/avatar-picker.js +56 -10
- package/dist/blocks/avatar-picker.js.map +1 -1
- package/dist/blocks/creation-search.d.ts +10 -1
- package/dist/blocks/creation-search.d.ts.map +1 -1
- package/dist/blocks/creation-search.js +5 -1
- package/dist/blocks/creation-search.js.map +1 -1
- package/dist/blocks/entity-card.d.ts +2 -0
- package/dist/blocks/entity-card.d.ts.map +1 -1
- package/dist/blocks/entity-card.js +22 -8
- package/dist/blocks/entity-card.js.map +1 -1
- package/dist/blocks/entity-identity.d.ts +24 -1
- package/dist/blocks/entity-identity.d.ts.map +1 -1
- package/dist/blocks/entity-identity.js +19 -0
- package/dist/blocks/entity-identity.js.map +1 -1
- package/dist/blocks/grid-profile.d.ts +18 -6
- package/dist/blocks/grid-profile.d.ts.map +1 -1
- package/dist/blocks/grid-profile.js +28 -17
- package/dist/blocks/grid-profile.js.map +1 -1
- package/dist/blocks/help-menu.d.ts +58 -0
- package/dist/blocks/help-menu.d.ts.map +1 -0
- package/dist/blocks/help-menu.js +64 -0
- package/dist/blocks/help-menu.js.map +1 -0
- package/dist/blocks/home-bento.d.ts +1 -1
- package/dist/blocks/home-bento.js +1 -1
- package/dist/blocks/home-pinned.d.ts +76 -9
- package/dist/blocks/home-pinned.d.ts.map +1 -1
- package/dist/blocks/home-pinned.js +66 -12
- package/dist/blocks/home-pinned.js.map +1 -1
- package/dist/blocks/icons.d.ts +13 -0
- package/dist/blocks/icons.d.ts.map +1 -1
- package/dist/blocks/icons.js +13 -0
- package/dist/blocks/icons.js.map +1 -1
- package/dist/blocks/image-adjust-dialog.d.ts +68 -11
- package/dist/blocks/image-adjust-dialog.d.ts.map +1 -1
- package/dist/blocks/image-adjust-dialog.js +69 -17
- package/dist/blocks/image-adjust-dialog.js.map +1 -1
- package/dist/blocks/inspiration-cards.d.ts +80 -24
- package/dist/blocks/inspiration-cards.d.ts.map +1 -1
- package/dist/blocks/inspiration-cards.js +145 -25
- package/dist/blocks/inspiration-cards.js.map +1 -1
- package/dist/blocks/invite-popup.d.ts +63 -5
- package/dist/blocks/invite-popup.d.ts.map +1 -1
- package/dist/blocks/invite-popup.js +60 -20
- package/dist/blocks/invite-popup.js.map +1 -1
- package/dist/blocks/motion.d.ts +4 -2
- package/dist/blocks/motion.d.ts.map +1 -1
- package/dist/blocks/motion.js +30 -26
- package/dist/blocks/motion.js.map +1 -1
- package/dist/blocks/need-help-line.d.ts +21 -0
- package/dist/blocks/need-help-line.d.ts.map +1 -0
- package/dist/blocks/need-help-line.js +24 -0
- package/dist/blocks/need-help-line.js.map +1 -0
- package/dist/blocks/needs-attention.d.ts +11 -0
- package/dist/blocks/needs-attention.d.ts.map +1 -1
- package/dist/blocks/needs-attention.js +4 -1
- package/dist/blocks/needs-attention.js.map +1 -1
- package/dist/blocks/phosphor-marks.d.ts +4 -0
- package/dist/blocks/phosphor-marks.d.ts.map +1 -1
- package/dist/blocks/phosphor-marks.js +6 -0
- package/dist/blocks/phosphor-marks.js.map +1 -1
- package/dist/blocks/picture-menu.d.ts +26 -0
- package/dist/blocks/picture-menu.d.ts.map +1 -0
- package/dist/blocks/picture-menu.js +22 -0
- package/dist/blocks/picture-menu.js.map +1 -0
- package/dist/blocks/recent-plugs.d.ts +23 -3
- package/dist/blocks/recent-plugs.d.ts.map +1 -1
- package/dist/blocks/recent-plugs.js +6 -3
- package/dist/blocks/recent-plugs.js.map +1 -1
- package/dist/blocks/shared-grid-illustration.js +3 -3
- package/dist/blocks/shared-grid-illustration.js.map +1 -1
- package/dist/blocks/top-creations.d.ts +10 -0
- package/dist/blocks/top-creations.d.ts.map +1 -1
- package/dist/blocks/top-creations.js +6 -1
- package/dist/blocks/top-creations.js.map +1 -1
- package/dist/brand/email/headline-1-invitation-left.png +0 -0
- package/dist/brand/email/headline-2-invitations-left.png +0 -0
- package/dist/brand/email/headline-3-invitations-left.png +0 -0
- package/dist/brand/email/headline-4-invitations-left.png +0 -0
- package/dist/brand/email/headline-5-invitations-left.png +0 -0
- package/dist/brand/email/headline-6-invitations-left.png +0 -0
- package/dist/brand/email/headline-7-invitations-left.png +0 -0
- package/dist/brand/email/headline-8-invitations-left.png +0 -0
- package/dist/brand/email/headline-9-invitations-left.png +0 -0
- package/dist/brand/email/headline-you-have-1-invitation.png +0 -0
- package/dist/brand/email/headline-you-have-2-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-3-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-4-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-5-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-6-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-7-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-8-invitations.png +0 -0
- package/dist/brand/email/headline-you-have-9-invitations.png +0 -0
- package/dist/email/assets.d.ts +108 -0
- package/dist/email/assets.d.ts.map +1 -1
- package/dist/email/assets.js +18 -0
- package/dist/email/assets.js.map +1 -1
- package/dist/email/index.d.ts +71 -0
- package/dist/email/index.d.ts.map +1 -1
- package/dist/email/index.js +110 -5
- package/dist/email/index.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/fit.js +1 -1
- package/dist/lib/fit.js.map +1 -1
- package/dist/lib/motion.d.ts +49 -10
- package/dist/lib/motion.d.ts.map +1 -1
- package/dist/lib/motion.js +75 -11
- package/dist/lib/motion.js.map +1 -1
- package/dist/lib/thumbnail-identity.d.ts +47 -0
- package/dist/lib/thumbnail-identity.d.ts.map +1 -0
- package/dist/lib/thumbnail-identity.js +59 -0
- package/dist/lib/thumbnail-identity.js.map +1 -0
- package/dist/lib/touch-hover.d.ts +63 -0
- package/dist/lib/touch-hover.d.ts.map +1 -0
- package/dist/lib/touch-hover.js +164 -0
- package/dist/lib/touch-hover.js.map +1 -0
- package/package.json +2 -2
package/dist/lib/motion.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { gsap } from "gsap";
|
|
3
2
|
/**
|
|
4
3
|
* The library's motion, on gsap (ui#533). The one module that imports gsap:
|
|
5
4
|
* the pieces in `blocks/motion.tsx` and `blocks/shared-grid-illustration.tsx`
|
|
@@ -22,13 +21,29 @@ import { gsap } from "gsap";
|
|
|
22
21
|
*
|
|
23
22
|
* - no script (a server render, a crawler): the end state;
|
|
24
23
|
* - reduced motion: the effect returns before it starts anything, so the
|
|
25
|
-
* end state shows at once and gsap never
|
|
24
|
+
* end state shows at once and gsap is never fetched;
|
|
26
25
|
* - an unmount mid-motion: the gsap context reverts, nothing is left inline.
|
|
27
26
|
*
|
|
28
27
|
* A server-rendered page shows the end state for the moment between its HTML
|
|
29
28
|
* painting and hydration, then runs the motion from the start. The Console's
|
|
30
29
|
* Home renders its data on the client, where the layout effect runs before the
|
|
31
|
-
* first paint and there is no such moment.
|
|
30
|
+
* first paint and there is no such moment, once gsap is on the page (below).
|
|
31
|
+
*
|
|
32
|
+
* ## gsap is fetched when a motion runs (ui#554)
|
|
33
|
+
*
|
|
34
|
+
* This module imports gsap's types only. gsap itself is fetched with
|
|
35
|
+
* `import("gsap")` the first time a piece starts a motion, and kept: a
|
|
36
|
+
* bundler splits it into a chunk of its own, so a page that renders a
|
|
37
|
+
* `RankedList` without `animated` (most of the Console) never downloads it.
|
|
38
|
+
* A static import here put its 28 KB gzip on every page that imports
|
|
39
|
+
* anything from `blocks/motion.tsx`, used or not.
|
|
40
|
+
*
|
|
41
|
+
* So the first motion on a page starts when gsap arrives, a moment after its
|
|
42
|
+
* layout effect, and the end state shows until then; every motion after it
|
|
43
|
+
* starts in its layout effect, as before. A piece undone before gsap arrives
|
|
44
|
+
* (unmounted, or its effect re-run) never starts. A page that knows a motion
|
|
45
|
+
* is coming (the Console Home, whose numbers mount after its data loads) calls
|
|
46
|
+
* `preloadMotion()` as it mounts, and its first motion starts at once too.
|
|
32
47
|
*
|
|
33
48
|
* ## The number reader
|
|
34
49
|
*
|
|
@@ -63,18 +78,68 @@ export const useIsoLayoutEffect = typeof document === "undefined" ? React.useEff
|
|
|
63
78
|
export function markMotion(el, state) {
|
|
64
79
|
el.setAttribute("data-motion", state);
|
|
65
80
|
}
|
|
81
|
+
let gsapHere;
|
|
82
|
+
let gsapOnItsWay;
|
|
83
|
+
/** gsap, fetched on the first call and kept; a failed fetch is tried again on the next. */
|
|
84
|
+
export function loadGsap() {
|
|
85
|
+
gsapOnItsWay ??= import("gsap").then((m) => (gsapHere = m.gsap), (error) => {
|
|
86
|
+
gsapOnItsWay = undefined;
|
|
87
|
+
throw error;
|
|
88
|
+
});
|
|
89
|
+
return gsapOnItsWay;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Runs `start` with gsap, and returns the undo. With gsap already here it runs
|
|
93
|
+
* at once, in the caller's layout effect; otherwise once gsap arrives. Undone
|
|
94
|
+
* before then, `start` never runs; after, the undo is `start`'s own. If gsap
|
|
95
|
+
* cannot be fetched, nothing runs and the end state, which is the markup,
|
|
96
|
+
* stays.
|
|
97
|
+
*/
|
|
98
|
+
export function withGsap(start) {
|
|
99
|
+
if (gsapHere)
|
|
100
|
+
return start(gsapHere) ?? noop;
|
|
101
|
+
let undone = false;
|
|
102
|
+
let undo;
|
|
103
|
+
loadGsap().then((gsap) => {
|
|
104
|
+
if (!undone)
|
|
105
|
+
undo = start(gsap);
|
|
106
|
+
}, noop);
|
|
107
|
+
return () => {
|
|
108
|
+
undone = true;
|
|
109
|
+
undo?.();
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function noop() { }
|
|
113
|
+
/**
|
|
114
|
+
* Starts fetching gsap now, ahead of a page's first motion, so that motion
|
|
115
|
+
* starts in its layout effect instead of showing the end state until gsap
|
|
116
|
+
* arrives. The Console Home calls it as the page mounts, before its data and
|
|
117
|
+
* its numbers. Exported from the package entry; nothing in the library calls
|
|
118
|
+
* it. Does nothing on a server or under reduced motion; a failed fetch is
|
|
119
|
+
* ignored, and the first motion asks again.
|
|
120
|
+
*/
|
|
121
|
+
export function preloadMotion() {
|
|
122
|
+
if (typeof window === "undefined" || prefersReducedMotion())
|
|
123
|
+
return;
|
|
124
|
+
loadGsap().catch(noop);
|
|
125
|
+
}
|
|
66
126
|
/**
|
|
67
|
-
* Runs `build` inside a gsap context scoped to `scope`,
|
|
68
|
-
* every tween it made is killed and every
|
|
127
|
+
* Runs `build` inside a gsap context scoped to `scope`, once gsap is here
|
|
128
|
+
* (`withGsap`), and returns the undo: every tween it made is killed and every
|
|
129
|
+
* inline style it set is removed; undone before gsap arrives, nothing starts.
|
|
69
130
|
*/
|
|
70
131
|
export function withMotion(scope, build) {
|
|
71
|
-
|
|
72
|
-
|
|
132
|
+
return withGsap((gsap) => {
|
|
133
|
+
const ctx = gsap.context(() => build(gsap), scope);
|
|
134
|
+
return () => ctx.revert();
|
|
135
|
+
});
|
|
73
136
|
}
|
|
74
137
|
/**
|
|
75
|
-
* The start state is written at once,
|
|
76
|
-
* next tick (`lazy: false` with the immediate render a from-tween has):
|
|
77
|
-
*
|
|
138
|
+
* The start state is written at once, when the tween is made, not on gsap's
|
|
139
|
+
* next tick (`lazy: false` with the immediate render a from-tween has): with
|
|
140
|
+
* gsap on the page that is the layout effect, so the browser never paints the
|
|
141
|
+
* end state first and then jumps back to the start. A page's first motion
|
|
142
|
+
* waits for gsap to arrive (ui#554), and shows the end state until it does.
|
|
78
143
|
*/
|
|
79
144
|
export const START_NOW = { immediateRender: true, lazy: false };
|
|
80
145
|
const INDEPENDENT = ["translate", "rotate", "scale"];
|
|
@@ -104,7 +169,6 @@ export function holdStyle(els) {
|
|
|
104
169
|
});
|
|
105
170
|
};
|
|
106
171
|
}
|
|
107
|
-
export { gsap };
|
|
108
172
|
const FIGURE = /^(\D*?)(\d{1,3}(?:,\d{3})+|\d+)(?:\.(\d+))?([\s\S]*)$/;
|
|
109
173
|
/** The first figure in `text`, with what comes before and after it; null for words. */
|
|
110
174
|
export function readFigure(text) {
|
package/dist/lib/motion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/lib/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"motion.js","sourceRoot":"","sources":["../../src/lib/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,4CAA4C;IAC5C,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;IAC5C,kEAAkE;IAClE,IAAI,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE;IAC3C,kEAAkE;IAClE,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;IAClE,6EAA6E;IAC7E,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE;IACrG,gEAAgE;IAChE,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,EA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AA;IACnF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACxC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA;AACrF,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,WAAW,CAAC,MAAc,EAAE,CAAS;IACnD,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO;QACzB,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,OAAO,EAAE;YACpC,qBAAqB,EAAE,MAAM,CAAC,QAAQ;YACtC,qBAAqB,EAAE,MAAM,CAAC,QAAQ;SACvC,CAAC;QACJ,CAAC,CAAC,KAAK,CAAA;IACT,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type EntityIdentitySize } from "../blocks/entity-identity.js";
|
|
3
|
+
/**
|
|
4
|
+
* THE IDENTITY UNDER A HOME THUMBNAIL (ui#573).
|
|
5
|
+
*
|
|
6
|
+
* A Home thumbnail (Pinned, Continue where you left off, My top creations,
|
|
7
|
+
* Recent plugs, the search window's rows) is a box with an `<img>` in it, or
|
|
8
|
+
* nothing. An item with a `seed` puts the creation's identity tile in that box
|
|
9
|
+
* too, from the seed and the name, as its card in My creations does: it fills
|
|
10
|
+
* the box, BEHIND the picture. A picture that paints covers it; no picture, or
|
|
11
|
+
* one that fails to load, shows it. The picture element is untouched.
|
|
12
|
+
*
|
|
13
|
+
* Behind, because the picture is an `<img>` in the flow and the identity is
|
|
14
|
+
* positioned, and a positioned element would otherwise paint over it: so the
|
|
15
|
+
* identity is `-z-10` and the box takes `THUMBNAIL_WITH_IDENTITY`, which makes it
|
|
16
|
+
* the stacking context that keeps the identity above the box's own ground.
|
|
17
|
+
*
|
|
18
|
+
* A picture that fails to load is taken out (`PictureOverIdentity`), because
|
|
19
|
+
* a broken `<img>` with a size is not always nothing: Chromium and WebKit both
|
|
20
|
+
* draw their broken-picture mark in it, alt="" or not, over the identity.
|
|
21
|
+
*
|
|
22
|
+
* Not exported from the package: the pieces' `seed` is the API.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ThumbnailIdentity({ seed, name, size, className, }: {
|
|
25
|
+
seed: string;
|
|
26
|
+
name: string;
|
|
27
|
+
size: EntityIdentitySize;
|
|
28
|
+
className?: string;
|
|
29
|
+
}): React.JSX.Element;
|
|
30
|
+
/** What a thumbnail's box adds when it holds an identity: positioned, and its own stacking context. */
|
|
31
|
+
export declare const THUMBNAIL_WITH_IDENTITY = "relative isolate";
|
|
32
|
+
/**
|
|
33
|
+
* A thumbnail's picture over its identity: the `<img>` the piece already drew,
|
|
34
|
+
* with the same attributes in the same order (so the server's markup is the
|
|
35
|
+
* same), taken out once it fails to load, so the identity under it shows
|
|
36
|
+
* rather than the browser's broken-picture mark.
|
|
37
|
+
*
|
|
38
|
+
* Two ways a failure is heard: `onError`, and, for a picture that failed
|
|
39
|
+
* before the page hydrated (whose error event no handler was there to hear),
|
|
40
|
+
* a check when the element mounts: complete with no size, and `decode()`
|
|
41
|
+
* refusing it, so a picture that is merely sizeless (an SVG without a width)
|
|
42
|
+
* is not mistaken for a broken one.
|
|
43
|
+
*/
|
|
44
|
+
export declare function PictureOverIdentity(props: React.ComponentProps<"img"> & {
|
|
45
|
+
src: string;
|
|
46
|
+
}): React.JSX.Element | null;
|
|
47
|
+
//# sourceMappingURL=thumbnail-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thumbnail-identity.d.ts","sourceRoot":"","sources":["../../src/lib/thumbnail-identity.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAwC,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAE7G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,kBAAkB,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,qBAEA;AAED,uGAAuG;AACvG,eAAO,MAAM,uBAAuB,qBAAqB,CAAA;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,4BAevF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../lib/cloudgrid-cn.js";
|
|
5
|
+
import { ENTITY_IDENTITY_FILL, EntityIdentity } from "../blocks/entity-identity.js";
|
|
6
|
+
/**
|
|
7
|
+
* THE IDENTITY UNDER A HOME THUMBNAIL (ui#573).
|
|
8
|
+
*
|
|
9
|
+
* A Home thumbnail (Pinned, Continue where you left off, My top creations,
|
|
10
|
+
* Recent plugs, the search window's rows) is a box with an `<img>` in it, or
|
|
11
|
+
* nothing. An item with a `seed` puts the creation's identity tile in that box
|
|
12
|
+
* too, from the seed and the name, as its card in My creations does: it fills
|
|
13
|
+
* the box, BEHIND the picture. A picture that paints covers it; no picture, or
|
|
14
|
+
* one that fails to load, shows it. The picture element is untouched.
|
|
15
|
+
*
|
|
16
|
+
* Behind, because the picture is an `<img>` in the flow and the identity is
|
|
17
|
+
* positioned, and a positioned element would otherwise paint over it: so the
|
|
18
|
+
* identity is `-z-10` and the box takes `THUMBNAIL_WITH_IDENTITY`, which makes it
|
|
19
|
+
* the stacking context that keeps the identity above the box's own ground.
|
|
20
|
+
*
|
|
21
|
+
* A picture that fails to load is taken out (`PictureOverIdentity`), because
|
|
22
|
+
* a broken `<img>` with a size is not always nothing: Chromium and WebKit both
|
|
23
|
+
* draw their broken-picture mark in it, alt="" or not, over the identity.
|
|
24
|
+
*
|
|
25
|
+
* Not exported from the package: the pieces' `seed` is the API.
|
|
26
|
+
*/
|
|
27
|
+
export function ThumbnailIdentity({ seed, name, size, className, }) {
|
|
28
|
+
return _jsx(EntityIdentity, { seed: seed, name: name, size: size, className: cn(ENTITY_IDENTITY_FILL, "-z-10", className) });
|
|
29
|
+
}
|
|
30
|
+
/** What a thumbnail's box adds when it holds an identity: positioned, and its own stacking context. */
|
|
31
|
+
export const THUMBNAIL_WITH_IDENTITY = "relative isolate";
|
|
32
|
+
/**
|
|
33
|
+
* A thumbnail's picture over its identity: the `<img>` the piece already drew,
|
|
34
|
+
* with the same attributes in the same order (so the server's markup is the
|
|
35
|
+
* same), taken out once it fails to load, so the identity under it shows
|
|
36
|
+
* rather than the browser's broken-picture mark.
|
|
37
|
+
*
|
|
38
|
+
* Two ways a failure is heard: `onError`, and, for a picture that failed
|
|
39
|
+
* before the page hydrated (whose error event no handler was there to hear),
|
|
40
|
+
* a check when the element mounts: complete with no size, and `decode()`
|
|
41
|
+
* refusing it, so a picture that is merely sizeless (an SVG without a width)
|
|
42
|
+
* is not mistaken for a broken one.
|
|
43
|
+
*/
|
|
44
|
+
export function PictureOverIdentity(props) {
|
|
45
|
+
const { src } = props;
|
|
46
|
+
const [failed, setFailed] = React.useState(null);
|
|
47
|
+
const fail = React.useCallback(() => setFailed(src), [src]);
|
|
48
|
+
const check = React.useCallback((img) => {
|
|
49
|
+
if (img && img.complete && img.naturalWidth === 0)
|
|
50
|
+
img.decode().catch(fail);
|
|
51
|
+
}, [fail]);
|
|
52
|
+
if (failed === src)
|
|
53
|
+
return null;
|
|
54
|
+
// `alt` restated (the caller's, "": the name is beside the picture) so the
|
|
55
|
+
// a11y rule can see it; a key a spread already set keeps its place, so the
|
|
56
|
+
// attributes stay in the caller's order.
|
|
57
|
+
return _jsx("img", { ...props, alt: props.alt, ref: check, onError: fail });
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=thumbnail-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thumbnail-identity.js","sourceRoot":"","sources":["../../src/lib/thumbnail-identity.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAA2B,MAAM,+BAA+B,CAAA;AAE7G;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,SAAS,GAMV;IACC,OAAO,KAAC,cAAc,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,oBAAoB,EAAE,OAAO,EAAE,SAAS,CAAC,GAAI,CAAA;AACxH,CAAC;AAED,uGAAuG;AACvG,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAoD;IACtF,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAA;IACrB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAgB,IAAI,CAAC,CAAA;IAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAC7B,CAAC,GAA4B,EAAE,EAAE;QAC/B,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,YAAY,KAAK,CAAC;YAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7E,CAAC,EACD,CAAC,IAAI,CAAC,CACP,CAAA;IACD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IAC/B,2EAA2E;IAC3E,2EAA2E;IAC3E,yCAAyC;IACzC,OAAO,iBAAS,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,GAAI,CAAA;AACtE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ON A TOUCH SCREEN, ONE TAP DOES WHAT HOVER DOES (ui#559, Asaf, 2026-11-22).
|
|
3
|
+
*
|
|
4
|
+
* A phone has no hover, so a piece that shows its actions on hover hides them
|
|
5
|
+
* from a touch reader. For the pieces that ask (a scope: the Home card, a
|
|
6
|
+
* pinned item), this makes the first tap show the hover state and a second tap
|
|
7
|
+
* open, as one tap did before:
|
|
8
|
+
*
|
|
9
|
+
* 1 the first tap on a scope writes `data-touch-hover` on it and goes no
|
|
10
|
+
* further: the link under it does not follow, no handler hears it
|
|
11
|
+
* 2 a tap on a scope that already has it is the tap's own: the door opens,
|
|
12
|
+
* a button presses
|
|
13
|
+
* 3 so a button works on its first tap once it shows, and never on the tap
|
|
14
|
+
* that showed it (it was inert while hidden, and that tap is swallowed
|
|
15
|
+
* wherever in the scope it landed)
|
|
16
|
+
* 4 one at a time: a press anywhere outside the scope clears it (a press on
|
|
17
|
+
* another scope, then, moves it), and so does a scroll, of a rail or of
|
|
18
|
+
* the page. A press or a scroll inside an open menu is not outside: the
|
|
19
|
+
* menu is the scope's, portalled away from it
|
|
20
|
+
* 5 touch is the press's `pointerType`, per tap: never the screen's width or
|
|
21
|
+
* `(hover: none)`. A mouse or a pen (which hovers) and the keyboard (a
|
|
22
|
+
* click with no press before it, `detail` 0) behave exactly as before
|
|
23
|
+
* 6 only a real finger reveals: a touch press with a contact size (`width`
|
|
24
|
+
* and `height` above 0), at the scope its click lands on. A screen
|
|
25
|
+
* reader's double-tap (VoiceOver, TalkBack) can arrive as a synthesized
|
|
26
|
+
* touch press of size 0, or as a click with no press before it; either
|
|
27
|
+
* activates at once, as before, so its first activation is never
|
|
28
|
+
* swallowed (Nataly's review on PR #562). Not yet checked on a device
|
|
29
|
+
*
|
|
30
|
+
* It moves no focus and adds no element, role or name: a screen reader hears
|
|
31
|
+
* what it heard. The look is the scope's own CSS: every `group-hover/<g>:`
|
|
32
|
+
* class has a `group-data-[touch-hover]/<g>:` twin beside it, so the tapped
|
|
33
|
+
* look is the hover look, eased by the same transition and stilled by the same
|
|
34
|
+
* reduced-motion rule.
|
|
35
|
+
*
|
|
36
|
+
* One listener set per document, in the capture phase (so a handler that
|
|
37
|
+
* stops propagation cannot hide a tap, and a swallowed tap reaches nothing),
|
|
38
|
+
* shared by every scope and counted, as `trackInputModality` is. The attribute
|
|
39
|
+
* is written on the element, not through React state: nothing re-renders, and
|
|
40
|
+
* the pieces that ask stay server components (`<TouchHover />` renders
|
|
41
|
+
* nothing).
|
|
42
|
+
*/
|
|
43
|
+
export declare const TOUCH_HOVER_ATTRIBUTE = "data-touch-hover";
|
|
44
|
+
type TouchHoverDocument = Pick<Document, "addEventListener" | "removeEventListener">;
|
|
45
|
+
/**
|
|
46
|
+
* Make the first touch tap on any element matching `scope` show its hover
|
|
47
|
+
* state (`data-touch-hover`), and the second open. Returns a function that
|
|
48
|
+
* stops this start. `<TouchHover scope=… />` is this in an effect.
|
|
49
|
+
*
|
|
50
|
+
* Counted per document and per scope: the first start attaches the listeners,
|
|
51
|
+
* the last stop removes them and clears the state; a stop released twice
|
|
52
|
+
* counts once.
|
|
53
|
+
*/
|
|
54
|
+
export declare function trackTouchHover(scope: string, doc?: TouchHoverDocument): () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Turns the touch rule on for `scope` while it is mounted. Renders nothing, so
|
|
57
|
+
* a server component can carry it: the Home card and Pinned do.
|
|
58
|
+
*/
|
|
59
|
+
export declare function TouchHover({ scope }: {
|
|
60
|
+
scope: string;
|
|
61
|
+
}): null;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=touch-hover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-hover.d.ts","sourceRoot":"","sources":["../../src/lib/touch-hover.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAA;AAOvD,KAAK,kBAAkB,GAAG,IAAI,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,CAAC,CAAA;AA2EpF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAE,kBAA6B,GAAG,MAAM,IAAI,CA0B7F;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAG7D"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* ON A TOUCH SCREEN, ONE TAP DOES WHAT HOVER DOES (ui#559, Asaf, 2026-11-22).
|
|
5
|
+
*
|
|
6
|
+
* A phone has no hover, so a piece that shows its actions on hover hides them
|
|
7
|
+
* from a touch reader. For the pieces that ask (a scope: the Home card, a
|
|
8
|
+
* pinned item), this makes the first tap show the hover state and a second tap
|
|
9
|
+
* open, as one tap did before:
|
|
10
|
+
*
|
|
11
|
+
* 1 the first tap on a scope writes `data-touch-hover` on it and goes no
|
|
12
|
+
* further: the link under it does not follow, no handler hears it
|
|
13
|
+
* 2 a tap on a scope that already has it is the tap's own: the door opens,
|
|
14
|
+
* a button presses
|
|
15
|
+
* 3 so a button works on its first tap once it shows, and never on the tap
|
|
16
|
+
* that showed it (it was inert while hidden, and that tap is swallowed
|
|
17
|
+
* wherever in the scope it landed)
|
|
18
|
+
* 4 one at a time: a press anywhere outside the scope clears it (a press on
|
|
19
|
+
* another scope, then, moves it), and so does a scroll, of a rail or of
|
|
20
|
+
* the page. A press or a scroll inside an open menu is not outside: the
|
|
21
|
+
* menu is the scope's, portalled away from it
|
|
22
|
+
* 5 touch is the press's `pointerType`, per tap: never the screen's width or
|
|
23
|
+
* `(hover: none)`. A mouse or a pen (which hovers) and the keyboard (a
|
|
24
|
+
* click with no press before it, `detail` 0) behave exactly as before
|
|
25
|
+
* 6 only a real finger reveals: a touch press with a contact size (`width`
|
|
26
|
+
* and `height` above 0), at the scope its click lands on. A screen
|
|
27
|
+
* reader's double-tap (VoiceOver, TalkBack) can arrive as a synthesized
|
|
28
|
+
* touch press of size 0, or as a click with no press before it; either
|
|
29
|
+
* activates at once, as before, so its first activation is never
|
|
30
|
+
* swallowed (Nataly's review on PR #562). Not yet checked on a device
|
|
31
|
+
*
|
|
32
|
+
* It moves no focus and adds no element, role or name: a screen reader hears
|
|
33
|
+
* what it heard. The look is the scope's own CSS: every `group-hover/<g>:`
|
|
34
|
+
* class has a `group-data-[touch-hover]/<g>:` twin beside it, so the tapped
|
|
35
|
+
* look is the hover look, eased by the same transition and stilled by the same
|
|
36
|
+
* reduced-motion rule.
|
|
37
|
+
*
|
|
38
|
+
* One listener set per document, in the capture phase (so a handler that
|
|
39
|
+
* stops propagation cannot hide a tap, and a swallowed tap reaches nothing),
|
|
40
|
+
* shared by every scope and counted, as `trackInputModality` is. The attribute
|
|
41
|
+
* is written on the element, not through React state: nothing re-renders, and
|
|
42
|
+
* the pieces that ask stay server components (`<TouchHover />` renders
|
|
43
|
+
* nothing).
|
|
44
|
+
*/
|
|
45
|
+
export const TOUCH_HOVER_ATTRIBUTE = "data-touch-hover";
|
|
46
|
+
/** Inside an open menu is not outside the scope that opened it. */
|
|
47
|
+
const MENU = '[role="menu"]';
|
|
48
|
+
const trackers = new WeakMap();
|
|
49
|
+
/** The nearest ancestor (or self) matching `selector`, if the target is an element at all. */
|
|
50
|
+
function closest(target, selector) {
|
|
51
|
+
const el = target;
|
|
52
|
+
return el && typeof el.closest === "function" ? el.closest(selector) : null;
|
|
53
|
+
}
|
|
54
|
+
function attach(doc, tracker) {
|
|
55
|
+
// The last press, if it was a finger's, and where it landed, until its click
|
|
56
|
+
// reads it. Cleared by every click and by a cancelled press, so a later
|
|
57
|
+
// keyboard or synthesized click never inherits it.
|
|
58
|
+
let finger = null;
|
|
59
|
+
const clear = () => {
|
|
60
|
+
tracker.current?.removeAttribute(TOUCH_HOVER_ATTRIBUTE);
|
|
61
|
+
tracker.current = null;
|
|
62
|
+
};
|
|
63
|
+
const selector = () => [...tracker.scopes.keys()].join(",");
|
|
64
|
+
const outside = (target) => tracker.current !== null && !tracker.current.contains(target) && closest(target, MENU) === null;
|
|
65
|
+
const onPointerDown = (event) => {
|
|
66
|
+
const e = event;
|
|
67
|
+
// A finger has a contact size. A screen reader's double-tap (VoiceOver,
|
|
68
|
+
// TalkBack) can arrive as a synthesized touch press of size 0: that is not
|
|
69
|
+
// a tap to reveal on, so it activates as it always did.
|
|
70
|
+
finger = e.pointerType === "touch" && e.width > 0 && e.height > 0 ? event.target : null;
|
|
71
|
+
if (outside(event.target))
|
|
72
|
+
clear();
|
|
73
|
+
};
|
|
74
|
+
const onPointerCancel = () => {
|
|
75
|
+
finger = null;
|
|
76
|
+
};
|
|
77
|
+
const onClick = (event) => {
|
|
78
|
+
const pressed = finger;
|
|
79
|
+
finger = null;
|
|
80
|
+
if (pressed === null || event.detail === 0)
|
|
81
|
+
return;
|
|
82
|
+
const scope = closest(event.target, selector());
|
|
83
|
+
if (!scope)
|
|
84
|
+
return;
|
|
85
|
+
// The finger's press must be at this scope: a click with no press of its
|
|
86
|
+
// own there (synthesized, or after a press elsewhere) activates at once.
|
|
87
|
+
if (!scope.contains(pressed))
|
|
88
|
+
return;
|
|
89
|
+
if (tracker.current === scope)
|
|
90
|
+
return;
|
|
91
|
+
clear();
|
|
92
|
+
scope.setAttribute(TOUCH_HOVER_ATTRIBUTE, "");
|
|
93
|
+
tracker.current = scope;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
};
|
|
97
|
+
const onScroll = (event) => {
|
|
98
|
+
if (closest(event.target, MENU) === null)
|
|
99
|
+
clear();
|
|
100
|
+
};
|
|
101
|
+
// An options object rather than `true`: Node's EventTarget does not match a
|
|
102
|
+
// boolean capture flag on removal, and the tests run there. Scroll does not
|
|
103
|
+
// bubble, so the capture phase is also the only way to hear a rail's.
|
|
104
|
+
const capture = { capture: true };
|
|
105
|
+
const passive = { capture: true, passive: true };
|
|
106
|
+
doc.addEventListener("pointerdown", onPointerDown, passive);
|
|
107
|
+
doc.addEventListener("pointercancel", onPointerCancel, passive);
|
|
108
|
+
doc.addEventListener("click", onClick, capture);
|
|
109
|
+
doc.addEventListener("scroll", onScroll, passive);
|
|
110
|
+
return () => {
|
|
111
|
+
doc.removeEventListener("pointerdown", onPointerDown, passive);
|
|
112
|
+
doc.removeEventListener("pointercancel", onPointerCancel, passive);
|
|
113
|
+
doc.removeEventListener("click", onClick, capture);
|
|
114
|
+
doc.removeEventListener("scroll", onScroll, passive);
|
|
115
|
+
clear();
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Make the first touch tap on any element matching `scope` show its hover
|
|
120
|
+
* state (`data-touch-hover`), and the second open. Returns a function that
|
|
121
|
+
* stops this start. `<TouchHover scope=… />` is this in an effect.
|
|
122
|
+
*
|
|
123
|
+
* Counted per document and per scope: the first start attaches the listeners,
|
|
124
|
+
* the last stop removes them and clears the state; a stop released twice
|
|
125
|
+
* counts once.
|
|
126
|
+
*/
|
|
127
|
+
export function trackTouchHover(scope, doc = document) {
|
|
128
|
+
let tracker = trackers.get(doc);
|
|
129
|
+
if (!tracker) {
|
|
130
|
+
const t = { scopes: new Map(), current: null, detach: () => { } };
|
|
131
|
+
t.detach = attach(doc, t);
|
|
132
|
+
trackers.set(doc, t);
|
|
133
|
+
tracker = t;
|
|
134
|
+
}
|
|
135
|
+
tracker.scopes.set(scope, (tracker.scopes.get(scope) ?? 0) + 1);
|
|
136
|
+
let released = false;
|
|
137
|
+
return () => {
|
|
138
|
+
if (released)
|
|
139
|
+
return;
|
|
140
|
+
released = true;
|
|
141
|
+
const t = trackers.get(doc);
|
|
142
|
+
if (!t)
|
|
143
|
+
return;
|
|
144
|
+
const n = (t.scopes.get(scope) ?? 1) - 1;
|
|
145
|
+
if (n > 0) {
|
|
146
|
+
t.scopes.set(scope, n);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
t.scopes.delete(scope);
|
|
150
|
+
if (t.scopes.size > 0)
|
|
151
|
+
return;
|
|
152
|
+
trackers.delete(doc);
|
|
153
|
+
t.detach();
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Turns the touch rule on for `scope` while it is mounted. Renders nothing, so
|
|
158
|
+
* a server component can carry it: the Home card and Pinned do.
|
|
159
|
+
*/
|
|
160
|
+
export function TouchHover({ scope }) {
|
|
161
|
+
React.useEffect(() => trackTouchHover(scope), [scope]);
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=touch-hover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"touch-hover.js","sourceRoot":"","sources":["../../src/lib/touch-hover.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,KAAK,KAA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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudgrid-io/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.0",
|
|
4
4
|
"description": "CloudGrid design system: React components, brand design tokens, Tailwind theme, self-hosted fonts.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"react-dom": "19.3.1",
|
|
115
115
|
"react-is": "19.3.1",
|
|
116
116
|
"typescript": "^5.9.3",
|
|
117
|
-
"typescript-eslint": "^8.
|
|
117
|
+
"typescript-eslint": "^8.73.0"
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"build": "node scripts/build.mjs && tsc -p tsconfig.build.json && node scripts/rewrite-aliases.mjs",
|