beez-ui 2.7.1 → 3.0.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 +78 -0
- package/README.md +43 -13
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/components/account-menu.d.ts +4 -3
- package/dist/components/account-menu.js +63 -54
- package/dist/components/alert.d.ts +15 -15
- package/dist/components/alert.js +289 -270
- package/dist/components/animated-theme-toggler.js +1 -1
- package/dist/components/avatar.d.ts +56 -31
- package/dist/components/avatar.js +394 -277
- package/dist/components/badge.d.ts +8 -28
- package/dist/components/badge.js +55 -108
- package/dist/components/calendar.d.ts +36 -26
- package/dist/components/calendar.js +132 -1227
- package/dist/components/card.d.ts +36 -25
- package/dist/components/card.js +895 -72
- package/dist/components/carousel.d.ts +63 -47
- package/dist/components/carousel.js +496 -777
- package/dist/components/data-table.d.ts +5 -4
- package/dist/components/data-table.js +7 -6
- package/dist/components/dialog-surface.d.ts +23 -1
- package/dist/components/dialog-surface.js +99 -3
- package/dist/components/dialog.d.ts +80 -45
- package/dist/components/dialog.js +258 -503
- package/dist/components/dropdown-menu.d.ts +56 -73
- package/dist/components/dropdown-menu.js +79 -714
- package/dist/components/field.d.ts +3 -1
- package/dist/components/field.js +49 -39
- package/dist/components/filter-presets-bar.js +2 -2
- package/dist/components/filter-query-bar.js +1 -1
- package/dist/components/hover-card.d.ts +42 -41
- package/dist/components/hover-card.js +57 -483
- package/dist/components/pagination.d.ts +53 -31
- package/dist/components/pagination.js +176 -412
- package/dist/components/popover.d.ts +11 -23
- package/dist/components/popover.js +19 -304
- package/dist/components/{alert-dialog.d.ts → primitives/alert-dialog.d.ts} +17 -5
- package/dist/components/{alert-dialog.js → primitives/alert-dialog.js} +102 -54
- package/dist/components/primitives/avatar.d.ts +46 -0
- package/dist/components/primitives/avatar.js +268 -0
- package/dist/components/primitives/calendar.d.ts +37 -0
- package/dist/components/primitives/calendar.js +1250 -0
- package/dist/components/primitives/carousel.d.ts +106 -0
- package/dist/components/primitives/carousel.js +928 -0
- package/dist/components/primitives/dialog.d.ts +62 -0
- package/dist/components/primitives/dialog.js +490 -0
- package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
- package/dist/components/primitives/dropdown-menu-items.js +265 -0
- package/dist/components/primitives/dropdown-menu.d.ts +64 -0
- package/dist/components/primitives/dropdown-menu.js +557 -0
- package/dist/components/primitives/hover-card.d.ts +50 -0
- package/dist/components/primitives/hover-card.js +507 -0
- package/dist/components/primitives/pagination.d.ts +65 -0
- package/dist/components/primitives/pagination.js +373 -0
- package/dist/components/primitives/popover.d.ts +22 -0
- package/dist/components/primitives/popover.js +213 -0
- package/dist/components/primitives/select.d.ts +36 -0
- package/dist/components/primitives/select.js +407 -0
- package/dist/components/primitives/tooltip.d.ts +30 -0
- package/dist/components/primitives/tooltip.js +277 -0
- package/dist/components/radio-group.d.ts +30 -17
- package/dist/components/radio-group.js +266 -315
- package/dist/components/rich-link-editor.js +1 -1
- package/dist/components/select.d.ts +51 -42
- package/dist/components/select.js +163 -495
- package/dist/components/skeleton.d.ts +16 -15
- package/dist/components/skeleton.js +99 -205
- package/dist/components/split-button.js +1 -1
- package/dist/components/switch.d.ts +3 -6
- package/dist/components/switch.js +163 -170
- package/dist/components/tabs.d.ts +3 -11
- package/dist/components/tabs.js +61 -75
- package/dist/components/themed-toaster.d.ts +1 -1
- package/dist/components/themed-toaster.js +1 -1
- package/dist/components/toaster.d.ts +1 -1
- package/dist/components/toaster.js +1 -1
- package/dist/components/tooltip.d.ts +36 -31
- package/dist/components/tooltip.js +44 -284
- package/dist/constants/alert.d.ts +5 -1
- package/dist/constants/alert.js +5 -1
- package/dist/constants/avatar.d.ts +29 -1
- package/dist/constants/avatar.js +25 -0
- package/dist/constants/calendar.d.ts +12 -0
- package/dist/constants/calendar.js +12 -0
- package/dist/constants/card.d.ts +23 -0
- package/dist/constants/card.js +20 -0
- package/dist/constants/carousel.d.ts +31 -13
- package/dist/constants/carousel.js +32 -11
- package/dist/constants/dialog.d.ts +6 -1
- package/dist/constants/dialog.js +5 -1
- package/dist/constants/dropdown-menu.d.ts +2 -2
- package/dist/constants/dropdown-menu.js +2 -2
- package/dist/constants/pagination.d.ts +13 -2
- package/dist/constants/pagination.js +13 -2
- package/dist/constants/select.d.ts +4 -2
- package/dist/constants/select.js +4 -2
- package/dist/constants/switch.d.ts +5 -16
- package/dist/constants/switch.js +6 -14
- package/dist/hooks/use-today.d.ts +7 -0
- package/dist/hooks/use-today.js +50 -0
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/motion/glide-indicator.d.ts +1 -1
- package/dist/motion/glide-indicator.js +1 -1
- package/dist/motion/presence.d.ts +0 -1
- package/dist/motion/presence.js +0 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -6
|
@@ -1,41 +1,21 @@
|
|
|
1
1
|
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
-
/**
|
|
3
|
-
export type BadgeVariant = "default" | "secondary" | "destructive" | "outline" | "ghost" | "link";
|
|
4
|
-
/** Arc's semantic tones; a `tone` wins over the tone implied by `variant`. */
|
|
2
|
+
/** Arc's semantic tones. */
|
|
5
3
|
export type BadgeTone = "neutral" | "success" | "info" | "warning" | "danger";
|
|
6
4
|
/** Arc's badge heights: 26px (`md`) and 22px (`sm`). */
|
|
7
5
|
export type BadgeSize = "sm" | "md";
|
|
8
|
-
/** Options of `badgeVariants`, for styling links or other elements as badges. */
|
|
9
|
-
export type BadgeVariantsOptions = {
|
|
10
|
-
variant?: BadgeVariant | null;
|
|
11
|
-
tone?: BadgeTone | null;
|
|
12
|
-
size?: BadgeSize | null;
|
|
13
|
-
className?: string;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Arc's badge classes for any element. Without a `tone`, the tone implied by `variant` is used, as in `Badge`.
|
|
17
|
-
* @param options - Variant, tone, size and extra classes.
|
|
18
|
-
* @returns The class list.
|
|
19
|
-
*/
|
|
20
|
-
declare function badgeVariants({ variant, tone, size, className }?: BadgeVariantsOptions): string;
|
|
21
6
|
export type BadgeProps = ComponentProps<"span"> & {
|
|
22
|
-
/**
|
|
23
|
-
* destructive (danger) and link (info, underlined on hover). */
|
|
24
|
-
variant?: BadgeVariant | null;
|
|
25
|
-
/** Arc's semantic tone; overrides the tone implied by `variant`. */
|
|
7
|
+
/** Arc's semantic tone: `neutral` (default), `success`, `info`, `warning` or `danger`. */
|
|
26
8
|
tone?: BadgeTone;
|
|
27
9
|
/** Arc's height: `md` (26px, default) or `sm` (22px). */
|
|
28
10
|
size?: BadgeSize;
|
|
29
|
-
/** A leading icon tinted with the tone, hidden from assistive technology. */
|
|
11
|
+
/** A leading icon tinted with the tone, hidden from assistive technology. A different icon component crossfades in. */
|
|
30
12
|
icon?: ReactNode;
|
|
31
|
-
/** Renders the child element instead of a span, merging the badge props into it. Text and icon swaps are off. */
|
|
32
|
-
asChild?: boolean;
|
|
33
13
|
};
|
|
34
14
|
/**
|
|
35
|
-
* A small label for status, category or metadata.
|
|
36
|
-
* to the new width; other children render as they are.
|
|
37
|
-
* @param props -
|
|
15
|
+
* A small label for status, category or metadata. String or number children swap in place with Arc's motion and the
|
|
16
|
+
* pill springs to the new width; other children render as they are.
|
|
17
|
+
* @param props - Tone, size, optional icon and native span attributes.
|
|
38
18
|
* @returns The badge.
|
|
39
19
|
*/
|
|
40
|
-
declare function Badge({ className,
|
|
41
|
-
export { Badge
|
|
20
|
+
declare function Badge({ className, tone, size, icon, children, ...props }: BadgeProps): import("react").JSX.Element;
|
|
21
|
+
export { Badge };
|
package/dist/components/badge.js
CHANGED
|
@@ -3,12 +3,11 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
3
3
|
/**
|
|
4
4
|
* Arc's Badge (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md): a small pill for status, category or
|
|
5
5
|
* metadata on Arc's tones and tokens. A new text label rises in while the pill springs to its new width, and a new
|
|
6
|
-
* icon crossfades in place. The
|
|
6
|
+
* icon crossfades in place. The API is Arc's: `tone`, `size`, `icon` and `children`.
|
|
7
7
|
*/
|
|
8
8
|
import { isValidElement, useRef } from "react";
|
|
9
9
|
import { cva } from "class-variance-authority";
|
|
10
10
|
import { AnimatePresence, motion, useIsPresent } from "motion/react";
|
|
11
|
-
import { Slot } from "radix-ui";
|
|
12
11
|
import { BADGE_LABEL_OFFSET_EM } from "../constants/badge.js";
|
|
13
12
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion.js";
|
|
14
13
|
import { cn } from "../lib/utils.js";
|
|
@@ -17,58 +16,23 @@ import { ARC_ICON_ENTER, ARC_ICON_EXIT, ARC_ICON_TRANSITION, ARC_REDUCED_EXIT, A
|
|
|
17
16
|
import { MotionSlot } from "../motion/motion-slot.js";
|
|
18
17
|
import { useMorphWidth } from "../motion/use-morph-width.js";
|
|
19
18
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
|
-
/** The Arc tone each shadcn variant is drawn with when no explicit `tone` is passed. */
|
|
21
|
-
const VARIANT_TONE = {
|
|
22
|
-
default: "info",
|
|
23
|
-
secondary: "neutral",
|
|
24
|
-
destructive: "danger",
|
|
25
|
-
outline: "neutral",
|
|
26
|
-
ghost: "neutral",
|
|
27
|
-
link: "info"
|
|
28
|
-
};
|
|
29
19
|
/**
|
|
30
20
|
* Arc's badge recipe. Each tone sets the pill's colour roles as custom properties, so hover can mix the tone into the
|
|
31
|
-
* border and fill
|
|
21
|
+
* border and fill. Hover answers on fine pointers only.
|
|
32
22
|
*/
|
|
33
|
-
const badgeRecipe = cva("group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-clip rounded-(--radius-pill) border border-(--badge-border) bg-(--badge-background) leading-none font-medium tracking-[-.01em] whitespace-nowrap text-(--badge-foreground) transition-[border-color,background-color,color] duration-(--duration-standard) ease-(--ease-standard) motion-reduce:duration-(--duration-instant) hover-fine:border-[color-mix(in_oklab,var(--badge-color)_32%,var(--border))] hover-fine:bg-[color-mix(in_oklab,var(--badge-color)_10%,var(--surface))]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
danger: "[--badge-background:color-mix(in_oklab,var(--danger)_10%,var(--surface))] [--badge-border:color-mix(in_oklab,var(--danger)_26%,var(--border))] [--badge-color:var(--danger)] [--badge-foreground:var(--danger)]"
|
|
41
|
-
},
|
|
42
|
-
variant: {
|
|
43
|
-
default: "",
|
|
44
|
-
secondary: "",
|
|
45
|
-
destructive: "",
|
|
46
|
-
outline: "[--badge-background:var(--surface)] [--badge-foreground:var(--foreground)]",
|
|
47
|
-
ghost: "[--badge-background:transparent] [--badge-border:transparent]",
|
|
48
|
-
link: "[--badge-background:transparent] [--badge-border:transparent] underline-offset-4 hover-fine:border-transparent hover-fine:bg-transparent hover-fine:underline"
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
sm: "min-h-[22px] gap-1 px-2 text-[11px]",
|
|
52
|
-
md: "min-h-[26px] gap-[5px] px-2.5 text-xs"
|
|
53
|
-
}
|
|
23
|
+
const badgeRecipe = cva("group/badge inline-flex w-fit shrink-0 items-center justify-center overflow-clip rounded-(--radius-pill) border border-(--badge-border) bg-(--badge-background) leading-none font-medium tracking-[-.01em] whitespace-nowrap text-(--badge-foreground) transition-[border-color,background-color,color] duration-(--duration-standard) ease-(--ease-standard) motion-reduce:duration-(--duration-instant) hover-fine:border-[color-mix(in_oklab,var(--badge-color)_32%,var(--border))] hover-fine:bg-[color-mix(in_oklab,var(--badge-color)_10%,var(--surface))] aria-invalid:border-danger [&>svg]:pointer-events-none [&>svg]:size-3! [&>svg]:text-(--badge-color)", { variants: {
|
|
24
|
+
tone: {
|
|
25
|
+
neutral: "[--badge-background:var(--surface-muted)] [--badge-border:var(--border)] [--badge-color:var(--text-secondary)] [--badge-foreground:var(--text-secondary)]",
|
|
26
|
+
success: "[--badge-background:color-mix(in_oklab,var(--success)_10%,var(--surface))] [--badge-border:color-mix(in_oklab,var(--success)_25%,var(--border))] [--badge-color:var(--success)] [--badge-foreground:var(--success)]",
|
|
27
|
+
info: "[--badge-background:var(--accent-subtle)] [--badge-border:color-mix(in_oklab,var(--accent)_24%,var(--border))] [--badge-color:var(--accent)] [--badge-foreground:var(--accent-strong)]",
|
|
28
|
+
warning: "[--badge-background:color-mix(in_oklab,var(--warning)_11%,var(--surface))] [--badge-border:color-mix(in_oklab,var(--warning)_27%,var(--border))] [--badge-color:var(--warning)] [--badge-foreground:var(--warning)]",
|
|
29
|
+
danger: "[--badge-background:color-mix(in_oklab,var(--danger)_10%,var(--surface))] [--badge-border:color-mix(in_oklab,var(--danger)_26%,var(--border))] [--badge-color:var(--danger)] [--badge-foreground:var(--danger)]"
|
|
54
30
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
31
|
+
size: {
|
|
32
|
+
sm: "min-h-[22px] gap-1 px-2 text-[11px]",
|
|
33
|
+
md: "min-h-[26px] gap-[5px] px-2.5 text-xs"
|
|
58
34
|
}
|
|
59
|
-
});
|
|
60
|
-
/**
|
|
61
|
-
* Arc's badge classes for any element. Without a `tone`, the tone implied by `variant` is used, as in `Badge`.
|
|
62
|
-
* @param options - Variant, tone, size and extra classes.
|
|
63
|
-
* @returns The class list.
|
|
64
|
-
*/
|
|
65
|
-
function badgeVariants({ variant, tone, size, className } = {}) {
|
|
66
|
-
return cn(badgeRecipe({
|
|
67
|
-
tone: tone ?? VARIANT_TONE[variant ?? "default"],
|
|
68
|
-
variant,
|
|
69
|
-
size
|
|
70
|
-
}), className);
|
|
71
|
-
}
|
|
35
|
+
} });
|
|
72
36
|
/** A new label rises out of a soft blur; the old one lifts away faster. */
|
|
73
37
|
const labelEnter = {
|
|
74
38
|
opacity: 0,
|
|
@@ -243,23 +207,21 @@ function BadgeIcon(t0) {
|
|
|
243
207
|
return t4;
|
|
244
208
|
}
|
|
245
209
|
/**
|
|
246
|
-
* A small label for status, category or metadata.
|
|
247
|
-
* to the new width; other children render as they are.
|
|
248
|
-
* @param props -
|
|
210
|
+
* A small label for status, category or metadata. String or number children swap in place with Arc's motion and the
|
|
211
|
+
* pill springs to the new width; other children render as they are.
|
|
212
|
+
* @param props - Tone, size, optional icon and native span attributes.
|
|
249
213
|
* @returns The badge.
|
|
250
214
|
*/
|
|
251
215
|
function Badge(t0) {
|
|
252
|
-
const $ = _c(
|
|
216
|
+
const $ = _c(22);
|
|
253
217
|
let children;
|
|
254
218
|
let className;
|
|
255
219
|
let icon;
|
|
256
220
|
let props;
|
|
257
221
|
let t1;
|
|
258
222
|
let t2;
|
|
259
|
-
let t3;
|
|
260
|
-
let tone;
|
|
261
223
|
if ($[0] !== t0) {
|
|
262
|
-
({className,
|
|
224
|
+
({className, tone: t1, size: t2, icon, children, ...props} = t0);
|
|
263
225
|
$[0] = t0;
|
|
264
226
|
$[1] = children;
|
|
265
227
|
$[2] = className;
|
|
@@ -267,8 +229,6 @@ function Badge(t0) {
|
|
|
267
229
|
$[4] = props;
|
|
268
230
|
$[5] = t1;
|
|
269
231
|
$[6] = t2;
|
|
270
|
-
$[7] = t3;
|
|
271
|
-
$[8] = tone;
|
|
272
232
|
} else {
|
|
273
233
|
children = $[1];
|
|
274
234
|
className = $[2];
|
|
@@ -276,20 +236,14 @@ function Badge(t0) {
|
|
|
276
236
|
props = $[4];
|
|
277
237
|
t1 = $[5];
|
|
278
238
|
t2 = $[6];
|
|
279
|
-
t3 = $[7];
|
|
280
|
-
tone = $[8];
|
|
281
239
|
}
|
|
282
|
-
const
|
|
240
|
+
const tone = t1 === undefined ? "neutral" : t1;
|
|
283
241
|
const size = t2 === undefined ? "md" : t2;
|
|
284
|
-
const asChild = t3 === undefined ? false : t3;
|
|
285
242
|
const reduceMotion = usePrefersReducedMotion();
|
|
286
|
-
const resolvedVariant = variant ?? "default";
|
|
287
|
-
const resolvedTone = tone ?? VARIANT_TONE[resolvedVariant];
|
|
288
243
|
const label = typeof children === "string" || typeof children === "number" ? String(children) : null;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
t4 = asChild ? children : label === null ? /* @__PURE__ */ _jsxs(_Fragment, { children: [icon ? /* @__PURE__ */ _jsx(BadgeIcon, {
|
|
244
|
+
let t3;
|
|
245
|
+
if ($[7] !== children || $[8] !== icon || $[9] !== label || $[10] !== reduceMotion) {
|
|
246
|
+
t3 = label === null ? /* @__PURE__ */ _jsxs(_Fragment, { children: [icon ? /* @__PURE__ */ _jsx(BadgeIcon, {
|
|
293
247
|
icon,
|
|
294
248
|
iconKey: getIconKey(icon),
|
|
295
249
|
reduceMotion
|
|
@@ -298,57 +252,50 @@ function Badge(t0) {
|
|
|
298
252
|
label,
|
|
299
253
|
reduceMotion
|
|
300
254
|
});
|
|
301
|
-
$[
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[14] = t4;
|
|
255
|
+
$[7] = children;
|
|
256
|
+
$[8] = icon;
|
|
257
|
+
$[9] = label;
|
|
258
|
+
$[10] = reduceMotion;
|
|
259
|
+
$[11] = t3;
|
|
307
260
|
} else {
|
|
308
|
-
|
|
261
|
+
t3 = $[11];
|
|
309
262
|
}
|
|
310
|
-
const content =
|
|
311
|
-
let
|
|
312
|
-
if ($[
|
|
313
|
-
|
|
314
|
-
tone
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[17] = resolvedVariant;
|
|
322
|
-
$[18] = size;
|
|
323
|
-
$[19] = t5;
|
|
263
|
+
const content = t3;
|
|
264
|
+
let t4;
|
|
265
|
+
if ($[12] !== className || $[13] !== size || $[14] !== tone) {
|
|
266
|
+
t4 = cn(badgeRecipe({
|
|
267
|
+
tone,
|
|
268
|
+
size
|
|
269
|
+
}), className);
|
|
270
|
+
$[12] = className;
|
|
271
|
+
$[13] = size;
|
|
272
|
+
$[14] = tone;
|
|
273
|
+
$[15] = t4;
|
|
324
274
|
} else {
|
|
325
|
-
|
|
275
|
+
t4 = $[15];
|
|
326
276
|
}
|
|
327
|
-
let
|
|
328
|
-
if ($[
|
|
329
|
-
|
|
277
|
+
let t5;
|
|
278
|
+
if ($[16] !== content || $[17] !== props || $[18] !== size || $[19] !== t4 || $[20] !== tone) {
|
|
279
|
+
t5 = /* @__PURE__ */ _jsx(MotionSlot, {
|
|
330
280
|
kind: "fade",
|
|
331
|
-
children: /* @__PURE__ */ _jsx(
|
|
281
|
+
children: /* @__PURE__ */ _jsx("span", {
|
|
332
282
|
"data-slot": "badge",
|
|
333
|
-
"data-
|
|
334
|
-
"data-tone": resolvedTone,
|
|
283
|
+
"data-tone": tone,
|
|
335
284
|
"data-size": size,
|
|
336
|
-
className:
|
|
285
|
+
className: t4,
|
|
337
286
|
...props,
|
|
338
287
|
children: content
|
|
339
288
|
})
|
|
340
289
|
});
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
$[
|
|
344
|
-
$[
|
|
345
|
-
$[
|
|
346
|
-
$[
|
|
347
|
-
$[26] = t5;
|
|
348
|
-
$[27] = t6;
|
|
290
|
+
$[16] = content;
|
|
291
|
+
$[17] = props;
|
|
292
|
+
$[18] = size;
|
|
293
|
+
$[19] = t4;
|
|
294
|
+
$[20] = tone;
|
|
295
|
+
$[21] = t5;
|
|
349
296
|
} else {
|
|
350
|
-
|
|
297
|
+
t5 = $[21];
|
|
351
298
|
}
|
|
352
|
-
return
|
|
299
|
+
return t5;
|
|
353
300
|
}
|
|
354
|
-
export { Badge
|
|
301
|
+
export { Badge };
|
|
@@ -1,37 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arc's Calendar (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md)
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* modes, ranges, dropdowns, locales and keyboard navigation; only the design and the motion come from Arc.
|
|
2
|
+
* Arc's Calendar (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md) as a closed component: one month for
|
|
3
|
+
* picking one date, with a sliding month change, a gliding selected disc and an optional Today button. It renders on
|
|
4
|
+
* the internal react-day-picker composition, which keeps keyboard navigation and accessible day labels.
|
|
6
5
|
*/
|
|
7
6
|
import * as React from "react";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
import { useToday } from "../hooks/use-today.js";
|
|
8
|
+
export { useToday };
|
|
9
|
+
/** Returns `true` for a day that cannot be picked, such as a weekend. */
|
|
10
|
+
type CalendarDateMatcher = (date: Date) => boolean;
|
|
11
|
+
/** Props of {@link Calendar}: Arc's calendar API plus the beez-ui extensions marked below. */
|
|
12
|
+
type CalendarProps = {
|
|
13
|
+
/** Selected date. Controlled only: the calendar shows what it receives. */
|
|
14
|
+
value?: Date | null;
|
|
15
|
+
/** Called with the day the viewer picks, including from the Today button. */
|
|
16
|
+
onChange?: (date: Date) => void;
|
|
17
|
+
/** Controlled visible month. Without it the calendar opens on the month of `value`, or on today's. */
|
|
18
|
+
month?: Date;
|
|
19
|
+
/** Called with the first day of the month the viewer navigates to. */
|
|
20
|
+
onMonthChange?: (month: Date) => void;
|
|
21
|
+
/** Earliest selectable day; navigation stops at its month. */
|
|
22
|
+
minDate?: Date;
|
|
23
|
+
/** Latest selectable day; navigation stops at its month. */
|
|
24
|
+
maxDate?: Date;
|
|
25
|
+
/** Return `true` to block a day, such as weekends. */
|
|
26
|
+
disabledDates?: CalendarDateMatcher;
|
|
13
27
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
28
|
+
* BCP 47 locale for month, weekday and day names. Defaults to `"es-AR"`, with weeks starting on Monday. Spanish and
|
|
29
|
+
* English locales are fully translated; any other keeps English accessible labels with `Intl` month and weekday names.
|
|
16
30
|
*/
|
|
31
|
+
locale?: string;
|
|
32
|
+
/** Class of the calendar root. */
|
|
33
|
+
className?: string;
|
|
34
|
+
/** Adds a Today button that returns to the current month and selects today when it is allowed. */
|
|
17
35
|
showToday?: boolean;
|
|
18
|
-
/**
|
|
36
|
+
/** beez-ui: copy of the Today button. Defaults to "Hoy". */
|
|
19
37
|
todayLabel?: string;
|
|
20
38
|
};
|
|
21
39
|
/**
|
|
22
|
-
* A month grid for picking
|
|
23
|
-
*
|
|
40
|
+
* A month grid for picking one date. Days before `minDate`, after `maxDate` or matched by `disabledDates` are blocked,
|
|
41
|
+
* and navigation stops at the months of `minDate` and `maxDate`.
|
|
42
|
+
* @param props - Arc's calendar props plus `todayLabel`.
|
|
24
43
|
* @returns The calendar, in Spanish by default.
|
|
25
44
|
*/
|
|
26
|
-
declare function Calendar({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* with a dot under its number that takes the number's colour.
|
|
30
|
-
* @param props - react-day-picker day button properties plus the locale used for `data-day`.
|
|
31
|
-
* @returns The day button.
|
|
32
|
-
*/
|
|
33
|
-
declare function CalendarDayButton({ className, day, modifiers, locale, ...props }: React.ComponentProps<typeof DayButton> & {
|
|
34
|
-
locale?: Partial<Locale>;
|
|
35
|
-
}): React.JSX.Element;
|
|
36
|
-
export { Calendar, CalendarDayButton };
|
|
37
|
-
export type { CalendarProps };
|
|
45
|
+
declare function Calendar({ value, onChange, month, onMonthChange, minDate, maxDate, disabledDates, locale, className, showToday, todayLabel, }: CalendarProps): React.JSX.Element;
|
|
46
|
+
export { Calendar };
|
|
47
|
+
export type { CalendarDateMatcher, CalendarProps };
|