@cloudgrid-io/ui 0.74.0 → 0.76.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 +4 -0
- package/dist/badge/css-base.js +1 -1
- package/dist/blocks/alert-row.d.ts +185 -0
- package/dist/blocks/alert-row.d.ts.map +1 -0
- package/dist/blocks/alert-row.js +332 -0
- package/dist/blocks/alert-row.js.map +1 -0
- package/dist/blocks/avatar-picker.d.ts +8 -1
- package/dist/blocks/avatar-picker.d.ts.map +1 -1
- package/dist/blocks/avatar-picker.js +8 -5
- package/dist/blocks/avatar-picker.js.map +1 -1
- package/dist/blocks/disabled-button.js +1 -1
- package/dist/blocks/disabled-button.js.map +1 -1
- package/dist/blocks/drop-zone.js +1 -1
- package/dist/blocks/drop-zone.js.map +1 -1
- package/dist/blocks/empty-creations.d.ts +2 -1
- package/dist/blocks/empty-creations.d.ts.map +1 -1
- package/dist/blocks/empty-creations.js +3 -2
- package/dist/blocks/empty-creations.js.map +1 -1
- package/dist/blocks/empty-state.js +1 -1
- package/dist/blocks/empty-state.js.map +1 -1
- package/dist/blocks/entity-card.d.ts.map +1 -1
- package/dist/blocks/entity-card.js +4 -3
- package/dist/blocks/entity-card.js.map +1 -1
- package/dist/blocks/feed-row.d.ts +16 -4
- package/dist/blocks/feed-row.d.ts.map +1 -1
- package/dist/blocks/feed-row.js +6 -3
- package/dist/blocks/feed-row.js.map +1 -1
- package/dist/blocks/from-your-grid.d.ts +10 -2
- package/dist/blocks/from-your-grid.d.ts.map +1 -1
- package/dist/blocks/from-your-grid.js +5 -3
- package/dist/blocks/from-your-grid.js.map +1 -1
- package/dist/blocks/grid-profile.d.ts +8 -1
- package/dist/blocks/grid-profile.d.ts.map +1 -1
- package/dist/blocks/grid-profile.js +8 -5
- package/dist/blocks/grid-profile.js.map +1 -1
- package/dist/blocks/home-pinned.d.ts +7 -1
- package/dist/blocks/home-pinned.d.ts.map +1 -1
- package/dist/blocks/home-pinned.js +2 -2
- package/dist/blocks/home-pinned.js.map +1 -1
- package/dist/blocks/icons.d.ts +6 -2
- package/dist/blocks/icons.d.ts.map +1 -1
- package/dist/blocks/icons.js +6 -2
- package/dist/blocks/icons.js.map +1 -1
- package/dist/blocks/image-adjust-dialog.d.ts +22 -2
- package/dist/blocks/image-adjust-dialog.d.ts.map +1 -1
- package/dist/blocks/image-adjust-dialog.js +60 -1
- package/dist/blocks/image-adjust-dialog.js.map +1 -1
- package/dist/blocks/inspiration-cards.d.ts +3 -1
- package/dist/blocks/inspiration-cards.d.ts.map +1 -1
- package/dist/blocks/inspiration-cards.js +1 -1
- package/dist/blocks/inspiration-cards.js.map +1 -1
- package/dist/blocks/locked-section.js +1 -1
- package/dist/blocks/locked-section.js.map +1 -1
- package/dist/blocks/needs-attention.d.ts +49 -10
- package/dist/blocks/needs-attention.d.ts.map +1 -1
- package/dist/blocks/needs-attention.js +26 -7
- package/dist/blocks/needs-attention.js.map +1 -1
- package/dist/blocks/notification-row.d.ts +59 -32
- package/dist/blocks/notification-row.d.ts.map +1 -1
- package/dist/blocks/notification-row.js +34 -13
- package/dist/blocks/notification-row.js.map +1 -1
- package/dist/blocks/phosphor-marks.d.ts +3 -1
- package/dist/blocks/phosphor-marks.d.ts.map +1 -1
- package/dist/blocks/phosphor-marks.js +4 -1
- package/dist/blocks/phosphor-marks.js.map +1 -1
- package/dist/blocks/recent-plugs.d.ts +14 -2
- package/dist/blocks/recent-plugs.d.ts.map +1 -1
- package/dist/blocks/recent-plugs.js +12 -3
- package/dist/blocks/recent-plugs.js.map +1 -1
- package/dist/blocks/request-card.js +1 -1
- package/dist/blocks/request-card.js.map +1 -1
- package/dist/blocks/segmented-choice.js +1 -1
- package/dist/blocks/segmented-choice.js.map +1 -1
- package/dist/blocks/stepper.d.ts +49 -0
- package/dist/blocks/stepper.d.ts.map +1 -0
- package/dist/blocks/stepper.js +19 -0
- package/dist/blocks/stepper.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/touch-hover.d.ts +11 -5
- package/dist/lib/touch-hover.d.ts.map +1 -1
- package/dist/lib/touch-hover.js +23 -18
- package/dist/lib/touch-hover.js.map +1 -1
- package/dist/theme.css +116 -0
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.d.ts.map +1 -1
- package/dist/ui/button.js +78 -3
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/combobox.js +2 -2
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/dropdown-menu.js +4 -4
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/radio-group.d.ts +3 -1
- package/dist/ui/radio-group.d.ts.map +1 -1
- package/dist/ui/radio-group.js +23 -5
- package/dist/ui/radio-group.js.map +1 -1
- package/dist/ui/select.js +3 -3
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/switch.js +1 -1
- package/dist/ui/switch.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,10 @@ The order matters, and getting it wrong fails quietly rather than loudly.
|
|
|
65
65
|
tokens they change.
|
|
66
66
|
- `shadcn.css` must come after whatever `:root` your own `shadcn init` wrote, because it
|
|
67
67
|
overrides those values. Put it earlier and the stock grey palette wins.
|
|
68
|
+
- The overlays' enter and exit animations (Drawer, Dialog, Popover, the menus, Select,
|
|
69
|
+
Combobox, Tooltip) come with `theme.css`: it ships `tw-animate-css`'s utilities, so there
|
|
70
|
+
is nothing else to import (#518). An app that already imports `tw-animate-css` can keep or
|
|
71
|
+
drop that line; both build and animate.
|
|
68
72
|
|
|
69
73
|
Not using the Console's face: skip the `console.css` line. Not using shadcn: skip the last line. Not using Tailwind: `tokens.css` alone gives you every
|
|
70
74
|
value as a custom property.
|
package/dist/badge/css-base.js
CHANGED
|
@@ -121,7 +121,7 @@ export const BADGE_BASE_CSS = /* @__PURE__ */ (() => `.cgb{all:initial;${BADGE_T
|
|
|
121
121
|
.cgb-sel-trigger:focus-visible{outline:none;border-color:var(--cg-text-accent);box-shadow:0 0 0 3px var(--cg-focus-ring)}
|
|
122
122
|
.cgb-menu{position:absolute;right:0;z-index:2;min-width:144px;padding:4px;border-radius:var(--cg-radius-lg);background:var(--cg-surface-card);` +
|
|
123
123
|
`box-shadow:var(--cg-shadow-card),0 0 0 1px color-mix(in srgb,var(--cg-text-primary) 10%,transparent)}
|
|
124
|
-
.cgb-menu-item{position:relative;display:flex;align-items:center;width:100%;height:30px;padding:0 32px 0 6px;border-radius:var(--cg-radius-md);font-size:var(--cg-body-sm);white-space:nowrap;cursor:
|
|
124
|
+
.cgb-menu-item{position:relative;display:flex;align-items:center;width:100%;height:30px;padding:0 32px 0 6px;border-radius:var(--cg-radius-md);font-size:var(--cg-body-sm);white-space:nowrap;cursor:pointer}
|
|
125
125
|
.cgb-menu-item:hover,.cgb-menu-item:focus{background:var(--cg-surface-subtle);outline:none}
|
|
126
126
|
.cgb-menu-item svg{position:absolute;right:8px;width:16px;height:16px;visibility:hidden}
|
|
127
127
|
.cgb-menu-item[aria-selected=true] svg{visibility:visible}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* THE ALERT ROW (ui#662, Asaf, 2026-11-30, option A): one row for the bell
|
|
4
|
+
* (`NotificationRow`) and for the Home's Needs attention (`NeedsAttention`).
|
|
5
|
+
* The two differ in what holds them (a Base UI menu, a list), so each block
|
|
6
|
+
* builds its own elements; what they share, the look and the Undo countdown,
|
|
7
|
+
* is here, once.
|
|
8
|
+
*
|
|
9
|
+
* ```
|
|
10
|
+
* [tile] Creator Impact Page Ideas expires Keep it (x)
|
|
11
|
+
* in 5 days
|
|
12
|
+
* No visits in 25 days · ACLabz
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* ## The row opens
|
|
16
|
+
*
|
|
17
|
+
* With `href` or `onOpen` the whole row is one door: an empty link or button
|
|
18
|
+
* stretched over the row (`ALERT_ROW_OPEN_CLASS`), named by the row's title.
|
|
19
|
+
* It is the row's hit area, carries the hand cursor, and draws the focus line
|
|
20
|
+
* (`focus-line`) around the whole row on Tab only. On hover the row takes the
|
|
21
|
+
* soft grey (`--cg-hover`) at radius 12 (`rounded-md`) and no frame, the
|
|
22
|
+
* hover Recent plugs and the feed rows use (ui#663), so the rows match across
|
|
23
|
+
* the Home and the bell. The row's own padding holds the grey, so nothing
|
|
24
|
+
* moves when it shows. The action and the x sit above the
|
|
25
|
+
* layer (`ALERT_ROW_CONTROLS_CLASS`, positioned), so they are their own
|
|
26
|
+
* controls and pressing them never opens the row; nothing interactive is
|
|
27
|
+
* nested in another. A row with neither does not pretend: no layer, no hand,
|
|
28
|
+
* no grey.
|
|
29
|
+
*
|
|
30
|
+
* ## The action
|
|
31
|
+
*
|
|
32
|
+
* "Keep it" is the Home's teal action link (`ACTION_LINK_CLASS`, bold), the
|
|
33
|
+
* hand on it; disabled, the arrow.
|
|
34
|
+
*
|
|
35
|
+
* ## Ignore
|
|
36
|
+
*
|
|
37
|
+
* With `onDismiss` a small x ends the row: a 28 square in the hover wash with
|
|
38
|
+
* the 14px `CloseIcon`. Shown while the pointer is over the row or focus is
|
|
39
|
+
* inside it, and always where there is no hover (`(hover: none)`, a phone).
|
|
40
|
+
* As it appears it fades in and turns 90 degrees on the Add tile's spring
|
|
41
|
+
* (`ALERT_ROW_TURN`, `add-tile.tsx`); under reduced motion it simply appears.
|
|
42
|
+
* Its name is "Ignore" and the title ("Ignore CRM Sync" in the bell), and its
|
|
43
|
+
* tooltip says "Ignore".
|
|
44
|
+
*
|
|
45
|
+
* ## Undo, in place (Asaf, 2026-11-30, option A)
|
|
46
|
+
*
|
|
47
|
+
* The caller marks the row `dismissed` when the x is pressed. The row turns
|
|
48
|
+
* into one quiet line on the soft grey, "Ignored **<name>**", with "Undo" as
|
|
49
|
+
* the teal action link at its end, and under it a thin line in the action
|
|
50
|
+
* link's teal on a light teal track runs down for five seconds
|
|
51
|
+
* (`ALERT_ROW_UNDO_MS`). Then the row folds away and `onDismissEnd` is called,
|
|
52
|
+
* so the caller can drop it. Undo (`onUndo`) brings it back as it was.
|
|
53
|
+
*
|
|
54
|
+
* - The countdown pauses while the pointer is over the row, or while keyboard
|
|
55
|
+
* focus is inside it. Focus the library moved there itself after a click
|
|
56
|
+
* does not hold it, or a mouse reader who pressed the x and moved on would
|
|
57
|
+
* wait forever.
|
|
58
|
+
* - Focus moves to Undo when the row turns; when the row leaves, to the next
|
|
59
|
+
* row (or the one before, or the list) if focus was inside it. Undo puts it
|
|
60
|
+
* back on the row. Undo is described by its line, so a screen reader hears
|
|
61
|
+
* "Undo, Ignored CRM Sync".
|
|
62
|
+
* - Under reduced motion the line does not run down and the row does not
|
|
63
|
+
* fold: it stays as it is for the five seconds, then leaves.
|
|
64
|
+
*
|
|
65
|
+
* The timing is the page's clock (`setTimeout`, `requestAnimationFrame`,
|
|
66
|
+
* `performance.now`), not a CSS animation, so a test steps it on a fake clock.
|
|
67
|
+
*
|
|
68
|
+
* Whether the alert is really ignored is the caller's: commit it on
|
|
69
|
+
* `onDismiss` and reverse it on `onUndo`, or commit it on `onDismissEnd`.
|
|
70
|
+
*/
|
|
71
|
+
/** The words the row says. */
|
|
72
|
+
export declare const ALERT_ROW_COPY: {
|
|
73
|
+
readonly ignore: "Ignore";
|
|
74
|
+
readonly ignored: "Ignored";
|
|
75
|
+
readonly undo: "Undo";
|
|
76
|
+
};
|
|
77
|
+
/** How long Undo stays, in milliseconds. */
|
|
78
|
+
export declare const ALERT_ROW_UNDO_MS = 5000;
|
|
79
|
+
/**
|
|
80
|
+
* A leading picture for the row: a glyph in the soft tile, or a person, drawn
|
|
81
|
+
* by the library `Avatar` at 32 (their initials, or their picture with `src`).
|
|
82
|
+
*/
|
|
83
|
+
export type AlertRowMedia = {
|
|
84
|
+
glyph: React.ReactNode;
|
|
85
|
+
} | {
|
|
86
|
+
name: string;
|
|
87
|
+
seed?: string;
|
|
88
|
+
src?: string;
|
|
89
|
+
};
|
|
90
|
+
/** The row: the hover group, positioned so the open layer can stretch over it. */
|
|
91
|
+
export declare const ALERT_ROW_CLASS = "group/alert relative flex gap-3 rounded-md px-3";
|
|
92
|
+
/** Only on a row that opens: the soft grey on hover, no frame. */
|
|
93
|
+
export declare const ALERT_ROW_OPENS_CLASS = "transition-colors duration-(--cg-duration) ease-out motion-reduce:transition-none hover:bg-(--cg-hover)";
|
|
94
|
+
/** The open layer: the whole row's hit area, the hand, the focus line on Tab only. */
|
|
95
|
+
export declare const ALERT_ROW_OPEN_CLASS = "absolute inset-0 cursor-pointer rounded-md no-underline select-none focus-line";
|
|
96
|
+
/** The words' column. */
|
|
97
|
+
export declare const ALERT_ROW_WORDS_CLASS = "grid min-w-0 flex-1 gap-0.75";
|
|
98
|
+
/** The title: wraps, never cut. */
|
|
99
|
+
export declare const ALERT_ROW_TITLE_CLASS = "m-0 text-body-sm text-ink";
|
|
100
|
+
/** The second line: the caption role, muted. */
|
|
101
|
+
export declare const ALERT_ROW_DETAIL_CLASS = "m-0 text-caption";
|
|
102
|
+
/** The action and the x: above the open layer. */
|
|
103
|
+
export declare const ALERT_ROW_CONTROLS_CLASS = "relative flex shrink-0 items-center gap-2";
|
|
104
|
+
/** "Keep it" and "Undo": the Home's teal action link, bold, the hand; disabled, the arrow. */
|
|
105
|
+
export declare const ALERT_ROW_ACTION_CLASS: string;
|
|
106
|
+
/**
|
|
107
|
+
* The x. Hidden until the row is hovered or holds focus, always shown where
|
|
108
|
+
* there is no hover. At rest it takes no room (width 0, its gap taken back),
|
|
109
|
+
* so the action sits at the row's end, as the sketch draws it; as it appears
|
|
110
|
+
* it opens to 28 and fades in at the library's duration, the action easing
|
|
111
|
+
* left to make room. Under reduced motion it is simply there.
|
|
112
|
+
*/
|
|
113
|
+
export declare const ALERT_ROW_DISMISS_CLASS: string;
|
|
114
|
+
/**
|
|
115
|
+
* The x turns 90 degrees as it appears, on the pin's and the Add tile's
|
|
116
|
+
* spring (`--cg-ease-spring`, 220ms). Under reduced motion it does not turn.
|
|
117
|
+
*/
|
|
118
|
+
export declare const ALERT_ROW_TURN = "inline-flex transition-[rotate] duration-220 ease-(--cg-ease-spring) motion-reduce:transition-none motion-safe:group-hover/alert:rotate-90 motion-safe:group-focus-within/alert:rotate-90";
|
|
119
|
+
/** The soft tile a glyph sits in: 32 at radius 8, the page grey (the wash on the panel and ink). */
|
|
120
|
+
export declare const ALERT_ROW_TILE_CLASS = "inline-flex size-8 shrink-0 items-center justify-center rounded-xs bg-page text-ink in-data-[cg-surface=panel]:bg-(--cg-hover) in-data-[cg-surface=ink]:bg-(--cg-hover) [&_svg]:size-4.5";
|
|
121
|
+
/** The turned row's line: one quiet line on the soft grey. */
|
|
122
|
+
export declare const ALERT_ROW_IGNORED_CLASS = "flex min-h-11 items-center gap-3 rounded-md bg-(--cg-hover) px-3 py-2";
|
|
123
|
+
/** The countdown's track: light teal, never grey. */
|
|
124
|
+
export declare const ALERT_ROW_COUNTDOWN_CLASS = "mx-3 mt-1.5 h-0.75 overflow-hidden rounded-pill bg-cyan-tint";
|
|
125
|
+
/** The countdown's fill: the action link's teal, running down from the right. */
|
|
126
|
+
export declare const ALERT_ROW_COUNTDOWN_FILL_CLASS = "block h-full w-full origin-left rounded-pill bg-cyan-dark";
|
|
127
|
+
/**
|
|
128
|
+
* On a row that starts at its top (a row with a help line, ui#563), the
|
|
129
|
+
* picture centres on the title's first line: half of (one line minus 32) above.
|
|
130
|
+
*/
|
|
131
|
+
export declare const ALERT_ROW_MEDIA_ON_FIRST_LINE = "text-body-sm mt-[calc((1lh-2rem)/2)]";
|
|
132
|
+
/** The leading picture: a glyph in the soft tile, or a person at 32. */
|
|
133
|
+
declare function AlertRowMediaSlot({ media, slot, className }: {
|
|
134
|
+
media: AlertRowMedia;
|
|
135
|
+
slot: string;
|
|
136
|
+
className?: string;
|
|
137
|
+
}): React.JSX.Element;
|
|
138
|
+
/** The x's glyph, which turns. */
|
|
139
|
+
declare function AlertRowDismissGlyph({ slot }: {
|
|
140
|
+
slot: string;
|
|
141
|
+
}): React.JSX.Element;
|
|
142
|
+
/** The rows, and the list or menu that holds them, mark themselves for the focus move. */
|
|
143
|
+
export declare const ALERT_ROW_ATTRIBUTE = "data-alert-row";
|
|
144
|
+
declare const FOCUS_ATTRIBUTE = "data-alert-focus";
|
|
145
|
+
/**
|
|
146
|
+
* The Undo countdown, shared by both rows. Pass the row's state; spread
|
|
147
|
+
* `rowProps` on the row's outer element, put `fillRef` on the countdown's fill
|
|
148
|
+
* and `undoRef` on Undo, and call `undo` from Undo's press.
|
|
149
|
+
*/
|
|
150
|
+
export declare function useAlertRowCountdown({ dismissed, onUndo, onDismissEnd, }: {
|
|
151
|
+
dismissed: boolean;
|
|
152
|
+
onUndo?: () => void;
|
|
153
|
+
onDismissEnd?: () => void;
|
|
154
|
+
}): {
|
|
155
|
+
rowProps: {
|
|
156
|
+
ref: React.RefObject<(HTMLDivElement & HTMLLIElement) | null>;
|
|
157
|
+
"data-alert-row": string;
|
|
158
|
+
onPointerEnter: (e: React.PointerEvent) => void;
|
|
159
|
+
onPointerLeave: () => void;
|
|
160
|
+
onFocus: (e: React.FocusEvent) => void;
|
|
161
|
+
onBlur: (e: React.FocusEvent) => void;
|
|
162
|
+
};
|
|
163
|
+
fillRef: React.RefObject<HTMLSpanElement | null>;
|
|
164
|
+
undoRef: React.RefObject<HTMLElement | null>;
|
|
165
|
+
undo: () => void;
|
|
166
|
+
folding: boolean;
|
|
167
|
+
};
|
|
168
|
+
/** The fold around a turned row: open, then folded to nothing. */
|
|
169
|
+
declare function AlertRowFold({ folding, children }: {
|
|
170
|
+
folding: boolean;
|
|
171
|
+
children: React.ReactNode;
|
|
172
|
+
}): React.JSX.Element;
|
|
173
|
+
/** The countdown line under a turned row. */
|
|
174
|
+
declare function AlertRowCountdown({ slot, fillRef }: {
|
|
175
|
+
slot: string;
|
|
176
|
+
fillRef: React.Ref<HTMLSpanElement>;
|
|
177
|
+
}): React.JSX.Element;
|
|
178
|
+
/** "Ignored <name>": the name in semibold. */
|
|
179
|
+
declare function AlertRowIgnoredText({ id, slot, name }: {
|
|
180
|
+
id: string;
|
|
181
|
+
slot: string;
|
|
182
|
+
name: React.ReactNode;
|
|
183
|
+
}): React.JSX.Element;
|
|
184
|
+
export { AlertRowCountdown, AlertRowDismissGlyph, AlertRowFold, AlertRowIgnoredText, AlertRowMediaSlot, FOCUS_ATTRIBUTE as ALERT_ROW_FOCUS_ATTRIBUTE, };
|
|
185
|
+
//# sourceMappingURL=alert-row.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-row.d.ts","sourceRoot":"","sources":["../../src/blocks/alert-row.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,8BAA8B;AAC9B,eAAO,MAAM,cAAc;;;;CAIjB,CAAA;AAEV,4CAA4C;AAC5C,eAAO,MAAM,iBAAiB,OAAO,CAAA;AAKrC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtG,kFAAkF;AAClF,eAAO,MAAM,eAAe,oDAAoD,CAAA;AAEhF,kEAAkE;AAClE,eAAO,MAAM,qBAAqB,4GACyE,CAAA;AAE3G,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,mFAAmF,CAAA;AAEpH,yBAAyB;AACzB,eAAO,MAAM,qBAAqB,iCAAiC,CAAA;AAEnE,mCAAmC;AACnC,eAAO,MAAM,qB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KAAK,CAAC,UAAU;oBAIjB,KAAK,CAAC,UAAU;;;;;;EAa/B;AAED,kEAAkE;AAClE,iBAAS,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAM3F;AAED,6CAA6C;AAC7C,iBAAS,iBAAiB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;CAAE,qBAMlG;AAED,8CAA8C;AAC9C,iBAAS,mBAAmB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAMnG;AAED,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,IAAI,yBAAyB,GAC7C,CAAA"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../lib/cloudgrid-cn.js";
|
|
5
|
+
import { ACTION_LINK_CLASS } from "./action-link.js";
|
|
6
|
+
import { Avatar } from "./avatar.js";
|
|
7
|
+
import { CloseIcon } from "./icons.js";
|
|
8
|
+
/**
|
|
9
|
+
* THE ALERT ROW (ui#662, Asaf, 2026-11-30, option A): one row for the bell
|
|
10
|
+
* (`NotificationRow`) and for the Home's Needs attention (`NeedsAttention`).
|
|
11
|
+
* The two differ in what holds them (a Base UI menu, a list), so each block
|
|
12
|
+
* builds its own elements; what they share, the look and the Undo countdown,
|
|
13
|
+
* is here, once.
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* [tile] Creator Impact Page Ideas expires Keep it (x)
|
|
17
|
+
* in 5 days
|
|
18
|
+
* No visits in 25 days · ACLabz
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## The row opens
|
|
22
|
+
*
|
|
23
|
+
* With `href` or `onOpen` the whole row is one door: an empty link or button
|
|
24
|
+
* stretched over the row (`ALERT_ROW_OPEN_CLASS`), named by the row's title.
|
|
25
|
+
* It is the row's hit area, carries the hand cursor, and draws the focus line
|
|
26
|
+
* (`focus-line`) around the whole row on Tab only. On hover the row takes the
|
|
27
|
+
* soft grey (`--cg-hover`) at radius 12 (`rounded-md`) and no frame, the
|
|
28
|
+
* hover Recent plugs and the feed rows use (ui#663), so the rows match across
|
|
29
|
+
* the Home and the bell. The row's own padding holds the grey, so nothing
|
|
30
|
+
* moves when it shows. The action and the x sit above the
|
|
31
|
+
* layer (`ALERT_ROW_CONTROLS_CLASS`, positioned), so they are their own
|
|
32
|
+
* controls and pressing them never opens the row; nothing interactive is
|
|
33
|
+
* nested in another. A row with neither does not pretend: no layer, no hand,
|
|
34
|
+
* no grey.
|
|
35
|
+
*
|
|
36
|
+
* ## The action
|
|
37
|
+
*
|
|
38
|
+
* "Keep it" is the Home's teal action link (`ACTION_LINK_CLASS`, bold), the
|
|
39
|
+
* hand on it; disabled, the arrow.
|
|
40
|
+
*
|
|
41
|
+
* ## Ignore
|
|
42
|
+
*
|
|
43
|
+
* With `onDismiss` a small x ends the row: a 28 square in the hover wash with
|
|
44
|
+
* the 14px `CloseIcon`. Shown while the pointer is over the row or focus is
|
|
45
|
+
* inside it, and always where there is no hover (`(hover: none)`, a phone).
|
|
46
|
+
* As it appears it fades in and turns 90 degrees on the Add tile's spring
|
|
47
|
+
* (`ALERT_ROW_TURN`, `add-tile.tsx`); under reduced motion it simply appears.
|
|
48
|
+
* Its name is "Ignore" and the title ("Ignore CRM Sync" in the bell), and its
|
|
49
|
+
* tooltip says "Ignore".
|
|
50
|
+
*
|
|
51
|
+
* ## Undo, in place (Asaf, 2026-11-30, option A)
|
|
52
|
+
*
|
|
53
|
+
* The caller marks the row `dismissed` when the x is pressed. The row turns
|
|
54
|
+
* into one quiet line on the soft grey, "Ignored **<name>**", with "Undo" as
|
|
55
|
+
* the teal action link at its end, and under it a thin line in the action
|
|
56
|
+
* link's teal on a light teal track runs down for five seconds
|
|
57
|
+
* (`ALERT_ROW_UNDO_MS`). Then the row folds away and `onDismissEnd` is called,
|
|
58
|
+
* so the caller can drop it. Undo (`onUndo`) brings it back as it was.
|
|
59
|
+
*
|
|
60
|
+
* - The countdown pauses while the pointer is over the row, or while keyboard
|
|
61
|
+
* focus is inside it. Focus the library moved there itself after a click
|
|
62
|
+
* does not hold it, or a mouse reader who pressed the x and moved on would
|
|
63
|
+
* wait forever.
|
|
64
|
+
* - Focus moves to Undo when the row turns; when the row leaves, to the next
|
|
65
|
+
* row (or the one before, or the list) if focus was inside it. Undo puts it
|
|
66
|
+
* back on the row. Undo is described by its line, so a screen reader hears
|
|
67
|
+
* "Undo, Ignored CRM Sync".
|
|
68
|
+
* - Under reduced motion the line does not run down and the row does not
|
|
69
|
+
* fold: it stays as it is for the five seconds, then leaves.
|
|
70
|
+
*
|
|
71
|
+
* The timing is the page's clock (`setTimeout`, `requestAnimationFrame`,
|
|
72
|
+
* `performance.now`), not a CSS animation, so a test steps it on a fake clock.
|
|
73
|
+
*
|
|
74
|
+
* Whether the alert is really ignored is the caller's: commit it on
|
|
75
|
+
* `onDismiss` and reverse it on `onUndo`, or commit it on `onDismissEnd`.
|
|
76
|
+
*/
|
|
77
|
+
/** The words the row says. */
|
|
78
|
+
export const ALERT_ROW_COPY = {
|
|
79
|
+
ignore: "Ignore",
|
|
80
|
+
ignored: "Ignored",
|
|
81
|
+
undo: "Undo",
|
|
82
|
+
};
|
|
83
|
+
/** How long Undo stays, in milliseconds. */
|
|
84
|
+
export const ALERT_ROW_UNDO_MS = 5000;
|
|
85
|
+
/** The fold, `--cg-duration`. */
|
|
86
|
+
const FOLD_MS = 180;
|
|
87
|
+
/** The row: the hover group, positioned so the open layer can stretch over it. */
|
|
88
|
+
export const ALERT_ROW_CLASS = "group/alert relative flex gap-3 rounded-md px-3";
|
|
89
|
+
/** Only on a row that opens: the soft grey on hover, no frame. */
|
|
90
|
+
export const ALERT_ROW_OPENS_CLASS = "transition-colors duration-(--cg-duration) ease-out motion-reduce:transition-none hover:bg-(--cg-hover)";
|
|
91
|
+
/** The open layer: the whole row's hit area, the hand, the focus line on Tab only. */
|
|
92
|
+
export const ALERT_ROW_OPEN_CLASS = "absolute inset-0 cursor-pointer rounded-md no-underline select-none focus-line";
|
|
93
|
+
/** The words' column. */
|
|
94
|
+
export const ALERT_ROW_WORDS_CLASS = "grid min-w-0 flex-1 gap-0.75";
|
|
95
|
+
/** The title: wraps, never cut. */
|
|
96
|
+
export const ALERT_ROW_TITLE_CLASS = "m-0 text-body-sm text-ink";
|
|
97
|
+
/** The second line: the caption role, muted. */
|
|
98
|
+
export const ALERT_ROW_DETAIL_CLASS = "m-0 text-caption";
|
|
99
|
+
/** The action and the x: above the open layer. */
|
|
100
|
+
export const ALERT_ROW_CONTROLS_CLASS = "relative flex shrink-0 items-center gap-2";
|
|
101
|
+
/** "Keep it" and "Undo": the Home's teal action link, bold, the hand; disabled, the arrow. */
|
|
102
|
+
export const ALERT_ROW_ACTION_CLASS = cn(ACTION_LINK_CLASS, "shrink-0 cursor-pointer border-0 bg-transparent p-0 font-bold select-none", "data-disabled:cursor-default data-disabled:no-underline data-disabled:opacity-50 disabled:cursor-default disabled:no-underline disabled:opacity-50");
|
|
103
|
+
/**
|
|
104
|
+
* The x. Hidden until the row is hovered or holds focus, always shown where
|
|
105
|
+
* there is no hover. At rest it takes no room (width 0, its gap taken back),
|
|
106
|
+
* so the action sits at the row's end, as the sketch draws it; as it appears
|
|
107
|
+
* it opens to 28 and fades in at the library's duration, the action easing
|
|
108
|
+
* left to make room. Under reduced motion it is simply there.
|
|
109
|
+
*/
|
|
110
|
+
export const ALERT_ROW_DISMISS_CLASS = cn("inline-flex h-7 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-2xs border-0 bg-(--cg-hover) p-0 text-ink select-none focus-line", "-ml-2 w-0 opacity-0 transition-[opacity,width,margin-left] duration-(--cg-duration) ease-out motion-reduce:transition-none", "group-hover/alert:ml-0 group-hover/alert:w-7 group-hover/alert:opacity-100", "group-focus-within/alert:ml-0 group-focus-within/alert:w-7 group-focus-within/alert:opacity-100", "[@media(hover:none)]:ml-0 [@media(hover:none)]:w-7 [@media(hover:none)]:opacity-100");
|
|
111
|
+
/**
|
|
112
|
+
* The x turns 90 degrees as it appears, on the pin's and the Add tile's
|
|
113
|
+
* spring (`--cg-ease-spring`, 220ms). Under reduced motion it does not turn.
|
|
114
|
+
*/
|
|
115
|
+
export const ALERT_ROW_TURN = "inline-flex transition-[rotate] duration-220 ease-(--cg-ease-spring) motion-reduce:transition-none motion-safe:group-hover/alert:rotate-90 motion-safe:group-focus-within/alert:rotate-90";
|
|
116
|
+
/** The soft tile a glyph sits in: 32 at radius 8, the page grey (the wash on the panel and ink). */
|
|
117
|
+
export const ALERT_ROW_TILE_CLASS = "inline-flex size-8 shrink-0 items-center justify-center rounded-xs bg-page text-ink in-data-[cg-surface=panel]:bg-(--cg-hover) in-data-[cg-surface=ink]:bg-(--cg-hover) [&_svg]:size-4.5";
|
|
118
|
+
/** The turned row's line: one quiet line on the soft grey. */
|
|
119
|
+
export const ALERT_ROW_IGNORED_CLASS = "flex min-h-11 items-center gap-3 rounded-md bg-(--cg-hover) px-3 py-2";
|
|
120
|
+
/** The countdown's track: light teal, never grey. */
|
|
121
|
+
export const ALERT_ROW_COUNTDOWN_CLASS = "mx-3 mt-1.5 h-0.75 overflow-hidden rounded-pill bg-cyan-tint";
|
|
122
|
+
/** The countdown's fill: the action link's teal, running down from the right. */
|
|
123
|
+
export const ALERT_ROW_COUNTDOWN_FILL_CLASS = "block h-full w-full origin-left rounded-pill bg-cyan-dark";
|
|
124
|
+
/** The fold: the row's height and opacity go to nothing; at once under reduced motion. */
|
|
125
|
+
const FOLD_CLASS = "grid transition-[grid-template-rows,opacity] duration-(--cg-duration) ease-out motion-reduce:transition-none";
|
|
126
|
+
/**
|
|
127
|
+
* On a row that starts at its top (a row with a help line, ui#563), the
|
|
128
|
+
* picture centres on the title's first line: half of (one line minus 32) above.
|
|
129
|
+
*/
|
|
130
|
+
export const ALERT_ROW_MEDIA_ON_FIRST_LINE = "text-body-sm mt-[calc((1lh-2rem)/2)]";
|
|
131
|
+
/** The leading picture: a glyph in the soft tile, or a person at 32. */
|
|
132
|
+
function AlertRowMediaSlot({ media, slot, className }) {
|
|
133
|
+
if ("glyph" in media) {
|
|
134
|
+
return (_jsx("span", { "data-slot": slot, "aria-hidden": "true", className: cn(ALERT_ROW_TILE_CLASS, className), children: media.glyph }));
|
|
135
|
+
}
|
|
136
|
+
return (_jsx("span", { "data-slot": slot, "aria-hidden": "true", className: cn("inline-flex shrink-0", className), children: _jsx(Avatar, { name: media.name, seed: media.seed, src: media.src, size: 32 }) }));
|
|
137
|
+
}
|
|
138
|
+
/** The x's glyph, which turns. */
|
|
139
|
+
function AlertRowDismissGlyph({ slot }) {
|
|
140
|
+
return (_jsx("span", { "data-slot": slot, "aria-hidden": "true", className: ALERT_ROW_TURN, children: _jsx(CloseIcon, { className: "size-3.5" }) }));
|
|
141
|
+
}
|
|
142
|
+
/** The rows, and the list or menu that holds them, mark themselves for the focus move. */
|
|
143
|
+
export const ALERT_ROW_ATTRIBUTE = "data-alert-row";
|
|
144
|
+
const FOCUS_ATTRIBUTE = "data-alert-focus";
|
|
145
|
+
const reducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
146
|
+
const canHover = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(hover: hover)").matches;
|
|
147
|
+
/** Focus that came from the keyboard: :focus-visible, and not after a pointer press (lib/input-modality). */
|
|
148
|
+
const keyboardFocus = (el) => {
|
|
149
|
+
try {
|
|
150
|
+
return el.matches(":focus-visible") && !el.closest('[data-cg-input="pointer"]');
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/** The first thing to focus in a row: its door, or its Undo, or anything focusable. */
|
|
157
|
+
const focusTarget = (row) => row.querySelector(`[${FOCUS_ATTRIBUTE}]`) ??
|
|
158
|
+
row.querySelector('a[href], button:not([disabled]), [role="menuitem"]:not([data-disabled])');
|
|
159
|
+
/**
|
|
160
|
+
* The Undo countdown, shared by both rows. Pass the row's state; spread
|
|
161
|
+
* `rowProps` on the row's outer element, put `fillRef` on the countdown's fill
|
|
162
|
+
* and `undoRef` on Undo, and call `undo` from Undo's press.
|
|
163
|
+
*/
|
|
164
|
+
export function useAlertRowCountdown({ dismissed, onUndo, onDismissEnd, }) {
|
|
165
|
+
const rowRef = React.useRef(null);
|
|
166
|
+
const fillRef = React.useRef(null);
|
|
167
|
+
const undoRef = React.useRef(null);
|
|
168
|
+
const [folding, setFolding] = React.useState(false);
|
|
169
|
+
const t = React.useRef({
|
|
170
|
+
remaining: ALERT_ROW_UNDO_MS,
|
|
171
|
+
startedAt: null,
|
|
172
|
+
timer: undefined,
|
|
173
|
+
fold: undefined,
|
|
174
|
+
frame: 0,
|
|
175
|
+
hovered: false,
|
|
176
|
+
focused: false,
|
|
177
|
+
counting: false,
|
|
178
|
+
restoreFocus: false,
|
|
179
|
+
});
|
|
180
|
+
const end = React.useRef(onDismissEnd);
|
|
181
|
+
React.useEffect(() => {
|
|
182
|
+
end.current = onDismissEnd;
|
|
183
|
+
});
|
|
184
|
+
const draw = React.useCallback((left) => {
|
|
185
|
+
const fill = fillRef.current;
|
|
186
|
+
if (fill)
|
|
187
|
+
fill.style.transform = `scaleX(${Math.max(0, left) / ALERT_ROW_UNDO_MS})`;
|
|
188
|
+
}, []);
|
|
189
|
+
const stop = React.useCallback(() => {
|
|
190
|
+
const s = t.current;
|
|
191
|
+
clearTimeout(s.timer);
|
|
192
|
+
if (s.frame)
|
|
193
|
+
cancelAnimationFrame(s.frame);
|
|
194
|
+
s.frame = 0;
|
|
195
|
+
if (s.startedAt !== null) {
|
|
196
|
+
s.remaining -= performance.now() - s.startedAt;
|
|
197
|
+
s.startedAt = null;
|
|
198
|
+
}
|
|
199
|
+
}, []);
|
|
200
|
+
const leave = React.useCallback(() => {
|
|
201
|
+
const row = rowRef.current;
|
|
202
|
+
// Focus inside the leaving row goes to the next row, the one before, or the list.
|
|
203
|
+
if (row && row.contains(document.activeElement)) {
|
|
204
|
+
const holder = row.parentElement?.closest(`[${ALERT_ROW_ATTRIBUTE}-list], [role="menu"]`) ?? null;
|
|
205
|
+
const rows = holder ? [...holder.querySelectorAll(`[${ALERT_ROW_ATTRIBUTE}]`)] : [];
|
|
206
|
+
const at = rows.indexOf(row);
|
|
207
|
+
const next = [...rows.slice(at + 1), ...rows.slice(0, Math.max(0, at)).reverse()]
|
|
208
|
+
.map(focusTarget)
|
|
209
|
+
.find((el) => el !== null);
|
|
210
|
+
(next ?? holder)?.focus();
|
|
211
|
+
}
|
|
212
|
+
end.current?.();
|
|
213
|
+
}, []);
|
|
214
|
+
const finish = React.useCallback(() => {
|
|
215
|
+
const s = t.current;
|
|
216
|
+
stop();
|
|
217
|
+
s.counting = false;
|
|
218
|
+
s.remaining = 0;
|
|
219
|
+
draw(0);
|
|
220
|
+
setFolding(true);
|
|
221
|
+
s.fold = setTimeout(leave, reducedMotion() ? 0 : FOLD_MS);
|
|
222
|
+
}, [draw, leave, stop]);
|
|
223
|
+
const run = React.useCallback(() => {
|
|
224
|
+
const s = t.current;
|
|
225
|
+
if (!s.counting || s.startedAt !== null || s.hovered || s.focused)
|
|
226
|
+
return;
|
|
227
|
+
s.startedAt = performance.now();
|
|
228
|
+
s.timer = setTimeout(finish, Math.max(0, s.remaining));
|
|
229
|
+
if (reducedMotion())
|
|
230
|
+
return;
|
|
231
|
+
const tick = () => {
|
|
232
|
+
if (s.startedAt === null)
|
|
233
|
+
return;
|
|
234
|
+
draw(s.remaining - (performance.now() - s.startedAt));
|
|
235
|
+
s.frame = requestAnimationFrame(tick);
|
|
236
|
+
};
|
|
237
|
+
s.frame = requestAnimationFrame(tick);
|
|
238
|
+
}, [draw, finish]);
|
|
239
|
+
const settle = React.useCallback(() => {
|
|
240
|
+
const s = t.current;
|
|
241
|
+
if (!s.counting)
|
|
242
|
+
return;
|
|
243
|
+
// A pointer that left while the row was changing under it can miss its
|
|
244
|
+
// leave event; the browser's own :hover is the tie-breaker.
|
|
245
|
+
if (s.hovered && rowRef.current && !rowRef.current.matches(":hover"))
|
|
246
|
+
s.hovered = false;
|
|
247
|
+
if (s.hovered || s.focused)
|
|
248
|
+
stop();
|
|
249
|
+
else
|
|
250
|
+
run();
|
|
251
|
+
}, [run, stop]);
|
|
252
|
+
const was = React.useRef(dismissed);
|
|
253
|
+
React.useEffect(() => {
|
|
254
|
+
const s = t.current;
|
|
255
|
+
const turned = dismissed && !was.current;
|
|
256
|
+
const back = !dismissed && was.current;
|
|
257
|
+
was.current = dismissed;
|
|
258
|
+
if (dismissed) {
|
|
259
|
+
stop();
|
|
260
|
+
clearTimeout(s.fold);
|
|
261
|
+
s.remaining = ALERT_ROW_UNDO_MS;
|
|
262
|
+
s.counting = true;
|
|
263
|
+
setFolding(false);
|
|
264
|
+
draw(ALERT_ROW_UNDO_MS);
|
|
265
|
+
// The press that turned the row left the pointer over it, or focus in it;
|
|
266
|
+
// read both afresh from the turned row.
|
|
267
|
+
const row = rowRef.current;
|
|
268
|
+
s.hovered = canHover() && (row?.matches(":hover") ?? false);
|
|
269
|
+
if (turned)
|
|
270
|
+
undoRef.current?.focus();
|
|
271
|
+
s.focused = row?.contains(document.activeElement) === true && keyboardFocus(document.activeElement);
|
|
272
|
+
settle();
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
stop();
|
|
276
|
+
clearTimeout(s.fold);
|
|
277
|
+
s.counting = false;
|
|
278
|
+
setFolding(false);
|
|
279
|
+
if (back && s.restoreFocus && rowRef.current)
|
|
280
|
+
focusTarget(rowRef.current)?.focus();
|
|
281
|
+
s.restoreFocus = false;
|
|
282
|
+
}
|
|
283
|
+
return () => {
|
|
284
|
+
stop();
|
|
285
|
+
clearTimeout(s.fold);
|
|
286
|
+
};
|
|
287
|
+
}, [dismissed, draw, settle, stop]);
|
|
288
|
+
const rowProps = {
|
|
289
|
+
ref: rowRef,
|
|
290
|
+
[ALERT_ROW_ATTRIBUTE]: "",
|
|
291
|
+
onPointerEnter: (e) => {
|
|
292
|
+
// A finger does not hover: on a phone the countdown runs.
|
|
293
|
+
if (e.pointerType === "touch")
|
|
294
|
+
return;
|
|
295
|
+
t.current.hovered = true;
|
|
296
|
+
settle();
|
|
297
|
+
},
|
|
298
|
+
onPointerLeave: () => {
|
|
299
|
+
t.current.hovered = false;
|
|
300
|
+
settle();
|
|
301
|
+
},
|
|
302
|
+
onFocus: (e) => {
|
|
303
|
+
t.current.focused = keyboardFocus(e.target);
|
|
304
|
+
settle();
|
|
305
|
+
},
|
|
306
|
+
onBlur: (e) => {
|
|
307
|
+
if (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget))
|
|
308
|
+
return;
|
|
309
|
+
t.current.focused = false;
|
|
310
|
+
settle();
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
const undo = React.useCallback(() => {
|
|
314
|
+
t.current.restoreFocus = rowRef.current?.contains(document.activeElement) ?? false;
|
|
315
|
+
onUndo?.();
|
|
316
|
+
}, [onUndo]);
|
|
317
|
+
return { rowProps, fillRef, undoRef, undo, folding };
|
|
318
|
+
}
|
|
319
|
+
/** The fold around a turned row: open, then folded to nothing. */
|
|
320
|
+
function AlertRowFold({ folding, children }) {
|
|
321
|
+
return (_jsx("div", { "data-folding": folding ? "true" : "false", className: cn(FOLD_CLASS, folding ? "grid-rows-[0fr] opacity-0" : "grid-rows-[1fr]"), children: _jsx("div", { className: "min-h-0 overflow-hidden", children: children }) }));
|
|
322
|
+
}
|
|
323
|
+
/** The countdown line under a turned row. */
|
|
324
|
+
function AlertRowCountdown({ slot, fillRef }) {
|
|
325
|
+
return (_jsx("div", { "data-slot": slot, "aria-hidden": "true", className: ALERT_ROW_COUNTDOWN_CLASS, children: _jsx("span", { ref: fillRef, "data-slot": `${slot}-fill`, className: ALERT_ROW_COUNTDOWN_FILL_CLASS }) }));
|
|
326
|
+
}
|
|
327
|
+
/** "Ignored <name>": the name in semibold. */
|
|
328
|
+
function AlertRowIgnoredText({ id, slot, name }) {
|
|
329
|
+
return (_jsxs("p", { id: id, "data-slot": slot, className: "m-0 min-w-0 flex-1 text-body-sm text-ink", children: [ALERT_ROW_COPY.ignored, " ", _jsx("span", { className: "font-semibold", children: name })] }));
|
|
330
|
+
}
|
|
331
|
+
export { AlertRowCountdown, AlertRowDismissGlyph, AlertRowFold, AlertRowIgnoredText, AlertRowMediaSlot, FOCUS_ATTRIBUTE as ALERT_ROW_FOCUS_ATTRIBUTE, };
|
|
332
|
+
//# sourceMappingURL=alert-row.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-row.js","sourceRoot":"","sources":["../../src/blocks/alert-row.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,8BAA8B;AAC9B,MAAM,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O,CACL,aAAG,EAAE,EAAE,EAAE,eAAa,IAAI,EAAE,SAAS,EAAC,0CAA0C,aAC7E,cAAc,CAAC,OAAO,OAAE,eAAM,SAAS,EAAC,eAAe,YAAE,IAAI,GAAQ,IACpE,CACL,CAAA;AACH,CAAC;AAED,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,IAAI,yBAAyB,GAC7C,CAAA"}
|
|
@@ -162,8 +162,15 @@ export type AvatarPickerProps = {
|
|
|
162
162
|
originalSrc?: string;
|
|
163
163
|
/** ui#556: the view the photo was cut at, from `originalSrc`. Ignored without it. */
|
|
164
164
|
view?: ImageAdjustView;
|
|
165
|
+
/**
|
|
166
|
+
* ui#576: the original is still being read. "Adjust photo" chosen now
|
|
167
|
+
* waits: the picture is `aria-busy` (its spinner after 300ms), and the step
|
|
168
|
+
* opens once this turns false, on `originalSrc` at `view` if one arrived,
|
|
169
|
+
* else on `src` at 100%. Escape or a press anywhere while it waits cancels.
|
|
170
|
+
*/
|
|
171
|
+
originalPending?: boolean;
|
|
165
172
|
className?: string;
|
|
166
173
|
};
|
|
167
|
-
declare function AvatarPicker({ name, seed, src, size, onSelectFile, onReject, accept, maxBytes, pending, disabled, label, adjust, onAdjust, onRemove, originalSrc, view, className, }: AvatarPickerProps): React.JSX.Element;
|
|
174
|
+
declare function AvatarPicker({ name, seed, src, size, onSelectFile, onReject, accept, maxBytes, pending, disabled, label, adjust, onAdjust, onRemove, originalSrc, view, originalPending, className, }: AvatarPickerProps): React.JSX.Element;
|
|
168
175
|
export { AvatarPicker };
|
|
169
176
|
//# sourceMappingURL=avatar-picker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar-picker.d.ts","sourceRoot":"","sources":["../../src/blocks/avatar-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,EAAU,KAAK,cA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
|
|
142
142
|
}
|
|
143
143
|
const OVERLAY = "absolute inset-0 grid place-items-center rounded-pill bg-scrim-strong text-ink";
|
|
144
|
-
function AvatarPicker({ name, seed, src, size = 56, onSelectFile, onReject, accept = AVATAR_PICKER_ACCEPT, maxBytes, pending = false, disabled = false, label = AVATAR_PICKER_LABEL, adjust, onAdjust, onRemove, originalSrc, view, className, }) {
|
|
144
|
+
function AvatarPicker({ name, seed, src, size = 56, onSelectFile, onReject, accept = AVATAR_PICKER_ACCEPT, maxBytes, pending = false, disabled = false, label = AVATAR_PICKER_LABEL, adjust, onAdjust, onRemove, originalSrc, view, originalPending = false, className, }) {
|
|
145
145
|
const input = React.useRef(null);
|
|
146
146
|
const off = disabled || pending;
|
|
147
147
|
// ui#556: the photo menu, opened from the picture while there is a photo.
|
|
148
148
|
const menu = Boolean(onAdjust || onRemove);
|
|
149
149
|
const pictureMenu = menu && Boolean(src);
|
|
150
150
|
const adjusting = useImageAdjustStep(adjust || menu, "circle", onSelectFile);
|
|
151
|
-
const current = useImageAdjustCurrent(adjust, "circle", { src, originalSrc, view }, onAdjust);
|
|
151
|
+
const current = useImageAdjustCurrent(adjust, "circle", { src, originalSrc, view, originalPending }, onAdjust);
|
|
152
|
+
// ui#576: an Adjust waiting for the original is busy, and shows it after 300ms.
|
|
153
|
+
const busy = pending || current.held;
|
|
154
|
+
const spinning = pending || current.heldShown;
|
|
152
155
|
const pick = () => {
|
|
153
156
|
if (off)
|
|
154
157
|
return;
|
|
@@ -156,11 +159,11 @@ function AvatarPicker({ name, seed, src, size = 56, onSelectFile, onReject, acce
|
|
|
156
159
|
};
|
|
157
160
|
const pictureProps = {
|
|
158
161
|
"aria-label": label,
|
|
159
|
-
"aria-busy":
|
|
162
|
+
"aria-busy": busy || undefined,
|
|
160
163
|
disabled: off,
|
|
161
|
-
className: cn("group/avatar-picker relative inline-flex shrink-0 cursor-pointer rounded-pill outline-none", "focus-line", "disabled:cursor-
|
|
164
|
+
className: cn("group/avatar-picker relative inline-flex shrink-0 cursor-pointer rounded-pill outline-none", "focus-line", "disabled:cursor-default", disabled && !pending ? "disabled:opacity-50" : ""),
|
|
162
165
|
};
|
|
163
|
-
const pictureInside = (_jsxs(_Fragment, { children: [_jsx(Avatar, { name: name, seed: seed, src: src, size: size }),
|
|
166
|
+
const pictureInside = (_jsxs(_Fragment, { children: [_jsx(Avatar, { name: name, seed: seed, src: src, size: size }), spinning ? (_jsx("span", { "data-cg-surface": "ink", "aria-hidden": "true", className: OVERLAY, children: _jsx(Spinner, { decorative: true, size: "lg" }) })) : disabled ? null : (_jsx("span", { "data-slot": "avatar-picker-mark", "data-cg-surface": "ink", "aria-hidden": "true", className: cn(OVERLAY, "opacity-0 transition-opacity duration-150 motion-reduce:transition-none", "group-hover/avatar-picker:opacity-100 group-focus-visible/avatar-picker:opacity-100"), children: _jsx(ChangePhotoIcon, { className: "size-[40%] min-h-3.5 min-w-3.5 shrink-0" }) }))] }));
|
|
164
167
|
return (_jsxs("span", { "data-slot": "avatar-picker", "data-pending": pending || undefined, className: cn("relative inline-flex shrink-0", className), children: [pictureMenu ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { ...pictureProps, children: pictureInside }), _jsx(DropdownMenuContent, { "data-slot": "avatar-picker-menu", className: "w-max", children: _jsx(PictureMenuItems, { noun: "photo", picture: true, onAdjust: onAdjust
|
|
165
168
|
? () => {
|
|
166
169
|
if (!off)
|