@epilot/spark-ui 0.16.0 → 0.17.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/accordion.cjs +3 -6
- package/dist/components/accordion.cjs.map +1 -1
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +3 -6
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.cjs +4 -5
- package/dist/components/alert-dialog.cjs.map +1 -1
- package/dist/components/alert-dialog.js +4 -5
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/autocomplete.cjs +161 -0
- package/dist/components/autocomplete.cjs.map +1 -0
- package/dist/components/autocomplete.d.cts +76 -0
- package/dist/components/autocomplete.d.ts +76 -0
- package/dist/components/autocomplete.js +143 -0
- package/dist/components/autocomplete.js.map +1 -0
- package/dist/components/avatar.js +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/bar-chart.js +1 -1
- package/dist/components/battery-progress-row.cjs +14 -11
- package/dist/components/battery-progress-row.cjs.map +1 -1
- package/dist/components/battery-progress-row.d.cts +2 -10
- package/dist/components/battery-progress-row.d.ts +2 -10
- package/dist/components/battery-progress-row.js +14 -11
- package/dist/components/battery-progress-row.js.map +1 -1
- package/dist/components/box.js +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button-group.js +1 -1
- package/dist/components/button.cjs +6 -6
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +2 -2
- package/dist/components/button.d.ts +2 -2
- package/dist/components/button.js +7 -7
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +4 -5
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.js +4 -5
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/callout.cjs +18 -14
- package/dist/components/callout.cjs.map +1 -1
- package/dist/components/callout.d.cts +10 -4
- package/dist/components/callout.d.ts +10 -4
- package/dist/components/callout.js +18 -15
- package/dist/components/callout.js.map +1 -1
- package/dist/components/card.js +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/device-card.cjs +2 -6
- package/dist/components/device-card.cjs.map +1 -1
- package/dist/components/device-card.d.cts +3 -3
- package/dist/components/device-card.d.ts +3 -3
- package/dist/components/device-card.js +2 -6
- package/dist/components/device-card.js.map +1 -1
- package/dist/components/dialog.cjs +2 -5
- package/dist/components/dialog.cjs.map +1 -1
- package/dist/components/dialog.js +2 -5
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dropdown-menu.cjs +4 -13
- package/dist/components/dropdown-menu.cjs.map +1 -1
- package/dist/components/dropdown-menu.js +4 -13
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/empty-state.cjs +5 -5
- package/dist/components/empty-state.cjs.map +1 -1
- package/dist/components/empty-state.d.cts +3 -3
- package/dist/components/empty-state.d.ts +3 -3
- package/dist/components/empty-state.js +5 -5
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/icon.cjs +2 -3
- package/dist/components/icon.cjs.map +1 -1
- package/dist/components/icon.d.cts +0 -3
- package/dist/components/icon.d.ts +0 -3
- package/dist/components/icon.js +3 -4
- 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-otp.cjs +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/line-chart.cjs +1 -1
- package/dist/components/line-chart.js +2 -2
- package/dist/components/list.cjs.map +1 -1
- package/dist/components/list.js.map +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/message-scroller.cjs +3 -3
- package/dist/components/message-scroller.cjs.map +1 -1
- package/dist/components/message-scroller.js +4 -4
- package/dist/components/message-scroller.js.map +1 -1
- package/dist/components/metering-row.cjs +3 -3
- package/dist/components/metering-row.cjs.map +1 -1
- package/dist/components/metering-row.d.cts +3 -3
- package/dist/components/metering-row.d.ts +3 -3
- package/dist/components/metering-row.js +3 -3
- package/dist/components/metering-row.js.map +1 -1
- package/dist/components/money-saved-block.cjs +2 -5
- package/dist/components/money-saved-block.cjs.map +1 -1
- package/dist/components/money-saved-block.js +2 -5
- package/dist/components/money-saved-block.js.map +1 -1
- package/dist/components/on-off-button.cjs +2 -5
- package/dist/components/on-off-button.cjs.map +1 -1
- package/dist/components/on-off-button.js +2 -5
- package/dist/components/on-off-button.js.map +1 -1
- package/dist/components/page-header.cjs +2 -2
- package/dist/components/page-header.cjs.map +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/page-header.js +2 -2
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/period-tabs.cjs +3 -6
- package/dist/components/period-tabs.cjs.map +1 -1
- package/dist/components/period-tabs.js +3 -6
- package/dist/components/period-tabs.js.map +1 -1
- package/dist/components/pill.cjs +2 -5
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.js +3 -6
- package/dist/components/pill.js.map +1 -1
- package/dist/components/power-history-chart.cjs +1 -1
- package/dist/components/power-history-chart.js +2 -2
- package/dist/components/power-history.cjs +1 -1
- package/dist/components/power-history.js +1 -1
- package/dist/components/power-network.cjs +3 -6
- package/dist/components/power-network.cjs.map +1 -1
- package/dist/components/power-network.js +4 -7
- package/dist/components/power-network.js.map +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/sankey-chart.cjs +56 -71
- package/dist/components/sankey-chart.cjs.map +1 -1
- package/dist/components/sankey-chart.js +56 -71
- package/dist/components/sankey-chart.js.map +1 -1
- package/dist/components/schedule-list.cjs +3 -9
- package/dist/components/schedule-list.cjs.map +1 -1
- package/dist/components/schedule-list.js +3 -9
- package/dist/components/schedule-list.js.map +1 -1
- package/dist/components/select.cjs +6 -18
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.js +6 -18
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.cjs +2 -5
- package/dist/components/sheet.cjs.map +1 -1
- package/dist/components/sheet.js +2 -5
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/slider.cjs +9 -3
- package/dist/components/slider.cjs.map +1 -1
- package/dist/components/slider.js +9 -3
- package/dist/components/slider.js.map +1 -1
- package/dist/components/smart-toggle-button.cjs +2 -5
- package/dist/components/smart-toggle-button.cjs.map +1 -1
- package/dist/components/smart-toggle-button.js +2 -5
- package/dist/components/smart-toggle-button.js.map +1 -1
- package/dist/components/solar-forecast-chart.cjs +8 -9
- package/dist/components/solar-forecast-chart.cjs.map +1 -1
- package/dist/components/solar-forecast-chart.d.cts +2 -2
- package/dist/components/solar-forecast-chart.d.ts +2 -2
- package/dist/components/solar-forecast-chart.js +8 -9
- package/dist/components/solar-forecast-chart.js.map +1 -1
- package/dist/components/stepper.cjs +3 -9
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.js +3 -9
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tabs.cjs +2 -2
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +2 -2
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/theme.js +1 -1
- package/dist/components/toast.cjs +9 -12
- package/dist/components/toast.cjs.map +1 -1
- package/dist/components/toast.js +9 -12
- package/dist/components/toast.js.map +1 -1
- package/dist/components/tooltip.cjs +2 -5
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.js +2 -5
- package/dist/components/tooltip.js.map +1 -1
- package/dist/styles/index.css +0 -2
- package/package.json +3 -10
- package/dist/icons/index.cjs +0 -7
- package/dist/icons/index.d.cts +0 -4
- package/dist/icons/index.d.ts +0 -4
- package/dist/icons/index.js +0 -3
- package/dist/icons/material-symbol.cjs +0 -106
- package/dist/icons/material-symbol.cjs.map +0 -1
- package/dist/icons/material-symbol.d.cts +0 -21
- package/dist/icons/material-symbol.d.ts +0 -21
- package/dist/icons/material-symbol.js +0 -102
- package/dist/icons/material-symbol.js.map +0 -1
- package/dist/styles/material-symbol.css +0 -25
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { InputVariant } from "./input.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
|
|
6
|
+
|
|
7
|
+
//#region src/components/autocomplete.d.ts
|
|
8
|
+
declare const Autocomplete: typeof Autocomplete$1.Root;
|
|
9
|
+
declare const AutocompleteCollection: typeof Autocomplete$1.Collection;
|
|
10
|
+
declare const useAutocompleteFilter: typeof import("@base-ui/react/internals/filter").getFilter;
|
|
11
|
+
declare const useAutocompleteFilteredItems: typeof Autocomplete$1.useFilteredItems;
|
|
12
|
+
declare function AutocompleteInput({
|
|
13
|
+
variant,
|
|
14
|
+
id: idProp,
|
|
15
|
+
className,
|
|
16
|
+
'aria-describedby': ariaDescribedByProp,
|
|
17
|
+
...props
|
|
18
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Input> & {
|
|
19
|
+
variant?: InputVariant;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare function AutocompleteInputGroup({
|
|
22
|
+
className,
|
|
23
|
+
...props
|
|
24
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.InputGroup>): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
declare function AutocompleteClear({
|
|
26
|
+
className,
|
|
27
|
+
children,
|
|
28
|
+
...props
|
|
29
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Clear>): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
declare function AutocompleteTrigger({
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
...props
|
|
34
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Trigger>): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
type AutocompleteContentProps = React$1.ComponentProps<typeof Autocomplete$1.Popup> & Pick<Autocomplete$1.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> & Pick<Autocomplete$1.Portal.Props, 'container'>;
|
|
36
|
+
declare function AutocompleteContent({
|
|
37
|
+
className,
|
|
38
|
+
children,
|
|
39
|
+
align,
|
|
40
|
+
alignOffset,
|
|
41
|
+
side,
|
|
42
|
+
sideOffset,
|
|
43
|
+
container,
|
|
44
|
+
...props
|
|
45
|
+
}: AutocompleteContentProps): import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
declare function AutocompleteList({
|
|
47
|
+
className,
|
|
48
|
+
...props
|
|
49
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.List>): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
declare function AutocompleteItem({
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Item>): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
declare function AutocompleteEmpty({
|
|
55
|
+
className,
|
|
56
|
+
...props
|
|
57
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Empty>): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
declare function AutocompleteStatus({
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Status>): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
declare function AutocompleteGroup({
|
|
63
|
+
className,
|
|
64
|
+
...props
|
|
65
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.Group>): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
declare function AutocompleteGroupLabel({
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React$1.ComponentProps<typeof Autocomplete$1.GroupLabel>): import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
declare function AutocompleteSeparator({
|
|
71
|
+
className,
|
|
72
|
+
...props
|
|
73
|
+
}: React$1.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
//#endregion
|
|
75
|
+
export { Autocomplete, AutocompleteClear, AutocompleteCollection, AutocompleteContent, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteInputGroup, AutocompleteItem, AutocompleteList, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, useAutocompleteFilter, useAutocompleteFilteredItems };
|
|
76
|
+
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { useFieldControl } from "./field.js";
|
|
5
|
+
import { Input } from "./input.js";
|
|
6
|
+
import { InputGroup } from "./input-group.js";
|
|
7
|
+
import * as React$1 from "react";
|
|
8
|
+
import { Close, KeyboardArrowDown } from "@epilot/spark-icons";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Autocomplete as Autocomplete$1 } from "@base-ui/react/autocomplete";
|
|
11
|
+
//#region src/components/autocomplete.tsx
|
|
12
|
+
const Autocomplete = Autocomplete$1.Root;
|
|
13
|
+
const AutocompleteCollection = Autocomplete$1.Collection;
|
|
14
|
+
const useAutocompleteFilter = Autocomplete$1.useFilter;
|
|
15
|
+
const useAutocompleteFilteredItems = Autocomplete$1.useFilteredItems;
|
|
16
|
+
const AutocompleteInputGroupContext = React$1.createContext(false);
|
|
17
|
+
const FOCUS_RING = "focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden";
|
|
18
|
+
const FOCUS_WITHIN_RING = "focus-within:ring-2 focus-within:ring-(--color-focus-root)! focus-within:ring-offset-2";
|
|
19
|
+
function AutocompleteInput({ variant, id: idProp, className, "aria-describedby": ariaDescribedByProp, ...props }) {
|
|
20
|
+
const inGroup = React$1.useContext(AutocompleteInputGroupContext);
|
|
21
|
+
const resolvedVariant = variant ?? (inGroup ? "none" : void 0);
|
|
22
|
+
const { id, ariaDescribedBy, ariaInvalid } = useFieldControl({
|
|
23
|
+
id: typeof idProp === "string" ? idProp : void 0,
|
|
24
|
+
ariaDescribedBy: typeof ariaDescribedByProp === "string" ? ariaDescribedByProp : void 0,
|
|
25
|
+
variant: resolvedVariant !== "none" ? resolvedVariant : void 0
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Input, {
|
|
28
|
+
render: /* @__PURE__ */ jsx(Input, {
|
|
29
|
+
id,
|
|
30
|
+
variant: resolvedVariant
|
|
31
|
+
}),
|
|
32
|
+
id,
|
|
33
|
+
"aria-invalid": ariaInvalid,
|
|
34
|
+
className: cn(!inGroup && FOCUS_RING, className),
|
|
35
|
+
...props,
|
|
36
|
+
"aria-describedby": ariaDescribedBy
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function AutocompleteInputGroup({ className, ...props }) {
|
|
40
|
+
return /* @__PURE__ */ jsx(AutocompleteInputGroupContext.Provider, {
|
|
41
|
+
value: true,
|
|
42
|
+
children: /* @__PURE__ */ jsx(Autocomplete$1.InputGroup, {
|
|
43
|
+
"data-slot": "autocomplete-input-group",
|
|
44
|
+
render: /* @__PURE__ */ jsx(InputGroup, {}),
|
|
45
|
+
className: cn(FOCUS_WITHIN_RING, className),
|
|
46
|
+
...props
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const ICON_BUTTON = "relative inline-flex size-6 shrink-0 items-center justify-center rounded-sm p-0 text-gray-light outline-hidden transition-colors hover:text-gray focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']";
|
|
51
|
+
function AutocompleteClear({ className, children, ...props }) {
|
|
52
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Clear, {
|
|
53
|
+
"data-slot": "autocomplete-clear",
|
|
54
|
+
className: cn(ICON_BUTTON, className),
|
|
55
|
+
...props,
|
|
56
|
+
children: children ?? /* @__PURE__ */ jsx(Close, {
|
|
57
|
+
"aria-hidden": true,
|
|
58
|
+
className: "[--spark-icon-size:14px]"
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function AutocompleteTrigger({ className, children, ...props }) {
|
|
63
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Trigger, {
|
|
64
|
+
"data-slot": "autocomplete-trigger",
|
|
65
|
+
className: cn(ICON_BUTTON, "[&_svg]:transition-transform data-popup-open:[&_svg]:rotate-180 motion-reduce:[&_svg]:transition-none", className),
|
|
66
|
+
...props,
|
|
67
|
+
children: children ?? /* @__PURE__ */ jsx(KeyboardArrowDown, {
|
|
68
|
+
"aria-hidden": true,
|
|
69
|
+
className: "[--spark-icon-size:14px]"
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function AutocompleteContent({ className, children, align = "start", alignOffset, side, sideOffset = 4, container, ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Portal, {
|
|
75
|
+
container,
|
|
76
|
+
children: /* @__PURE__ */ jsx(Autocomplete$1.Positioner, {
|
|
77
|
+
align,
|
|
78
|
+
alignOffset,
|
|
79
|
+
side,
|
|
80
|
+
sideOffset,
|
|
81
|
+
children: /* @__PURE__ */ jsx(Autocomplete$1.Popup, {
|
|
82
|
+
"data-slot": "autocomplete-content",
|
|
83
|
+
className: cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto overscroll-contain rounded-lg border border-gray-a1 bg-gray-1 p-1 text-gray-a12 shadow-lg", "transition-[opacity,scale,translate] duration-100 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none", "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", className),
|
|
84
|
+
...props,
|
|
85
|
+
children
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function AutocompleteList({ className, ...props }) {
|
|
91
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.List, {
|
|
92
|
+
"data-slot": "autocomplete-list",
|
|
93
|
+
className: cn("outline-hidden data-empty:p-0", className),
|
|
94
|
+
...props
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function AutocompleteItem({ className, ...props }) {
|
|
98
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Item, {
|
|
99
|
+
"data-slot": "autocomplete-item",
|
|
100
|
+
className: cn("relative flex w-full cursor-default items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm text-gray outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none", className),
|
|
101
|
+
...props
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function AutocompleteEmpty({ className, ...props }) {
|
|
105
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Empty, {
|
|
106
|
+
"data-slot": "autocomplete-empty",
|
|
107
|
+
className: cn("px-1.5 py-1.5 text-sm text-gray-light empty:p-0", className),
|
|
108
|
+
...props
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function AutocompleteStatus({ className, ...props }) {
|
|
112
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Status, {
|
|
113
|
+
"data-slot": "autocomplete-status",
|
|
114
|
+
className: cn("px-1.5 py-1.5 text-sm text-gray-light empty:p-0", className),
|
|
115
|
+
...props
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function AutocompleteGroup({ className, ...props }) {
|
|
119
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.Group, {
|
|
120
|
+
"data-slot": "autocomplete-group",
|
|
121
|
+
className: cn("scroll-my-1", className),
|
|
122
|
+
...props
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function AutocompleteGroupLabel({ className, ...props }) {
|
|
126
|
+
return /* @__PURE__ */ jsx(Autocomplete$1.GroupLabel, {
|
|
127
|
+
"data-slot": "autocomplete-group-label",
|
|
128
|
+
className: cn("px-1.5 py-1 text-xs text-gray-light", className),
|
|
129
|
+
...props
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function AutocompleteSeparator({ className, ...props }) {
|
|
133
|
+
return /* @__PURE__ */ jsx("div", {
|
|
134
|
+
"aria-hidden": "true",
|
|
135
|
+
"data-slot": "autocomplete-separator",
|
|
136
|
+
className: cn("pointer-events-none -mx-1 my-1 h-px bg-gray-a3", className),
|
|
137
|
+
...props
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
export { Autocomplete, AutocompleteClear, AutocompleteCollection, AutocompleteContent, AutocompleteEmpty, AutocompleteGroup, AutocompleteGroupLabel, AutocompleteInput, AutocompleteInputGroup, AutocompleteItem, AutocompleteList, AutocompleteSeparator, AutocompleteStatus, AutocompleteTrigger, useAutocompleteFilter, useAutocompleteFilteredItems };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.js","names":["AutocompletePrimitive","React"],"sources":["../../src/components/autocomplete.tsx"],"sourcesContent":["'use client'\n\nimport { Autocomplete as AutocompletePrimitive } from '@base-ui/react/autocomplete'\nimport { Close, KeyboardArrowDown } from '@epilot/spark-icons'\nimport * as React from 'react'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\nimport { Input, type InputVariant } from './input'\nimport { InputGroup } from './input-group'\n\nconst Autocomplete = AutocompletePrimitive.Root\nconst AutocompleteCollection = AutocompletePrimitive.Collection\nconst useAutocompleteFilter = AutocompletePrimitive.useFilter\nconst useAutocompleteFilteredItems = AutocompletePrimitive.useFilteredItems\n\nconst AutocompleteInputGroupContext = React.createContext(false)\n\nconst FOCUS_RING =\n 'focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden'\n\nconst FOCUS_WITHIN_RING =\n 'focus-within:ring-2 focus-within:ring-(--color-focus-root)! focus-within:ring-offset-2'\n\nfunction AutocompleteInput({\n variant,\n id: idProp,\n className,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Input> & {\n variant?: InputVariant\n}) {\n const inGroup = React.useContext(AutocompleteInputGroupContext)\n const resolvedVariant = variant ?? (inGroup ? 'none' : undefined)\n const { id, ariaDescribedBy, ariaInvalid } = useFieldControl({\n id: typeof idProp === 'string' ? idProp : undefined,\n ariaDescribedBy:\n typeof ariaDescribedByProp === 'string' ? ariaDescribedByProp : undefined,\n variant: resolvedVariant !== 'none' ? resolvedVariant : undefined,\n })\n return (\n <AutocompletePrimitive.Input\n render={<Input id={id} variant={resolvedVariant} />}\n id={id}\n aria-invalid={ariaInvalid}\n className={cn(!inGroup && FOCUS_RING, className)}\n {...props}\n aria-describedby={ariaDescribedBy}\n />\n )\n}\n\nfunction AutocompleteInputGroup({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.InputGroup>) {\n return (\n <AutocompleteInputGroupContext.Provider value={true}>\n <AutocompletePrimitive.InputGroup\n data-slot=\"autocomplete-input-group\"\n render={<InputGroup />}\n className={cn(FOCUS_WITHIN_RING, className)}\n {...props}\n />\n </AutocompleteInputGroupContext.Provider>\n )\n}\n\nconst ICON_BUTTON =\n \"relative inline-flex size-6 shrink-0 items-center justify-center rounded-sm p-0 text-gray-light outline-hidden transition-colors hover:text-gray focus-visible:ring-2 focus-visible:ring-(--color-focus-root)! focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0 before:absolute before:top-1/2 before:left-1/2 before:size-10 before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']\"\n\nfunction AutocompleteClear({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Clear>) {\n return (\n <AutocompletePrimitive.Clear\n data-slot=\"autocomplete-clear\"\n className={cn(ICON_BUTTON, className)}\n {...props}\n >\n {children ?? <Close aria-hidden className=\"[--spark-icon-size:14px]\" />}\n </AutocompletePrimitive.Clear>\n )\n}\n\nfunction AutocompleteTrigger({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Trigger>) {\n return (\n <AutocompletePrimitive.Trigger\n data-slot=\"autocomplete-trigger\"\n className={cn(\n ICON_BUTTON,\n '[&_svg]:transition-transform data-popup-open:[&_svg]:rotate-180 motion-reduce:[&_svg]:transition-none',\n className,\n )}\n {...props}\n >\n {children ?? (\n <KeyboardArrowDown aria-hidden className=\"[--spark-icon-size:14px]\" />\n )}\n </AutocompletePrimitive.Trigger>\n )\n}\n\ntype AutocompleteContentProps = React.ComponentProps<\n typeof AutocompletePrimitive.Popup\n> &\n Pick<\n AutocompletePrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset'\n > &\n Pick<AutocompletePrimitive.Portal.Props, 'container'>\n\nfunction AutocompleteContent({\n className,\n children,\n align = 'start',\n alignOffset,\n side,\n sideOffset = 4,\n container,\n ...props\n}: AutocompleteContentProps) {\n return (\n <AutocompletePrimitive.Portal container={container}>\n <AutocompletePrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n >\n <AutocompletePrimitive.Popup\n data-slot=\"autocomplete-content\"\n className={cn(\n 'relative isolate z-50 max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto overscroll-contain rounded-lg border border-gray-a1 bg-gray-1 p-1 text-gray-a12 shadow-lg',\n 'transition-[opacity,scale,translate] duration-100 data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',\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 className,\n )}\n {...props}\n >\n {children}\n </AutocompletePrimitive.Popup>\n </AutocompletePrimitive.Positioner>\n </AutocompletePrimitive.Portal>\n )\n}\n\nfunction AutocompleteList({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.List>) {\n return (\n <AutocompletePrimitive.List\n data-slot=\"autocomplete-list\"\n className={cn('outline-hidden data-empty:p-0', className)}\n {...props}\n />\n )\n}\n\nfunction AutocompleteItem({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Item>) {\n return (\n <AutocompletePrimitive.Item\n data-slot=\"autocomplete-item\"\n className={cn(\n 'relative flex w-full cursor-default items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm text-gray outline-hidden transition-colors select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-highlighted:bg-gray-a3 motion-reduce:transition-none',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AutocompleteEmpty({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Empty>) {\n return (\n <AutocompletePrimitive.Empty\n data-slot=\"autocomplete-empty\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AutocompleteStatus({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Status>) {\n return (\n <AutocompletePrimitive.Status\n data-slot=\"autocomplete-status\"\n className={cn(\n 'px-1.5 py-1.5 text-sm text-gray-light empty:p-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AutocompleteGroup({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.Group>) {\n return (\n <AutocompletePrimitive.Group\n data-slot=\"autocomplete-group\"\n className={cn('scroll-my-1', className)}\n {...props}\n />\n )\n}\n\nfunction AutocompleteGroupLabel({\n className,\n ...props\n}: React.ComponentProps<typeof AutocompletePrimitive.GroupLabel>) {\n return (\n <AutocompletePrimitive.GroupLabel\n data-slot=\"autocomplete-group-label\"\n className={cn('px-1.5 py-1 text-xs text-gray-light', className)}\n {...props}\n />\n )\n}\n\nfunction AutocompleteSeparator({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n aria-hidden=\"true\"\n data-slot=\"autocomplete-separator\"\n className={cn(\n 'pointer-events-none -mx-1 my-1 h-px bg-gray-a3',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n Autocomplete,\n AutocompleteClear,\n AutocompleteCollection,\n AutocompleteContent,\n AutocompleteEmpty,\n AutocompleteGroup,\n AutocompleteGroupLabel,\n AutocompleteInput,\n AutocompleteInputGroup,\n AutocompleteItem,\n AutocompleteList,\n AutocompleteSeparator,\n AutocompleteStatus,\n AutocompleteTrigger,\n useAutocompleteFilter,\n useAutocompleteFilteredItems,\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,eAAeA,eAAsB;AAC3C,MAAM,yBAAyBA,eAAsB;AACrD,MAAM,wBAAwBA,eAAsB;AACpD,MAAM,+BAA+BA,eAAsB;AAE3D,MAAM,gCAAgCC,QAAM,cAAc,KAAK;AAE/D,MAAM,aACJ;AAEF,MAAM,oBACJ;AAEF,SAAS,kBAAkB,EACzB,SACA,IAAI,QACJ,WACA,oBAAoB,qBACpB,GAAG,SAGF;CACD,MAAM,UAAUA,QAAM,WAAW,6BAA6B;CAC9D,MAAM,kBAAkB,YAAY,UAAU,SAAS,KAAA;CACvD,MAAM,EAAE,IAAI,iBAAiB,gBAAgB,gBAAgB;EAC3D,IAAI,OAAO,WAAW,WAAW,SAAS,KAAA;EAC1C,iBACE,OAAO,wBAAwB,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I;IAEH;GAC0B,CAAA;EACG,CAAA;CACN,CAAA;AAElC;AAEA,SAAS,iBAAiB,EACxB,WACA,GAAG,SACuD;CAC1D,OACE,oBAACA,eAAsB,MAAvB;EACE,aAAU;EACV,WAAW,GAAG,iCAAiC,SAAS;EACxD,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,iBAAiB,EACxB,WACA,GAAG,SACuD;CAC1D,OACE,oBAACA,eAAsB,MAAvB;EACE,aAAU;EACV,WAAW,GACT,yQACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SACwD;CAC3D,OACE,oBAACA,eAAsB,OAAvB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,mBAAmB,EAC1B,WACA,GAAG,SACyD;CAC5D,OACE,oBAACA,eAAsB,QAAvB;EACE,aAAU;EACV,WAAW,GACT,mDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,kBAAkB,EACzB,WACA,GAAG,SACwD;CAC3D,OACE,oBAACA,eAAsB,OAAvB;EACE,aAAU;EACV,WAAW,GAAG,eAAe,SAAS;EACtC,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,uBAAuB,EAC9B,WACA,GAAG,SAC6D;CAChE,OACE,oBAACA,eAAsB,YAAvB;EACE,aAAU;EACV,WAAW,GAAG,uCAAuC,SAAS;EAC9D,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,sBAAsB,EAC7B,WACA,GAAG,SAC2B;CAC9B,OACE,oBAAC,OAAD;EACE,eAAY;EACZ,aAAU;EACV,WAAW,GACT,kDACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
2
|
import { accentByColor } from "../lib/accent-colors.js";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
|
package/dist/components/badge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
2
|
import { useReducedMotion } from "../hooks/use-reduced-motion.js";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
4
|
import { localeNumberFormat } from "../utils/format.js";
|
|
5
5
|
import { buildYAxisScale, formatYAxisTick, measureYAxisGutter } from "../utils/chart-scale.js";
|
|
6
6
|
import { ChartTooltipCard, clampTooltipPosition, useMeasuredSize } from "./chart.js";
|
|
@@ -4,6 +4,7 @@ const require_components_badge = require("./badge.cjs");
|
|
|
4
4
|
const require_components_icon = require("./icon.cjs");
|
|
5
5
|
const require_components_progress = require("./progress.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
|
+
let _epilot_spark_icons = require("@epilot/spark-icons");
|
|
7
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
9
|
let cnfast = require("cnfast");
|
|
9
10
|
//#region src/components/battery-progress-row.tsx
|
|
@@ -23,25 +24,27 @@ const BatteryProgressRow = ({ className, soc, children, ...rest }) => {
|
|
|
23
24
|
})
|
|
24
25
|
});
|
|
25
26
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const BATTERY_BY_LEVEL = [
|
|
28
|
+
_epilot_spark_icons.Battery0Bar,
|
|
29
|
+
_epilot_spark_icons.Battery1Bar,
|
|
30
|
+
_epilot_spark_icons.Battery2Bar,
|
|
31
|
+
_epilot_spark_icons.Battery3Bar,
|
|
32
|
+
_epilot_spark_icons.Battery4Bar,
|
|
33
|
+
_epilot_spark_icons.Battery5Bar,
|
|
34
|
+
_epilot_spark_icons.Battery6Bar
|
|
35
|
+
];
|
|
34
36
|
const BatteryProgressRowIcon = ({ className, icon: overrideIcon, ...rest }) => {
|
|
35
37
|
const { soc } = useBatteryProgressRowContext();
|
|
36
38
|
const clampedSoc = Math.min(Math.max(soc, 0), 100);
|
|
37
39
|
const batteryLevel = Math.min(Math.floor(clampedSoc / (100 / 7)), 6);
|
|
38
|
-
const
|
|
40
|
+
const fallback = clampedSoc === 100 ? _epilot_spark_icons.BatteryFull : BATTERY_BY_LEVEL[batteryLevel] ?? _epilot_spark_icons.Battery0Bar;
|
|
41
|
+
const Glyph = overrideIcon ?? fallback;
|
|
39
42
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_icon.Icon, {
|
|
40
43
|
...rest,
|
|
41
44
|
className,
|
|
42
45
|
color: "success",
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
size: "large",
|
|
47
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Glyph, {})
|
|
45
48
|
});
|
|
46
49
|
};
|
|
47
50
|
const BatteryProgressRowContent = ({ className, ...rest }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"battery-progress-row.cjs","names":["Icon","Badge","Progress"],"sources":["../../src/components/battery-progress-row.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"battery-progress-row.cjs","names":["Battery0Bar","Battery1Bar","Battery2Bar","Battery3Bar","Battery4Bar","Battery5Bar","Battery6Bar","BatteryFull","Icon","Badge","Progress"],"sources":["../../src/components/battery-progress-row.tsx"],"sourcesContent":["import {\n Battery0Bar,\n Battery1Bar,\n Battery2Bar,\n Battery3Bar,\n Battery4Bar,\n Battery5Bar,\n Battery6Bar,\n BatteryFull,\n type SparkIcon,\n} from '@epilot/spark-icons'\nimport { createContext, useContext } from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\nimport { Badge, type SparkBadgeColor } from './badge'\nimport { Icon } from './icon'\nimport { Progress } from './progress'\n\ninterface BatteryProgressRowContextValue {\n soc: number\n}\n\nconst BatteryProgressRowContext =\n createContext<BatteryProgressRowContextValue | null>(null)\n\nfunction useBatteryProgressRowContext() {\n const context = useContext(BatteryProgressRowContext)\n if (!context) {\n throw new Error(\n 'BatteryProgressRow.* must be rendered inside <BatteryProgressRow>',\n )\n }\n return context\n}\n\nconst BatteryProgressRow = ({\n className,\n soc,\n children,\n ...rest\n}: React.ComponentProps<'div'> & { soc: number }) => {\n return (\n <BatteryProgressRowContext.Provider value={{ soc }}>\n <div className={cn('flex items-center gap-3', className)} {...rest}>\n {children}\n </div>\n </BatteryProgressRowContext.Provider>\n )\n}\n\nconst BATTERY_BY_LEVEL = [\n Battery0Bar,\n Battery1Bar,\n Battery2Bar,\n Battery3Bar,\n Battery4Bar,\n Battery5Bar,\n Battery6Bar,\n] as const\n\nconst BatteryProgressRowIcon = ({\n className,\n icon: overrideIcon,\n ...rest\n}: React.ComponentProps<'span'> & { icon?: SparkIcon }) => {\n const { soc } = useBatteryProgressRowContext()\n const clampedSoc = Math.min(Math.max(soc, 0), 100)\n const batteryLevel = Math.min(Math.floor(clampedSoc / (100 / 7)), 6)\n const fallback: SparkIcon =\n clampedSoc === 100\n ? BatteryFull\n : (BATTERY_BY_LEVEL[batteryLevel] ?? Battery0Bar)\n const Glyph = overrideIcon ?? fallback\n\n return (\n <Icon {...rest} className={className} color=\"success\" size=\"large\">\n <Glyph />\n </Icon>\n )\n}\n\nconst BatteryProgressRowContent = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-1.5', className)}\n {...rest}\n />\n )\n}\n\nconst BatteryProgressRowHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn('flex items-center justify-between gap-2', className)}\n {...rest}\n />\n )\n}\n\nconst toneToBadgeColor: Record<Tone, SparkBadgeColor> = {\n success: 'success',\n warning: 'warning',\n error: 'danger',\n accent: 'accent',\n neutral: 'neutral',\n}\n\nconst BatteryProgressRowStateBadge = ({\n className,\n children,\n tone = 'neutral',\n ...rest\n}: Omit<React.ComponentProps<'span'>, 'color'> & { tone?: Tone }) => {\n if (children === null || children === undefined) return null\n return (\n <Badge\n color={toneToBadgeColor[tone]}\n className={cn('w-fit', className)}\n {...rest}\n >\n {children}\n </Badge>\n )\n}\n\nconst BatteryProgressRowChargingPower = ({\n className,\n children,\n ...rest\n}: React.ComponentProps<'span'>) => {\n if (children === null || children === undefined) return null\n return (\n <span\n className={cn(\n 'ml-auto text-lg leading-tight font-bold text-gray tabular-nums',\n className,\n )}\n {...rest}\n >\n {children}\n </span>\n )\n}\n\n/**\n * Linear progress bar bound to the row's `soc`.\n */\nconst BatteryProgressRowProgressBar = ({\n className,\n ...rest\n}: Omit<React.ComponentProps<typeof Progress>, 'value' | 'max'>) => {\n const { soc } = useBatteryProgressRowContext()\n return <Progress className={className} max={100} value={soc} {...rest} />\n}\n\nconst BatteryProgressRowFooter = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn(\n 'flex justify-between text-xs text-gray-light tabular-nums',\n className,\n )}\n {...rest}\n />\n )\n}\n\nconst BatteryProgressRowMinSoc = ({\n className,\n children,\n ...rest\n}: React.ComponentProps<'span'>) => {\n if (children === null || children === undefined) return null\n return (\n <span className={cn(className)} {...rest}>\n {children}\n </span>\n )\n}\n\n/**\n * Current state-of-charge label, rendered as `{soc}%`. Reads from context.\n */\nconst BatteryProgressRowSoc = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => {\n const { soc } = useBatteryProgressRowContext()\n return (\n <span className={cn(className)} {...rest}>\n {`${soc}%`}\n </span>\n )\n}\n\nexport {\n BatteryProgressRow,\n BatteryProgressRowIcon,\n BatteryProgressRowContent,\n BatteryProgressRowHeader,\n BatteryProgressRowStateBadge,\n BatteryProgressRowChargingPower,\n BatteryProgressRowProgressBar,\n BatteryProgressRowFooter,\n BatteryProgressRowMinSoc,\n BatteryProgressRowSoc,\n}\n"],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,OAAA,IAAc,SAAS;EAAG,GAAI;EACjC;CACG,CAAA;AAEV;;;;AAKA,MAAM,yBAAyB,EAC7B,WACA,GAAG,WAC+B;CAClC,MAAM,EAAE,QAAQ,6BAA6B;CAC7C,OACE,iBAAA,GAAA,kBAAA,KAAC,QAAD;EAAM,YAAA,GAAA,OAAA,IAAc,SAAS;EAAG,GAAI;YACjC,GAAG,IAAI;CACJ,CAAA;AAEV"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { MaterialSymbolIconName } from "../icons/material-symbol.cjs";
|
|
4
3
|
import { Tone } from "../lib/tones.cjs";
|
|
5
4
|
import { Progress } from "./progress.cjs";
|
|
5
|
+
import { SparkIcon } from "@epilot/spark-icons";
|
|
6
6
|
|
|
7
7
|
//#region src/components/battery-progress-row.d.ts
|
|
8
8
|
declare const BatteryProgressRow: ({
|
|
@@ -13,20 +13,12 @@ declare const BatteryProgressRow: ({
|
|
|
13
13
|
}: React.ComponentProps<"div"> & {
|
|
14
14
|
soc: number;
|
|
15
15
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
/**
|
|
17
|
-
* Battery icon. Auto-selects its variant from the row's `soc`.
|
|
18
|
-
*
|
|
19
|
-
* @param className - Optional className to apply to the icon to further style it
|
|
20
|
-
* @param icon - The icon to render (defaults to auto-selecting based on the row's `soc`)
|
|
21
|
-
* @param ...rest - Additional props to pass to the span
|
|
22
|
-
* @returns A React component that renders a battery icon
|
|
23
|
-
*/
|
|
24
16
|
declare const BatteryProgressRowIcon: ({
|
|
25
17
|
className,
|
|
26
18
|
icon: overrideIcon,
|
|
27
19
|
...rest
|
|
28
20
|
}: React.ComponentProps<"span"> & {
|
|
29
|
-
icon?:
|
|
21
|
+
icon?: SparkIcon;
|
|
30
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
31
23
|
declare const BatteryProgressRowContent: ({
|
|
32
24
|
className,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { MaterialSymbolIconName } from "../icons/material-symbol.js";
|
|
4
3
|
import { Tone } from "../lib/tones.js";
|
|
5
4
|
import { Progress } from "./progress.js";
|
|
5
|
+
import { SparkIcon } from "@epilot/spark-icons";
|
|
6
6
|
|
|
7
7
|
//#region src/components/battery-progress-row.d.ts
|
|
8
8
|
declare const BatteryProgressRow: ({
|
|
@@ -13,20 +13,12 @@ declare const BatteryProgressRow: ({
|
|
|
13
13
|
}: React.ComponentProps<"div"> & {
|
|
14
14
|
soc: number;
|
|
15
15
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
/**
|
|
17
|
-
* Battery icon. Auto-selects its variant from the row's `soc`.
|
|
18
|
-
*
|
|
19
|
-
* @param className - Optional className to apply to the icon to further style it
|
|
20
|
-
* @param icon - The icon to render (defaults to auto-selecting based on the row's `soc`)
|
|
21
|
-
* @param ...rest - Additional props to pass to the span
|
|
22
|
-
* @returns A React component that renders a battery icon
|
|
23
|
-
*/
|
|
24
16
|
declare const BatteryProgressRowIcon: ({
|
|
25
17
|
className,
|
|
26
18
|
icon: overrideIcon,
|
|
27
19
|
...rest
|
|
28
20
|
}: React.ComponentProps<"span"> & {
|
|
29
|
-
icon?:
|
|
21
|
+
icon?: SparkIcon;
|
|
30
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
31
23
|
declare const BatteryProgressRowContent: ({
|
|
32
24
|
className,
|
|
@@ -4,6 +4,7 @@ import { Badge } from "./badge.js";
|
|
|
4
4
|
import { Icon } from "./icon.js";
|
|
5
5
|
import { Progress } from "./progress.js";
|
|
6
6
|
import { createContext, useContext } from "react";
|
|
7
|
+
import { Battery0Bar, Battery1Bar, Battery2Bar, Battery3Bar, Battery4Bar, Battery5Bar, Battery6Bar, BatteryFull } from "@epilot/spark-icons";
|
|
7
8
|
import { jsx } from "react/jsx-runtime";
|
|
8
9
|
//#region src/components/battery-progress-row.tsx
|
|
9
10
|
const BatteryProgressRowContext = createContext(null);
|
|
@@ -22,25 +23,27 @@ const BatteryProgressRow = ({ className, soc, children, ...rest }) => {
|
|
|
22
23
|
})
|
|
23
24
|
});
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const BATTERY_BY_LEVEL = [
|
|
27
|
+
Battery0Bar,
|
|
28
|
+
Battery1Bar,
|
|
29
|
+
Battery2Bar,
|
|
30
|
+
Battery3Bar,
|
|
31
|
+
Battery4Bar,
|
|
32
|
+
Battery5Bar,
|
|
33
|
+
Battery6Bar
|
|
34
|
+
];
|
|
33
35
|
const BatteryProgressRowIcon = ({ className, icon: overrideIcon, ...rest }) => {
|
|
34
36
|
const { soc } = useBatteryProgressRowContext();
|
|
35
37
|
const clampedSoc = Math.min(Math.max(soc, 0), 100);
|
|
36
38
|
const batteryLevel = Math.min(Math.floor(clampedSoc / (100 / 7)), 6);
|
|
37
|
-
const
|
|
39
|
+
const fallback = clampedSoc === 100 ? BatteryFull : BATTERY_BY_LEVEL[batteryLevel] ?? Battery0Bar;
|
|
40
|
+
const Glyph = overrideIcon ?? fallback;
|
|
38
41
|
return /* @__PURE__ */ jsx(Icon, {
|
|
39
42
|
...rest,
|
|
40
43
|
className,
|
|
41
44
|
color: "success",
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
size: "large",
|
|
46
|
+
children: /* @__PURE__ */ jsx(Glyph, {})
|
|
44
47
|
});
|
|
45
48
|
};
|
|
46
49
|
const BatteryProgressRowContent = ({ className, ...rest }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"battery-progress-row.js","names":[],"sources":["../../src/components/battery-progress-row.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"battery-progress-row.js","names":[],"sources":["../../src/components/battery-progress-row.tsx"],"sourcesContent":["import {\n Battery0Bar,\n Battery1Bar,\n Battery2Bar,\n Battery3Bar,\n Battery4Bar,\n Battery5Bar,\n Battery6Bar,\n BatteryFull,\n type SparkIcon,\n} from '@epilot/spark-icons'\nimport { createContext, useContext } from 'react'\nimport type { Tone } from '../lib/tones'\nimport { cn } from '../utils/cn'\nimport { Badge, type SparkBadgeColor } from './badge'\nimport { Icon } from './icon'\nimport { Progress } from './progress'\n\ninterface BatteryProgressRowContextValue {\n soc: number\n}\n\nconst BatteryProgressRowContext =\n createContext<BatteryProgressRowContextValue | null>(null)\n\nfunction useBatteryProgressRowContext() {\n const context = useContext(BatteryProgressRowContext)\n if (!context) {\n throw new Error(\n 'BatteryProgressRow.* must be rendered inside <BatteryProgressRow>',\n )\n }\n return context\n}\n\nconst BatteryProgressRow = ({\n className,\n soc,\n children,\n ...rest\n}: React.ComponentProps<'div'> & { soc: number }) => {\n return (\n <BatteryProgressRowContext.Provider value={{ soc }}>\n <div className={cn('flex items-center gap-3', className)} {...rest}>\n {children}\n </div>\n </BatteryProgressRowContext.Provider>\n )\n}\n\nconst BATTERY_BY_LEVEL = [\n Battery0Bar,\n Battery1Bar,\n Battery2Bar,\n Battery3Bar,\n Battery4Bar,\n Battery5Bar,\n Battery6Bar,\n] as const\n\nconst BatteryProgressRowIcon = ({\n className,\n icon: overrideIcon,\n ...rest\n}: React.ComponentProps<'span'> & { icon?: SparkIcon }) => {\n const { soc } = useBatteryProgressRowContext()\n const clampedSoc = Math.min(Math.max(soc, 0), 100)\n const batteryLevel = Math.min(Math.floor(clampedSoc / (100 / 7)), 6)\n const fallback: SparkIcon =\n clampedSoc === 100\n ? BatteryFull\n : (BATTERY_BY_LEVEL[batteryLevel] ?? Battery0Bar)\n const Glyph = overrideIcon ?? fallback\n\n return (\n <Icon {...rest} className={className} color=\"success\" size=\"large\">\n <Glyph />\n </Icon>\n )\n}\n\nconst BatteryProgressRowContent = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn('flex min-w-0 flex-1 flex-col gap-1.5', className)}\n {...rest}\n />\n )\n}\n\nconst BatteryProgressRowHeader = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn('flex items-center justify-between gap-2', className)}\n {...rest}\n />\n )\n}\n\nconst toneToBadgeColor: Record<Tone, SparkBadgeColor> = {\n success: 'success',\n warning: 'warning',\n error: 'danger',\n accent: 'accent',\n neutral: 'neutral',\n}\n\nconst BatteryProgressRowStateBadge = ({\n className,\n children,\n tone = 'neutral',\n ...rest\n}: Omit<React.ComponentProps<'span'>, 'color'> & { tone?: Tone }) => {\n if (children === null || children === undefined) return null\n return (\n <Badge\n color={toneToBadgeColor[tone]}\n className={cn('w-fit', className)}\n {...rest}\n >\n {children}\n </Badge>\n )\n}\n\nconst BatteryProgressRowChargingPower = ({\n className,\n children,\n ...rest\n}: React.ComponentProps<'span'>) => {\n if (children === null || children === undefined) return null\n return (\n <span\n className={cn(\n 'ml-auto text-lg leading-tight font-bold text-gray tabular-nums',\n className,\n )}\n {...rest}\n >\n {children}\n </span>\n )\n}\n\n/**\n * Linear progress bar bound to the row's `soc`.\n */\nconst BatteryProgressRowProgressBar = ({\n className,\n ...rest\n}: Omit<React.ComponentProps<typeof Progress>, 'value' | 'max'>) => {\n const { soc } = useBatteryProgressRowContext()\n return <Progress className={className} max={100} value={soc} {...rest} />\n}\n\nconst BatteryProgressRowFooter = ({\n className,\n ...rest\n}: React.ComponentProps<'div'>) => {\n return (\n <div\n className={cn(\n 'flex justify-between text-xs text-gray-light tabular-nums',\n className,\n )}\n {...rest}\n />\n )\n}\n\nconst BatteryProgressRowMinSoc = ({\n className,\n children,\n ...rest\n}: React.ComponentProps<'span'>) => {\n if (children === null || children === undefined) return null\n return (\n <span className={cn(className)} {...rest}>\n {children}\n </span>\n )\n}\n\n/**\n * Current state-of-charge label, rendered as `{soc}%`. Reads from context.\n */\nconst BatteryProgressRowSoc = ({\n className,\n ...rest\n}: React.ComponentProps<'span'>) => {\n const { soc } = useBatteryProgressRowContext()\n return (\n <span className={cn(className)} {...rest}>\n {`${soc}%`}\n </span>\n )\n}\n\nexport {\n BatteryProgressRow,\n BatteryProgressRowIcon,\n BatteryProgressRowContent,\n BatteryProgressRowHeader,\n BatteryProgressRowStateBadge,\n BatteryProgressRowChargingPower,\n BatteryProgressRowProgressBar,\n BatteryProgressRowFooter,\n BatteryProgressRowMinSoc,\n BatteryProgressRowSoc,\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAM,4BACJ,cAAqD,IAAI;AAE3D,SAAS,+BAA+B;CACtC,MAAM,UAAU,WAAW,yBAAyB;CACpD,IAAI,CAAC,SACH,MAAM,IAAI,MACR,mEACF;CAEF,OAAO;AACT;AAEA,MAAM,sBAAsB,EAC1B,WACA,KACA,UACA,GAAG,WACgD;CACnD,OACE,oBAAC,0BAA0B,UAA3B;EAAoC,OAAO,EAAE,IAAI;YAC/C,oBAAC,OAAD;GAAK,WAAW,GAAG,2BAA2B,SAAS;GAAG,GAAI;GAC3D;EACE,CAAA;CAC6B,CAAA;AAExC;AAEA,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,0BAA0B,EAC9B,WACA,MAAM,cACN,GAAG,WACsD;CACzD,MAAM,EAAE,QAAQ,6BAA6B;CAC7C,MAAM,aAAa,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,GAAG,GAAG;CACjD,MAAM,eAAe,KAAK,IAAI,KAAK,MAAM,cAAc,MAAM,EAAE,GAAG,CAAC;CACnE,MAAM,WACJ,eAAe,MACX,cACC,iBAAiB,iBAAiB;CACzC,MAAM,QAAQ,gBAAgB;CAE9B,OACE,oBAAC,MAAD;EAAM,GAAI;EAAiB;EAAW,OAAM;EAAU,MAAK;YACzD,oBAAC,OAAD,CAAQ,CAAA;CACJ,CAAA;AAEV;AAEA,MAAM,6BAA6B,EACjC,WACA,GAAG,WAC8B;CACjC,OACE,oBAAC,OAAD;EACE,WAAW,GAAG,wCAAwC,SAAS;EAC/D,GAAI;CACL,CA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,GAAI;YACjC,GAAG,IAAI;CACJ,CAAA;AAEV"}
|
package/dist/components/box.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { cn } from "../utils/cn.js";
|
|
3
2
|
import { containerChrome, containerInteractiveClasses, containerPaddingAll, radiusClasses } from "../lib/container-chrome.js";
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
4
|
import { cva } from "class-variance-authority";
|
|
5
5
|
import { mergeProps } from "@base-ui/react/merge-props";
|
|
6
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
@@ -10,7 +10,7 @@ declare function BubbleGroup({
|
|
|
10
10
|
...props
|
|
11
11
|
}: React$1.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
declare const bubbleVariants: (props?: ({
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "secondary" | "destructive" | "default" | "ghost" | "outline" | "muted" | "tinted" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
declare function Bubble({
|
|
16
16
|
variant,
|
|
@@ -10,7 +10,7 @@ declare function BubbleGroup({
|
|
|
10
10
|
...props
|
|
11
11
|
}: React$1.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
declare const bubbleVariants: (props?: ({
|
|
13
|
-
variant?: "
|
|
13
|
+
variant?: "secondary" | "destructive" | "default" | "ghost" | "outline" | "muted" | "tinted" | null | undefined;
|
|
14
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
15
|
declare function Bubble({
|
|
16
16
|
variant,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import { cn } from "../utils/cn.js";
|
|
4
3
|
import { accentByColor } from "../lib/accent-colors.js";
|
|
4
|
+
import { cn } from "../utils/cn.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { Button } from "@base-ui/react/button";
|
|
@@ -25,12 +25,12 @@ const buttonVariants = (0, class_variance_authority.cva)("group/button touch-tar
|
|
|
25
25
|
danger: "focus-visible:ring-base-error-solid"
|
|
26
26
|
},
|
|
27
27
|
size: {
|
|
28
|
-
small: "h-9 px-3 text-sm [&_svg:not([class*=size-])]:size-4",
|
|
29
|
-
default: "h-10 px-3 [&_svg:not([class*=size-])]:size-5",
|
|
30
|
-
medium: "h-11 px-4 [&_svg:not([class*=size-])]:size-6",
|
|
31
|
-
"icon-small": "size-9 [&_svg:not([class*=size-])]:size-4",
|
|
32
|
-
icon: "size-10 [&_svg:not([class*=size-])]:size-5",
|
|
33
|
-
"icon-medium": "size-11 [&_svg:not([class*=size-])]:size-6"
|
|
28
|
+
small: "h-9 px-3 text-sm [--spark-icon-size:16px] [&_svg:not([class*=size-])]:size-4",
|
|
29
|
+
default: "h-10 px-3 [--spark-icon-size:20px] [&_svg:not([class*=size-])]:size-5",
|
|
30
|
+
medium: "h-11 px-4 [--spark-icon-size:24px] [&_svg:not([class*=size-])]:size-6",
|
|
31
|
+
"icon-small": "size-9 [--spark-icon-size:16px] [&_svg:not([class*=size-])]:size-4",
|
|
32
|
+
icon: "size-10 [--spark-icon-size:20px] [&_svg:not([class*=size-])]:size-5",
|
|
33
|
+
"icon-medium": "size-11 [--spark-icon-size:24px] [&_svg:not([class*=size-])]:size-6"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
defaultVariants: { size: "default" }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.cjs","names":["React","ButtonPrimitive","accentByColor"],"sources":["../../src/components/button.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nconst buttonVariants = cva(\n 'group/button touch-target inline-flex cursor-pointer items-center justify-center gap-2 rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))] text-base font-medium whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n primary:\n 'bg-(--spark-style-bg,var(--spark-9)) text-(--spark-style-fg,var(--spark-contrast)) hover:bg-(--spark-style-bg-hover,var(--spark-10))',\n secondary:\n 'bg-gray-2 text-gray-a11 shadow-[inset_0_0_0_1px_var(--neutral-a7)] hover:bg-gray-a3',\n tertiary: 'bg-transparent text-gray-a11 hover:bg-gray-a3',\n bare: 'rounded-none! text-gray-12 outline-hidden!',\n destructive:\n 'bg-red-a3 text-red-a11 hover:bg-red-a4 focus-visible:ring-base-error-solid',\n },\n color: {\n accent: '',\n neutral: '',\n danger: 'focus-visible:ring-base-error-solid',\n },\n size: {\n small
|
|
1
|
+
{"version":3,"file":"button.cjs","names":["React","ButtonPrimitive","accentByColor"],"sources":["../../src/components/button.tsx"],"sourcesContent":["'use client'\n\nimport { Button as ButtonPrimitive } from '@base-ui/react/button'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nconst buttonVariants = cva(\n 'group/button touch-target inline-flex cursor-pointer items-center justify-center gap-2 rounded-[max(var(--spark-rounded-md),var(--spark-rounded-full))] text-base font-medium whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0',\n {\n variants: {\n variant: {\n primary:\n 'bg-(--spark-style-bg,var(--spark-9)) text-(--spark-style-fg,var(--spark-contrast)) hover:bg-(--spark-style-bg-hover,var(--spark-10))',\n secondary:\n 'bg-gray-2 text-gray-a11 shadow-[inset_0_0_0_1px_var(--neutral-a7)] hover:bg-gray-a3',\n tertiary: 'bg-transparent text-gray-a11 hover:bg-gray-a3',\n bare: 'rounded-none! text-gray-12 outline-hidden!',\n destructive:\n 'bg-red-a3 text-red-a11 hover:bg-red-a4 focus-visible:ring-base-error-solid',\n },\n color: {\n accent: '',\n neutral: '',\n danger: 'focus-visible:ring-base-error-solid',\n },\n size: {\n small:\n 'h-9 px-3 text-sm [--spark-icon-size:16px] [&_svg:not([class*=size-])]:size-4',\n default:\n 'h-10 px-3 [--spark-icon-size:20px] [&_svg:not([class*=size-])]:size-5',\n medium:\n 'h-11 px-4 [--spark-icon-size:24px] [&_svg:not([class*=size-])]:size-6',\n 'icon-small':\n 'size-9 [--spark-icon-size:16px] [&_svg:not([class*=size-])]:size-4',\n icon: 'size-10 [--spark-icon-size:20px] [&_svg:not([class*=size-])]:size-5',\n 'icon-medium':\n 'size-11 [--spark-icon-size:24px] [&_svg:not([class*=size-])]:size-6',\n },\n },\n defaultVariants: {\n size: 'default',\n },\n },\n)\n\nconst buttonRecipe =\n 'bg-(--spark-style-bg,var(--spark-9)) text-(--spark-style-fg,var(--spark-contrast)) hover:bg-(--spark-style-bg-hover,var(--spark-10)) shadow-[inset_0_0_0_var(--spark-style-border-width,1px)_var(--spark-style-border,transparent)]'\n\nexport type SparkButtonColor = 'accent' | 'neutral' | 'danger'\n\nexport interface ButtonProps\n extends\n Omit<React.ComponentProps<typeof ButtonPrimitive>, 'ref'>,\n Omit<VariantProps<typeof buttonVariants>, 'variant' | 'color'> {\n styleVariant?: SparkStyle\n color?: SparkButtonColor\n /**\n * @deprecated Not a `<Button>` prop and silently ignored -- use `styleVariant`\n * (`solid | soft | surface | ghost | outline`) and `color`\n * (`accent | neutral | danger`) instead. The `variant` axis on\n * `buttonVariants` exists only for class-string callers.\n */\n variant?: never\n}\n\n// forwardRef keeps refs working for React 18 consumers (ref-as-prop is 19-only)\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n className,\n styleVariant,\n color,\n size,\n render,\n nativeButton,\n variant: _variant,\n ...props\n },\n ref,\n) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n\n return (\n <ButtonPrimitive\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n nativeButton={nativeButton ?? render === undefined}\n render={render}\n className={cn(buttonVariants({ size, color }), buttonRecipe, className)}\n ref={ref}\n {...props}\n />\n )\n})\n\nButton.displayName = 'Button'\n\nexport { Button, buttonVariants }\n"],"mappings":";;;;;;;;;;;;AASA,MAAM,kBAAA,GAAA,yBAAA,KACJ,0dACA;CACE,UAAU;EACR,SAAS;GACP,SACE;GACF,WACE;GACF,UAAU;GACV,MAAM;GACN,aACE;EACJ;EACA,OAAO;GACL,QAAQ;GACR,SAAS;GACT,QAAQ;EACV;EACA,MAAM;GACJ,OACE;GACF,SACE;GACF,QACE;GACF,cACE;GACF,MAAM;GACN,eACE;EACJ;CACF;CACA,iBAAiB,EACf,MAAM,UACR;AACF,CACF;AAEA,MAAM,eACJ;AAoBF,MAAM,SAASA,MAAM,WAA2C,SAAS,OACvE,EACE,WACA,cACA,OACA,MACA,QACA,cACA,SAAS,UACT,GAAG,SAEL,KACA;CAKA,OACE,iBAAA,GAAA,kBAAA,KAACC,sBAAAA,QAAD;EACE,cANY,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;EAMpD,qBALoB,QAAQC,0BAAAA,cAAc,SAAS,KAAA;EAMnD,cAAc,gBAAgB,WAAW,KAAA;EACjC;EACR,YAAA,GAAA,OAAA,IAAc,eAAe;GAAE;GAAM;EAAM,CAAC,GAAG,cAAc,SAAS;EACjE;EACL,GAAI;CACL,CAAA;AAEL,CAAC;AAED,OAAO,cAAc"}
|
|
@@ -7,9 +7,9 @@ import { VariantProps } from "class-variance-authority";
|
|
|
7
7
|
|
|
8
8
|
//#region src/components/button.d.ts
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
|
-
variant?: "
|
|
10
|
+
variant?: "primary" | "secondary" | "tertiary" | "bare" | "destructive" | null | undefined;
|
|
11
11
|
color?: "accent" | "neutral" | "danger" | null | undefined;
|
|
12
|
-
size?: "small" | "default" | "
|
|
12
|
+
size?: "small" | "default" | "medium" | "icon-small" | "icon" | "icon-medium" | null | undefined;
|
|
13
13
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
14
14
|
type SparkButtonColor = 'accent' | 'neutral' | 'danger';
|
|
15
15
|
interface ButtonProps extends Omit<React$1.ComponentProps<typeof Button$1>, 'ref'>, Omit<VariantProps<typeof buttonVariants>, 'variant' | 'color'> {
|