@slipstream-ui/core 0.12.1 → 0.14.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 +208 -4
- package/dist/index.d.ts +208 -4
- package/dist/index.js +471 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +463 -11
- 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/consent-banner.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cover-image.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/figure.manifest.json +105 -0
- 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 +1 -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/icon-button.manifest.json +101 -0
- package/dist/manifests/icon-tile.manifest.json +107 -0
- package/dist/manifests/icon.manifest.json +119 -0
- 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-toolbar.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/media-card.manifest.json +1 -1
- package/dist/manifests/media.manifest.json +142 -0
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/month-schedule.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 +1 -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/social-links.manifest.json +120 -0
- 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 +49 -6
- 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 +1 -1
- package/dist/src/components/figure/Figure.d.ts +23 -0
- package/dist/src/components/figure/Figure.js +60 -0
- package/dist/src/components/figure/Figure.js.map +1 -0
- package/dist/src/components/figure/Figure.mjs +26 -0
- package/dist/src/components/figure/Figure.mjs.map +1 -0
- package/dist/src/components/figure/index.d.ts +2 -0
- package/dist/src/components/figure/index.js +29 -0
- package/dist/src/components/figure/index.js.map +1 -0
- package/dist/src/components/figure/index.mjs +5 -0
- package/dist/src/components/figure/index.mjs.map +1 -0
- package/dist/src/components/icon/Icon.d.ts +33 -0
- package/dist/src/components/icon/Icon.js +82 -0
- package/dist/src/components/icon/Icon.js.map +1 -0
- package/dist/src/components/icon/Icon.mjs +47 -0
- package/dist/src/components/icon/Icon.mjs.map +1 -0
- package/dist/src/components/icon/index.d.ts +2 -0
- package/dist/src/components/icon/index.js +31 -0
- package/dist/src/components/icon/index.js.map +1 -0
- package/dist/src/components/icon/index.mjs +6 -0
- package/dist/src/components/icon/index.mjs.map +1 -0
- package/dist/src/components/icon-button/IconButton.d.ts +25 -0
- package/dist/src/components/icon-button/IconButton.js +60 -0
- package/dist/src/components/icon-button/IconButton.js.map +1 -0
- package/dist/src/components/icon-button/IconButton.mjs +26 -0
- package/dist/src/components/icon-button/IconButton.mjs.map +1 -0
- package/dist/src/components/icon-button/index.d.ts +2 -0
- package/dist/src/components/icon-button/index.js +29 -0
- package/dist/src/components/icon-button/index.js.map +1 -0
- package/dist/src/components/icon-button/index.mjs +5 -0
- package/dist/src/components/icon-button/index.mjs.map +1 -0
- package/dist/src/components/icon-tile/IconTile.d.ts +23 -0
- package/dist/src/components/icon-tile/IconTile.js +75 -0
- package/dist/src/components/icon-tile/IconTile.js.map +1 -0
- package/dist/src/components/icon-tile/IconTile.mjs +40 -0
- package/dist/src/components/icon-tile/IconTile.mjs.map +1 -0
- package/dist/src/components/icon-tile/index.d.ts +2 -0
- package/dist/src/components/icon-tile/index.js +31 -0
- package/dist/src/components/icon-tile/index.js.map +1 -0
- package/dist/src/components/icon-tile/index.mjs +6 -0
- package/dist/src/components/icon-tile/index.mjs.map +1 -0
- package/dist/src/components/media/Media.d.ts +48 -0
- package/dist/src/components/media/Media.js +97 -0
- package/dist/src/components/media/Media.js.map +1 -0
- package/dist/src/components/media/Media.mjs +63 -0
- package/dist/src/components/media/Media.mjs.map +1 -0
- package/dist/src/components/media/index.d.ts +2 -0
- package/dist/src/components/media/index.js +29 -0
- package/dist/src/components/media/index.js.map +1 -0
- package/dist/src/components/media/index.mjs +5 -0
- package/dist/src/components/media/index.mjs.map +1 -0
- package/dist/src/components/social-links/SocialLinks.d.ts +34 -0
- package/dist/src/components/social-links/SocialLinks.js +69 -0
- package/dist/src/components/social-links/SocialLinks.js.map +1 -0
- package/dist/src/components/social-links/SocialLinks.mjs +35 -0
- package/dist/src/components/social-links/SocialLinks.mjs.map +1 -0
- package/dist/src/components/social-links/index.d.ts +2 -0
- package/dist/src/components/social-links/index.js +29 -0
- package/dist/src/components/social-links/index.js.map +1 -0
- package/dist/src/components/social-links/index.mjs +5 -0
- package/dist/src/components/social-links/index.mjs.map +1 -0
- package/dist/src/components/time-picker/TimePicker.d.ts +31 -2
- package/dist/src/components/time-picker/TimePicker.js +244 -11
- package/dist/src/components/time-picker/TimePicker.js.map +1 -1
- package/dist/src/components/time-picker/TimePicker.mjs +244 -11
- package/dist/src/components/time-picker/TimePicker.mjs.map +1 -1
- package/dist/src/index.d.ts +6 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/src/components/figure/Figure.test.tsx +54 -0
- package/src/components/figure/Figure.tsx +38 -0
- package/src/components/figure/index.ts +2 -0
- package/src/components/icon/Icon.test.tsx +70 -0
- package/src/components/icon/Icon.tsx +61 -0
- package/src/components/icon/index.ts +2 -0
- package/src/components/icon-button/IconButton.test.tsx +76 -0
- package/src/components/icon-button/IconButton.tsx +38 -0
- package/src/components/icon-button/index.ts +2 -0
- package/src/components/icon-tile/IconTile.test.tsx +63 -0
- package/src/components/icon-tile/IconTile.tsx +55 -0
- package/src/components/icon-tile/index.ts +2 -0
- package/src/components/media/Media.test.tsx +53 -0
- package/src/components/media/Media.tsx +92 -0
- package/src/components/media/index.ts +2 -0
- package/src/components/social-links/SocialLinks.test.tsx +59 -0
- package/src/components/social-links/SocialLinks.tsx +73 -0
- package/src/components/social-links/index.ts +2 -0
- package/src/components/time-picker/TimePicker.test.tsx +77 -0
- package/src/components/time-picker/TimePicker.tsx +315 -12
- package/src/index.ts +6 -0
- 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/consent-banner.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cover-image.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/figure.manifest.json +105 -0
- 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 +1 -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/icon-button.manifest.json +101 -0
- package/src/manifests/icon-tile.manifest.json +107 -0
- package/src/manifests/icon.manifest.json +119 -0
- 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-toolbar.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/media-card.manifest.json +1 -1
- package/src/manifests/media.manifest.json +142 -0
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/month-schedule.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 +1 -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/social-links.manifest.json +120 -0
- 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 +49 -6
- 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 +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { axe } from 'jest-axe';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { SocialLinks } from './SocialLinks';
|
|
5
|
+
|
|
6
|
+
const GithubIcon = (props: React.SVGProps<SVGSVGElement>) => (
|
|
7
|
+
<svg data-testid="github-icon" viewBox="0 0 24 24" {...props} />
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
describe('SocialLinks', () => {
|
|
11
|
+
it('renders a labelled navigation landmark', () => {
|
|
12
|
+
render(<SocialLinks links={[{ href: 'https://github.com/acme', label: 'GitHub' }]} />);
|
|
13
|
+
expect(screen.getByRole('navigation', { name: 'Social links' })).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('names each destination and applies safe external attributes', () => {
|
|
17
|
+
render(
|
|
18
|
+
<SocialLinks
|
|
19
|
+
links={[
|
|
20
|
+
{ href: 'https://github.com/acme', label: 'GitHub', icon: GithubIcon },
|
|
21
|
+
{ href: 'https://x.com/acme', label: 'X profile' },
|
|
22
|
+
]}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
const github = screen.getByRole('link', { name: 'GitHub' });
|
|
26
|
+
expect(github).toHaveAttribute('href', 'https://github.com/acme');
|
|
27
|
+
expect(github).toHaveAttribute('target', '_blank');
|
|
28
|
+
expect(github).toHaveAttribute('rel', expect.stringContaining('noopener'));
|
|
29
|
+
expect(screen.getByRole('link', { name: 'X profile' })).toHaveTextContent('X profile');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('renders icon components through Icon sizing', () => {
|
|
33
|
+
render(
|
|
34
|
+
<SocialLinks iconSize="lg" iconTone="primary" links={[{ href: 'https://a.dev', label: 'A', icon: GithubIcon }]} />
|
|
35
|
+
);
|
|
36
|
+
expect(screen.getByTestId('github-icon')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByRole('link', { name: 'A' }).querySelector('span')).toHaveClass('text-primary-ink');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('accepts a custom landmark label', () => {
|
|
41
|
+
render(
|
|
42
|
+
<SocialLinks label="Follow the studio" links={[{ href: 'https://a.dev', label: 'Site' }]} />
|
|
43
|
+
);
|
|
44
|
+
expect(screen.getByRole('navigation', { name: 'Follow the studio' })).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('has no accessibility violations', async () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<SocialLinks
|
|
50
|
+
label="Studio socials"
|
|
51
|
+
links={[
|
|
52
|
+
{ href: 'https://github.com/acme', label: 'GitHub', icon: GithubIcon },
|
|
53
|
+
{ href: 'https://x.com/acme', label: 'X' },
|
|
54
|
+
]}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { Icon, type IconProps } from '../icon/Icon';
|
|
4
|
+
|
|
5
|
+
export type SocialLink = {
|
|
6
|
+
/** Destination URL. Rendered with safe external-link attributes. */
|
|
7
|
+
href: string;
|
|
8
|
+
/** Accessible name for the destination (e.g. "GitHub"). */
|
|
9
|
+
label: string;
|
|
10
|
+
/** Optional icon element or component rendered inside the link. */
|
|
11
|
+
icon?: React.ReactElement | React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type SocialLinksProps = React.HTMLAttributes<HTMLElement> & {
|
|
15
|
+
links: SocialLink[];
|
|
16
|
+
/** Accessible name for the navigation landmark (default "Social links"). */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** Icon size passed through to Icon (default 'md'). */
|
|
19
|
+
iconSize?: IconProps['size'];
|
|
20
|
+
/** Icon tone (default 'muted'). */
|
|
21
|
+
iconTone?: IconProps['tone'];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function isElement(icon: SocialLink['icon']): icon is React.ReactElement {
|
|
25
|
+
return React.isValidElement(icon);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Row of outbound social/profile links. Every destination is named via
|
|
30
|
+
* `aria-label`, external links get `target="_blank" rel="noopener noreferrer"`,
|
|
31
|
+
* and icon-only links stay accessible because the label is always applied.
|
|
32
|
+
*/
|
|
33
|
+
const SocialLinks = React.forwardRef<HTMLElement, SocialLinksProps>(
|
|
34
|
+
({ className, links, label = 'Social links', iconSize = 'md', iconTone = 'muted', ...props }, ref) => (
|
|
35
|
+
<nav ref={ref} aria-label={label} className={cn('flex items-center gap-1', className)} {...props}>
|
|
36
|
+
<ul className="flex items-center gap-1">
|
|
37
|
+
{links.map((link) => (
|
|
38
|
+
<li key={link.href}>
|
|
39
|
+
<a
|
|
40
|
+
href={link.href}
|
|
41
|
+
target="_blank"
|
|
42
|
+
rel="noopener noreferrer"
|
|
43
|
+
aria-label={link.icon ? link.label : undefined}
|
|
44
|
+
className={cn(
|
|
45
|
+
'inline-flex items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
46
|
+
link.icon ? 'h-9 w-9' : 'px-3 py-1.5 text-sm'
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
{link.icon ? (
|
|
50
|
+
isElement(link.icon) ? (
|
|
51
|
+
<Icon size={iconSize} tone={iconTone}>
|
|
52
|
+
{link.icon}
|
|
53
|
+
</Icon>
|
|
54
|
+
) : (
|
|
55
|
+
<Icon
|
|
56
|
+
size={iconSize}
|
|
57
|
+
tone={iconTone}
|
|
58
|
+
icon={link.icon as React.ComponentType<React.SVGProps<SVGSVGElement>>}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
) : (
|
|
62
|
+
link.label
|
|
63
|
+
)}
|
|
64
|
+
</a>
|
|
65
|
+
</li>
|
|
66
|
+
))}
|
|
67
|
+
</ul>
|
|
68
|
+
</nav>
|
|
69
|
+
)
|
|
70
|
+
);
|
|
71
|
+
SocialLinks.displayName = 'SocialLinks';
|
|
72
|
+
|
|
73
|
+
export { SocialLinks };
|
|
@@ -35,3 +35,80 @@ describe('localized labels', () => {
|
|
|
35
35
|
expect(screen.getByRole('button', { name: "Effacer l'heure" })).toBeInTheDocument();
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
describe('12h format', () => {
|
|
40
|
+
it('renders a trigger showing the formatted time', () => {
|
|
41
|
+
render(<TimePicker aria-label="Starts at" format="12h" defaultValue="21:30" />);
|
|
42
|
+
expect(screen.getByRole('button', { name: 'Starts at' })).toHaveTextContent('9:30 PM');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('shows the placeholder when empty', () => {
|
|
46
|
+
render(<TimePicker aria-label="Starts at" format="12h" />);
|
|
47
|
+
expect(screen.getByRole('button', { name: 'Starts at' })).toHaveTextContent('Pick a time');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('commits HH:MM when the period changes', async () => {
|
|
51
|
+
const user = userEvent.setup();
|
|
52
|
+
const onValueChange = vi.fn();
|
|
53
|
+
render(<TimePicker aria-label="Starts at" format="12h" defaultValue="09:30" onValueChange={onValueChange} />);
|
|
54
|
+
await user.click(screen.getByRole('button', { name: 'Starts at' }));
|
|
55
|
+
await user.selectOptions(screen.getByLabelText('AM or PM'), 'PM');
|
|
56
|
+
expect(onValueChange).toHaveBeenCalledWith('21:30');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('commits HH:MM when the hour changes', async () => {
|
|
60
|
+
const user = userEvent.setup();
|
|
61
|
+
const onValueChange = vi.fn();
|
|
62
|
+
render(<TimePicker aria-label="Starts at" format="12h" defaultValue="09:30" onValueChange={onValueChange} />);
|
|
63
|
+
await user.click(screen.getByRole('button', { name: 'Starts at' }));
|
|
64
|
+
await user.selectOptions(screen.getByLabelText('Hour'), '5');
|
|
65
|
+
expect(onValueChange).toHaveBeenCalledWith('05:30');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('limits minute options by minuteStep', async () => {
|
|
69
|
+
const user = userEvent.setup();
|
|
70
|
+
render(<TimePicker aria-label="Starts at" format="12h" defaultValue="09:30" minuteStep={15} />);
|
|
71
|
+
await user.click(screen.getByRole('button', { name: 'Starts at' }));
|
|
72
|
+
const minute = screen.getByLabelText('Minute') as HTMLSelectElement;
|
|
73
|
+
const values = Array.from(minute.options).map((o) => o.value);
|
|
74
|
+
expect(values).toEqual(['0', '15', '30', '45']);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('disables out-of-range hours under min/max', async () => {
|
|
78
|
+
const user = userEvent.setup();
|
|
79
|
+
render(
|
|
80
|
+
<TimePicker aria-label="Starts at" format="12h" min="13:00" max="17:00" defaultValue="14:00" />
|
|
81
|
+
);
|
|
82
|
+
await user.click(screen.getByRole('button', { name: 'Starts at' }));
|
|
83
|
+
const hour = screen.getByLabelText('Hour') as HTMLSelectElement;
|
|
84
|
+
// Draft period is PM (14:00): 9 PM–12 PM? No — hours map 1–12 onto
|
|
85
|
+
// 13:00–23:59. 9 PM (21:00) and 12 PM (12:00) are out of range;
|
|
86
|
+
// 5 PM (17:00, minute 0 only) is the last enabled hour.
|
|
87
|
+
expect(hour.options[8]).toBeDisabled(); // value "9" -> 21:00
|
|
88
|
+
expect(hour.options[11]).toBeDisabled(); // value "12" -> 12:00
|
|
89
|
+
expect(hour.options[4]).not.toBeDisabled(); // value "5" -> 17:00
|
|
90
|
+
expect(hour.options[5]).toBeDisabled(); // value "6" -> 18:00
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('clears the value in 12h mode', async () => {
|
|
94
|
+
const user = userEvent.setup();
|
|
95
|
+
const onValueChange = vi.fn();
|
|
96
|
+
render(<TimePicker aria-label="Ends" format="12h" clearable defaultValue="17:00" onValueChange={onValueChange} />);
|
|
97
|
+
await user.click(screen.getByRole('button', { name: 'Clear time' }));
|
|
98
|
+
expect(onValueChange).toHaveBeenCalledWith('');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('renders a hidden input for native forms', () => {
|
|
102
|
+
const { container } = render(
|
|
103
|
+
<TimePicker aria-label="Starts at" format="12h" name="starts_at" defaultValue="21:30" />
|
|
104
|
+
);
|
|
105
|
+
const hidden = container.querySelector('input[type="hidden"]');
|
|
106
|
+
expect(hidden).toHaveAttribute('name', 'starts_at');
|
|
107
|
+
expect(hidden).toHaveValue('21:30');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('has no accessibility violations in 12h mode', async () => {
|
|
111
|
+
const { container } = render(<TimePicker aria-label="Time" format="12h" />);
|
|
112
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { cn } from '../../utils/cn';
|
|
5
5
|
import { Input, type InputProps } from '../input/Input';
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
7
|
+
import { Select } from '../select';
|
|
8
|
+
|
|
9
|
+
export type TimePickerFormat = '24h' | '12h';
|
|
6
10
|
|
|
7
11
|
export type TimePickerProps = Omit<InputProps, 'type' | 'value' | 'defaultValue'> & {
|
|
8
12
|
/** "HH:MM" (24h) — controlled. */
|
|
@@ -15,30 +19,171 @@ export type TimePickerProps = Omit<InputProps, 'type' | 'value' | 'defaultValue'
|
|
|
15
19
|
clearable?: boolean;
|
|
16
20
|
/** Accessible label for the clear button. Default 'Clear time'. */
|
|
17
21
|
clearLabel?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Display contract. '24h' (default) renders the native time input.
|
|
24
|
+
* '12h' renders a button trigger with an hour/minute/AM-PM panel because
|
|
25
|
+
* input[type=time] cannot show AM/PM portably. Both emit "HH:MM".
|
|
26
|
+
*/
|
|
27
|
+
format?: TimePickerFormat;
|
|
28
|
+
/** Minute granularity for the panel options and the native input step. Default 1. */
|
|
29
|
+
minuteStep?: number;
|
|
30
|
+
/** Earliest selectable time, "HH:MM" inclusive. */
|
|
31
|
+
min?: string;
|
|
32
|
+
/** Latest selectable time, "HH:MM" inclusive. */
|
|
33
|
+
max?: string;
|
|
34
|
+
/** Text shown before a time is chosen (12h mode). */
|
|
35
|
+
placeholder?: string;
|
|
18
36
|
};
|
|
19
37
|
|
|
38
|
+
const pad = (n: number) => String(n).padStart(2, '0');
|
|
39
|
+
|
|
40
|
+
/** "HH:MM" -> minutes since midnight, or null when malformed. */
|
|
41
|
+
function toMinutes(value: string | undefined): number | null {
|
|
42
|
+
if (!value) return null;
|
|
43
|
+
const match = /^(\d{1,2}):(\d{2})/.exec(value.trim());
|
|
44
|
+
if (!match) return null;
|
|
45
|
+
const minutes = Number(match[1]) * 60 + Number(match[2]);
|
|
46
|
+
return minutes >= 0 && minutes <= 1439 ? minutes : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function fromMinutes(total: number): string {
|
|
50
|
+
return `${pad(Math.floor(total / 60))}:${pad(total % 60)}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** All stepped minute-of-hour values. */
|
|
54
|
+
function minuteChoices(step: number): number[] {
|
|
55
|
+
const out: number[] = [];
|
|
56
|
+
for (let m = 0; m < 60; m += step) out.push(m);
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
20
60
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
61
|
+
* Minutes-of-hour values that keep `hour24:minute` inside [minBound, maxBound].
|
|
62
|
+
* hour24 is the 24-hour hour the candidate belongs to.
|
|
63
|
+
*/
|
|
64
|
+
function allowedMinutes(hour24: number, minBound: number, maxBound: number, step: number): number[] {
|
|
65
|
+
const base = hour24 * 60;
|
|
66
|
+
return minuteChoices(step).filter((m) => {
|
|
67
|
+
const total = base + m;
|
|
68
|
+
return total >= minBound && total <= maxBound;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Whether any stepped minute keeps `hour24` inside the bounds. */
|
|
73
|
+
function hourHasValidMinute(hour24: number, minBound: number, maxBound: number, step: number): boolean {
|
|
74
|
+
return allowedMinutes(hour24, minBound, maxBound, step).length > 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** "HH:MM" -> { hour12, minute, period } for the 12h panel. */
|
|
78
|
+
function to12(hour24: number, minute: number): { hour12: number; minute: number; period: 'AM' | 'PM' } {
|
|
79
|
+
const period = hour24 >= 12 ? 'PM' : 'AM';
|
|
80
|
+
const hour12 = hour24 % 12 === 0 ? 12 : hour24 % 12;
|
|
81
|
+
return { hour12, minute, period };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** { hour12, minute, period } -> minutes since midnight. */
|
|
85
|
+
function from12(hour12: number, minute: number, period: 'AM' | 'PM'): number {
|
|
86
|
+
const hour24 = (hour12 % 12) + (period === 'PM' ? 12 : 0);
|
|
87
|
+
return hour24 * 60 + minute;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** "21:30" -> "9:30 PM". */
|
|
91
|
+
function format12(value: string): string {
|
|
92
|
+
const total = toMinutes(value);
|
|
93
|
+
if (total === null) return '';
|
|
94
|
+
const { hour12, minute, period } = to12(Math.floor(total / 60), total % 60);
|
|
95
|
+
return `${hour12}:${pad(minute)} ${period}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const PERIODS = ['AM', 'PM'] as const;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Time field with an "HH:MM" contract. The 24h format is a native time input;
|
|
102
|
+
* the 12h format is a button trigger with an hour/minute/period panel.
|
|
23
103
|
*/
|
|
24
104
|
export const TimePicker = React.forwardRef<HTMLInputElement, TimePickerProps>(function TimePicker(
|
|
25
|
-
{
|
|
105
|
+
{
|
|
106
|
+
value,
|
|
107
|
+
defaultValue,
|
|
108
|
+
onValueChange,
|
|
109
|
+
onChange,
|
|
110
|
+
clearable = false,
|
|
111
|
+
clearLabel = 'Clear time',
|
|
112
|
+
format = '24h',
|
|
113
|
+
minuteStep = 1,
|
|
114
|
+
min,
|
|
115
|
+
max,
|
|
116
|
+
placeholder,
|
|
117
|
+
className,
|
|
118
|
+
name,
|
|
119
|
+
id,
|
|
120
|
+
disabled,
|
|
121
|
+
required,
|
|
122
|
+
'aria-label': ariaLabel,
|
|
123
|
+
'aria-describedby': ariaDescribedBy,
|
|
124
|
+
'aria-invalid': ariaInvalid,
|
|
125
|
+
...props
|
|
126
|
+
},
|
|
26
127
|
ref
|
|
27
128
|
) {
|
|
28
129
|
const [internal, setInternal] = React.useState(defaultValue ?? '');
|
|
29
130
|
const current = value ?? internal;
|
|
131
|
+
const step = Math.min(60, Math.max(1, Math.floor(minuteStep)));
|
|
30
132
|
|
|
31
133
|
const commit = (next: string) => {
|
|
32
134
|
if (value === undefined) setInternal(next);
|
|
33
135
|
onValueChange?.(next);
|
|
34
136
|
};
|
|
35
137
|
|
|
138
|
+
const clearButton = clearable && current ? (
|
|
139
|
+
<button
|
|
140
|
+
type="button"
|
|
141
|
+
onClick={() => commit('')}
|
|
142
|
+
aria-label={clearLabel}
|
|
143
|
+
className="absolute right-1.5 top-1/2 z-10 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
144
|
+
>
|
|
145
|
+
✕
|
|
146
|
+
</button>
|
|
147
|
+
) : null;
|
|
148
|
+
|
|
149
|
+
if (format === '12h') {
|
|
150
|
+
return (
|
|
151
|
+
<TimePicker12h
|
|
152
|
+
current={current}
|
|
153
|
+
commit={commit}
|
|
154
|
+
clearButton={clearButton}
|
|
155
|
+
step={step}
|
|
156
|
+
min={min}
|
|
157
|
+
max={max}
|
|
158
|
+
placeholder={placeholder ?? 'Pick a time'}
|
|
159
|
+
className={className}
|
|
160
|
+
name={name}
|
|
161
|
+
id={id}
|
|
162
|
+
disabled={disabled}
|
|
163
|
+
ariaLabel={ariaLabel}
|
|
164
|
+
ariaDescribedBy={ariaDescribedBy}
|
|
165
|
+
ariaInvalid={ariaInvalid}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
36
170
|
return (
|
|
37
171
|
<div className={cn('relative flex items-center', className)}>
|
|
38
172
|
<Input
|
|
39
173
|
ref={ref}
|
|
40
174
|
type="time"
|
|
41
175
|
value={current}
|
|
176
|
+
min={min}
|
|
177
|
+
max={max}
|
|
178
|
+
step={step * 60}
|
|
179
|
+
placeholder={placeholder}
|
|
180
|
+
name={name}
|
|
181
|
+
id={id}
|
|
182
|
+
disabled={disabled}
|
|
183
|
+
required={required}
|
|
184
|
+
aria-label={ariaLabel}
|
|
185
|
+
aria-describedby={ariaDescribedBy}
|
|
186
|
+
aria-invalid={ariaInvalid}
|
|
42
187
|
onChange={(event) => {
|
|
43
188
|
commit(event.target.value);
|
|
44
189
|
onChange?.(event);
|
|
@@ -46,16 +191,174 @@ export const TimePicker = React.forwardRef<HTMLInputElement, TimePickerProps>(fu
|
|
|
46
191
|
className={clearable && current ? 'pr-9' : undefined}
|
|
47
192
|
{...props}
|
|
48
193
|
/>
|
|
49
|
-
{
|
|
50
|
-
|
|
194
|
+
{clearButton}
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
TimePicker.displayName = 'TimePicker';
|
|
199
|
+
|
|
200
|
+
type TimePicker12hConfig = {
|
|
201
|
+
current: string;
|
|
202
|
+
commit: (value: string) => void;
|
|
203
|
+
clearButton: React.ReactNode;
|
|
204
|
+
step: number;
|
|
205
|
+
min?: string;
|
|
206
|
+
max?: string;
|
|
207
|
+
placeholder: string;
|
|
208
|
+
className?: string;
|
|
209
|
+
name?: string;
|
|
210
|
+
id?: string;
|
|
211
|
+
disabled?: boolean;
|
|
212
|
+
ariaLabel?: string;
|
|
213
|
+
ariaDescribedBy?: string;
|
|
214
|
+
ariaInvalid?: boolean | 'true' | 'false' | 'grammar' | 'spelling';
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
function TimePicker12h({
|
|
218
|
+
current,
|
|
219
|
+
commit,
|
|
220
|
+
clearButton,
|
|
221
|
+
step,
|
|
222
|
+
min,
|
|
223
|
+
max,
|
|
224
|
+
placeholder,
|
|
225
|
+
className,
|
|
226
|
+
name,
|
|
227
|
+
id,
|
|
228
|
+
disabled,
|
|
229
|
+
ariaLabel,
|
|
230
|
+
ariaDescribedBy,
|
|
231
|
+
ariaInvalid,
|
|
232
|
+
}: TimePicker12hConfig) {
|
|
233
|
+
const [open, setOpen] = React.useState(false);
|
|
234
|
+
|
|
235
|
+
const total = toMinutes(current);
|
|
236
|
+
const minBound = toMinutes(min) ?? 0;
|
|
237
|
+
const maxBound = toMinutes(max) ?? 1439;
|
|
238
|
+
|
|
239
|
+
// Draft selection derived from the committed value; falls back to the
|
|
240
|
+
// earliest in-range time so the panel always has a coherent selection.
|
|
241
|
+
const draft = React.useMemo(() => {
|
|
242
|
+
if (total !== null) {
|
|
243
|
+
const hour24 = Math.floor(total / 60);
|
|
244
|
+
const { hour12, minute, period } = to12(hour24, total % 60);
|
|
245
|
+
return { hour12, minute, period };
|
|
246
|
+
}
|
|
247
|
+
// No value: anchor the draft at the lower bound so the panel opens on
|
|
248
|
+
// the earliest selectable time.
|
|
249
|
+
const anchor = minBound;
|
|
250
|
+
const hour24 = Math.floor(anchor / 60);
|
|
251
|
+
const { hour12, minute, period } = to12(hour24, anchor % 60);
|
|
252
|
+
return { hour12, minute, period };
|
|
253
|
+
}, [total, minBound]);
|
|
254
|
+
|
|
255
|
+
const minutesFor = (hour12: number, period: 'AM' | 'PM') => {
|
|
256
|
+
const hour24 = (hour12 % 12) + (period === 'PM' ? 12 : 0);
|
|
257
|
+
return allowedMinutes(hour24, minBound, maxBound, step);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const hours12 = Array.from({ length: 12 }, (_, i) => i + 1);
|
|
261
|
+
|
|
262
|
+
const hour24Of = (h12: number, p: 'AM' | 'PM') => (h12 % 12) + (p === 'PM' ? 12 : 0);
|
|
263
|
+
|
|
264
|
+
// An hour is selectable only when it yields valid minutes under the period
|
|
265
|
+
// currently shown, so a disabled-looking choice can never be committed.
|
|
266
|
+
const isHourEnabled = (h12: number) => minutesFor(h12, draft.period).length > 0;
|
|
267
|
+
|
|
268
|
+
const isPeriodEnabled = (p: 'AM' | 'PM') =>
|
|
269
|
+
hours12.some((h) => hourHasValidMinute(hour24Of(h, p), minBound, maxBound, step));
|
|
270
|
+
|
|
271
|
+
const minuteOptions = minutesFor(draft.hour12, draft.period);
|
|
272
|
+
const validMinute = minuteOptions.includes(draft.minute) ? draft.minute : minuteOptions[0];
|
|
273
|
+
|
|
274
|
+
const emit = (h12: number, minute: number, p: 'AM' | 'PM') => {
|
|
275
|
+
commit(fromMinutes(from12(h12, minute, p)));
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const onHour = (h12: number) => {
|
|
279
|
+
const options = minutesFor(h12, draft.period);
|
|
280
|
+
if (options.length === 0) return;
|
|
281
|
+
const minute = options.includes(draft.minute) ? draft.minute : options[0];
|
|
282
|
+
emit(h12, minute, draft.period);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const onPeriod = (p: 'AM' | 'PM') => {
|
|
286
|
+
// The current hour may have no valid minutes under the new period (e.g.
|
|
287
|
+
// min=13:00 makes every AM hour invalid); snap to the first valid hour.
|
|
288
|
+
let hour = draft.hour12;
|
|
289
|
+
let options = minutesFor(hour, p);
|
|
290
|
+
if (options.length === 0) {
|
|
291
|
+
hour = hours12.find((h) => minutesFor(h, p).length > 0) ?? hour;
|
|
292
|
+
options = minutesFor(hour, p);
|
|
293
|
+
if (options.length === 0) return;
|
|
294
|
+
}
|
|
295
|
+
const minute = options.includes(draft.minute) ? draft.minute : options[0];
|
|
296
|
+
emit(hour, minute, p);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const label = total !== null ? format12(current) : placeholder;
|
|
300
|
+
|
|
301
|
+
return (
|
|
302
|
+
<div className={cn('relative flex items-center', className)}>
|
|
303
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
304
|
+
<PopoverTrigger
|
|
305
|
+
id={id}
|
|
51
306
|
type="button"
|
|
52
|
-
|
|
53
|
-
aria-label={
|
|
54
|
-
|
|
307
|
+
disabled={disabled}
|
|
308
|
+
aria-label={ariaLabel}
|
|
309
|
+
aria-describedby={ariaDescribedBy}
|
|
310
|
+
aria-invalid={ariaInvalid}
|
|
311
|
+
className={cn(
|
|
312
|
+
'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-left text-sm',
|
|
313
|
+
'hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
|
314
|
+
total === null && 'text-muted-foreground',
|
|
315
|
+
clearButton && 'pr-9'
|
|
316
|
+
)}
|
|
55
317
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
318
|
+
<span>{label}</span>
|
|
319
|
+
<span aria-hidden="true" className="text-muted-foreground">
|
|
320
|
+
▾
|
|
321
|
+
</span>
|
|
322
|
+
</PopoverTrigger>
|
|
323
|
+
<PopoverContent side="bottom" align="start" matchTriggerWidth className="p-3">
|
|
324
|
+
<div className="flex items-end gap-2">
|
|
325
|
+
<Select
|
|
326
|
+
label="Hour"
|
|
327
|
+
labelHidden
|
|
328
|
+
className="flex-1"
|
|
329
|
+
value={String(draft.hour12)}
|
|
330
|
+
onValueChange={(v) => onHour(Number(Array.isArray(v) ? v[0] : v))}
|
|
331
|
+
options={hours12.map((h) => ({
|
|
332
|
+
value: String(h),
|
|
333
|
+
label: pad(h),
|
|
334
|
+
disabled: !isHourEnabled(h),
|
|
335
|
+
}))}
|
|
336
|
+
/>
|
|
337
|
+
<Select
|
|
338
|
+
label="Minute"
|
|
339
|
+
labelHidden
|
|
340
|
+
className="flex-1"
|
|
341
|
+
value={String(validMinute)}
|
|
342
|
+
onValueChange={(v) => emit(draft.hour12, Number(Array.isArray(v) ? v[0] : v), draft.period)}
|
|
343
|
+
options={minuteOptions.map((m) => ({ value: String(m), label: pad(m) }))}
|
|
344
|
+
/>
|
|
345
|
+
<Select
|
|
346
|
+
label="AM or PM"
|
|
347
|
+
labelHidden
|
|
348
|
+
className="flex-1"
|
|
349
|
+
value={draft.period}
|
|
350
|
+
onValueChange={(v) => onPeriod((Array.isArray(v) ? v[0] : v) as 'AM' | 'PM')}
|
|
351
|
+
options={PERIODS.map((p) => ({
|
|
352
|
+
value: p,
|
|
353
|
+
label: p,
|
|
354
|
+
disabled: !isPeriodEnabled(p),
|
|
355
|
+
}))}
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
</PopoverContent>
|
|
359
|
+
</Popover>
|
|
360
|
+
{clearButton}
|
|
361
|
+
{name ? <input type="hidden" name={name} value={current} /> : null}
|
|
59
362
|
</div>
|
|
60
363
|
);
|
|
61
|
-
}
|
|
364
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -105,3 +105,9 @@ export * from './components/alert';
|
|
|
105
105
|
export * from './components/popover';
|
|
106
106
|
export * from './components/breadcrumb';
|
|
107
107
|
export * from './components/pagination';
|
|
108
|
+
export * from './components/icon';
|
|
109
|
+
export * from './components/icon-button';
|
|
110
|
+
export * from './components/icon-tile';
|
|
111
|
+
export * from './components/social-links';
|
|
112
|
+
export * from './components/figure';
|
|
113
|
+
export * from './components/media';
|
|
@@ -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.14.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.14.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.14.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.",
|