@nsaa/core 0.1.0-alpha.3 → 0.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/NOTICE +27 -0
- package/dist/alert/alert.d.ts +27 -3
- package/dist/alert/alert.js +198 -17
- package/dist/alert/index.d.ts +2 -2
- package/dist/badge/badge.d.ts +2 -2
- package/dist/badge/badge.js +1 -1
- package/dist/button/button.d.ts +2 -2
- package/dist/button/button.js +2 -1
- package/dist/date-range-picker/date-range-picker.d.ts +55 -0
- package/dist/date-range-picker/date-range-picker.js +359 -0
- package/dist/date-range-picker/index.d.ts +4 -0
- package/dist/date-range-picker/presets.d.ts +25 -0
- package/dist/date-range-picker/presets.js +115 -0
- package/dist/empty/empty.d.ts +1 -1
- package/dist/empty/empty.js +2 -2
- package/dist/index.d.ts +17 -4
- package/dist/index.js +12 -5
- package/dist/input-group/input-group.d.ts +1 -1
- package/dist/input-otp/input-otp.js +1 -1
- package/dist/lib/dev.js +14 -0
- package/dist/meter/index.d.ts +3 -0
- package/dist/meter/meter.d.ts +33 -0
- package/dist/meter/meter.js +145 -0
- package/dist/money/index.d.ts +3 -0
- package/dist/money/money.d.ts +28 -0
- package/dist/money/money.js +77 -0
- package/dist/progress/index.d.ts +3 -0
- package/dist/progress/progress.d.ts +8 -0
- package/dist/progress/progress.js +43 -0
- package/dist/sidebar/index.d.ts +3 -0
- package/dist/sidebar/sidebar.d.ts +66 -0
- package/dist/sidebar/sidebar.js +449 -0
- package/dist/sidebar/use-mobile.js +13 -0
- package/dist/sources/alert.css +20 -0
- package/dist/sources/date-range-picker.css +29 -0
- package/dist/sources/meter.css +3 -0
- package/dist/sources/money.css +3 -0
- package/dist/sources/progress.css +3 -0
- package/dist/sources/sidebar.css +32 -0
- package/dist/sources/stat.css +4 -0
- package/dist/stat/index.d.ts +3 -0
- package/dist/stat/stat.d.ts +47 -0
- package/dist/stat/stat.js +161 -0
- package/dist/tokens/dist/motion.js +19 -1
- package/dist/toolbar/toolbar-item.js +1 -1
- package/dist/toolbar/toolbar.js +2 -2
- package/package.json +5 -2
- package/src/feel.css +131 -3
package/LICENSE
CHANGED
|
@@ -25,4 +25,4 @@ SOFTWARE.
|
|
|
25
25
|
This licence covers the free packages in this repository. The Pro package
|
|
26
26
|
(`packages/blocks`, when it exists) ships under its own commercial licence,
|
|
27
27
|
stated in that folder. Third-party code adapted into Nsaa keeps its original
|
|
28
|
-
notice in the file header; colour scales come from
|
|
28
|
+
notice in the file header; colour scales come from Tailwind CSS (MIT).
|
package/NOTICE
CHANGED
|
@@ -152,3 +152,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
152
152
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
153
153
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
154
154
|
SOFTWARE.
|
|
155
|
+
|
|
156
|
+
-------------------------------------------------------------------------------
|
|
157
|
+
Tailwind CSS (https://github.com/tailwindlabs/tailwindcss), v4.3.3. Its default colour palette
|
|
158
|
+
(theme.css) is the source of the colour primitives in packages/tokens (src/primitives.json and
|
|
159
|
+
dist/), #149.
|
|
160
|
+
|
|
161
|
+
MIT License
|
|
162
|
+
|
|
163
|
+
Copyright (c) Tailwind Labs, Inc.
|
|
164
|
+
|
|
165
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
166
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
167
|
+
in the Software without restriction, including without limitation the rights
|
|
168
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
169
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
170
|
+
furnished to do so, subject to the following conditions:
|
|
171
|
+
|
|
172
|
+
The above copyright notice and this permission notice shall be included in all
|
|
173
|
+
copies or substantial portions of the Software.
|
|
174
|
+
|
|
175
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
176
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
177
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
178
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
179
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
180
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
181
|
+
SOFTWARE.
|
package/dist/alert/alert.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
4
|
import { VariantProps } from "class-variance-authority";
|
|
3
5
|
import * as React from "react";
|
|
4
6
|
declare const alertVariants: (props?: ({
|
|
5
7
|
variant?: "success" | "warning" | "default" | "destructive" | "info" | null | undefined;
|
|
8
|
+
appearance?: "soft" | "outline" | "solid" | null | undefined;
|
|
9
|
+
size?: "default" | "sm" | null | undefined;
|
|
6
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
-
|
|
11
|
+
type AlertAppearance = NonNullable<VariantProps<typeof alertVariants>["appearance"]>;
|
|
12
|
+
declare function Alert({ className, variant, appearance, size, announce, open, defaultOpen, onOpenChange, ref, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants> & {
|
|
13
|
+
/**
|
|
14
|
+
* How loud it is: `outline`, `soft` or `solid`. Defaults by variant: outline for default and
|
|
15
|
+
* destructive (base-nova), soft for success, warning and info.
|
|
16
|
+
*/
|
|
17
|
+
appearance?: AlertAppearance | null;
|
|
18
|
+
/** `default`, or `sm`: one compact line (icon, title, description, close) for tight places. */
|
|
19
|
+
size?: "default" | "sm" | null;
|
|
8
20
|
/**
|
|
9
21
|
* The error sound (feedback.error) when the Alert appears (#114). Left unset it's automatic: a
|
|
10
22
|
* destructive Alert plays it when a person's action caused it (within the browser's transient
|
|
@@ -12,8 +24,20 @@ declare function Alert({ className, variant, announce, ...props }: React.Compone
|
|
|
12
24
|
* warning are silent unless `announce` is set, then play feedback.success / feedback.warning.
|
|
13
25
|
*/
|
|
14
26
|
announce?: boolean;
|
|
15
|
-
|
|
27
|
+
/** Whether the Alert is shown (controlled). Only matters with an `AlertClose`. */
|
|
28
|
+
open?: boolean;
|
|
29
|
+
/** Whether the Alert starts shown when uncontrolled. Defaults to `true`. */
|
|
30
|
+
defaultOpen?: boolean;
|
|
31
|
+
/** Called with `false` when `AlertClose` is pressed. */
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
}): React.JSX.Element | null;
|
|
16
34
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
17
35
|
declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
18
36
|
declare function AlertAction({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
19
|
-
|
|
37
|
+
/** Nsaa (#148): dismisses the Alert. A ghost icon Button named "Dismiss", at the inline end. */
|
|
38
|
+
declare function AlertClose({ className, children, onClick, ...props }: Omit<React.ComponentProps<typeof Button>, "variant" | "size">): React.JSX.Element;
|
|
39
|
+
/** Nsaa (#148): a row of `AlertLink`s under the description. The ∙ between them is CSS, never read. */
|
|
40
|
+
declare function AlertLinks({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
41
|
+
/** Nsaa (#148): a real link in the Alert's own text colour, medium weight, underlined. */
|
|
42
|
+
declare function AlertLink({ className, render, ...props }: useRender.ComponentProps<"a">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
43
|
+
export { Alert, AlertAction, AlertClose, AlertDescription, AlertLink, AlertLinks, AlertTitle };
|
package/dist/alert/alert.js
CHANGED
|
@@ -1,22 +1,123 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
-
import { recentUserAction } from "../lib/user-action.js";
|
|
4
3
|
import { useCue } from "../sound/sound-map.js";
|
|
5
|
-
import {
|
|
4
|
+
import { Button } from "../button/button.js";
|
|
5
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
6
|
+
import { recentUserAction } from "../lib/user-action.js";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
9
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
10
|
import { cva } from "class-variance-authority";
|
|
7
11
|
import * as React from "react";
|
|
8
12
|
// src/alert/alert.tsx
|
|
9
13
|
const alertVariants = cva("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", {
|
|
10
|
-
variants: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
variants: {
|
|
15
|
+
variant: {
|
|
16
|
+
default: "bg-card text-card-foreground",
|
|
17
|
+
destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
|
|
18
|
+
success: "",
|
|
19
|
+
warning: "",
|
|
20
|
+
info: ""
|
|
21
|
+
},
|
|
22
|
+
appearance: {
|
|
23
|
+
outline: "",
|
|
24
|
+
soft: "",
|
|
25
|
+
solid: ""
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
default: "has-data-[slot=alert-close]:pr-10 has-data-[slot=alert-action]:has-data-[slot=alert-close]:pr-25 rtl:has-data-[slot=alert-close]:pr-2.5 rtl:has-data-[slot=alert-close]:pl-10 rtl:has-data-[slot=alert-action]:has-data-[slot=alert-close]:pl-25",
|
|
29
|
+
sm: "block rounded-md px-2 py-1.5 text-xs has-data-[slot=alert-close]:pr-8 rtl:has-data-[slot=alert-close]:pr-2 rtl:has-data-[slot=alert-close]:pl-8 *:[svg]:float-start *:[svg]:me-2 *:[svg]:translate-y-0 *:data-[slot=alert-title]:inline *:data-[slot=alert-description]:ms-1 *:data-[slot=alert-description]:inline *:data-[slot=alert-description]:text-xs"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
compoundVariants: [
|
|
33
|
+
{
|
|
34
|
+
variant: "default",
|
|
35
|
+
appearance: "soft",
|
|
36
|
+
className: "bg-muted border-transparent text-foreground *:data-[slot=alert-description]:text-foreground *:data-[slot=alert-close]:text-muted-foreground *:[svg]:text-muted-foreground"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
variant: "destructive",
|
|
40
|
+
appearance: "soft",
|
|
41
|
+
className: "bg-danger-subtle border-transparent text-foreground *:data-[slot=alert-description]:text-foreground *:data-[slot=alert-close]:text-muted-foreground *:[svg]:text-(--nsaa-color-danger-foreground)"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
variant: "success",
|
|
45
|
+
appearance: "soft",
|
|
46
|
+
className: "bg-positive-subtle border-transparent text-foreground *:data-[slot=alert-description]:text-foreground *:data-[slot=alert-close]:text-muted-foreground *:[svg]:text-(--nsaa-color-positive-foreground)"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
variant: "warning",
|
|
50
|
+
appearance: "soft",
|
|
51
|
+
className: "bg-warning-subtle border-transparent text-foreground *:data-[slot=alert-description]:text-foreground *:data-[slot=alert-close]:text-muted-foreground *:[svg]:text-(--nsaa-color-warning-foreground)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
variant: "info",
|
|
55
|
+
appearance: "soft",
|
|
56
|
+
className: "bg-info-subtle border-transparent text-foreground *:data-[slot=alert-description]:text-foreground *:data-[slot=alert-close]:text-muted-foreground *:[svg]:text-(--nsaa-color-info-foreground)"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
variant: "default",
|
|
60
|
+
appearance: "solid",
|
|
61
|
+
className: "border-inverted-solid bg-inverted-solid text-on-inverted-foreground *:data-[slot=alert-action]:rounded-[min(var(--radius-md),10px)] *:data-[slot=alert-action]:bg-background *:data-[slot=alert-action]:text-foreground *:data-[slot=alert-description]:text-on-inverted-foreground"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
variant: "destructive",
|
|
65
|
+
appearance: "outline",
|
|
66
|
+
className: "border-danger-border-default bg-card"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
variant: "success",
|
|
70
|
+
appearance: "outline",
|
|
71
|
+
className: "border-positive-border-default bg-card text-card-foreground *:[svg]:text-(--nsaa-color-positive-foreground)"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
variant: "warning",
|
|
75
|
+
appearance: "outline",
|
|
76
|
+
className: "border-warning-border-default bg-card text-card-foreground *:[svg]:text-(--nsaa-color-warning-foreground)"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
variant: "info",
|
|
80
|
+
appearance: "outline",
|
|
81
|
+
className: "border-info-border-default bg-card text-card-foreground *:[svg]:text-(--nsaa-color-info-foreground)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
variant: "destructive",
|
|
85
|
+
appearance: "solid",
|
|
86
|
+
className: "border-transparent bg-danger-solid text-on-danger-solid-foreground *:data-[slot=alert-description]:text-on-danger-solid-foreground *:data-[slot=alert-action]:rounded-[min(var(--radius-md),10px)] *:data-[slot=alert-action]:bg-on-danger-solid-foreground *:data-[slot=alert-action]:text-danger-solid **:data-[slot=button]:text-danger-solid!"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
variant: "success",
|
|
90
|
+
appearance: "solid",
|
|
91
|
+
className: "border-transparent bg-positive-solid text-on-positive-solid-foreground *:data-[slot=alert-description]:text-on-positive-solid-foreground *:data-[slot=alert-action]:rounded-[min(var(--radius-md),10px)] *:data-[slot=alert-action]:bg-on-positive-solid-foreground *:data-[slot=alert-action]:text-positive-solid **:data-[slot=button]:text-positive-solid!"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
variant: "warning",
|
|
95
|
+
appearance: "solid",
|
|
96
|
+
className: "border-transparent bg-warning-solid text-on-warning-solid-foreground *:data-[slot=alert-description]:text-on-warning-solid-foreground *:data-[slot=alert-action]:rounded-[min(var(--radius-md),10px)] *:data-[slot=alert-action]:bg-on-warning-solid-foreground *:data-[slot=alert-action]:text-warning-solid **:data-[slot=button]:text-warning-solid!"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
variant: "info",
|
|
100
|
+
appearance: "solid",
|
|
101
|
+
className: "border-transparent bg-info-solid text-on-info-solid-foreground *:data-[slot=alert-description]:text-on-info-solid-foreground *:data-[slot=alert-action]:rounded-[min(var(--radius-md),10px)] *:data-[slot=alert-action]:bg-on-info-solid-foreground *:data-[slot=alert-action]:text-info-solid **:data-[slot=button]:text-info-solid!"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
appearance: ["soft", "solid"],
|
|
105
|
+
className: "[&_a:hover]:text-current!"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
defaultVariants: {
|
|
109
|
+
variant: "default",
|
|
110
|
+
size: "default"
|
|
111
|
+
}
|
|
18
112
|
});
|
|
19
|
-
|
|
113
|
+
const AlertContext = React.createContext(null);
|
|
114
|
+
const FOCUSABLE = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
|
|
115
|
+
/** The next focusable element after `el` in the page, or the previous one if there is none. */
|
|
116
|
+
function neighbour(el) {
|
|
117
|
+
const all = [...el.ownerDocument.querySelectorAll(FOCUSABLE)].filter((node) => !el.contains(node) && (node.checkVisibility?.() ?? true));
|
|
118
|
+
return all.find((node) => el.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING) ?? all.filter((node) => el.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING).at(-1) ?? null;
|
|
119
|
+
}
|
|
120
|
+
function Alert({ className, variant, appearance, size, announce, open, defaultOpen = true, onOpenChange, ref, ...props }) {
|
|
20
121
|
const cue = useCue("alert");
|
|
21
122
|
const destructive = variant === "destructive";
|
|
22
123
|
const announceCue = variant === "success" || variant === "warning" ? variant : "destructive";
|
|
@@ -27,11 +128,47 @@ function Alert({ className, variant, announce, ...props }) {
|
|
|
27
128
|
React.useEffect(() => {
|
|
28
129
|
if (announce !== false && (destructive || announce)) appear();
|
|
29
130
|
}, [destructive, announce]);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
131
|
+
const [uncontrolled, setUncontrolled] = React.useState(defaultOpen);
|
|
132
|
+
const shown = open ?? uncontrolled;
|
|
133
|
+
const [mounted, setMounted] = React.useState(shown);
|
|
134
|
+
const node = React.useRef(null);
|
|
135
|
+
if (shown && !mounted) setMounted(true);
|
|
136
|
+
React.useLayoutEffect(() => {
|
|
137
|
+
const el = node.current;
|
|
138
|
+
if (shown || !el) return;
|
|
139
|
+
let live = true;
|
|
140
|
+
const running = el.getAnimations?.() ?? [];
|
|
141
|
+
Promise.allSettled(running.map((a) => a.finished)).then(() => {
|
|
142
|
+
if (!live) return;
|
|
143
|
+
if (el.contains(el.ownerDocument.activeElement)) neighbour(el)?.focus();
|
|
144
|
+
setMounted(false);
|
|
145
|
+
});
|
|
146
|
+
return () => {
|
|
147
|
+
live = false;
|
|
148
|
+
};
|
|
149
|
+
}, [shown]);
|
|
150
|
+
const context = React.useMemo(() => ({ close: () => {
|
|
151
|
+
if (open === void 0) setUncontrolled(false);
|
|
152
|
+
onOpenChange?.(false);
|
|
153
|
+
} }), [open, onOpenChange]);
|
|
154
|
+
if (!mounted) return null;
|
|
155
|
+
const status = variant ?? "default";
|
|
156
|
+
const look = appearance ?? (status === "success" || status === "warning" || status === "info" ? "soft" : "outline");
|
|
157
|
+
return /* @__PURE__ */ jsx(AlertContext.Provider, {
|
|
158
|
+
value: context,
|
|
159
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
160
|
+
ref: mergeRefs(node, ref),
|
|
161
|
+
"data-slot": "alert",
|
|
162
|
+
"data-size": size ?? "default",
|
|
163
|
+
"data-ending-style": shown ? void 0 : "",
|
|
164
|
+
role: destructive || status === "warning" ? "alert" : "status",
|
|
165
|
+
className: cn(alertVariants({
|
|
166
|
+
variant,
|
|
167
|
+
appearance: look,
|
|
168
|
+
size
|
|
169
|
+
}), "rtl:text-right rtl:has-data-[slot=alert-action]:pr-2.5 rtl:has-data-[slot=alert-action]:pl-18 rtl:*:data-[slot=alert-action]:right-auto rtl:*:data-[slot=alert-action]:left-2", "has-data-[slot=alert-close]:*:data-[slot=alert-action]:right-10 rtl:has-data-[slot=alert-close]:*:data-[slot=alert-action]:left-10", className),
|
|
170
|
+
...props
|
|
171
|
+
})
|
|
35
172
|
});
|
|
36
173
|
}
|
|
37
174
|
function AlertTitle({ className, ...props }) {
|
|
@@ -55,4 +192,48 @@ function AlertAction({ className, ...props }) {
|
|
|
55
192
|
...props
|
|
56
193
|
});
|
|
57
194
|
}
|
|
58
|
-
|
|
195
|
+
/** Nsaa (#148): dismisses the Alert. A ghost icon Button named "Dismiss", at the inline end. */
|
|
196
|
+
function AlertClose({ className, children, onClick, ...props }) {
|
|
197
|
+
const alert = React.useContext(AlertContext);
|
|
198
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
199
|
+
"data-slot": "alert-close",
|
|
200
|
+
variant: "ghost",
|
|
201
|
+
size: "icon-xs",
|
|
202
|
+
"aria-label": "Dismiss",
|
|
203
|
+
className: cn("absolute top-2 right-2 text-current rtl:right-auto rtl:left-2 group-data-[size=sm]/alert:top-1 group-data-[size=sm]/alert:right-1 rtl:group-data-[size=sm]/alert:right-auto rtl:group-data-[size=sm]/alert:left-1", className),
|
|
204
|
+
onClick: (event) => {
|
|
205
|
+
onClick?.(event);
|
|
206
|
+
if (!event.defaultPrevented) alert?.close();
|
|
207
|
+
},
|
|
208
|
+
...props,
|
|
209
|
+
children: children ?? /* @__PURE__ */ jsxs("svg", {
|
|
210
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
211
|
+
viewBox: "0 0 24 24",
|
|
212
|
+
fill: "none",
|
|
213
|
+
stroke: "currentColor",
|
|
214
|
+
strokeWidth: "2",
|
|
215
|
+
strokeLinecap: "round",
|
|
216
|
+
strokeLinejoin: "round",
|
|
217
|
+
"aria-hidden": "true",
|
|
218
|
+
children: [/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }), /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })]
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/** Nsaa (#148): a row of `AlertLink`s under the description. The ∙ between them is CSS, never read. */
|
|
223
|
+
function AlertLinks({ className, ...props }) {
|
|
224
|
+
return /* @__PURE__ */ jsx("div", {
|
|
225
|
+
"data-slot": "alert-links",
|
|
226
|
+
className: cn("mt-1 flex flex-wrap items-center gap-x-4 gap-y-1 group-has-[>svg]/alert:col-start-2", className),
|
|
227
|
+
...props
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/** Nsaa (#148): a real link in the Alert's own text colour, medium weight, underlined. */
|
|
231
|
+
function AlertLink({ className, render, ...props }) {
|
|
232
|
+
return useRender({
|
|
233
|
+
defaultTagName: "a",
|
|
234
|
+
props: mergeProps({ className: cn("relative font-medium text-current underline underline-offset-3 hover:decoration-2", "not-first:before:pointer-events-none not-first:before:absolute not-first:before:-start-2.5 not-first:before:no-underline not-first:before:content-['∙'_/_'']", className) }, props),
|
|
235
|
+
render,
|
|
236
|
+
state: { slot: "alert-link" }
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
export { Alert, AlertAction, AlertClose, AlertDescription, AlertLink, AlertLinks, AlertTitle };
|
package/dist/alert/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import { Alert, AlertAction, AlertDescription, AlertTitle } from "./alert.js";
|
|
3
|
-
export { Alert, AlertAction, AlertDescription, AlertTitle };
|
|
2
|
+
import { Alert, AlertAction, AlertClose, AlertDescription, AlertLink, AlertLinks, AlertTitle } from "./alert.js";
|
|
3
|
+
export { Alert, AlertAction, AlertClose, AlertDescription, AlertLink, AlertLinks, AlertTitle };
|
package/dist/badge/badge.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
2
|
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
declare const badgeVariants: (props?: ({
|
|
5
|
-
variant?: "default" | "destructive" | "link" | "
|
|
5
|
+
variant?: "default" | "destructive" | "link" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
8
8
|
export { Badge, badgeVariants };
|
package/dist/badge/badge.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
-
import { cva } from "class-variance-authority";
|
|
4
3
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
4
|
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
6
|
// src/badge/badge.tsx
|
|
7
7
|
const badgeVariants = cva("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", {
|
|
8
8
|
variants: { variant: {
|
package/dist/button/button.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { VariantProps } from "class-variance-authority";
|
|
3
3
|
import { Button } from "@base-ui/react/button";
|
|
4
4
|
declare const buttonVariants: (props?: ({
|
|
5
|
-
variant?: "default" | "destructive" | "link" | "
|
|
6
|
-
size?: "default" | "
|
|
5
|
+
variant?: "default" | "destructive" | "link" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
6
|
+
size?: "default" | "sm" | "xs" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
type LoadingPlacement = "auto" | "start" | "center";
|
|
9
9
|
declare function Button$1({ className, variant, size, loading, loadingLabel, loadingPlacement, children, onClick, onPointerDown, onPointerUp, onPointerLeave, onPointerCancel, ...props }: Button.Props & VariantProps<typeof buttonVariants> & {
|
package/dist/button/button.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
-
import { useCue } from "../sound/sound-map.js";
|
|
4
3
|
import { useControlDefaults } from "../lib/control-defaults.js";
|
|
5
4
|
import { usePress } from "../lib/use-press.js";
|
|
5
|
+
import { useCue } from "../sound/sound-map.js";
|
|
6
6
|
import { Spinner } from "../spinner/spinner.js";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { cva } from "class-variance-authority";
|
|
@@ -95,6 +95,7 @@ function Button$1({ className, variant = "default", size = "default", loading =
|
|
|
95
95
|
const placement = loading ? resolvePlacement(loadingPlacement, children, size ?? "default") : null;
|
|
96
96
|
return /* @__PURE__ */ jsx(Button, {
|
|
97
97
|
"data-slot": "button",
|
|
98
|
+
"data-variant": variant ?? "default",
|
|
98
99
|
className: cn(buttonVariants({
|
|
99
100
|
variant,
|
|
100
101
|
size
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
import { DateRangePreset, DateRangeValue, WeekDay } from "./presets.js";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Locale, Matcher } from "react-day-picker";
|
|
5
|
+
export type DateRangePickerLabels = {
|
|
6
|
+
/** Trigger text when there is no range. */
|
|
7
|
+
placeholder: string;
|
|
8
|
+
/** The presetsOnly option that opens the calendar. */
|
|
9
|
+
custom: string;
|
|
10
|
+
/** The presets listbox's name. */
|
|
11
|
+
presets: string;
|
|
12
|
+
/** The panel's name (Popover) and the Drawer's title. */
|
|
13
|
+
title: string;
|
|
14
|
+
};
|
|
15
|
+
export type DateRangePickerProps = Omit<React.ComponentProps<"div">, "defaultValue" | "onChange" | "children"> & {
|
|
16
|
+
/** The selected range (controlled), or null for none. */
|
|
17
|
+
value?: DateRangeValue | null | undefined;
|
|
18
|
+
/** The range it starts with when uncontrolled. */
|
|
19
|
+
defaultValue?: DateRangeValue | null | undefined;
|
|
20
|
+
/** `preset` is the id of the picked preset, or of the preset a custom range matches; else null. */
|
|
21
|
+
onValueChange?: ((range: DateRangeValue, details: {
|
|
22
|
+
preset: string | null;
|
|
23
|
+
}) => void) | undefined;
|
|
24
|
+
/** Default: every built-in preset, in the order of `presets`. Pass `[]` for none. */
|
|
25
|
+
presets?: readonly DateRangePreset[] | undefined;
|
|
26
|
+
/** Presets in a Select-like menu; "Custom…" opens the calendar. */
|
|
27
|
+
presetsOnly?: boolean | undefined;
|
|
28
|
+
/** Default: the locale's first day (`Intl.Locale` week info), else Monday. */
|
|
29
|
+
weekStartsOn?: WeekDay | undefined;
|
|
30
|
+
/** IANA zone that decides what "today" is. Default: the device zone. */
|
|
31
|
+
timeZone?: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* A BCP 47 tag (formats the trigger and the announcement, sets the week start) or a date-fns locale
|
|
34
|
+
* (`import { fr } from "date-fns/locale"`), which also translates the calendar's month and day
|
|
35
|
+
* names. Default: `<html lang>`, else the runtime's; the calendar's names stay English unless a
|
|
36
|
+
* date-fns locale is passed.
|
|
37
|
+
*/
|
|
38
|
+
locale?: string | Partial<Locale> | undefined;
|
|
39
|
+
/** The current instant. Default: now. Pin it for tests and stable screenshots. */
|
|
40
|
+
now?: Date | undefined;
|
|
41
|
+
/** The earliest day that can be picked; presets ending before it are disabled. */
|
|
42
|
+
min?: Date | undefined;
|
|
43
|
+
/** The latest day that can be picked; presets starting after it are disabled. */
|
|
44
|
+
max?: Date | undefined;
|
|
45
|
+
/** Days that cannot be picked (react-day-picker matchers). */
|
|
46
|
+
disabled?: Matcher | Matcher[] | undefined;
|
|
47
|
+
/** Default: 2 on containers at least 600 px wide, else 1. 2 also puts presets in a side list. */
|
|
48
|
+
numberOfMonths?: 1 | 2 | undefined;
|
|
49
|
+
/** The trigger Button's size. */
|
|
50
|
+
size?: "default" | "sm" | undefined;
|
|
51
|
+
/** Overrides for the visible and spoken strings: placeholder, custom, preset labels and the panel title. */
|
|
52
|
+
labels?: Partial<DateRangePickerLabels> | undefined;
|
|
53
|
+
};
|
|
54
|
+
declare function DateRangePicker({ value: valueProp, defaultValue, onValueChange, presets: presetList, presetsOnly, weekStartsOn: weekStartsOnProp, timeZone, locale: localeProp, now, min, max, disabled, numberOfMonths: monthsProp, size, labels: labelsProp, id, "aria-label": ariaLabel, className, ...props }: DateRangePickerProps): React.JSX.Element;
|
|
55
|
+
export { DateRangePicker };
|