@seekbuddy/dsh-ui 0.0.0-stage → 0.2.0-beta.1
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 +83 -0
- package/LICENSE +22 -0
- package/README.md +175 -2
- package/README.zh.md +176 -0
- package/THIRD_PARTY_NOTICES.md +42 -0
- package/UPSTREAM.md +59 -0
- package/dist/blocks.js +1617 -0
- package/dist/chunks/chunk-23KOEBWJ.js +104 -0
- package/dist/chunks/chunk-6SGSJ5KW.js +57 -0
- package/dist/chunks/chunk-7NH2UOZO.js +155 -0
- package/dist/chunks/chunk-7SKW4S35.js +66 -0
- package/dist/chunks/chunk-B3EEK7A2.js +408 -0
- package/dist/chunks/chunk-CEBTQO6W.js +24 -0
- package/dist/chunks/chunk-ENKPNYOB.js +26 -0
- package/dist/chunks/chunk-EWAZFWLW.js +27 -0
- package/dist/chunks/chunk-F352IICS.js +57 -0
- package/dist/chunks/chunk-FFJ6TCCF.js +31 -0
- package/dist/chunks/chunk-FZXK4LTI.js +129 -0
- package/dist/chunks/chunk-JA3XDLIA.js +1115 -0
- package/dist/chunks/chunk-L7XALG4J.js +36 -0
- package/dist/chunks/chunk-OCAQFVT3.js +3172 -0
- package/dist/chunks/chunk-RAXDA2PT.js +202 -0
- package/dist/chunks/chunk-RNVSCTW7.js +24 -0
- package/dist/chunks/chunk-RZOP2PFC.js +152 -0
- package/dist/chunks/chunk-SN6RSUWC.js +61 -0
- package/dist/chunks/chunk-SNVSQWCU.js +22 -0
- package/dist/chunks/chunk-SO3DCAWG.js +170 -0
- package/dist/chunks/chunk-UAEFKTV3.js +144 -0
- package/dist/chunks/chunk-UGEORMLD.js +89 -0
- package/dist/chunks/chunk-W6FLI3AK.js +112 -0
- package/dist/chunks/chunk-WX46TSKP.js +328 -0
- package/dist/chunks/chunk-XL33IPCV.js +261 -0
- package/dist/chunks/chunk-XW4L4ZGL.js +967 -0
- package/dist/chunks/chunk-YOBY6PSL.js +850 -0
- package/dist/chunks/chunk-ZA47FP7C.js +7 -0
- package/dist/icons.js +859 -0
- package/dist/index.js +1675 -0
- package/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/katex.css +1 -0
- package/dist/katex.css.d.ts +2 -0
- package/dist/markdown.js +225 -0
- package/dist/meta.json +7575 -0
- package/dist/root-inputs.json +86 -0
- package/dist/seekbuddy-card.js +7 -0
- package/dist/seekbuddy-empty.js +8 -0
- package/dist/seekbuddy-internal/DangerButton.js +7 -0
- package/dist/seekbuddy-internal/Mark.js +7 -0
- package/dist/seekbuddy-internal/Message.js +10 -0
- package/dist/seekbuddy-internal/Pagination.js +9 -0
- package/dist/seekbuddy-internal/StatusBadge.js +7 -0
- package/dist/seekbuddy-internal/SubtleButton.js +7 -0
- package/dist/seekbuddy-internal/Switch.js +7 -0
- package/dist/seekbuddy-internal/Upload.js +7 -0
- package/dist/seekbuddy-internal/date/Calendar.js +8 -0
- package/dist/seekbuddy-internal/date/DatePicker.js +9 -0
- package/dist/seekbuddy-internal/date/DateRangePicker.js +9 -0
- package/dist/seekbuddy-internal/date/TimePicker.js +8 -0
- package/dist/seekbuddy-internal/date/fields.js +16 -0
- package/dist/seekbuddy-internal/qr/QrCode.js +7 -0
- package/dist/seekbuddy-spinner.js +7 -0
- package/dist/seekbuddy-tabs.js +7 -0
- package/dist/seekbuddy-timeline.js +8 -0
- package/dist/seekbuddy.js +89 -0
- package/dist/theme-bootstrap.js +13 -0
- package/dist/theme.js +37 -0
- package/dist/tokens.css +974 -0
- package/dist/tokens.css.d.ts +2 -0
- package/dist/types/AnimatedRows.d.ts +45 -0
- package/dist/types/Button.d.ts +18 -0
- package/dist/types/Checkbox.d.ts +19 -0
- package/dist/types/CodeFileIcon.d.ts +11 -0
- package/dist/types/CodeToolbar.d.ts +29 -0
- package/dist/types/CommandText.d.ts +15 -0
- package/dist/types/ConfigField.d.ts +32 -0
- package/dist/types/ConnectionIndicator.d.ts +25 -0
- package/dist/types/DetailDocument.d.ts +77 -0
- package/dist/types/DiffBlock.d.ts +51 -0
- package/dist/types/DisclosureRow.d.ts +37 -0
- package/dist/types/DraggableImage.d.ts +18 -0
- package/dist/types/FileTypeIcon.d.ts +42 -0
- package/dist/types/FoldToggle.d.ts +19 -0
- package/dist/types/HoverCard.d.ts +44 -0
- package/dist/types/HoverCardGroup.d.ts +24 -0
- package/dist/types/ImageLightbox.d.ts +29 -0
- package/dist/types/ImagePreview.d.ts +11 -0
- package/dist/types/InlineEditor.d.ts +22 -0
- package/dist/types/Input.d.ts +11 -0
- package/dist/types/JsonTree.d.ts +58 -0
- package/dist/types/LinkIcon.d.ts +33 -0
- package/dist/types/Menu.d.ts +163 -0
- package/dist/types/MenuGroup.d.ts +21 -0
- package/dist/types/MenuSurface.d.ts +24 -0
- package/dist/types/Modal.d.ts +43 -0
- package/dist/types/PermissionIcon.d.ts +50 -0
- package/dist/types/Pill.d.ts +12 -0
- package/dist/types/QuotePreview.d.ts +23 -0
- package/dist/types/ReadBlock.d.ts +47 -0
- package/dist/types/ReferenceIcon.d.ts +20 -0
- package/dist/types/RiskConfirmation.d.ts +19 -0
- package/dist/types/SearchBlock.d.ts +71 -0
- package/dist/types/SegmentedControl.d.ts +34 -0
- package/dist/types/SegmentedTabs.d.ts +27 -0
- package/dist/types/ShortcutKeys.d.ts +10 -0
- package/dist/types/SiteGlyph.d.ts +24 -0
- package/dist/types/StateDot.d.ts +19 -0
- package/dist/types/Switch.d.ts +19 -0
- package/dist/types/Tag.d.ts +31 -0
- package/dist/types/TerminalBlock.d.ts +85 -0
- package/dist/types/TextShimmer.d.ts +22 -0
- package/dist/types/Toast.d.ts +48 -0
- package/dist/types/Tooltip.d.ts +69 -0
- package/dist/types/UserMessageBubble.d.ts +10 -0
- package/dist/types/WebBlock.d.ts +60 -0
- package/dist/types/ZoomControls.d.ts +26 -0
- package/dist/types/ansi.d.ts +16 -0
- package/dist/types/blocks.d.ts +21 -0
- package/dist/types/clipboard.d.ts +8 -0
- package/dist/types/code-file-icon-artwork.d.ts +53 -0
- package/dist/types/code-file-types.d.ts +29 -0
- package/dist/types/code-highlighting.d.ts +11 -0
- package/dist/types/css-modules.d.ts +6 -0
- package/dist/types/darwin-desktop.d.ts +8 -0
- package/dist/types/document-zoom.d.ts +16 -0
- package/dist/types/file-drag-actions.d.ts +36 -0
- package/dist/types/file-size.d.ts +7 -0
- package/dist/types/focus.d.ts +15 -0
- package/dist/types/guide-artwork.d.ts +14 -0
- package/dist/types/head-tail-cap.d.ts +22 -0
- package/dist/types/icons/artwork.d.ts +421 -0
- package/dist/types/icons/index.d.ts +397 -0
- package/dist/types/icons/props.d.ts +8 -0
- package/dist/types/icons/shared-artwork.d.ts +36 -0
- package/dist/types/icons.d.ts +6 -0
- package/dist/types/image-drag.d.ts +16 -0
- package/dist/types/index.d.ts +71 -0
- package/dist/types/input-modality.d.ts +18 -0
- package/dist/types/keyboard-composition.d.ts +10 -0
- package/dist/types/markdown/CodeBlock.d.ts +34 -0
- package/dist/types/markdown/JsonBlock.d.ts +7 -0
- package/dist/types/markdown/MarkdownDelegate.d.ts +68 -0
- package/dist/types/markdown/MarkdownText.d.ts +54 -0
- package/dist/types/markdown/cjkFriendlyStrong.d.ts +8 -0
- package/dist/types/markdown/file-link.d.ts +22 -0
- package/dist/types/markdown/highlight.d.ts +169 -0
- package/dist/types/markdown/incremental.d.ts +79 -0
- package/dist/types/markdown/katex.d.ts +18 -0
- package/dist/types/markdown/local-image-syntax.d.ts +9 -0
- package/dist/types/markdown/mathCompatibility.d.ts +10 -0
- package/dist/types/markdown/parse.d.ts +24 -0
- package/dist/types/markdown/plain-text.d.ts +21 -0
- package/dist/types/markdown/quote-text.d.ts +7 -0
- package/dist/types/markdown/render.d.ts +145 -0
- package/dist/types/markdown/useViewportHighlighting.d.ts +10 -0
- package/dist/types/markdown/windows-path-destinations.d.ts +10 -0
- package/dist/types/markdown.d.ts +12 -0
- package/dist/types/overlay-top-margin.d.ts +14 -0
- package/dist/types/plugin-artwork.d.ts +16 -0
- package/dist/types/pointer-grace.d.ts +21 -0
- package/dist/types/rank-by-name.d.ts +21 -0
- package/dist/types/relative-time.d.ts +22 -0
- package/dist/types/seekbuddy/Card.d.ts +28 -0
- package/dist/types/seekbuddy/DangerButton.d.ts +31 -0
- package/dist/types/seekbuddy/Empty.d.ts +34 -0
- package/dist/types/seekbuddy/Mark.d.ts +27 -0
- package/dist/types/seekbuddy/Message.d.ts +52 -0
- package/dist/types/seekbuddy/Pagination.d.ts +66 -0
- package/dist/types/seekbuddy/Spinner.d.ts +20 -0
- package/dist/types/seekbuddy/StatusBadge.d.ts +33 -0
- package/dist/types/seekbuddy/SubtleButton.d.ts +30 -0
- package/dist/types/seekbuddy/Switch.d.ts +36 -0
- package/dist/types/seekbuddy/Tabs.d.ts +49 -0
- package/dist/types/seekbuddy/Timeline.d.ts +42 -0
- package/dist/types/seekbuddy/Upload.d.ts +101 -0
- package/dist/types/seekbuddy/date/Calendar.d.ts +94 -0
- package/dist/types/seekbuddy/date/DatePicker.d.ts +29 -0
- package/dist/types/seekbuddy/date/DateRangePicker.d.ts +41 -0
- package/dist/types/seekbuddy/date/TimePicker.d.ts +35 -0
- package/dist/types/seekbuddy/date/date.d.ts +79 -0
- package/dist/types/seekbuddy/date/fields.d.ts +45 -0
- package/dist/types/seekbuddy/index.d.ts +49 -0
- package/dist/types/seekbuddy/qr/QrCode.d.ts +37 -0
- package/dist/types/seekbuddy/qr/qr.d.ts +38 -0
- package/dist/types/theme-bootstrap.d.ts +3 -0
- package/dist/types/theme-core.d.ts +14 -0
- package/dist/types/theme.d.ts +4 -0
- package/dist/types/tooltip-placement.d.ts +34 -0
- package/dist/types/use-clipboard-copy.d.ts +13 -0
- package/dist/types/useAnchoredMaxHeight.d.ts +13 -0
- package/dist/types/useAnchoredPosition.d.ts +35 -0
- package/dist/types/useDismissOnOutsidePointer.d.ts +10 -0
- package/dist/types/useModalLayer.d.ts +26 -0
- package/dist/types/useRowDragPreview.d.ts +19 -0
- package/dist/types/user-text.d.ts +31 -0
- package/package.json +151 -4
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDays,
|
|
3
|
+
addMonths,
|
|
4
|
+
addMonthsToDate,
|
|
5
|
+
compareIso,
|
|
6
|
+
isInRange,
|
|
7
|
+
isOutsideBounds,
|
|
8
|
+
monthGrid,
|
|
9
|
+
monthOf,
|
|
10
|
+
monthTitle,
|
|
11
|
+
normalizeRange,
|
|
12
|
+
todayIso,
|
|
13
|
+
weekOffset,
|
|
14
|
+
weekdayNames
|
|
15
|
+
} from "./chunk-RZOP2PFC.js";
|
|
16
|
+
|
|
17
|
+
// src/seekbuddy/date/Calendar.tsx
|
|
18
|
+
import clsx from "clsx";
|
|
19
|
+
import { Button } from "@seekbuddy/dsh-ui";
|
|
20
|
+
import { IconChevronLeftOutlineRegular, IconChevronRightOutlineRegular } from "@seekbuddy/dsh-ui/icons";
|
|
21
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
22
|
+
|
|
23
|
+
// .build/css/seekbuddy/date/Calendar.module.mjs
|
|
24
|
+
var id = "@seekbuddy/dsh-ui/seekbuddy/date/Calendar.module.css";
|
|
25
|
+
if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id + '"]')) {
|
|
26
|
+
const element = document.createElement("style");
|
|
27
|
+
element.setAttribute("data-dsh-ui-primitives", id);
|
|
28
|
+
element.textContent = "._2W6iWW_calendar{--calendar-cell:32px;--calendar-gap:2px;color:var(--dsw-alias-label-primary);gap:24px;display:inline-grid}._2W6iWW_twoMonths{grid-auto-flow:column}._2W6iWW_month{gap:8px;display:grid}._2W6iWW_header{justify-content:space-between;align-items:center;gap:4px;min-height:28px;display:flex}._2W6iWW_navGroup{gap:2px;display:inline-flex}._2W6iWW_nav{width:28px;color:var(--dsw-alias-label-secondary);padding:0}._2W6iWW_nav:hover:not(:disabled){color:var(--dsw-alias-label-primary)}._2W6iWW_nav:focus-visible{outline-offset:1px;outline-style:solid}._2W6iWW_double{align-items:center;display:inline-flex}._2W6iWW_double>:last-child{margin-left:-8px}._2W6iWW_title{text-align:center;font:var(--dsw-font-s-strong-14);flex:1}._2W6iWW_grid{border-collapse:separate;border-spacing:var(--calendar-gap);margin:calc(var(--calendar-gap) * -1)}._2W6iWW_weekday{width:var(--calendar-cell);height:24px;color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxs-12);text-align:center;padding:0;font-weight:400}._2W6iWW_cell{padding:0}._2W6iWW_day{width:var(--calendar-cell);height:var(--calendar-cell);border-radius:var(--dsw-radius-sm);color:inherit;cursor:pointer;font:var(--dsw-font-xs-13);font-variant-numeric:tabular-nums;background:0 0;border:0;justify-content:center;align-items:center;padding:0;display:inline-flex}._2W6iWW_day:hover:not(._2W6iWW_disabled):not(._2W6iWW_selected){background:var(--dsw-alias-interactive-bg-hover)}._2W6iWW_day:active:not(._2W6iWW_disabled):not(._2W6iWW_selected){background:var(--dsw-alias-interactive-bg-active)}._2W6iWW_day:focus-visible{outline-offset:1px;outline-style:solid}._2W6iWW_outside{color:var(--dsw-alias-label-dimmed)}._2W6iWW_today{box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}._2W6iWW_selected{color:var(--dsw-alias-label-primary-foreground);background:var(--dsw-alias-button-primary-fill)}._2W6iWW_selected:hover{background:var(--dsw-alias-button-primary-hover)}._2W6iWW_disabled{color:var(--dsw-alias-label-dimmed);cursor:not-allowed;text-decoration:line-through}._2W6iWW_range ._2W6iWW_grid{border-spacing:0 var(--calendar-gap)}._2W6iWW_range ._2W6iWW_day{border-radius:0}._2W6iWW_range ._2W6iWW_day:not([data-range]):not([data-range-preview]){border-radius:var(--dsw-radius-sm)}._2W6iWW_day[data-range=middle]{background:var(--dsw-alias-interactive-bg-hover)}._2W6iWW_day[data-range=start],._2W6iWW_day[data-range-preview=start]{border-radius:var(--dsw-radius-sm) 0 0 var(--dsw-radius-sm)}._2W6iWW_day[data-range=end],._2W6iWW_day[data-range-preview=end]{border-radius:0 var(--dsw-radius-sm) var(--dsw-radius-sm) 0}._2W6iWW_day[data-range=single],._2W6iWW_day[data-range-preview=single]{border-radius:var(--dsw-radius-sm)}._2W6iWW_day[data-range-preview]{background:var(--dsw-alias-interactive-bg-hover)}._2W6iWW_range ._2W6iWW_selected:hover{background:var(--dsw-alias-button-primary-hover)}";
|
|
29
|
+
document.head.appendChild(element);
|
|
30
|
+
}
|
|
31
|
+
var Calendar_module_default = { "month": "_2W6iWW_month", "title": "_2W6iWW_title", "nav": "_2W6iWW_nav", "header": "_2W6iWW_header", "cell": "_2W6iWW_cell", "grid": "_2W6iWW_grid", "outside": "_2W6iWW_outside", "day": "_2W6iWW_day", "today": "_2W6iWW_today", "double": "_2W6iWW_double", "range": "_2W6iWW_range", "disabled": "_2W6iWW_disabled", "selected": "_2W6iWW_selected", "weekday": "_2W6iWW_weekday", "twoMonths": "_2W6iWW_twoMonths", "navGroup": "_2W6iWW_navGroup", "calendar": "_2W6iWW_calendar" };
|
|
32
|
+
|
|
33
|
+
// src/seekbuddy/date/Calendar.tsx
|
|
34
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
35
|
+
var DAY_KEYS = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };
|
|
36
|
+
function rangePosition(date, range) {
|
|
37
|
+
if (!isInRange(date, range)) return void 0;
|
|
38
|
+
if (range.start === range.end) return "single";
|
|
39
|
+
if (date === range.start) return "start";
|
|
40
|
+
if (date === range.end) return "end";
|
|
41
|
+
return "middle";
|
|
42
|
+
}
|
|
43
|
+
function Calendar(props) {
|
|
44
|
+
const {
|
|
45
|
+
month,
|
|
46
|
+
onMonthChange,
|
|
47
|
+
numberOfMonths = props.mode === "range" ? 2 : 1,
|
|
48
|
+
min,
|
|
49
|
+
max,
|
|
50
|
+
isDateDisabled,
|
|
51
|
+
locale,
|
|
52
|
+
weekStart = 1,
|
|
53
|
+
today: todayProp,
|
|
54
|
+
labels,
|
|
55
|
+
autoFocus = false,
|
|
56
|
+
className
|
|
57
|
+
} = props;
|
|
58
|
+
const idBase = useId();
|
|
59
|
+
const [today] = useState(() => todayProp ?? todayIso());
|
|
60
|
+
const resolvedToday = todayProp ?? today;
|
|
61
|
+
const single = props.mode === "single" ? props.value : null;
|
|
62
|
+
const rangeStart = props.mode === "range" ? props.value?.start ?? null : null;
|
|
63
|
+
const rangeEnd = props.mode === "range" ? props.value?.end ?? null : null;
|
|
64
|
+
const committed = rangeStart !== null && rangeEnd !== null ? { start: rangeStart, end: rangeEnd } : null;
|
|
65
|
+
const drafting = props.mode === "range" && rangeStart !== null && rangeEnd === null;
|
|
66
|
+
const anchor = props.mode === "single" ? single : rangeStart;
|
|
67
|
+
const [monthState, setMonthState] = useState(() => monthOf(anchor ?? resolvedToday));
|
|
68
|
+
const [seenAnchor, setSeenAnchor] = useState(anchor);
|
|
69
|
+
if (anchor !== seenAnchor) {
|
|
70
|
+
setSeenAnchor(anchor);
|
|
71
|
+
if (anchor !== null) {
|
|
72
|
+
const anchorMonth = monthOf(anchor);
|
|
73
|
+
const visibleUntil = addMonths(monthState, numberOfMonths - 1);
|
|
74
|
+
if (compareIso(anchorMonth, monthState) < 0 || compareIso(anchorMonth, visibleUntil) > 0) {
|
|
75
|
+
setMonthState(anchorMonth);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const firstMonth = month ?? monthState;
|
|
80
|
+
const lastMonth = addMonths(firstMonth, numberOfMonths - 1);
|
|
81
|
+
const showMonth = (next) => {
|
|
82
|
+
if (month === void 0) setMonthState(next);
|
|
83
|
+
onMonthChange?.(next);
|
|
84
|
+
};
|
|
85
|
+
const [focused, setFocused] = useState(null);
|
|
86
|
+
const pendingFocus = useRef(null);
|
|
87
|
+
const pendingAutoFocus = useRef(autoFocus);
|
|
88
|
+
const cellRefs = useRef(/* @__PURE__ */ new Map());
|
|
89
|
+
const [hovered, setHovered] = useState(null);
|
|
90
|
+
const [focusedCell, setFocusedCell] = useState(null);
|
|
91
|
+
const previewTarget = drafting ? hovered ?? focusedCell : null;
|
|
92
|
+
const preview = previewTarget !== null && rangeStart !== null && previewTarget !== rangeStart ? normalizeRange(rangeStart, previewTarget) : null;
|
|
93
|
+
const isDisabled = (date) => isOutsideBounds(date, min, max) || (isDateDisabled?.(date) ?? false);
|
|
94
|
+
const inView = (date) => {
|
|
95
|
+
const m = monthOf(date);
|
|
96
|
+
return compareIso(m, firstMonth) >= 0 && compareIso(m, lastMonth) <= 0;
|
|
97
|
+
};
|
|
98
|
+
const months = [];
|
|
99
|
+
for (let index = 0; index < numberOfMonths; index += 1) {
|
|
100
|
+
const current2 = addMonths(firstMonth, index);
|
|
101
|
+
months.push({
|
|
102
|
+
month: current2,
|
|
103
|
+
title: monthTitle(locale, current2),
|
|
104
|
+
titleId: `${idBase}-title-${index}`,
|
|
105
|
+
cells: monthGrid(current2, weekStart)
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
let tabStop = null;
|
|
109
|
+
if (focused !== null && inView(focused)) tabStop = focused;
|
|
110
|
+
else if (anchor !== null && inView(anchor)) tabStop = anchor;
|
|
111
|
+
else if (inView(resolvedToday)) tabStop = resolvedToday;
|
|
112
|
+
else {
|
|
113
|
+
outer: for (const visible of months) {
|
|
114
|
+
for (const date of visible.cells) {
|
|
115
|
+
if (monthOf(date) === visible.month && !isDisabled(date)) {
|
|
116
|
+
tabStop = date;
|
|
117
|
+
break outer;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const target = pendingAutoFocus.current ? tabStop : pendingFocus.current;
|
|
124
|
+
pendingAutoFocus.current = false;
|
|
125
|
+
pendingFocus.current = null;
|
|
126
|
+
if (target !== null) cellRefs.current.get(target)?.focus();
|
|
127
|
+
});
|
|
128
|
+
const moveFocus = (next) => {
|
|
129
|
+
setFocused(next);
|
|
130
|
+
pendingFocus.current = next;
|
|
131
|
+
if (compareIso(monthOf(next), firstMonth) < 0) showMonth(monthOf(next));
|
|
132
|
+
else if (compareIso(monthOf(next), lastMonth) > 0) showMonth(addMonths(monthOf(next), -(numberOfMonths - 1)));
|
|
133
|
+
};
|
|
134
|
+
const onGridKeyDown = (event) => {
|
|
135
|
+
const origin = event.target.dataset["date"];
|
|
136
|
+
if (origin === void 0) return;
|
|
137
|
+
let next;
|
|
138
|
+
const days = DAY_KEYS[event.key];
|
|
139
|
+
if (days !== void 0) next = addDays(origin, days);
|
|
140
|
+
else if (event.key === "Home") next = addDays(origin, -weekOffset(origin, weekStart));
|
|
141
|
+
else if (event.key === "End") next = addDays(origin, 6 - weekOffset(origin, weekStart));
|
|
142
|
+
else if (event.key === "PageUp") next = addMonthsToDate(origin, event.shiftKey ? -12 : -1);
|
|
143
|
+
else if (event.key === "PageDown") next = addMonthsToDate(origin, event.shiftKey ? 12 : 1);
|
|
144
|
+
else return;
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
moveFocus(next);
|
|
147
|
+
};
|
|
148
|
+
const current = props;
|
|
149
|
+
const pick = (date) => {
|
|
150
|
+
if (isDisabled(date)) return;
|
|
151
|
+
setFocused(date);
|
|
152
|
+
if (!inView(date)) {
|
|
153
|
+
pendingFocus.current = date;
|
|
154
|
+
showMonth(monthOf(date));
|
|
155
|
+
}
|
|
156
|
+
if (current.mode === "single") current.onChange(date);
|
|
157
|
+
else if (drafting && rangeStart !== null) {
|
|
158
|
+
setHovered(null);
|
|
159
|
+
current.onChange(normalizeRange(rangeStart, date));
|
|
160
|
+
} else current.onChange({ start: date, end: null });
|
|
161
|
+
};
|
|
162
|
+
const weekdaysShort = weekdayNames(locale, weekStart, "short");
|
|
163
|
+
const weekdaysLong = weekdayNames(locale, weekStart, "long");
|
|
164
|
+
const twoMonths = numberOfMonths === 2;
|
|
165
|
+
const nav = (label, onClick, icon, double) => {
|
|
166
|
+
const Chevron = icon === "prev" ? IconChevronLeftOutlineRegular : IconChevronRightOutlineRegular;
|
|
167
|
+
return /* @__PURE__ */ jsx(
|
|
168
|
+
Button,
|
|
169
|
+
{
|
|
170
|
+
variant: "ghost",
|
|
171
|
+
size: "sm",
|
|
172
|
+
className: Calendar_module_default.nav,
|
|
173
|
+
"aria-label": label,
|
|
174
|
+
onClick,
|
|
175
|
+
icon: double ? /* @__PURE__ */ jsxs("span", { className: Calendar_module_default.double, "aria-hidden": "true", children: [
|
|
176
|
+
/* @__PURE__ */ jsx(Chevron, {}),
|
|
177
|
+
/* @__PURE__ */ jsx(Chevron, {})
|
|
178
|
+
] }) : /* @__PURE__ */ jsx(Chevron, {})
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
const renderMonth = (visible, index) => /* @__PURE__ */ jsxs("div", { className: Calendar_module_default.month, children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: Calendar_module_default.header, children: [
|
|
184
|
+
twoMonths ? index === 0 && nav(labels.previousMonth, () => showMonth(addMonths(firstMonth, -1)), "prev", false) : /* @__PURE__ */ jsxs("span", { className: Calendar_module_default.navGroup, children: [
|
|
185
|
+
nav(labels.previousYear, () => showMonth(addMonths(firstMonth, -12)), "prev", true),
|
|
186
|
+
nav(labels.previousMonth, () => showMonth(addMonths(firstMonth, -1)), "prev", false)
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ jsx("span", { id: visible.titleId, className: Calendar_module_default.title, "aria-live": "polite", children: visible.title }),
|
|
189
|
+
twoMonths ? index === numberOfMonths - 1 && nav(labels.nextMonth, () => showMonth(addMonths(firstMonth, 1)), "next", false) : /* @__PURE__ */ jsxs("span", { className: Calendar_module_default.navGroup, children: [
|
|
190
|
+
nav(labels.nextMonth, () => showMonth(addMonths(firstMonth, 1)), "next", false),
|
|
191
|
+
nav(labels.nextYear, () => showMonth(addMonths(firstMonth, 12)), "next", true)
|
|
192
|
+
] })
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ jsxs("table", { role: "grid", "aria-labelledby": visible.titleId, className: Calendar_module_default.grid, onKeyDown: onGridKeyDown, children: [
|
|
195
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: weekdaysShort.map((name, column) => /* @__PURE__ */ jsx("th", { scope: "col", abbr: weekdaysLong[column], className: Calendar_module_default.weekday, children: name }, name)) }) }),
|
|
196
|
+
/* @__PURE__ */ jsx("tbody", { children: Array.from({ length: 6 }, (_, row) => /* @__PURE__ */ jsx("tr", { children: visible.cells.slice(row * 7, row * 7 + 7).map((date) => {
|
|
197
|
+
const outside = monthOf(date) !== visible.month;
|
|
198
|
+
const state = {
|
|
199
|
+
selected: props.mode === "single" ? single === date : date === rangeStart || date === rangeEnd,
|
|
200
|
+
today: date === resolvedToday,
|
|
201
|
+
disabled: isDisabled(date),
|
|
202
|
+
inRange: committed !== null && isInRange(date, committed)
|
|
203
|
+
};
|
|
204
|
+
const position = !outside && committed !== null ? rangePosition(date, committed) : void 0;
|
|
205
|
+
const previewPosition = !outside && preview !== null && date !== rangeStart ? rangePosition(date, preview) : void 0;
|
|
206
|
+
return /* @__PURE__ */ jsx(
|
|
207
|
+
"td",
|
|
208
|
+
{
|
|
209
|
+
role: "gridcell",
|
|
210
|
+
"aria-selected": state.selected,
|
|
211
|
+
"aria-disabled": state.disabled || void 0,
|
|
212
|
+
className: Calendar_module_default.cell,
|
|
213
|
+
children: /* @__PURE__ */ jsx(
|
|
214
|
+
"button",
|
|
215
|
+
{
|
|
216
|
+
type: "button",
|
|
217
|
+
ref: (node) => {
|
|
218
|
+
if (outside) return;
|
|
219
|
+
if (node === null) cellRefs.current.delete(date);
|
|
220
|
+
else cellRefs.current.set(date, node);
|
|
221
|
+
},
|
|
222
|
+
tabIndex: !outside && date === tabStop ? 0 : -1,
|
|
223
|
+
"aria-label": labels.dayLabel(date, state),
|
|
224
|
+
"aria-disabled": state.disabled || void 0,
|
|
225
|
+
"data-date": date,
|
|
226
|
+
"data-outside": outside || void 0,
|
|
227
|
+
"data-range": position,
|
|
228
|
+
"data-range-preview": previewPosition,
|
|
229
|
+
className: clsx(
|
|
230
|
+
Calendar_module_default.day,
|
|
231
|
+
state.selected && !outside && Calendar_module_default.selected,
|
|
232
|
+
state.today && Calendar_module_default.today,
|
|
233
|
+
outside && Calendar_module_default.outside,
|
|
234
|
+
state.disabled && Calendar_module_default.disabled
|
|
235
|
+
),
|
|
236
|
+
onClick: () => pick(date),
|
|
237
|
+
onPointerEnter: drafting ? () => setHovered(date) : void 0,
|
|
238
|
+
onFocus: props.mode === "range" ? () => setFocusedCell(date) : void 0,
|
|
239
|
+
onBlur: props.mode === "range" ? () => setFocusedCell(null) : void 0,
|
|
240
|
+
children: Number(date.slice(-2))
|
|
241
|
+
}
|
|
242
|
+
)
|
|
243
|
+
},
|
|
244
|
+
date
|
|
245
|
+
);
|
|
246
|
+
}) }, row)) })
|
|
247
|
+
] })
|
|
248
|
+
] }, index);
|
|
249
|
+
return /* @__PURE__ */ jsx(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
className: clsx(Calendar_module_default.calendar, twoMonths && Calendar_module_default.twoMonths, props.mode === "range" && Calendar_module_default.range, className),
|
|
253
|
+
onPointerLeave: drafting ? () => setHovered(null) : void 0,
|
|
254
|
+
children: months.map(renderMonth)
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export {
|
|
260
|
+
Calendar
|
|
261
|
+
};
|