@robert-stackflow/oneui 0.0.0-stage → 0.2.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/CHANGELOG.md +18 -0
- package/README.md +72 -2
- package/assets/LUCIDE-LICENSE.txt +43 -0
- package/assets/character-metadata.json +1 -0
- package/assets/emoji.json +1 -0
- package/assets/icon-catalog.json +1 -0
- package/assets/symbols.json +1 -0
- package/components/Accessibility.module.css +8 -0
- package/components/Accordion.d.ts +7 -0
- package/components/Accordion.js +41 -0
- package/components/Accordion.module.css +38 -0
- package/components/Alert.d.ts +9 -0
- package/components/Alert.js +42 -0
- package/components/Alert.module.css +56 -0
- package/components/AppShell.d.ts +30 -0
- package/components/AppShell.js +152 -0
- package/components/AppShell.module.css +239 -0
- package/components/AppearanceSettings.d.ts +7 -0
- package/components/AppearanceSettings.js +201 -0
- package/components/AppearanceSettings.module.css +32 -0
- package/components/Avatar.d.ts +14 -0
- package/components/Avatar.js +69 -0
- package/components/Avatar.module.css +70 -0
- package/components/AvatarGroup.d.ts +15 -0
- package/components/AvatarGroup.js +115 -0
- package/components/AvatarGroup.module.css +54 -0
- package/components/Badge.d.ts +5 -0
- package/components/Badge.js +11 -0
- package/components/Badge.module.css +30 -0
- package/components/BlockedTab.d.ts +4 -0
- package/components/BlockedTab.js +10 -0
- package/components/Breadcrumb.d.ts +16 -0
- package/components/Breadcrumb.js +157 -0
- package/components/Breadcrumb.module.css +97 -0
- package/components/Button.d.ts +13 -0
- package/components/Button.js +52 -0
- package/components/Button.module.css +88 -0
- package/components/Calendar.d.ts +10 -0
- package/components/Calendar.js +260 -0
- package/components/Calendar.module.css +106 -0
- package/components/Card.d.ts +8 -0
- package/components/Card.js +29 -0
- package/components/Card.module.css +47 -0
- package/components/Cascader.d.ts +14 -0
- package/components/Cascader.js +296 -0
- package/components/CatalogIcon.d.ts +3 -0
- package/components/CatalogIcon.js +11 -0
- package/components/CharacterPicker.d.ts +15 -0
- package/components/CharacterPicker.js +200 -0
- package/components/Checkbox.d.ts +12 -0
- package/components/Checkbox.js +82 -0
- package/components/Checkbox.module.css +95 -0
- package/components/ColorField.d.ts +6 -0
- package/components/ColorField.js +61 -0
- package/components/ColorField.module.css +15 -0
- package/components/ColorPicker.d.ts +5 -0
- package/components/ColorPicker.js +188 -0
- package/components/ColorPicker.module.css +90 -0
- package/components/Combobox.d.ts +13 -0
- package/components/Combobox.js +338 -0
- package/components/Combobox.module.css +24 -0
- package/components/CommandPalette.d.ts +25 -0
- package/components/CommandPalette.js +269 -0
- package/components/CommandPalette.module.css +49 -0
- package/components/ContextMenu.d.ts +9 -0
- package/components/ContextMenu.js +363 -0
- package/components/ContextMenu.module.css +42 -0
- package/components/ContextMenuPanel.d.ts +22 -0
- package/components/ContextMenuPanel.js +155 -0
- package/components/ContributionCalendar.d.ts +18 -0
- package/components/ContributionCalendar.js +201 -0
- package/components/ContributionCalendar.module.css +114 -0
- package/components/ContributionCell.d.ts +11 -0
- package/components/ContributionCell.js +41 -0
- package/components/Control.module.css +86 -0
- package/components/DataTable.d.ts +49 -0
- package/components/DataTable.js +220 -0
- package/components/DataTable.module.css +112 -0
- package/components/DatePicker.d.ts +15 -0
- package/components/DatePicker.js +186 -0
- package/components/DatePicker.module.css +85 -0
- package/components/DateRangePicker.d.ts +9 -0
- package/components/DateRangePicker.js +168 -0
- package/components/Descriptions.d.ts +21 -0
- package/components/Descriptions.js +162 -0
- package/components/Descriptions.module.css +117 -0
- package/components/Dialog.d.ts +14 -0
- package/components/Dialog.js +125 -0
- package/components/Dialog.module.css +88 -0
- package/components/DialogVariants.d.ts +27 -0
- package/components/DialogVariants.js +161 -0
- package/components/DialogVariants.module.css +29 -0
- package/components/DisclosureChevron.d.ts +3 -0
- package/components/DisclosureChevron.js +17 -0
- package/components/DisclosureChevron.module.css +17 -0
- package/components/Divider.d.ts +5 -0
- package/components/Divider.js +24 -0
- package/components/Divider.module.css +19 -0
- package/components/Drawer.d.ts +18 -0
- package/components/Drawer.js +145 -0
- package/components/Drawer.module.css +109 -0
- package/components/EmojiPicker.d.ts +6 -0
- package/components/EmojiPicker.js +19 -0
- package/components/EmptyState.d.ts +8 -0
- package/components/EmptyState.js +20 -0
- package/components/EmptyState.module.css +30 -0
- package/components/FieldLabel.d.ts +8 -0
- package/components/FieldLabel.js +20 -0
- package/components/FieldMessages.d.ts +5 -0
- package/components/FieldMessages.js +15 -0
- package/components/FileDropOverlay.d.ts +5 -0
- package/components/FileDropOverlay.js +26 -0
- package/components/FileDropOverlay.module.css +55 -0
- package/components/FileDropZone.d.ts +15 -0
- package/components/FileDropZone.js +113 -0
- package/components/FileDropZone.module.css +6 -0
- package/components/FilePicker.d.ts +10 -0
- package/components/FilePicker.js +59 -0
- package/components/FileSelectionFeedback.d.ts +5 -0
- package/components/FileSelectionFeedback.js +23 -0
- package/components/FileSelectionFeedback.module.css +14 -0
- package/components/FileTree.d.ts +13 -0
- package/components/FileTree.js +125 -0
- package/components/FileTree.module.css +66 -0
- package/components/Form.d.ts +7 -0
- package/components/Form.js +26 -0
- package/components/Form.module.css +7 -0
- package/components/FormErrorSummary.d.ts +6 -0
- package/components/FormErrorSummary.js +27 -0
- package/components/FormErrorSummary.module.css +27 -0
- package/components/FormField.d.ts +9 -0
- package/components/FormField.js +59 -0
- package/components/FormField.module.css +85 -0
- package/components/FormGroup.d.ts +9 -0
- package/components/FormGroup.js +32 -0
- package/components/HierarchyPicker.module.css +181 -0
- package/components/IconButton.d.ts +7 -0
- package/components/IconButton.js +30 -0
- package/components/IconButton.module.css +42 -0
- package/components/IconPicker.d.ts +6 -0
- package/components/IconPicker.js +111 -0
- package/components/Indicator.d.ts +18 -0
- package/components/Indicator.js +97 -0
- package/components/Indicator.module.css +83 -0
- package/components/Input.d.ts +8 -0
- package/components/Input.js +37 -0
- package/components/Input.module.css +40 -0
- package/components/LoadingOverlay.d.ts +6 -0
- package/components/LoadingOverlay.js +16 -0
- package/components/LoadingOverlay.module.css +22 -0
- package/components/LoadingState.d.ts +7 -0
- package/components/LoadingState.js +40 -0
- package/components/LoadingState.module.css +17 -0
- package/components/Menu.d.ts +11 -0
- package/components/Menu.js +82 -0
- package/components/MenuItem.d.ts +15 -0
- package/components/MenuItem.js +51 -0
- package/components/MenuItem.module.css +172 -0
- package/components/MenuItemContent.d.ts +8 -0
- package/components/MenuItemContent.js +19 -0
- package/components/MultiSelect.d.ts +13 -0
- package/components/MultiSelect.js +225 -0
- package/components/MultiSelect.module.css +99 -0
- package/components/NumberInput.d.ts +12 -0
- package/components/NumberInput.js +114 -0
- package/components/NumberInput.module.css +33 -0
- package/components/OptionList.module.css +12 -0
- package/components/Page.d.ts +7 -0
- package/components/Page.js +22 -0
- package/components/Page.module.css +44 -0
- package/components/Pagination.d.ts +11 -0
- package/components/Pagination.js +160 -0
- package/components/Pagination.module.css +70 -0
- package/components/PasswordField.d.ts +9 -0
- package/components/PasswordField.js +102 -0
- package/components/PasswordField.module.css +64 -0
- package/components/Picker.module.css +52 -0
- package/components/PinInput.d.ts +13 -0
- package/components/PinInput.js +173 -0
- package/components/PinInput.module.css +72 -0
- package/components/Placeholder.d.ts +31 -0
- package/components/Placeholder.js +36 -0
- package/components/Popconfirm.d.ts +17 -0
- package/components/Popconfirm.js +159 -0
- package/components/Popconfirm.module.css +49 -0
- package/components/Popover.d.ts +16 -0
- package/components/Popover.js +156 -0
- package/components/Popover.module.css +19 -0
- package/components/Progress.d.ts +5 -0
- package/components/Progress.js +31 -0
- package/components/Progress.module.css +33 -0
- package/components/RadioGroup.d.ts +15 -0
- package/components/RadioGroup.js +73 -0
- package/components/RadioGroup.module.css +87 -0
- package/components/RangeSlider.d.ts +22 -0
- package/components/RangeSlider.js +278 -0
- package/components/RangeSlider.module.css +141 -0
- package/components/ResizablePanel.d.ts +21 -0
- package/components/ResizablePanel.js +219 -0
- package/components/ResizablePanel.module.css +101 -0
- package/components/SearchField.d.ts +11 -0
- package/components/SearchField.js +67 -0
- package/components/SearchField.module.css +37 -0
- package/components/Section.d.ts +6 -0
- package/components/Section.js +18 -0
- package/components/Section.module.css +14 -0
- package/components/Segmented.d.ts +11 -0
- package/components/Segmented.js +77 -0
- package/components/Segmented.module.css +82 -0
- package/components/Select.d.ts +11 -0
- package/components/Select.js +172 -0
- package/components/Select.module.css +24 -0
- package/components/SelectOptionContent.d.ts +5 -0
- package/components/SelectOptionContent.js +20 -0
- package/components/SelectOptionContent.module.css +7 -0
- package/components/SelectTrigger.d.ts +5 -0
- package/components/SelectTrigger.js +32 -0
- package/components/SelectTrigger.module.css +24 -0
- package/components/SelectionTag.d.ts +8 -0
- package/components/SelectionTag.js +39 -0
- package/components/SettingRow.d.ts +7 -0
- package/components/SettingRow.js +19 -0
- package/components/SettingRow.module.css +44 -0
- package/components/SettingsLayout.d.ts +11 -0
- package/components/SettingsLayout.js +61 -0
- package/components/SettingsLayout.module.css +68 -0
- package/components/ShortcutInput.d.ts +8 -0
- package/components/ShortcutInput.js +131 -0
- package/components/ShortcutInput.module.css +39 -0
- package/components/Skeleton.d.ts +5 -0
- package/components/Skeleton.js +19 -0
- package/components/Skeleton.module.css +27 -0
- package/components/SkeletonRows.d.ts +4 -0
- package/components/SkeletonRows.js +19 -0
- package/components/SkeletonRows.module.css +19 -0
- package/components/SkinTonePicker.d.ts +4 -0
- package/components/SkinTonePicker.js +43 -0
- package/components/SkinTonePicker.module.css +50 -0
- package/components/Slider.d.ts +10 -0
- package/components/Slider.js +40 -0
- package/components/Slider.module.css +19 -0
- package/components/Spinner.d.ts +6 -0
- package/components/Spinner.js +31 -0
- package/components/Spinner.module.css +57 -0
- package/components/SplitButton.d.ts +17 -0
- package/components/SplitButton.js +102 -0
- package/components/SplitButton.module.css +56 -0
- package/components/Statistic.d.ts +22 -0
- package/components/Statistic.js +102 -0
- package/components/Statistic.module.css +55 -0
- package/components/Steps.d.ts +19 -0
- package/components/Steps.js +102 -0
- package/components/Steps.module.css +176 -0
- package/components/Switch.d.ts +6 -0
- package/components/Switch.js +25 -0
- package/components/Switch.module.css +59 -0
- package/components/SymbolPicker.d.ts +6 -0
- package/components/SymbolPicker.js +18 -0
- package/components/Tab.module.css +145 -0
- package/components/TabList.d.ts +11 -0
- package/components/TabList.js +51 -0
- package/components/Table.d.ts +16 -0
- package/components/Table.js +30 -0
- package/components/Table.module.css +48 -0
- package/components/TableColumnFilter.d.ts +6 -0
- package/components/TableColumnFilter.js +76 -0
- package/components/TableColumnVisibility.d.ts +11 -0
- package/components/TableColumnVisibility.js +76 -0
- package/components/Tabs.d.ts +13 -0
- package/components/Tabs.js +49 -0
- package/components/Tabs.module.css +3 -0
- package/components/TagInput.d.ts +11 -0
- package/components/TagInput.js +142 -0
- package/components/TagInput.module.css +64 -0
- package/components/Textarea.d.ts +6 -0
- package/components/Textarea.js +24 -0
- package/components/Textarea.module.css +9 -0
- package/components/ThemePicker.d.ts +6 -0
- package/components/ThemePicker.js +78 -0
- package/components/ThemePicker.module.css +178 -0
- package/components/ThemeProvider.d.ts +11 -0
- package/components/ThemeProvider.js +94 -0
- package/components/ThemeStylePicker.d.ts +5 -0
- package/components/ThemeStylePicker.js +22 -0
- package/components/TimeColumns.d.ts +6 -0
- package/components/TimeColumns.js +55 -0
- package/components/TimeColumns.module.css +47 -0
- package/components/Timeline.d.ts +26 -0
- package/components/Timeline.js +131 -0
- package/components/Timeline.module.css +202 -0
- package/components/Toast.d.ts +6 -0
- package/components/Toast.js +181 -0
- package/components/Toast.module.css +175 -0
- package/components/ToastProvider.d.ts +35 -0
- package/components/ToastProvider.js +47 -0
- package/components/Tooltip.d.ts +10 -0
- package/components/Tooltip.js +169 -0
- package/components/Tooltip.module.css +53 -0
- package/components/TreeGuides.d.ts +9 -0
- package/components/TreeGuides.js +39 -0
- package/components/TreeGuides.module.css +45 -0
- package/components/TreeSelect.d.ts +26 -0
- package/components/TreeSelect.js +337 -0
- package/components/TreeTable.d.ts +15 -0
- package/components/TreeTable.js +151 -0
- package/components/TreeTable.module.css +53 -0
- package/components/UIProvider.d.ts +10 -0
- package/components/UIProvider.js +20 -0
- package/components/UnderlinedTab.d.ts +2 -0
- package/components/UnderlinedTab.js +8 -0
- package/components/Upload.d.ts +22 -0
- package/components/Upload.js +165 -0
- package/components/Upload.module.css +36 -0
- package/components/UploadList.d.ts +9 -0
- package/components/UploadList.js +14 -0
- package/components/UploadList.module.css +130 -0
- package/components/UploadListItem.d.ts +13 -0
- package/components/UploadListItem.js +122 -0
- package/components/VirtualPickerList.d.ts +25 -0
- package/components/VirtualPickerList.js +269 -0
- package/components/VirtualPickerList.module.css +93 -0
- package/components/appearance.d.ts +20 -0
- package/components/appearance.js +69 -0
- package/components/characterCatalog.d.ts +9 -0
- package/components/characterCatalog.js +55 -0
- package/components/color.d.ts +7 -0
- package/components/color.js +18 -0
- package/components/contribution.d.ts +57 -0
- package/components/contribution.js +86 -0
- package/components/dateConstraints.d.ts +13 -0
- package/components/dateConstraints.js +44 -0
- package/components/field.d.ts +58 -0
- package/components/field.js +57 -0
- package/components/fileSelection.d.ts +21 -0
- package/components/fileSelection.js +43 -0
- package/components/hierarchy.d.ts +23 -0
- package/components/hierarchy.js +33 -0
- package/components/iconCatalog.d.ts +13 -0
- package/components/iconCatalog.js +80 -0
- package/components/index.d.ts +152 -0
- package/components/index.js +225 -0
- package/components/menuFocus.d.ts +7 -0
- package/components/menuFocus.js +21 -0
- package/components/menuPointer.d.ts +6 -0
- package/components/menuPointer.js +13 -0
- package/components/menuTypes.d.ts +24 -0
- package/components/menuTypes.js +0 -0
- package/components/motion.d.ts +9 -0
- package/components/motion.js +82 -0
- package/components/rangeMath.d.ts +12 -0
- package/components/rangeMath.js +30 -0
- package/components/surfacePortal.d.ts +13 -0
- package/components/surfacePortal.js +22 -0
- package/components/tooltipState.d.ts +5 -0
- package/components/tooltipState.js +48 -0
- package/components/types.d.ts +9 -0
- package/components/types.js +0 -0
- package/components/uploadTypes.d.ts +21 -0
- package/components/uploadTypes.js +0 -0
- package/components/useFormState.d.ts +51 -0
- package/components/useFormState.js +218 -0
- package/components/useHierarchy.d.ts +8 -0
- package/components/useHierarchy.js +80 -0
- package/components/useMenuLayers.d.ts +17 -0
- package/components/useMenuLayers.js +23 -0
- package/components/useModalScrollLock.d.ts +1 -0
- package/components/useModalScrollLock.js +18 -0
- package/components/usePopover.d.ts +8 -0
- package/components/usePopover.js +22 -0
- package/components/useTabIndicator.d.ts +12 -0
- package/components/useTabIndicator.js +63 -0
- package/components/useUploadQueue.d.ts +20 -0
- package/components/useUploadQueue.js +175 -0
- package/package.json +810 -3
- package/styles/base.css +206 -0
- package/styles/blue.css +268 -0
- package/styles/desktop.css +2 -0
- package/styles/minimal.css +337 -0
- package/styles/themes.css +2 -0
- package/styles/web.css +2 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.host {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
}
|
|
4
|
+
.root {
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
padding: 0;
|
|
11
|
+
border: 0;
|
|
12
|
+
background: transparent;
|
|
13
|
+
color: var(--fg);
|
|
14
|
+
overflow: visible;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
.root::backdrop {
|
|
18
|
+
background: transparent;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
}
|
|
21
|
+
.panel {
|
|
22
|
+
position: fixed;
|
|
23
|
+
pointer-events: auto;
|
|
24
|
+
width: 236px;
|
|
25
|
+
max-width: calc(100vw - 16px);
|
|
26
|
+
max-height: calc(100vh - 16px);
|
|
27
|
+
overflow: auto;
|
|
28
|
+
padding: 5px;
|
|
29
|
+
background: var(--surface);
|
|
30
|
+
border: 1px solid var(--line);
|
|
31
|
+
border-radius: var(--radius);
|
|
32
|
+
box-shadow: var(--shadow);
|
|
33
|
+
}
|
|
34
|
+
.error {
|
|
35
|
+
padding: 8px;
|
|
36
|
+
color: var(--danger);
|
|
37
|
+
font-size: 12px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.panel[inert] {
|
|
41
|
+
pointer-events: none;
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type KeyboardEvent } from "react";
|
|
2
|
+
import type { ContextMenuItem, MenuAction } from "./menuTypes";
|
|
3
|
+
export declare function ContextMenuPanel({ open, onExited, onPanelEnter, onReady, items, level, point, anchor, activeId, busy, error, onHover, onChoose, onKey, onScroll, }: {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onExited(): void;
|
|
6
|
+
onPanelEnter(): void;
|
|
7
|
+
onReady(node: HTMLDivElement): void;
|
|
8
|
+
items: ContextMenuItem[];
|
|
9
|
+
level: number;
|
|
10
|
+
point: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
anchor?: HTMLElement;
|
|
15
|
+
activeId?: string;
|
|
16
|
+
busy?: string;
|
|
17
|
+
error?: string;
|
|
18
|
+
onHover(item: MenuAction, index: number): void;
|
|
19
|
+
onChoose(item: MenuAction, index: number): void;
|
|
20
|
+
onKey(event: KeyboardEvent<HTMLDivElement>, level: number): void;
|
|
21
|
+
onScroll(): void;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItem } from "./MenuItem.js";
|
|
3
|
+
import { menuSurfaceMotion, cancelMotion } from "./motion.js";
|
|
4
|
+
import { useLayoutEffect, useRef } from "react";
|
|
5
|
+
import { ChevronRight } from "lucide-react";
|
|
6
|
+
import { Spinner } from "./Spinner.js";
|
|
7
|
+
import { Divider } from "./Divider.js";
|
|
8
|
+
import s from "./ContextMenu.module.css";
|
|
9
|
+
function ContextMenuPanel({
|
|
10
|
+
open,
|
|
11
|
+
onExited,
|
|
12
|
+
onPanelEnter,
|
|
13
|
+
onReady,
|
|
14
|
+
items,
|
|
15
|
+
level,
|
|
16
|
+
point,
|
|
17
|
+
anchor,
|
|
18
|
+
activeId,
|
|
19
|
+
busy,
|
|
20
|
+
error,
|
|
21
|
+
onHover,
|
|
22
|
+
onChoose,
|
|
23
|
+
onKey,
|
|
24
|
+
onScroll
|
|
25
|
+
}) {
|
|
26
|
+
const reserveIcon = items.some(
|
|
27
|
+
(item) => item.type !== "separator" && !!item.icon
|
|
28
|
+
);
|
|
29
|
+
const ref = useRef(null), opened = useRef(open), exited = useRef(onExited), reposition = useRef(() => {
|
|
30
|
+
}), ready = useRef(onReady);
|
|
31
|
+
ready.current = onReady;
|
|
32
|
+
opened.current = open;
|
|
33
|
+
exited.current = onExited;
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
const node = ref.current;
|
|
36
|
+
const position = () => {
|
|
37
|
+
const rect = node.getBoundingClientRect(), parent = anchor?.getBoundingClientRect();
|
|
38
|
+
let side = anchor?.closest("[data-menu-level]")?.dataset.side || "right";
|
|
39
|
+
let x = point.x, y = point.y;
|
|
40
|
+
if (parent) {
|
|
41
|
+
x = side === "left" ? parent.left - rect.width - 4 : parent.right + 4;
|
|
42
|
+
y = parent.top - 5;
|
|
43
|
+
if (side === "right" && x + rect.width > innerWidth - 8) {
|
|
44
|
+
side = "left";
|
|
45
|
+
x = parent.left - rect.width - 4;
|
|
46
|
+
} else if (side === "left" && x < 8) {
|
|
47
|
+
side = "right";
|
|
48
|
+
x = parent.right + 4;
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
const left = Math.max(8, Math.min(x, innerWidth - rect.width - 8));
|
|
52
|
+
side = left > innerWidth - left - rect.width ? "left" : "right";
|
|
53
|
+
}
|
|
54
|
+
node.dataset.side = side;
|
|
55
|
+
node.dataset.motionSide = anchor ? side : y > innerHeight - rect.height - 8 ? "top" : "bottom";
|
|
56
|
+
node.style.left = Math.max(8, Math.min(x, innerWidth - rect.width - 8)) + "px";
|
|
57
|
+
node.style.top = Math.max(8, Math.min(y, innerHeight - rect.height - 8)) + "px";
|
|
58
|
+
node.style.visibility = "visible";
|
|
59
|
+
ready.current(node);
|
|
60
|
+
};
|
|
61
|
+
reposition.current = position;
|
|
62
|
+
position();
|
|
63
|
+
const frame = requestAnimationFrame(() => {
|
|
64
|
+
position();
|
|
65
|
+
});
|
|
66
|
+
const observer = new ResizeObserver(position);
|
|
67
|
+
observer.observe(node);
|
|
68
|
+
window.addEventListener("resize", position);
|
|
69
|
+
return () => {
|
|
70
|
+
observer.disconnect();
|
|
71
|
+
cancelAnimationFrame(frame);
|
|
72
|
+
window.removeEventListener("resize", position);
|
|
73
|
+
};
|
|
74
|
+
}, [anchor, point, level]);
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
const node = ref.current;
|
|
77
|
+
node.inert = !open;
|
|
78
|
+
if (open) ready.current(node);
|
|
79
|
+
if (!open) node.setAttribute("aria-hidden", "true");
|
|
80
|
+
else node.removeAttribute("aria-hidden");
|
|
81
|
+
const frame = requestAnimationFrame(() => {
|
|
82
|
+
if (!open && !node.dataset.motionPhase) {
|
|
83
|
+
exited.current();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const side = node.dataset.motionSide || "bottom";
|
|
87
|
+
void menuSurfaceMotion(node, open ? "enter" : "exit", side).then(
|
|
88
|
+
(done) => {
|
|
89
|
+
if (done && !open && !opened.current) exited.current();
|
|
90
|
+
else if (done && open && opened.current) reposition.current();
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
return () => cancelAnimationFrame(frame);
|
|
95
|
+
}, [open, point]);
|
|
96
|
+
useLayoutEffect(() => {
|
|
97
|
+
const node = ref.current;
|
|
98
|
+
return () => cancelMotion(node);
|
|
99
|
+
}, []);
|
|
100
|
+
return /* @__PURE__ */ jsxs(
|
|
101
|
+
"div",
|
|
102
|
+
{
|
|
103
|
+
ref,
|
|
104
|
+
role: "menu",
|
|
105
|
+
"aria-busy": !!busy,
|
|
106
|
+
"aria-label": level ? "\u5B50\u83DC\u5355 " + level : "\u53F3\u952E\u83DC\u5355",
|
|
107
|
+
"data-menu-level": level,
|
|
108
|
+
"data-menu-state": open ? "open" : "closing",
|
|
109
|
+
onPointerEnter: onPanelEnter,
|
|
110
|
+
className: s.panel,
|
|
111
|
+
style: {
|
|
112
|
+
visibility: "hidden",
|
|
113
|
+
opacity: 0,
|
|
114
|
+
zIndex: level * 2 + (open ? 2 : 1)
|
|
115
|
+
},
|
|
116
|
+
onKeyDown: (e) => onKey(e, level),
|
|
117
|
+
onScroll,
|
|
118
|
+
children: [
|
|
119
|
+
items.map(
|
|
120
|
+
(item, index) => item.type === "separator" ? /* @__PURE__ */ jsx(Divider, { spacing: 4 }, item.id) : /* @__PURE__ */ jsx(
|
|
121
|
+
MenuItem,
|
|
122
|
+
{
|
|
123
|
+
reserveIcon,
|
|
124
|
+
label: item.label,
|
|
125
|
+
description: item.description,
|
|
126
|
+
icon: busy === item.id && reserveIcon ? /* @__PURE__ */ jsx(Spinner, { size: 16, decorative: true }) : item.icon,
|
|
127
|
+
shortcut: item.shortcut,
|
|
128
|
+
selected: !!item.checked,
|
|
129
|
+
selection: item.type === "checkbox" ? "checkbox" : item.type === "radio" ? "radio" : void 0,
|
|
130
|
+
trailing: !reserveIcon && busy === item.id ? /* @__PURE__ */ jsx(Spinner, { size: 16, decorative: true }) : item.children?.length ? /* @__PURE__ */ jsx(ChevronRight, {}) : void 0,
|
|
131
|
+
tone: item.tone,
|
|
132
|
+
role: item.type === "checkbox" ? "menuitemcheckbox" : item.type === "radio" ? "menuitemradio" : "menuitem",
|
|
133
|
+
"aria-checked": item.type === "checkbox" || item.type === "radio" ? !!item.checked : void 0,
|
|
134
|
+
"aria-haspopup": item.children?.length ? "menu" : void 0,
|
|
135
|
+
"aria-expanded": item.children?.length ? activeId === item.id : void 0,
|
|
136
|
+
disabled: item.disabled || !!busy,
|
|
137
|
+
"data-menu-index": index,
|
|
138
|
+
"data-menu-id": item.id,
|
|
139
|
+
"data-tone": item.tone,
|
|
140
|
+
className: item.className,
|
|
141
|
+
style: { color: item.color, ...item.style },
|
|
142
|
+
onPointerMove: () => onHover(item, index),
|
|
143
|
+
onClick: () => onChoose(item, index)
|
|
144
|
+
},
|
|
145
|
+
item.id
|
|
146
|
+
)
|
|
147
|
+
),
|
|
148
|
+
error && level === 0 && /* @__PURE__ */ jsx("p", { role: "alert", className: s.error, children: error })
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
ContextMenuPanel
|
|
155
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ContributionDay } from "./contribution";
|
|
2
|
+
export declare function ContributionCalendar({ data, year, startDate, endDate, weekStartsOn, value, onChange, label, unit, locale, color, emptyMode, allowFuture, today, thresholds, }: {
|
|
3
|
+
data: ContributionDay[];
|
|
4
|
+
year?: number;
|
|
5
|
+
startDate?: string;
|
|
6
|
+
endDate?: string;
|
|
7
|
+
weekStartsOn?: 0 | 1;
|
|
8
|
+
value?: string;
|
|
9
|
+
onChange?(date: string): void;
|
|
10
|
+
label?: string;
|
|
11
|
+
unit?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
color?: string;
|
|
14
|
+
emptyMode?: "zero" | "missing";
|
|
15
|
+
allowFuture?: boolean;
|
|
16
|
+
today?: string;
|
|
17
|
+
thresholds?: [number, number, number, number];
|
|
18
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
useCallback,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState
|
|
7
|
+
} from "react";
|
|
8
|
+
import { ContributionCell } from "./ContributionCell.js";
|
|
9
|
+
import {
|
|
10
|
+
buildContributionCalendar,
|
|
11
|
+
parseCalendarDay
|
|
12
|
+
} from "./contribution.js";
|
|
13
|
+
import s from "./ContributionCalendar.module.css";
|
|
14
|
+
function ContributionCalendar({
|
|
15
|
+
data,
|
|
16
|
+
year = (/* @__PURE__ */ new Date()).getFullYear(),
|
|
17
|
+
startDate,
|
|
18
|
+
endDate,
|
|
19
|
+
weekStartsOn = 1,
|
|
20
|
+
value,
|
|
21
|
+
onChange,
|
|
22
|
+
label = "\u6D3B\u52A8\u8BB0\u5F55",
|
|
23
|
+
unit = "\u6B21\u6D3B\u52A8",
|
|
24
|
+
locale = "zh-CN",
|
|
25
|
+
color = "var(--success)",
|
|
26
|
+
emptyMode = "zero",
|
|
27
|
+
allowFuture = false,
|
|
28
|
+
today,
|
|
29
|
+
thresholds
|
|
30
|
+
}) {
|
|
31
|
+
const current = /* @__PURE__ */ new Date(), todayKey = today || [
|
|
32
|
+
current.getFullYear(),
|
|
33
|
+
String(current.getMonth() + 1).padStart(2, "0"),
|
|
34
|
+
String(current.getDate()).padStart(2, "0")
|
|
35
|
+
].join("-");
|
|
36
|
+
const model = useMemo(
|
|
37
|
+
() => buildContributionCalendar({
|
|
38
|
+
data,
|
|
39
|
+
year,
|
|
40
|
+
startDate,
|
|
41
|
+
endDate,
|
|
42
|
+
weekStartsOn,
|
|
43
|
+
today: todayKey,
|
|
44
|
+
allowFuture,
|
|
45
|
+
thresholds
|
|
46
|
+
}),
|
|
47
|
+
[
|
|
48
|
+
data,
|
|
49
|
+
year,
|
|
50
|
+
startDate,
|
|
51
|
+
endDate,
|
|
52
|
+
weekStartsOn,
|
|
53
|
+
todayKey,
|
|
54
|
+
allowFuture,
|
|
55
|
+
thresholds
|
|
56
|
+
]
|
|
57
|
+
);
|
|
58
|
+
const root = useRef(null), [focused, setFocused] = useState(), active = model.dates.some((day) => day.date === focused) ? focused : model.dates.some((day) => day.date === value) ? value : model.dates.some((day) => day.date === todayKey) ? todayKey : model.dates[0]?.date;
|
|
59
|
+
const formatter = useMemo(
|
|
60
|
+
() => new Intl.DateTimeFormat(locale, {
|
|
61
|
+
year: "numeric",
|
|
62
|
+
month: "long",
|
|
63
|
+
day: "numeric",
|
|
64
|
+
timeZone: "UTC"
|
|
65
|
+
}),
|
|
66
|
+
[locale]
|
|
67
|
+
), numbers = useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
68
|
+
const choose = useCallback((date) => onChange?.(date), [onChange]);
|
|
69
|
+
const move = useCallback(
|
|
70
|
+
(event, day) => {
|
|
71
|
+
let nextIndex;
|
|
72
|
+
if (event.key === "ArrowUp" && day.row === 0 || event.key === "ArrowDown" && day.row === 6 || event.key === "ArrowLeft" && day.column === 0 || event.key === "ArrowRight" && day.column === model.weeks - 1) {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const offset = {
|
|
77
|
+
ArrowUp: -1,
|
|
78
|
+
ArrowDown: 1,
|
|
79
|
+
ArrowLeft: -7,
|
|
80
|
+
ArrowRight: 7
|
|
81
|
+
}[event.key];
|
|
82
|
+
if (offset !== void 0) nextIndex = day.index + offset;
|
|
83
|
+
else if (event.key === "Home")
|
|
84
|
+
nextIndex = event.ctrlKey ? model.dates[0]?.index : model.dates.find((item) => item.row === day.row)?.index;
|
|
85
|
+
else if (event.key === "End")
|
|
86
|
+
nextIndex = event.ctrlKey ? model.dates.at(-1)?.index : model.dates.findLast((item) => item.row === day.row)?.index;
|
|
87
|
+
if (nextIndex === void 0) return;
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
const date = model.cells[nextIndex];
|
|
90
|
+
if (!date || date.outside) return;
|
|
91
|
+
setFocused(date.date);
|
|
92
|
+
const node = root.current?.querySelector(
|
|
93
|
+
'[data-date="' + date.date + '"]'
|
|
94
|
+
);
|
|
95
|
+
node?.focus({ preventScroll: true });
|
|
96
|
+
node?.scrollIntoView({
|
|
97
|
+
block: "nearest",
|
|
98
|
+
inline: "nearest",
|
|
99
|
+
behavior: "instant"
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
[model]
|
|
103
|
+
);
|
|
104
|
+
if (!model.valid) return /* @__PURE__ */ jsx("p", { role: "alert", children: "\u65E5\u671F\u8303\u56F4\u65E0\u6548\u3002" });
|
|
105
|
+
return /* @__PURE__ */ jsxs(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: s.calendar,
|
|
109
|
+
style: { "--calendar-color": color },
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsxs("header", { className: s.header, children: [
|
|
112
|
+
/* @__PURE__ */ jsx("h3", { children: label }),
|
|
113
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
114
|
+
numbers.format(model.total),
|
|
115
|
+
" ",
|
|
116
|
+
unit
|
|
117
|
+
] })
|
|
118
|
+
] }),
|
|
119
|
+
/* @__PURE__ */ jsxs("div", { className: s.scroll, ref: root, children: [
|
|
120
|
+
/* @__PURE__ */ jsxs(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
className: s.months,
|
|
124
|
+
style: {
|
|
125
|
+
gridTemplateColumns: "28px repeat(" + model.weeks + ",var(--calendar-cell))"
|
|
126
|
+
},
|
|
127
|
+
"aria-hidden": "true",
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
130
|
+
model.months.map((month) => /* @__PURE__ */ jsxs("span", { style: { gridColumn: month.column + 2 }, children: [
|
|
131
|
+
month.month,
|
|
132
|
+
"\u6708"
|
|
133
|
+
] }, month.key))
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
"div",
|
|
139
|
+
{
|
|
140
|
+
role: "grid",
|
|
141
|
+
"aria-label": label,
|
|
142
|
+
"aria-rowcount": 7,
|
|
143
|
+
"aria-colcount": model.weeks,
|
|
144
|
+
children: Array.from({ length: 7 }, (_, row) => /* @__PURE__ */ jsxs(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
role: "row",
|
|
148
|
+
className: s.row,
|
|
149
|
+
style: {
|
|
150
|
+
gridTemplateColumns: "28px repeat(" + model.weeks + ",var(--calendar-cell))"
|
|
151
|
+
},
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ jsx("span", { className: s.weekday, role: "rowheader", children: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"][(row + weekStartsOn) % 7] }),
|
|
154
|
+
Array.from({ length: model.weeks }, (_2, column) => {
|
|
155
|
+
const day = model.cells[column * 7 + row];
|
|
156
|
+
const text = formatter.format(parseCalendarDay(day.date)) + (day.future ? "\uFF0C\u672A\u6765\u65E5\u671F" : emptyMode === "missing" && day.missing ? "\uFF0C\u6682\u65E0\u6570\u636E" : "\uFF0C" + numbers.format(day.count) + " " + unit);
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
ContributionCell,
|
|
159
|
+
{
|
|
160
|
+
day,
|
|
161
|
+
label: text,
|
|
162
|
+
selected: value === day.date,
|
|
163
|
+
tabIndex: active === day.date ? 0 : -1,
|
|
164
|
+
missing: emptyMode === "missing" && day.missing && !day.future,
|
|
165
|
+
onSelect: choose,
|
|
166
|
+
onFocus: setFocused,
|
|
167
|
+
onKeyDown: move
|
|
168
|
+
},
|
|
169
|
+
day.date
|
|
170
|
+
);
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
row
|
|
175
|
+
))
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
] }),
|
|
179
|
+
/* @__PURE__ */ jsxs("footer", { className: s.footer, children: [
|
|
180
|
+
value && /* @__PURE__ */ jsx("span", { children: value }),
|
|
181
|
+
/* @__PURE__ */ jsxs("div", { className: s.legend, "aria-label": "\u6D3B\u52A8\u6B21\u6570\u7531\u5C11\u5230\u591A", children: [
|
|
182
|
+
/* @__PURE__ */ jsx("span", { children: "\u5C11" }),
|
|
183
|
+
[0, 1, 2, 3, 4].map((level) => /* @__PURE__ */ jsx(
|
|
184
|
+
"i",
|
|
185
|
+
{
|
|
186
|
+
className: s.day,
|
|
187
|
+
"data-level": level,
|
|
188
|
+
"aria-hidden": "true"
|
|
189
|
+
},
|
|
190
|
+
level
|
|
191
|
+
)),
|
|
192
|
+
/* @__PURE__ */ jsx("span", { children: "\u591A" })
|
|
193
|
+
] })
|
|
194
|
+
] })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
ContributionCalendar
|
|
201
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
.calendar {
|
|
2
|
+
--calendar-cell: 13px;
|
|
3
|
+
--calendar-gap: 3px;
|
|
4
|
+
min-width: 0;
|
|
5
|
+
border: 1px solid var(--line);
|
|
6
|
+
border-radius: var(--radius);
|
|
7
|
+
padding: 20px;
|
|
8
|
+
background: var(--surface);
|
|
9
|
+
}
|
|
10
|
+
.header,
|
|
11
|
+
.footer {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
gap: 14px;
|
|
16
|
+
}
|
|
17
|
+
.header {
|
|
18
|
+
margin-bottom: 16px;
|
|
19
|
+
}
|
|
20
|
+
.header > span,
|
|
21
|
+
.footer {
|
|
22
|
+
font-size: 11px;
|
|
23
|
+
color: var(--muted);
|
|
24
|
+
}
|
|
25
|
+
.scroll {
|
|
26
|
+
overflow: auto;
|
|
27
|
+
padding: 3px 2px 6px;
|
|
28
|
+
}
|
|
29
|
+
.months,
|
|
30
|
+
.row {
|
|
31
|
+
display: grid;
|
|
32
|
+
column-gap: var(--calendar-gap);
|
|
33
|
+
width: max-content;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
.months {
|
|
37
|
+
height: 22px;
|
|
38
|
+
font-size: 10px;
|
|
39
|
+
color: var(--muted);
|
|
40
|
+
}
|
|
41
|
+
.months > span {
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
}
|
|
44
|
+
.row {
|
|
45
|
+
height: calc(var(--calendar-cell) + var(--calendar-gap));
|
|
46
|
+
}
|
|
47
|
+
.weekday {
|
|
48
|
+
font-size: 10px;
|
|
49
|
+
color: var(--muted);
|
|
50
|
+
}
|
|
51
|
+
.day,
|
|
52
|
+
.pad {
|
|
53
|
+
width: var(--calendar-cell);
|
|
54
|
+
height: var(--calendar-cell);
|
|
55
|
+
}
|
|
56
|
+
.day {
|
|
57
|
+
display: block;
|
|
58
|
+
padding: 0;
|
|
59
|
+
border: 1px solid color-mix(in srgb, var(--fg) 6%, transparent);
|
|
60
|
+
border-radius: 3px;
|
|
61
|
+
background: color-mix(in srgb, var(--fg) 8%, var(--surface));
|
|
62
|
+
transition:
|
|
63
|
+
transform var(--motion-press),
|
|
64
|
+
box-shadow var(--motion-hover);
|
|
65
|
+
}
|
|
66
|
+
.day[data-level="1"] {
|
|
67
|
+
background: color-mix(in srgb, var(--calendar-color) 25%, var(--surface));
|
|
68
|
+
}
|
|
69
|
+
.day[data-level="2"] {
|
|
70
|
+
background: color-mix(in srgb, var(--calendar-color) 45%, var(--surface));
|
|
71
|
+
}
|
|
72
|
+
.day[data-level="3"] {
|
|
73
|
+
background: color-mix(in srgb, var(--calendar-color) 70%, var(--surface));
|
|
74
|
+
}
|
|
75
|
+
.day[data-level="4"] {
|
|
76
|
+
background: var(--calendar-color);
|
|
77
|
+
}
|
|
78
|
+
.day[data-future="true"] {
|
|
79
|
+
opacity: 0.3;
|
|
80
|
+
cursor: default;
|
|
81
|
+
}
|
|
82
|
+
.day[data-missing="true"] {
|
|
83
|
+
background: repeating-linear-gradient(
|
|
84
|
+
135deg,
|
|
85
|
+
transparent,
|
|
86
|
+
transparent 2px,
|
|
87
|
+
color-mix(in srgb, var(--fg) 12%, var(--surface)) 2px,
|
|
88
|
+
color-mix(in srgb, var(--fg) 12%, var(--surface)) 3px
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
.day:hover:not([data-future="true"]) {
|
|
92
|
+
transform: scale(1.12);
|
|
93
|
+
}
|
|
94
|
+
.day:focus-visible,
|
|
95
|
+
.day[aria-selected="true"] {
|
|
96
|
+
outline: 2px solid var(--accent);
|
|
97
|
+
outline-offset: 1px;
|
|
98
|
+
}
|
|
99
|
+
.footer {
|
|
100
|
+
margin-top: 12px;
|
|
101
|
+
min-height: 18px;
|
|
102
|
+
}
|
|
103
|
+
.legend {
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 4px;
|
|
107
|
+
margin-left: auto;
|
|
108
|
+
}
|
|
109
|
+
.legend > span {
|
|
110
|
+
margin: 0 3px;
|
|
111
|
+
}
|
|
112
|
+
.legend .day {
|
|
113
|
+
cursor: default;
|
|
114
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ContributionCellData } from "./contribution";
|
|
2
|
+
export declare const ContributionCell: import("react").MemoExoticComponent<({ day, label, selected, tabIndex, missing, onSelect, onFocus, onKeyDown, }: {
|
|
3
|
+
day: ContributionCellData;
|
|
4
|
+
label: string;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
tabIndex: number;
|
|
7
|
+
missing: boolean;
|
|
8
|
+
onSelect(date: string): void;
|
|
9
|
+
onFocus(date: string): void;
|
|
10
|
+
onKeyDown(event: React.KeyboardEvent<HTMLButtonElement>, day: ContributionCellData): void;
|
|
11
|
+
}) => import("react").JSX.Element>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { Tooltip } from "./Tooltip.js";
|
|
4
|
+
import s from "./ContributionCalendar.module.css";
|
|
5
|
+
const ContributionCell = memo(function ContributionCell2({
|
|
6
|
+
day,
|
|
7
|
+
label,
|
|
8
|
+
selected,
|
|
9
|
+
tabIndex,
|
|
10
|
+
missing,
|
|
11
|
+
onSelect,
|
|
12
|
+
onFocus,
|
|
13
|
+
onKeyDown
|
|
14
|
+
}) {
|
|
15
|
+
if (day.outside)
|
|
16
|
+
return /* @__PURE__ */ jsx("span", { className: s.pad, role: "gridcell", "aria-hidden": "true" });
|
|
17
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, children: /* @__PURE__ */ jsx(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
type: "button",
|
|
21
|
+
role: "gridcell",
|
|
22
|
+
"aria-label": label,
|
|
23
|
+
"aria-selected": selected,
|
|
24
|
+
"aria-disabled": day.future || void 0,
|
|
25
|
+
"data-date": day.date,
|
|
26
|
+
"data-level": day.level,
|
|
27
|
+
"data-future": day.future,
|
|
28
|
+
"data-missing": missing,
|
|
29
|
+
className: s.day,
|
|
30
|
+
tabIndex,
|
|
31
|
+
onClick: () => {
|
|
32
|
+
if (!day.future) onSelect(day.date);
|
|
33
|
+
},
|
|
34
|
+
onFocus: () => onFocus(day.date),
|
|
35
|
+
onKeyDown: (event) => onKeyDown(event, day)
|
|
36
|
+
}
|
|
37
|
+
) });
|
|
38
|
+
});
|
|
39
|
+
export {
|
|
40
|
+
ContributionCell
|
|
41
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
.surface {
|
|
2
|
+
height: var(--control-height);
|
|
3
|
+
min-width: 0;
|
|
4
|
+
border: 1px solid var(--control-border, var(--line));
|
|
5
|
+
border-radius: var(--field-radius);
|
|
6
|
+
background: var(--field);
|
|
7
|
+
color: var(--fg);
|
|
8
|
+
font-size: var(--field-font-size);
|
|
9
|
+
line-height: var(--field-line-height);
|
|
10
|
+
outline: none;
|
|
11
|
+
transition:
|
|
12
|
+
border-color var(--motion-hover),
|
|
13
|
+
box-shadow var(--motion-hover),
|
|
14
|
+
background-color var(--motion-hover);
|
|
15
|
+
}
|
|
16
|
+
.surface:hover:where(
|
|
17
|
+
:not(
|
|
18
|
+
:disabled,
|
|
19
|
+
[data-disabled="true"],
|
|
20
|
+
[aria-disabled="true"],
|
|
21
|
+
[readonly],
|
|
22
|
+
[aria-readonly="true"],
|
|
23
|
+
[data-readonly="true"],
|
|
24
|
+
[data-disabled="true"] *,
|
|
25
|
+
[aria-disabled="true"] *,
|
|
26
|
+
[data-readonly="true"] *,
|
|
27
|
+
fieldset:disabled *,
|
|
28
|
+
:has(input:disabled, textarea:disabled)
|
|
29
|
+
)
|
|
30
|
+
) {
|
|
31
|
+
border-color: var(
|
|
32
|
+
--field-hover-border,
|
|
33
|
+
color-mix(in srgb, var(--fg) var(--field-hover-strength), var(--surface))
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
.surface[data-focus="true"],
|
|
37
|
+
.surface:focus,
|
|
38
|
+
.surface:focus-visible,
|
|
39
|
+
.surface:focus-within,
|
|
40
|
+
.surface[aria-expanded="true"] {
|
|
41
|
+
outline: none;
|
|
42
|
+
border-color: var(--field-focus-border);
|
|
43
|
+
box-shadow: 0 0 0 var(--field-focus-width)
|
|
44
|
+
color-mix(in srgb, var(--accent) var(--field-focus-strength), transparent);
|
|
45
|
+
}
|
|
46
|
+
.surface[aria-invalid="true"] {
|
|
47
|
+
border-color: var(--danger);
|
|
48
|
+
}
|
|
49
|
+
.surface[aria-invalid="true"][data-focus="true"],
|
|
50
|
+
.surface[aria-invalid="true"]:focus-within {
|
|
51
|
+
box-shadow: 0 0 0 var(--field-focus-width)
|
|
52
|
+
color-mix(in srgb, var(--danger) var(--field-focus-strength), transparent);
|
|
53
|
+
}
|
|
54
|
+
.surface:disabled,
|
|
55
|
+
.surface[data-disabled="true"] {
|
|
56
|
+
opacity: var(--field-disabled-opacity);
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
}
|
|
59
|
+
.surface[data-disabled="true"] input:disabled {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
}
|
|
62
|
+
.surface input {
|
|
63
|
+
outline: none;
|
|
64
|
+
color: inherit;
|
|
65
|
+
font-family: inherit;
|
|
66
|
+
line-height: inherit;
|
|
67
|
+
}
|
|
68
|
+
.surface input:focus-visible {
|
|
69
|
+
outline: none;
|
|
70
|
+
}
|
|
71
|
+
.surface::placeholder,
|
|
72
|
+
.surface input::placeholder {
|
|
73
|
+
color: var(--placeholder);
|
|
74
|
+
opacity: 1;
|
|
75
|
+
}
|
|
76
|
+
.surface[readonly],
|
|
77
|
+
.surface[aria-readonly="true"],
|
|
78
|
+
.surface:has(input[readonly]) {
|
|
79
|
+
background: var(--field-readonly);
|
|
80
|
+
}
|
|
81
|
+
@media (max-width: 600px) {
|
|
82
|
+
.surface:has(input),
|
|
83
|
+
.surface:is(input, textarea) {
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
}
|
|
86
|
+
}
|