@charcuterie/ui 4.27.2 → 4.28.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/dist/Accordion/AccordionSection.d.ts.map +1 -1
- package/dist/Accordion/AccordionSection.js +43 -4
- package/dist/Accordion/AccordionSection.js.map +1 -1
- package/dist/Combobox/Combobox.d.ts.map +1 -1
- package/dist/Combobox/Combobox.js +3 -3
- package/dist/Combobox/Combobox.js.map +1 -1
- package/dist/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/DatePicker/DatePicker.js +3 -3
- package/dist/DatePicker/DatePicker.js.map +1 -1
- package/dist/Dialog/Dialog.d.ts +7 -1
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +2 -2
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/GroupedList/GroupedList.d.ts +9 -2
- package/dist/GroupedList/GroupedList.d.ts.map +1 -1
- package/dist/GroupedList/GroupedList.js +39 -5
- package/dist/GroupedList/GroupedList.js.map +1 -1
- package/dist/GroupedList/GroupedListRow.d.ts +4 -1
- package/dist/GroupedList/GroupedListRow.d.ts.map +1 -1
- package/dist/GroupedList/GroupedListRow.js +3 -3
- package/dist/GroupedList/GroupedListRow.js.map +1 -1
- package/dist/GroupedList/GroupedListRows.d.ts +16 -0
- package/dist/GroupedList/GroupedListRows.d.ts.map +1 -0
- package/dist/GroupedList/GroupedListRows.js +17 -0
- package/dist/GroupedList/GroupedListRows.js.map +1 -0
- package/dist/Listbox/Listbox.d.ts.map +1 -1
- package/dist/Listbox/Listbox.js +6 -4
- package/dist/Listbox/Listbox.js.map +1 -1
- package/dist/Menu/Menu.d.ts.map +1 -1
- package/dist/Menu/Menu.js +6 -4
- package/dist/Menu/Menu.js.map +1 -1
- package/dist/Modal/Modal.d.ts +7 -1
- package/dist/Modal/Modal.d.ts.map +1 -1
- package/dist/Modal/Modal.js +1 -1
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/Motion/useLastPresentValue.d.ts +21 -0
- package/dist/Motion/useLastPresentValue.d.ts.map +1 -0
- package/dist/Motion/useLastPresentValue.js +30 -0
- package/dist/Motion/useLastPresentValue.js.map +1 -0
- package/dist/Motion/useListMotion.d.ts +111 -0
- package/dist/Motion/useListMotion.d.ts.map +1 -0
- package/dist/Motion/useListMotion.js +358 -0
- package/dist/Motion/useListMotion.js.map +1 -0
- package/dist/Motion/usePresence.d.ts +81 -0
- package/dist/Motion/usePresence.d.ts.map +1 -0
- package/dist/Motion/usePresence.js +131 -0
- package/dist/Motion/usePresence.js.map +1 -0
- package/dist/Motion/useValueChangeMotion.d.ts +52 -0
- package/dist/Motion/useValueChangeMotion.d.ts.map +1 -0
- package/dist/Motion/useValueChangeMotion.js +87 -0
- package/dist/Motion/useValueChangeMotion.js.map +1 -0
- package/dist/Overlay/OverlayPanel.d.ts +18 -1
- package/dist/Overlay/OverlayPanel.d.ts.map +1 -1
- package/dist/Overlay/OverlayPanel.js +40 -10
- package/dist/Overlay/OverlayPanel.js.map +1 -1
- package/dist/Overlay/SharedBackdrop.d.ts +3 -0
- package/dist/Overlay/SharedBackdrop.d.ts.map +1 -1
- package/dist/Overlay/SharedBackdrop.js +8 -2
- package/dist/Overlay/SharedBackdrop.js.map +1 -1
- package/dist/Overlay/useAnchoredOverlay.d.ts +17 -3
- package/dist/Overlay/useAnchoredOverlay.d.ts.map +1 -1
- package/dist/Overlay/useAnchoredOverlay.js +23 -5
- package/dist/Overlay/useAnchoredOverlay.js.map +1 -1
- package/dist/Popover/Popover.d.ts.map +1 -1
- package/dist/Popover/Popover.js +4 -2
- package/dist/Popover/Popover.js.map +1 -1
- package/dist/ReorderList/ReorderList.d.ts +6 -0
- package/dist/ReorderList/ReorderList.d.ts.map +1 -1
- package/dist/ReorderList/ReorderList.js +23 -6
- package/dist/ReorderList/ReorderList.js.map +1 -1
- package/dist/TableViewport/TableViewport.d.ts.map +1 -1
- package/dist/TableViewport/TableViewport.js +9 -1
- package/dist/TableViewport/TableViewport.js.map +1 -1
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +16 -13
- package/dist/Tooltip/Tooltip.js.map +1 -1
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/styles.css +191 -1
- package/package.json +2 -2
- package/src/Accordion/AccordionSection.tsx +63 -4
- package/src/Combobox/Combobox.tsx +8 -2
- package/src/DatePicker/DatePicker.tsx +7 -1
- package/src/Dialog/Dialog.tsx +8 -0
- package/src/GroupedList/GroupedList.mdx +3 -2
- package/src/GroupedList/GroupedList.test.tsx +283 -0
- package/src/GroupedList/GroupedList.tsx +88 -44
- package/src/GroupedList/GroupedListRow.tsx +8 -0
- package/src/GroupedList/GroupedListRows.tsx +51 -0
- package/src/Listbox/Listbox.tsx +9 -1
- package/src/Menu/Menu.tsx +9 -1
- package/src/Modal/Modal.tsx +8 -0
- package/src/Motion/useLastPresentValue.test.tsx +66 -0
- package/src/Motion/useLastPresentValue.ts +38 -0
- package/src/Motion/useListMotion.test.tsx +527 -0
- package/src/Motion/useListMotion.ts +674 -0
- package/src/Motion/usePresence.test.tsx +223 -0
- package/src/Motion/usePresence.ts +252 -0
- package/src/Motion/useValueChangeMotion.test.tsx +131 -0
- package/src/Motion/useValueChangeMotion.ts +110 -0
- package/src/Overlay/OverlayPanel.tsx +78 -14
- package/src/Overlay/SharedBackdrop.tsx +17 -2
- package/src/Overlay/useAnchoredOverlay.ts +56 -4
- package/src/Popover/Popover.tsx +9 -1
- package/src/ReorderList/ReorderList.test.tsx +76 -0
- package/src/ReorderList/ReorderList.tsx +86 -48
- package/src/TableViewport/TableViewport.tsx +4 -0
- package/src/Tooltip/Tooltip.tsx +32 -4
- package/src/index.ts +30 -0
- package/src/styles.css +191 -1
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -14,10 +14,16 @@ import {
|
|
|
14
14
|
useFocus,
|
|
15
15
|
useHover,
|
|
16
16
|
useInteractions,
|
|
17
|
+
useMergeRefs,
|
|
17
18
|
useRole,
|
|
18
19
|
} from "@floating-ui/react"
|
|
19
20
|
import type { ReactElement, ReactNode } from "react"
|
|
20
21
|
|
|
22
|
+
import {
|
|
23
|
+
toFadeMotionClass,
|
|
24
|
+
toTransformOrigin,
|
|
25
|
+
usePresence,
|
|
26
|
+
} from "../Motion/usePresence.ts"
|
|
21
27
|
import type { SlotProps } from "../slotProps.ts"
|
|
22
28
|
import { mergeSlotProps } from "../slotProps.ts"
|
|
23
29
|
import { toClassName } from "../toClassName.ts"
|
|
@@ -110,7 +116,12 @@ export const Tooltip = ({
|
|
|
110
116
|
}: TooltipProps): ReactNode => {
|
|
111
117
|
const { isVisible, setIsVisible } = useVisibility()
|
|
112
118
|
|
|
113
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
context,
|
|
121
|
+
floatingStyles,
|
|
122
|
+
placement: resolvedPlacement,
|
|
123
|
+
refs,
|
|
124
|
+
} = useFloating({
|
|
114
125
|
// Read-only, as everywhere: floating-ui is told what is true and
|
|
115
126
|
// never decides it.
|
|
116
127
|
open: isVisible,
|
|
@@ -151,11 +162,21 @@ export const Tooltip = ({
|
|
|
151
162
|
}),
|
|
152
163
|
)
|
|
153
164
|
|
|
165
|
+
// A tip fades rather than scales: it is a label, not a surface, and
|
|
166
|
+
// a growing label reads as a wobble.
|
|
167
|
+
const { isExiting, isMounted, presenceRef } =
|
|
168
|
+
usePresence(isVisible)
|
|
169
|
+
|
|
170
|
+
const setTooltipRef = useMergeRefs([
|
|
171
|
+
refs.setFloating,
|
|
172
|
+
presenceRef,
|
|
173
|
+
])
|
|
174
|
+
|
|
154
175
|
return (
|
|
155
176
|
<>
|
|
156
177
|
{clonedTrigger}
|
|
157
178
|
|
|
158
|
-
{
|
|
179
|
+
{isMounted ? (
|
|
159
180
|
<FloatingPortal>
|
|
160
181
|
<div
|
|
161
182
|
{...getFloatingProps()}
|
|
@@ -173,6 +194,7 @@ export const Tooltip = ({
|
|
|
173
194
|
// content rather than fine print. It was the whole
|
|
174
195
|
// tooltip at 12px before 2026-08-10.
|
|
175
196
|
"z-[var(--layer-tooltip)] max-w-xs rounded-md bg-intent-neutral-solid px-2 py-1 text-intent-neutral-on-solid text-sm shadow-medium",
|
|
197
|
+
toFadeMotionClass(isExiting),
|
|
176
198
|
className,
|
|
177
199
|
)}
|
|
178
200
|
// Portalled to `document.body`, the same reversal as the
|
|
@@ -182,14 +204,20 @@ export const Tooltip = ({
|
|
|
182
204
|
// focus never enters a tooltip, and moving it here is what
|
|
183
205
|
// would make one unescapable. `--layer-tooltip` keeps it
|
|
184
206
|
// above a modal.
|
|
185
|
-
|
|
207
|
+
aria-hidden={isExiting ? true : undefined}
|
|
208
|
+
ref={setTooltipRef}
|
|
186
209
|
// Duplicated from `getFloatingProps()` deliberately, and
|
|
187
210
|
// the two cannot differ — `useRole(context, { role:
|
|
188
211
|
// "tooltip" })` above is where it comes from. Stated here
|
|
189
212
|
// because a linter cannot see a role through a spread, and
|
|
190
213
|
// neither can the next reader.
|
|
191
214
|
role="tooltip"
|
|
192
|
-
style={
|
|
215
|
+
style={{
|
|
216
|
+
...floatingStyles,
|
|
217
|
+
transformOrigin: toTransformOrigin(
|
|
218
|
+
resolvedPlacement,
|
|
219
|
+
),
|
|
220
|
+
}}
|
|
193
221
|
>
|
|
194
222
|
{label}
|
|
195
223
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -358,6 +358,36 @@ export type { MetricCardProps } from "./MetricCard/MetricCard.tsx"
|
|
|
358
358
|
export { MetricCard } from "./MetricCard/MetricCard.tsx"
|
|
359
359
|
export type { ModalProps } from "./Modal/Modal.tsx"
|
|
360
360
|
export { Modal } from "./Modal/Modal.tsx"
|
|
361
|
+
/**
|
|
362
|
+
* The value, or the last value it had once it becomes empty — so an
|
|
363
|
+
* overlay built from a selection keeps its content while it closes.
|
|
364
|
+
*/
|
|
365
|
+
export { useLastPresentValue } from "./Motion/useLastPresentValue.ts"
|
|
366
|
+
/**
|
|
367
|
+
* Keep an element in the page until its exit animation ends, and the
|
|
368
|
+
* enter/exit classes every library overlay uses. For an app's own
|
|
369
|
+
* thing that appears and disappears — a row, a banner, a panel — so it
|
|
370
|
+
* moves the way the library's overlays do.
|
|
371
|
+
*/
|
|
372
|
+
export type {
|
|
373
|
+
ListMotionEntry,
|
|
374
|
+
ListMotionProps,
|
|
375
|
+
UseListMotionOptions,
|
|
376
|
+
} from "./Motion/useListMotion.ts"
|
|
377
|
+
/**
|
|
378
|
+
* An added item enters, a removed one leaves, and the rest slide to
|
|
379
|
+
* their new places. Spread `motionProps` on a wrapper the hook owns.
|
|
380
|
+
*/
|
|
381
|
+
export { useListMotion } from "./Motion/useListMotion.ts"
|
|
382
|
+
export type { UsePresenceResult } from "./Motion/usePresence.ts"
|
|
383
|
+
export {
|
|
384
|
+
toFadeMotionClass,
|
|
385
|
+
toOverlayMotionClass,
|
|
386
|
+
usePresence,
|
|
387
|
+
} from "./Motion/usePresence.ts"
|
|
388
|
+
/** Props that pop an element each time the value it shows changes. */
|
|
389
|
+
export type { ValueChangeMotionProps } from "./Motion/useValueChangeMotion.ts"
|
|
390
|
+
export { useValueChangeMotion } from "./Motion/useValueChangeMotion.ts"
|
|
361
391
|
export type {
|
|
362
392
|
NavLayout,
|
|
363
393
|
NavProps,
|
package/src/styles.css
CHANGED
|
@@ -132,12 +132,202 @@
|
|
|
132
132
|
var(--easing-standard) infinite;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/* Overlay enter and exit: "this opened" and "this closed".
|
|
136
|
+
*
|
|
137
|
+
* A panel that appears or disappears in one frame is easy to miss, so
|
|
138
|
+
* every overlay fades and scales a little as it opens and closes (the
|
|
139
|
+
* 2026-11-09 decision). The keyframes name only the far end: the enter
|
|
140
|
+
* starts transparent and small and ends on the element's own resting
|
|
141
|
+
* style, and the exit runs the other way and holds (`forwards`) until
|
|
142
|
+
* `usePresence` removes the element on `animationend`.
|
|
143
|
+
*
|
|
144
|
+
* `scale` and not `transform`, because floating-ui positions an
|
|
145
|
+
* anchored panel with `transform: translate(...)` in its inline style.
|
|
146
|
+
* The individual `scale` property composes with that; an animated
|
|
147
|
+
* `transform` would replace it and throw the panel to the corner.
|
|
148
|
+
*
|
|
149
|
+
* The exit is shorter than the enter: arriving is information the user
|
|
150
|
+
* reads, leaving is just getting out of the way of the next thing.
|
|
151
|
+
* `pointer-events: none` on the exit is what lets a click land on the
|
|
152
|
+
* page under a closing panel instead of on its ghost.
|
|
153
|
+
*
|
|
154
|
+
* The resting style is the static fallback, so reduced motion switches
|
|
155
|
+
* all four off below and loses nothing: an enter with no animation is
|
|
156
|
+
* simply there, and an exit with no animation is removed in the same
|
|
157
|
+
* commit because `usePresence` reads a zero length. */
|
|
158
|
+
@keyframes charcuterie-overlay-in {
|
|
159
|
+
from {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
scale: 0.96;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@keyframes charcuterie-overlay-out {
|
|
166
|
+
to {
|
|
167
|
+
opacity: 0;
|
|
168
|
+
scale: 0.96;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@keyframes charcuterie-fade-in {
|
|
173
|
+
from {
|
|
174
|
+
opacity: 0;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@keyframes charcuterie-fade-out {
|
|
179
|
+
to {
|
|
180
|
+
opacity: 0;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.charcuterie-overlay-enter {
|
|
185
|
+
animation: charcuterie-overlay-in var(--duration-normal)
|
|
186
|
+
var(--easing-entrance);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.charcuterie-overlay-exit {
|
|
190
|
+
animation: charcuterie-overlay-out var(--duration-fast)
|
|
191
|
+
var(--easing-exit) forwards;
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.charcuterie-fade-enter {
|
|
196
|
+
animation: charcuterie-fade-in var(--duration-normal)
|
|
197
|
+
var(--easing-entrance);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.charcuterie-fade-exit {
|
|
201
|
+
animation: charcuterie-fade-out var(--duration-fast)
|
|
202
|
+
var(--easing-exit) forwards;
|
|
203
|
+
pointer-events: none;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* A list item an action added, removed, or changed (`useListMotion`,
|
|
207
|
+
* `useValueChangeMotion`).
|
|
208
|
+
*
|
|
209
|
+
* An added item grows a little and fades in; a removed one fades and
|
|
210
|
+
* shrinks in place before the gap closes, and its neighbours then
|
|
211
|
+
* slide (a transition `useListMotion` writes inline, on the same
|
|
212
|
+
* `--duration-normal` token).
|
|
213
|
+
*
|
|
214
|
+
* Neither animates `translate`, because the slide does. A running
|
|
215
|
+
* animation overrides an inline style, so an enter that moved the
|
|
216
|
+
* item would freeze the slide of an item that moves again while it is
|
|
217
|
+
* still entering, and it would jump to its new place instead.
|
|
218
|
+
*
|
|
219
|
+
* A changed value pops: it starts slightly larger and settles, so the
|
|
220
|
+
* eye finds it without a colour that could clash with the element's
|
|
221
|
+
* own. The two `value-changed` names share one set of keyframes so
|
|
222
|
+
* that a second change restarts the animation. */
|
|
223
|
+
@keyframes charcuterie-item-in {
|
|
224
|
+
from {
|
|
225
|
+
opacity: 0;
|
|
226
|
+
scale: 0.96;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@keyframes charcuterie-item-out {
|
|
231
|
+
to {
|
|
232
|
+
opacity: 0;
|
|
233
|
+
scale: 0.94;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@keyframes charcuterie-value-pop {
|
|
238
|
+
from {
|
|
239
|
+
scale: 1.15;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@keyframes charcuterie-value-pop-again {
|
|
244
|
+
from {
|
|
245
|
+
scale: 1.15;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.charcuterie-item-enter {
|
|
250
|
+
animation: charcuterie-item-in var(--duration-normal)
|
|
251
|
+
var(--easing-entrance);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.charcuterie-item-exit {
|
|
255
|
+
animation: charcuterie-item-out var(--duration-fast)
|
|
256
|
+
var(--easing-exit) forwards;
|
|
257
|
+
pointer-events: none;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.charcuterie-value-changed {
|
|
261
|
+
animation: charcuterie-value-pop var(--duration-slow)
|
|
262
|
+
var(--easing-emphasized);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.charcuterie-value-changed-again {
|
|
266
|
+
animation: charcuterie-value-pop-again
|
|
267
|
+
var(--duration-slow) var(--easing-emphasized);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* A disclosure panel's height opens and shuts instead of jumping.
|
|
271
|
+
*
|
|
272
|
+
* Keyframes rather than a transition, because Tailwind's preflight
|
|
273
|
+
* makes `[hidden]` `display: none !important`, which no transition can
|
|
274
|
+
* delay. `usePresence` keeps the panel un-hidden until the close
|
|
275
|
+
* animation ends, exactly as it keeps a closing modal in the page.
|
|
276
|
+
* `interpolate-size` is what lets `height` animate to and from `auto`;
|
|
277
|
+
* a browser without it gets no animation at all (the `@supports`), and
|
|
278
|
+
* a panel that simply opens and shuts, rather than a half-length
|
|
279
|
+
* pause and a jump. */
|
|
280
|
+
@keyframes charcuterie-disclosure-in {
|
|
281
|
+
from {
|
|
282
|
+
height: 0;
|
|
283
|
+
opacity: 0;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@keyframes charcuterie-disclosure-out {
|
|
288
|
+
to {
|
|
289
|
+
height: 0;
|
|
290
|
+
opacity: 0;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@supports (interpolate-size: allow-keywords) {
|
|
295
|
+
.charcuterie-disclosure-enter,
|
|
296
|
+
.charcuterie-disclosure-exit {
|
|
297
|
+
interpolate-size: allow-keywords;
|
|
298
|
+
overflow: clip;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.charcuterie-disclosure-enter {
|
|
302
|
+
animation: charcuterie-disclosure-in
|
|
303
|
+
var(--duration-normal) var(--easing-standard);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.charcuterie-disclosure-exit {
|
|
307
|
+
animation: charcuterie-disclosure-out
|
|
308
|
+
var(--duration-fast) var(--easing-exit) forwards;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
135
312
|
@media (prefers-reduced-motion: reduce) {
|
|
136
313
|
.charcuterie-spin,
|
|
137
314
|
.charcuterie-shimmer,
|
|
138
315
|
.charcuterie-sweep,
|
|
139
316
|
.charcuterie-pulse,
|
|
140
|
-
.charcuterie-highlight
|
|
317
|
+
.charcuterie-highlight,
|
|
318
|
+
.charcuterie-overlay-enter,
|
|
319
|
+
.charcuterie-overlay-exit,
|
|
320
|
+
.charcuterie-fade-enter,
|
|
321
|
+
.charcuterie-fade-exit,
|
|
322
|
+
.charcuterie-item-enter,
|
|
323
|
+
.charcuterie-item-exit,
|
|
324
|
+
.charcuterie-value-changed,
|
|
325
|
+
.charcuterie-value-changed-again {
|
|
326
|
+
animation: none;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.charcuterie-disclosure-enter,
|
|
330
|
+
.charcuterie-disclosure-exit {
|
|
141
331
|
animation: none;
|
|
142
332
|
}
|
|
143
333
|
|