@slipstream-ui/core 0.9.0 → 0.10.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/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +96 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -46
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +1 -1
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +1 -1
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +1 -1
- package/dist/manifests/date-picker-popover.manifest.json +1 -1
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +13 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +1 -1
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +1 -1
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +8 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +1 -1
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +1 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +12 -1
- package/dist/src/components/accordion/Accordion.js +26 -19
- package/dist/src/components/accordion/Accordion.js.map +1 -1
- package/dist/src/components/accordion/Accordion.mjs +26 -19
- package/dist/src/components/accordion/Accordion.mjs.map +1 -1
- package/dist/src/components/checkbox/Checkbox.js +1 -1
- package/dist/src/components/checkbox/Checkbox.js.map +1 -1
- package/dist/src/components/checkbox/Checkbox.mjs +1 -1
- package/dist/src/components/checkbox/Checkbox.mjs.map +1 -1
- package/dist/src/components/drawer/Drawer.js +2 -1
- package/dist/src/components/drawer/Drawer.js.map +1 -1
- package/dist/src/components/drawer/Drawer.mjs +2 -1
- package/dist/src/components/drawer/Drawer.mjs.map +1 -1
- package/dist/src/components/filter-chips/FilterChips.d.ts +4 -0
- package/dist/src/components/filter-chips/FilterChips.js +35 -4
- package/dist/src/components/filter-chips/FilterChips.js.map +1 -1
- package/dist/src/components/filter-chips/FilterChips.mjs +35 -4
- package/dist/src/components/filter-chips/FilterChips.mjs.map +1 -1
- package/dist/src/components/radio/Radio.js +1 -1
- package/dist/src/components/radio/Radio.js.map +1 -1
- package/dist/src/components/radio/Radio.mjs +1 -1
- package/dist/src/components/radio/Radio.mjs.map +1 -1
- package/dist/src/components/range-slider/RangeSlider.js +3 -3
- package/dist/src/components/range-slider/RangeSlider.js.map +1 -1
- package/dist/src/components/range-slider/RangeSlider.mjs +3 -3
- package/dist/src/components/range-slider/RangeSlider.mjs.map +1 -1
- package/dist/src/components/select/Select.d.ts +10 -0
- package/dist/src/components/select/Select.js +2 -2
- package/dist/src/components/select/Select.js.map +1 -1
- package/dist/src/components/select/Select.mjs +2 -2
- package/dist/src/components/select/Select.mjs.map +1 -1
- package/dist/src/components/timeline/Timeline.js +17 -13
- package/dist/src/components/timeline/Timeline.js.map +1 -1
- package/dist/src/components/timeline/Timeline.mjs +17 -13
- package/dist/src/components/timeline/Timeline.mjs.map +1 -1
- package/dist/src/components/tooltip/Tooltip.d.ts +5 -0
- package/dist/src/components/tooltip/Tooltip.js +9 -2
- package/dist/src/components/tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/tooltip/Tooltip.mjs +9 -2
- package/dist/src/components/tooltip/Tooltip.mjs.map +1 -1
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/accordion/Accordion.test.tsx +14 -3
- package/src/components/accordion/Accordion.tsx +34 -21
- package/src/components/checkbox/Checkbox.tsx +1 -1
- package/src/components/drawer/Drawer.test.tsx +12 -0
- package/src/components/drawer/Drawer.tsx +8 -1
- package/src/components/filter-chips/FilterChips.test.tsx +11 -0
- package/src/components/filter-chips/FilterChips.tsx +40 -4
- package/src/components/radio/Radio.tsx +1 -1
- package/src/components/range-slider/RangeSlider.tsx +3 -3
- package/src/components/select/Select.test.tsx +14 -0
- package/src/components/select/Select.tsx +7 -2
- package/src/components/timeline/Timeline.test.tsx +11 -0
- package/src/components/timeline/Timeline.tsx +13 -2
- package/src/components/tooltip/Tooltip.test.tsx +15 -0
- package/src/components/tooltip/Tooltip.tsx +19 -2
- package/src/manifests/accordion.manifest.json +1 -1
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +1 -1
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +1 -1
- package/src/manifests/date-picker-popover.manifest.json +1 -1
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +13 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +1 -1
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +1 -1
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +8 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +1 -1
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +1 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +12 -1
|
@@ -201,29 +201,42 @@ const AccordionContent = React.forwardRef<HTMLDivElement, AccordionContentProps>
|
|
|
201
201
|
// Expansion animation via grid-template-rows (0fr -> 1fr): supported
|
|
202
202
|
// in Chrome 117+/Firefox 66+/Safari 17+, and degrades to an instant
|
|
203
203
|
// toggle elsewhere because the rows value simply stops interpolating.
|
|
204
|
-
//
|
|
205
|
-
//
|
|
204
|
+
//
|
|
205
|
+
// Closing keeps the panel mounted for the transition window. Binding
|
|
206
|
+
// `hidden` straight to `open` removed the panel on the closing frame, so
|
|
207
|
+
// collapse was a jump cut with no animation at all.
|
|
208
|
+
const [mounted, setMounted] = React.useState(open);
|
|
206
209
|
const [expanded, setExpanded] = React.useState(open);
|
|
210
|
+
|
|
207
211
|
React.useEffect(() => {
|
|
208
|
-
if (!open) {
|
|
209
|
-
setExpanded(false);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
212
|
const reduce =
|
|
213
213
|
typeof window.matchMedia === 'function' &&
|
|
214
214
|
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
215
|
+
|
|
216
|
+
if (open) {
|
|
217
|
+
setMounted(true);
|
|
218
|
+
if (reduce) {
|
|
219
|
+
setExpanded(true);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// Paint the collapsed frame first so the row transition has a start.
|
|
223
|
+
let second = 0;
|
|
224
|
+
const first = requestAnimationFrame(() => {
|
|
225
|
+
second = requestAnimationFrame(() => setExpanded(true));
|
|
226
|
+
});
|
|
227
|
+
return () => {
|
|
228
|
+
cancelAnimationFrame(first);
|
|
229
|
+
cancelAnimationFrame(second);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
setExpanded(false);
|
|
215
234
|
if (reduce) {
|
|
216
|
-
|
|
235
|
+
setMounted(false);
|
|
217
236
|
return;
|
|
218
237
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
second = requestAnimationFrame(() => setExpanded(true));
|
|
222
|
-
});
|
|
223
|
-
return () => {
|
|
224
|
-
cancelAnimationFrame(first);
|
|
225
|
-
cancelAnimationFrame(second);
|
|
226
|
-
};
|
|
238
|
+
const timer = setTimeout(() => setMounted(false), 320);
|
|
239
|
+
return () => clearTimeout(timer);
|
|
227
240
|
}, [open]);
|
|
228
241
|
|
|
229
242
|
return (
|
|
@@ -232,16 +245,16 @@ const AccordionContent = React.forwardRef<HTMLDivElement, AccordionContentProps>
|
|
|
232
245
|
id={`${id}-panel`}
|
|
233
246
|
role="region"
|
|
234
247
|
aria-labelledby={`${id}-trigger`}
|
|
235
|
-
hidden={
|
|
248
|
+
aria-hidden={open ? undefined : true}
|
|
249
|
+
hidden={!mounted}
|
|
236
250
|
className={cn(
|
|
237
|
-
// No display utility while
|
|
251
|
+
// No display utility while unmounted: author styles would beat the
|
|
238
252
|
// UA [hidden] rule and keep the collapsed panel visible.
|
|
239
|
-
|
|
253
|
+
mounted &&
|
|
240
254
|
cn(
|
|
241
|
-
'grid transition-[grid-template-rows] duration-
|
|
242
|
-
expanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]'
|
|
255
|
+
'grid transition-[grid-template-rows,opacity] duration-300 ease-out motion-reduce:transition-none',
|
|
256
|
+
expanded ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] pointer-events-none opacity-0'
|
|
243
257
|
),
|
|
244
|
-
!open && 'grid-rows-[0fr]',
|
|
245
258
|
className
|
|
246
259
|
)}
|
|
247
260
|
{...props}
|
|
@@ -24,7 +24,7 @@ const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
|
|
|
24
24
|
onChange?.(event);
|
|
25
25
|
}}
|
|
26
26
|
className={cn(
|
|
27
|
-
'peer h-4 w-4 shrink-0 rounded-sm border border-primary',
|
|
27
|
+
'peer h-4 w-4 shrink-0 rounded-sm border border-primary accent-primary',
|
|
28
28
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
29
29
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
30
30
|
'checked:bg-primary checked:text-primary-foreground',
|
|
@@ -67,6 +67,18 @@ describe('Drawer', () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
describe('Drawer animate (optional slide)', () => {
|
|
70
|
+
it('dims the backdrop so content never flashes through on close', () => {
|
|
71
|
+
render(
|
|
72
|
+
<Drawer open animate onOpenChange={vi.fn()} title="Sliding" side="right">
|
|
73
|
+
body
|
|
74
|
+
</Drawer>
|
|
75
|
+
);
|
|
76
|
+
const backdrop = document.body.querySelector('.fixed.inset-0');
|
|
77
|
+
expect(backdrop).toHaveClass('bg-background/80');
|
|
78
|
+
expect(backdrop).toHaveClass('animate-in');
|
|
79
|
+
expect(backdrop?.className).toContain('fade-in-0');
|
|
80
|
+
});
|
|
81
|
+
|
|
70
82
|
it('applies side-aware slide-in classes when animate is on', () => {
|
|
71
83
|
render(
|
|
72
84
|
<Drawer open animate onOpenChange={vi.fn()} title="Sliding" side="left">
|
|
@@ -306,9 +306,16 @@ export function Drawer({
|
|
|
306
306
|
)
|
|
307
307
|
: undefined;
|
|
308
308
|
|
|
309
|
+
// The backdrop dims and fades with the panel. Without it the page showed
|
|
310
|
+
// through at full brightness while the drawer slid out, which read as a
|
|
311
|
+
// content flash during close.
|
|
312
|
+
const backdropMotion = animate
|
|
313
|
+
? cn('motion-reduce:animate-none', exiting ? 'animate-out fade-out-0' : 'animate-in fade-in-0')
|
|
314
|
+
: undefined;
|
|
315
|
+
|
|
309
316
|
return createPortal(
|
|
310
317
|
<div
|
|
311
|
-
className=
|
|
318
|
+
className={cn('fixed inset-0 z-50 bg-background/80', backdropMotion)}
|
|
312
319
|
onMouseDown={(event) => {
|
|
313
320
|
if (closeOnBackdrop && event.target === event.currentTarget) requestClose();
|
|
314
321
|
}}
|
|
@@ -19,6 +19,17 @@ describe('FilterChips', () => {
|
|
|
19
19
|
expect(onRemove).toHaveBeenCalled();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
it('scales the chip set with size', () => {
|
|
23
|
+
const { rerender, container } = render(
|
|
24
|
+
<FilterChips size="sm" filters={[{ key: 'type', label: 'Type', value: 'PE' }]} />
|
|
25
|
+
);
|
|
26
|
+
expect(container.querySelector('span.text-xs')).not.toBeNull();
|
|
27
|
+
rerender(
|
|
28
|
+
<FilterChips size="lg" filters={[{ key: 'type', label: 'Type', value: 'PE' }]} />
|
|
29
|
+
);
|
|
30
|
+
expect(container.querySelector('span.text-base')).not.toBeNull();
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
it('renders a clear-all action', () => {
|
|
23
34
|
const onClearAll = vi.fn();
|
|
24
35
|
render(
|
|
@@ -17,6 +17,8 @@ export type FilterChip = {
|
|
|
17
17
|
export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
18
18
|
/** Active filters to render. */
|
|
19
19
|
filters: FilterChip[];
|
|
20
|
+
/** Chip scale. Default 'md'. */
|
|
21
|
+
size?: 'sm' | 'md' | 'lg';
|
|
20
22
|
/** Shows a clear-all action when provided. */
|
|
21
23
|
onClearAll?: () => void;
|
|
22
24
|
/** Label for the clear-all action. Default "Clear all". */
|
|
@@ -25,6 +27,28 @@ export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
25
27
|
emptyLabel?: string;
|
|
26
28
|
};
|
|
27
29
|
|
|
30
|
+
/** Literal size maps so the scanner keeps every chip utility. */
|
|
31
|
+
const CHIP_SIZES = {
|
|
32
|
+
sm: {
|
|
33
|
+
chip: 'gap-1 py-0.5 pl-2.5 pr-0.5 text-xs',
|
|
34
|
+
remove: 'p-0.5',
|
|
35
|
+
icon: 'h-3 w-3',
|
|
36
|
+
clear: 'text-xs',
|
|
37
|
+
},
|
|
38
|
+
md: {
|
|
39
|
+
chip: 'gap-1.5 py-1 pl-3 pr-1 text-sm',
|
|
40
|
+
remove: 'p-1',
|
|
41
|
+
icon: 'h-3.5 w-3.5',
|
|
42
|
+
clear: 'text-sm',
|
|
43
|
+
},
|
|
44
|
+
lg: {
|
|
45
|
+
chip: 'gap-2 py-1.5 pl-3.5 pr-1.5 text-base',
|
|
46
|
+
remove: 'p-1.5',
|
|
47
|
+
icon: 'h-4 w-4',
|
|
48
|
+
clear: 'text-base',
|
|
49
|
+
},
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
28
52
|
/**
|
|
29
53
|
* Active-filter summary for list and dashboard pages. Each chip pairs a
|
|
30
54
|
* filter name with its current value and exposes a remove action; an optional
|
|
@@ -34,6 +58,7 @@ export type FilterChipsProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
34
58
|
export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(function FilterChips(
|
|
35
59
|
{
|
|
36
60
|
filters,
|
|
61
|
+
size = 'md',
|
|
37
62
|
onClearAll,
|
|
38
63
|
clearLabel = 'Clear all',
|
|
39
64
|
emptyLabel,
|
|
@@ -51,6 +76,8 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
51
76
|
) : null;
|
|
52
77
|
}
|
|
53
78
|
|
|
79
|
+
const scale = CHIP_SIZES[size];
|
|
80
|
+
|
|
54
81
|
return (
|
|
55
82
|
<div
|
|
56
83
|
ref={ref}
|
|
@@ -62,7 +89,10 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
62
89
|
{filters.map((filter) => (
|
|
63
90
|
<span
|
|
64
91
|
key={filter.key}
|
|
65
|
-
className=
|
|
92
|
+
className={cn(
|
|
93
|
+
'inline-flex max-w-full items-center rounded-full border border-border bg-muted/60',
|
|
94
|
+
scale.chip
|
|
95
|
+
)}
|
|
66
96
|
>
|
|
67
97
|
<span className="truncate">
|
|
68
98
|
<span className="text-muted-foreground">{filter.label}:</span>{' '}
|
|
@@ -73,9 +103,12 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
73
103
|
type="button"
|
|
74
104
|
onClick={filter.onRemove}
|
|
75
105
|
aria-label={`Remove ${filter.label}${filter.value ? `: ${filter.value}` : ''}`}
|
|
76
|
-
className=
|
|
106
|
+
className={cn(
|
|
107
|
+
'rounded-full text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
108
|
+
scale.remove
|
|
109
|
+
)}
|
|
77
110
|
>
|
|
78
|
-
<svg aria-hidden="true" viewBox="0 0 20 20" className=
|
|
111
|
+
<svg aria-hidden="true" viewBox="0 0 20 20" className={scale.icon} fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round">
|
|
79
112
|
<path d="m5 5 10 10M15 5 5 15" />
|
|
80
113
|
</svg>
|
|
81
114
|
</button>
|
|
@@ -86,7 +119,10 @@ export const FilterChips = React.forwardRef<HTMLDivElement, FilterChipsProps>(fu
|
|
|
86
119
|
<button
|
|
87
120
|
type="button"
|
|
88
121
|
onClick={onClearAll}
|
|
89
|
-
className=
|
|
122
|
+
className={cn(
|
|
123
|
+
'rounded-sm px-1 font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
124
|
+
scale.clear
|
|
125
|
+
)}
|
|
90
126
|
>
|
|
91
127
|
{clearLabel}
|
|
92
128
|
</button>
|
|
@@ -26,7 +26,7 @@ const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
|
|
|
26
26
|
onChange?.(event);
|
|
27
27
|
}}
|
|
28
28
|
className={cn(
|
|
29
|
-
'h-4 w-4 shrink-0 rounded-full border border-primary',
|
|
29
|
+
'h-4 w-4 shrink-0 rounded-full border border-primary accent-primary',
|
|
30
30
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
31
31
|
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
32
32
|
'checked:bg-primary checked:text-primary-foreground',
|
|
@@ -34,9 +34,9 @@ export type RangeSliderProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onCha
|
|
|
34
34
|
const rangeInputClass = cn(
|
|
35
35
|
'pointer-events-none absolute inset-x-0 top-1/2 h-6 w-full -translate-y-1/2 appearance-none bg-transparent',
|
|
36
36
|
'[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-transparent',
|
|
37
|
-
'[&::-webkit-slider-thumb]:pointer-events-auto [&::-webkit-slider-thumb]:mt-[-6px] [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-
|
|
37
|
+
'[&::-webkit-slider-thumb]:pointer-events-auto [&::-webkit-slider-thumb]:mt-[-6px] [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:cursor-grab [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-background [&::-webkit-slider-thumb]:bg-primary [&::-webkit-slider-thumb]:shadow-md',
|
|
38
38
|
'[&::-moz-range-track]:h-1 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-transparent',
|
|
39
|
-
'[&::-moz-range-thumb]:pointer-events-auto [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:cursor-grab [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-
|
|
39
|
+
'[&::-moz-range-thumb]:pointer-events-auto [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:cursor-grab [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-background [&::-moz-range-thumb]:bg-primary [&::-moz-range-thumb]:shadow-md',
|
|
40
40
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
41
41
|
'disabled:cursor-not-allowed disabled:opacity-50'
|
|
42
42
|
);
|
|
@@ -92,7 +92,7 @@ export const RangeSlider = React.forwardRef<HTMLDivElement, RangeSliderProps>(fu
|
|
|
92
92
|
</div>
|
|
93
93
|
)}
|
|
94
94
|
<div className="relative h-6 w-full">
|
|
95
|
-
<div className="absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-
|
|
95
|
+
<div className="absolute inset-x-0 top-1/2 h-1 -translate-y-1/2 rounded-full bg-border" />
|
|
96
96
|
<div
|
|
97
97
|
className="absolute top-1/2 h-1 -translate-y-1/2 rounded-full bg-primary"
|
|
98
98
|
style={{ left: `${lowPercent}%`, right: `${100 - highPercent}%` }}
|
|
@@ -20,6 +20,20 @@ describe('Select', () => {
|
|
|
20
20
|
expect(select).toBeInTheDocument();
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
it('can hide the label visually while keeping it accessible', () => {
|
|
24
|
+
render(
|
|
25
|
+
<Select
|
|
26
|
+
label="Status"
|
|
27
|
+
labelHidden
|
|
28
|
+
options={[{ value: 'all', label: 'All' }]}
|
|
29
|
+
defaultValue="all"
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
const label = screen.getByText('Status');
|
|
33
|
+
expect(label).toHaveClass('sr-only');
|
|
34
|
+
expect(screen.getByRole('combobox', { name: 'Status' })).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
23
37
|
it('supports uncontrolled defaultValue', () => {
|
|
24
38
|
render(<Select options={options} defaultValue="sm" aria-label="Size" />);
|
|
25
39
|
expect(screen.getByRole('combobox', { name: 'Size' })).toHaveValue('sm');
|
|
@@ -23,6 +23,11 @@ export type SelectProps = Omit<
|
|
|
23
23
|
/** Optgroups with a heading per section. Takes precedence over `options` and `children`. */
|
|
24
24
|
groups?: SelectOptionGroup[];
|
|
25
25
|
label?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Keep the label for assistive tech but hide it visually, so the control
|
|
28
|
+
* lines up with sibling inputs in a filter bar or toolbar.
|
|
29
|
+
*/
|
|
30
|
+
labelHidden?: boolean;
|
|
26
31
|
/** Renders a disabled empty option — the native "choose one" affordance. */
|
|
27
32
|
placeholder?: string;
|
|
28
33
|
/** Native multi-select: value/onChange switch to string[]. */
|
|
@@ -43,7 +48,7 @@ export type SelectProps = Omit<
|
|
|
43
48
|
* <option>/<optgroup> children for dynamic lists.
|
|
44
49
|
*/
|
|
45
50
|
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(function Select(
|
|
46
|
-
{ options, groups, label, placeholder, multiple = false, value, defaultValue, onChange, onValueChange, children, id, className, ...props },
|
|
51
|
+
{ options, groups, label, labelHidden = false, placeholder, multiple = false, value, defaultValue, onChange, onValueChange, children, id, className, ...props },
|
|
47
52
|
ref,
|
|
48
53
|
) {
|
|
49
54
|
const generatedId = React.useId();
|
|
@@ -59,7 +64,7 @@ export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(function
|
|
|
59
64
|
return (
|
|
60
65
|
<div className="flex w-full flex-col gap-1.5">
|
|
61
66
|
{label && (
|
|
62
|
-
<label id={labelId} htmlFor={selectId} className=
|
|
67
|
+
<label id={labelId} htmlFor={selectId} className={labelHidden ? 'sr-only' : 'text-sm font-medium'}>
|
|
63
68
|
{label}
|
|
64
69
|
</label>
|
|
65
70
|
)}
|
|
@@ -19,6 +19,17 @@ describe('Timeline', () => {
|
|
|
19
19
|
expect(screen.getByText('Platform team')).toBeInTheDocument();
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
it('draws one connector rail per item except the last', () => {
|
|
23
|
+
const { container } = render(
|
|
24
|
+
<Timeline items={[{ title: 'One' }, { title: 'Two' }, { title: 'Three' }]} />
|
|
25
|
+
);
|
|
26
|
+
const rails = container.querySelectorAll('li > span[aria-hidden="true"]');
|
|
27
|
+
expect(rails).toHaveLength(2);
|
|
28
|
+
// The rail spans from the dot's lower edge into the next item's dot.
|
|
29
|
+
expect(rails[0]).toHaveClass('top-4');
|
|
30
|
+
expect(rails[0]).toHaveClass('-bottom-7');
|
|
31
|
+
});
|
|
32
|
+
|
|
22
33
|
it('has no accessibility violations', async () => {
|
|
23
34
|
const { container } = render(<Timeline items={[{ title: 'Started' }]} />);
|
|
24
35
|
expect(await axe(container)).toHaveNoViolations();
|
|
@@ -28,7 +28,19 @@ export const Timeline = React.forwardRef<HTMLOListElement, TimelineProps>(functi
|
|
|
28
28
|
<ol ref={ref} className={cn('relative flex flex-col gap-6', className)} {...props}>
|
|
29
29
|
{items.map((item, index) => (
|
|
30
30
|
<li key={`${item.title}-${index}`} className="relative flex gap-4">
|
|
31
|
-
|
|
31
|
+
{/*
|
|
32
|
+
One rail per item, absolutely positioned so it starts at the dot's
|
|
33
|
+
bottom edge and runs through the list gap into the next dot. A
|
|
34
|
+
flex-column connector stops at the item box, which left a visible
|
|
35
|
+
break at every item boundary.
|
|
36
|
+
*/}
|
|
37
|
+
{index < items.length - 1 && (
|
|
38
|
+
<span
|
|
39
|
+
aria-hidden="true"
|
|
40
|
+
className="absolute left-[5.5px] top-4 -bottom-7 w-px bg-border"
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
43
|
+
<div className="relative z-10 flex flex-col items-center">
|
|
32
44
|
<span
|
|
33
45
|
aria-hidden="true"
|
|
34
46
|
className={cn(
|
|
@@ -36,7 +48,6 @@ export const Timeline = React.forwardRef<HTMLOListElement, TimelineProps>(functi
|
|
|
36
48
|
item.muted ? 'border-border bg-background' : 'border-primary bg-primary'
|
|
37
49
|
)}
|
|
38
50
|
/>
|
|
39
|
-
{index < items.length - 1 && <span aria-hidden="true" className="mt-1 w-px flex-1 bg-border" />}
|
|
40
51
|
</div>
|
|
41
52
|
<div className="min-w-0 pb-1">
|
|
42
53
|
{item.period && (
|
|
@@ -18,6 +18,21 @@ describe('Tooltip', () => {
|
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
it('renders the inverse palette on request', async () => {
|
|
22
|
+
const user = userEvent.setup();
|
|
23
|
+
render(
|
|
24
|
+
<Tooltip content="Dark bubble" delay={0} variant="inverse">
|
|
25
|
+
<button>Hover me</button>
|
|
26
|
+
</Tooltip>
|
|
27
|
+
);
|
|
28
|
+
await user.hover(screen.getByRole('button'));
|
|
29
|
+
await waitFor(() => {
|
|
30
|
+
const bubble = screen.getByRole('tooltip');
|
|
31
|
+
expect(bubble).toHaveClass('bg-inverse');
|
|
32
|
+
expect(bubble).toHaveClass('text-inverse-foreground');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
21
36
|
it('hides the tooltip on unhover', async () => {
|
|
22
37
|
const user = userEvent.setup();
|
|
23
38
|
render(
|
|
@@ -11,6 +11,11 @@ export type TooltipProps = {
|
|
|
11
11
|
side?: 'top' | 'bottom' | 'left' | 'right';
|
|
12
12
|
/** Delay before showing on hover, in milliseconds. */
|
|
13
13
|
delay?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Bubble palette. `default` uses the popover surface; `inverse` flips the
|
|
16
|
+
* surface (dark bubble in light mode, light bubble in dark mode).
|
|
17
|
+
*/
|
|
18
|
+
variant?: 'default' | 'inverse';
|
|
14
19
|
className?: string;
|
|
15
20
|
/** A single focusable element; receives aria-describedby when open. */
|
|
16
21
|
children: React.ReactElement;
|
|
@@ -20,6 +25,15 @@ type Position = { top: number; left: number; transform: string };
|
|
|
20
25
|
|
|
21
26
|
const GAP = 8;
|
|
22
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Literal class maps so the Tailwind scanner keeps both palettes. `inverse`
|
|
30
|
+
* reuses the inverse surface tokens: navy in light mode, white in dark mode.
|
|
31
|
+
*/
|
|
32
|
+
const VARIANTS: Record<NonNullable<TooltipProps['variant']>, string> = {
|
|
33
|
+
default: 'border-border bg-popover text-popover-foreground',
|
|
34
|
+
inverse: 'border-inverse-border bg-inverse text-inverse-foreground',
|
|
35
|
+
};
|
|
36
|
+
|
|
23
37
|
/**
|
|
24
38
|
* Hover/focus tooltip built on aria-describedby. Shows on pointer
|
|
25
39
|
* hover and keyboard focus (not click), dismisses on Escape, and
|
|
@@ -30,7 +44,7 @@ const GAP = 8;
|
|
|
30
44
|
* scroll the container (the reported "tooltip causes scroll" bug).
|
|
31
45
|
*/
|
|
32
46
|
const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
|
|
33
|
-
({ content, side = 'top', delay = 300, className, children }, ref) => {
|
|
47
|
+
({ content, side = 'top', delay = 300, variant = 'default', className, children }, ref) => {
|
|
34
48
|
const [open, setOpen] = React.useState(false);
|
|
35
49
|
const [pos, setPos] = React.useState<Position | null>(null);
|
|
36
50
|
const anchorRef = React.useRef<HTMLDivElement | null>(null);
|
|
@@ -113,7 +127,10 @@ const Tooltip = React.forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
113
127
|
id={id}
|
|
114
128
|
role="tooltip"
|
|
115
129
|
style={{ position: 'fixed', top: pos.top, left: pos.left, transform: pos.transform, zIndex: 60 }}
|
|
116
|
-
className=
|
|
130
|
+
className={cn(
|
|
131
|
+
'pointer-events-none w-max max-w-xs rounded-md border px-3 py-1.5 text-xs shadow-md',
|
|
132
|
+
VARIANTS[variant]
|
|
133
|
+
)}
|
|
117
134
|
>
|
|
118
135
|
{content}
|
|
119
136
|
</div>,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.10.0",
|
|
8
8
|
"sourceDir": "announcement-bar",
|
|
9
9
|
"exportName": "AnnouncementBar",
|
|
10
10
|
"description": "Dismissible announcement bar with optional action, tone and sticky positioning.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.10.0",
|
|
8
8
|
"sourceDir": "applied-filters",
|
|
9
9
|
"exportName": "AppliedFilters",
|
|
10
10
|
"description": "Applied-filter summary with a live count, removable chips and an edit action.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.10.0",
|
|
8
8
|
"sourceDir": "article-card",
|
|
9
9
|
"exportName": "ArticleCard",
|
|
10
10
|
"description": "Linked article or resource card with media, eyebrow, title, summary and metadata.",
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"tier": "molecule",
|
|
5
5
|
"package": "@slipstream-ui/core",
|
|
6
6
|
"importPath": "@slipstream-ui/core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.10.0",
|
|
8
8
|
"sourceDir": "comparison-table",
|
|
9
9
|
"exportName": "ComparisonTable",
|
|
10
10
|
"description": "Marketing comparison table with check/dash boolean cells, a highlighted column and responsive overflow.",
|