@epilot/spark-ui 0.27.1 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion.cjs +1 -1
- package/dist/components/accordion.cjs.map +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/attachment.cjs +2 -2
- package/dist/components/attachment.cjs.map +1 -1
- package/dist/components/attachment.d.cts +1 -1
- package/dist/components/attachment.d.ts +1 -1
- package/dist/components/attachment.js +2 -2
- package/dist/components/attachment.js.map +1 -1
- package/dist/components/autocomplete.cjs +3 -5
- package/dist/components/autocomplete.cjs.map +1 -1
- package/dist/components/autocomplete.js +3 -5
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.d.cts +1 -1
- package/dist/components/avatar.d.ts +1 -1
- package/dist/components/badge.d.cts +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/box.d.cts +1 -1
- package/dist/components/box.d.ts +1 -1
- package/dist/components/breadcrumbs.cjs +4 -1
- package/dist/components/breadcrumbs.cjs.map +1 -1
- package/dist/components/breadcrumbs.js +4 -1
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/bubble.cjs +1 -1
- package/dist/components/bubble.cjs.map +1 -1
- package/dist/components/bubble.d.cts +1 -1
- package/dist/components/bubble.d.ts +1 -1
- package/dist/components/bubble.js +1 -1
- package/dist/components/bubble.js.map +1 -1
- package/dist/components/button-group.cjs +2 -2
- package/dist/components/button-group.cjs.map +1 -1
- package/dist/components/button-group.d.cts +1 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.cjs +40 -13
- package/dist/components/button.cjs.map +1 -1
- package/dist/components/button.d.cts +13 -14
- package/dist/components/button.d.ts +13 -14
- package/dist/components/button.js +41 -14
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.cjs +3 -3
- package/dist/components/calendar.cjs.map +1 -1
- package/dist/components/calendar.js +3 -3
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.cjs.map +1 -1
- package/dist/components/card.d.cts +2 -2
- package/dist/components/card.d.ts +2 -2
- package/dist/components/card.js.map +1 -1
- package/dist/components/checkbox-group.d.cts +1 -1
- package/dist/components/checkbox-group.d.ts +1 -1
- package/dist/components/checkbox.cjs +2 -1
- package/dist/components/checkbox.cjs.map +1 -1
- package/dist/components/checkbox.d.cts +1 -1
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +2 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/combobox.cjs +337 -0
- package/dist/components/combobox.cjs.map +1 -0
- package/dist/components/combobox.d.cts +132 -0
- package/dist/components/combobox.d.ts +132 -0
- package/dist/components/combobox.js +312 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/day-of-week-picker.cjs +4 -2
- package/dist/components/day-of-week-picker.cjs.map +1 -1
- package/dist/components/day-of-week-picker.js +4 -2
- package/dist/components/day-of-week-picker.js.map +1 -1
- package/dist/components/empty-state.d.cts +1 -1
- package/dist/components/empty-state.d.ts +1 -1
- package/dist/components/entity-card.cjs +2 -1
- package/dist/components/entity-card.cjs.map +1 -1
- package/dist/components/entity-card.js +2 -1
- package/dist/components/entity-card.js.map +1 -1
- package/dist/components/field.cjs +4 -4
- package/dist/components/field.cjs.map +1 -1
- package/dist/components/field.d.cts +1 -1
- package/dist/components/field.d.ts +1 -1
- package/dist/components/field.js +4 -4
- package/dist/components/field.js.map +1 -1
- package/dist/components/info-block.d.cts +1 -1
- package/dist/components/info-block.d.ts +1 -1
- package/dist/components/input-group.cjs +11 -11
- package/dist/components/input-group.cjs.map +1 -1
- package/dist/components/input-group.js +11 -11
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.cjs +3 -2
- package/dist/components/input-otp.cjs.map +1 -1
- package/dist/components/input-otp.js +4 -3
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.cjs +4 -4
- package/dist/components/input.cjs.map +1 -1
- package/dist/components/input.d.cts +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +5 -5
- package/dist/components/input.js.map +1 -1
- package/dist/components/list.cjs +3 -3
- package/dist/components/list.cjs.map +1 -1
- package/dist/components/list.d.cts +2 -2
- package/dist/components/list.d.ts +2 -2
- package/dist/components/list.js +3 -3
- package/dist/components/list.js.map +1 -1
- package/dist/components/marker.cjs +1 -1
- package/dist/components/marker.cjs.map +1 -1
- package/dist/components/marker.js +1 -1
- package/dist/components/marker.js.map +1 -1
- package/dist/components/message-scroller.cjs +2 -2
- package/dist/components/message-scroller.cjs.map +1 -1
- package/dist/components/message-scroller.js +2 -2
- package/dist/components/message-scroller.js.map +1 -1
- package/dist/components/pill.cjs +1 -1
- package/dist/components/pill.cjs.map +1 -1
- package/dist/components/pill.d.cts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/pill.js +1 -1
- package/dist/components/pill.js.map +1 -1
- package/dist/components/radio-card-group.cjs +2 -1
- package/dist/components/radio-card-group.cjs.map +1 -1
- package/dist/components/radio-card-group.js +2 -1
- package/dist/components/radio-card-group.js.map +1 -1
- package/dist/components/radio.cjs +1 -1
- package/dist/components/radio.cjs.map +1 -1
- package/dist/components/radio.d.cts +1 -1
- package/dist/components/radio.d.ts +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/radio.js.map +1 -1
- package/dist/components/rating.cjs +1 -1
- package/dist/components/rating.cjs.map +1 -1
- package/dist/components/rating.js +1 -1
- package/dist/components/rating.js.map +1 -1
- package/dist/components/schedule-list.cjs +6 -3
- package/dist/components/schedule-list.cjs.map +1 -1
- package/dist/components/schedule-list.js +6 -3
- package/dist/components/schedule-list.js.map +1 -1
- package/dist/components/scroll-area.cjs +1 -1
- package/dist/components/scroll-area.cjs.map +1 -1
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/segmented-control.cjs +1 -1
- package/dist/components/segmented-control.cjs.map +1 -1
- package/dist/components/segmented-control.d.cts +1 -1
- package/dist/components/segmented-control.d.ts +1 -1
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/segmented-control.js.map +1 -1
- package/dist/components/select.cjs +5 -4
- package/dist/components/select.cjs.map +1 -1
- package/dist/components/select.d.cts +1 -1
- package/dist/components/select.d.ts +1 -1
- package/dist/components/select.js +5 -4
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-legend.cjs +2 -1
- package/dist/components/series-legend.cjs.map +1 -1
- package/dist/components/series-legend.js +2 -1
- package/dist/components/series-legend.js.map +1 -1
- package/dist/components/slider.cjs +3 -2
- package/dist/components/slider.cjs.map +1 -1
- package/dist/components/slider.js +3 -2
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stepper.cjs +3 -1
- package/dist/components/stepper.cjs.map +1 -1
- package/dist/components/stepper.js +3 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch-group.d.cts +1 -1
- package/dist/components/switch-group.d.ts +1 -1
- package/dist/components/switch.cjs +1 -1
- package/dist/components/switch.cjs.map +1 -1
- package/dist/components/switch.d.cts +1 -1
- package/dist/components/switch.d.ts +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.cjs +3 -3
- package/dist/components/table.cjs.map +1 -1
- package/dist/components/table.js +3 -3
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.cjs +3 -3
- package/dist/components/tabs.cjs.map +1 -1
- package/dist/components/tabs.js +3 -3
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/textarea.cjs +4 -4
- package/dist/components/textarea.cjs.map +1 -1
- package/dist/components/textarea.d.cts +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +5 -5
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.cjs +100 -15
- package/dist/components/theme.cjs.map +1 -1
- package/dist/components/theme.d.cts +4 -3
- package/dist/components/theme.d.ts +4 -3
- package/dist/components/theme.js +100 -16
- package/dist/components/theme.js.map +1 -1
- package/dist/components/time-picker.cjs +2 -1
- package/dist/components/time-picker.cjs.map +1 -1
- package/dist/components/time-picker.js +2 -1
- package/dist/components/time-picker.js.map +1 -1
- package/dist/components/toggle-group.d.cts +1 -1
- package/dist/components/toggle-group.d.ts +1 -1
- package/dist/components/toggle.d.cts +1 -1
- package/dist/components/toggle.d.ts +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/components/trace.cjs +2 -2
- package/dist/components/trace.cjs.map +1 -1
- package/dist/components/trace.js +2 -2
- package/dist/components/trace.js.map +1 -1
- package/dist/lib/accent-theme.d.cts +1 -1
- package/dist/lib/accent-theme.d.ts +1 -1
- package/dist/lib/container-chrome.cjs +2 -3
- package/dist/lib/container-chrome.cjs.map +1 -1
- package/dist/lib/container-chrome.d.cts +1 -1
- package/dist/lib/container-chrome.d.ts +1 -1
- package/dist/lib/container-chrome.js +2 -3
- package/dist/lib/container-chrome.js.map +1 -1
- package/dist/lib/input-box-variants.cjs +11 -9
- package/dist/lib/input-box-variants.cjs.map +1 -1
- package/dist/lib/input-box-variants.d.cts +4 -3
- package/dist/lib/input-box-variants.d.ts +4 -3
- package/dist/lib/input-box-variants.js +11 -10
- package/dist/lib/input-box-variants.js.map +1 -1
- package/dist/lib/selection-list.d.cts +1 -1
- package/dist/lib/selection-list.d.ts +1 -1
- package/dist/lib/theme-types.cjs.map +1 -1
- package/dist/lib/theme-types.d.cts +2 -2
- package/dist/lib/theme-types.d.ts +2 -2
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/toggle-group-context.d.cts +1 -1
- package/dist/lib/toggle-group-context.d.ts +1 -1
- package/dist/styles/spark-default.css +98 -0
- package/dist/styles/theme.css +12 -0
- package/dist/{theme-types-CKZzOmSa.d.ts → theme-types-Dlge0s3s.d.cts} +12 -6
- package/dist/{theme-types-CKZzOmSa.d.cts → theme-types-Dlge0s3s.d.ts} +12 -6
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","names":["React"],"sources":["../../src/components/textarea.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { boxChrome,
|
|
1
|
+
{"version":3,"file":"textarea.js","names":["React"],"sources":["../../src/components/textarea.tsx"],"sourcesContent":["import { cva } from 'class-variance-authority'\nimport * as React from 'react'\nimport { boxChrome, INSET_UNDERLINE } from '../lib/input-box-variants'\nimport type { SparkInputStyle } from '../lib/theme-types'\nimport { cn } from '../utils/cn'\nimport { useFieldControl } from './field'\n\ntype TextareaVariant = SparkInputStyle | 'none'\n\nconst textareaVariants = cva(\n 'flex w-full min-w-0 bg-transparent text-gray transition-[color,background-color,border-color] group-data-[invalid=true]/field:text-error placeholder:text-gray-placeholder disabled:cursor-not-allowed disabled:text-gray-disabled disabled:placeholder:text-gray-disabled aria-invalid:text-error motion-reduce:transition-none',\n {\n variants: {\n chrome: {\n none: 'border-0 px-0 focus-visible:outline-hidden',\n inset: INSET_UNDERLINE,\n box: 'min-h-11 rounded-md px-3 py-2 text-base transition-[color,background-color,border-color] motion-reduce:transition-none',\n },\n inputStyle: { soft: '', surface: '', outlined: '', ghost: '' },\n inputColor: { brand: '', gray: '' },\n autoResize: {\n true: 'field-sizing-content resize-none',\n false: 'resize-y',\n },\n },\n compoundVariants: [\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'brand',\n class: boxChrome.soft.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'soft',\n inputColor: 'gray',\n class: boxChrome.soft.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'brand',\n class: boxChrome.surface.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'surface',\n inputColor: 'gray',\n class: boxChrome.surface.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'brand',\n class: boxChrome.outlined.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'outlined',\n inputColor: 'gray',\n class: boxChrome.outlined.gray,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'brand',\n class: boxChrome.ghost.brand,\n },\n {\n chrome: 'box',\n inputStyle: 'ghost',\n inputColor: 'gray',\n class: boxChrome.ghost.gray,\n },\n { chrome: 'inset', inputColor: 'brand', class: 'border-b-input' },\n { chrome: 'inset', inputColor: 'gray', class: 'border-b-input-gray' },\n // GHOST_UNDERLINE and boxChrome.ghost.* hardcode h-10; un-clamp for\n // textarea's min-height model — must come after those compounds above\n { chrome: 'inset', class: 'h-auto min-h-10' },\n { chrome: 'box', inputStyle: 'ghost', class: 'h-auto' },\n ],\n },\n)\n\ninterface TextareaProps extends React.ComponentProps<'textarea'> {\n variant?: TextareaVariant\n autoResize?: boolean\n}\n\nconst Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n function Textarea(\n {\n variant,\n autoResize = false,\n rows = 3,\n className,\n id: idProp,\n 'aria-describedby': ariaDescribedByProp,\n ...props\n },\n ref,\n ) {\n const { field, id, ariaDescribedBy, ariaInvalid, inputStyle, inputColor } =\n useFieldControl({\n id: idProp,\n ariaDescribedBy: ariaDescribedByProp,\n variant: variant !== 'none' ? variant : undefined,\n })\n // an explicit variant prop keeps the box even inside an inset field\n const chrome =\n variant === 'none'\n ? 'none'\n : !variant && field?.labelPosition === 'inset'\n ? 'inset'\n : 'box'\n\n return (\n <textarea\n data-slot=\"textarea\"\n className={cn(\n textareaVariants({ chrome, inputStyle, inputColor, autoResize }),\n className,\n )}\n id={id}\n rows={rows}\n ref={ref}\n aria-invalid={ariaInvalid}\n {...props}\n aria-describedby={ariaDescribedBy}\n />\n )\n },\n)\n\nexport { Textarea }\nexport type { TextareaProps, TextareaVariant }\n"],"mappings":";;;;;;;;AASA,MAAM,mBAAmB,IACvB,oUACA;CACE,UAAU;EACR,QAAQ;GACN,MAAM;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OACE,oBAAC,YAAD;EACE,aAAU;EACV,WAAW,GACT,iBAAiB;GAAE,QAVvB,YAAY,SACR,SACA,CAAC,WAAW,OAAO,kBAAkB,UACnC,UACA;GAMyB;GAAY;GAAY;EAAW,CAAC,GAC/D,SACF;EACI;EACE;EACD;EACL,gBAAc;EACd,GAAI;EACJ,oBAAkB;CACnB,CAAA;AAEL,CACF"}
|
|
@@ -21,21 +21,46 @@ function roleOf(style, color) {
|
|
|
21
21
|
...color !== void 0 && { color }
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
+
const DESIGN_VARIANTS = [
|
|
25
|
+
"primary",
|
|
26
|
+
"secondary",
|
|
27
|
+
"tertiary"
|
|
28
|
+
];
|
|
29
|
+
function isDesignColor(value) {
|
|
30
|
+
return typeof value === "object" && value !== null && typeof value.light === "string";
|
|
31
|
+
}
|
|
32
|
+
const colorKey = (color) => isDesignColor(color) ? JSON.stringify({
|
|
33
|
+
light: color.light,
|
|
34
|
+
dark: color.dark
|
|
35
|
+
}) : color;
|
|
36
|
+
const colorFromKey = (key) => key?.startsWith("{") ? JSON.parse(key) : key;
|
|
37
|
+
function parsableColor(variant, color) {
|
|
38
|
+
if (!isDesignColor(color)) return color;
|
|
39
|
+
if (!require_lib_accent_theme.isParsableColor(color.light)) {
|
|
40
|
+
console.warn(`[Theme] Ignoring invalid buttons.${variant}.color "${color.light}".`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (color.dark !== void 0 && !require_lib_accent_theme.isParsableColor(color.dark)) {
|
|
44
|
+
console.warn(`[Theme] Ignoring invalid buttons.${variant}.color dark "${color.dark}".`);
|
|
45
|
+
return { light: color.light };
|
|
46
|
+
}
|
|
47
|
+
return color.dark === void 0 ? { light: color.light } : color;
|
|
48
|
+
}
|
|
24
49
|
function useButtonRoles(buttons) {
|
|
25
50
|
const isSet = buttons !== void 0;
|
|
26
51
|
const { primary, secondary, tertiary } = buttons ?? {};
|
|
27
52
|
const primaryStyle = primary?.style;
|
|
28
|
-
const primaryColor = primary?.color;
|
|
53
|
+
const primaryColor = colorKey(primary?.color);
|
|
29
54
|
const secondaryStyle = secondary?.style;
|
|
30
|
-
const secondaryColor = secondary?.color;
|
|
55
|
+
const secondaryColor = colorKey(secondary?.color);
|
|
31
56
|
const tertiaryStyle = tertiary?.style;
|
|
32
|
-
const tertiaryColor = tertiary?.color;
|
|
57
|
+
const tertiaryColor = colorKey(tertiary?.color);
|
|
33
58
|
return react.useMemo(() => {
|
|
34
59
|
if (!isSet) return void 0;
|
|
35
60
|
const roles = {};
|
|
36
|
-
const primaryRole = roleOf(primaryStyle, primaryColor);
|
|
37
|
-
const secondaryRole = roleOf(secondaryStyle, secondaryColor);
|
|
38
|
-
const tertiaryRole = roleOf(tertiaryStyle, tertiaryColor);
|
|
61
|
+
const primaryRole = roleOf(primaryStyle, parsableColor("primary", colorFromKey(primaryColor)));
|
|
62
|
+
const secondaryRole = roleOf(secondaryStyle, parsableColor("secondary", colorFromKey(secondaryColor)));
|
|
63
|
+
const tertiaryRole = roleOf(tertiaryStyle, parsableColor("tertiary", colorFromKey(tertiaryColor)));
|
|
39
64
|
if (primaryRole) roles.primary = primaryRole;
|
|
40
65
|
if (secondaryRole) roles.secondary = secondaryRole;
|
|
41
66
|
if (tertiaryRole) roles.tertiary = tertiaryRole;
|
|
@@ -50,6 +75,31 @@ function useButtonRoles(buttons) {
|
|
|
50
75
|
tertiaryColor
|
|
51
76
|
]);
|
|
52
77
|
}
|
|
78
|
+
function mergeRoles(parent, own) {
|
|
79
|
+
const merged = { ...parent };
|
|
80
|
+
for (const variant of DESIGN_VARIANTS) if (own[variant]) merged[variant] = {
|
|
81
|
+
...parent?.[variant],
|
|
82
|
+
...own[variant]
|
|
83
|
+
};
|
|
84
|
+
return merged;
|
|
85
|
+
}
|
|
86
|
+
function buttonColorDecls(roles, appearance) {
|
|
87
|
+
const decls = [];
|
|
88
|
+
for (const variant of DESIGN_VARIANTS) {
|
|
89
|
+
const color = roles?.[variant]?.color;
|
|
90
|
+
if (!isDesignColor(color)) continue;
|
|
91
|
+
const scale = require_lib_accent_theme.generateAccentScale(appearance === "dark" ? color.dark ?? color.light : color.light, appearance);
|
|
92
|
+
const prefix = `--spark-button-${variant}`;
|
|
93
|
+
decls.push(...scale.accentScale.map((c, i) => `${prefix}-${i + 1}: ${c};`), ...scale.accentScaleAlpha.map((c, i) => `${prefix}-a${i + 1}: ${c};`), `${prefix}-contrast: ${scale.accentContrast};`, `${prefix}-on-solid: ${scale.accentOnSolid};`, `${prefix}-surface: ${scale.accentSurface};`);
|
|
94
|
+
}
|
|
95
|
+
return decls;
|
|
96
|
+
}
|
|
97
|
+
function declsToVars(decls) {
|
|
98
|
+
return Object.fromEntries(decls.map((decl) => {
|
|
99
|
+
const i = decl.indexOf(":");
|
|
100
|
+
return [decl.slice(0, i).trim(), decl.slice(i + 1, -1).trim()];
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
53
103
|
const ThemeOutputContext = react.createContext(null);
|
|
54
104
|
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
55
105
|
function useTheme() {
|
|
@@ -75,10 +125,7 @@ const Theme = react.forwardRef(function Theme({ accentColor, backgroundColor, ne
|
|
|
75
125
|
inputColor: inputColor ?? parent.inputColor,
|
|
76
126
|
cardVariant: cardVariant ?? parent.cardVariant,
|
|
77
127
|
cardColor: cardColor ?? parent.cardColor,
|
|
78
|
-
buttons: buttons ?
|
|
79
|
-
...parent.buttons,
|
|
80
|
-
...buttons
|
|
81
|
-
} : parent.buttons,
|
|
128
|
+
buttons: buttons ? mergeRoles(parent.buttons, buttons) : parent.buttons,
|
|
82
129
|
appearance: appearance ?? parent.appearance,
|
|
83
130
|
fontHeading: fontHeading ?? parent.fontHeading,
|
|
84
131
|
fontBody: fontBody ?? parent.fontBody
|
|
@@ -217,6 +264,32 @@ const Theme = react.forwardRef(function Theme({ accentColor, backgroundColor, ne
|
|
|
217
264
|
...fontHeading ? { "--spark-font-heading": fontHeading } : null,
|
|
218
265
|
...fontBody ? { "--spark-font-body": fontBody } : null
|
|
219
266
|
}), [fontHeading, fontBody]);
|
|
267
|
+
const buttonVars = react.useMemo(() => {
|
|
268
|
+
if (value.appearance) return {
|
|
269
|
+
vars: declsToVars(buttonColorDecls(buttons, value.appearance)),
|
|
270
|
+
scope: void 0,
|
|
271
|
+
css: ""
|
|
272
|
+
};
|
|
273
|
+
const light = buttonColorDecls(buttons, "light");
|
|
274
|
+
const dark = buttonColorDecls(buttons, "dark");
|
|
275
|
+
if (!light.length) return {
|
|
276
|
+
vars: {},
|
|
277
|
+
scope: void 0,
|
|
278
|
+
css: ""
|
|
279
|
+
};
|
|
280
|
+
const scope = `${scopeId}b`;
|
|
281
|
+
const sel = `[data-spark-scope~="${scope}"]`;
|
|
282
|
+
return {
|
|
283
|
+
vars: {},
|
|
284
|
+
scope,
|
|
285
|
+
css: `${sel}{${light.join("")}}:is(.dark,.dark-theme) ${sel}{${dark.join("")}}`
|
|
286
|
+
};
|
|
287
|
+
}, [
|
|
288
|
+
buttons,
|
|
289
|
+
value.appearance,
|
|
290
|
+
scopeId
|
|
291
|
+
]);
|
|
292
|
+
const ownScopes = [...accent.scoped ? [scopeId] : [], ...buttonVars.scope ? [buttonVars.scope] : []];
|
|
220
293
|
const element = (0, _base_ui_react_use_render.useRender)({
|
|
221
294
|
defaultTagName: "div",
|
|
222
295
|
render,
|
|
@@ -225,11 +298,12 @@ const Theme = react.forwardRef(function Theme({ accentColor, backgroundColor, ne
|
|
|
225
298
|
className: (0, cn.cn)("spark-theme", appearance, className),
|
|
226
299
|
...attrs,
|
|
227
300
|
"data-inverted": inverted ? "" : void 0,
|
|
228
|
-
"data-spark-scope":
|
|
301
|
+
"data-spark-scope": ownScopes.length ? ownScopes.join(" ") : void 0,
|
|
229
302
|
style: {
|
|
230
303
|
...accent.inlineVars,
|
|
231
304
|
...backgroundColor ? { backgroundColor: "var(--spark-background)" } : null,
|
|
232
305
|
...fontVars,
|
|
306
|
+
...buttonVars.vars,
|
|
233
307
|
...style
|
|
234
308
|
},
|
|
235
309
|
children
|
|
@@ -246,21 +320,31 @@ const Theme = react.forwardRef(function Theme({ accentColor, backgroundColor, ne
|
|
|
246
320
|
vars: {
|
|
247
321
|
...parentOutput?.vars,
|
|
248
322
|
...accent.portalVars,
|
|
249
|
-
...fontVars
|
|
323
|
+
...fontVars,
|
|
324
|
+
...buttonVars.vars
|
|
250
325
|
},
|
|
251
|
-
scopes:
|
|
326
|
+
scopes: [
|
|
327
|
+
...parentScopes,
|
|
328
|
+
...accent.portalScope ? [accent.portalScope] : [],
|
|
329
|
+
...buttonVars.scope ? [buttonVars.scope] : []
|
|
330
|
+
]
|
|
252
331
|
};
|
|
253
332
|
}, [
|
|
254
333
|
parentOutput,
|
|
255
334
|
attrs,
|
|
256
335
|
accent,
|
|
257
|
-
fontVars
|
|
336
|
+
fontVars,
|
|
337
|
+
buttonVars
|
|
258
338
|
]);
|
|
259
339
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeContext.Provider, {
|
|
260
340
|
value,
|
|
261
341
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ThemeOutputContext.Provider, {
|
|
262
342
|
value: output,
|
|
263
|
-
children: [
|
|
343
|
+
children: [
|
|
344
|
+
accent.css ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: accent.css }) : null,
|
|
345
|
+
buttonVars.css ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: buttonVars.css }) : null,
|
|
346
|
+
element
|
|
347
|
+
]
|
|
264
348
|
})
|
|
265
349
|
});
|
|
266
350
|
});
|
|
@@ -291,6 +375,7 @@ function PortalTheme({ children }) {
|
|
|
291
375
|
//#endregion
|
|
292
376
|
exports.PortalTheme = PortalTheme;
|
|
293
377
|
exports.Theme = Theme;
|
|
378
|
+
exports.isDesignColor = isDesignColor;
|
|
294
379
|
exports.useTheme = useTheme;
|
|
295
380
|
|
|
296
381
|
//# sourceMappingURL=theme.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.cjs","names":["React","resolveAutoNeutral","isSparkNeutralFamily","isParsableColor","getMatchingNeutral","CURATED_ACCENTS","appearanceForBackground","accentSparkVars","neutralSparkVars","generateAccentScale","invertAccentScale","neutralFamilyVars"],"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 appearanceForBackground,\n generateAccentScale,\n getMatchingNeutral,\n invertAccentScale,\n isParsableColor,\n neutralFamilyVars,\n neutralSparkVars,\n resolveAutoNeutral,\n type Appearance,\n type SparkAccentScale,\n} from '../lib/accent-theme'\nimport {\n isSparkNeutralFamily,\n type SparkButtonColor,\n type SparkButtonRoles,\n type SparkCardColor,\n type SparkCardVariant,\n type SparkInputColor,\n type SparkInputStyle,\n type SparkLabelPosition,\n type SparkNeutral,\n type SparkRadius,\n type SparkScaling,\n type SparkSpacing,\n type SparkStyle,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type {\n SparkButtonColor,\n SparkButtonEmphasis,\n SparkButtonRole,\n SparkButtonRoles,\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkNeutralFamily,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\n\n/** The epilot brand accent — the scale `spark-default.css` ships statically. */\nconst DEFAULT_ACCENT = '#005EB4'\n\nexport interface ThemeValue {\n /** Curated accent name or a custom hex. */\n accentColor?: string\n /**\n * Page canvas as a custom hex. Regenerates BOTH the accent and neutral scales against\n * it (each alpha step is composited against the canvas, so a saturated colour needs\n * the neutral ramp regenerated too, not just the accent). Unset → the fixed\n * `#ffffff` / `#000000` default, and neutrals stay on the static Radix families.\n */\n backgroundColor?: string\n /**\n * A curated family name, an arbitrary color to seed the neutral scale, or `'auto'` to\n * resolve one — preferring `backgroundColor`'s own hue when it's perceptibly tinted,\n * else pairing with the accent (Radix's `grayColor=\"auto\"`). A custom seed (from `auto`\n * or set directly) only regenerates the scale alongside a `backgroundColor`; without\n * one, `data-neutral-color` falls back to the accent-matched family and that's what\n * actually paints.\n */\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 /**\n * Orthogonal to `styleVariant`: re-casts the accent scale for use ON its own solid fill,\n * for controls sitting on a solid accent surface (a `<Card variant=\"solid\" color=\"accent\">`),\n * where a solid control would otherwise paint the same `--spark-9` as the card and vanish.\n * Swaps step 9 with its contrast ink, so the fill/ink pair stays WCAG-safe for any accent.\n */\n inverted?: 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 /** `<Button emphasis>` looks; an explicit `styleVariant` / `color` on the button wins. */\n buttons?: SparkButtonRoles\n appearance?: Appearance\n /** Font stack for `h1`–`h6`. Any valid CSS `font-family` value. */\n fontHeading?: string\n /** Font stack for everything else. Any valid CSS `font-family` value. */\n fontBody?: string\n}\n\nconst ThemeContext = React.createContext<ThemeValue>({})\n\n/** What a Theme actually wrote to the DOM, merged over its ancestors (nearest wins). */\ninterface ThemeOutput {\n attrs: Record<string, string>\n vars: Record<string, string>\n scopes: string[]\n}\n\nfunction roleOf(\n style: SparkStyle | undefined,\n color: SparkButtonColor | undefined,\n) {\n if (style === undefined && color === undefined) return undefined\n return {\n ...(style !== undefined && { style }),\n ...(color !== undefined && { color }),\n }\n}\n\nfunction useButtonRoles(buttons: SparkButtonRoles | undefined) {\n const isSet = buttons !== undefined\n const { primary, secondary, tertiary } = buttons ?? {}\n const primaryStyle = primary?.style\n const primaryColor = primary?.color\n const secondaryStyle = secondary?.style\n const secondaryColor = secondary?.color\n const tertiaryStyle = tertiary?.style\n const tertiaryColor = tertiary?.color\n return React.useMemo<SparkButtonRoles | undefined>(() => {\n if (!isSet) return undefined\n const roles: SparkButtonRoles = {}\n const primaryRole = roleOf(primaryStyle, primaryColor)\n const secondaryRole = roleOf(secondaryStyle, secondaryColor)\n const tertiaryRole = roleOf(tertiaryStyle, tertiaryColor)\n if (primaryRole) roles.primary = primaryRole\n if (secondaryRole) roles.secondary = secondaryRole\n if (tertiaryRole) roles.tertiary = tertiaryRole\n return roles\n }, [\n isSet,\n primaryStyle,\n primaryColor,\n secondaryStyle,\n secondaryColor,\n tertiaryStyle,\n tertiaryColor,\n ])\n}\n\nconst ThemeOutputContext = React.createContext<ThemeOutput | null>(null)\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 backgroundColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n inverted,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n buttons: buttonsProp,\n appearance,\n fontHeading,\n fontBody,\n render,\n className,\n style,\n children,\n ...rest\n },\n ref,\n ) {\n const parent = useTheme()\n const buttons = useButtonRoles(buttonsProp)\n const parentOutput = React.useContext(ThemeOutputContext)\n\n const value = React.useMemo<ThemeValue>(\n () => ({\n accentColor: accentColor ?? parent.accentColor,\n backgroundColor: backgroundColor ?? parent.backgroundColor,\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 inverted: inverted ?? parent.inverted,\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 buttons: buttons ? { ...parent.buttons, ...buttons } : parent.buttons,\n appearance: appearance ?? parent.appearance,\n fontHeading: fontHeading ?? parent.fontHeading,\n fontBody: fontBody ?? parent.fontBody,\n }),\n [\n accentColor,\n backgroundColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n inverted,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n buttons,\n appearance,\n fontHeading,\n fontBody,\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 // 'auto' pairs a neutral with the canvas's own tint when it has one, else the\n // effective accent (Radix's grayColor=\"auto\") — see resolveAutoNeutral. Reads the\n // OWN backgroundColor, not the merged value.backgroundColor: optsFor (below) only\n // ever regenerates against a scope's own canvas too, so preferring an inherited one\n // here would resolve a seed that then gets silently discarded.\n const rawNeutralColor =\n neutralColor === 'auto'\n ? resolveAutoNeutral(\n value.accentColor ?? DEFAULT_ACCENT,\n backgroundColor,\n )\n : neutralColor\n\n // A custom neutral that isn't a recognized family must be a real, parseable color —\n // reject invalid input here (e.g. a typo'd family name like \"slat\") so it can't throw\n // deep inside the shared generator, where the catch below would otherwise blame\n // accentColor/backgroundColor without ever naming neutralColor as the actual cause.\n const neutralColorIsValid =\n rawNeutralColor === undefined ||\n isSparkNeutralFamily(rawNeutralColor) ||\n isParsableColor(rawNeutralColor)\n if (!neutralColorIsValid) {\n console.warn(\n `[Theme] Ignoring invalid neutralColor \"${rawNeutralColor}\" — falling back to the accent-matched family.`,\n )\n }\n const resolvedNeutralColor = neutralColorIsValid\n ? rawNeutralColor\n : getMatchingNeutral(value.accentColor ?? DEFAULT_ACCENT)\n\n // The DOM attribute stays one of the 6 static families `[data-neutral-color]` has CSS\n // for — a raw color (from the canvas-tinted auto path, or an arbitrary neutralColor\n // prop) falls back to its accent-matched family here instead, so the attribute is\n // always CSS-selectable/debuggable rather than a sentinel nothing matches.\n // generateAccentScale still gets the real resolvedNeutralColor for generation, below —\n // this substitution is display-only, and doesn't by itself guarantee the *other*\n // appearance's neutrals in ambient (no explicit `appearance`) mode: that's a\n // pre-existing cross-appearance leak in the same family as review-findings.md #5, not\n // something this attribute fallback fixes or regresses.\n const neutralColorAttr =\n resolvedNeutralColor === undefined\n ? undefined\n : isSparkNeutralFamily(resolvedNeutralColor)\n ? resolvedNeutralColor\n : getMatchingNeutral(value.accentColor ?? DEFAULT_ACCENT)\n\n const accent = React.useMemo(() => {\n const empty = {\n inlineVars: {} as React.CSSProperties,\n portalVars: {} as React.CSSProperties,\n portalScope: undefined as string | undefined,\n css: '',\n scoped: false,\n }\n // A custom canvas generates even with no accent of its own: the neutral ramp is\n // composited against it, and --spark-background has to carry it.\n if (!accentColor && !backgroundColor) 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 source = value.accentColor ?? DEFAULT_ACCENT\n const hex = CURATED_ACCENTS[source] ?? source\n\n // A canvas has a polarity, unlike an accent hue: a yellow page is a *light*\n // page, and reusing it for the dark scale yields light ink on a light canvas\n // (measured 1.16:1). So the custom canvas applies to the appearance it actually\n // belongs to, and the other keeps its default. One knob still covers the common\n // case — a tenant wanting both sets an explicit appearance per scope.\n const bgAppearance = backgroundColor\n ? appearanceForBackground(backgroundColor)\n : undefined\n\n // Honouring a mismatched canvas would paint light ink on a light page, so it's\n // dropped — but say so, or the prop looks broken.\n if (\n backgroundColor &&\n value.appearance &&\n bgAppearance !== value.appearance\n ) {\n console.warn(\n `[Theme] Ignoring backgroundColor \"${backgroundColor}\": it reads as a ${bgAppearance} canvas on an appearance=\"${value.appearance}\" scope. Pass a ${value.appearance} colour, or set it on a scope whose appearance matches.`,\n )\n }\n\n // Default to slate so a regenerated neutral stays in the family the static\n // `:root` default already points at, rather than the generator's ECP gray seed.\n const optsFor = (appearance: Appearance) =>\n backgroundColor && bgAppearance === appearance\n ? {\n background: backgroundColor,\n neutral: resolvedNeutralColor ?? ('slate' as const),\n }\n : undefined\n\n // Neutrals are only worth regenerating against a custom canvas — see\n // neutralSparkVars. Without one the static Radix families are already correct.\n const emit = (scale: SparkAccentScale, custom: boolean) =>\n custom\n ? [...accentSparkVars(scale), ...neutralSparkVars(scale)]\n : accentSparkVars(scale)\n\n const build = (appearance: Appearance) => {\n const opts = optsFor(appearance)\n const scale = generateAccentScale(hex, appearance, opts)\n // `inverted` re-casts the accent for a solid-accent surface; the neutral ramp is\n // unrelated to that swap, so it passes through untouched.\n const rendered = emit(\n inverted ? invertAccentScale(scale) : scale,\n opts != null,\n )\n // Popups sit on their own surface, so they get the scale before the inverted re-cast.\n const plain = inverted ? emit(scale, opts != null) : rendered\n return { rendered, plain }\n }\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 const { rendered, plain } = build(value.appearance)\n const inlineVars = toVars(rendered)\n return {\n inlineVars,\n portalVars: inverted ? toVars(plain) : inlineVars,\n portalScope: undefined,\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 //\n // Both blocks must declare the SAME tokens. A custom canvas only regenerates\n // neutrals for its own appearance (see optsFor), and a custom property the other\n // block leaves undeclared keeps its sibling's value rather than falling back — so\n // the off-canvas appearance would paint this one's canvas-tinted neutrals, and\n // being unlayered they'd beat `[data-neutral-color]`'s @layer base mapping too.\n // Point it at the static family instead: the same seed the canvas side was given,\n // so the two appearances agree on family and differ only in canvas.\n const offCanvasNeutrals = backgroundColor\n ? neutralFamilyVars(resolvedNeutralColor ?? 'slate')\n : []\n const scaleFor = (appearance: Appearance) => {\n const { rendered, plain } = build(appearance)\n const extra = bgAppearance === appearance ? [] : offCanvasNeutrals\n return {\n rendered: [...rendered, ...extra],\n plain: [...plain, ...extra],\n }\n }\n const light = scaleFor('light')\n const dark = scaleFor('dark')\n const rule = (\n id: string,\n lightDecls: string[],\n darkDecls: string[],\n ) => {\n const sel = `[data-spark-scope~=\"${id}\"]`\n return `${sel}{${lightDecls.join('')}}:is(.dark,.dark-theme) ${sel}{${darkDecls.join('')}}`\n }\n const portalScope = inverted ? `${scopeId}p` : scopeId\n const css =\n rule(scopeId, light.rendered, dark.rendered) +\n (inverted ? rule(portalScope, light.plain, dark.plain) : '')\n return {\n inlineVars: {} as React.CSSProperties,\n portalVars: {} as React.CSSProperties,\n portalScope,\n css,\n scoped: true,\n }\n } catch (error) {\n // A bad accentColor/backgroundColor must not throw through render — fall back\n // to the default theme.\n console.warn(\n `[Theme] Ignoring invalid accentColor \"${accentColor}\" / backgroundColor \"${backgroundColor}\".`,\n error,\n )\n return empty\n }\n }, [\n accentColor,\n backgroundColor,\n inverted,\n resolvedNeutralColor,\n value.accentColor,\n value.appearance,\n scopeId,\n ])\n\n const attrs = React.useMemo(\n () => ({\n 'data-neutral-color': neutralColorAttr,\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,\n }),\n [\n neutralColorAttr,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n ],\n )\n const fontVars = React.useMemo(\n () => ({\n ...(fontHeading ? { '--spark-font-heading': fontHeading } : null),\n ...(fontBody ? { '--spark-font-body': fontBody } : null),\n }),\n [fontHeading, fontBody],\n )\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 ...attrs,\n 'data-inverted': inverted ? '' : undefined,\n 'data-spark-scope': accent.scoped ? scopeId : undefined,\n style: {\n ...accent.inlineVars,\n // Paint the canvas we were handed, else the prop emits a token and visibly\n // does nothing. Reads the var (not the raw prop) so the scoped <style>'s\n // per-appearance value still wins under ambient appearance.\n ...(backgroundColor\n ? { backgroundColor: 'var(--spark-background)' }\n : null),\n ...fontVars,\n ...style,\n } as React.CSSProperties,\n children,\n } as React.ComponentProps<'div'>,\n rest,\n ),\n })\n\n const output = React.useMemo<ThemeOutput>(() => {\n // An unset own knob must not blank out the ancestor's value it inherits.\n const own = Object.fromEntries(\n Object.entries(attrs).filter(\n (entry): entry is [string, string] => entry[1] !== undefined,\n ),\n )\n const parentScopes = parentOutput?.scopes ?? []\n return {\n attrs: { ...parentOutput?.attrs, ...own },\n vars: {\n ...parentOutput?.vars,\n ...(accent.portalVars as Record<string, string>),\n ...fontVars,\n },\n scopes: accent.portalScope\n ? [...parentScopes, accent.portalScope]\n : parentScopes,\n }\n }, [parentOutput, attrs, accent, fontVars])\n\n return (\n <ThemeContext.Provider value={value}>\n <ThemeOutputContext.Provider value={output}>\n {accent.css ? <style>{accent.css}</style> : null}\n {element}\n </ThemeOutputContext.Provider>\n </ThemeContext.Provider>\n )\n },\n)\n\n/** Re-emits what the enclosing Themes rendered inside a portal, where CSS inheritance from them stops. */\nexport function PortalTheme({ children }: { children: React.ReactNode }) {\n const output = React.useContext(ThemeOutputContext)\n const theme = useTheme()\n // A popup sits on its own surface, never on the solid accent `inverted` is for.\n const value = React.useMemo(() => ({ ...theme, inverted: false }), [theme])\n if (!output) return <>{children}</>\n return (\n <ThemeContext.Provider value={value}>\n <div\n data-slot=\"portal-theme\"\n className={cn('spark-theme', theme.appearance)}\n {...output.attrs}\n data-spark-scope={\n output.scopes.length ? output.scopes.join(' ') : undefined\n }\n style={{ display: 'contents', ...output.vars }}\n >\n {children}\n </div>\n </ThemeContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AAuDA,MAAM,iBAAiB;AAkDvB,MAAM,eAAeA,MAAM,cAA0B,CAAC,CAAC;AASvD,SAAS,OACP,OACA,OACA;CACA,IAAI,UAAU,KAAA,KAAa,UAAU,KAAA,GAAW,OAAO,KAAA;CACvD,OAAO;EACL,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;EACnC,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;CACrC;AACF;AAEA,SAAS,eAAe,SAAuC;CAC7D,MAAM,QAAQ,YAAY,KAAA;CAC1B,MAAM,EAAE,SAAS,WAAW,aAAa,WAAW,CAAC;CACrD,MAAM,eAAe,SAAS;CAC9B,MAAM,eAAe,SAAS;CAC9B,MAAM,iBAAiB,WAAW;CAClC,MAAM,iBAAiB,WAAW;CAClC,MAAM,gBAAgB,UAAU;CAChC,MAAM,gBAAgB,UAAU;CAChC,OAAOA,MAAM,cAA4C;EACvD,IAAI,CAAC,OAAO,OAAO,KAAA;EACnB,MAAM,QAA0B,CAAC;EACjC,MAAM,cAAc,OAAO,cAAc,YAAY;EACrD,MAAM,gBAAgB,OAAO,gBAAgB,cAAc;EAC3D,MAAM,eAAe,OAAO,eAAe,aAAa;EACxD,IAAI,aAAa,MAAM,UAAU;EACjC,IAAI,eAAe,MAAM,YAAY;EACrC,IAAI,cAAc,MAAM,WAAW;EACnC,OAAO;CACT,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAM,qBAAqBA,MAAM,cAAkC,IAAI;;AAGvE,SAAgB,WAAuB;CACrC,OAAOA,MAA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AC;CAE1C,OACE,iBAAA,GAAA,kBAAA,KAAC,aAAa,UAAd;EAA8B;YAC5B,iBAAA,GAAA,kBAAA,MAAC,mBAAmB,UAApB;GAA6B,OAAO;aAApC,CACG,OAAO,MAAM,iBAAA,GAAA,kBAAA,KAAC,SAAD,EAAA,UAAQ,OAAO,IAAW,CAAA,IAAI,MAC3C,OAC0B;;CACR,CAAA;AAE3B,CACF;;AAGA,SAAgB,YAAY,EAAE,YAA2C;CACvE,MAAM,SAASA,MAAM,WAAW,kBAAkB;CAClD,MAAM,QAAQ,SAAS;CAEvB,MAAM,QAAQA,MAAM,eAAe;EAAE,GAAG;EAAO,UAAU;CAAM,IAAI,CAAC,KAAK,CAAC;CAC1E,IAAI,CAAC,QAAQ,OAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAG,SAAW,CAAA;CAClC,OACE,iBAAA,GAAA,kBAAA,KAAC,aAAa,UAAd;EAA8B;YAC5B,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACE,aAAU;GACV,YAAA,GAAA,GAAA,IAAc,eAAe,MAAM,UAAU;GAC7C,GAAI,OAAO;GACX,oBACE,OAAO,OAAO,SAAS,OAAO,OAAO,KAAK,GAAG,IAAI,KAAA;GAEnD,OAAO;IAAE,SAAS;IAAY,GAAG,OAAO;GAAK;GAE5C;EACE,CAAA;CACgB,CAAA;AAE3B"}
|
|
1
|
+
{"version":3,"file":"theme.cjs","names":["React","isParsableColor","generateAccentScale","resolveAutoNeutral","isSparkNeutralFamily","getMatchingNeutral","CURATED_ACCENTS","appearanceForBackground","accentSparkVars","neutralSparkVars","invertAccentScale","neutralFamilyVars"],"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 appearanceForBackground,\n generateAccentScale,\n getMatchingNeutral,\n invertAccentScale,\n isParsableColor,\n neutralFamilyVars,\n neutralSparkVars,\n resolveAutoNeutral,\n type Appearance,\n type SparkAccentScale,\n} from '../lib/accent-theme'\nimport {\n isSparkNeutralFamily,\n type SparkButtonColor,\n type SparkButtonDesignColor,\n type SparkButtonDesignVariant,\n type SparkButtonRole,\n type SparkButtonRoles,\n type SparkCardColor,\n type SparkCardVariant,\n type SparkInputColor,\n type SparkInputStyle,\n type SparkLabelPosition,\n type SparkNeutral,\n type SparkRadius,\n type SparkScaling,\n type SparkSpacing,\n type SparkStyle,\n} from '../lib/theme-types'\nimport { cn } from '../utils/cn'\n\nexport type {\n SparkButtonColor,\n SparkButtonDesignVariant,\n SparkButtonRole,\n SparkButtonRoles,\n SparkCardColor,\n SparkCardVariant,\n SparkInputColor,\n SparkInputStyle,\n SparkLabelPosition,\n SparkNeutral,\n SparkNeutralFamily,\n SparkRadius,\n SparkScaling,\n SparkSpacing,\n SparkStyle,\n} from '../lib/theme-types'\n\n/** The epilot brand accent — the scale `spark-default.css` ships statically. */\nconst DEFAULT_ACCENT = '#005EB4'\n\nexport interface ThemeValue {\n /** Curated accent name or a custom hex. */\n accentColor?: string\n /**\n * Page canvas as a custom hex. Regenerates BOTH the accent and neutral scales against\n * it (each alpha step is composited against the canvas, so a saturated colour needs\n * the neutral ramp regenerated too, not just the accent). Unset → the fixed\n * `#ffffff` / `#000000` default, and neutrals stay on the static Radix families.\n */\n backgroundColor?: string\n /**\n * A curated family name, an arbitrary color to seed the neutral scale, or `'auto'` to\n * resolve one — preferring `backgroundColor`'s own hue when it's perceptibly tinted,\n * else pairing with the accent (Radix's `grayColor=\"auto\"`). A custom seed (from `auto`\n * or set directly) only regenerates the scale alongside a `backgroundColor`; without\n * one, `data-neutral-color` falls back to the accent-matched family and that's what\n * actually paints.\n */\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 /**\n * Orthogonal to `styleVariant`: re-casts the accent scale for use ON its own solid fill,\n * for controls sitting on a solid accent surface (a `<Card variant=\"solid\" color=\"accent\">`),\n * where a solid control would otherwise paint the same `--spark-9` as the card and vanish.\n * Swaps step 9 with its contrast ink, so the fill/ink pair stays WCAG-safe for any accent.\n */\n inverted?: 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 /** Looks of the `primary`, `secondary` and `tertiary` `<Button variant>`. */\n buttons?: SparkButtonRoles\n appearance?: Appearance\n /** Font stack for `h1`–`h6`. Any valid CSS `font-family` value. */\n fontHeading?: string\n /** Font stack for everything else. Any valid CSS `font-family` value. */\n fontBody?: string\n}\n\nconst ThemeContext = React.createContext<ThemeValue>({})\n\n/** What a Theme actually wrote to the DOM, merged over its ancestors (nearest wins). */\ninterface ThemeOutput {\n attrs: Record<string, string>\n vars: Record<string, string>\n scopes: string[]\n}\n\nfunction roleOf(\n style: SparkStyle | undefined,\n color: SparkButtonRole['color'],\n) {\n if (style === undefined && color === undefined) return undefined\n return {\n ...(style !== undefined && { style }),\n ...(color !== undefined && { color }),\n }\n}\n\nconst DESIGN_VARIANTS = [\n 'primary',\n 'secondary',\n 'tertiary',\n] as const satisfies readonly SparkButtonDesignVariant[]\n\nexport function isDesignColor(value: unknown): value is SparkButtonDesignColor {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as SparkButtonDesignColor).light === 'string'\n )\n}\n\nconst colorKey = (color: SparkButtonRole['color']) =>\n isDesignColor(color)\n ? JSON.stringify({ light: color.light, dark: color.dark })\n : color\n\nconst colorFromKey = (key: string | undefined): SparkButtonRole['color'] =>\n key?.startsWith('{')\n ? (JSON.parse(key) as SparkButtonDesignColor)\n : (key as SparkButtonColor | undefined)\n\nfunction parsableColor(\n variant: SparkButtonDesignVariant,\n color: SparkButtonRole['color'],\n): SparkButtonRole['color'] {\n if (!isDesignColor(color)) return color\n if (!isParsableColor(color.light)) {\n console.warn(\n `[Theme] Ignoring invalid buttons.${variant}.color \"${color.light}\".`,\n )\n return undefined\n }\n if (color.dark !== undefined && !isParsableColor(color.dark)) {\n console.warn(\n `[Theme] Ignoring invalid buttons.${variant}.color dark \"${color.dark}\".`,\n )\n return { light: color.light }\n }\n return color.dark === undefined ? { light: color.light } : color\n}\n\nfunction useButtonRoles(buttons: SparkButtonRoles | undefined) {\n const isSet = buttons !== undefined\n const { primary, secondary, tertiary } = buttons ?? {}\n const primaryStyle = primary?.style\n const primaryColor = colorKey(primary?.color)\n const secondaryStyle = secondary?.style\n const secondaryColor = colorKey(secondary?.color)\n const tertiaryStyle = tertiary?.style\n const tertiaryColor = colorKey(tertiary?.color)\n return React.useMemo<SparkButtonRoles | undefined>(() => {\n if (!isSet) return undefined\n const roles: SparkButtonRoles = {}\n const primaryRole = roleOf(\n primaryStyle,\n parsableColor('primary', colorFromKey(primaryColor)),\n )\n const secondaryRole = roleOf(\n secondaryStyle,\n parsableColor('secondary', colorFromKey(secondaryColor)),\n )\n const tertiaryRole = roleOf(\n tertiaryStyle,\n parsableColor('tertiary', colorFromKey(tertiaryColor)),\n )\n if (primaryRole) roles.primary = primaryRole\n if (secondaryRole) roles.secondary = secondaryRole\n if (tertiaryRole) roles.tertiary = tertiaryRole\n return roles\n }, [\n isSet,\n primaryStyle,\n primaryColor,\n secondaryStyle,\n secondaryColor,\n tertiaryStyle,\n tertiaryColor,\n ])\n}\n\nfunction mergeRoles(\n parent: SparkButtonRoles | undefined,\n own: SparkButtonRoles,\n): SparkButtonRoles {\n const merged: SparkButtonRoles = { ...parent }\n for (const variant of DESIGN_VARIANTS) {\n if (own[variant])\n merged[variant] = { ...parent?.[variant], ...own[variant] }\n }\n return merged\n}\n\nfunction buttonColorDecls(\n roles: SparkButtonRoles | undefined,\n appearance: Appearance,\n): string[] {\n const decls: string[] = []\n for (const variant of DESIGN_VARIANTS) {\n const color = roles?.[variant]?.color\n if (!isDesignColor(color)) continue\n const hex =\n appearance === 'dark' ? (color.dark ?? color.light) : color.light\n const scale = generateAccentScale(hex, appearance)\n const prefix = `--spark-button-${variant}`\n decls.push(\n ...scale.accentScale.map((c, i) => `${prefix}-${i + 1}: ${c};`),\n ...scale.accentScaleAlpha.map((c, i) => `${prefix}-a${i + 1}: ${c};`),\n `${prefix}-contrast: ${scale.accentContrast};`,\n `${prefix}-on-solid: ${scale.accentOnSolid};`,\n `${prefix}-surface: ${scale.accentSurface};`,\n )\n }\n return decls\n}\n\nfunction declsToVars(decls: string[]): Record<string, string> {\n return Object.fromEntries(\n decls.map((decl) => {\n const i = decl.indexOf(':')\n return [decl.slice(0, i).trim(), decl.slice(i + 1, -1).trim()]\n }),\n )\n}\n\nconst ThemeOutputContext = React.createContext<ThemeOutput | null>(null)\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 backgroundColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n inverted,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n buttons: buttonsProp,\n appearance,\n fontHeading,\n fontBody,\n render,\n className,\n style,\n children,\n ...rest\n },\n ref,\n ) {\n const parent = useTheme()\n const buttons = useButtonRoles(buttonsProp)\n const parentOutput = React.useContext(ThemeOutputContext)\n\n const value = React.useMemo<ThemeValue>(\n () => ({\n accentColor: accentColor ?? parent.accentColor,\n backgroundColor: backgroundColor ?? parent.backgroundColor,\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 inverted: inverted ?? parent.inverted,\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 buttons: buttons ? mergeRoles(parent.buttons, buttons) : parent.buttons,\n appearance: appearance ?? parent.appearance,\n fontHeading: fontHeading ?? parent.fontHeading,\n fontBody: fontBody ?? parent.fontBody,\n }),\n [\n accentColor,\n backgroundColor,\n neutralColor,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n inverted,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n buttons,\n appearance,\n fontHeading,\n fontBody,\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 // 'auto' pairs a neutral with the canvas's own tint when it has one, else the\n // effective accent (Radix's grayColor=\"auto\") — see resolveAutoNeutral. Reads the\n // OWN backgroundColor, not the merged value.backgroundColor: optsFor (below) only\n // ever regenerates against a scope's own canvas too, so preferring an inherited one\n // here would resolve a seed that then gets silently discarded.\n const rawNeutralColor =\n neutralColor === 'auto'\n ? resolveAutoNeutral(\n value.accentColor ?? DEFAULT_ACCENT,\n backgroundColor,\n )\n : neutralColor\n\n // A custom neutral that isn't a recognized family must be a real, parseable color —\n // reject invalid input here (e.g. a typo'd family name like \"slat\") so it can't throw\n // deep inside the shared generator, where the catch below would otherwise blame\n // accentColor/backgroundColor without ever naming neutralColor as the actual cause.\n const neutralColorIsValid =\n rawNeutralColor === undefined ||\n isSparkNeutralFamily(rawNeutralColor) ||\n isParsableColor(rawNeutralColor)\n if (!neutralColorIsValid) {\n console.warn(\n `[Theme] Ignoring invalid neutralColor \"${rawNeutralColor}\" — falling back to the accent-matched family.`,\n )\n }\n const resolvedNeutralColor = neutralColorIsValid\n ? rawNeutralColor\n : getMatchingNeutral(value.accentColor ?? DEFAULT_ACCENT)\n\n // The DOM attribute stays one of the 6 static families `[data-neutral-color]` has CSS\n // for — a raw color (from the canvas-tinted auto path, or an arbitrary neutralColor\n // prop) falls back to its accent-matched family here instead, so the attribute is\n // always CSS-selectable/debuggable rather than a sentinel nothing matches.\n // generateAccentScale still gets the real resolvedNeutralColor for generation, below —\n // this substitution is display-only, and doesn't by itself guarantee the *other*\n // appearance's neutrals in ambient (no explicit `appearance`) mode: that's a\n // pre-existing cross-appearance leak in the same family as review-findings.md #5, not\n // something this attribute fallback fixes or regresses.\n const neutralColorAttr =\n resolvedNeutralColor === undefined\n ? undefined\n : isSparkNeutralFamily(resolvedNeutralColor)\n ? resolvedNeutralColor\n : getMatchingNeutral(value.accentColor ?? DEFAULT_ACCENT)\n\n const accent = React.useMemo(() => {\n const empty = {\n inlineVars: {} as React.CSSProperties,\n portalVars: {} as React.CSSProperties,\n portalScope: undefined as string | undefined,\n css: '',\n scoped: false,\n }\n // A custom canvas generates even with no accent of its own: the neutral ramp is\n // composited against it, and --spark-background has to carry it.\n if (!accentColor && !backgroundColor) 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 source = value.accentColor ?? DEFAULT_ACCENT\n const hex = CURATED_ACCENTS[source] ?? source\n\n // A canvas has a polarity, unlike an accent hue: a yellow page is a *light*\n // page, and reusing it for the dark scale yields light ink on a light canvas\n // (measured 1.16:1). So the custom canvas applies to the appearance it actually\n // belongs to, and the other keeps its default. One knob still covers the common\n // case — a tenant wanting both sets an explicit appearance per scope.\n const bgAppearance = backgroundColor\n ? appearanceForBackground(backgroundColor)\n : undefined\n\n // Honouring a mismatched canvas would paint light ink on a light page, so it's\n // dropped — but say so, or the prop looks broken.\n if (\n backgroundColor &&\n value.appearance &&\n bgAppearance !== value.appearance\n ) {\n console.warn(\n `[Theme] Ignoring backgroundColor \"${backgroundColor}\": it reads as a ${bgAppearance} canvas on an appearance=\"${value.appearance}\" scope. Pass a ${value.appearance} colour, or set it on a scope whose appearance matches.`,\n )\n }\n\n // Default to slate so a regenerated neutral stays in the family the static\n // `:root` default already points at, rather than the generator's ECP gray seed.\n const optsFor = (appearance: Appearance) =>\n backgroundColor && bgAppearance === appearance\n ? {\n background: backgroundColor,\n neutral: resolvedNeutralColor ?? ('slate' as const),\n }\n : undefined\n\n // Neutrals are only worth regenerating against a custom canvas — see\n // neutralSparkVars. Without one the static Radix families are already correct.\n const emit = (scale: SparkAccentScale, custom: boolean) =>\n custom\n ? [...accentSparkVars(scale), ...neutralSparkVars(scale)]\n : accentSparkVars(scale)\n\n const build = (appearance: Appearance) => {\n const opts = optsFor(appearance)\n const scale = generateAccentScale(hex, appearance, opts)\n // `inverted` re-casts the accent for a solid-accent surface; the neutral ramp is\n // unrelated to that swap, so it passes through untouched.\n const rendered = emit(\n inverted ? invertAccentScale(scale) : scale,\n opts != null,\n )\n // Popups sit on their own surface, so they get the scale before the inverted re-cast.\n const plain = inverted ? emit(scale, opts != null) : rendered\n return { rendered, plain }\n }\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 const { rendered, plain } = build(value.appearance)\n const inlineVars = toVars(rendered)\n return {\n inlineVars,\n portalVars: inverted ? toVars(plain) : inlineVars,\n portalScope: undefined,\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 //\n // Both blocks must declare the SAME tokens. A custom canvas only regenerates\n // neutrals for its own appearance (see optsFor), and a custom property the other\n // block leaves undeclared keeps its sibling's value rather than falling back — so\n // the off-canvas appearance would paint this one's canvas-tinted neutrals, and\n // being unlayered they'd beat `[data-neutral-color]`'s @layer base mapping too.\n // Point it at the static family instead: the same seed the canvas side was given,\n // so the two appearances agree on family and differ only in canvas.\n const offCanvasNeutrals = backgroundColor\n ? neutralFamilyVars(resolvedNeutralColor ?? 'slate')\n : []\n const scaleFor = (appearance: Appearance) => {\n const { rendered, plain } = build(appearance)\n const extra = bgAppearance === appearance ? [] : offCanvasNeutrals\n return {\n rendered: [...rendered, ...extra],\n plain: [...plain, ...extra],\n }\n }\n const light = scaleFor('light')\n const dark = scaleFor('dark')\n const rule = (\n id: string,\n lightDecls: string[],\n darkDecls: string[],\n ) => {\n const sel = `[data-spark-scope~=\"${id}\"]`\n return `${sel}{${lightDecls.join('')}}:is(.dark,.dark-theme) ${sel}{${darkDecls.join('')}}`\n }\n const portalScope = inverted ? `${scopeId}p` : scopeId\n const css =\n rule(scopeId, light.rendered, dark.rendered) +\n (inverted ? rule(portalScope, light.plain, dark.plain) : '')\n return {\n inlineVars: {} as React.CSSProperties,\n portalVars: {} as React.CSSProperties,\n portalScope,\n css,\n scoped: true,\n }\n } catch (error) {\n // A bad accentColor/backgroundColor must not throw through render — fall back\n // to the default theme.\n console.warn(\n `[Theme] Ignoring invalid accentColor \"${accentColor}\" / backgroundColor \"${backgroundColor}\".`,\n error,\n )\n return empty\n }\n }, [\n accentColor,\n backgroundColor,\n inverted,\n resolvedNeutralColor,\n value.accentColor,\n value.appearance,\n scopeId,\n ])\n\n const attrs = React.useMemo(\n () => ({\n 'data-neutral-color': neutralColorAttr,\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,\n }),\n [\n neutralColorAttr,\n radius,\n scaling,\n spacing,\n styleVariant,\n highContrast,\n labelPosition,\n inputStyle,\n inputColor,\n cardVariant,\n cardColor,\n ],\n )\n const fontVars = React.useMemo(\n () => ({\n ...(fontHeading ? { '--spark-font-heading': fontHeading } : null),\n ...(fontBody ? { '--spark-font-body': fontBody } : null),\n }),\n [fontHeading, fontBody],\n )\n\n const buttonVars = React.useMemo(() => {\n if (value.appearance) {\n const decls = buttonColorDecls(buttons, value.appearance)\n return { vars: declsToVars(decls), scope: undefined, css: '' }\n }\n const light = buttonColorDecls(buttons, 'light')\n const dark = buttonColorDecls(buttons, 'dark')\n if (!light.length) return { vars: {}, scope: undefined, css: '' }\n const scope = `${scopeId}b`\n const sel = `[data-spark-scope~=\"${scope}\"]`\n return {\n vars: {},\n scope,\n css: `${sel}{${light.join('')}}:is(.dark,.dark-theme) ${sel}{${dark.join('')}}`,\n }\n }, [buttons, value.appearance, scopeId])\n\n const ownScopes = [\n ...(accent.scoped ? [scopeId] : []),\n ...(buttonVars.scope ? [buttonVars.scope] : []),\n ]\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 ...attrs,\n 'data-inverted': inverted ? '' : undefined,\n 'data-spark-scope': ownScopes.length\n ? ownScopes.join(' ')\n : undefined,\n style: {\n ...accent.inlineVars,\n // Paint the canvas we were handed, else the prop emits a token and visibly\n // does nothing. Reads the var (not the raw prop) so the scoped <style>'s\n // per-appearance value still wins under ambient appearance.\n ...(backgroundColor\n ? { backgroundColor: 'var(--spark-background)' }\n : null),\n ...fontVars,\n ...buttonVars.vars,\n ...style,\n } as React.CSSProperties,\n children,\n } as React.ComponentProps<'div'>,\n rest,\n ),\n })\n\n const output = React.useMemo<ThemeOutput>(() => {\n // An unset own knob must not blank out the ancestor's value it inherits.\n const own = Object.fromEntries(\n Object.entries(attrs).filter(\n (entry): entry is [string, string] => entry[1] !== undefined,\n ),\n )\n const parentScopes = parentOutput?.scopes ?? []\n return {\n attrs: { ...parentOutput?.attrs, ...own },\n vars: {\n ...parentOutput?.vars,\n ...(accent.portalVars as Record<string, string>),\n ...fontVars,\n ...buttonVars.vars,\n },\n scopes: [\n ...parentScopes,\n ...(accent.portalScope ? [accent.portalScope] : []),\n ...(buttonVars.scope ? [buttonVars.scope] : []),\n ],\n }\n }, [parentOutput, attrs, accent, fontVars, buttonVars])\n\n return (\n <ThemeContext.Provider value={value}>\n <ThemeOutputContext.Provider value={output}>\n {accent.css ? <style>{accent.css}</style> : null}\n {buttonVars.css ? <style>{buttonVars.css}</style> : null}\n {element}\n </ThemeOutputContext.Provider>\n </ThemeContext.Provider>\n )\n },\n)\n\n/** Re-emits what the enclosing Themes rendered inside a portal, where CSS inheritance from them stops. */\nexport function PortalTheme({ children }: { children: React.ReactNode }) {\n const output = React.useContext(ThemeOutputContext)\n const theme = useTheme()\n // A popup sits on its own surface, never on the solid accent `inverted` is for.\n const value = React.useMemo(() => ({ ...theme, inverted: false }), [theme])\n if (!output) return <>{children}</>\n return (\n <ThemeContext.Provider value={value}>\n <div\n data-slot=\"portal-theme\"\n className={cn('spark-theme', theme.appearance)}\n {...output.attrs}\n data-spark-scope={\n output.scopes.length ? output.scopes.join(' ') : undefined\n }\n style={{ display: 'contents', ...output.vars }}\n >\n {children}\n </div>\n </ThemeContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA0DA,MAAM,iBAAiB;AAkDvB,MAAM,eAAeA,MAAM,cAA0B,CAAC,CAAC;AASvD,SAAS,OACP,OACA,OACA;CACA,IAAI,UAAU,KAAA,KAAa,UAAU,KAAA,GAAW,OAAO,KAAA;CACvD,OAAO;EACL,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;EACnC,GAAI,UAAU,KAAA,KAAa,EAAE,MAAM;CACrC;AACF;AAEA,MAAM,kBAAkB;CACtB;CACA;CACA;AACF;AAEA,SAAgB,cAAc,OAAiD;CAC7E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAiC,UAA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AASA,MAAM,WAAW,kBAAkB;CAClD,MAAM,QAAQ,SAAS;CAEvB,MAAM,QAAQA,MAAM,eAAe;EAAE,GAAG;EAAO,UAAU;CAAM,IAAI,CAAC,KAAK,CAAC;CAC1E,IAAI,CAAC,QAAQ,OAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAG,SAAW,CAAA;CAClC,OACE,iBAAA,GAAA,kBAAA,KAAC,aAAa,UAAd;EAA8B;YAC5B,iBAAA,GAAA,kBAAA,KAAC,OAAD;GACE,aAAU;GACV,YAAA,GAAA,GAAA,IAAc,eAAe,MAAM,UAAU;GAC7C,GAAI,OAAO;GACX,oBACE,OAAO,OAAO,SAAS,OAAO,OAAO,KAAK,GAAG,IAAI,KAAA;GAEnD,OAAO;IAAE,SAAS;IAAY,GAAG,OAAO;GAAK;GAE5C;EACE,CAAA;CACgB,CAAA;AAE3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { a as
|
|
3
|
+
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, u as SparkInputColor, v as SparkStyle } from "../theme-types-Dlge0s3s.cjs";
|
|
4
4
|
import { Appearance } from "../lib/accent-theme.cjs";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
@@ -45,7 +45,7 @@ interface ThemeValue {
|
|
|
45
45
|
cardVariant?: SparkCardVariant;
|
|
46
46
|
/** App-level default `<Card>` palette; a per-card `color` prop overrides it. */
|
|
47
47
|
cardColor?: SparkCardColor;
|
|
48
|
-
/**
|
|
48
|
+
/** Looks of the `primary`, `secondary` and `tertiary` `<Button variant>`. */
|
|
49
49
|
buttons?: SparkButtonRoles;
|
|
50
50
|
appearance?: Appearance;
|
|
51
51
|
/** Font stack for `h1`–`h6`. Any valid CSS `font-family` value. */
|
|
@@ -53,6 +53,7 @@ interface ThemeValue {
|
|
|
53
53
|
/** Font stack for everything else. Any valid CSS `font-family` value. */
|
|
54
54
|
fontBody?: string;
|
|
55
55
|
}
|
|
56
|
+
declare function isDesignColor(value: unknown): value is SparkButtonDesignColor;
|
|
56
57
|
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
57
58
|
declare function useTheme(): ThemeValue;
|
|
58
59
|
interface ThemeProps extends useRender.ComponentProps<'div'>, ThemeValue {}
|
|
@@ -65,5 +66,5 @@ declare function PortalTheme({
|
|
|
65
66
|
children: React$1.ReactNode;
|
|
66
67
|
}): import("react/jsx-runtime").JSX.Element;
|
|
67
68
|
//#endregion
|
|
68
|
-
export { PortalTheme, type SparkButtonColor, type
|
|
69
|
+
export { PortalTheme, type SparkButtonColor, type SparkButtonDesignVariant, type SparkButtonRole, type SparkButtonRoles, type SparkCardColor, type SparkCardVariant, type SparkInputColor, type SparkInputStyle, type SparkLabelPosition, type SparkNeutral, type SparkNeutralFamily, type SparkRadius, type SparkScaling, type SparkSpacing, type SparkStyle, Theme, ThemeProps, ThemeValue, isDesignColor, useTheme };
|
|
69
70
|
//# sourceMappingURL=theme.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { a as
|
|
3
|
+
import { _ as SparkSpacing, a as SparkButtonRole, c as SparkCardColor, d as SparkInputStyle, f as SparkLabelPosition, g as SparkScaling, h as SparkRadius, i as SparkButtonDesignVariant, l as SparkCardVariant, m as SparkNeutralFamily, n as SparkButtonColor, o as SparkButtonRoles, p as SparkNeutral, r as SparkButtonDesignColor, u as SparkInputColor, v as SparkStyle } from "../theme-types-Dlge0s3s.js";
|
|
4
4
|
import { Appearance } from "../lib/accent-theme.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
6
|
import { useRender } from "@base-ui/react/use-render";
|
|
@@ -45,7 +45,7 @@ interface ThemeValue {
|
|
|
45
45
|
cardVariant?: SparkCardVariant;
|
|
46
46
|
/** App-level default `<Card>` palette; a per-card `color` prop overrides it. */
|
|
47
47
|
cardColor?: SparkCardColor;
|
|
48
|
-
/**
|
|
48
|
+
/** Looks of the `primary`, `secondary` and `tertiary` `<Button variant>`. */
|
|
49
49
|
buttons?: SparkButtonRoles;
|
|
50
50
|
appearance?: Appearance;
|
|
51
51
|
/** Font stack for `h1`–`h6`. Any valid CSS `font-family` value. */
|
|
@@ -53,6 +53,7 @@ interface ThemeValue {
|
|
|
53
53
|
/** Font stack for everything else. Any valid CSS `font-family` value. */
|
|
54
54
|
fontBody?: string;
|
|
55
55
|
}
|
|
56
|
+
declare function isDesignColor(value: unknown): value is SparkButtonDesignColor;
|
|
56
57
|
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
57
58
|
declare function useTheme(): ThemeValue;
|
|
58
59
|
interface ThemeProps extends useRender.ComponentProps<'div'>, ThemeValue {}
|
|
@@ -65,5 +66,5 @@ declare function PortalTheme({
|
|
|
65
66
|
children: React$1.ReactNode;
|
|
66
67
|
}): import("react/jsx-runtime").JSX.Element;
|
|
67
68
|
//#endregion
|
|
68
|
-
export { PortalTheme, type SparkButtonColor, type
|
|
69
|
+
export { PortalTheme, type SparkButtonColor, type SparkButtonDesignVariant, type SparkButtonRole, type SparkButtonRoles, type SparkCardColor, type SparkCardVariant, type SparkInputColor, type SparkInputStyle, type SparkLabelPosition, type SparkNeutral, type SparkNeutralFamily, type SparkRadius, type SparkScaling, type SparkSpacing, type SparkStyle, Theme, ThemeProps, ThemeValue, isDesignColor, useTheme };
|
|
69
70
|
//# sourceMappingURL=theme.d.ts.map
|
package/dist/components/theme.js
CHANGED
|
@@ -18,21 +18,46 @@ function roleOf(style, color) {
|
|
|
18
18
|
...color !== void 0 && { color }
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
+
const DESIGN_VARIANTS = [
|
|
22
|
+
"primary",
|
|
23
|
+
"secondary",
|
|
24
|
+
"tertiary"
|
|
25
|
+
];
|
|
26
|
+
function isDesignColor(value) {
|
|
27
|
+
return typeof value === "object" && value !== null && typeof value.light === "string";
|
|
28
|
+
}
|
|
29
|
+
const colorKey = (color) => isDesignColor(color) ? JSON.stringify({
|
|
30
|
+
light: color.light,
|
|
31
|
+
dark: color.dark
|
|
32
|
+
}) : color;
|
|
33
|
+
const colorFromKey = (key) => key?.startsWith("{") ? JSON.parse(key) : key;
|
|
34
|
+
function parsableColor(variant, color) {
|
|
35
|
+
if (!isDesignColor(color)) return color;
|
|
36
|
+
if (!isParsableColor(color.light)) {
|
|
37
|
+
console.warn(`[Theme] Ignoring invalid buttons.${variant}.color "${color.light}".`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (color.dark !== void 0 && !isParsableColor(color.dark)) {
|
|
41
|
+
console.warn(`[Theme] Ignoring invalid buttons.${variant}.color dark "${color.dark}".`);
|
|
42
|
+
return { light: color.light };
|
|
43
|
+
}
|
|
44
|
+
return color.dark === void 0 ? { light: color.light } : color;
|
|
45
|
+
}
|
|
21
46
|
function useButtonRoles(buttons) {
|
|
22
47
|
const isSet = buttons !== void 0;
|
|
23
48
|
const { primary, secondary, tertiary } = buttons ?? {};
|
|
24
49
|
const primaryStyle = primary?.style;
|
|
25
|
-
const primaryColor = primary?.color;
|
|
50
|
+
const primaryColor = colorKey(primary?.color);
|
|
26
51
|
const secondaryStyle = secondary?.style;
|
|
27
|
-
const secondaryColor = secondary?.color;
|
|
52
|
+
const secondaryColor = colorKey(secondary?.color);
|
|
28
53
|
const tertiaryStyle = tertiary?.style;
|
|
29
|
-
const tertiaryColor = tertiary?.color;
|
|
54
|
+
const tertiaryColor = colorKey(tertiary?.color);
|
|
30
55
|
return React$1.useMemo(() => {
|
|
31
56
|
if (!isSet) return void 0;
|
|
32
57
|
const roles = {};
|
|
33
|
-
const primaryRole = roleOf(primaryStyle, primaryColor);
|
|
34
|
-
const secondaryRole = roleOf(secondaryStyle, secondaryColor);
|
|
35
|
-
const tertiaryRole = roleOf(tertiaryStyle, tertiaryColor);
|
|
58
|
+
const primaryRole = roleOf(primaryStyle, parsableColor("primary", colorFromKey(primaryColor)));
|
|
59
|
+
const secondaryRole = roleOf(secondaryStyle, parsableColor("secondary", colorFromKey(secondaryColor)));
|
|
60
|
+
const tertiaryRole = roleOf(tertiaryStyle, parsableColor("tertiary", colorFromKey(tertiaryColor)));
|
|
36
61
|
if (primaryRole) roles.primary = primaryRole;
|
|
37
62
|
if (secondaryRole) roles.secondary = secondaryRole;
|
|
38
63
|
if (tertiaryRole) roles.tertiary = tertiaryRole;
|
|
@@ -47,6 +72,31 @@ function useButtonRoles(buttons) {
|
|
|
47
72
|
tertiaryColor
|
|
48
73
|
]);
|
|
49
74
|
}
|
|
75
|
+
function mergeRoles(parent, own) {
|
|
76
|
+
const merged = { ...parent };
|
|
77
|
+
for (const variant of DESIGN_VARIANTS) if (own[variant]) merged[variant] = {
|
|
78
|
+
...parent?.[variant],
|
|
79
|
+
...own[variant]
|
|
80
|
+
};
|
|
81
|
+
return merged;
|
|
82
|
+
}
|
|
83
|
+
function buttonColorDecls(roles, appearance) {
|
|
84
|
+
const decls = [];
|
|
85
|
+
for (const variant of DESIGN_VARIANTS) {
|
|
86
|
+
const color = roles?.[variant]?.color;
|
|
87
|
+
if (!isDesignColor(color)) continue;
|
|
88
|
+
const scale = generateAccentScale(appearance === "dark" ? color.dark ?? color.light : color.light, appearance);
|
|
89
|
+
const prefix = `--spark-button-${variant}`;
|
|
90
|
+
decls.push(...scale.accentScale.map((c, i) => `${prefix}-${i + 1}: ${c};`), ...scale.accentScaleAlpha.map((c, i) => `${prefix}-a${i + 1}: ${c};`), `${prefix}-contrast: ${scale.accentContrast};`, `${prefix}-on-solid: ${scale.accentOnSolid};`, `${prefix}-surface: ${scale.accentSurface};`);
|
|
91
|
+
}
|
|
92
|
+
return decls;
|
|
93
|
+
}
|
|
94
|
+
function declsToVars(decls) {
|
|
95
|
+
return Object.fromEntries(decls.map((decl) => {
|
|
96
|
+
const i = decl.indexOf(":");
|
|
97
|
+
return [decl.slice(0, i).trim(), decl.slice(i + 1, -1).trim()];
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
50
100
|
const ThemeOutputContext = React$1.createContext(null);
|
|
51
101
|
/** Merged theme values from enclosing `<Theme>` providers. */
|
|
52
102
|
function useTheme() {
|
|
@@ -72,10 +122,7 @@ const Theme = React$1.forwardRef(function Theme({ accentColor, backgroundColor,
|
|
|
72
122
|
inputColor: inputColor ?? parent.inputColor,
|
|
73
123
|
cardVariant: cardVariant ?? parent.cardVariant,
|
|
74
124
|
cardColor: cardColor ?? parent.cardColor,
|
|
75
|
-
buttons: buttons ?
|
|
76
|
-
...parent.buttons,
|
|
77
|
-
...buttons
|
|
78
|
-
} : parent.buttons,
|
|
125
|
+
buttons: buttons ? mergeRoles(parent.buttons, buttons) : parent.buttons,
|
|
79
126
|
appearance: appearance ?? parent.appearance,
|
|
80
127
|
fontHeading: fontHeading ?? parent.fontHeading,
|
|
81
128
|
fontBody: fontBody ?? parent.fontBody
|
|
@@ -214,6 +261,32 @@ const Theme = React$1.forwardRef(function Theme({ accentColor, backgroundColor,
|
|
|
214
261
|
...fontHeading ? { "--spark-font-heading": fontHeading } : null,
|
|
215
262
|
...fontBody ? { "--spark-font-body": fontBody } : null
|
|
216
263
|
}), [fontHeading, fontBody]);
|
|
264
|
+
const buttonVars = React$1.useMemo(() => {
|
|
265
|
+
if (value.appearance) return {
|
|
266
|
+
vars: declsToVars(buttonColorDecls(buttons, value.appearance)),
|
|
267
|
+
scope: void 0,
|
|
268
|
+
css: ""
|
|
269
|
+
};
|
|
270
|
+
const light = buttonColorDecls(buttons, "light");
|
|
271
|
+
const dark = buttonColorDecls(buttons, "dark");
|
|
272
|
+
if (!light.length) return {
|
|
273
|
+
vars: {},
|
|
274
|
+
scope: void 0,
|
|
275
|
+
css: ""
|
|
276
|
+
};
|
|
277
|
+
const scope = `${scopeId}b`;
|
|
278
|
+
const sel = `[data-spark-scope~="${scope}"]`;
|
|
279
|
+
return {
|
|
280
|
+
vars: {},
|
|
281
|
+
scope,
|
|
282
|
+
css: `${sel}{${light.join("")}}:is(.dark,.dark-theme) ${sel}{${dark.join("")}}`
|
|
283
|
+
};
|
|
284
|
+
}, [
|
|
285
|
+
buttons,
|
|
286
|
+
value.appearance,
|
|
287
|
+
scopeId
|
|
288
|
+
]);
|
|
289
|
+
const ownScopes = [...accent.scoped ? [scopeId] : [], ...buttonVars.scope ? [buttonVars.scope] : []];
|
|
217
290
|
const element = useRender({
|
|
218
291
|
defaultTagName: "div",
|
|
219
292
|
render,
|
|
@@ -222,11 +295,12 @@ const Theme = React$1.forwardRef(function Theme({ accentColor, backgroundColor,
|
|
|
222
295
|
className: cn("spark-theme", appearance, className),
|
|
223
296
|
...attrs,
|
|
224
297
|
"data-inverted": inverted ? "" : void 0,
|
|
225
|
-
"data-spark-scope":
|
|
298
|
+
"data-spark-scope": ownScopes.length ? ownScopes.join(" ") : void 0,
|
|
226
299
|
style: {
|
|
227
300
|
...accent.inlineVars,
|
|
228
301
|
...backgroundColor ? { backgroundColor: "var(--spark-background)" } : null,
|
|
229
302
|
...fontVars,
|
|
303
|
+
...buttonVars.vars,
|
|
230
304
|
...style
|
|
231
305
|
},
|
|
232
306
|
children
|
|
@@ -243,21 +317,31 @@ const Theme = React$1.forwardRef(function Theme({ accentColor, backgroundColor,
|
|
|
243
317
|
vars: {
|
|
244
318
|
...parentOutput?.vars,
|
|
245
319
|
...accent.portalVars,
|
|
246
|
-
...fontVars
|
|
320
|
+
...fontVars,
|
|
321
|
+
...buttonVars.vars
|
|
247
322
|
},
|
|
248
|
-
scopes:
|
|
323
|
+
scopes: [
|
|
324
|
+
...parentScopes,
|
|
325
|
+
...accent.portalScope ? [accent.portalScope] : [],
|
|
326
|
+
...buttonVars.scope ? [buttonVars.scope] : []
|
|
327
|
+
]
|
|
249
328
|
};
|
|
250
329
|
}, [
|
|
251
330
|
parentOutput,
|
|
252
331
|
attrs,
|
|
253
332
|
accent,
|
|
254
|
-
fontVars
|
|
333
|
+
fontVars,
|
|
334
|
+
buttonVars
|
|
255
335
|
]);
|
|
256
336
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, {
|
|
257
337
|
value,
|
|
258
338
|
children: /* @__PURE__ */ jsxs(ThemeOutputContext.Provider, {
|
|
259
339
|
value: output,
|
|
260
|
-
children: [
|
|
340
|
+
children: [
|
|
341
|
+
accent.css ? /* @__PURE__ */ jsx("style", { children: accent.css }) : null,
|
|
342
|
+
buttonVars.css ? /* @__PURE__ */ jsx("style", { children: buttonVars.css }) : null,
|
|
343
|
+
element
|
|
344
|
+
]
|
|
261
345
|
})
|
|
262
346
|
});
|
|
263
347
|
});
|
|
@@ -286,6 +370,6 @@ function PortalTheme({ children }) {
|
|
|
286
370
|
});
|
|
287
371
|
}
|
|
288
372
|
//#endregion
|
|
289
|
-
export { PortalTheme, Theme, useTheme };
|
|
373
|
+
export { PortalTheme, Theme, isDesignColor, useTheme };
|
|
290
374
|
|
|
291
375
|
//# sourceMappingURL=theme.js.map
|