@teamofsilicons/silicon-ui 0.0.0-stage → 0.1.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/LICENSE +22 -0
- package/README.md +63 -2
- package/components/accordion/accordion.d.ts +13 -0
- package/components/accordion/accordion.js +35 -0
- package/components/accordion/accordion.module.css +15 -0
- package/components/action-button/action-button.d.ts +11 -0
- package/components/action-button/action-button.js +57 -0
- package/components/action-button/action-button.module.css +15 -0
- package/components/activity-heatmap/activity-heatmap.d.ts +37 -0
- package/components/activity-heatmap/activity-heatmap.js +303 -0
- package/components/activity-heatmap/activity-heatmap.module.css +83 -0
- package/components/alert/alert.d.ts +13 -0
- package/components/alert/alert.js +79 -0
- package/components/alert/alert.module.css +15 -0
- package/components/animated-counter/animated-counter.d.ts +13 -0
- package/components/animated-counter/animated-counter.js +73 -0
- package/components/animated-counter/animated-counter.module.css +12 -0
- package/components/announcement-bar/announcement-bar.d.ts +53 -0
- package/components/announcement-bar/announcement-bar.js +187 -0
- package/components/announcement-bar/announcement-bar.module.css +60 -0
- package/components/avatar/avatar.d.ts +8 -0
- package/components/avatar/avatar.js +18 -0
- package/components/avatar/avatar.module.css +60 -0
- package/components/avatar-group/avatar-group.d.ts +13 -0
- package/components/avatar-group/avatar-group.js +24 -0
- package/components/avatar-group/avatar-group.module.css +27 -0
- package/components/badge/badge.d.ts +10 -0
- package/components/badge/badge.js +66 -0
- package/components/badge/badge.module.css +52 -0
- package/components/bar-chart/bar-chart.d.ts +32 -0
- package/components/bar-chart/bar-chart.js +327 -0
- package/components/bar-chart/bar-chart.module.css +49 -0
- package/components/billing-toggle/billing-toggle.d.ts +35 -0
- package/components/billing-toggle/billing-toggle.js +83 -0
- package/components/billing-toggle/billing-toggle.module.css +139 -0
- package/components/bottom-sheet/bottom-sheet.d.ts +27 -0
- package/components/bottom-sheet/bottom-sheet.js +386 -0
- package/components/bottom-sheet/bottom-sheet.module.css +69 -0
- package/components/breadcrumb/breadcrumb.d.ts +13 -0
- package/components/breadcrumb/breadcrumb.js +19 -0
- package/components/breadcrumb/breadcrumb.module.css +12 -0
- package/components/brush-chart/brush-chart.d.ts +45 -0
- package/components/brush-chart/brush-chart.js +426 -0
- package/components/brush-chart/brush-chart.module.css +69 -0
- package/components/button/button.d.ts +10 -0
- package/components/button/button.js +97 -0
- package/components/button/button.module.css +39 -0
- package/components/button-group/button-group.d.ts +59 -0
- package/components/button-group/button-group.js +280 -0
- package/components/button-group/button-group.module.css +87 -0
- package/components/button-link/button-link.d.ts +24 -0
- package/components/button-link/button-link.js +11 -0
- package/components/button-link/button-link.module.css +7 -0
- package/components/calendar/calendar.d.ts +22 -0
- package/components/calendar/calendar.js +253 -0
- package/components/calendar/calendar.module.css +51 -0
- package/components/card/card.d.ts +19 -0
- package/components/card/card.js +108 -0
- package/components/card/card.module.css +51 -0
- package/components/card-stack/card-stack.d.ts +34 -0
- package/components/card-stack/card-stack.js +291 -0
- package/components/card-stack/card-stack.module.css +63 -0
- package/components/carousel/carousel.d.ts +28 -0
- package/components/carousel/carousel.js +332 -0
- package/components/carousel/carousel.module.css +42 -0
- package/components/chat-thread/chat-thread.d.ts +135 -0
- package/components/chat-thread/chat-thread.js +406 -0
- package/components/chat-thread/chat-thread.module.css +242 -0
- package/components/checkbox/checkbox.d.ts +7 -0
- package/components/checkbox/checkbox.js +23 -0
- package/components/checkbox/checkbox.module.css +15 -0
- package/components/chip-group/chip-group.d.ts +24 -0
- package/components/chip-group/chip-group.js +196 -0
- package/components/chip-group/chip-group.module.css +38 -0
- package/components/code-block/code-block.d.ts +11 -0
- package/components/code-block/code-block.js +133 -0
- package/components/code-block/code-block.module.css +43 -0
- package/components/color-picker/color-picker.d.ts +40 -0
- package/components/color-picker/color-picker.js +449 -0
- package/components/color-picker/color-picker.module.css +111 -0
- package/components/combobox/combobox.d.ts +19 -0
- package/components/combobox/combobox.js +167 -0
- package/components/combobox/combobox.module.css +28 -0
- package/components/command-palette/command-palette.d.ts +20 -0
- package/components/command-palette/command-palette.js +151 -0
- package/components/command-palette/command-palette.module.css +94 -0
- package/components/comment-thread/comment-thread.d.ts +120 -0
- package/components/comment-thread/comment-thread.js +343 -0
- package/components/comment-thread/comment-thread.module.css +195 -0
- package/components/confirm-morph/confirm-morph.d.ts +65 -0
- package/components/confirm-morph/confirm-morph.js +355 -0
- package/components/confirm-morph/confirm-morph.module.css +146 -0
- package/components/context-menu/context-menu.d.ts +18 -0
- package/components/context-menu/context-menu.js +148 -0
- package/components/context-menu/context-menu.module.css +17 -0
- package/components/copy-button/copy-button.d.ts +10 -0
- package/components/copy-button/copy-button.js +69 -0
- package/components/copy-button/copy-button.module.css +21 -0
- package/components/countdown/countdown.d.ts +31 -0
- package/components/countdown/countdown.js +177 -0
- package/components/countdown/countdown.module.css +49 -0
- package/components/date-picker/date-picker.d.ts +17 -0
- package/components/date-picker/date-picker.js +100 -0
- package/components/date-picker/date-picker.module.css +34 -0
- package/components/date-range-picker/date-range-picker.d.ts +44 -0
- package/components/date-range-picker/date-range-picker.js +534 -0
- package/components/date-range-picker/date-range-picker.module.css +214 -0
- package/components/dialog/dialog.d.ts +11 -0
- package/components/dialog/dialog.js +52 -0
- package/components/dialog/dialog.module.css +36 -0
- package/components/donut-chart/donut-chart.d.ts +46 -0
- package/components/donut-chart/donut-chart.js +382 -0
- package/components/donut-chart/donut-chart.module.css +48 -0
- package/components/drawer/drawer.d.ts +20 -0
- package/components/drawer/drawer.js +111 -0
- package/components/drawer/drawer.module.css +97 -0
- package/components/dropdown-menu/dropdown-menu.d.ts +16 -0
- package/components/dropdown-menu/dropdown-menu.js +39 -0
- package/components/dropdown-menu/dropdown-menu.module.css +38 -0
- package/components/elastic-slider/elastic-slider.d.ts +39 -0
- package/components/elastic-slider/elastic-slider.js +261 -0
- package/components/elastic-slider/elastic-slider.module.css +40 -0
- package/components/empty-state/empty-state.d.ts +12 -0
- package/components/empty-state/empty-state.js +69 -0
- package/components/empty-state/empty-state.module.css +13 -0
- package/components/expandable-card/expandable-card.d.ts +13 -0
- package/components/expandable-card/expandable-card.js +89 -0
- package/components/expandable-card/expandable-card.module.css +22 -0
- package/components/expanding-button-group/expanding-button-group.d.ts +41 -0
- package/components/expanding-button-group/expanding-button-group.js +258 -0
- package/components/expanding-button-group/expanding-button-group.module.css +44 -0
- package/components/expanding-search/expanding-search.d.ts +38 -0
- package/components/expanding-search/expanding-search.js +242 -0
- package/components/expanding-search/expanding-search.module.css +52 -0
- package/components/file-dropzone/file-dropzone.d.ts +44 -0
- package/components/file-dropzone/file-dropzone.js +379 -0
- package/components/file-dropzone/file-dropzone.module.css +115 -0
- package/components/file-upload/file-upload.d.ts +22 -0
- package/components/file-upload/file-upload.js +192 -0
- package/components/file-upload/file-upload.module.css +49 -0
- package/components/filter-toolbar/filter-toolbar.d.ts +48 -0
- package/components/filter-toolbar/filter-toolbar.js +446 -0
- package/components/filter-toolbar/filter-toolbar.module.css +70 -0
- package/components/floating-button-group/floating-button-group.d.ts +51 -0
- package/components/floating-button-group/floating-button-group.js +215 -0
- package/components/floating-button-group/floating-button-group.module.css +74 -0
- package/components/gauge/gauge.d.ts +18 -0
- package/components/gauge/gauge.js +101 -0
- package/components/gauge/gauge.module.css +22 -0
- package/components/hold-to-confirm/hold-to-confirm.d.ts +25 -0
- package/components/hold-to-confirm/hold-to-confirm.js +165 -0
- package/components/hold-to-confirm/hold-to-confirm.module.css +20 -0
- package/components/hover-card/hover-card.d.ts +38 -0
- package/components/hover-card/hover-card.js +145 -0
- package/components/hover-card/hover-card.module.css +20 -0
- package/components/image-compare/image-compare.d.ts +27 -0
- package/components/image-compare/image-compare.js +267 -0
- package/components/image-compare/image-compare.module.css +25 -0
- package/components/in-view-title/in-view-title.d.ts +17 -0
- package/components/in-view-title/in-view-title.js +70 -0
- package/components/in-view-title/in-view-title.module.css +13 -0
- package/components/inline-edit/inline-edit.d.ts +27 -0
- package/components/inline-edit/inline-edit.js +315 -0
- package/components/inline-edit/inline-edit.module.css +73 -0
- package/components/input/input.d.ts +7 -0
- package/components/input/input.js +60 -0
- package/components/input/input.module.css +22 -0
- package/components/json-viewer/json-viewer.d.ts +48 -0
- package/components/json-viewer/json-viewer.js +463 -0
- package/components/json-viewer/json-viewer.module.css +92 -0
- package/components/line-chart/line-chart.d.ts +58 -0
- package/components/line-chart/line-chart.js +383 -0
- package/components/line-chart/line-chart.module.css +60 -0
- package/components/mention-input/mention-input.d.ts +72 -0
- package/components/mention-input/mention-input.js +417 -0
- package/components/mention-input/mention-input.module.css +134 -0
- package/components/metric-card/metric-card.d.ts +8 -0
- package/components/metric-card/metric-card.js +44 -0
- package/components/metric-card/metric-card.module.css +18 -0
- package/components/money-input/money-input.d.ts +48 -0
- package/components/money-input/money-input.js +503 -0
- package/components/money-input/money-input.module.css +77 -0
- package/components/morph-select/morph-select.d.ts +50 -0
- package/components/morph-select/morph-select.js +395 -0
- package/components/morph-select/morph-select.module.css +88 -0
- package/components/multi-select/multi-select.d.ts +18 -0
- package/components/multi-select/multi-select.js +105 -0
- package/components/multi-select/multi-select.module.css +37 -0
- package/components/notification-center/notification-center.d.ts +24 -0
- package/components/notification-center/notification-center.js +146 -0
- package/components/notification-center/notification-center.module.css +79 -0
- package/components/number-field/number-field.d.ts +41 -0
- package/components/number-field/number-field.js +455 -0
- package/components/number-field/number-field.module.css +71 -0
- package/components/otp-input/otp-input.d.ts +13 -0
- package/components/otp-input/otp-input.js +129 -0
- package/components/otp-input/otp-input.module.css +28 -0
- package/components/pagination/pagination.d.ts +7 -0
- package/components/pagination/pagination.js +60 -0
- package/components/pagination/pagination.module.css +16 -0
- package/components/password-field/password-field.d.ts +14 -0
- package/components/password-field/password-field.js +51 -0
- package/components/password-field/password-field.module.css +27 -0
- package/components/password-strength/password-strength.d.ts +107 -0
- package/components/password-strength/password-strength.js +161 -0
- package/components/password-strength/password-strength.module.css +57 -0
- package/components/phone-input/phone-input.d.ts +73 -0
- package/components/phone-input/phone-input.js +612 -0
- package/components/phone-input/phone-input.module.css +98 -0
- package/components/popover/popover.d.ts +6 -0
- package/components/popover/popover.js +19 -0
- package/components/popover/popover.module.css +32 -0
- package/components/progress/progress.d.ts +8 -0
- package/components/progress/progress.js +42 -0
- package/components/progress/progress.module.css +1 -0
- package/components/radio-cards/radio-cards.d.ts +35 -0
- package/components/radio-cards/radio-cards.js +110 -0
- package/components/radio-cards/radio-cards.module.css +84 -0
- package/components/radio-group/radio-group.d.ts +13 -0
- package/components/radio-group/radio-group.js +55 -0
- package/components/radio-group/radio-group.module.css +30 -0
- package/components/resizable-panels/resizable-panels.d.ts +37 -0
- package/components/resizable-panels/resizable-panels.js +338 -0
- package/components/resizable-panels/resizable-panels.module.css +40 -0
- package/components/rich-text-editor/rich-text-editor.d.ts +55 -0
- package/components/rich-text-editor/rich-text-editor.js +1733 -0
- package/components/rich-text-editor/rich-text-editor.module.css +201 -0
- package/components/ridgeline/ridgeline.d.ts +37 -0
- package/components/ridgeline/ridgeline.js +346 -0
- package/components/ridgeline/ridgeline.module.css +58 -0
- package/components/scroll-area/scroll-area.d.ts +40 -0
- package/components/scroll-area/scroll-area.js +153 -0
- package/components/scroll-area/scroll-area.module.css +79 -0
- package/components/search-field/search-field.d.ts +7 -0
- package/components/search-field/search-field.js +20 -0
- package/components/search-field/search-field.module.css +17 -0
- package/components/segmented-control/segmented-control.d.ts +16 -0
- package/components/segmented-control/segmented-control.js +56 -0
- package/components/segmented-control/segmented-control.module.css +15 -0
- package/components/select/select.d.ts +15 -0
- package/components/select/select.js +36 -0
- package/components/select/select.module.css +35 -0
- package/components/shortcut-recorder/shortcut-recorder.d.ts +108 -0
- package/components/shortcut-recorder/shortcut-recorder.js +380 -0
- package/components/shortcut-recorder/shortcut-recorder.module.css +85 -0
- package/components/signature-pad/signature-pad.d.ts +72 -0
- package/components/signature-pad/signature-pad.js +450 -0
- package/components/signature-pad/signature-pad.module.css +84 -0
- package/components/skeleton/skeleton.d.ts +13 -0
- package/components/skeleton/skeleton.js +53 -0
- package/components/skeleton/skeleton.module.css +11 -0
- package/components/slider/slider.d.ts +45 -0
- package/components/slider/slider.js +347 -0
- package/components/slider/slider.module.css +45 -0
- package/components/slope-chart/slope-chart.d.ts +38 -0
- package/components/slope-chart/slope-chart.js +183 -0
- package/components/slope-chart/slope-chart.module.css +51 -0
- package/components/slot-text/slot-text.d.ts +26 -0
- package/components/slot-text/slot-text.js +119 -0
- package/components/slot-text/slot-text.module.css +19 -0
- package/components/sortable-data-table/sortable-data-table.d.ts +38 -0
- package/components/sortable-data-table/sortable-data-table.js +240 -0
- package/components/sortable-data-table/sortable-data-table.module.css +116 -0
- package/components/sparkline/sparkline.d.ts +19 -0
- package/components/sparkline/sparkline.js +239 -0
- package/components/sparkline/sparkline.module.css +26 -0
- package/components/split-button/split-button.d.ts +19 -0
- package/components/split-button/split-button.js +33 -0
- package/components/split-button/split-button.module.css +51 -0
- package/components/stepper/stepper.d.ts +36 -0
- package/components/stepper/stepper.js +108 -0
- package/components/stepper/stepper.module.css +74 -0
- package/components/streamgraph/streamgraph.d.ts +51 -0
- package/components/streamgraph/streamgraph.js +376 -0
- package/components/streamgraph/streamgraph.module.css +55 -0
- package/components/swipe-actions/swipe-actions.d.ts +35 -0
- package/components/swipe-actions/swipe-actions.js +330 -0
- package/components/swipe-actions/swipe-actions.module.css +64 -0
- package/components/switch/switch.d.ts +7 -0
- package/components/switch/switch.js +45 -0
- package/components/switch/switch.module.css +12 -0
- package/components/tabs/tabs.d.ts +8 -0
- package/components/tabs/tabs.js +138 -0
- package/components/tabs/tabs.module.css +27 -0
- package/components/tag-input/tag-input.d.ts +15 -0
- package/components/tag-input/tag-input.js +150 -0
- package/components/tag-input/tag-input.module.css +34 -0
- package/components/text-morph/text-morph.d.ts +13 -0
- package/components/text-morph/text-morph.js +69 -0
- package/components/text-morph/text-morph.module.css +8 -0
- package/components/text-reveal/text-reveal.d.ts +14 -0
- package/components/text-reveal/text-reveal.js +20 -0
- package/components/text-reveal/text-reveal.module.css +13 -0
- package/components/text-shimmer/text-shimmer.d.ts +18 -0
- package/components/text-shimmer/text-shimmer.js +90 -0
- package/components/text-shimmer/text-shimmer.module.css +9 -0
- package/components/textarea/textarea.d.ts +7 -0
- package/components/textarea/textarea.js +56 -0
- package/components/textarea/textarea.module.css +22 -0
- package/components/theme-switch/theme-switch.d.ts +11 -0
- package/components/theme-switch/theme-switch.js +37 -0
- package/components/theme-switch/theme-switch.module.css +31 -0
- package/components/time-picker/time-picker.d.ts +13 -0
- package/components/time-picker/time-picker.js +95 -0
- package/components/time-picker/time-picker.module.css +23 -0
- package/components/timeline/timeline.d.ts +47 -0
- package/components/timeline/timeline.js +171 -0
- package/components/timeline/timeline.module.css +51 -0
- package/components/toast/toast.d.ts +8 -0
- package/components/toast/toast.js +118 -0
- package/components/toast/toast.module.css +100 -0
- package/components/toast-stack/toast-stack.d.ts +57 -0
- package/components/toast-stack/toast-stack.js +399 -0
- package/components/toast-stack/toast-stack.module.css +61 -0
- package/components/tooltip/tooltip.d.ts +8 -0
- package/components/tooltip/tooltip.js +62 -0
- package/components/tooltip/tooltip.module.css +18 -0
- package/components/tree-view/tree-view.d.ts +17 -0
- package/components/tree-view/tree-view.js +147 -0
- package/components/tree-view/tree-view.module.css +22 -0
- package/components/treemap/treemap.d.ts +35 -0
- package/components/treemap/treemap.js +375 -0
- package/components/treemap/treemap.module.css +59 -0
- package/components/usage-meter/usage-meter.d.ts +24 -0
- package/components/usage-meter/usage-meter.js +296 -0
- package/components/usage-meter/usage-meter.module.css +61 -0
- package/components/user-menu/user-menu.d.ts +62 -0
- package/components/user-menu/user-menu.js +316 -0
- package/components/user-menu/user-menu.module.css +97 -0
- package/components/waffle-chart/waffle-chart.d.ts +39 -0
- package/components/waffle-chart/waffle-chart.js +244 -0
- package/components/waffle-chart/waffle-chart.module.css +52 -0
- package/components.json +1330 -0
- package/lib/escape.d.ts +19 -0
- package/lib/escape.js +50 -0
- package/lib/media.d.ts +353 -0
- package/lib/media.js +65 -0
- package/lib/menu-highlight.d.ts +28 -0
- package/lib/menu-highlight.js +43 -0
- package/lib/motion-tokens.d.ts +60 -0
- package/lib/motion-tokens.js +25 -0
- package/lib/return-focus.d.ts +9 -0
- package/lib/return-focus.js +53 -0
- package/lib/silicon-provider.d.ts +60 -0
- package/lib/silicon-provider.js +47 -0
- package/lib/use-copy-feedback.d.ts +8 -0
- package/lib/use-copy-feedback.js +36 -0
- package/lib/use-today.d.ts +2 -0
- package/lib/use-today.js +29 -0
- package/package.json +66 -4
- package/styles.css +218 -0
- package/styles.css.d.ts +1 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
4
|
+
import { ChevronDown, X } from "lucide-react";
|
|
5
|
+
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { motionTokens } from "../../lib/motion-tokens.js";
|
|
7
|
+
import styles from "./multi-select.module.css";
|
|
8
|
+
const enter = motionTokens.ease.enter;
|
|
9
|
+
const standard = motionTokens.ease.standard;
|
|
10
|
+
/** Each chip sits in a slot whose width opens and collapses on a spring, so neighbours travel with it and nothing overlaps. */
|
|
11
|
+
const slot = {
|
|
12
|
+
hidden: { width: 0, opacity: 0 },
|
|
13
|
+
shown: { width: "auto", opacity: 1, transition: { width: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast, ease: enter } } },
|
|
14
|
+
gone: { width: 0, opacity: 0, transition: { width: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.instant, ease: standard } } },
|
|
15
|
+
};
|
|
16
|
+
/** The chip itself grows in from .9 with a soft blur and shrinks back as it leaves. */
|
|
17
|
+
const chip = {
|
|
18
|
+
hidden: { scale: 0.9, filter: `blur(${motionTokens.blur.soft}px)` },
|
|
19
|
+
shown: { scale: 1, filter: "blur(0px)", transition: { ...motionTokens.spring.snappy, filter: { duration: motionTokens.duration.standard, ease: enter } } },
|
|
20
|
+
gone: { scale: 0.9, filter: `blur(${motionTokens.blur.subtle}px)`, transition: { duration: motionTokens.duration.instant, ease: standard } },
|
|
21
|
+
};
|
|
22
|
+
/** Reduced motion keeps short crossfades; resting states match the moving variants so server and client markup agree. */
|
|
23
|
+
const fade = { hidden: { opacity: 0 }, shown: { opacity: 1, y: 0, filter: "blur(0px)", transition: { duration: motionTokens.duration.instant } }, gone: { opacity: 0, transition: { duration: motionTokens.duration.instant } } };
|
|
24
|
+
const slotFade = { hidden: { opacity: 0 }, shown: { width: "auto", opacity: 1, transition: { duration: motionTokens.duration.instant } }, gone: { opacity: 0, transition: { duration: motionTokens.duration.instant } } };
|
|
25
|
+
const chipStill = { hidden: { scale: 1, filter: "blur(0px)" }, shown: { scale: 1, filter: "blur(0px)" }, gone: { scale: 1, filter: "blur(0px)" } };
|
|
26
|
+
/** The overflow count rolls: a larger number rises from below, a smaller one drops from above. */
|
|
27
|
+
const roll = {
|
|
28
|
+
hidden: (direction) => ({ opacity: 0, y: `${direction * 0.5}em`, filter: `blur(${motionTokens.blur.subtle}px)` }),
|
|
29
|
+
shown: { opacity: 1, y: 0, filter: "blur(0px)", transition: { duration: motionTokens.duration.standard, ease: enter } },
|
|
30
|
+
gone: (direction) => ({ opacity: 0, y: `${direction * -0.5}em`, filter: `blur(${motionTokens.blur.subtle}px)`, transition: { duration: motionTokens.duration.instant, ease: standard } }),
|
|
31
|
+
};
|
|
32
|
+
/** A check that draws itself when an option is picked and retracts when it is removed. */
|
|
33
|
+
function CheckMark({ reduce }) {
|
|
34
|
+
return _jsx("svg", { className: styles.check, width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx(motion.path, { d: "M4 12.5 9 17.5 20 6.5", initial: reduce ? { opacity: 0 } : { pathLength: 0, opacity: 0 }, animate: { pathLength: 1, opacity: 1 }, exit: reduce ? { opacity: 0 } : { pathLength: 0, opacity: 0 }, transition: reduce ? { duration: motionTokens.duration.instant } : { pathLength: { duration: motionTokens.duration.standard, ease: enter }, opacity: { duration: motionTokens.duration.instant } } }) });
|
|
35
|
+
}
|
|
36
|
+
export function MultiSelect({ label, options, value, defaultValue = [], onValueChange, placeholder = "Select options", description, maxVisible = 2, disabled = false, className }) {
|
|
37
|
+
const id = useId();
|
|
38
|
+
const labelId = `${id}-label`;
|
|
39
|
+
const valueId = `${id}-value`;
|
|
40
|
+
const rootRef = useRef(null);
|
|
41
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
44
|
+
const selected = value ?? internal;
|
|
45
|
+
const selectedSet = useMemo(() => new Set(selected), [selected]);
|
|
46
|
+
const labelFor = (item) => options.find((option) => option.value === item)?.label ?? item;
|
|
47
|
+
const visible = selected.slice(0, maxVisible).map((item) => ({ value: item, label: labelFor(item) }));
|
|
48
|
+
const remaining = Math.max(0, selected.length - visible.length);
|
|
49
|
+
// A closed menu forgets its highlight, so the next open starts clean instead of on a stale hovered row.
|
|
50
|
+
const [wasOpen, setWasOpen] = useState(open);
|
|
51
|
+
if (wasOpen !== open) {
|
|
52
|
+
setWasOpen(open);
|
|
53
|
+
if (!open)
|
|
54
|
+
setActiveIndex(-1);
|
|
55
|
+
}
|
|
56
|
+
const [previousRemaining, setPreviousRemaining] = useState(remaining);
|
|
57
|
+
const [countDirection, setCountDirection] = useState(1);
|
|
58
|
+
if (previousRemaining !== remaining) {
|
|
59
|
+
setPreviousRemaining(remaining);
|
|
60
|
+
setCountDirection(remaining > previousRemaining ? 1 : -1);
|
|
61
|
+
}
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const close = (event) => { if (!rootRef.current?.contains(event.target))
|
|
64
|
+
setOpen(false); };
|
|
65
|
+
document.addEventListener("pointerdown", close);
|
|
66
|
+
return () => document.removeEventListener("pointerdown", close);
|
|
67
|
+
}, []);
|
|
68
|
+
const update = (next) => { if (value === undefined)
|
|
69
|
+
setInternal(next); onValueChange?.(next); };
|
|
70
|
+
const toggle = (option) => {
|
|
71
|
+
if (disabled || option.disabled)
|
|
72
|
+
return;
|
|
73
|
+
update(selectedSet.has(option.value) ? selected.filter((item) => item !== option.value) : [...selected, option.value]);
|
|
74
|
+
};
|
|
75
|
+
const clear = () => { update([]); setOpen(false); };
|
|
76
|
+
const enabled = options.map((option, index) => option.disabled ? -1 : index).filter((index) => index >= 0);
|
|
77
|
+
const onKeyDown = (event) => {
|
|
78
|
+
if (disabled)
|
|
79
|
+
return;
|
|
80
|
+
if (event.key === "Enter" && open && activeIndex >= 0) {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
toggle(options[activeIndex]);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setOpen((current) => !current);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (event.key === "Escape") {
|
|
91
|
+
setOpen(false);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if ((event.key === "ArrowDown" || event.key === "ArrowUp") && enabled.length) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
setOpen(true);
|
|
97
|
+
const current = enabled.indexOf(activeIndex);
|
|
98
|
+
const next = current < 0 ? (event.key === "ArrowDown" ? 0 : enabled.length - 1) : event.key === "ArrowDown" ? (current + 1) % enabled.length : (current - 1 + enabled.length) % enabled.length;
|
|
99
|
+
setActiveIndex(enabled[next]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const reduce = useReducedMotion();
|
|
103
|
+
return _jsxs("div", { ref: rootRef, className: [styles.field, className].filter(Boolean).join(" "), children: [_jsx("span", { id: labelId, className: styles.label, children: label }), _jsxs("div", { className: styles.control, children: [_jsxs("button", { type: "button", className: `${styles.trigger} ${selected.length ? styles.hasClear : ""}`, disabled: disabled, "aria-labelledby": `${labelId} ${valueId}`, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": `${id}-listbox`, onClick: () => setOpen((current) => !current), onKeyDown: onKeyDown, children: [_jsx("span", { id: valueId, className: styles.srOnly, children: selected.length ? selected.map(labelFor).join(", ") : placeholder }), _jsx("span", { className: styles.value, "aria-hidden": "true", children: _jsxs(AnimatePresence, { initial: false, children: [visible.map((item) => _jsx(motion.span, { className: styles.slot, variants: reduce ? slotFade : slot, initial: "hidden", animate: "shown", exit: "gone", children: _jsx(motion.span, { className: styles.chip, variants: reduce ? chipStill : chip, children: item.label }) }, `chip-${item.value}`)), remaining > 0 && _jsx(motion.span, { className: styles.slot, variants: reduce ? slotFade : slot, initial: "hidden", animate: "shown", exit: "gone", children: _jsxs(motion.span, { className: styles.more, variants: reduce ? chipStill : chip, children: ["+", _jsx("span", { className: styles.count, children: _jsx(AnimatePresence, { initial: false, custom: countDirection, children: _jsx(motion.span, { custom: countDirection, variants: reduce ? fade : roll, initial: "hidden", animate: "shown", exit: "gone", children: remaining }, remaining) }) })] }) }, "more"), !selected.length && _jsx(motion.span, { className: styles.placeholder, variants: fade, initial: "hidden", animate: "shown", exit: "gone", children: placeholder }, "placeholder")] }) }), _jsx(ChevronDown, { className: styles.chevron, size: 16, "aria-hidden": "true" })] }), _jsx(AnimatePresence, { initial: false, children: selected.length > 0 && !disabled && _jsx(motion.button, { type: "button", "aria-label": "Clear selections", className: styles.clear, onClick: clear, initial: reduce ? { opacity: 0 } : { opacity: 0, scale: 0.6, filter: `blur(${motionTokens.blur.subtle}px)` }, animate: { opacity: 1, scale: 1, filter: "blur(0px)", transition: reduce ? { duration: motionTokens.duration.instant } : { ...motionTokens.spring.snappy, opacity: { duration: motionTokens.duration.fast } } }, exit: { opacity: 0, ...(reduce ? {} : { scale: 0.6, filter: `blur(${motionTokens.blur.subtle}px)` }), transition: { duration: motionTokens.duration.instant, ease: standard } }, whileTap: { scale: reduce ? 1 : 0.96, transition: { duration: motionTokens.duration.instant, ease: standard } }, children: _jsx(X, { size: 14, "aria-hidden": "true" }) }) }), _jsx(AnimatePresence, { initial: false, children: open && _jsx(motion.div, { id: `${id}-listbox`, className: styles.menu, role: "listbox", "aria-label": label, "aria-multiselectable": "true", initial: reduce ? { opacity: 0 } : { opacity: 0, y: -6, scale: .97 }, animate: { opacity: 1, y: 0, scale: 1, transition: reduce ? { duration: motionTokens.duration.instant } : { ...motionTokens.spring.snappy, opacity: { duration: motionTokens.duration.fast, ease: enter } } }, exit: { opacity: 0, ...(reduce ? {} : { y: -4, scale: .98 }), transition: { duration: motionTokens.duration.instant, ease: standard } }, children: options.map((option, index) => _jsxs("button", { type: "button", role: "option", "aria-selected": selectedSet.has(option.value), "aria-disabled": option.disabled || undefined, className: styles.option, "data-active": activeIndex === index, disabled: option.disabled, onPointerMove: () => { if (activeIndex !== index)
|
|
104
|
+
setActiveIndex(index); }, onClick: () => toggle(option), children: [_jsx("span", { children: option.label }), _jsx(AnimatePresence, { initial: false, children: selectedSet.has(option.value) && _jsx(CheckMark, { reduce: reduce }, "check") })] }, option.value)) }) })] }), description && _jsx("span", { className: styles.description, children: description })] });
|
|
105
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.field { position: relative; display: grid; gap: var(--space-related); min-width: 0; }
|
|
2
|
+
.control { position: relative; min-width: 0; }
|
|
3
|
+
.label { font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); }
|
|
4
|
+
/* The trigger anchors the menu, so press feedback stays in color; it never scales. */
|
|
5
|
+
.trigger { position: relative; display: flex; width: 100%; min-height: var(--control-height-md); align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 5px 11px 5px 12px; background: var(--surface); color: var(--foreground); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; transition: border-color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }
|
|
6
|
+
@media (hover: hover) and (pointer: fine) { .trigger:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-muted); } }
|
|
7
|
+
.trigger:active:not(:disabled), .trigger[aria-expanded="true"] { border-color: var(--border-strong); background: var(--surface-muted); }
|
|
8
|
+
.trigger:disabled { opacity: .5; cursor: not-allowed; }
|
|
9
|
+
/* The chevron stays pinned to the trailing edge; a selection only reserves room for the clear button beside it, so nothing jumps. */
|
|
10
|
+
.hasClear .chevron { margin-left: 26px; }
|
|
11
|
+
.value { position: relative; display: flex; min-width: 0; min-height: 26px; flex: 1; align-items: center; overflow: hidden; }
|
|
12
|
+
.placeholder, .description { color: var(--text-muted); }
|
|
13
|
+
/* The placeholder sits outside the flow so the first chip can open its slot from the leading edge. */
|
|
14
|
+
.placeholder { position: absolute; inset: 0; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
|
|
15
|
+
/* The slot clips while its width springs open or closed; the chip keeps its natural width so the label never re-truncates mid-flight. */
|
|
16
|
+
.slot { display: flex; flex: 0 1 auto; min-width: 0; overflow: hidden; }
|
|
17
|
+
.slot:has(.more) { flex-shrink: 0; }
|
|
18
|
+
.chip, .more { box-sizing: border-box; flex: 0 0 auto; max-width: 9rem; overflow: hidden; margin-right: 5px; border-radius: var(--radius-full); corner-shape: round; padding: 4px 8px; background: var(--surface-muted); box-shadow: inset 0 0 0 1px var(--border-subtle); color: var(--foreground); text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); transition: background-color var(--duration-fast) var(--ease-standard); }
|
|
19
|
+
.trigger[aria-expanded="true"] .chip, .trigger[aria-expanded="true"] .more { background: var(--surface); }
|
|
20
|
+
@media (hover: hover) and (pointer: fine) { .trigger:hover:not(:disabled) .chip, .trigger:hover:not(:disabled) .more { background: var(--surface); } }
|
|
21
|
+
.more { display: inline-flex; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
|
|
22
|
+
.count { display: inline-grid; }
|
|
23
|
+
.count > span { grid-area: 1 / 1; }
|
|
24
|
+
.srOnly { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
|
25
|
+
.clear { position: absolute; top: 0; bottom: 0; right: 36px; display: grid; width: 22px; height: 22px; margin: auto 0; place-items: center; border: 0; border-radius: var(--radius-full); corner-shape: round; background: transparent; color: var(--text-muted); cursor: pointer; transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard); }
|
|
26
|
+
@media (hover: hover) and (pointer: fine) { .clear:hover { background: var(--surface); color: var(--foreground); } }
|
|
27
|
+
.chevron { flex: 0 0 auto; color: var(--text-muted); transition: transform var(--duration-spring) var(--ease-spring); }
|
|
28
|
+
.trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
|
|
29
|
+
.description { font-size: var(--text-xs); }
|
|
30
|
+
.menu { position: absolute; z-index: 80; top: calc(100% + 8px); right: 0; left: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); padding: 5px; background: var(--surface-raised); box-shadow: var(--shadow-floating); transform-origin: top center; will-change: transform, opacity; }
|
|
31
|
+
/* Arrow keys move the highlight often, so it changes almost instantly. Selection is shown by the check, not by weight, so labels never reflow. */
|
|
32
|
+
.option { display: flex; width: 100%; min-height: 38px; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-radius: calc(var(--radius-container) - 5px); corner-shape: var(--corner-shape); padding: 0 11px; background: transparent; color: var(--foreground); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer; transition: background-color 80ms var(--ease-standard), color 80ms var(--ease-standard); }
|
|
33
|
+
.option > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
34
|
+
.option[data-active="true"] { background: var(--surface-muted); }
|
|
35
|
+
.option:disabled { opacity: .42; cursor: not-allowed; }
|
|
36
|
+
.check { flex: 0 0 auto; }
|
|
37
|
+
@media (prefers-reduced-motion: reduce) { .trigger, .chevron, .option, .clear, .chip, .more { transition: none; } }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface NotificationItem {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
time: string;
|
|
6
|
+
read?: boolean;
|
|
7
|
+
tone?: "info" | "success" | "warning";
|
|
8
|
+
/** A local portrait asset for person-generated updates. */
|
|
9
|
+
actor?: {
|
|
10
|
+
name: string;
|
|
11
|
+
photo: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface NotificationCenterProps {
|
|
15
|
+
notifications: NotificationItem[];
|
|
16
|
+
label?: string;
|
|
17
|
+
onReadChange?: (notification: NotificationItem, read: boolean) => void;
|
|
18
|
+
onDismiss?: (notification: NotificationItem) => void;
|
|
19
|
+
open?: boolean;
|
|
20
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
|
+
avoidCollisions?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function NotificationCenter({ notifications: initial, label, onReadChange, onDismiss, open, onOpenChange, avoidCollisions }: NotificationCenterProps): import("react").JSX.Element;
|
|
24
|
+
export default NotificationCenter;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { AnimatePresence, animate, motion, useIsPresent, useMotionValue, useReducedMotion } from "motion/react";
|
|
5
|
+
import { Bell, Check, CheckCheck, CircleCheck, CircleDot, MessageCircle, TriangleAlert, X } from "lucide-react";
|
|
6
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
7
|
+
import { Avatar } from "../avatar/avatar.js";
|
|
8
|
+
import { motionTokens } from "../../lib/motion-tokens.js";
|
|
9
|
+
import styles from "./notification-center.module.css";
|
|
10
|
+
const enter = { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter] };
|
|
11
|
+
const exitFast = { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.standard] };
|
|
12
|
+
const instant = { duration: 0 };
|
|
13
|
+
const textIn = { opacity: 0, y: "0.3em", filter: `blur(${motionTokens.blur.soft}px)` };
|
|
14
|
+
const textOut = { opacity: 0, y: "-0.3em", filter: `blur(${motionTokens.blur.subtle}px)`, transition: exitFast };
|
|
15
|
+
const iconIn = { opacity: 0, scale: .6, filter: `blur(${motionTokens.blur.subtle}px)` };
|
|
16
|
+
const shown = { opacity: 1, y: "0em", scale: 1, filter: "blur(0px)" };
|
|
17
|
+
const fadeOut = { opacity: 0, transition: { duration: motionTokens.duration.instant } };
|
|
18
|
+
/** Bulk actions cascade down the list, capped so the whole sweep stays under a quarter second. */
|
|
19
|
+
const cascade = (index) => Math.min(index * motionTokens.stagger.item, .2);
|
|
20
|
+
/** Outgoing copies are hidden from assistive tech while they fade, so live text reads only the current value. */
|
|
21
|
+
function Swap(props) {
|
|
22
|
+
const present = useIsPresent();
|
|
23
|
+
return _jsx(motion.span, { ...props, "aria-hidden": present ? props["aria-hidden"] : true });
|
|
24
|
+
}
|
|
25
|
+
function SwapText({ children, reduce }) {
|
|
26
|
+
return _jsx("span", { className: styles.swap, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(Swap, { className: styles.swapLine, initial: reduce ? { opacity: 0 } : textIn, animate: shown, exit: reduce ? fadeOut : textOut, transition: reduce ? instant : enter, children: children }, children) }) });
|
|
27
|
+
}
|
|
28
|
+
const rollVariants = {
|
|
29
|
+
enter: (direction) => ({ opacity: 0, y: direction >= 0 ? "0.7em" : "-0.7em", filter: `blur(${motionTokens.blur.subtle}px)` }),
|
|
30
|
+
center: { opacity: 1, y: "0em", filter: "blur(0px)" },
|
|
31
|
+
exit: (direction) => ({ opacity: 0, y: direction >= 0 ? "-0.7em" : "0.7em", filter: `blur(${motionTokens.blur.subtle}px)`, transition: exitFast }),
|
|
32
|
+
};
|
|
33
|
+
/** Counts roll like an odometer: a higher number rises from below, a lower one drops from above. */
|
|
34
|
+
function RollingCount({ value, display = String(value), reduce }) {
|
|
35
|
+
const [previous, setPrevious] = useState(value);
|
|
36
|
+
const [direction, setDirection] = useState(0);
|
|
37
|
+
if (value !== previous) {
|
|
38
|
+
setDirection(value > previous ? 1 : -1);
|
|
39
|
+
setPrevious(value);
|
|
40
|
+
}
|
|
41
|
+
return _jsx("span", { className: styles.roll, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: direction, children: _jsx(Swap, { className: styles.rollValue, custom: direction, variants: reduce ? undefined : rollVariants, initial: reduce ? { opacity: 0 } : "enter", animate: reduce ? { opacity: 1 } : "center", exit: reduce ? fadeOut : "exit", transition: reduce ? instant : { y: motionTokens.spring.snappy, opacity: exitFast, filter: exitFast }, children: display }, display) }) });
|
|
42
|
+
}
|
|
43
|
+
/** Follows the width of its content. After `morphKey` changes the width springs from the old size to the new one, then returns to auto, so a longer label grows the control instead of snapping it. */
|
|
44
|
+
function MorphWidth({ reduce, morphKey, children }) {
|
|
45
|
+
const frame = useRef(null);
|
|
46
|
+
const content = useRef(null);
|
|
47
|
+
const width = useMotionValue("auto");
|
|
48
|
+
const changedAt = useRef(0);
|
|
49
|
+
useLayoutEffect(() => { changedAt.current = performance.now(); }, [morphKey]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const node = content.current;
|
|
52
|
+
if (!node || typeof ResizeObserver === "undefined")
|
|
53
|
+
return;
|
|
54
|
+
let last;
|
|
55
|
+
let controls;
|
|
56
|
+
const settle = () => { width.jump("auto"); if (frame.current)
|
|
57
|
+
frame.current.style.width = "auto"; };
|
|
58
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
59
|
+
if (!entry)
|
|
60
|
+
return;
|
|
61
|
+
const next = entry.borderBoxSize?.[0]?.inlineSize ?? node.offsetWidth;
|
|
62
|
+
const current = width.get();
|
|
63
|
+
const from = typeof current === "number" ? current : last;
|
|
64
|
+
last = next;
|
|
65
|
+
controls?.stop();
|
|
66
|
+
if (reduce || from === undefined || from === next || performance.now() - changedAt.current > 120)
|
|
67
|
+
return settle();
|
|
68
|
+
// Pin the old width before this frame paints, then spring to the new one.
|
|
69
|
+
if (frame.current)
|
|
70
|
+
frame.current.style.width = `${from}px`;
|
|
71
|
+
controls = animate(width, [from, next], { ...motionTokens.spring.morph, onComplete: settle });
|
|
72
|
+
});
|
|
73
|
+
observer.observe(node);
|
|
74
|
+
return () => { observer.disconnect(); controls?.stop(); };
|
|
75
|
+
}, [width, reduce]);
|
|
76
|
+
return _jsx(motion.span, { ref: frame, className: styles.morph, style: { width }, children: _jsx("span", { ref: content, className: styles.morphContent, children: children }) });
|
|
77
|
+
}
|
|
78
|
+
function NotificationVisual({ item }) {
|
|
79
|
+
if (item.actor)
|
|
80
|
+
return _jsx(Avatar, { name: item.actor.name, src: item.actor.photo, size: "md" });
|
|
81
|
+
return _jsx("span", { className: [styles.eventIcon, styles[item.tone ?? "info"]].join(" "), "aria-hidden": "true", children: item.tone === "warning" ? _jsx(TriangleAlert, { size: 18, strokeWidth: 1.7 }) : item.tone === "success" ? _jsx(CircleCheck, { size: 18, strokeWidth: 1.7 }) : _jsx(MessageCircle, { size: 18, strokeWidth: 1.7 }) });
|
|
82
|
+
}
|
|
83
|
+
export function NotificationCenter({ notifications: initial, label = "Notifications", onReadChange, onDismiss, open, onOpenChange, avoidCollisions = true }) {
|
|
84
|
+
const reduce = useReducedMotion();
|
|
85
|
+
const layoutId = useId();
|
|
86
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
87
|
+
const [items, setItems] = useState(initial);
|
|
88
|
+
const [view, setView] = useState("all");
|
|
89
|
+
const [expandedId, setExpandedId] = useState(null);
|
|
90
|
+
const [bulk, setBulk] = useState(false);
|
|
91
|
+
const itemRefs = useRef(new Map());
|
|
92
|
+
const allTabRef = useRef(null);
|
|
93
|
+
const unreadTabRef = useRef(null);
|
|
94
|
+
const isOpen = open ?? internalOpen;
|
|
95
|
+
const unreadCount = useMemo(() => items.filter((item) => !item.read).length, [items]);
|
|
96
|
+
const readCount = items.length - unreadCount;
|
|
97
|
+
const visible = view === "unread" ? items.filter((item) => !item.read) : items;
|
|
98
|
+
const summary = unreadCount ? `${unreadCount} update${unreadCount === 1 ? "" : "s"} waiting for you` : "You’re all caught up";
|
|
99
|
+
function setOpen(next) {
|
|
100
|
+
if (open === undefined)
|
|
101
|
+
setInternalOpen(next);
|
|
102
|
+
onOpenChange?.(next);
|
|
103
|
+
}
|
|
104
|
+
function toggleRead(item) {
|
|
105
|
+
const next = !item.read;
|
|
106
|
+
if (next && view === "unread") {
|
|
107
|
+
const index = visible.findIndex((entry) => entry.id === item.id);
|
|
108
|
+
const nextId = visible[index + 1]?.id ?? visible[index - 1]?.id;
|
|
109
|
+
requestAnimationFrame(() => nextId ? itemRefs.current.get(nextId)?.focus() : unreadTabRef.current?.focus());
|
|
110
|
+
}
|
|
111
|
+
setBulk(false);
|
|
112
|
+
setItems((current) => current.map((entry) => entry.id === item.id ? { ...entry, read: next } : entry));
|
|
113
|
+
if (next && view === "unread")
|
|
114
|
+
setExpandedId(null);
|
|
115
|
+
onReadChange?.(item, next);
|
|
116
|
+
}
|
|
117
|
+
function markAllRead() {
|
|
118
|
+
items.filter((item) => !item.read).forEach((item) => onReadChange?.(item, true));
|
|
119
|
+
setBulk(true);
|
|
120
|
+
setItems((current) => current.map((item) => ({ ...item, read: true })));
|
|
121
|
+
setExpandedId(null);
|
|
122
|
+
requestAnimationFrame(() => (view === "unread" ? unreadTabRef : allTabRef).current?.focus());
|
|
123
|
+
}
|
|
124
|
+
function dismiss(item) {
|
|
125
|
+
const index = visible.findIndex((entry) => entry.id === item.id);
|
|
126
|
+
const nextId = visible[index + 1]?.id ?? visible[index - 1]?.id;
|
|
127
|
+
requestAnimationFrame(() => nextId ? itemRefs.current.get(nextId)?.focus() : unreadTabRef.current?.focus());
|
|
128
|
+
setBulk(false);
|
|
129
|
+
setItems((current) => current.filter((entry) => entry.id !== item.id));
|
|
130
|
+
if (expandedId === item.id)
|
|
131
|
+
setExpandedId(null);
|
|
132
|
+
onDismiss?.(item);
|
|
133
|
+
}
|
|
134
|
+
function clearRead() {
|
|
135
|
+
items.filter((item) => item.read).forEach((item) => onDismiss?.(item));
|
|
136
|
+
setBulk(true);
|
|
137
|
+
setItems((current) => current.filter((item) => !item.read));
|
|
138
|
+
requestAnimationFrame(() => allTabRef.current?.focus());
|
|
139
|
+
}
|
|
140
|
+
const height = reduce ? instant : { height: motionTokens.spring.smooth, opacity: enter };
|
|
141
|
+
return _jsxs(PopoverPrimitive.Root, { open: isOpen, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { className: styles.trigger, type: "button", "aria-label": `${label}${unreadCount ? `, ${unreadCount} unread` : ""}`, children: [_jsx(motion.span, { animate: { rotate: isOpen && !reduce ? -12 : 0 }, transition: reduce ? instant : motionTokens.spring.snappy, children: _jsx(Bell, { size: 19, strokeWidth: 1.75, "aria-hidden": "true" }) }), _jsx(AnimatePresence, { initial: false, children: unreadCount > 0 && _jsx(motion.span, { className: styles.badge, "aria-hidden": "true", initial: reduce ? { opacity: 0 } : { opacity: 0, scale: .6 }, animate: { opacity: 1, scale: 1 }, exit: reduce ? fadeOut : { opacity: 0, scale: .6, transition: exitFast }, transition: reduce ? instant : motionTokens.spring.snappy, children: _jsx(RollingCount, { value: unreadCount, display: unreadCount > 9 ? "9+" : String(unreadCount), reduce: reduce }) }, "badge") })] }) }), _jsx(PopoverPrimitive.Portal, { children: _jsxs(PopoverPrimitive.Content, { className: styles.panel, align: "center", side: "bottom", sideOffset: 12, collisionPadding: 12, avoidCollisions: avoidCollisions, "aria-label": label, children: [_jsxs("div", { className: styles.header, children: [_jsxs("div", { children: [_jsxs("div", { className: styles.heading, children: [_jsx("h2", { children: label }), _jsx("span", { className: styles.count, children: _jsx(RollingCount, { value: unreadCount, reduce: reduce }) })] }), _jsx("p", { "aria-live": "polite", children: _jsx(SwapText, { reduce: reduce, children: summary }) })] }), _jsx(PopoverPrimitive.Close, { className: styles.close, "aria-label": "Close notifications", children: _jsx(X, { size: 17, strokeWidth: 1.75, "aria-hidden": "true" }) })] }), _jsxs("div", { className: styles.toolbar, children: [_jsx("div", { className: styles.viewSwitch, role: "group", "aria-label": "Show notifications", children: ["all", "unread"].map((next) => _jsxs("button", { ref: next === "unread" ? unreadTabRef : allTabRef, type: "button", className: view === next ? styles.viewActive : undefined, "aria-pressed": view === next, onClick: () => { setBulk(false); setView(next); setExpandedId(null); }, children: [view === next && _jsx(motion.span, { className: styles.viewHighlight, layoutId: `${layoutId}-view`, transition: reduce ? instant : motionTokens.spring.morph }), _jsx("span", { children: next === "all" ? "All" : "Unread" })] }, next)) }), _jsx(AnimatePresence, { initial: false, children: unreadCount > 0 && _jsxs(motion.button, { type: "button", className: styles.markAll, onClick: markAllRead, initial: reduce ? { opacity: 0 } : { opacity: 0, filter: `blur(${motionTokens.blur.subtle}px)` }, animate: { opacity: 1, filter: "blur(0px)" }, exit: reduce ? fadeOut : { opacity: 0, filter: `blur(${motionTokens.blur.subtle}px)`, transition: exitFast }, transition: reduce ? instant : enter, children: [_jsx(CheckCheck, { size: 15, strokeWidth: 1.75, "aria-hidden": "true" }), _jsx("span", { children: "Mark all read" })] }, "mark-all") })] }), _jsx("div", { className: styles.list, role: "list", "aria-label": view === "all" ? "All notifications" : "Unread notifications", children: _jsxs(AnimatePresence, { initial: false, custom: bulk, children: [visible.map((item, index) => _jsx(motion.div, { role: "listitem", className: styles.row, custom: bulk, variants: { exit: (isBulk) => reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: { ...motionTokens.spring.smooth, delay: isBulk ? cascade(index) : 0 }, opacity: { ...exitFast, delay: isBulk ? cascade(index) : 0 } } } }, initial: reduce ? { opacity: 0 } : { height: 0 }, animate: { height: "auto", opacity: 1 }, exit: "exit", transition: height, children: _jsxs("article", { className: [styles.item, item.read ? styles.itemRead : "", expandedId === item.id ? styles.itemExpanded : ""].filter(Boolean).join(" "), style: { "--index": Math.min(index, 7) }, children: [_jsxs("div", { className: styles.itemMain, children: [_jsx(NotificationVisual, { item: item }), _jsxs("button", { ref: (node) => { if (node)
|
|
142
|
+
itemRefs.current.set(item.id, node);
|
|
143
|
+
else
|
|
144
|
+
itemRefs.current.delete(item.id); }, type: "button", className: styles.itemToggle, "aria-expanded": expandedId === item.id, "aria-label": `${item.title}${item.read ? "" : ", unread"}. ${expandedId === item.id ? "Hide details" : "Show details"}`, onClick: () => setExpandedId((current) => current === item.id ? null : item.id), children: [_jsxs("span", { className: styles.itemTitle, children: [_jsx("strong", { children: item.title }), _jsx(AnimatePresence, { initial: false, custom: bulk, children: !item.read && _jsx(motion.span, { className: styles.unreadDot, "aria-hidden": "true", custom: bulk, variants: { exit: (isBulk) => reduce ? fadeOut : { opacity: 0, scale: .3, transition: { ...exitFast, delay: isBulk ? cascade(index) : 0 } } }, initial: reduce ? { opacity: 0 } : { opacity: 0, scale: .3 }, animate: { opacity: 1, scale: 1 }, exit: "exit", transition: reduce ? instant : motionTokens.spring.snappy }, "dot") })] }), _jsx("span", { className: styles.itemPreview, children: item.description ?? (item.actor ? `From ${item.actor.name}` : "View update details") })] }), _jsx("time", { className: styles.time, children: item.time })] }), _jsx(AnimatePresence, { initial: false, children: expandedId === item.id && _jsxs(motion.div, { className: styles.details, initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: motionTokens.spring.smooth, opacity: exitFast } }, transition: height, children: [_jsx("p", { children: item.description ?? (item.actor ? `${item.actor.name} shared an update with you.` : "This update is ready to review.") }), _jsxs("div", { className: styles.itemActions, children: [_jsx("button", { type: "button", onClick: () => toggleRead(item), children: _jsxs(MorphWidth, { reduce: reduce, morphKey: item.read ? "read" : "unread", children: [_jsx("span", { className: styles.actionIcon, children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, children: _jsx(Swap, { className: styles.actionGlyph, initial: reduce ? { opacity: 0 } : iconIn, animate: shown, exit: reduce ? fadeOut : { ...iconIn, transition: exitFast }, transition: reduce ? instant : motionTokens.spring.snappy, children: item.read ? _jsx(CircleDot, { size: 14, strokeWidth: 1.75, "aria-hidden": "true" }) : _jsx(Check, { size: 14, strokeWidth: 1.75, "aria-hidden": "true" }) }, item.read ? "unread" : "read") }) }), _jsx(SwapText, { reduce: reduce, children: item.read ? "Mark unread" : "Mark read" })] }) }), _jsxs("button", { type: "button", onClick: () => dismiss(item), children: [_jsx(X, { size: 14, strokeWidth: 1.75, "aria-hidden": "true" }), "Dismiss"] })] })] }) })] }) }, item.id)), visible.length === 0 && _jsx(motion.div, { className: styles.emptyFrame, initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: motionTokens.spring.smooth, opacity: exitFast } }, transition: reduce ? instant : { height: { ...motionTokens.spring.smooth, delay: bulk ? cascade(3) : 0 }, opacity: { ...enter, delay: motionTokens.duration.fast } }, children: _jsxs(motion.div, { className: styles.empty, initial: reduce ? false : { y: 6 }, animate: { y: 0 }, transition: reduce ? instant : { ...enter, delay: motionTokens.duration.fast }, children: [_jsx(CircleCheck, { size: 24, strokeWidth: 1.5, "aria-hidden": "true" }), _jsx("strong", { children: _jsx(SwapText, { reduce: reduce, children: view === "unread" ? "Nothing unread" : "All clear" }) }), _jsx("p", { children: _jsx(SwapText, { reduce: reduce, children: view === "unread" ? "You’ve seen every update." : "New updates will appear here." }) }), view === "unread" && items.length > 0 && _jsx("button", { type: "button", onClick: () => { setBulk(false); setView("all"); }, children: "View all updates" })] }) }, "empty")] }) }), _jsx(AnimatePresence, { initial: false, children: readCount > 0 && _jsx(motion.div, { className: styles.footerFrame, initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0 }, animate: { height: "auto", opacity: 1 }, exit: reduce ? fadeOut : { height: 0, opacity: 0, transition: { height: motionTokens.spring.smooth, opacity: exitFast } }, transition: height, children: _jsxs("div", { className: styles.footer, children: [_jsxs("span", { children: [_jsx(RollingCount, { value: readCount, reduce: reduce }), " read"] }), _jsx("button", { type: "button", onClick: clearRead, children: "Clear read" })] }) }, "footer") })] }) })] });
|
|
145
|
+
}
|
|
146
|
+
export default NotificationCenter;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
.trigger { position: relative; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--surface); color: var(--foreground); cursor: pointer; transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard); }
|
|
2
|
+
.trigger[data-state="open"], .trigger:active { border-color: var(--border-strong); background: var(--surface-muted); }
|
|
3
|
+
@media (hover: hover) and (pointer: fine) { .trigger:hover { border-color: var(--border-strong); background: var(--surface-muted); } }
|
|
4
|
+
.trigger > span:first-child { display: grid; place-items: center; }
|
|
5
|
+
.badge { position: absolute; top: -6px; right: -6px; display: grid; min-width: 20px; height: 20px; padding: 0 5px; place-items: center; overflow: hidden; border: 2px solid var(--surface); border-radius: var(--radius-full); corner-shape: round; background: var(--foreground); color: var(--background); font-size: var(--text-xs); font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
|
|
6
|
+
.panel { z-index: 90; display: flex; flex-direction: column; width: min(424px, calc(100vw - 24px)); max-height: min(590px, calc(100vh - 24px)); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--surface-raised); color: var(--foreground); box-shadow: var(--shadow-floating); font-family: var(--font-body); letter-spacing: var(--tracking-body); transform-origin: var(--radix-popover-content-transform-origin); }
|
|
7
|
+
/* The panel grows out of the bell: it starts a few pixels toward the trigger on whichever side Radix placed it, and leaves faster than it arrives. */
|
|
8
|
+
.panel { --panel-x: 0px; --panel-y: -6px; }
|
|
9
|
+
.panel[data-side="top"] { --panel-y: 6px; }
|
|
10
|
+
.panel[data-side="left"] { --panel-x: 6px; --panel-y: 0px; }
|
|
11
|
+
.panel[data-side="right"] { --panel-x: -6px; --panel-y: 0px; }
|
|
12
|
+
.panel[data-state="open"] { animation: panel-open var(--duration-standard) var(--ease-enter) both; }
|
|
13
|
+
.panel[data-state="closed"] { animation: panel-close var(--duration-instant) var(--ease-standard) both; }
|
|
14
|
+
.header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 23px 24px 18px; }
|
|
15
|
+
.heading { display: flex; align-items: center; gap: var(--space-related); }
|
|
16
|
+
.heading h2 { margin: 0; font-size: var(--text-xl); font-weight: 500; letter-spacing: var(--tracking-body); line-height: 1.2; }
|
|
17
|
+
.count { display: grid; min-width: 21px; height: 21px; padding: 0 5px; place-items: center; overflow: hidden; border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: var(--surface-muted); color: var(--text-secondary); font-size: var(--text-xs); line-height: 1; font-variant-numeric: tabular-nums; }
|
|
18
|
+
.header p { position: relative; margin: 4px 0 0; color: var(--text-secondary); font-size: var(--text-xs); line-height: var(--leading-body); }
|
|
19
|
+
.close { display: grid; width: 30px; height: 30px; flex: none; place-items: center; border: 0; border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: transparent; color: var(--text-muted); cursor: pointer; transition: transform var(--duration-spring) var(--ease-spring), color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard); }
|
|
20
|
+
.close:active { transform: scale(.96); }
|
|
21
|
+
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 17px 13px 20px; border-bottom: 1px solid var(--border-subtle); }
|
|
22
|
+
.viewSwitch { display: inline-flex; align-items: center; gap: 3px; }
|
|
23
|
+
.viewSwitch button { position: relative; isolation: isolate; min-width: 61px; height: 31px; padding: 0 10px; border: 0; border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: transparent; color: var(--text-secondary); font: inherit; font-size: var(--text-xs); cursor: pointer; transition: color var(--duration-fast) var(--ease-standard); }
|
|
24
|
+
.viewSwitch .viewActive { color: var(--foreground); }
|
|
25
|
+
.viewSwitch button > span:last-child { position: relative; z-index: 1; }
|
|
26
|
+
.viewHighlight { position: absolute; z-index: -1; inset: 0; border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: var(--surface-muted); }
|
|
27
|
+
.markAll { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: var(--text-xs); white-space: nowrap; cursor: pointer; transition: transform var(--duration-spring) var(--ease-spring), color var(--duration-fast) var(--ease-standard); }
|
|
28
|
+
.markAll:active { transform: scale(.97); }
|
|
29
|
+
.list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 9px 11px 10px; scrollbar-width: none; }
|
|
30
|
+
.list::-webkit-scrollbar { display: none; }
|
|
31
|
+
.row { overflow: hidden; }
|
|
32
|
+
/* Rows settle in with a short cascade when the panel opens or a view adds them. */
|
|
33
|
+
.item { position: relative; padding: 10px; border-radius: calc(var(--radius-container) - 12px); corner-shape: var(--corner-shape); transition: background var(--duration-fast) var(--ease-standard); animation: item-in var(--duration-standard) var(--ease-enter) calc(var(--index, 0) * 35ms) both; }
|
|
34
|
+
.itemExpanded { background: var(--surface-muted); }
|
|
35
|
+
.itemRead .itemTitle strong { color: var(--text-secondary); }
|
|
36
|
+
.itemMain { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
|
|
37
|
+
.eventIcon { display: grid; width: 36px; height: 36px; flex: none; place-items: center; color: var(--accent); }
|
|
38
|
+
.eventIcon.success { color: var(--success); }
|
|
39
|
+
.eventIcon.warning { color: var(--warning); }
|
|
40
|
+
.itemToggle { display: grid; min-width: 0; flex: 1; gap: 4px; padding: 2px 0 0; border: 0; background: transparent; color: var(--foreground); text-align: left; font: inherit; cursor: pointer; }
|
|
41
|
+
.itemTitle { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 20px; }
|
|
42
|
+
.itemTitle strong { overflow: hidden; font-size: var(--text-sm); font-weight: 500; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
|
|
43
|
+
.unreadDot { display: block; width: 6px; height: 6px; flex: none; border-radius: 50%; corner-shape: round; background: var(--foreground); }
|
|
44
|
+
.itemPreview { overflow: hidden; color: var(--text-secondary); font-size: var(--text-xs); line-height: var(--leading-body); text-overflow: ellipsis; white-space: nowrap; }
|
|
45
|
+
.time { flex: none; padding-top: 4px; color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
46
|
+
.details { overflow: hidden; padding-left: 47px; }
|
|
47
|
+
.details p { margin: 12px 0; color: var(--text-secondary); font-size: var(--text-xs); line-height: var(--leading-body); }
|
|
48
|
+
.itemActions { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 5px; }
|
|
49
|
+
.itemActions button { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; overflow: clip; border: 1px solid var(--border); border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: transparent; color: var(--foreground); font: inherit; font-size: var(--text-xs); line-height: 1; white-space: nowrap; cursor: pointer; transition: transform var(--duration-spring) var(--ease-spring), border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard); }
|
|
50
|
+
.itemActions button:active { transform: scale(.97); }
|
|
51
|
+
/* Quick press, spring release: the resting transition above carries the spring back. */
|
|
52
|
+
.close:active, .markAll:active, .itemActions button:active, .footer button:active { transition-duration: var(--duration-instant); transition-timing-function: var(--ease-standard); }
|
|
53
|
+
.morph { display: inline-flex; align-items: center; }
|
|
54
|
+
.morphContent { position: relative; display: inline-flex; width: max-content; align-items: center; gap: 5px; }
|
|
55
|
+
.actionIcon, .actionGlyph { position: relative; display: grid; place-items: center; }
|
|
56
|
+
.swap { position: relative; display: inline-block; max-width: 100%; vertical-align: top; }
|
|
57
|
+
.swapLine { display: block; }
|
|
58
|
+
.roll { position: relative; display: inline-grid; vertical-align: top; }
|
|
59
|
+
.rollValue { display: block; }
|
|
60
|
+
.emptyFrame { overflow: hidden; }
|
|
61
|
+
.empty { display: grid; justify-items: center; align-content: center; min-height: 190px; padding: 22px 12px; text-align: center; }
|
|
62
|
+
.empty > svg { margin-bottom: 13px; color: var(--text-muted); }
|
|
63
|
+
.empty strong { font-size: var(--text-sm); font-weight: 500; }
|
|
64
|
+
.empty p { margin: 4px 0 0; color: var(--text-secondary); font-size: var(--text-xs); }
|
|
65
|
+
.empty button { margin-top: 16px; padding: 0; border: 0; background: transparent; color: var(--foreground); font: inherit; font-size: var(--text-xs); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
|
|
66
|
+
.footerFrame { flex: none; overflow: hidden; }
|
|
67
|
+
.footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 8px 22px; border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: var(--text-xs); }
|
|
68
|
+
.footer button { padding: 4px 0; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: var(--text-xs); cursor: pointer; transition: transform var(--duration-spring) var(--ease-spring), color var(--duration-fast) var(--ease-standard); }
|
|
69
|
+
.footer button:active { transform: scale(.97); }
|
|
70
|
+
@media (hover: hover) and (pointer: fine) {
|
|
71
|
+
.close:hover, .item:hover { background: var(--surface-muted); }
|
|
72
|
+
.close:hover, .viewSwitch button:hover, .markAll:hover, .footer button:hover { color: var(--foreground); }
|
|
73
|
+
.itemActions button:hover { border-color: var(--border-strong); background: var(--surface); }
|
|
74
|
+
}
|
|
75
|
+
@keyframes panel-open { from { opacity: 0; transform: translate(var(--panel-x), var(--panel-y)) scale(.97); } }
|
|
76
|
+
@keyframes panel-close { to { opacity: 0; transform: translate(calc(var(--panel-x) / 2), calc(var(--panel-y) / 2)) scale(.98); } }
|
|
77
|
+
@keyframes item-in { from { opacity: 0; transform: translateY(4px); } }
|
|
78
|
+
@media (max-width: 380px) { .header { padding: 20px 16px 16px; } .heading h2 { font-size: var(--text-lg); } .toolbar { align-items: flex-start; padding: 0 12px 12px; } .list { padding: 8px 5px; } .item { padding-inline: 7px; } .itemMain { gap: 7px; } .details { padding-left: 43px; } .itemActions { gap: 5px; } .itemActions button { padding-inline: 7px; } .markAll span { display: none; } .footer { padding-inline: 16px; } }
|
|
79
|
+
@media (prefers-reduced-motion: reduce) { .panel[data-state], .trigger, .close, .viewSwitch button, .markAll, .item, .itemActions button, .footer button { animation: none; transition-duration: 0ms; } .close:active, .markAll:active, .itemActions button:active, .footer button:active { transform: none; } }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Text shown beside the number. A function receives the value, so a unit can follow it: `n => n === 1 ? " seat" : " seats"`. */
|
|
2
|
+
export type NumberFieldAffix = string | ((value: number) => string);
|
|
3
|
+
export interface NumberFieldProps {
|
|
4
|
+
label: string;
|
|
5
|
+
value?: number;
|
|
6
|
+
defaultValue?: number;
|
|
7
|
+
onValueChange?: (value: number) => void;
|
|
8
|
+
min?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
step?: number;
|
|
11
|
+
/** PageUp, PageDown, and Shift with an arrow move this far. Defaults to ten steps. */
|
|
12
|
+
largeStep?: number;
|
|
13
|
+
description?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
/** Text before the number, such as "$". */
|
|
17
|
+
prefix?: NumberFieldAffix;
|
|
18
|
+
/** Text after the number, such as " seats". */
|
|
19
|
+
suffix?: NumberFieldAffix;
|
|
20
|
+
/** Drag the label sideways to scrub the value, one step every few pixels. */
|
|
21
|
+
scrub?: boolean;
|
|
22
|
+
/** Formatting locale. Fixed by default so server and client render the same digits. */
|
|
23
|
+
locale?: string;
|
|
24
|
+
/** Fraction digits and grouping. Fraction digits follow the precision of `step` by default. */
|
|
25
|
+
formatOptions?: {
|
|
26
|
+
minimumFractionDigits?: number;
|
|
27
|
+
maximumFractionDigits?: number;
|
|
28
|
+
useGrouping?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/** Control height, type size, and default width. */
|
|
31
|
+
size?: NumberFieldSize;
|
|
32
|
+
/** A short note beside the label when a press meets a limit or a typed value passes one. `false` hides it; a function writes the copy. */
|
|
33
|
+
limitHint?: boolean | ((edge: "min" | "max", limit: number) => string);
|
|
34
|
+
}
|
|
35
|
+
export type NumberFieldSize = "sm" | "md" | "lg";
|
|
36
|
+
/**
|
|
37
|
+
* A bounded number with odometer digits. Buttons and arrow keys repeat and speed up while held, PageUp and PageDown take
|
|
38
|
+
* large steps, Home and End jump to the limits, and `scrub` lets the label be dragged. Typing edits a plain draft that
|
|
39
|
+
* applies live while valid; the rolling digits return once it commits on Enter, blur, or the next step.
|
|
40
|
+
*/
|
|
41
|
+
export declare function NumberField({ label, value, defaultValue, onValueChange, min, max, step: stepProp, largeStep, description, disabled, id, prefix, suffix, scrub, locale, formatOptions, size, limitHint }: NumberFieldProps): import("react").JSX.Element;
|