beez-ui 0.7.0 → 0.8.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 +21 -3
- package/README.md +290 -274
- package/dist/components/account-menu.d.ts +53 -0
- package/dist/components/account-menu.js +405 -0
- package/dist/components/animated-collapse.d.ts +19 -0
- package/dist/components/animated-collapse.js +81 -0
- package/dist/components/animated-count.d.ts +13 -0
- package/dist/components/animated-count.js +105 -0
- package/dist/components/animated-list-item.d.ts +25 -0
- package/dist/components/animated-list-item.js +132 -0
- package/dist/components/bouncing-dots-loader.d.ts +19 -0
- package/dist/components/bouncing-dots-loader.js +47 -0
- package/dist/components/confirm-delete-button.d.ts +29 -0
- package/dist/components/confirm-delete-button.js +254 -0
- package/dist/components/empty-state.d.ts +24 -0
- package/dist/components/empty-state.js +37 -0
- package/dist/components/error-state.d.ts +20 -0
- package/dist/components/error-state.js +145 -0
- package/dist/components/external-browser-handoff.d.ts +27 -0
- package/dist/components/external-browser-handoff.js +306 -0
- package/dist/components/file-upload.d.ts +78 -0
- package/dist/components/file-upload.js +678 -0
- package/dist/components/info-popover.d.ts +23 -0
- package/dist/components/info-popover.js +158 -0
- package/dist/components/month-calendar-header.d.ts +65 -0
- package/dist/components/month-calendar-header.js +337 -0
- package/dist/components/month-grid.d.ts +59 -0
- package/dist/components/month-grid.js +301 -0
- package/dist/components/notification-bell.d.ts +50 -0
- package/dist/components/notification-bell.js +338 -0
- package/dist/components/notification-panel.d.ts +56 -0
- package/dist/components/notification-panel.js +281 -0
- package/dist/components/open-in-browser-cta.d.ts +22 -0
- package/dist/components/open-in-browser-cta.js +61 -0
- package/dist/components/presence-swap.d.ts +22 -0
- package/dist/components/presence-swap.js +162 -0
- package/dist/components/progress-ring.d.ts +20 -0
- package/dist/components/progress-ring.js +53 -0
- package/dist/components/pwa-update-control.d.ts +18 -0
- package/dist/components/pwa-update-control.js +119 -0
- package/dist/components/reaction-button.d.ts +26 -0
- package/dist/components/reaction-button.js +114 -0
- package/dist/components/rich-link-editor.d.ts +25 -0
- package/dist/components/rich-link-editor.js +320 -0
- package/dist/components/rich-markdown-content.d.ts +10 -0
- package/dist/components/rich-markdown-content.js +56 -0
- package/dist/components/rich-text-content.d.ts +19 -0
- package/dist/components/rich-text-content.js +26 -0
- package/dist/emoji-picker.d.ts +27 -0
- package/dist/emoji-picker.js +283 -0
- package/dist/hooks/use-horizontal-swipe.d.ts +23 -0
- package/dist/hooks/use-horizontal-swipe.js +80 -0
- package/dist/hooks/use-is-hydrated.d.ts +6 -0
- package/dist/hooks/use-is-hydrated.js +20 -0
- package/dist/hooks/use-minute-clock.d.ts +23 -0
- package/dist/hooks/use-minute-clock.js +147 -0
- package/dist/hooks/use-month-transition-direction.d.ts +21 -0
- package/dist/hooks/use-month-transition-direction.js +110 -0
- package/dist/hooks/use-rich-link-editor.d.ts +55 -0
- package/dist/hooks/use-rich-link-editor.js +515 -0
- package/dist/hooks/use-viewer-time-zone.d.ts +6 -0
- package/dist/hooks/use-viewer-time-zone.js +20 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +43 -0
- package/dist/lib/browser-clipboard.d.ts +13 -0
- package/dist/lib/browser-clipboard.js +48 -0
- package/dist/lib/browser-navigation.d.ts +21 -0
- package/dist/lib/browser-navigation.js +42 -0
- package/dist/lib/file-acceptance.d.ts +43 -0
- package/dist/lib/file-acceptance.js +107 -0
- package/dist/lib/format-file-size.d.ts +16 -0
- package/dist/lib/format-file-size.js +34 -0
- package/dist/lib/fuzzy-search.d.ts +17 -0
- package/dist/lib/fuzzy-search.js +183 -0
- package/dist/lib/horizontal-swipe.d.ts +23 -0
- package/dist/lib/horizontal-swipe.js +29 -0
- package/dist/lib/in-app-browser.d.ts +35 -0
- package/dist/lib/in-app-browser.js +80 -0
- package/dist/lib/month-grid.d.ts +42 -0
- package/dist/lib/month-grid.js +74 -0
- package/dist/lib/name-initials.d.ts +7 -0
- package/dist/lib/name-initials.js +11 -0
- package/dist/lib/rich-text/link-markdown-constants.d.ts +147 -0
- package/dist/lib/rich-text/link-markdown-constants.js +458 -0
- package/dist/lib/rich-text/link-markdown-types.d.ts +53 -0
- package/dist/lib/rich-text/link-markdown-types.js +1 -0
- package/dist/lib/rich-text/link-markdown.d.ts +193 -0
- package/dist/lib/rich-text/link-markdown.js +592 -0
- package/dist/lib/rich-text/rich-markdown.d.ts +41 -0
- package/dist/lib/rich-text/rich-markdown.js +105 -0
- package/dist/lib/rich-text/rich-text-editor-dom.d.ts +26 -0
- package/dist/lib/rich-text/rich-text-editor-dom.js +79 -0
- package/dist/motion/tokens.d.ts +17 -1
- package/dist/motion/tokens.js +17 -1
- package/dist/styles.css +1 -1
- package/package.json +211 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders persisted rich text (markdown links plus auto-detected URLs) as plain text interleaved
|
|
3
|
+
* with safe `<a>` links. Raw HTML in the content is never interpreted as markup.
|
|
4
|
+
*/
|
|
5
|
+
import type { MouseEvent } from "react";
|
|
6
|
+
/** Shared look of links inside rendered rich text. */
|
|
7
|
+
export declare const RICH_TEXT_LINK_CLASS_NAME = "rounded-[0.2rem] text-primary underline decoration-primary/45 underline-offset-[0.18em] transition-[color,text-decoration-color] [word-break:break-word] hover:text-[color-mix(in_oklab,var(--primary)_72%,var(--foreground))] hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
|
|
8
|
+
export interface RichTextContentProps {
|
|
9
|
+
content: string;
|
|
10
|
+
onLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
11
|
+
linkClassName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Renders an inline fragment instead of a wrapper element, so it composes inside any container
|
|
15
|
+
* without altering layout-sensitive behavior such as `line-clamp` on an ancestor.
|
|
16
|
+
* @param props - Stored content, optional link click handler and link class name.
|
|
17
|
+
* @returns Text and links.
|
|
18
|
+
*/
|
|
19
|
+
export declare function RichTextContent({ content, onLinkClick, linkClassName }: RichTextContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cn } from "../lib/utils.js";
|
|
2
|
+
import { RICH_TEXT_SEGMENT_TYPE } from "../lib/rich-text/link-markdown-constants.js";
|
|
3
|
+
import { parseRichTextSegments } from "../lib/rich-text/link-markdown.js";
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
|
+
const LINK_TARGET = "_blank";
|
|
6
|
+
const LINK_REL = "noreferrer";
|
|
7
|
+
/** Shared look of links inside rendered rich text. */
|
|
8
|
+
export const RICH_TEXT_LINK_CLASS_NAME = "rounded-[0.2rem] text-primary underline decoration-primary/45 underline-offset-[0.18em] transition-[color,text-decoration-color] [word-break:break-word] hover:text-[color-mix(in_oklab,var(--primary)_72%,var(--foreground))] hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
|
|
9
|
+
/**
|
|
10
|
+
* Renders an inline fragment instead of a wrapper element, so it composes inside any container
|
|
11
|
+
* without altering layout-sensitive behavior such as `line-clamp` on an ancestor.
|
|
12
|
+
* @param props - Stored content, optional link click handler and link class name.
|
|
13
|
+
* @returns Text and links.
|
|
14
|
+
*/
|
|
15
|
+
export function RichTextContent({ content, onLinkClick, linkClassName }) {
|
|
16
|
+
const segments = parseRichTextSegments(content);
|
|
17
|
+
return /* @__PURE__ */ _jsx(_Fragment, { children: segments.map((segment, segmentIndex) => segment.type === RICH_TEXT_SEGMENT_TYPE.link ? /* @__PURE__ */ _jsx("a", {
|
|
18
|
+
"data-slot": "rich-text-link",
|
|
19
|
+
className: cn(RICH_TEXT_LINK_CLASS_NAME, "font-bold decoration-[0.08em]", linkClassName),
|
|
20
|
+
href: segment.url,
|
|
21
|
+
onClick: onLinkClick,
|
|
22
|
+
rel: LINK_REL,
|
|
23
|
+
target: LINK_TARGET,
|
|
24
|
+
children: segment.text
|
|
25
|
+
}, segment.type + String(segmentIndex)) : segment.text) });
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface EmojiPickerLabels {
|
|
2
|
+
/** Accessible name of the trigger. */
|
|
3
|
+
chooseEmoji: string;
|
|
4
|
+
/** Accessible name of the popover. */
|
|
5
|
+
picker: string;
|
|
6
|
+
searchPlaceholder: string;
|
|
7
|
+
loading: string;
|
|
8
|
+
}
|
|
9
|
+
export interface EmojiPickerProps {
|
|
10
|
+
/** Currently selected emoji; empty shows a placeholder icon. */
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (emoji: string) => void;
|
|
13
|
+
/** Visible label of the field. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Keeps the label for assistive technology but hides it visually. */
|
|
16
|
+
isLabelVisuallyHidden?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
labels?: Partial<EmojiPickerLabels>;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders an outline trigger showing the current emoji that opens a searchable emoji popover. The
|
|
23
|
+
* chosen emoji swaps in with a short cross-fade; the picker follows the resolved color theme.
|
|
24
|
+
* @param props - Current value, change handler, label and optional copy.
|
|
25
|
+
* @returns The labelled emoji picker.
|
|
26
|
+
*/
|
|
27
|
+
export declare function EmojiPicker({ value, onChange, label, isLabelVisuallyHidden, disabled, labels, className, }: EmojiPickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Isolates the optional `emoji-picker-react` peer from the package root: only apps importing
|
|
5
|
+
* `beez-ui/emoji-picker` need it installed.
|
|
6
|
+
*/
|
|
7
|
+
import { lazy, Suspense, useState } from "react";
|
|
8
|
+
import { SmilePlusIcon } from "lucide-react";
|
|
9
|
+
import { useTheme } from "next-themes";
|
|
10
|
+
import { cn } from "./lib/utils.js";
|
|
11
|
+
import { Button } from "./components/button.js";
|
|
12
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./components/popover.js";
|
|
13
|
+
import { PresenceSwap } from "./components/presence-swap.js";
|
|
14
|
+
import { BouncingDotsLoader } from "./components/bouncing-dots-loader.js";
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
/** Loads the picker bundle (and its emoji data) only when the popover opens for the first time. */
|
|
17
|
+
const LazyEmojiPickerReact = lazy(async () => {
|
|
18
|
+
const emojiPickerModule = await import("emoji-picker-react");
|
|
19
|
+
const moduleDefault = emojiPickerModule.default;
|
|
20
|
+
return { default: "default" in moduleDefault ? moduleDefault.default : moduleDefault };
|
|
21
|
+
});
|
|
22
|
+
const EMOJI_PICKER_HEIGHT_PX = 360;
|
|
23
|
+
/** Fills the popover, which already caps its width to the viewport on phones. */
|
|
24
|
+
const EMOJI_PICKER_WIDTH = "100%";
|
|
25
|
+
/** Presence key of the placeholder icon shown before an emoji is chosen. */
|
|
26
|
+
const EMPTY_SELECTION_KEY = "empty";
|
|
27
|
+
const DARK_THEME = "dark";
|
|
28
|
+
/**
|
|
29
|
+
* Picker options as the string values of the library enums. Only types are imported, so the
|
|
30
|
+
* library is not evaluated until the lazy import runs (never during server rendering).
|
|
31
|
+
*/
|
|
32
|
+
const EMOJI_PICKER_OPTIONS = {
|
|
33
|
+
emojiStyle: "apple",
|
|
34
|
+
defaultSkinTone: "neutral",
|
|
35
|
+
skinTonePickerLocation: "SEARCH",
|
|
36
|
+
suggestedEmojisMode: "recent",
|
|
37
|
+
darkTheme: "dark",
|
|
38
|
+
lightTheme: "light"
|
|
39
|
+
};
|
|
40
|
+
const EMOJI_PICKER_DEFAULT_LABELS = {
|
|
41
|
+
chooseEmoji: "Elegir emoji",
|
|
42
|
+
picker: "Selector de emojis",
|
|
43
|
+
searchPlaceholder: "Buscar emoji",
|
|
44
|
+
loading: "Cargando emojis..."
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Renders an outline trigger showing the current emoji that opens a searchable emoji popover. The
|
|
48
|
+
* chosen emoji swaps in with a short cross-fade; the picker follows the resolved color theme.
|
|
49
|
+
* @param props - Current value, change handler, label and optional copy.
|
|
50
|
+
* @returns The labelled emoji picker.
|
|
51
|
+
*/
|
|
52
|
+
export function EmojiPicker(t0) {
|
|
53
|
+
const $ = _c(46);
|
|
54
|
+
const { value, onChange, label, isLabelVisuallyHidden: t1, disabled: t2, labels, className } = t0;
|
|
55
|
+
const isLabelVisuallyHidden = t1 === undefined ? false : t1;
|
|
56
|
+
const disabled = t2 === undefined ? false : t2;
|
|
57
|
+
let t3;
|
|
58
|
+
if ($[0] !== labels) {
|
|
59
|
+
t3 = {
|
|
60
|
+
...EMOJI_PICKER_DEFAULT_LABELS,
|
|
61
|
+
...labels
|
|
62
|
+
};
|
|
63
|
+
$[0] = labels;
|
|
64
|
+
$[1] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[1];
|
|
67
|
+
}
|
|
68
|
+
const resolvedLabels = t3;
|
|
69
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
70
|
+
const { resolvedTheme } = useTheme();
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[2] !== value) {
|
|
73
|
+
t4 = value.trim();
|
|
74
|
+
$[2] = value;
|
|
75
|
+
$[3] = t4;
|
|
76
|
+
} else {
|
|
77
|
+
t4 = $[3];
|
|
78
|
+
}
|
|
79
|
+
const selectedEmoji = t4;
|
|
80
|
+
let t5;
|
|
81
|
+
if ($[4] !== onChange) {
|
|
82
|
+
t5 = (emojiData) => {
|
|
83
|
+
onChange(emojiData.emoji);
|
|
84
|
+
setIsOpen(false);
|
|
85
|
+
};
|
|
86
|
+
$[4] = onChange;
|
|
87
|
+
$[5] = t5;
|
|
88
|
+
} else {
|
|
89
|
+
t5 = $[5];
|
|
90
|
+
}
|
|
91
|
+
const handleEmojiClick = t5;
|
|
92
|
+
let t6;
|
|
93
|
+
if ($[6] !== className) {
|
|
94
|
+
t6 = cn("grid w-fit min-w-0 gap-[0.4rem]", className);
|
|
95
|
+
$[6] = className;
|
|
96
|
+
$[7] = t6;
|
|
97
|
+
} else {
|
|
98
|
+
t6 = $[7];
|
|
99
|
+
}
|
|
100
|
+
const t7 = isLabelVisuallyHidden && "sr-only";
|
|
101
|
+
let t8;
|
|
102
|
+
if ($[8] !== t7) {
|
|
103
|
+
t8 = cn("text-[0.82rem] leading-tight font-semibold text-muted-foreground", t7);
|
|
104
|
+
$[8] = t7;
|
|
105
|
+
$[9] = t8;
|
|
106
|
+
} else {
|
|
107
|
+
t8 = $[9];
|
|
108
|
+
}
|
|
109
|
+
let t9;
|
|
110
|
+
if ($[10] !== label || $[11] !== t8) {
|
|
111
|
+
t9 = /* @__PURE__ */ _jsx("span", {
|
|
112
|
+
className: t8,
|
|
113
|
+
children: label
|
|
114
|
+
});
|
|
115
|
+
$[10] = label;
|
|
116
|
+
$[11] = t8;
|
|
117
|
+
$[12] = t9;
|
|
118
|
+
} else {
|
|
119
|
+
t9 = $[12];
|
|
120
|
+
}
|
|
121
|
+
const t10 = selectedEmoji || EMPTY_SELECTION_KEY;
|
|
122
|
+
let t11;
|
|
123
|
+
if ($[13] !== selectedEmoji) {
|
|
124
|
+
t11 = selectedEmoji || /* @__PURE__ */ _jsx(SmilePlusIcon, {});
|
|
125
|
+
$[13] = selectedEmoji;
|
|
126
|
+
$[14] = t11;
|
|
127
|
+
} else {
|
|
128
|
+
t11 = $[14];
|
|
129
|
+
}
|
|
130
|
+
let t12;
|
|
131
|
+
if ($[15] !== t11) {
|
|
132
|
+
t12 = /* @__PURE__ */ _jsx("span", {
|
|
133
|
+
"aria-hidden": true,
|
|
134
|
+
children: t11
|
|
135
|
+
});
|
|
136
|
+
$[15] = t11;
|
|
137
|
+
$[16] = t12;
|
|
138
|
+
} else {
|
|
139
|
+
t12 = $[16];
|
|
140
|
+
}
|
|
141
|
+
let t13;
|
|
142
|
+
if ($[17] !== t10 || $[18] !== t12) {
|
|
143
|
+
t13 = /* @__PURE__ */ _jsx(PresenceSwap, {
|
|
144
|
+
as: "span",
|
|
145
|
+
className: "inline-grid min-h-5 min-w-5 place-items-center text-[1.15rem] leading-none",
|
|
146
|
+
mode: "popLayout",
|
|
147
|
+
presenceKey: t10,
|
|
148
|
+
children: t12
|
|
149
|
+
});
|
|
150
|
+
$[17] = t10;
|
|
151
|
+
$[18] = t12;
|
|
152
|
+
$[19] = t13;
|
|
153
|
+
} else {
|
|
154
|
+
t13 = $[19];
|
|
155
|
+
}
|
|
156
|
+
let t14;
|
|
157
|
+
if ($[20] !== disabled || $[21] !== resolvedLabels.chooseEmoji || $[22] !== t13) {
|
|
158
|
+
t14 = /* @__PURE__ */ _jsx(PopoverTrigger, {
|
|
159
|
+
asChild: true,
|
|
160
|
+
children: /* @__PURE__ */ _jsx(Button, {
|
|
161
|
+
"aria-label": resolvedLabels.chooseEmoji,
|
|
162
|
+
className: "min-h-[2.7rem] w-fit min-w-[3.25rem] justify-center gap-[0.55rem] border-border bg-background text-[0.95rem] text-foreground data-[state=open]:border-ring data-[state=open]:shadow-[0_0_0_2px_color-mix(in_srgb,var(--ring)_18%,transparent)]",
|
|
163
|
+
disabled,
|
|
164
|
+
type: "button",
|
|
165
|
+
variant: "outline",
|
|
166
|
+
children: t13
|
|
167
|
+
})
|
|
168
|
+
});
|
|
169
|
+
$[20] = disabled;
|
|
170
|
+
$[21] = resolvedLabels.chooseEmoji;
|
|
171
|
+
$[22] = t13;
|
|
172
|
+
$[23] = t14;
|
|
173
|
+
} else {
|
|
174
|
+
t14 = $[23];
|
|
175
|
+
}
|
|
176
|
+
let t15;
|
|
177
|
+
if ($[24] !== resolvedLabels.loading) {
|
|
178
|
+
t15 = /* @__PURE__ */ _jsx(BouncingDotsLoader, {
|
|
179
|
+
className: "py-10",
|
|
180
|
+
label: resolvedLabels.loading,
|
|
181
|
+
size: "sm"
|
|
182
|
+
});
|
|
183
|
+
$[24] = resolvedLabels.loading;
|
|
184
|
+
$[25] = t15;
|
|
185
|
+
} else {
|
|
186
|
+
t15 = $[25];
|
|
187
|
+
}
|
|
188
|
+
let t16;
|
|
189
|
+
if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
|
|
190
|
+
t16 = [];
|
|
191
|
+
$[26] = t16;
|
|
192
|
+
} else {
|
|
193
|
+
t16 = $[26];
|
|
194
|
+
}
|
|
195
|
+
let t17;
|
|
196
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
197
|
+
t17 = { showPreview: false };
|
|
198
|
+
$[27] = t17;
|
|
199
|
+
} else {
|
|
200
|
+
t17 = $[27];
|
|
201
|
+
}
|
|
202
|
+
const t18 = resolvedTheme === DARK_THEME ? EMOJI_PICKER_OPTIONS.darkTheme : EMOJI_PICKER_OPTIONS.lightTheme;
|
|
203
|
+
let t19;
|
|
204
|
+
if ($[28] !== handleEmojiClick || $[29] !== resolvedLabels.searchPlaceholder || $[30] !== t18) {
|
|
205
|
+
t19 = /* @__PURE__ */ _jsx(LazyEmojiPickerReact, {
|
|
206
|
+
autoFocusSearch: true,
|
|
207
|
+
customEmojis: t16,
|
|
208
|
+
defaultSkinTone: EMOJI_PICKER_OPTIONS.defaultSkinTone,
|
|
209
|
+
emojiStyle: EMOJI_PICKER_OPTIONS.emojiStyle,
|
|
210
|
+
height: EMOJI_PICKER_HEIGHT_PX,
|
|
211
|
+
lazyLoadEmojis: true,
|
|
212
|
+
onEmojiClick: handleEmojiClick,
|
|
213
|
+
previewConfig: t17,
|
|
214
|
+
searchPlaceholder: resolvedLabels.searchPlaceholder,
|
|
215
|
+
skinTonePickerLocation: EMOJI_PICKER_OPTIONS.skinTonePickerLocation,
|
|
216
|
+
suggestedEmojisMode: EMOJI_PICKER_OPTIONS.suggestedEmojisMode,
|
|
217
|
+
theme: t18,
|
|
218
|
+
width: EMOJI_PICKER_WIDTH
|
|
219
|
+
});
|
|
220
|
+
$[28] = handleEmojiClick;
|
|
221
|
+
$[29] = resolvedLabels.searchPlaceholder;
|
|
222
|
+
$[30] = t18;
|
|
223
|
+
$[31] = t19;
|
|
224
|
+
} else {
|
|
225
|
+
t19 = $[31];
|
|
226
|
+
}
|
|
227
|
+
let t20;
|
|
228
|
+
if ($[32] !== t15 || $[33] !== t19) {
|
|
229
|
+
t20 = /* @__PURE__ */ _jsx(Suspense, {
|
|
230
|
+
fallback: t15,
|
|
231
|
+
children: t19
|
|
232
|
+
});
|
|
233
|
+
$[32] = t15;
|
|
234
|
+
$[33] = t19;
|
|
235
|
+
$[34] = t20;
|
|
236
|
+
} else {
|
|
237
|
+
t20 = $[34];
|
|
238
|
+
}
|
|
239
|
+
let t21;
|
|
240
|
+
if ($[35] !== resolvedLabels.picker || $[36] !== t20) {
|
|
241
|
+
t21 = /* @__PURE__ */ _jsx(PopoverContent, {
|
|
242
|
+
"data-slot": "emoji-picker-content",
|
|
243
|
+
align: "start",
|
|
244
|
+
"aria-label": resolvedLabels.picker,
|
|
245
|
+
className: "w-[min(20rem,calc(100vw-2rem))] overflow-hidden p-0",
|
|
246
|
+
children: t20
|
|
247
|
+
});
|
|
248
|
+
$[35] = resolvedLabels.picker;
|
|
249
|
+
$[36] = t20;
|
|
250
|
+
$[37] = t21;
|
|
251
|
+
} else {
|
|
252
|
+
t21 = $[37];
|
|
253
|
+
}
|
|
254
|
+
let t22;
|
|
255
|
+
if ($[38] !== isOpen || $[39] !== t14 || $[40] !== t21) {
|
|
256
|
+
t22 = /* @__PURE__ */ _jsxs(Popover, {
|
|
257
|
+
open: isOpen,
|
|
258
|
+
onOpenChange: setIsOpen,
|
|
259
|
+
children: [t14, t21]
|
|
260
|
+
});
|
|
261
|
+
$[38] = isOpen;
|
|
262
|
+
$[39] = t14;
|
|
263
|
+
$[40] = t21;
|
|
264
|
+
$[41] = t22;
|
|
265
|
+
} else {
|
|
266
|
+
t22 = $[41];
|
|
267
|
+
}
|
|
268
|
+
let t23;
|
|
269
|
+
if ($[42] !== t22 || $[43] !== t6 || $[44] !== t9) {
|
|
270
|
+
t23 = /* @__PURE__ */ _jsxs("div", {
|
|
271
|
+
"data-slot": "emoji-picker",
|
|
272
|
+
className: t6,
|
|
273
|
+
children: [t9, t22]
|
|
274
|
+
});
|
|
275
|
+
$[42] = t22;
|
|
276
|
+
$[43] = t6;
|
|
277
|
+
$[44] = t9;
|
|
278
|
+
$[45] = t23;
|
|
279
|
+
} else {
|
|
280
|
+
t23 = $[45];
|
|
281
|
+
}
|
|
282
|
+
return t23;
|
|
283
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Recognizes one-finger horizontal swipes on touch surfaces such as pagers and calendars. */
|
|
2
|
+
import { type TouchEvent } from "react";
|
|
3
|
+
import { type HorizontalSwipeDirection } from "../lib/horizontal-swipe.js";
|
|
4
|
+
/**
|
|
5
|
+
* Touch handlers to spread on the swipe surface.
|
|
6
|
+
*/
|
|
7
|
+
export type HorizontalSwipeHandlers = {
|
|
8
|
+
onTouchCancel: () => void;
|
|
9
|
+
onTouchEnd: (event: TouchEvent<HTMLElement>) => void;
|
|
10
|
+
onTouchStart: (event: TouchEvent<HTMLElement>) => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Detects horizontal one-finger swipes. Touch events are used instead of
|
|
14
|
+
* Pointer Events because browsers fire `pointercancel` as soon as they start
|
|
15
|
+
* scrolling, and WebKit (iOS Safari and every iOS browser) has only partial
|
|
16
|
+
* `touch-action` support to prevent it, while `touchend` is delivered on
|
|
17
|
+
* both engines. The handlers never call `preventDefault`, so native vertical
|
|
18
|
+
* scrolling and pinch-zoom keep working; mouse drags never trigger a swipe.
|
|
19
|
+
*
|
|
20
|
+
* @param onSwipe - Called once per recognised swipe.
|
|
21
|
+
* @returns Handlers for the swipe surface.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useHorizontalSwipe(onSwipe: (direction: HorizontalSwipeDirection) => void): HorizontalSwipeHandlers;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** Recognizes one-finger horizontal swipes on touch surfaces such as pagers and calendars. */
|
|
4
|
+
import { useRef } from "react";
|
|
5
|
+
import { resolveHorizontalSwipe } from "../lib/horizontal-swipe.js";
|
|
6
|
+
/**
|
|
7
|
+
* Detects horizontal one-finger swipes. Touch events are used instead of
|
|
8
|
+
* Pointer Events because browsers fire `pointercancel` as soon as they start
|
|
9
|
+
* scrolling, and WebKit (iOS Safari and every iOS browser) has only partial
|
|
10
|
+
* `touch-action` support to prevent it, while `touchend` is delivered on
|
|
11
|
+
* both engines. The handlers never call `preventDefault`, so native vertical
|
|
12
|
+
* scrolling and pinch-zoom keep working; mouse drags never trigger a swipe.
|
|
13
|
+
*
|
|
14
|
+
* @param onSwipe - Called once per recognised swipe.
|
|
15
|
+
* @returns Handlers for the swipe surface.
|
|
16
|
+
*/
|
|
17
|
+
export function useHorizontalSwipe(onSwipe) {
|
|
18
|
+
const $ = _c(6);
|
|
19
|
+
const swipeStartRef = useRef(null);
|
|
20
|
+
let t0;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t0 = () => {
|
|
23
|
+
swipeStartRef.current = null;
|
|
24
|
+
};
|
|
25
|
+
$[0] = t0;
|
|
26
|
+
} else {
|
|
27
|
+
t0 = $[0];
|
|
28
|
+
}
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[1] !== onSwipe) {
|
|
31
|
+
t1 = (event) => {
|
|
32
|
+
const swipeStart = swipeStartRef.current;
|
|
33
|
+
const endTouch = swipeStart ? Array.from(event.changedTouches).find((touch) => touch.identifier === swipeStart.identifier) : undefined;
|
|
34
|
+
swipeStartRef.current = null;
|
|
35
|
+
if (!swipeStart || !endTouch) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const direction = resolveHorizontalSwipe({
|
|
39
|
+
deltaX: endTouch.clientX - swipeStart.x,
|
|
40
|
+
deltaY: endTouch.clientY - swipeStart.y,
|
|
41
|
+
durationMs: event.timeStamp - swipeStart.startTime
|
|
42
|
+
});
|
|
43
|
+
if (direction) {
|
|
44
|
+
onSwipe(direction);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
$[1] = onSwipe;
|
|
48
|
+
$[2] = t1;
|
|
49
|
+
} else {
|
|
50
|
+
t1 = $[2];
|
|
51
|
+
}
|
|
52
|
+
let t2;
|
|
53
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
54
|
+
t2 = (event_0) => {
|
|
55
|
+
const [firstTouch] = Array.from(event_0.touches);
|
|
56
|
+
swipeStartRef.current = event_0.touches.length === 1 && firstTouch ? {
|
|
57
|
+
identifier: firstTouch.identifier,
|
|
58
|
+
startTime: event_0.timeStamp,
|
|
59
|
+
x: firstTouch.clientX,
|
|
60
|
+
y: firstTouch.clientY
|
|
61
|
+
} : null;
|
|
62
|
+
};
|
|
63
|
+
$[3] = t2;
|
|
64
|
+
} else {
|
|
65
|
+
t2 = $[3];
|
|
66
|
+
}
|
|
67
|
+
let t3;
|
|
68
|
+
if ($[4] !== t1) {
|
|
69
|
+
t3 = {
|
|
70
|
+
onTouchCancel: t0,
|
|
71
|
+
onTouchEnd: t1,
|
|
72
|
+
onTouchStart: t2
|
|
73
|
+
};
|
|
74
|
+
$[4] = t1;
|
|
75
|
+
$[5] = t3;
|
|
76
|
+
} else {
|
|
77
|
+
t3 = $[5];
|
|
78
|
+
}
|
|
79
|
+
return t3;
|
|
80
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hydration store: the server snapshot is `false` and the client snapshot is
|
|
3
|
+
* `true`, so the first client render still matches the server markup and the
|
|
4
|
+
* component learns it is hydrated on the very next render without an effect.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useIsHydrated(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/** Tells hydrated client renders apart from server and hydration renders without an effect. */
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
function subscribeToNothing() {
|
|
5
|
+
return () => undefined;
|
|
6
|
+
}
|
|
7
|
+
function getHydratedSnapshot() {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
function getServerHydratedSnapshot() {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hydration store: the server snapshot is `false` and the client snapshot is
|
|
15
|
+
* `true`, so the first client render still matches the server markup and the
|
|
16
|
+
* component learns it is hydrated on the very next render without an effect.
|
|
17
|
+
*/
|
|
18
|
+
export function useIsHydrated() {
|
|
19
|
+
return useSyncExternalStore(subscribeToNothing, getHydratedSnapshot, getServerHydratedSnapshot);
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves the clock forward to `instantTime` (epoch ms) and re-renders every
|
|
3
|
+
* consumer. Earlier instants are ignored, so the clock never goes back. Use
|
|
4
|
+
* it when a scheduled boundary is reached or the server proved that an
|
|
5
|
+
* instant already passed (for example an occurrence it reported as ended
|
|
6
|
+
* while the local clock still lagged behind).
|
|
7
|
+
*
|
|
8
|
+
* @param instantTime - Instant the clock must reach, in epoch milliseconds.
|
|
9
|
+
*/
|
|
10
|
+
export declare function advanceMinuteClockTo(instantTime: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Current time, refreshed on every minute boundary and at the exact instant of
|
|
13
|
+
* each wake-up time that falls before the next boundary. Between boundaries it
|
|
14
|
+
* holds the minute (or the last wake-up instant) it settled on. Returns null
|
|
15
|
+
* during server rendering and hydration so time-dependent UI never produces a
|
|
16
|
+
* server/client markup mismatch; it settles to a number right after mount.
|
|
17
|
+
*
|
|
18
|
+
* @param wakeUpTimes - Instants (epoch ms) where time-dependent UI changes,
|
|
19
|
+
* such as the end of an occurrence on screen; the clock re-renders exactly
|
|
20
|
+
* then instead of waiting for the next minute.
|
|
21
|
+
* @returns The clock value in epoch milliseconds, or null before hydration.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useMinuteClock(wakeUpTimes?: readonly number[]): number | null;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { c as _c } from "react/compiler-runtime";
|
|
3
|
+
/** Shares one minute-aligned clock across components, hydration-safe and with exact wake-ups. */
|
|
4
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
5
|
+
const MILLISECONDS_PER_MINUTE = 6e4;
|
|
6
|
+
const NO_WAKE_UP_TIMES = [];
|
|
7
|
+
const clockListeners = new Set();
|
|
8
|
+
/**
|
|
9
|
+
* Latest instant the clock settled on. It only moves forward: minute ticks
|
|
10
|
+
* raise it to the current minute and wake-ups (or an instant the server
|
|
11
|
+
* confirmed) raise it to that exact instant. Null while nobody observes the
|
|
12
|
+
* clock, so a later mount starts again from the real time.
|
|
13
|
+
*/
|
|
14
|
+
let settledClockTime = null;
|
|
15
|
+
let minuteTickTimeoutId = null;
|
|
16
|
+
function truncateToMinute(time) {
|
|
17
|
+
return Math.floor(time / MILLISECONDS_PER_MINUTE) * MILLISECONDS_PER_MINUTE;
|
|
18
|
+
}
|
|
19
|
+
function notifyClockListeners() {
|
|
20
|
+
for (const listener of clockListeners) {
|
|
21
|
+
listener();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Moves the clock forward to `instantTime` (epoch ms) and re-renders every
|
|
26
|
+
* consumer. Earlier instants are ignored, so the clock never goes back. Use
|
|
27
|
+
* it when a scheduled boundary is reached or the server proved that an
|
|
28
|
+
* instant already passed (for example an occurrence it reported as ended
|
|
29
|
+
* while the local clock still lagged behind).
|
|
30
|
+
*
|
|
31
|
+
* @param instantTime - Instant the clock must reach, in epoch milliseconds.
|
|
32
|
+
*/
|
|
33
|
+
export function advanceMinuteClockTo(instantTime) {
|
|
34
|
+
if (settledClockTime !== null && instantTime <= settledClockTime) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
settledClockTime = instantTime;
|
|
38
|
+
notifyClockListeners();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Schedules the next tick on the next minute boundary. Each tick measures the
|
|
42
|
+
* remaining time again instead of relying on a fixed interval, so the clock
|
|
43
|
+
* never lags by the mount offset and a timer that fires a little early or
|
|
44
|
+
* late re-aligns on the following boundary.
|
|
45
|
+
*/
|
|
46
|
+
function scheduleNextMinuteTick() {
|
|
47
|
+
const currentTime = Date.now();
|
|
48
|
+
const millisecondsToNextMinute = truncateToMinute(currentTime) + MILLISECONDS_PER_MINUTE - currentTime;
|
|
49
|
+
minuteTickTimeoutId = window.setTimeout(() => {
|
|
50
|
+
scheduleNextMinuteTick();
|
|
51
|
+
notifyClockListeners();
|
|
52
|
+
}, millisecondsToNextMinute);
|
|
53
|
+
}
|
|
54
|
+
function stopMinuteTicks() {
|
|
55
|
+
if (minuteTickTimeoutId !== null) {
|
|
56
|
+
window.clearTimeout(minuteTickTimeoutId);
|
|
57
|
+
minuteTickTimeoutId = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function subscribe(onStoreChange) {
|
|
61
|
+
clockListeners.add(onStoreChange);
|
|
62
|
+
if (clockListeners.size === 1) {
|
|
63
|
+
scheduleNextMinuteTick();
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
clockListeners.delete(onStoreChange);
|
|
67
|
+
if (clockListeners.size === 0) {
|
|
68
|
+
stopMinuteTicks();
|
|
69
|
+
settledClockTime = null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function getSnapshot() {
|
|
74
|
+
const currentMinuteTime = truncateToMinute(Date.now());
|
|
75
|
+
if (settledClockTime === null || currentMinuteTime > settledClockTime) {
|
|
76
|
+
settledClockTime = currentMinuteTime;
|
|
77
|
+
}
|
|
78
|
+
return settledClockTime;
|
|
79
|
+
}
|
|
80
|
+
function getServerSnapshot() {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function findNextWakeUpTime(wakeUpTimes, nowTime) {
|
|
84
|
+
let nextWakeUpTime = null;
|
|
85
|
+
for (const wakeUpTime of wakeUpTimes) {
|
|
86
|
+
if (wakeUpTime > nowTime && (nextWakeUpTime === null || wakeUpTime < nextWakeUpTime)) {
|
|
87
|
+
nextWakeUpTime = wakeUpTime;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return nextWakeUpTime;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Current time, refreshed on every minute boundary and at the exact instant of
|
|
94
|
+
* each wake-up time that falls before the next boundary. Between boundaries it
|
|
95
|
+
* holds the minute (or the last wake-up instant) it settled on. Returns null
|
|
96
|
+
* during server rendering and hydration so time-dependent UI never produces a
|
|
97
|
+
* server/client markup mismatch; it settles to a number right after mount.
|
|
98
|
+
*
|
|
99
|
+
* @param wakeUpTimes - Instants (epoch ms) where time-dependent UI changes,
|
|
100
|
+
* such as the end of an occurrence on screen; the clock re-renders exactly
|
|
101
|
+
* then instead of waiting for the next minute.
|
|
102
|
+
* @returns The clock value in epoch milliseconds, or null before hydration.
|
|
103
|
+
*/
|
|
104
|
+
export function useMinuteClock(t0) {
|
|
105
|
+
const $ = _c(8);
|
|
106
|
+
const wakeUpTimes = t0 === undefined ? NO_WAKE_UP_TIMES : t0;
|
|
107
|
+
const nowTime = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
108
|
+
let t1;
|
|
109
|
+
if ($[0] !== nowTime || $[1] !== wakeUpTimes) {
|
|
110
|
+
t1 = nowTime === null ? null : findNextWakeUpTime(wakeUpTimes, nowTime);
|
|
111
|
+
$[0] = nowTime;
|
|
112
|
+
$[1] = wakeUpTimes;
|
|
113
|
+
$[2] = t1;
|
|
114
|
+
} else {
|
|
115
|
+
t1 = $[2];
|
|
116
|
+
}
|
|
117
|
+
const nextWakeUpTime = t1;
|
|
118
|
+
let t2;
|
|
119
|
+
if ($[3] !== nextWakeUpTime) {
|
|
120
|
+
t2 = () => {
|
|
121
|
+
if (nextWakeUpTime === null) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const millisecondsToWakeUp = nextWakeUpTime - Date.now();
|
|
125
|
+
if (millisecondsToWakeUp > MILLISECONDS_PER_MINUTE) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const wakeUpTimeoutId = window.setTimeout(() => advanceMinuteClockTo(nextWakeUpTime), Math.max(0, millisecondsToWakeUp));
|
|
129
|
+
return () => window.clearTimeout(wakeUpTimeoutId);
|
|
130
|
+
};
|
|
131
|
+
$[3] = nextWakeUpTime;
|
|
132
|
+
$[4] = t2;
|
|
133
|
+
} else {
|
|
134
|
+
t2 = $[4];
|
|
135
|
+
}
|
|
136
|
+
let t3;
|
|
137
|
+
if ($[5] !== nextWakeUpTime || $[6] !== nowTime) {
|
|
138
|
+
t3 = [nextWakeUpTime, nowTime];
|
|
139
|
+
$[5] = nextWakeUpTime;
|
|
140
|
+
$[6] = nowTime;
|
|
141
|
+
$[7] = t3;
|
|
142
|
+
} else {
|
|
143
|
+
t3 = $[7];
|
|
144
|
+
}
|
|
145
|
+
useEffect(t2, t3);
|
|
146
|
+
return nowTime;
|
|
147
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const MONTH_TRANSITION_DIRECTION: {
|
|
2
|
+
readonly next: "next";
|
|
3
|
+
readonly none: "none";
|
|
4
|
+
readonly previous: "previous";
|
|
5
|
+
};
|
|
6
|
+
export type MonthTransitionDirection = (typeof MONTH_TRANSITION_DIRECTION)[keyof typeof MONTH_TRANSITION_DIRECTION];
|
|
7
|
+
/**
|
|
8
|
+
* Compares two `YYYY-MM` keys, which sort chronologically as plain strings.
|
|
9
|
+
* @param fromMonth - Month shown before, or null when there is none.
|
|
10
|
+
* @param toMonth - Month shown now.
|
|
11
|
+
* @returns `next` or `previous` when the month changed, `none` otherwise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveMonthTransitionDirection(fromMonth: string | null, toMonth: string): MonthTransitionDirection;
|
|
14
|
+
/**
|
|
15
|
+
* Direction of the latest month change of a calendar: a new `month` on the same instance, or a
|
|
16
|
+
* fresh mount right after another month of the same calendar was on screen.
|
|
17
|
+
* @param scopeKey - Calendar identity, so different calendars do not orient each other.
|
|
18
|
+
* @param month - Visible `YYYY-MM` month.
|
|
19
|
+
* @returns Direction to animate the month entrance with.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useMonthTransitionDirection(scopeKey: string, month: string): MonthTransitionDirection;
|