@epilot/spark-ui 0.11.0 → 0.12.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/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/avatar.d.cts +1 -1
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/bar-chart.cjs +2 -1
- package/dist/components/bar-chart.cjs.map +1 -1
- package/dist/components/bar-chart.js +2 -1
- package/dist/components/bar-chart.js.map +1 -1
- package/dist/components/box.cjs +3 -2
- package/dist/components/box.cjs.map +1 -1
- package/dist/components/box.d.cts +8 -1
- package/dist/components/box.d.ts +8 -1
- package/dist/components/box.js +3 -2
- package/dist/components/box.js.map +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button-group.d.cts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button.d.cts +3 -3
- package/dist/components/button.d.ts +3 -3
- package/dist/components/calendar.cjs +2 -2
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.js +2 -2
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +1 -1
- package/dist/components/callout.cjs.map +1 -1
- package/dist/components/callout.d.cts +3 -3
- package/dist/components/callout.d.ts +3 -3
- package/dist/components/callout.js +1 -1
- package/dist/components/callout.js.map +1 -1
- package/dist/components/card.cjs +3 -2
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +7 -1
- package/dist/components/card.d.ts +7 -1
- package/dist/components/card.js +3 -2
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/field.d.cts +1 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/icon.cjs +1 -1
- package/dist/components/icon.cjs.map +1 -1
- package/dist/components/icon.js +1 -1
- package/dist/components/icon.js.map +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/input-group.cjs +1 -1
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/layout.cjs +6 -2
- package/dist/components/layout.cjs.map +1 -1
- package/dist/components/layout.d.cts +9 -2
- package/dist/components/layout.d.ts +8 -2
- package/dist/components/layout.js +6 -2
- package/dist/components/layout.js.map +1 -1
- package/dist/components/list.cjs +46 -14
- package/dist/components/list.cjs.map +1 -1
- package/dist/components/list.d.cts +27 -3
- package/dist/components/list.d.ts +27 -3
- package/dist/components/list.js +46 -14
- package/dist/components/list.js.map +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/pill.cjs +19 -12
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/pill.js +19 -12
- package/dist/components/pill.js.map +1 -1
- package/dist/components/popover.cjs +16 -13
- package/dist/components/popover.cjs.map +1 -1
- package/dist/components/popover.d.cts +2 -1
- package/dist/components/popover.d.ts +2 -1
- package/dist/components/popover.js +16 -13
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress.cjs +1 -1
- package/dist/components/progress.cjs.map +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-card-group.cjs +6 -2
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.d.cts +2 -0
- package/dist/components/radio-card-group.d.ts +2 -0
- package/dist/components/radio-card-group.js +6 -2
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/radio.cjs +6 -2
- package/dist/components/radio.cjs.map +1 -1
- package/dist/components/radio.d.cts +7 -3
- package/dist/components/radio.d.ts +7 -3
- package/dist/components/radio.js +6 -2
- package/dist/components/radio.js.map +1 -1
- package/dist/components/schedule-list.cjs +10 -7
- package/dist/components/schedule-list.cjs.map +1 -1
- package/dist/components/schedule-list.js +10 -7
- package/dist/components/schedule-list.js.map +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +21 -18
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +3 -2
- package/dist/components/select.d.ts +3 -2
- package/dist/components/select.js +21 -18
- package/dist/components/select.js.map +1 -1
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/tabs.cjs +4 -3
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.d.cts +9 -0
- package/dist/components/tabs.d.ts +9 -0
- package/dist/components/tabs.js +4 -3
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/theme.cjs +18 -6
- package/dist/components/theme.cjs.map +1 -1
- package/dist/components/theme.d.cts +16 -2
- package/dist/components/theme.d.ts +16 -2
- package/dist/components/theme.js +19 -7
- package/dist/components/theme.js.map +1 -1
- package/dist/{generate-radix-colors-Bw-RYaV4.d.ts → generate-radix-colors-BY4Wjsm7.d.cts} +4 -2
- package/dist/{generate-radix-colors-Bw-RYaV4.d.cts → generate-radix-colors-BY4Wjsm7.d.ts} +4 -2
- package/dist/icons/material-symbol.cjs +1 -1
- package/dist/icons/material-symbol.cjs.map +1 -1
- package/dist/icons/material-symbol.js +1 -1
- package/dist/icons/material-symbol.js.map +1 -1
- package/dist/lib/accent-theme.cjs +367 -16
- package/dist/lib/accent-theme.cjs.map +1 -1
- package/dist/lib/accent-theme.d.cts +75 -6
- package/dist/lib/accent-theme.d.ts +75 -6
- package/dist/lib/accent-theme.js +365 -18
- package/dist/lib/accent-theme.js.map +1 -1
- package/dist/lib/container-chrome.cjs +9 -7
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +4 -3
- package/dist/lib/container-chrome.d.ts +4 -3
- package/dist/lib/container-chrome.js +9 -8
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/generate-radix-colors.cjs +7 -0
- package/dist/lib/generate-radix-colors.cjs.map +1 -1
- package/dist/lib/generate-radix-colors.d.cts +2 -2
- package/dist/lib/generate-radix-colors.d.ts +2 -2
- package/dist/lib/generate-radix-colors.js +6 -1
- package/dist/lib/generate-radix-colors.js.map +1 -1
- package/dist/lib/input-box-variants.d.cts +1 -1
- package/dist/lib/input-box-variants.d.ts +1 -1
- package/dist/lib/theme-types.cjs +19 -0
- package/dist/lib/theme-types.cjs.map +1 -0
- package/dist/lib/theme-types.d.cts +2 -2
- package/dist/lib/theme-types.d.ts +2 -2
- package/dist/lib/theme-types.js +17 -1
- package/dist/lib/theme-types.js.map +1 -0
- package/dist/styles/material-symbol.css +3 -0
- package/dist/styles/spark-default.css +148 -0
- package/dist/styles/utilities.css +9 -8
- package/dist/{theme-types-1yB0d8mp.d.ts → theme-types-Bn5E15-P.d.cts} +12 -3
- package/dist/{theme-types-1yB0d8mp.d.cts → theme-types-Bn5E15-P.d.ts} +12 -3
- package/package.json +113 -55
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { n as SparkCardColor, r as SparkCardVariant } from "../theme-types-Bn5E15-P.cjs";
|
|
4
|
+
import { ContainerRadius } from "../lib/container-chrome.cjs";
|
|
3
5
|
import * as React$1 from "react";
|
|
4
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
5
7
|
|
|
6
8
|
//#region src/components/list.d.ts
|
|
7
|
-
type ListVariant =
|
|
9
|
+
type ListVariant = SparkCardVariant;
|
|
10
|
+
type ListRadius = ContainerRadius;
|
|
8
11
|
interface ListProps extends React$1.ComponentProps<'ul'> {
|
|
9
12
|
/** A prop, not the ambient `data-style` knob — that would cascade into row content. */
|
|
10
13
|
variant?: ListVariant;
|
|
14
|
+
/** Chrome palette. `neutral` (default) tracks the app neutral; `accent` tints with the brand accent. */
|
|
15
|
+
color?: SparkCardColor;
|
|
16
|
+
/** Corner radius, as a named step. Unset → `md`, today's fixed behaviour. */
|
|
17
|
+
radius?: ListRadius;
|
|
18
|
+
/** How many `--spark-layout-gap` units apart each row sits (`soft`/`solid`/`ghost` only). */
|
|
19
|
+
gap?: number;
|
|
11
20
|
}
|
|
12
21
|
declare function List({
|
|
13
22
|
className,
|
|
14
23
|
variant,
|
|
24
|
+
color,
|
|
25
|
+
radius,
|
|
26
|
+
gap,
|
|
27
|
+
style,
|
|
15
28
|
...props
|
|
16
29
|
}: ListProps): import("react/jsx-runtime").JSX.Element;
|
|
17
30
|
interface ListItemProps extends React$1.ComponentProps<'li'> {
|
|
@@ -36,10 +49,21 @@ declare function ListItem({
|
|
|
36
49
|
render,
|
|
37
50
|
...props
|
|
38
51
|
}: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
interface ListItemLeadingProps extends React$1.ComponentProps<'div'> {
|
|
53
|
+
/**
|
|
54
|
+
* Set when this slot holds a focusable control (Checkbox, Radio, Button). ListItem
|
|
55
|
+
* then hoists it outside `render`'s element — nesting a real control inside the row's
|
|
56
|
+
* own <a>/<button> is invalid HTML and double-fires clicks. Leave unset for decorative
|
|
57
|
+
* content (an icon): it stays inside the row, so the whole visual row is one
|
|
58
|
+
* click/tap target, same as a row with no leading slot at all.
|
|
59
|
+
*/
|
|
60
|
+
interactive?: boolean;
|
|
61
|
+
}
|
|
39
62
|
declare function ListItemLeading({
|
|
40
63
|
className,
|
|
64
|
+
interactive: _interactive,
|
|
41
65
|
...props
|
|
42
|
-
}:
|
|
66
|
+
}: ListItemLeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
43
67
|
interface ListItemContentProps extends React$1.ComponentProps<'div'> {
|
|
44
68
|
/** `end` right-aligns the column (the value column). */
|
|
45
69
|
align?: 'start' | 'end';
|
|
@@ -67,5 +91,5 @@ declare function ListItemTrailing({
|
|
|
67
91
|
...props
|
|
68
92
|
}: React$1.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
69
93
|
//#endregion
|
|
70
|
-
export { List, ListItem, ListItemContent, type ListItemContentProps, ListItemLeading, ListItemPreline, type ListItemProps, ListItemSubline, ListItemTitle, ListItemTrailing, type ListProps, type ListVariant };
|
|
94
|
+
export { List, ListItem, ListItemContent, type ListItemContentProps, ListItemLeading, type ListItemLeadingProps, ListItemPreline, type ListItemProps, ListItemSubline, ListItemTitle, ListItemTrailing, type ListProps, type ListRadius, type ListVariant };
|
|
71
95
|
//# sourceMappingURL=list.d.cts.map
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { n as SparkCardColor, r as SparkCardVariant } from "../theme-types-Bn5E15-P.js";
|
|
4
|
+
import { ContainerRadius } from "../lib/container-chrome.js";
|
|
3
5
|
import * as React$1 from "react";
|
|
4
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
5
7
|
|
|
6
8
|
//#region src/components/list.d.ts
|
|
7
|
-
type ListVariant =
|
|
9
|
+
type ListVariant = SparkCardVariant;
|
|
10
|
+
type ListRadius = ContainerRadius;
|
|
8
11
|
interface ListProps extends React$1.ComponentProps<'ul'> {
|
|
9
12
|
/** A prop, not the ambient `data-style` knob — that would cascade into row content. */
|
|
10
13
|
variant?: ListVariant;
|
|
14
|
+
/** Chrome palette. `neutral` (default) tracks the app neutral; `accent` tints with the brand accent. */
|
|
15
|
+
color?: SparkCardColor;
|
|
16
|
+
/** Corner radius, as a named step. Unset → `md`, today's fixed behaviour. */
|
|
17
|
+
radius?: ListRadius;
|
|
18
|
+
/** How many `--spark-layout-gap` units apart each row sits (`soft`/`solid`/`ghost` only). */
|
|
19
|
+
gap?: number;
|
|
11
20
|
}
|
|
12
21
|
declare function List({
|
|
13
22
|
className,
|
|
14
23
|
variant,
|
|
24
|
+
color,
|
|
25
|
+
radius,
|
|
26
|
+
gap,
|
|
27
|
+
style,
|
|
15
28
|
...props
|
|
16
29
|
}: ListProps): import("react/jsx-runtime").JSX.Element;
|
|
17
30
|
interface ListItemProps extends React$1.ComponentProps<'li'> {
|
|
@@ -36,10 +49,21 @@ declare function ListItem({
|
|
|
36
49
|
render,
|
|
37
50
|
...props
|
|
38
51
|
}: ListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
interface ListItemLeadingProps extends React$1.ComponentProps<'div'> {
|
|
53
|
+
/**
|
|
54
|
+
* Set when this slot holds a focusable control (Checkbox, Radio, Button). ListItem
|
|
55
|
+
* then hoists it outside `render`'s element — nesting a real control inside the row's
|
|
56
|
+
* own <a>/<button> is invalid HTML and double-fires clicks. Leave unset for decorative
|
|
57
|
+
* content (an icon): it stays inside the row, so the whole visual row is one
|
|
58
|
+
* click/tap target, same as a row with no leading slot at all.
|
|
59
|
+
*/
|
|
60
|
+
interactive?: boolean;
|
|
61
|
+
}
|
|
39
62
|
declare function ListItemLeading({
|
|
40
63
|
className,
|
|
64
|
+
interactive: _interactive,
|
|
41
65
|
...props
|
|
42
|
-
}:
|
|
66
|
+
}: ListItemLeadingProps): import("react/jsx-runtime").JSX.Element;
|
|
43
67
|
interface ListItemContentProps extends React$1.ComponentProps<'div'> {
|
|
44
68
|
/** `end` right-aligns the column (the value column). */
|
|
45
69
|
align?: 'start' | 'end';
|
|
@@ -67,5 +91,5 @@ declare function ListItemTrailing({
|
|
|
67
91
|
...props
|
|
68
92
|
}: React$1.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
69
93
|
//#endregion
|
|
70
|
-
export { List, ListItem, ListItemContent, type ListItemContentProps, ListItemLeading, ListItemPreline, type ListItemProps, ListItemSubline, ListItemTitle, ListItemTrailing, type ListProps, type ListVariant };
|
|
94
|
+
export { List, ListItem, ListItemContent, type ListItemContentProps, ListItemLeading, type ListItemLeadingProps, ListItemPreline, type ListItemProps, ListItemSubline, ListItemTitle, ListItemTrailing, type ListProps, type ListRadius, type ListVariant };
|
|
71
95
|
//# sourceMappingURL=list.d.ts.map
|
package/dist/components/list.js
CHANGED
|
@@ -5,42 +5,74 @@ import * as React$1 from "react";
|
|
|
5
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
7
7
|
//#region src/components/list.tsx
|
|
8
|
+
const radiusRowClasses = {
|
|
9
|
+
none: "group-data-[radius=none]/list:first:rounded-t-none group-data-[radius=none]/list:last:rounded-b-none",
|
|
10
|
+
sm: "group-data-[radius=sm]/list:first:rounded-t-sm group-data-[radius=sm]/list:last:rounded-b-sm",
|
|
11
|
+
md: "group-data-[radius=md]/list:first:rounded-t-md group-data-[radius=md]/list:last:rounded-b-md",
|
|
12
|
+
lg: "group-data-[radius=lg]/list:first:rounded-t-lg group-data-[radius=lg]/list:last:rounded-b-lg",
|
|
13
|
+
xl: "group-data-[radius=xl]/list:first:rounded-t-xl group-data-[radius=xl]/list:last:rounded-b-xl",
|
|
14
|
+
"2xl": "group-data-[radius=2xl]/list:first:rounded-t-2xl group-data-[radius=2xl]/list:last:rounded-b-2xl",
|
|
15
|
+
"3xl": "group-data-[radius=3xl]/list:first:rounded-t-3xl group-data-[radius=3xl]/list:last:rounded-b-3xl",
|
|
16
|
+
full: "group-data-[radius=full]/list:first:rounded-t-full group-data-[radius=full]/list:last:rounded-b-full"
|
|
17
|
+
};
|
|
8
18
|
const ListItemContext = React$1.createContext({ recent: false });
|
|
9
19
|
const ListItemColumnContext = React$1.createContext({ isEnd: false });
|
|
10
|
-
function List({ className, variant = "soft", ...props }) {
|
|
20
|
+
function List({ className, variant = "soft", color = "neutral", radius = "md", gap = .5, style, ...props }) {
|
|
11
21
|
return /* @__PURE__ */ jsx("ul", {
|
|
12
22
|
role: "list",
|
|
13
23
|
"data-slot": "list",
|
|
14
24
|
"data-variant": variant,
|
|
15
|
-
|
|
25
|
+
"data-look": color === "accent" ? `${variant}-accent` : variant,
|
|
26
|
+
"data-radius": radius,
|
|
27
|
+
className: cn("group/list m-0 list-none p-0", "data-[variant=soft]:flex data-[variant=soft]:flex-col data-[variant=soft]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]", "data-[variant=solid]:flex data-[variant=solid]:flex-col data-[variant=solid]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]", "data-[variant=ghost]:flex data-[variant=ghost]:flex-col data-[variant=ghost]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]", className),
|
|
28
|
+
style: {
|
|
29
|
+
"--list-gap-steps": gap,
|
|
30
|
+
...variant === "solid" && {
|
|
31
|
+
"--list-item-fg": color === "accent" ? "var(--spark-contrast)" : "var(--neutral-contrast)",
|
|
32
|
+
"--list-item-fg-muted": color === "accent" ? "var(--spark-contrast)" : "var(--neutral-contrast)"
|
|
33
|
+
},
|
|
34
|
+
...style
|
|
35
|
+
},
|
|
16
36
|
...props
|
|
17
37
|
});
|
|
18
38
|
}
|
|
19
39
|
function ListItem({ className, children, recent, selected, skeleton, render, ...props }) {
|
|
20
40
|
const interactive = !skeleton && render != null;
|
|
21
41
|
const recentCtx = React$1.useMemo(() => ({ recent: recent ?? false }), [recent]);
|
|
42
|
+
const rendersAnchorOrButton = React$1.isValidElement(render) && (render.type === "a" || render.type === "button");
|
|
43
|
+
const childArray = skeleton ? void 0 : React$1.Children.toArray(children);
|
|
44
|
+
const leadingChild = childArray?.find((child) => React$1.isValidElement(child) && child.type === ListItemLeading);
|
|
45
|
+
const hoistLeading = rendersAnchorOrButton && Boolean(leadingChild?.props.interactive);
|
|
46
|
+
const leading = hoistLeading ? leadingChild : void 0;
|
|
22
47
|
const row = useRender({
|
|
23
48
|
defaultTagName: "div",
|
|
24
49
|
render: skeleton ? void 0 : render,
|
|
25
50
|
props: {
|
|
26
51
|
"data-slot": "list-item-row",
|
|
27
52
|
"aria-hidden": skeleton ? true : void 0,
|
|
28
|
-
className: cn("flex min-h-[2.75rem]
|
|
53
|
+
className: cn("flex min-h-[2.75rem] items-center gap-4 py-3 text-left no-underline", hoistLeading ? "min-w-0 flex-1 pr-4" : "w-full rounded-[inherit] px-4", !hoistLeading && !skeleton && selected && "bg-spark-a3", interactive && [
|
|
29
54
|
"group/row cursor-pointer transition-colors duration-150 motion-reduce:transition-none",
|
|
30
|
-
"
|
|
31
|
-
"focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"
|
|
32
|
-
"disabled:pointer-events-none disabled:opacity-50"
|
|
55
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
56
|
+
hoistLeading ? "focus-visible:outline-hidden" : ["hover:bg-spark-a3 focus-visible:bg-spark-a3", "focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden"]
|
|
33
57
|
]),
|
|
34
|
-
children: skeleton ? /* @__PURE__ */ jsx(ListItemSkeleton, {}) : children
|
|
58
|
+
children: skeleton ? /* @__PURE__ */ jsx(ListItemSkeleton, {}) : hoistLeading ? childArray?.filter((child) => child !== leadingChild) : children
|
|
35
59
|
}
|
|
36
60
|
});
|
|
37
61
|
return /* @__PURE__ */ jsx("li", {
|
|
38
62
|
"data-slot": "list-item",
|
|
39
|
-
className: cn("relative has-focus-visible:z-10",
|
|
63
|
+
className: cn("relative has-focus-visible:z-10", hoistLeading && [
|
|
64
|
+
"flex min-w-0 items-center gap-4 pl-4",
|
|
65
|
+
!skeleton && selected && "bg-spark-a3",
|
|
66
|
+
interactive && [
|
|
67
|
+
"cursor-pointer",
|
|
68
|
+
"hover:bg-spark-a3 has-focus-visible:bg-spark-a3",
|
|
69
|
+
"has-focus-visible:ring-2 has-focus-visible:ring-offset-2"
|
|
70
|
+
]
|
|
71
|
+
], "group-data-[variant=surface]/list:border-x group-data-[variant=surface]/list:border-t group-data-[variant=surface]/list:last:border-b", "group-data-[variant=outline]/list:border-x group-data-[variant=outline]/list:border-t group-data-[variant=outline]/list:last:border-b", "group-data-[look=soft]/list:bg-gray-a2 dark:group-data-[look=soft]/list:bg-gray-a3", "group-data-[look=soft-accent]/list:bg-(--spark-a3)", "group-data-[look=surface]/list:border-gray-a6 group-data-[look=surface]/list:bg-gray-2", "group-data-[look=surface-accent]/list:border-spark-a6 group-data-[look=surface-accent]/list:bg-(--spark-surface)", "group-data-[look=outline]/list:border-gray-a6", "group-data-[look=outline-accent]/list:border-spark-a6", "group-data-[look=solid]/list:bg-(--neutral-1)", "group-data-[look=solid-accent]/list:bg-spark-9", Object.values(radiusRowClasses), className),
|
|
40
72
|
...props,
|
|
41
|
-
children: /* @__PURE__ */
|
|
73
|
+
children: /* @__PURE__ */ jsxs(ListItemContext.Provider, {
|
|
42
74
|
value: recentCtx,
|
|
43
|
-
children: row
|
|
75
|
+
children: [leading, row]
|
|
44
76
|
})
|
|
45
77
|
});
|
|
46
78
|
}
|
|
@@ -57,7 +89,7 @@ function ListItemSkeleton() {
|
|
|
57
89
|
})
|
|
58
90
|
] });
|
|
59
91
|
}
|
|
60
|
-
function ListItemLeading({ className, ...props }) {
|
|
92
|
+
function ListItemLeading({ className, interactive: _interactive, ...props }) {
|
|
61
93
|
return /* @__PURE__ */ jsx("div", {
|
|
62
94
|
"data-slot": "list-item-leading",
|
|
63
95
|
className: cn("flex shrink-0 items-center", className),
|
|
@@ -78,7 +110,7 @@ function ListItemContent({ className, align = "start", ...props }) {
|
|
|
78
110
|
function ListItemPreline({ className, ...props }) {
|
|
79
111
|
return /* @__PURE__ */ jsx("span", {
|
|
80
112
|
"data-slot": "list-item-preline",
|
|
81
|
-
className: cn("block w-full truncate text-sm text-
|
|
113
|
+
className: cn("block w-full truncate text-sm text-(--list-item-fg-muted,var(--neutral-11))", className),
|
|
82
114
|
...props
|
|
83
115
|
});
|
|
84
116
|
}
|
|
@@ -88,7 +120,7 @@ function ListItemTitle({ className, children, ...props }) {
|
|
|
88
120
|
const showDot = recent && !isEnd;
|
|
89
121
|
const title = /* @__PURE__ */ jsx("span", {
|
|
90
122
|
"data-slot": "list-item-title",
|
|
91
|
-
className: cn(showDot ? "min-w-0 truncate" : "block w-full truncate", "text-base font-bold text-
|
|
123
|
+
className: cn(showDot ? "min-w-0 truncate" : "block w-full truncate", "text-base font-bold text-(--list-item-fg,var(--neutral-12))", className),
|
|
92
124
|
...props,
|
|
93
125
|
children
|
|
94
126
|
});
|
|
@@ -105,7 +137,7 @@ function ListItemTitle({ className, children, ...props }) {
|
|
|
105
137
|
function ListItemSubline({ className, ...props }) {
|
|
106
138
|
return /* @__PURE__ */ jsx("span", {
|
|
107
139
|
"data-slot": "list-item-subline",
|
|
108
|
-
className: cn("block w-full truncate text-sm text-
|
|
140
|
+
className: cn("block w-full truncate text-sm text-(--list-item-fg-muted,var(--neutral-11))", className),
|
|
109
141
|
...props
|
|
110
142
|
});
|
|
111
143
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","names":["React"],"sources":["../../src/components/list.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { Skeleton } from './skeleton'\n\ntype ListVariant = 'soft' | 'surface' | 'outline' | 'ghost'\n\n// ListItem publishes `recent` so ListItemTitle can render the inline recency dot; the\n// column context lets the title show it only on the primary (start) column, never the\n// value column of a two-column row.\nconst ListItemContext = React.createContext<{ recent: boolean }>({\n recent: false,\n})\nconst ListItemColumnContext = React.createContext<{ isEnd: boolean }>({\n isEnd: false,\n})\n\ninterface ListProps extends React.ComponentProps<'ul'> {\n /** A prop, not the ambient `data-style` knob — that would cascade into row content. */\n variant?: ListVariant\n}\n\nfunction List({ className, variant = 'soft', ...props }: ListProps) {\n return (\n <ul\n // role=list keeps list semantics even under list-style:none (Safari drops them).\n role=\"list\"\n data-slot=\"list\"\n // group/list + data-variant drive every item's per-variant chrome (below).\n data-variant={variant}\n className={cn(\n 'group/list m-0 list-none p-0',\n // soft = separate cards → stack with a small gap (the gap IS the divider). ghost\n // shares that same gap for spacing but no fill/border (see ListItem's chrome\n // block, which has no ghost selector). surface/outline glue rows into one panel.\n 'data-[variant=soft]:flex data-[variant=soft]:flex-col data-[variant=soft]:gap-[calc(var(--spark-layout-gap)*0.5)]',\n 'data-[variant=ghost]:flex data-[variant=ghost]:flex-col data-[variant=ghost]:gap-[calc(var(--spark-layout-gap)*0.5)]',\n className,\n )}\n {...props}\n />\n )\n}\n\ninterface ListItemProps extends React.ComponentProps<'li'> {\n /** The \"recently changed\" accent dot. */\n recent?: boolean\n /** Persistent accent-tint (e.g. the active document). */\n selected?: boolean\n /** Loading placeholder (Figma `skeleton=true`). */\n skeleton?: boolean\n /**\n * Base UI polymorphism for the inner row. Pass `<a href/>` or `<button/>` to make\n * the row interactive (accent-on-hover/focus, cursor, focus ring). Omit → static row.\n */\n render?: useRender.RenderProp\n}\n\nfunction ListItem({\n className,\n children,\n recent,\n selected,\n skeleton,\n render,\n ...props\n}: ListItemProps) {\n // Skeleton rows are decorative placeholders — never render as a real <a>/<button>. An\n // aria-hidden anchor would still be focusable (WCAG 4.1.2), so skeleton forces a plain,\n // non-interactive <div> regardless of `render`.\n const interactive = !skeleton && render != null\n\n const recentCtx = React.useMemo(() => ({ recent: recent ?? false }), [recent])\n\n const row = useRender({\n defaultTagName: 'div',\n render: skeleton ? undefined : render,\n props: {\n 'data-slot': 'list-item-row',\n // skeleton is a decorative placeholder → keep it out of the a11y tree.\n 'aria-hidden': skeleton ? true : undefined,\n className: cn(\n // row layout from Figma 2217-1667; min-h is a HARD 44px floor (WCAG 2.5.5),\n // py/gap/text still scale past it via the spacing/scaling knobs. no-underline\n // resets the default <a> decoration when the row renders as a link.\n 'flex min-h-[2.75rem] w-full items-center gap-4 rounded-[inherit] px-4 py-3 text-left no-underline',\n !skeleton && selected && 'bg-spark-a3',\n interactive && [\n 'group/row cursor-pointer transition-colors duration-150 motion-reduce:transition-none',\n // neutral at rest → subtle accent tint on hover/focus (the affordance goes\n // accent too, in ListItemTrailing; title + leading stay neutral).\n 'hover:bg-spark-a3 focus-visible:bg-spark-a3',\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n 'disabled:pointer-events-none disabled:opacity-50',\n ],\n ),\n children: skeleton ? <ListItemSkeleton /> : children,\n },\n })\n\n return (\n <li\n data-slot=\"list-item\"\n className={cn(\n 'relative has-focus-visible:z-10',\n 'group-data-[variant=soft]/list:rounded-md group-data-[variant=soft]/list:bg-gray-a2 dark:group-data-[variant=soft]/list:bg-gray-a3',\n 'group-data-[variant=surface]/list:bg-gray-2',\n 'group-data-[variant=surface]/list:border-x group-data-[variant=surface]/list:border-t group-data-[variant=surface]/list:border-gray-a6 group-data-[variant=surface]/list:first:rounded-t-md group-data-[variant=surface]/list:last:rounded-b-md group-data-[variant=surface]/list:last:border-b',\n 'group-data-[variant=outline]/list:border-x group-data-[variant=outline]/list:border-t group-data-[variant=outline]/list:border-gray-a6 group-data-[variant=outline]/list:first:rounded-t-md group-data-[variant=outline]/list:last:rounded-b-md group-data-[variant=outline]/list:last:border-b',\n className,\n )}\n {...props}\n >\n <ListItemContext.Provider value={recentCtx}>\n {row}\n </ListItemContext.Provider>\n </li>\n )\n}\n\nfunction ListItemSkeleton() {\n // Compose the shared Skeleton primitive so the placeholder matches every other skeleton\n // (token + radius + animation + motion-reduce).\n return (\n <>\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n <Skeleton className=\"h-3.5 w-1/3\" />\n <Skeleton className=\"h-3.5 w-2/3\" />\n </div>\n <div className=\"flex min-w-0 flex-1 flex-col items-end gap-2\">\n <Skeleton className=\"h-3.5 w-1/4\" />\n <Skeleton className=\"h-3.5 w-1/2\" />\n </div>\n </>\n )\n}\n\nfunction ListItemLeading({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"list-item-leading\"\n className={cn('flex shrink-0 items-center', className)}\n {...props}\n />\n )\n}\n\ninterface ListItemContentProps extends React.ComponentProps<'div'> {\n /** `end` right-aligns the column (the value column). */\n align?: 'start' | 'end'\n}\n\nfunction ListItemContent({\n className,\n align = 'start',\n ...props\n}: ListItemContentProps) {\n const columnCtx = React.useMemo(() => ({ isEnd: align === 'end' }), [align])\n return (\n <ListItemColumnContext.Provider value={columnCtx}>\n <div\n data-slot=\"list-item-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-1',\n align === 'end' ? 'items-end text-right' : 'items-start text-left',\n className,\n )}\n {...props}\n />\n </ListItemColumnContext.Provider>\n )\n}\n\nfunction ListItemPreline({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"list-item-preline\"\n className={cn('block w-full truncate text-sm text-gray-11', className)}\n {...props}\n />\n )\n}\n\nfunction ListItemTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'span'>) {\n const { recent } = React.useContext(ListItemContext)\n const { isEnd } = React.useContext(ListItemColumnContext)\n // recency dot sits inline, immediately left of the title (Figma 1310-977) — only on the\n // primary (start) column, so a two-column value row's value never carries it.\n const showDot = recent && !isEnd\n\n // className/{...props} always land on THIS span (the one that truncates), so a caller's\n // override (e.g. `title`, `line-clamp-2 whitespace-normal`) behaves identically whether\n // or not the dot renders — only the wrapping structure differs below.\n const title = (\n <span\n data-slot=\"list-item-title\"\n className={cn(\n showDot ? 'min-w-0 truncate' : 'block w-full truncate',\n 'text-base font-bold text-gray-12',\n className,\n )}\n {...props}\n >\n {children}\n </span>\n )\n\n if (!showDot) {\n // No dot: stay a plain block so the column's text alignment (e.g. an end column's\n // text-right) governs the title directly.\n return title\n }\n\n return (\n <span className=\"flex w-full items-center gap-2\">\n <span\n aria-hidden=\"true\"\n data-slot=\"list-item-indicator\"\n className=\"size-2 shrink-0 rounded-full bg-spark-9\"\n />\n {title}\n </span>\n )\n}\n\nfunction ListItemSubline({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"list-item-subline\"\n className={cn('block w-full truncate text-sm text-gray-11', className)}\n {...props}\n />\n )\n}\n\nfunction ListItemTrailing({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"list-item-trailing\"\n className={cn(\n 'flex shrink-0 items-center text-gray-11',\n // interactive rows tint the affordance accent on hover/focus (group/row is set on\n // the interactive inner row; absent on static rows, so this simply never fires).\n // Relies on the child reading currentColor (MaterialSymbol does) — the colour-\n // independent Icon component hardcodes its own ink and won't pick this up; use\n // MaterialSymbol here, not Icon.\n 'transition-colors duration-150 motion-reduce:transition-none',\n 'group-hover/row:text-spark-a11 group-focus-visible/row:text-spark-a11',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n List,\n ListItem,\n ListItemContent,\n ListItemLeading,\n ListItemPreline,\n ListItemSubline,\n ListItemTitle,\n ListItemTrailing,\n}\nexport type { ListProps, ListItemProps, ListItemContentProps, ListVariant }\n"],"mappings":";;;;;;;AAUA,MAAM,kBAAkBA,QAAM,cAAmC,EAC/D,QAAQ,MACV,CAAC;AACD,MAAM,wBAAwBA,QAAM,cAAkC,EACpE,OAAO,MACT,CAAC;AAOD,SAAS,KAAK,EAAE,WAAW,UAAU,QAAQ,GAAG,SAAoB;CAClE,OACE,oBAAC,MAAD;EAEE,MAAK;EACL,aAAU;EAEV,gBAAc;EACd,WAAW,GACT,gCAIA,qHACA,wHACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAgBA,SAAS,SAAS,EAChB,WACA,UACA,QACA,UACA,UACA,QACA,GAAG,SACa;CAIhB,MAAM,cAAc,CAAC,YAAY,UAAU;CAE3C,MAAM,YAAYA,QAAM,eAAe,EAAE,QAAQ,UAAU,MAAM,IAAI,CAAC,MAAM,CAAC;CAE7E,MAAM,MAAM,UAAU;EACpB,gBAAgB;EAChB,QAAQ,WAAW,KAAA,IAAY;EAC/B,OAAO;GACL,aAAa;GAEb,eAAe,WAAW,OAAO,KAAA;GACjC,WAAW,GAIT,qGACA,CAAC,YAAY,YAAY,eACzB,eAAe;IACb;IAGA;IACA;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EL;AAEA,SAAS,cAAc,EACrB,WACA,UACA,GAAG,SAC4B;CAC/B,MAAM,EAAE,WAAWA,QAAM,WAAW,eAAe;CACnD,MAAM,EAAE,UAAUA,QAAM,WAAW,qBAAqB;CAGxD,MAAM,UAAU,UAAU,CAAC;CAK3B,MAAM,QACJ,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GACT,UAAU,qBAAqB,yBAC/B,oCACA,SACF;EACA,GAAI;EAEH;CACG,CAAA;CAGR,IAAI,CAAC,SAGH,OAAO;CAGT,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,oBAAC,QAAD;GACE,eAAY;GACZ,aAAU;GACV,WAAU;EACX,CAAA,GACA,KACG;;AAEV;AAEA,SAAS,gBAAgB,EACvB,WACA,GAAG,SAC4B;CAC/B,OACE,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GAAG,8CAA8C,SAAS;EACrE,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,iBAAiB,EACxB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,2CAMA,gEACA,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"list.js","names":["React"],"sources":["../../src/components/list.tsx"],"sourcesContent":["import { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport type { ContainerRadius } from '../lib/container-chrome'\nimport type { SparkCardColor, SparkCardVariant } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { Skeleton } from './skeleton'\n\ntype ListVariant = SparkCardVariant\ntype ListRadius = ContainerRadius\n\n// Rounds only the first/last row of a run, regardless of variant — harmless on ghost\n// (nothing painted to clip). Keyed on `data-radius` alone: unlike fill (below), rounding\n// doesn't depend on variant/color, so no compound group-data selector is needed.\nconst radiusRowClasses: Record<ListRadius, string> = {\n none: 'group-data-[radius=none]/list:first:rounded-t-none group-data-[radius=none]/list:last:rounded-b-none',\n sm: 'group-data-[radius=sm]/list:first:rounded-t-sm group-data-[radius=sm]/list:last:rounded-b-sm',\n md: 'group-data-[radius=md]/list:first:rounded-t-md group-data-[radius=md]/list:last:rounded-b-md',\n lg: 'group-data-[radius=lg]/list:first:rounded-t-lg group-data-[radius=lg]/list:last:rounded-b-lg',\n xl: 'group-data-[radius=xl]/list:first:rounded-t-xl group-data-[radius=xl]/list:last:rounded-b-xl',\n '2xl':\n 'group-data-[radius=2xl]/list:first:rounded-t-2xl group-data-[radius=2xl]/list:last:rounded-b-2xl',\n '3xl':\n 'group-data-[radius=3xl]/list:first:rounded-t-3xl group-data-[radius=3xl]/list:last:rounded-b-3xl',\n full: 'group-data-[radius=full]/list:first:rounded-t-full group-data-[radius=full]/list:last:rounded-b-full',\n}\n\n// ListItem publishes `recent` so ListItemTitle can render the inline recency dot; the\n// column context lets the title show it only on the primary (start) column, never the\n// value column of a two-column row.\nconst ListItemContext = React.createContext<{ recent: boolean }>({\n recent: false,\n})\nconst ListItemColumnContext = React.createContext<{ isEnd: boolean }>({\n isEnd: false,\n})\n\ninterface ListProps extends React.ComponentProps<'ul'> {\n /** A prop, not the ambient `data-style` knob — that would cascade into row content. */\n variant?: ListVariant\n /** Chrome palette. `neutral` (default) tracks the app neutral; `accent` tints with the brand accent. */\n color?: SparkCardColor\n /** Corner radius, as a named step. Unset → `md`, today's fixed behaviour. */\n radius?: ListRadius\n /** How many `--spark-layout-gap` units apart each row sits (`soft`/`solid`/`ghost` only). */\n gap?: number\n}\n\nfunction List({\n className,\n variant = 'soft',\n color = 'neutral',\n radius = 'md',\n gap = 0.5,\n style,\n ...props\n}: ListProps) {\n // Fill/border-colour needs BOTH axes at once (e.g. \"soft, tinted with accent\"), which a\n // single group-data selector can't express and chaining two on the same named group\n // can't either (that generates a descendant match between two *different* ancestors,\n // not one ancestor bearing both attributes). Resolving the pair to one value up front\n // sidesteps it entirely — see the `data-look` selectors on ListItem below.\n const look = color === 'accent' ? `${variant}-accent` : variant\n return (\n <ul\n // role=list keeps list semantics even under list-style:none (Safari drops them).\n role=\"list\"\n data-slot=\"list\"\n // group/list + data-variant drive every item's per-variant chrome (below).\n data-variant={variant}\n data-look={look}\n data-radius={radius}\n className={cn(\n 'group/list m-0 list-none p-0',\n // soft/solid = separate rows → stack with a small gap (the gap IS the divider).\n // ghost shares that same gap for spacing but no fill/border (see ListItem's\n // chrome block, which has no ghost selector). surface/outline glue rows into one\n // panel with no gap at all.\n 'data-[variant=soft]:flex data-[variant=soft]:flex-col data-[variant=soft]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]',\n 'data-[variant=solid]:flex data-[variant=solid]:flex-col data-[variant=solid]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]',\n 'data-[variant=ghost]:flex data-[variant=ghost]:flex-col data-[variant=ghost]:gap-[calc(var(--spark-layout-gap)*var(--list-gap-steps,0.5))]',\n className,\n )}\n style={\n {\n '--list-gap-steps': gap,\n // solid's fill inverts far enough that the row's own ink must invert with it\n // (unlike soft/surface/outline's translucent tints, where the default ink\n // stays legible regardless of colour) — matches Card's own solid recipe,\n // where fg and fg-muted both collapse to the one contrast-guaranteed step.\n ...(variant === 'solid' && {\n '--list-item-fg':\n color === 'accent'\n ? 'var(--spark-contrast)'\n : 'var(--neutral-contrast)',\n '--list-item-fg-muted':\n color === 'accent'\n ? 'var(--spark-contrast)'\n : 'var(--neutral-contrast)',\n }),\n ...style,\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\ninterface ListItemProps extends React.ComponentProps<'li'> {\n /** The \"recently changed\" accent dot. */\n recent?: boolean\n /** Persistent accent-tint (e.g. the active document). */\n selected?: boolean\n /** Loading placeholder (Figma `skeleton=true`). */\n skeleton?: boolean\n /**\n * Base UI polymorphism for the inner row. Pass `<a href/>` or `<button/>` to make\n * the row interactive (accent-on-hover/focus, cursor, focus ring). Omit → static row.\n */\n render?: useRender.RenderProp\n}\n\nfunction ListItem({\n className,\n children,\n recent,\n selected,\n skeleton,\n render,\n ...props\n}: ListItemProps) {\n // Skeleton rows are decorative placeholders — never render as a real <a>/<button>. An\n // aria-hidden anchor would still be focusable (WCAG 4.1.2), so skeleton forces a plain,\n // non-interactive <div> regardless of `render`.\n const interactive = !skeleton && render != null\n\n const recentCtx = React.useMemo(() => ({ recent: recent ?? false }), [recent])\n\n // Only a ListItemLeading actually marked `interactive` (a Checkbox/Radio/Button) needs\n // to move outside `render`'s element, and only when `render` is literally an <a>/\n // <button> — nesting a focusable control inside another interactive element is invalid\n // HTML and double-fires clicks. A `render` of anything else (a `<Card/>`, say) has no\n // such conflict: it isn't natively interactive itself, so a control inside it is valid,\n // unduplicated HTML, and hoisting would only pull the control outside whatever that\n // element paints (its fill, border, rounded corner) for no reason. A plain icon\n // (interactive unset) is the same story from the other side — either way, Leading stays\n // inside the row by default, so the whole visual row remains one click/tap target.\n const rendersAnchorOrButton =\n React.isValidElement(render) &&\n (render.type === 'a' || render.type === 'button')\n const childArray = skeleton ? undefined : React.Children.toArray(children)\n const leadingChild = childArray?.find(\n (child): child is React.ReactElement<ListItemLeadingProps> =>\n React.isValidElement(child) && child.type === ListItemLeading,\n )\n const hoistLeading =\n rendersAnchorOrButton && Boolean(leadingChild?.props.interactive)\n const leading = hoistLeading ? leadingChild : undefined\n\n const row = useRender({\n defaultTagName: 'div',\n render: skeleton ? undefined : render,\n props: {\n 'data-slot': 'list-item-row',\n // skeleton is a decorative placeholder → keep it out of the a11y tree.\n 'aria-hidden': skeleton ? true : undefined,\n className: cn(\n // row layout from Figma 2217-1667; min-h is a HARD 44px floor (WCAG 2.5.5),\n // py/gap/text still scale past it via the spacing/scaling knobs. no-underline\n // resets the default <a> decoration when the row renders as a link.\n 'flex min-h-[2.75rem] items-center gap-4 py-3 text-left no-underline',\n hoistLeading ? 'min-w-0 flex-1 pr-4' : 'w-full rounded-[inherit] px-4',\n // not hoisted → this row IS the whole visual item (no outer <li> chrome), so\n // selection tint lives here, same as a row with no leading slot at all.\n !hoistLeading && !skeleton && selected && 'bg-spark-a3',\n interactive && [\n 'group/row cursor-pointer transition-colors duration-150 motion-reduce:transition-none',\n 'disabled:pointer-events-none disabled:opacity-50',\n hoistLeading\n ? // the custom focus ring is drawn on the outer <li> (has-focus-visible,\n // below) so it wraps the leading control too — but the browser's own\n // default outline still targets whichever element actually has focus,\n // which is this one, so it has to be suppressed here specifically.\n 'focus-visible:outline-hidden'\n : [\n 'hover:bg-spark-a3 focus-visible:bg-spark-a3',\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n ],\n ],\n ),\n children: skeleton ? (\n <ListItemSkeleton />\n ) : hoistLeading ? (\n childArray?.filter((child) => child !== leadingChild)\n ) : (\n children\n ),\n },\n })\n\n return (\n <li\n data-slot=\"list-item\"\n className={cn(\n 'relative has-focus-visible:z-10',\n hoistLeading && [\n 'flex min-w-0 items-center gap-4 pl-4',\n !skeleton && selected && 'bg-spark-a3',\n interactive && [\n // neutral at rest → subtle accent tint on hover/focus (the affordance goes\n // accent too, in ListItemTrailing; title + leading stay neutral). The click\n // target itself is `row`, so focus-visible (unlike hover) has to be read off\n // a descendant via has() — it never lands on this <li> directly.\n 'cursor-pointer',\n 'hover:bg-spark-a3 has-focus-visible:bg-spark-a3',\n 'has-focus-visible:ring-2 has-focus-visible:ring-offset-2',\n ],\n ],\n // soft/solid rows sit in a gapped stack, not a glued panel, but still read as one\n // rounded group: only the first/last row round the outer corners. surface/\n // outline glue rows into one bordered panel instead — border SIDES are variant-\n // only (no colour axis), so they stay on data-variant; fill and border COLOUR\n // depend on variant *and* colour together, so those live on data-look instead\n // (see the comment on `look` in List, above).\n 'group-data-[variant=surface]/list:border-x group-data-[variant=surface]/list:border-t group-data-[variant=surface]/list:last:border-b',\n 'group-data-[variant=outline]/list:border-x group-data-[variant=outline]/list:border-t group-data-[variant=outline]/list:last:border-b',\n 'group-data-[look=soft]/list:bg-gray-a2 dark:group-data-[look=soft]/list:bg-gray-a3',\n // arbitrary-var form, not the bg-spark-a3 utility: identical colour, but avoids a\n // literal substring collision with the unconditional selection/hover tint below,\n // which a couple of tests distinguish with a plain className.includes check.\n 'group-data-[look=soft-accent]/list:bg-(--spark-a3)',\n 'group-data-[look=surface]/list:border-gray-a6 group-data-[look=surface]/list:bg-gray-2',\n 'group-data-[look=surface-accent]/list:border-spark-a6 group-data-[look=surface-accent]/list:bg-(--spark-surface)',\n 'group-data-[look=outline]/list:border-gray-a6',\n 'group-data-[look=outline-accent]/list:border-spark-a6',\n 'group-data-[look=solid]/list:bg-(--neutral-1)',\n 'group-data-[look=solid-accent]/list:bg-spark-9',\n Object.values(radiusRowClasses),\n className,\n )}\n {...props}\n >\n <ListItemContext.Provider value={recentCtx}>\n {leading}\n {row}\n </ListItemContext.Provider>\n </li>\n )\n}\n\nfunction ListItemSkeleton() {\n // Compose the shared Skeleton primitive so the placeholder matches every other skeleton\n // (token + radius + animation + motion-reduce).\n return (\n <>\n <Skeleton className=\"size-10 shrink-0 rounded-full\" />\n <div className=\"flex min-w-0 flex-1 flex-col gap-2\">\n <Skeleton className=\"h-3.5 w-1/3\" />\n <Skeleton className=\"h-3.5 w-2/3\" />\n </div>\n <div className=\"flex min-w-0 flex-1 flex-col items-end gap-2\">\n <Skeleton className=\"h-3.5 w-1/4\" />\n <Skeleton className=\"h-3.5 w-1/2\" />\n </div>\n </>\n )\n}\n\ninterface ListItemLeadingProps extends React.ComponentProps<'div'> {\n /**\n * Set when this slot holds a focusable control (Checkbox, Radio, Button). ListItem\n * then hoists it outside `render`'s element — nesting a real control inside the row's\n * own <a>/<button> is invalid HTML and double-fires clicks. Leave unset for decorative\n * content (an icon): it stays inside the row, so the whole visual row is one\n * click/tap target, same as a row with no leading slot at all.\n */\n interactive?: boolean\n}\n\nfunction ListItemLeading({\n className,\n interactive: _interactive,\n ...props\n}: ListItemLeadingProps) {\n return (\n <div\n data-slot=\"list-item-leading\"\n className={cn('flex shrink-0 items-center', className)}\n {...props}\n />\n )\n}\n\ninterface ListItemContentProps extends React.ComponentProps<'div'> {\n /** `end` right-aligns the column (the value column). */\n align?: 'start' | 'end'\n}\n\nfunction ListItemContent({\n className,\n align = 'start',\n ...props\n}: ListItemContentProps) {\n const columnCtx = React.useMemo(() => ({ isEnd: align === 'end' }), [align])\n return (\n <ListItemColumnContext.Provider value={columnCtx}>\n <div\n data-slot=\"list-item-content\"\n className={cn(\n 'flex min-w-0 flex-1 flex-col gap-1',\n align === 'end' ? 'items-end text-right' : 'items-start text-left',\n className,\n )}\n {...props}\n />\n </ListItemColumnContext.Provider>\n )\n}\n\nfunction ListItemPreline({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"list-item-preline\"\n className={cn(\n 'block w-full truncate text-sm text-(--list-item-fg-muted,var(--neutral-11))',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ListItemTitle({\n className,\n children,\n ...props\n}: React.ComponentProps<'span'>) {\n const { recent } = React.useContext(ListItemContext)\n const { isEnd } = React.useContext(ListItemColumnContext)\n // recency dot sits inline, immediately left of the title (Figma 1310-977) — only on the\n // primary (start) column, so a two-column value row's value never carries it.\n const showDot = recent && !isEnd\n\n // className/{...props} always land on THIS span (the one that truncates), so a caller's\n // override (e.g. `title`, `line-clamp-2 whitespace-normal`) behaves identically whether\n // or not the dot renders — only the wrapping structure differs below.\n const title = (\n <span\n data-slot=\"list-item-title\"\n className={cn(\n showDot ? 'min-w-0 truncate' : 'block w-full truncate',\n 'text-base font-bold text-(--list-item-fg,var(--neutral-12))',\n className,\n )}\n {...props}\n >\n {children}\n </span>\n )\n\n if (!showDot) {\n // No dot: stay a plain block so the column's text alignment (e.g. an end column's\n // text-right) governs the title directly.\n return title\n }\n\n return (\n <span className=\"flex w-full items-center gap-2\">\n <span\n aria-hidden=\"true\"\n data-slot=\"list-item-indicator\"\n className=\"size-2 shrink-0 rounded-full bg-spark-9\"\n />\n {title}\n </span>\n )\n}\n\nfunction ListItemSubline({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"list-item-subline\"\n className={cn(\n 'block w-full truncate text-sm text-(--list-item-fg-muted,var(--neutral-11))',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction ListItemTrailing({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"list-item-trailing\"\n className={cn(\n 'flex shrink-0 items-center text-gray-11',\n // interactive rows tint the affordance accent on hover/focus (group/row is set on\n // the interactive inner row; absent on static rows, so this simply never fires).\n // Relies on the child reading currentColor (MaterialSymbol does) — the colour-\n // independent Icon component hardcodes its own ink and won't pick this up; use\n // MaterialSymbol here, not Icon.\n 'transition-colors duration-150 motion-reduce:transition-none',\n 'group-hover/row:text-spark-a11 group-focus-visible/row:text-spark-a11',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n List,\n ListItem,\n ListItemContent,\n ListItemLeading,\n ListItemPreline,\n ListItemSubline,\n ListItemTitle,\n ListItemTrailing,\n}\nexport type {\n ListProps,\n ListItemProps,\n ListItemContentProps,\n ListItemLeadingProps,\n ListVariant,\n ListRadius,\n}\n"],"mappings":";;;;;;;AAaA,MAAM,mBAA+C;CACnD,MAAM;CACN,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,OACE;CACF,OACE;CACF,MAAM;AACR;AAKA,MAAM,kBAAkBA,QAAM,cAAmC,EAC/D,QAAQ,MACV,CAAC;AACD,MAAM,wBAAwBA,QAAM,cAAkC,EACpE,OAAO,MACT,CAAC;AAaD,SAAS,KAAK,EACZ,WACA,UAAU,QACV,QAAQ,WACR,SAAS,MACT,MAAM,IACN,OACA,GAAG,SACS;CAOZ,OACE,oBAAC,MAAD;EAEE,MAAK;EACL,aAAU;EAEV,gBAAc;EACd,aARS,UAAU,WAAW,GAAG,QAAQ,WAAW;EASpD,eAAa;EACb,WAAW,GACT,gCAKA,2IACA,8IACA,8IACA,SACF;EACA,OACE;GACE,oBAAoB;GAKpB,GAAI,YAAY,WAAW;IACzB,kBACE,UAAU,WACN,0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AAU;EACV,WAAW,GACT,UAAU,qBAAqB,yBAC/B,+DACA,SACF;EACA,GAAI;EAEH;CACG,CAAA;CAGR,IAAI,CAAC,SAGH,OAAO;CAGT,OACE,qBAAC,QAAD;EAAM,WAAU;YAAhB,CACE,oBAAC,QAAD;GACE,eAAY;GACZ,aAAU;GACV,WAAU;EACX,CAAA,GACA,KACG;;AAEV;AAEA,SAAS,gBAAgB,EACvB,WACA,GAAG,SAC4B;CAC/B,OACE,oBAAC,QAAD;EACE,aAAU;EACV,WAAW,GACT,+EACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,iBAAiB,EACxB,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,2CAMA,gEACA,yEACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -6,7 +6,7 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/page-header.d.ts
|
|
8
8
|
declare const PageHeader: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLElement> & React$1.RefAttributes<HTMLElement>>;
|
|
9
|
-
declare const PageHeaderBackButton: React$1.ForwardRefExoticComponent<Omit<ButtonProps, "color" | "
|
|
9
|
+
declare const PageHeaderBackButton: React$1.ForwardRefExoticComponent<Omit<ButtonProps, "color" | "styleVariant" | "size"> & React$1.RefAttributes<HTMLButtonElement>>;
|
|
10
10
|
declare const PageHeaderTitle: ({
|
|
11
11
|
className,
|
|
12
12
|
...props
|
|
@@ -6,7 +6,7 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
6
6
|
|
|
7
7
|
//#region src/components/page-header.d.ts
|
|
8
8
|
declare const PageHeader: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLElement> & React$1.RefAttributes<HTMLElement>>;
|
|
9
|
-
declare const PageHeaderBackButton: React$1.ForwardRefExoticComponent<Omit<ButtonProps, "color" | "
|
|
9
|
+
declare const PageHeaderBackButton: React$1.ForwardRefExoticComponent<Omit<ButtonProps, "color" | "styleVariant" | "size"> & React$1.RefAttributes<HTMLButtonElement>>;
|
|
10
10
|
declare const PageHeaderTitle: ({
|
|
11
11
|
className,
|
|
12
12
|
...props
|
package/dist/components/pill.cjs
CHANGED
|
@@ -17,24 +17,31 @@ const Pill = react.forwardRef(function Pill({ className, children, styleVariant,
|
|
|
17
17
|
const clickable = !disabled && onClick !== void 0;
|
|
18
18
|
const removable = !disabled && onRemove !== void 0;
|
|
19
19
|
const focusable = clickable || removable;
|
|
20
|
+
const hasLook = styleVariant !== void 0 || color !== void 0;
|
|
21
|
+
const handleKeyDown = (event) => {
|
|
22
|
+
onKeyDown?.(event);
|
|
23
|
+
if (clickable && (event.key === "Enter" || event.key === " ")) {
|
|
24
|
+
if (event.key === " ") event.preventDefault();
|
|
25
|
+
onClick?.(event);
|
|
26
|
+
}
|
|
27
|
+
if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
|
|
28
|
+
};
|
|
29
|
+
const interaction = {
|
|
30
|
+
onKeyDown: handleKeyDown,
|
|
31
|
+
...clickable && {
|
|
32
|
+
role: "button",
|
|
33
|
+
onClick
|
|
34
|
+
},
|
|
35
|
+
...focusable && { tabIndex: 0 }
|
|
36
|
+
};
|
|
20
37
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
21
38
|
"aria-disabled": disabled || void 0,
|
|
22
39
|
"aria-keyshortcuts": removable ? "Delete" : void 0,
|
|
23
40
|
"data-slot": "pill",
|
|
24
|
-
"data-style":
|
|
41
|
+
"data-style": hasLook ? styleVariant ?? "soft" : void 0,
|
|
25
42
|
"data-accent-color": color ? require_lib_accent_colors.accentByColor[color] : void 0,
|
|
26
|
-
|
|
27
|
-
onKeyDown: (event) => {
|
|
28
|
-
onKeyDown?.(event);
|
|
29
|
-
if (clickable && (event.key === "Enter" || event.key === " ")) {
|
|
30
|
-
if (event.key === " ") event.preventDefault();
|
|
31
|
-
onClick?.(event);
|
|
32
|
-
}
|
|
33
|
-
if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
|
|
34
|
-
},
|
|
43
|
+
...interaction,
|
|
35
44
|
ref,
|
|
36
|
-
role: clickable ? "button" : void 0,
|
|
37
|
-
tabIndex: focusable ? 0 : void 0,
|
|
38
45
|
className: (0, cnfast.cn)("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--neutral-a11))", focusable && "transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover)", disabled && "pointer-events-none opacity-50", className),
|
|
39
46
|
...props,
|
|
40
47
|
children: [children, removable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.cjs","names":["React","accentByColor","MaterialSymbol"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["import * as React from 'react'\nimport { MaterialSymbol } from '../icons/material-symbol'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n
|
|
1
|
+
{"version":3,"file":"pill.cjs","names":["React","accentByColor","MaterialSymbol"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["import * as React from 'react'\nimport { MaterialSymbol } from '../icons/material-symbol'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n if (removable && (event.key === 'Delete' || event.key === 'Backspace')) {\n onRemove?.(event)\n }\n }\n\n // button role and click handler travel together, so a clickable pill always\n // answers Enter/Space; a removable-only pill stays generic and answers Delete\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick }),\n ...(focusable && { tabIndex: 0 }),\n }\n\n return (\n <span\n aria-disabled={disabled || undefined}\n aria-keyshortcuts={removable ? 'Delete' : undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--neutral-a11))',\n focusable &&\n 'transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden motion-reduce:transition-none',\n clickable && 'cursor-pointer hover:bg-(--spark-style-bg-hover)',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n {removable ? (\n <>\n {/* aria-hidden hides the glyph itself; this carries removeLabel into the pill's own accessible name */}\n <span className=\"sr-only\">{removeLabel}</span>\n <span\n aria-hidden=\"true\"\n data-slot=\"pill-remove\"\n onClick={(event) => {\n event.stopPropagation()\n onRemove?.(event)\n }}\n className=\"-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover) motion-reduce:transition-none\"\n >\n <MaterialSymbol className=\"[--spark-icon-size:14px]\" name=\"close\" />\n </span>\n </>\n ) : null}\n </span>\n )\n})\n\nPill.displayName = 'Pill'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B,MAAM,gBAAgB;IACtB,WAAW,KAAK;GAClB;GACA,WAAU;aAEV,iBAAA,GAAA,kBAAA,KAACC,8BAAAA,gBAAD;IAAgB,WAAU;IAA2B,MAAK;GAAS,CAAA;EAC/D,CAAA,CACN,EAAA,CAAA,IACA,IACA;;AAEV,CAAC;AAED,KAAK,cAAc"}
|
package/dist/components/pill.js
CHANGED
|
@@ -14,24 +14,31 @@ const Pill = React$1.forwardRef(function Pill({ className, children, styleVarian
|
|
|
14
14
|
const clickable = !disabled && onClick !== void 0;
|
|
15
15
|
const removable = !disabled && onRemove !== void 0;
|
|
16
16
|
const focusable = clickable || removable;
|
|
17
|
+
const hasLook = styleVariant !== void 0 || color !== void 0;
|
|
18
|
+
const handleKeyDown = (event) => {
|
|
19
|
+
onKeyDown?.(event);
|
|
20
|
+
if (clickable && (event.key === "Enter" || event.key === " ")) {
|
|
21
|
+
if (event.key === " ") event.preventDefault();
|
|
22
|
+
onClick?.(event);
|
|
23
|
+
}
|
|
24
|
+
if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
|
|
25
|
+
};
|
|
26
|
+
const interaction = {
|
|
27
|
+
onKeyDown: handleKeyDown,
|
|
28
|
+
...clickable && {
|
|
29
|
+
role: "button",
|
|
30
|
+
onClick
|
|
31
|
+
},
|
|
32
|
+
...focusable && { tabIndex: 0 }
|
|
33
|
+
};
|
|
17
34
|
return /* @__PURE__ */ jsxs("span", {
|
|
18
35
|
"aria-disabled": disabled || void 0,
|
|
19
36
|
"aria-keyshortcuts": removable ? "Delete" : void 0,
|
|
20
37
|
"data-slot": "pill",
|
|
21
|
-
"data-style":
|
|
38
|
+
"data-style": hasLook ? styleVariant ?? "soft" : void 0,
|
|
22
39
|
"data-accent-color": color ? accentByColor[color] : void 0,
|
|
23
|
-
|
|
24
|
-
onKeyDown: (event) => {
|
|
25
|
-
onKeyDown?.(event);
|
|
26
|
-
if (clickable && (event.key === "Enter" || event.key === " ")) {
|
|
27
|
-
if (event.key === " ") event.preventDefault();
|
|
28
|
-
onClick?.(event);
|
|
29
|
-
}
|
|
30
|
-
if (removable && (event.key === "Delete" || event.key === "Backspace")) onRemove?.(event);
|
|
31
|
-
},
|
|
40
|
+
...interaction,
|
|
32
41
|
ref,
|
|
33
|
-
role: clickable ? "button" : void 0,
|
|
34
|
-
tabIndex: focusable ? 0 : void 0,
|
|
35
42
|
className: cn("inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none", "bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--neutral-a11))", focusable && "transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden motion-reduce:transition-none", clickable && "cursor-pointer hover:bg-(--spark-style-bg-hover)", disabled && "pointer-events-none opacity-50", className),
|
|
36
43
|
...props,
|
|
37
44
|
children: [children, removable ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pill.js","names":["React"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["import * as React from 'react'\nimport { MaterialSymbol } from '../icons/material-symbol'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n
|
|
1
|
+
{"version":3,"file":"pill.js","names":["React"],"sources":["../../src/components/pill.tsx"],"sourcesContent":["import * as React from 'react'\nimport { MaterialSymbol } from '../icons/material-symbol'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkAccentColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\ntype PillRemoveProps =\n | { onRemove?: undefined; removeLabel?: string }\n | {\n /** Fires on a pointer click of the (decorative) glyph, or Delete/Backspace while the pill has focus. */\n onRemove: (event: React.SyntheticEvent) => void\n /** Visually-hidden text folded into the pill's accessible name -- the glyph itself is `aria-hidden`. */\n removeLabel: string\n }\n\ntype PillProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'onClick'> &\n PillRemoveProps & {\n styleVariant?: SparkStyle\n color?: SparkAccentColor\n disabled?: boolean\n onClick?: (event: React.SyntheticEvent<HTMLSpanElement>) => void\n }\n\n/**\n * Like Badge, but interactive: `onClick` makes the whole pill a button\n * (Enter/Space), `onRemove` adds a Delete/Backspace-and-click affordance.\n * Both are optional -- with neither, it's a static label.\n */\nconst Pill = React.forwardRef<HTMLSpanElement, PillProps>(function Pill(\n {\n className,\n children,\n styleVariant,\n color,\n disabled = false,\n onClick,\n onRemove,\n removeLabel,\n onKeyDown,\n ...props\n },\n ref,\n) {\n const clickable = !disabled && onClick !== undefined\n const removable = !disabled && onRemove !== undefined\n const focusable = clickable || removable\n const hasLook = styleVariant !== undefined || color !== undefined\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n onKeyDown?.(event)\n if (clickable && (event.key === 'Enter' || event.key === ' ')) {\n if (event.key === ' ') event.preventDefault()\n onClick?.(event)\n }\n if (removable && (event.key === 'Delete' || event.key === 'Backspace')) {\n onRemove?.(event)\n }\n }\n\n // button role and click handler travel together, so a clickable pill always\n // answers Enter/Space; a removable-only pill stays generic and answers Delete\n const interaction = {\n onKeyDown: handleKeyDown,\n ...(clickable && { role: 'button' as const, onClick }),\n ...(focusable && { tabIndex: 0 }),\n }\n\n return (\n <span\n aria-disabled={disabled || undefined}\n aria-keyshortcuts={removable ? 'Delete' : undefined}\n data-slot=\"pill\"\n data-style={hasLook ? (styleVariant ?? 'soft') : undefined}\n data-accent-color={color ? accentByColor[color] : undefined}\n {...interaction}\n ref={ref}\n className={cn(\n 'inline-flex h-7 items-center gap-1 rounded-full px-2.5 text-xs font-medium select-none',\n 'bg-(--spark-style-bg,var(--neutral-a3)) text-(--spark-style-fg,var(--neutral-a11))',\n focusable &&\n 'transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden motion-reduce:transition-none',\n clickable && 'cursor-pointer hover:bg-(--spark-style-bg-hover)',\n disabled && 'pointer-events-none opacity-50',\n className,\n )}\n {...props}\n >\n {children}\n {removable ? (\n <>\n {/* aria-hidden hides the glyph itself; this carries removeLabel into the pill's own accessible name */}\n <span className=\"sr-only\">{removeLabel}</span>\n <span\n aria-hidden=\"true\"\n data-slot=\"pill-remove\"\n onClick={(event) => {\n event.stopPropagation()\n onRemove?.(event)\n }}\n className=\"-mr-1 inline-flex size-4 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-(--spark-style-bg-hover) motion-reduce:transition-none\"\n >\n <MaterialSymbol className=\"[--spark-icon-size:14px]\" name=\"close\" />\n </span>\n </>\n ) : null}\n </span>\n )\n})\n\nPill.displayName = 'Pill'\n\nexport { Pill }\nexport type { PillProps }\n"],"mappings":";;;;;;;;;;;;AA6BA,MAAM,OAAOA,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}
|
|
@@ -37,21 +37,24 @@ function PopoverAnchor({ render, ...props }) {
|
|
|
37
37
|
props: (0, _base_ui_react_merge_props.mergeProps)({ "data-slot": "popover-anchor" }, props)
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
function PopoverContent({ className, align = "center", sideOffset = 4, side, alignOffset, anchor, ...props }) {
|
|
40
|
+
function PopoverContent({ className, align = "center", sideOffset = 4, side, alignOffset, anchor, container, ...props }) {
|
|
41
41
|
const context = react.useContext(PopoverAnchorContext);
|
|
42
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Portal, {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Portal, {
|
|
43
|
+
container,
|
|
44
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Positioner, {
|
|
45
|
+
align,
|
|
46
|
+
alignOffset,
|
|
47
|
+
anchor: anchor ?? context?.anchor ?? void 0,
|
|
48
|
+
className: "isolate z-50",
|
|
49
|
+
side,
|
|
50
|
+
sideOffset,
|
|
51
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_popover.Popover.Popup, {
|
|
52
|
+
"data-slot": "popover-content",
|
|
53
|
+
className: (0, cnfast.cn)("z-50 w-72 origin-(--transform-origin) rounded-lg border border-gray-a1 bg-gray-1 p-4 text-gray-a12 shadow-md outline-hidden transition-[opacity,scale,translate] duration-100 motion-reduce:transition-none", "data-starting-style:scale-95 data-starting-style:opacity-0", "data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2", "data-ending-style:scale-95 data-ending-style:opacity-0", className),
|
|
54
|
+
...props
|
|
55
|
+
})
|
|
53
56
|
})
|
|
54
|
-
})
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
//#endregion
|
|
57
60
|
exports.Popover = Popover;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.cjs","names":["React","PopoverPrimitive"],"sources":["../../src/components/popover.tsx"],"sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\n// Base UI dropped the Anchor part; the anchor element registers itself here and\n// PopoverContent feeds it to the Positioner.\nconst PopoverAnchorContext = React.createContext<{\n anchor: HTMLElement | null\n setAnchor: (element: HTMLElement | null) => void\n} | null>(null)\n\nfunction Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n const [anchor, setAnchor] = React.useState<HTMLElement | null>(null)\n const value = React.useMemo(() => ({ anchor, setAnchor }), [anchor])\n return (\n <PopoverAnchorContext.Provider value={value}>\n <PopoverPrimitive.Root {...props} />\n </PopoverAnchorContext.Provider>\n )\n}\n\nfunction PopoverTrigger(\n props: React.ComponentProps<typeof PopoverPrimitive.Trigger>,\n) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />\n}\n\n/** Anchors the popover to this element instead of the trigger. Pass `render` to\n * wrap an existing element (was radix `asChild`). */\nfunction PopoverAnchor({ render, ...props }: useRender.ComponentProps<'div'>) {\n const context = React.useContext(PopoverAnchorContext)\n return useRender({\n defaultTagName: 'div',\n render,\n ref: context?.setAnchor,\n props: mergeProps<'div'>(\n { 'data-slot': 'popover-anchor' } as React.ComponentProps<'div'>,\n props,\n ),\n })\n}\n\ntype PopoverContentProps = React.ComponentProps<typeof PopoverPrimitive.Popup> &\n Pick<\n PopoverPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'\n >\n\nfunction PopoverContent({\n className,\n align = 'center',\n sideOffset = 4,\n side,\n alignOffset,\n anchor,\n ...props\n}: PopoverContentProps) {\n const context = React.useContext(PopoverAnchorContext)\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n anchor={anchor ?? context?.anchor ?? undefined}\n className=\"isolate z-50\"\n side={side}\n sideOffset={sideOffset}\n >\n <PopoverPrimitive.Popup\n data-slot=\"popover-content\"\n className={cn(\n 'z-50 w-72 origin-(--transform-origin) rounded-lg border border-gray-a1 bg-gray-1 p-4 text-gray-a12 shadow-md outline-hidden transition-[opacity,scale,translate] duration-100 motion-reduce:transition-none',\n // enter: fade + zoom + a slight per-side slide (was animate-in)\n 'data-starting-style:scale-95 data-starting-style:opacity-0',\n 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n // exit: fade + zoom (was animate-out)\n 'data-ending-style:scale-95 data-ending-style:opacity-0',\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n )\n}\n\nexport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger }\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,uBAAuBA,MAAM,cAGzB,IAAI;AAEd,SAAS,QAAQ,OAA2D;CAC1E,MAAM,CAAC,QAAQ,aAAaA,MAAM,SAA6B,IAAI;CACnE,MAAM,QAAQA,MAAM,eAAe;EAAE;EAAQ;CAAU,IAAI,CAAC,MAAM,CAAC;CACnE,OACE,iBAAA,GAAA,kBAAA,KAAC,qBAAqB,UAAtB;EAAsC;YACpC,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,QAAiB,MAAlB,EAAuB,GAAI,MAAQ,CAAA;CACN,CAAA;AAEnC;AAEA,SAAS,eACP,OACA;CACA,OAAO,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,QAAiB,SAAlB;EAA0B,aAAU;EAAkB,GAAI;CAAQ,CAAA;AAC3E;;;AAIA,SAAS,cAAc,EAAE,QAAQ,GAAG,SAA0C;CAE5E,QAAA,GAAA,0BAAA,WAAiB;EACf,gBAAgB;EAChB;EACA,KAJcD,MAAM,WAAW,oBAIpB,GAAG;EACd,QAAA,GAAA,2BAAA,YACE,EAAE,aAAa,iBAAiB,GAChC,KACF;CACF,CAAC;AACH;
|
|
1
|
+
{"version":3,"file":"popover.cjs","names":["React","PopoverPrimitive"],"sources":["../../src/components/popover.tsx"],"sourcesContent":["import { mergeProps } from '@base-ui/react/merge-props'\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\n\n// Base UI dropped the Anchor part; the anchor element registers itself here and\n// PopoverContent feeds it to the Positioner.\nconst PopoverAnchorContext = React.createContext<{\n anchor: HTMLElement | null\n setAnchor: (element: HTMLElement | null) => void\n} | null>(null)\n\nfunction Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>) {\n const [anchor, setAnchor] = React.useState<HTMLElement | null>(null)\n const value = React.useMemo(() => ({ anchor, setAnchor }), [anchor])\n return (\n <PopoverAnchorContext.Provider value={value}>\n <PopoverPrimitive.Root {...props} />\n </PopoverAnchorContext.Provider>\n )\n}\n\nfunction PopoverTrigger(\n props: React.ComponentProps<typeof PopoverPrimitive.Trigger>,\n) {\n return <PopoverPrimitive.Trigger data-slot=\"popover-trigger\" {...props} />\n}\n\n/** Anchors the popover to this element instead of the trigger. Pass `render` to\n * wrap an existing element (was radix `asChild`). */\nfunction PopoverAnchor({ render, ...props }: useRender.ComponentProps<'div'>) {\n const context = React.useContext(PopoverAnchorContext)\n return useRender({\n defaultTagName: 'div',\n render,\n ref: context?.setAnchor,\n props: mergeProps<'div'>(\n { 'data-slot': 'popover-anchor' } as React.ComponentProps<'div'>,\n props,\n ),\n })\n}\n\ntype PopoverContentProps = React.ComponentProps<typeof PopoverPrimitive.Popup> &\n Pick<\n PopoverPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'\n > &\n Pick<PopoverPrimitive.Portal.Props, 'container'>\n\nfunction PopoverContent({\n className,\n align = 'center',\n sideOffset = 4,\n side,\n alignOffset,\n anchor,\n container,\n ...props\n}: PopoverContentProps) {\n const context = React.useContext(PopoverAnchorContext)\n return (\n <PopoverPrimitive.Portal container={container}>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n anchor={anchor ?? context?.anchor ?? undefined}\n className=\"isolate z-50\"\n side={side}\n sideOffset={sideOffset}\n >\n <PopoverPrimitive.Popup\n data-slot=\"popover-content\"\n className={cn(\n 'z-50 w-72 origin-(--transform-origin) rounded-lg border border-gray-a1 bg-gray-1 p-4 text-gray-a12 shadow-md outline-hidden transition-[opacity,scale,translate] duration-100 motion-reduce:transition-none',\n // enter: fade + zoom + a slight per-side slide (was animate-in)\n 'data-starting-style:scale-95 data-starting-style:opacity-0',\n 'data-[side=bottom]:data-starting-style:-translate-y-2 data-[side=left]:data-starting-style:translate-x-2 data-[side=right]:data-starting-style:-translate-x-2 data-[side=top]:data-starting-style:translate-y-2',\n // exit: fade + zoom (was animate-out)\n 'data-ending-style:scale-95 data-ending-style:opacity-0',\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n )\n}\n\nexport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger }\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,uBAAuBA,MAAM,cAGzB,IAAI;AAEd,SAAS,QAAQ,OAA2D;CAC1E,MAAM,CAAC,QAAQ,aAAaA,MAAM,SAA6B,IAAI;CACnE,MAAM,QAAQA,MAAM,eAAe;EAAE;EAAQ;CAAU,IAAI,CAAC,MAAM,CAAC;CACnE,OACE,iBAAA,GAAA,kBAAA,KAAC,qBAAqB,UAAtB;EAAsC;YACpC,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,QAAiB,MAAlB,EAAuB,GAAI,MAAQ,CAAA;CACN,CAAA;AAEnC;AAEA,SAAS,eACP,OACA;CACA,OAAO,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,QAAiB,SAAlB;EAA0B,aAAU;EAAkB,GAAI;CAAQ,CAAA;AAC3E;;;AAIA,SAAS,cAAc,EAAE,QAAQ,GAAG,SAA0C;CAE5E,QAAA,GAAA,0BAAA,WAAiB;EACf,gBAAgB;EAChB;EACA,KAJcD,MAAM,WAAW,oBAIpB,GAAG;EACd,QAAA,GAAA,2BAAA,YACE,EAAE,aAAa,iBAAiB,GAChC,KACF;CACF,CAAC;AACH;AASA,SAAS,eAAe,EACtB,WACA,QAAQ,UACR,aAAa,GACb,MACA,aACA,QACA,WACA,GAAG,SACmB;CACtB,MAAM,UAAUA,MAAM,WAAW,oBAAoB;CACrD,OACE,iBAAA,GAAA,kBAAA,KAACC,uBAAAA,QAAiB,QAAlB;EAAoC;YAClC,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,QAAiB,YAAlB;GACS;GACM;GACb,QAAQ,UAAU,SAAS,UAAU,KAAA;GACrC,WAAU;GACJ;GACM;aAEZ,iBAAA,GAAA,kBAAA,KAACA,uBAAAA,QAAiB,OAAlB;IACE,aAAU;IACV,YAAA,GAAA,OAAA,IACE,+MAEA,8DACA,mNAEA,0DACA,SACF;IACA,GAAI;GACL,CAAA;EAC0B,CAAA;CACN,CAAA;AAE7B"}
|
|
@@ -13,7 +13,7 @@ declare function PopoverAnchor({
|
|
|
13
13
|
render,
|
|
14
14
|
...props
|
|
15
15
|
}: useRender.ComponentProps<'div'>): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
|
|
16
|
-
type PopoverContentProps = React$1.ComponentProps<typeof Popover$1.Popup> & Pick<Popover$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'>;
|
|
16
|
+
type PopoverContentProps = React$1.ComponentProps<typeof Popover$1.Popup> & Pick<Popover$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'anchor'> & Pick<Popover$1.Portal.Props, 'container'>;
|
|
17
17
|
declare function PopoverContent({
|
|
18
18
|
className,
|
|
19
19
|
align,
|
|
@@ -21,6 +21,7 @@ declare function PopoverContent({
|
|
|
21
21
|
side,
|
|
22
22
|
alignOffset,
|
|
23
23
|
anchor,
|
|
24
|
+
container,
|
|
24
25
|
...props
|
|
25
26
|
}: PopoverContentProps): import("react/jsx-runtime").JSX.Element;
|
|
26
27
|
//#endregion
|