@epilot/spark-ui 1.0.0-alpha.7 → 1.0.0-alpha.9
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/badge.cjs +2 -2
- package/dist/components/badge.cjs.map +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +1 -1
- package/dist/components/battery-progress-row.d.cts +1 -1
- package/dist/components/battery-progress-row.d.ts +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/button.cjs +5 -4
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +4 -17
- package/dist/components/button.d.ts +5 -18
- package/dist/components/button.js +5 -4
- package/dist/components/button.js.map +1 -1
- package/dist/components/callout.cjs +4 -4
- package/dist/components/callout.cjs.map +1 -1
- package/dist/components/callout.d.cts +6 -1
- package/dist/components/callout.d.ts +6 -1
- package/dist/components/callout.js +4 -4
- package/dist/components/callout.js.map +1 -1
- package/dist/components/card.cjs +25 -11
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +6 -0
- package/dist/components/card.d.ts +7 -1
- package/dist/components/card.js +25 -11
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox.cjs +2 -2
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/circular-gauge.d.cts +1 -1
- package/dist/components/circular-gauge.d.ts +1 -1
- package/dist/components/device-card.d.cts +1 -1
- package/dist/components/device-card.d.ts +1 -1
- package/dist/components/empty-state.cjs +9 -2
- package/dist/components/empty-state.cjs.map +1 -1
- package/dist/components/empty-state.d.cts +8 -2
- package/dist/components/empty-state.d.ts +8 -2
- package/dist/components/empty-state.js +10 -2
- package/dist/components/empty-state.js.map +1 -1
- package/dist/components/energy-bar-chart.d.cts +1 -1
- package/dist/components/energy-bar-chart.d.ts +1 -1
- package/dist/components/feed-in-hero.d.cts +1 -1
- package/dist/components/feed-in-hero.d.ts +1 -1
- package/dist/components/field.cjs +3 -3
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +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 +2 -2
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.d.cts +1 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-otp.cjs +10 -10
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input.cjs +10 -10
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/marker.d.cts +1 -1
- package/dist/components/marker.d.ts +1 -1
- package/dist/components/message-scroller.cjs +1 -1
- package/dist/components/message-scroller.cjs.map +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/message-scroller.js.map +1 -1
- package/dist/components/metering-row.d.cts +1 -1
- package/dist/components/metering-row.d.ts +1 -1
- package/dist/components/number-flow.d.cts +1 -1
- package/dist/components/number-flow.d.ts +1 -1
- package/dist/components/page-header.d.cts +1 -1
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/radio.cjs +3 -3
- package/dist/components/radio.cjs.map +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/sankey-chart.d.cts +1 -1
- package/dist/components/sankey-chart.d.ts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/select.cjs +2 -2
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/switch.cjs +2 -2
- package/dist/components/switch.cjs.map +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/theme.cjs +119 -3
- package/dist/components/theme.cjs.map +1 -0
- package/dist/components/theme.d.cts +1 -3
- package/dist/components/theme.d.ts +2 -4
- package/dist/components/theme.js +115 -1
- package/dist/components/theme.js.map +1 -0
- package/dist/components/toast.cjs +158 -65
- package/dist/components/toast.cjs.map +1 -1
- package/dist/components/toast.d.cts +51 -9
- package/dist/components/toast.d.ts +51 -9
- package/dist/components/toast.js +158 -65
- package/dist/components/toast.js.map +1 -1
- package/dist/components/tooltip.cjs +1 -1
- package/dist/components/tooltip.cjs.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/generate-radix-colors-BW09KT9m.d.ts +33 -0
- package/dist/generate-radix-colors-C5mWRWnQ.d.cts +33 -0
- package/dist/{accent-colors-CjHCf8fH.cjs → lib/accent-colors.cjs} +3 -7
- package/dist/lib/accent-colors.cjs.map +1 -0
- package/dist/lib/accent-colors.d.cts +8 -0
- package/dist/lib/accent-colors.d.ts +8 -0
- package/dist/{accent-colors-Ch2J0EEY.js → lib/accent-colors.js} +2 -2
- package/dist/lib/accent-colors.js.map +1 -0
- package/dist/lib/accent-theme.cjs +130 -0
- package/dist/lib/accent-theme.cjs.map +1 -0
- package/dist/lib/accent-theme.d.cts +35 -0
- package/dist/lib/accent-theme.d.ts +35 -0
- package/dist/lib/accent-theme.js +122 -0
- package/dist/lib/accent-theme.js.map +1 -0
- package/dist/{theme-ClRJhexF.cjs → lib/generate-radix-colors.cjs} +12 -240
- package/dist/lib/generate-radix-colors.cjs.map +1 -0
- package/dist/lib/generate-radix-colors.d.cts +4 -0
- package/dist/lib/generate-radix-colors.d.ts +4 -0
- package/dist/{theme-8PDO9E0S.js → lib/generate-radix-colors.js} +8 -225
- package/dist/lib/generate-radix-colors.js.map +1 -0
- package/dist/{input-box-variants-ZCtgs-1S.cjs → lib/input-box-variants.cjs} +5 -14
- package/dist/lib/input-box-variants.cjs.map +1 -0
- package/dist/lib/input-box-variants.d.cts +10 -0
- package/dist/lib/input-box-variants.d.ts +10 -0
- package/dist/{input-box-variants-DcajYXvo.js → lib/input-box-variants.js} +3 -3
- package/dist/lib/input-box-variants.js.map +1 -0
- package/dist/lib/theme-types.cjs +1 -0
- package/dist/lib/theme-types.d.cts +4 -0
- package/dist/lib/theme-types.d.ts +4 -0
- package/dist/lib/theme-types.js +2 -0
- package/dist/lib/tones.cjs +14 -0
- package/dist/lib/tones.cjs.map +1 -0
- package/dist/{tones-PXJGlSpe.d.ts → lib/tones.d.cts} +2 -2
- package/dist/{tones-DjgKOX3s.d.cts → lib/tones.d.ts} +2 -2
- package/dist/lib/tones.js +13 -0
- package/dist/lib/tones.js.map +1 -0
- package/dist/{number-flow-DMJouddg.d.cts → number-flow-CVIvQhZn.d.cts} +1 -1
- package/dist/{number-flow-D9zsxH0-.d.ts → number-flow-DVUHTv9D.d.ts} +1 -1
- package/dist/styles/index.css +158 -0
- package/dist/styles/spark-default.css +1 -0
- package/dist/{theme-types-BDdoRxXa.d.ts → theme-types-BKlzRiyw.d.ts} +1 -1
- package/package.json +18 -3
- package/dist/accent-colors-Ch2J0EEY.js.map +0 -1
- package/dist/accent-colors-CjHCf8fH.cjs.map +0 -1
- package/dist/input-box-variants-DcajYXvo.js.map +0 -1
- package/dist/input-box-variants-ZCtgs-1S.cjs.map +0 -1
- package/dist/theme-8PDO9E0S.js.map +0 -1
- package/dist/theme-ClRJhexF.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { i as SparkInputStyle } from "../theme-types-
|
|
3
|
+
import { i as SparkInputStyle } from "../theme-types-BKlzRiyw.js";
|
|
4
4
|
import * as React$1 from "react";
|
|
5
5
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
6
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { cn } from "../utils/cn.js";
|
|
4
4
|
import { MaterialSymbol } from "../icons/material-symbol.js";
|
|
5
5
|
import { useFieldControl } from "./field.js";
|
|
6
|
-
import {
|
|
6
|
+
import { boxChrome } from "../lib/input-box-variants.js";
|
|
7
7
|
import "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../chunk-aJGBMT86.cjs");
|
|
4
|
-
const
|
|
4
|
+
const require_lib_accent_colors = require("../lib/accent-colors.cjs");
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
let _base_ui_react_switch = require("@base-ui/react/switch");
|
|
7
7
|
let cnfast = require("cnfast");
|
|
8
8
|
//#region src/components/switch.tsx
|
|
9
9
|
function Switch({ className, styleVariant, color, size: _size, variant: _variant, ...props }) {
|
|
10
10
|
const dataStyle = styleVariant !== void 0 || color !== void 0 ? styleVariant ?? "solid" : void 0;
|
|
11
|
-
const dataAccentColor = color ?
|
|
11
|
+
const dataAccentColor = color ? require_lib_accent_colors.accentByColor[color] : void 0;
|
|
12
12
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_switch.Switch.Root, {
|
|
13
13
|
"data-slot": "switch",
|
|
14
14
|
"data-style": dataStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.cjs","names":["accentByColor","SwitchPrimitive"],"sources":["../../src/components/switch.tsx"],"sourcesContent":["import { Switch as SwitchPrimitive } from '@base-ui/react/switch'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type SparkSwitchColor = 'accent' | 'neutral' | 'danger'\n\ntype SwitchProps = SwitchPrimitive.Root.Props & {\n styleVariant?: SparkStyle\n color?: SparkSwitchColor\n /**\n * @deprecated The switch now renders a single size. Accepted for back-compat\n * but ignored.\n */\n size?: 'sm' | 'base' | 'lg'\n /**\n * @deprecated Use `color=\"danger\"` for a destructive/error switch. Accepted\n * for back-compat but ignored.\n */\n variant?: 'primary' | 'destructive'\n}\n\nfunction Switch({\n className,\n styleVariant,\n color,\n size: _size,\n variant: _variant,\n ...props\n}: SwitchProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n return (\n <SwitchPrimitive.Root\n data-slot=\"switch\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n className={cn(\n 'peer relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center p-[2px] transition-colors',\n \"before:absolute before:inset-x-0 before:top-1/2 before:h-10 before:-translate-y-1/2 before:content-['']\",\n 'rounded-(--spark-rounded-xl)',\n 'shadow-[0_1px_2px_0_rgb(0_0_0/0.05),inset_0_0_0_1px_var(--spark-switch-ring,transparent)]',\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n 'data-unchecked:bg-gray-a5 data-unchecked:[--spark-switch-ring:var(--spark-switch-idle-border,transparent)]',\n 'data-checked:bg-(--spark-switch-track,var(--spark-9)) data-checked:[--spark-switch-ring:var(--spark-style-border,transparent)]',\n className,\n )}\n {...props}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n className={cn(\n 'pointer-events-none block size-5 bg-(--spark-switch-thumb,var(--spark-on-solid,#fff)) shadow-xs transition-transform',\n 'rounded-(--spark-rounded-lg)',\n 'data-checked:translate-x-4 data-unchecked:translate-x-0',\n )}\n />\n </SwitchPrimitive.Root>\n )\n}\n\nexport { Switch }\nexport type { SwitchProps }\n"],"mappings":";;;;;;;;AAsBA,SAAS,OAAO,EACd,WACA,cACA,OACA,MAAM,OACN,SAAS,UACT,GAAG,SACW;CAEd,MAAM,YADU,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;CACxD,MAAM,kBAAkB,QAAQA,
|
|
1
|
+
{"version":3,"file":"switch.cjs","names":["accentByColor","SwitchPrimitive"],"sources":["../../src/components/switch.tsx"],"sourcesContent":["import { Switch as SwitchPrimitive } from '@base-ui/react/switch'\nimport { accentByColor } from '../lib/accent-colors'\nimport type { SparkStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type SparkSwitchColor = 'accent' | 'neutral' | 'danger'\n\ntype SwitchProps = SwitchPrimitive.Root.Props & {\n styleVariant?: SparkStyle\n color?: SparkSwitchColor\n /**\n * @deprecated The switch now renders a single size. Accepted for back-compat\n * but ignored.\n */\n size?: 'sm' | 'base' | 'lg'\n /**\n * @deprecated Use `color=\"danger\"` for a destructive/error switch. Accepted\n * for back-compat but ignored.\n */\n variant?: 'primary' | 'destructive'\n}\n\nfunction Switch({\n className,\n styleVariant,\n color,\n size: _size,\n variant: _variant,\n ...props\n}: SwitchProps) {\n const hasLook = styleVariant !== undefined || color !== undefined\n const dataStyle = hasLook ? (styleVariant ?? 'solid') : undefined\n const dataAccentColor = color ? accentByColor[color] : undefined\n return (\n <SwitchPrimitive.Root\n data-slot=\"switch\"\n data-style={dataStyle}\n data-accent-color={dataAccentColor}\n className={cn(\n 'peer relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center p-[2px] transition-colors',\n \"before:absolute before:inset-x-0 before:top-1/2 before:h-10 before:-translate-y-1/2 before:content-['']\",\n 'rounded-(--spark-rounded-xl)',\n 'shadow-[0_1px_2px_0_rgb(0_0_0/0.05),inset_0_0_0_1px_var(--spark-switch-ring,transparent)]',\n 'focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',\n 'data-disabled:pointer-events-none data-disabled:opacity-50',\n 'data-unchecked:bg-gray-a5 data-unchecked:[--spark-switch-ring:var(--spark-switch-idle-border,transparent)]',\n 'data-checked:bg-(--spark-switch-track,var(--spark-9)) data-checked:[--spark-switch-ring:var(--spark-style-border,transparent)]',\n className,\n )}\n {...props}\n >\n <SwitchPrimitive.Thumb\n data-slot=\"switch-thumb\"\n className={cn(\n 'pointer-events-none block size-5 bg-(--spark-switch-thumb,var(--spark-on-solid,#fff)) shadow-xs transition-transform',\n 'rounded-(--spark-rounded-lg)',\n 'data-checked:translate-x-4 data-unchecked:translate-x-0',\n )}\n />\n </SwitchPrimitive.Root>\n )\n}\n\nexport { Switch }\nexport type { SwitchProps }\n"],"mappings":";;;;;;;;AAsBA,SAAS,OAAO,EACd,WACA,cACA,OACA,MAAM,OACN,SAAS,UACT,GAAG,SACW;CAEd,MAAM,YADU,iBAAiB,KAAA,KAAa,UAAU,KAAA,IAC3B,gBAAgB,UAAW,KAAA;CACxD,MAAM,kBAAkB,QAAQA,0BAAAA,cAAc,SAAS,KAAA;AACvD,QACE,iBAAA,GAAA,kBAAA,KAACC,sBAAAA,OAAgB,MAAjB;EACE,aAAU;EACV,cAAY;EACZ,qBAAmB;EACnB,YAAA,GAAA,OAAA,IACE,qGACA,2GACA,gCACA,6FACA,iFACA,8DACA,8GACA,kIACA,UACD;EACD,GAAI;YAEJ,iBAAA,GAAA,kBAAA,KAACA,sBAAAA,OAAgB,OAAjB;GACE,aAAU;GACV,YAAA,GAAA,OAAA,IACE,wHACA,gCACA,0DACD;GACD,CAAA;EACmB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { u as SparkStyle } from "../theme-types-
|
|
3
|
+
import { u as SparkStyle } from "../theme-types-BKlzRiyw.js";
|
|
4
4
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
5
|
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../utils/cn.js";
|
|
3
|
-
import {
|
|
3
|
+
import { accentByColor } from "../lib/accent-colors.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import { Switch as Switch$1 } from "@base-ui/react/switch";
|
|
6
6
|
//#region src/components/switch.tsx
|
|
@@ -1,6 +1,122 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const require_chunk = require("../chunk-aJGBMT86.cjs");
|
|
5
|
+
const require_lib_accent_theme = require("../lib/accent-theme.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
react = require_chunk.__toESM(react);
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let _base_ui_react_merge_props = require("@base-ui/react/merge-props");
|
|
10
|
+
let _base_ui_react_use_render = require("@base-ui/react/use-render");
|
|
11
|
+
let cnfast = require("cnfast");
|
|
12
|
+
//#region src/components/theme.tsx
|
|
13
|
+
const ThemeContext = react.createContext({});
|
|
14
|
+
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
15
|
+
function useTheme() {
|
|
16
|
+
return react.useContext(ThemeContext);
|
|
17
|
+
}
|
|
18
|
+
/** Optional sugar: writes the theming `data-*` attrs + accent `--spark-*` vars onto a wrapper. */
|
|
19
|
+
const Theme = react.forwardRef(function Theme({ accentColor, neutralColor, radius, scaling, spacing, styleVariant, highContrast, labelPosition, inputStyle, inputColor, cardVariant, cardColor, appearance, render, className, style, children, ...rest }, ref) {
|
|
20
|
+
const parent = useTheme();
|
|
21
|
+
const value = react.useMemo(() => ({
|
|
22
|
+
accentColor: accentColor ?? parent.accentColor,
|
|
23
|
+
neutralColor: neutralColor ?? parent.neutralColor,
|
|
24
|
+
radius: radius ?? parent.radius,
|
|
25
|
+
scaling: scaling ?? parent.scaling,
|
|
26
|
+
spacing: spacing ?? parent.spacing,
|
|
27
|
+
styleVariant: styleVariant ?? parent.styleVariant,
|
|
28
|
+
highContrast: highContrast ?? parent.highContrast,
|
|
29
|
+
labelPosition: labelPosition ?? parent.labelPosition,
|
|
30
|
+
inputStyle: inputStyle ?? parent.inputStyle,
|
|
31
|
+
inputColor: inputColor ?? parent.inputColor,
|
|
32
|
+
cardVariant: cardVariant ?? parent.cardVariant,
|
|
33
|
+
cardColor: cardColor ?? parent.cardColor,
|
|
34
|
+
appearance: appearance ?? parent.appearance
|
|
35
|
+
}), [
|
|
36
|
+
accentColor,
|
|
37
|
+
neutralColor,
|
|
38
|
+
radius,
|
|
39
|
+
scaling,
|
|
40
|
+
spacing,
|
|
41
|
+
styleVariant,
|
|
42
|
+
highContrast,
|
|
43
|
+
labelPosition,
|
|
44
|
+
inputStyle,
|
|
45
|
+
inputColor,
|
|
46
|
+
cardVariant,
|
|
47
|
+
cardColor,
|
|
48
|
+
appearance,
|
|
49
|
+
parent
|
|
50
|
+
]);
|
|
51
|
+
const scopeId = react.useId();
|
|
52
|
+
const accent = react.useMemo(() => {
|
|
53
|
+
const empty = {
|
|
54
|
+
inlineVars: {},
|
|
55
|
+
css: "",
|
|
56
|
+
scoped: false
|
|
57
|
+
};
|
|
58
|
+
if (!accentColor) return empty;
|
|
59
|
+
const toVars = (decls) => Object.fromEntries(decls.filter((decl) => decl.includes(":")).map((decl) => {
|
|
60
|
+
const i = decl.indexOf(":");
|
|
61
|
+
return [decl.slice(0, i).trim(), decl.slice(i + 1).replace(/;$/, "").trim()];
|
|
62
|
+
}));
|
|
63
|
+
try {
|
|
64
|
+
const hex = require_lib_accent_theme.CURATED_ACCENTS[accentColor] ?? accentColor;
|
|
65
|
+
if (value.appearance) return {
|
|
66
|
+
inlineVars: toVars(require_lib_accent_theme.accentSparkVars(require_lib_accent_theme.generateAccentScale(hex, value.appearance))),
|
|
67
|
+
css: "",
|
|
68
|
+
scoped: false
|
|
69
|
+
};
|
|
70
|
+
const light = require_lib_accent_theme.accentSparkVars(require_lib_accent_theme.generateAccentScale(hex, "light"));
|
|
71
|
+
const dark = require_lib_accent_theme.accentSparkVars(require_lib_accent_theme.generateAccentScale(hex, "dark"));
|
|
72
|
+
const sel = `[data-spark-scope="${scopeId}"]`;
|
|
73
|
+
return {
|
|
74
|
+
inlineVars: {},
|
|
75
|
+
css: `${sel}{${light.join("")}}:is(.dark,.dark-theme) ${sel}{${dark.join("")}}`,
|
|
76
|
+
scoped: true
|
|
77
|
+
};
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.warn(`[Theme] Ignoring invalid accentColor "${accentColor}".`, error);
|
|
80
|
+
return empty;
|
|
81
|
+
}
|
|
82
|
+
}, [
|
|
83
|
+
accentColor,
|
|
84
|
+
value.appearance,
|
|
85
|
+
scopeId
|
|
86
|
+
]);
|
|
87
|
+
const resolvedNeutralColor = neutralColor === "auto" ? require_lib_accent_theme.getMatchingNeutral(value.accentColor ?? "#005EB4") : neutralColor;
|
|
88
|
+
const element = (0, _base_ui_react_use_render.useRender)({
|
|
89
|
+
defaultTagName: "div",
|
|
90
|
+
render,
|
|
91
|
+
ref,
|
|
92
|
+
props: (0, _base_ui_react_merge_props.mergeProps)({
|
|
93
|
+
className: (0, cnfast.cn)("spark-theme", appearance, className),
|
|
94
|
+
"data-neutral-color": resolvedNeutralColor,
|
|
95
|
+
"data-radius": radius,
|
|
96
|
+
"data-scaling": scaling,
|
|
97
|
+
"data-spacing": spacing,
|
|
98
|
+
"data-style": styleVariant,
|
|
99
|
+
"data-high-contrast": highContrast ? "" : void 0,
|
|
100
|
+
"data-label-position": labelPosition,
|
|
101
|
+
"data-input-style": inputStyle,
|
|
102
|
+
"data-input-color": inputColor,
|
|
103
|
+
"data-card-variant": cardVariant,
|
|
104
|
+
"data-card-color": cardColor === "accent" ? "accent" : void 0,
|
|
105
|
+
"data-spark-scope": accent.scoped ? scopeId : void 0,
|
|
106
|
+
style: {
|
|
107
|
+
...accent.inlineVars,
|
|
108
|
+
...style
|
|
109
|
+
},
|
|
110
|
+
children
|
|
111
|
+
}, rest)
|
|
112
|
+
});
|
|
113
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ThemeContext.Provider, {
|
|
114
|
+
value,
|
|
115
|
+
children: [accent.css ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: accent.css }) : null, element]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
//#endregion
|
|
119
|
+
exports.Theme = Theme;
|
|
120
|
+
exports.useTheme = useTheme;
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=theme.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.cjs","names":["React","CURATED_ACCENTS","accentSparkVars","generateAccentScale","getMatchingNeutral"],"sources":["../../src/components/theme.tsx"],"sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport {\n CURATED_ACCENTS,\n accentSparkVars,\n generateAccentScale,\n getMatchingNeutral,\n type Appearance,\n} from '../lib/accent-theme'\nimport type {\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type {\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\n\nexport interface ThemeValue {\n /** Curated accent name or a custom hex. */\n accentColor?: string\n /** A neutral name, or `'auto'` to pair one with the accent (Radix's `grayColor=\"auto\"`). */\n neutralColor?: SparkNeutral\n radius?: SparkRadius\n scaling?: SparkScaling\n spacing?: SparkSpacing\n styleVariant?: SparkStyle\n /** Orthogonal to `styleVariant`: shifts any style toward higher-contrast steps. */\n highContrast?: boolean\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n /** App-level default `<Card>` chrome; a per-card `variant` prop overrides it. */\n cardVariant?: SparkCardVariant\n /** App-level default `<Card>` palette; a per-card `color` prop overrides it. */\n cardColor?: SparkCardColor\n appearance?: Appearance\n}\n\nconst ThemeContext = React.createContext<ThemeValue>({})\n\n/** Merged theme values from enclosing `<Theme>` providers. */\nexport function useTheme(): ThemeValue {\n return React.useContext(ThemeContext)\n}\n\nexport interface ThemeProps\n extends useRender.ComponentProps<'div'>, ThemeValue {}\n\n/** Optional sugar: writes the theming `data-*` attrs + accent `--spark-*` vars onto a wrapper. */\nexport const Theme = React.forwardRef<HTMLDivElement, ThemeProps>(\n function Theme(\n {\n accentColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n appearance,\n render,\n className,\n style,\n children,\n ...rest\n },\n ref,\n ) {\n const parent = useTheme()\n\n const value = React.useMemo<ThemeValue>(\n () => ({\n accentColor: accentColor ?? parent.accentColor,\n neutralColor: neutralColor ?? parent.neutralColor,\n radius: radius ?? parent.radius,\n scaling: scaling ?? parent.scaling,\n spacing: spacing ?? parent.spacing,\n styleVariant: styleVariant ?? parent.styleVariant,\n highContrast: highContrast ?? parent.highContrast,\n labelPosition: labelPosition ?? parent.labelPosition,\n inputStyle: inputStyle ?? parent.inputStyle,\n inputColor: inputColor ?? parent.inputColor,\n cardVariant: cardVariant ?? parent.cardVariant,\n cardColor: cardColor ?? parent.cardColor,\n appearance: appearance ?? parent.appearance,\n }),\n [\n accentColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n appearance,\n parent,\n ],\n )\n\n // Scope id for the ambient-appearance case (both scales emitted in a <style>).\n const scopeId = React.useId()\n\n const accent = React.useMemo(() => {\n const empty = {\n inlineVars: {} as React.CSSProperties,\n css: '',\n scoped: false,\n }\n if (!accentColor) return empty\n\n const toVars = (decls: string[]) =>\n Object.fromEntries(\n decls\n .filter((decl) => decl.includes(':'))\n .map((decl) => {\n const i = decl.indexOf(':')\n return [\n decl.slice(0, i).trim(),\n decl\n .slice(i + 1)\n .replace(/;$/, '')\n .trim(),\n ]\n }),\n ) as React.CSSProperties\n\n try {\n const hex = CURATED_ACCENTS[accentColor] ?? accentColor\n\n // Explicit appearance → single-scale inline vars. Correct for a light\n // island inside a dark page (which must NOT pick up the dark scale).\n if (value.appearance) {\n return {\n inlineVars: toVars(\n accentSparkVars(generateAccentScale(hex, value.appearance)),\n ),\n css: '',\n scoped: false,\n }\n }\n\n // Ambient appearance → emit BOTH scales in a scoped <style> so the\n // `.dark` class selects the right one. Without this, a single-appearance\n // inline scale (default light) breaks components in dark mode.\n const light = accentSparkVars(generateAccentScale(hex, 'light'))\n const dark = accentSparkVars(generateAccentScale(hex, 'dark'))\n const sel = `[data-spark-scope=\"${scopeId}\"]`\n const css = `${sel}{${light.join('')}}:is(.dark,.dark-theme) ${sel}{${dark.join('')}}`\n return { inlineVars: {} as React.CSSProperties, css, scoped: true }\n } catch (error) {\n // A bad accentColor must not throw through render — fall back to the default theme.\n console.warn(\n `[Theme] Ignoring invalid accentColor \"${accentColor}\".`,\n error,\n )\n return empty\n }\n }, [accentColor, value.appearance, scopeId])\n\n // 'auto' pairs a neutral with the effective accent (Radix's grayColor=\"auto\").\n const resolvedNeutralColor =\n neutralColor === 'auto'\n ? getMatchingNeutral(value.accentColor ?? '#005EB4')\n : neutralColor\n\n const element = useRender({\n defaultTagName: 'div',\n render,\n ref,\n props: mergeProps<'div'>(\n {\n className: cn('spark-theme', appearance, className),\n 'data-neutral-color': resolvedNeutralColor,\n 'data-radius': radius,\n 'data-scaling': scaling,\n 'data-spacing': spacing,\n 'data-style': styleVariant,\n 'data-high-contrast': highContrast ? '' : undefined,\n 'data-label-position': labelPosition,\n 'data-input-style': inputStyle,\n 'data-input-color': inputColor,\n 'data-card-variant': cardVariant,\n 'data-card-color': cardColor === 'accent' ? 'accent' : undefined,\n 'data-spark-scope': accent.scoped ? scopeId : undefined,\n style: { ...accent.inlineVars, ...style },\n children,\n } as React.ComponentProps<'div'>,\n rest,\n ),\n })\n\n return (\n <ThemeContext.Provider value={value}>\n {accent.css ? <style>{accent.css}</style> : null}\n {element}\n </ThemeContext.Provider>\n )\n },\n)\n"],"mappings":"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"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { a as SparkLabelPosition, c as SparkScaling, i as SparkInputStyle, l as SparkSpacing, n as SparkCardVariant, o as SparkNeutral, r as SparkInputColor, s as SparkRadius, t as SparkCardColor, u as SparkStyle } from "../theme-types-BwSJKdsB.cjs";
|
|
4
|
+
import { Appearance } from "../lib/accent-theme.cjs";
|
|
4
5
|
import * as React$1 from "react";
|
|
5
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
6
7
|
|
|
7
|
-
//#region src/lib/accent-theme.d.ts
|
|
8
|
-
type Appearance = 'light' | 'dark';
|
|
9
|
-
//#endregion
|
|
10
8
|
//#region src/components/theme.d.ts
|
|
11
9
|
interface ThemeValue {
|
|
12
10
|
/** Curated accent name or a custom hex. */
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { a as SparkLabelPosition, c as SparkScaling, i as SparkInputStyle, l as SparkSpacing, n as SparkCardVariant, o as SparkNeutral, r as SparkInputColor, s as SparkRadius, t as SparkCardColor, u as SparkStyle } from "../theme-types-
|
|
3
|
+
import { a as SparkLabelPosition, c as SparkScaling, i as SparkInputStyle, l as SparkSpacing, n as SparkCardVariant, o as SparkNeutral, r as SparkInputColor, s as SparkRadius, t as SparkCardColor, u as SparkStyle } from "../theme-types-BKlzRiyw.js";
|
|
4
|
+
import { Appearance } from "../lib/accent-theme.js";
|
|
4
5
|
import * as React$1 from "react";
|
|
5
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
6
7
|
|
|
7
|
-
//#region src/lib/accent-theme.d.ts
|
|
8
|
-
type Appearance = 'light' | 'dark';
|
|
9
|
-
//#endregion
|
|
10
8
|
//#region src/components/theme.d.ts
|
|
11
9
|
interface ThemeValue {
|
|
12
10
|
/** Curated accent name or a custom hex. */
|
package/dist/components/theme.js
CHANGED
|
@@ -1,4 +1,118 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "../utils/cn.js";
|
|
4
|
+
import { CURATED_ACCENTS, accentSparkVars, generateAccentScale, getMatchingNeutral } from "../lib/accent-theme.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
8
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
9
|
+
//#region src/components/theme.tsx
|
|
10
|
+
const ThemeContext = React$1.createContext({});
|
|
11
|
+
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
12
|
+
function useTheme() {
|
|
13
|
+
return React$1.useContext(ThemeContext);
|
|
14
|
+
}
|
|
15
|
+
/** Optional sugar: writes the theming `data-*` attrs + accent `--spark-*` vars onto a wrapper. */
|
|
16
|
+
const Theme = React$1.forwardRef(function Theme({ accentColor, neutralColor, radius, scaling, spacing, styleVariant, highContrast, labelPosition, inputStyle, inputColor, cardVariant, cardColor, appearance, render, className, style, children, ...rest }, ref) {
|
|
17
|
+
const parent = useTheme();
|
|
18
|
+
const value = React$1.useMemo(() => ({
|
|
19
|
+
accentColor: accentColor ?? parent.accentColor,
|
|
20
|
+
neutralColor: neutralColor ?? parent.neutralColor,
|
|
21
|
+
radius: radius ?? parent.radius,
|
|
22
|
+
scaling: scaling ?? parent.scaling,
|
|
23
|
+
spacing: spacing ?? parent.spacing,
|
|
24
|
+
styleVariant: styleVariant ?? parent.styleVariant,
|
|
25
|
+
highContrast: highContrast ?? parent.highContrast,
|
|
26
|
+
labelPosition: labelPosition ?? parent.labelPosition,
|
|
27
|
+
inputStyle: inputStyle ?? parent.inputStyle,
|
|
28
|
+
inputColor: inputColor ?? parent.inputColor,
|
|
29
|
+
cardVariant: cardVariant ?? parent.cardVariant,
|
|
30
|
+
cardColor: cardColor ?? parent.cardColor,
|
|
31
|
+
appearance: appearance ?? parent.appearance
|
|
32
|
+
}), [
|
|
33
|
+
accentColor,
|
|
34
|
+
neutralColor,
|
|
35
|
+
radius,
|
|
36
|
+
scaling,
|
|
37
|
+
spacing,
|
|
38
|
+
styleVariant,
|
|
39
|
+
highContrast,
|
|
40
|
+
labelPosition,
|
|
41
|
+
inputStyle,
|
|
42
|
+
inputColor,
|
|
43
|
+
cardVariant,
|
|
44
|
+
cardColor,
|
|
45
|
+
appearance,
|
|
46
|
+
parent
|
|
47
|
+
]);
|
|
48
|
+
const scopeId = React$1.useId();
|
|
49
|
+
const accent = React$1.useMemo(() => {
|
|
50
|
+
const empty = {
|
|
51
|
+
inlineVars: {},
|
|
52
|
+
css: "",
|
|
53
|
+
scoped: false
|
|
54
|
+
};
|
|
55
|
+
if (!accentColor) return empty;
|
|
56
|
+
const toVars = (decls) => Object.fromEntries(decls.filter((decl) => decl.includes(":")).map((decl) => {
|
|
57
|
+
const i = decl.indexOf(":");
|
|
58
|
+
return [decl.slice(0, i).trim(), decl.slice(i + 1).replace(/;$/, "").trim()];
|
|
59
|
+
}));
|
|
60
|
+
try {
|
|
61
|
+
const hex = CURATED_ACCENTS[accentColor] ?? accentColor;
|
|
62
|
+
if (value.appearance) return {
|
|
63
|
+
inlineVars: toVars(accentSparkVars(generateAccentScale(hex, value.appearance))),
|
|
64
|
+
css: "",
|
|
65
|
+
scoped: false
|
|
66
|
+
};
|
|
67
|
+
const light = accentSparkVars(generateAccentScale(hex, "light"));
|
|
68
|
+
const dark = accentSparkVars(generateAccentScale(hex, "dark"));
|
|
69
|
+
const sel = `[data-spark-scope="${scopeId}"]`;
|
|
70
|
+
return {
|
|
71
|
+
inlineVars: {},
|
|
72
|
+
css: `${sel}{${light.join("")}}:is(.dark,.dark-theme) ${sel}{${dark.join("")}}`,
|
|
73
|
+
scoped: true
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.warn(`[Theme] Ignoring invalid accentColor "${accentColor}".`, error);
|
|
77
|
+
return empty;
|
|
78
|
+
}
|
|
79
|
+
}, [
|
|
80
|
+
accentColor,
|
|
81
|
+
value.appearance,
|
|
82
|
+
scopeId
|
|
83
|
+
]);
|
|
84
|
+
const resolvedNeutralColor = neutralColor === "auto" ? getMatchingNeutral(value.accentColor ?? "#005EB4") : neutralColor;
|
|
85
|
+
const element = useRender({
|
|
86
|
+
defaultTagName: "div",
|
|
87
|
+
render,
|
|
88
|
+
ref,
|
|
89
|
+
props: mergeProps({
|
|
90
|
+
className: cn("spark-theme", appearance, className),
|
|
91
|
+
"data-neutral-color": resolvedNeutralColor,
|
|
92
|
+
"data-radius": radius,
|
|
93
|
+
"data-scaling": scaling,
|
|
94
|
+
"data-spacing": spacing,
|
|
95
|
+
"data-style": styleVariant,
|
|
96
|
+
"data-high-contrast": highContrast ? "" : void 0,
|
|
97
|
+
"data-label-position": labelPosition,
|
|
98
|
+
"data-input-style": inputStyle,
|
|
99
|
+
"data-input-color": inputColor,
|
|
100
|
+
"data-card-variant": cardVariant,
|
|
101
|
+
"data-card-color": cardColor === "accent" ? "accent" : void 0,
|
|
102
|
+
"data-spark-scope": accent.scoped ? scopeId : void 0,
|
|
103
|
+
style: {
|
|
104
|
+
...accent.inlineVars,
|
|
105
|
+
...style
|
|
106
|
+
},
|
|
107
|
+
children
|
|
108
|
+
}, rest)
|
|
109
|
+
});
|
|
110
|
+
return /* @__PURE__ */ jsxs(ThemeContext.Provider, {
|
|
111
|
+
value,
|
|
112
|
+
children: [accent.css ? /* @__PURE__ */ jsx("style", { children: accent.css }) : null, element]
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
//#endregion
|
|
4
116
|
export { Theme, useTheme };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","names":["React"],"sources":["../../src/components/theme.tsx"],"sourcesContent":["'use client'\n\nimport { mergeProps } from '@base-ui/react/merge-props'\nimport { useRender } from '@base-ui/react/use-render'\nimport * as React from 'react'\nimport {\n CURATED_ACCENTS,\n accentSparkVars,\n generateAccentScale,\n getMatchingNeutral,\n type Appearance,\n} from '../lib/accent-theme'\nimport type {\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type {\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\n\nexport interface ThemeValue {\n /** Curated accent name or a custom hex. */\n accentColor?: string\n /** A neutral name, or `'auto'` to pair one with the accent (Radix's `grayColor=\"auto\"`). */\n neutralColor?: SparkNeutral\n radius?: SparkRadius\n scaling?: SparkScaling\n spacing?: SparkSpacing\n styleVariant?: SparkStyle\n /** Orthogonal to `styleVariant`: shifts any style toward higher-contrast steps. */\n highContrast?: boolean\n labelPosition?: SparkLabelPosition\n inputStyle?: SparkInputStyle\n inputColor?: SparkInputColor\n /** App-level default `<Card>` chrome; a per-card `variant` prop overrides it. */\n cardVariant?: SparkCardVariant\n /** App-level default `<Card>` palette; a per-card `color` prop overrides it. */\n cardColor?: SparkCardColor\n appearance?: Appearance\n}\n\nconst ThemeContext = React.createContext<ThemeValue>({})\n\n/** Merged theme values from enclosing `<Theme>` providers. */\nexport function useTheme(): ThemeValue {\n return React.useContext(ThemeContext)\n}\n\nexport interface ThemeProps\n extends useRender.ComponentProps<'div'>, ThemeValue {}\n\n/** Optional sugar: writes the theming `data-*` attrs + accent `--spark-*` vars onto a wrapper. */\nexport const Theme = React.forwardRef<HTMLDivElement, ThemeProps>(\n function Theme(\n {\n accentColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n appearance,\n render,\n className,\n style,\n children,\n ...rest\n },\n ref,\n ) {\n const parent = useTheme()\n\n const value = React.useMemo<ThemeValue>(\n () => ({\n accentColor: accentColor ?? parent.accentColor,\n neutralColor: neutralColor ?? parent.neutralColor,\n radius: radius ?? parent.radius,\n scaling: scaling ?? parent.scaling,\n spacing: spacing ?? parent.spacing,\n styleVariant: styleVariant ?? parent.styleVariant,\n highContrast: highContrast ?? parent.highContrast,\n labelPosition: labelPosition ?? parent.labelPosition,\n inputStyle: inputStyle ?? parent.inputStyle,\n inputColor: inputColor ?? parent.inputColor,\n cardVariant: cardVariant ?? parent.cardVariant,\n cardColor: cardColor ?? parent.cardColor,\n appearance: appearance ?? parent.appearance,\n }),\n [\n accentColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n appearance,\n parent,\n ],\n )\n\n // Scope id for the ambient-appearance case (both scales emitted in a <style>).\n const scopeId = React.useId()\n\n const accent = React.useMemo(() => {\n const empty = {\n inlineVars: {} as React.CSSProperties,\n css: '',\n scoped: false,\n }\n if (!accentColor) return empty\n\n const toVars = (decls: string[]) =>\n Object.fromEntries(\n decls\n .filter((decl) => decl.includes(':'))\n .map((decl) => {\n const i = decl.indexOf(':')\n return [\n decl.slice(0, i).trim(),\n decl\n .slice(i + 1)\n .replace(/;$/, '')\n .trim(),\n ]\n }),\n ) as React.CSSProperties\n\n try {\n const hex = CURATED_ACCENTS[accentColor] ?? accentColor\n\n // Explicit appearance → single-scale inline vars. Correct for a light\n // island inside a dark page (which must NOT pick up the dark scale).\n if (value.appearance) {\n return {\n inlineVars: toVars(\n accentSparkVars(generateAccentScale(hex, value.appearance)),\n ),\n css: '',\n scoped: false,\n }\n }\n\n // Ambient appearance → emit BOTH scales in a scoped <style> so the\n // `.dark` class selects the right one. Without this, a single-appearance\n // inline scale (default light) breaks components in dark mode.\n const light = accentSparkVars(generateAccentScale(hex, 'light'))\n const dark = accentSparkVars(generateAccentScale(hex, 'dark'))\n const sel = `[data-spark-scope=\"${scopeId}\"]`\n const css = `${sel}{${light.join('')}}:is(.dark,.dark-theme) ${sel}{${dark.join('')}}`\n return { inlineVars: {} as React.CSSProperties, css, scoped: true }\n } catch (error) {\n // A bad accentColor must not throw through render — fall back to the default theme.\n console.warn(\n `[Theme] Ignoring invalid accentColor \"${accentColor}\".`,\n error,\n )\n return empty\n }\n }, [accentColor, value.appearance, scopeId])\n\n // 'auto' pairs a neutral with the effective accent (Radix's grayColor=\"auto\").\n const resolvedNeutralColor =\n neutralColor === 'auto'\n ? getMatchingNeutral(value.accentColor ?? '#005EB4')\n : neutralColor\n\n const element = useRender({\n defaultTagName: 'div',\n render,\n ref,\n props: mergeProps<'div'>(\n {\n className: cn('spark-theme', appearance, className),\n 'data-neutral-color': resolvedNeutralColor,\n 'data-radius': radius,\n 'data-scaling': scaling,\n 'data-spacing': spacing,\n 'data-style': styleVariant,\n 'data-high-contrast': highContrast ? '' : undefined,\n 'data-label-position': labelPosition,\n 'data-input-style': inputStyle,\n 'data-input-color': inputColor,\n 'data-card-variant': cardVariant,\n 'data-card-color': cardColor === 'accent' ? 'accent' : undefined,\n 'data-spark-scope': accent.scoped ? scopeId : undefined,\n style: { ...accent.inlineVars, ...style },\n children,\n } as React.ComponentProps<'div'>,\n rest,\n ),\n })\n\n return (\n <ThemeContext.Provider value={value}>\n {accent.css ? <style>{accent.css}</style> : null}\n {element}\n </ThemeContext.Provider>\n )\n },\n)\n"],"mappings":"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"}
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const require_chunk = require("../chunk-aJGBMT86.cjs");
|
|
5
5
|
const require_icons_material_symbol = require("../icons/material-symbol.cjs");
|
|
6
|
+
const require_components_button = require("./button.cjs");
|
|
6
7
|
const require_components_spinner = require("./spinner.cjs");
|
|
7
8
|
let react = require("react");
|
|
8
9
|
react = require_chunk.__toESM(react);
|
|
9
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let
|
|
11
|
+
let _base_ui_react_toast = require("@base-ui/react/toast");
|
|
11
12
|
let cnfast = require("cnfast");
|
|
12
13
|
//#region src/components/toast.tsx
|
|
13
|
-
const
|
|
14
|
+
const TOAST_ICONS = {
|
|
14
15
|
success: {
|
|
15
16
|
name: "check_circle",
|
|
16
17
|
className: "text-success-light"
|
|
@@ -27,73 +28,165 @@ const ICONS = Object.fromEntries(Object.entries({
|
|
|
27
28
|
name: "cancel",
|
|
28
29
|
className: "text-error-light"
|
|
29
30
|
}
|
|
30
|
-
}).map(([type, icon]) => [type, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
31
|
-
className: (0, cnfast.cn)("inline-flex shrink-0 items-center [--spark-icon-size:16px]", icon.className),
|
|
32
|
-
name: icon.name
|
|
33
|
-
}, type)]));
|
|
34
|
-
ICONS.loading = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_spinner.Spinner, {
|
|
35
|
-
"aria-hidden": "true",
|
|
36
|
-
className: "flex text-gray-11",
|
|
37
|
-
label: "",
|
|
38
|
-
role: "presentation",
|
|
39
|
-
size: "sm"
|
|
40
|
-
});
|
|
41
|
-
const STYLE_VARS = {
|
|
42
|
-
"--normal-bg": "var(--color-gray-2)",
|
|
43
|
-
"--normal-text": "var(--color-gray-12)",
|
|
44
|
-
"--normal-border": "var(--color-gray-a1)",
|
|
45
|
-
"--border-radius": "var(--radius-lg)",
|
|
46
|
-
"--gray1": "var(--color-gray-1)",
|
|
47
|
-
"--gray2": "var(--color-gray-2)",
|
|
48
|
-
"--gray3": "var(--color-gray-3)",
|
|
49
|
-
"--gray4": "var(--color-gray-4)",
|
|
50
|
-
"--gray5": "var(--color-gray-5)",
|
|
51
|
-
"--gray11": "var(--color-gray-11)",
|
|
52
|
-
"--gray12": "var(--color-gray-12)",
|
|
53
|
-
"--toast-close-button-start": "unset",
|
|
54
|
-
"--toast-close-button-end": "0",
|
|
55
|
-
"--toast-close-button-transform": "translate(35%, -35%)",
|
|
56
|
-
"--success-bg": "var(--color-green-2)",
|
|
57
|
-
"--success-border": "transparent",
|
|
58
|
-
"--success-text": "var(--color-green-11)",
|
|
59
|
-
"--info-bg": "var(--color-blue-2)",
|
|
60
|
-
"--info-border": "transparent",
|
|
61
|
-
"--info-text": "var(--color-blue-11)",
|
|
62
|
-
"--warning-bg": "var(--color-orange-2)",
|
|
63
|
-
"--warning-border": "transparent",
|
|
64
|
-
"--warning-text": "var(--color-orange-11)",
|
|
65
|
-
"--error-bg": "var(--color-red-2)",
|
|
66
|
-
"--error-border": "transparent",
|
|
67
|
-
"--error-text": "var(--color-red-11)"
|
|
68
31
|
};
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
32
|
+
const TONE_CLASSES = {
|
|
33
|
+
success: "border-green-6 bg-green-2 text-green-11",
|
|
34
|
+
info: "border-blue-6 bg-blue-2 text-blue-11",
|
|
35
|
+
warning: "border-orange-6 bg-orange-2 text-orange-11",
|
|
36
|
+
error: "border-red-6 bg-red-2 text-red-11"
|
|
73
37
|
};
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
38
|
+
const POSITION_CLASSES = {
|
|
39
|
+
"top-left": "sm:top-4 sm:right-auto sm:bottom-auto sm:left-4",
|
|
40
|
+
"top-center": "sm:top-4 sm:right-auto sm:bottom-auto sm:left-1/2 sm:-translate-x-1/2",
|
|
41
|
+
"top-right": "sm:top-4 sm:right-4 sm:bottom-auto sm:left-auto",
|
|
42
|
+
"bottom-left": "sm:top-auto sm:right-auto sm:bottom-4 sm:left-4",
|
|
43
|
+
"bottom-center": "sm:top-auto sm:right-auto sm:bottom-4 sm:left-1/2 sm:-translate-x-1/2",
|
|
44
|
+
"bottom-right": "sm:top-auto sm:right-4 sm:bottom-4 sm:left-auto"
|
|
45
|
+
};
|
|
46
|
+
const manager = _base_ui_react_toast.Toast.createToastManager();
|
|
47
|
+
let sequence = 0;
|
|
48
|
+
function actionRest({ label: _label, onClick: _onClick, ...rest }) {
|
|
49
|
+
return rest;
|
|
50
|
+
}
|
|
51
|
+
function toManagerOptions(id, title, type, options) {
|
|
52
|
+
const action = options?.action;
|
|
53
|
+
return {
|
|
54
|
+
id,
|
|
55
|
+
title,
|
|
56
|
+
type,
|
|
57
|
+
description: options?.description,
|
|
58
|
+
timeout: options?.duration,
|
|
59
|
+
priority: options?.priority,
|
|
60
|
+
onClose: options?.onDismiss,
|
|
61
|
+
actionProps: action && {
|
|
62
|
+
...actionRest(action),
|
|
63
|
+
children: action.label,
|
|
64
|
+
onClick: (event) => {
|
|
65
|
+
action.onClick?.(event);
|
|
66
|
+
manager.close(id);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
data: { closeButton: options?.closeButton }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const emit = (type) => (message, options) => {
|
|
73
|
+
const id = options?.id ?? `spark-toast-${sequence += 1}`;
|
|
74
|
+
return manager.add(toManagerOptions(id, message, type, options));
|
|
75
|
+
};
|
|
76
|
+
const phase = (value, type) => (result) => {
|
|
77
|
+
return {
|
|
78
|
+
title: typeof value === "function" ? value(result) : value,
|
|
79
|
+
type
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const toast = Object.assign(emit(), {
|
|
83
|
+
success: emit("success"),
|
|
84
|
+
info: emit("info"),
|
|
85
|
+
warning: emit("warning"),
|
|
86
|
+
error: emit("error"),
|
|
87
|
+
loading: emit("loading"),
|
|
88
|
+
/** Dismiss one toast, or every toast when called without an id. */
|
|
89
|
+
dismiss: (id) => manager.close(id),
|
|
90
|
+
promise: (promiseValue, messages) => manager.promise(promiseValue, {
|
|
91
|
+
loading: {
|
|
92
|
+
title: messages.loading,
|
|
93
|
+
type: "loading"
|
|
94
|
+
},
|
|
95
|
+
success: phase(messages.success, "success"),
|
|
96
|
+
error: phase(messages.error, "error")
|
|
97
|
+
})
|
|
94
98
|
});
|
|
99
|
+
function ToastIcon({ type }) {
|
|
100
|
+
const icon = TOAST_ICONS[type];
|
|
101
|
+
if (type !== "loading" && !icon) return null;
|
|
102
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
103
|
+
"aria-hidden": "true",
|
|
104
|
+
className: "flex h-5 w-5 shrink-0 items-center justify-center",
|
|
105
|
+
children: type === "loading" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_spinner.Spinner, {
|
|
106
|
+
className: "text-gray-11",
|
|
107
|
+
label: "",
|
|
108
|
+
role: "presentation",
|
|
109
|
+
size: "sm"
|
|
110
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
111
|
+
className: (0, cnfast.cn)("[--spark-icon-size:20px]", icon.className),
|
|
112
|
+
name: icon.name
|
|
113
|
+
})
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function ToastItem({ closeButton, richColors, toast: toastObject }) {
|
|
117
|
+
const tone = TONE_CLASSES[toastObject.type];
|
|
118
|
+
const showClose = toastObject.data?.closeButton ?? closeButton;
|
|
119
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_toast.Toast.Root, {
|
|
120
|
+
"data-slot": "toast",
|
|
121
|
+
className: (0, cnfast.cn)("flex items-start gap-2 rounded-md border border-gray-a5 bg-gray-1 p-3 text-gray shadow-md select-none", richColors && tone),
|
|
122
|
+
swipeDirection: [
|
|
123
|
+
"up",
|
|
124
|
+
"down",
|
|
125
|
+
"right"
|
|
126
|
+
],
|
|
127
|
+
toast: toastObject,
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastIcon, { type: toastObject.type }),
|
|
130
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_base_ui_react_toast.Toast.Content, {
|
|
131
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
132
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Title, {
|
|
133
|
+
className: "text-sm font-medium",
|
|
134
|
+
"data-slot": "toast-title"
|
|
135
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Description, {
|
|
136
|
+
className: (0, cnfast.cn)("text-sm", richColors && tone ? "text-inherit" : "text-gray-11"),
|
|
137
|
+
"data-slot": "toast-description"
|
|
138
|
+
})]
|
|
139
|
+
}),
|
|
140
|
+
toastObject.actionProps ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Action, {
|
|
141
|
+
className: (0, cnfast.cn)(require_components_button.buttonVariants({
|
|
142
|
+
size: "small",
|
|
143
|
+
variant: "primary"
|
|
144
|
+
}), "-my-2 shrink-0 self-center rounded-full"),
|
|
145
|
+
"data-slot": "toast-action"
|
|
146
|
+
}) : null,
|
|
147
|
+
showClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Close, {
|
|
148
|
+
"aria-label": "Close",
|
|
149
|
+
className: (0, cnfast.cn)(require_components_button.buttonVariants({
|
|
150
|
+
size: "icon-small",
|
|
151
|
+
variant: "tertiary"
|
|
152
|
+
}), "-my-1 -mr-1 size-7 shrink-0 self-center text-gray-11"),
|
|
153
|
+
"data-slot": "toast-close",
|
|
154
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons_material_symbol.MaterialSymbol, {
|
|
155
|
+
"aria-hidden": "true",
|
|
156
|
+
className: "[--spark-icon-size:18px]",
|
|
157
|
+
name: "close"
|
|
158
|
+
})
|
|
159
|
+
}) : null
|
|
160
|
+
]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function ToastList({ closeButton, richColors }) {
|
|
164
|
+
const { toasts } = _base_ui_react_toast.Toast.useToastManager();
|
|
165
|
+
return toasts.map((toastObject) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastItem, {
|
|
166
|
+
closeButton,
|
|
167
|
+
richColors,
|
|
168
|
+
toast: toastObject
|
|
169
|
+
}, toastObject.id));
|
|
170
|
+
}
|
|
171
|
+
function Toaster({ className, closeButton = true, duration = 4e3, limit, mobilePosition = "top", position = "bottom-right", richColors = true }) {
|
|
172
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Provider, {
|
|
173
|
+
limit,
|
|
174
|
+
timeout: duration,
|
|
175
|
+
toastManager: manager,
|
|
176
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_base_ui_react_toast.Toast.Viewport, {
|
|
177
|
+
className: (0, cnfast.cn)("fixed inset-x-4 z-50 block h-0 outline-none", mobilePosition === "top" ? "top-4" : "bottom-4", "sm:inset-x-auto sm:w-96 sm:max-w-[calc(100vw-2rem)]", POSITION_CLASSES[position], className),
|
|
178
|
+
"data-mobile-side": mobilePosition,
|
|
179
|
+
"data-side": position.startsWith("top") ? "top" : "bottom",
|
|
180
|
+
"data-slot": "toaster",
|
|
181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToastList, {
|
|
182
|
+
closeButton,
|
|
183
|
+
richColors
|
|
184
|
+
})
|
|
185
|
+
}) })
|
|
186
|
+
});
|
|
187
|
+
}
|
|
95
188
|
//#endregion
|
|
96
189
|
exports.Toaster = Toaster;
|
|
97
|
-
exports.toast =
|
|
190
|
+
exports.toast = toast;
|
|
98
191
|
|
|
99
192
|
//# sourceMappingURL=toast.cjs.map
|