entasis 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/attachments/spinnerOverlay.theme.d.ts +2 -36
- package/dist/components/AIAskUserQuestion/aiAskUserQuestion.theme.d.ts +2 -30
- package/dist/components/AIChat/aiChat.theme.d.ts +2 -14
- package/dist/components/AIComposer/aiComposer.theme.d.ts +2 -50
- package/dist/components/AIContext/aiContext.theme.d.ts +2 -37
- package/dist/components/AIConversation/aiConversation.theme.d.ts +2 -4
- package/dist/components/AIFilePreview/aiFilePreview.theme.d.ts +2 -17
- package/dist/components/AIMarker/aiMarker.theme.d.ts +2 -18
- package/dist/components/AIMessage/aiMessage.theme.d.ts +2 -72
- package/dist/components/AIMessageActions/aiMessageActions.theme.d.ts +2 -29
- package/dist/components/AIModelSelector/aiModelSelector.theme.d.ts +2 -25
- package/dist/components/AIReasoning/aiReasoning.theme.d.ts +2 -9
- package/dist/components/AISuggestion/aiSuggestion.theme.d.ts +2 -6
- package/dist/components/AIThread/aiThread.theme.d.ts +2 -35
- package/dist/components/AIThreadToc/aiThreadToc.theme.d.ts +2 -44
- package/dist/components/AITool/aiTool.mcp.d.ts +1 -1
- package/dist/components/AITool/aiTool.mcp.js +1 -1
- package/dist/components/AITool/aiTool.theme.d.ts +2 -170
- package/dist/components/AITool/aiTool.theme.js +14 -12
- package/dist/components/Accordion/accordion.theme.d.ts +2 -135
- package/dist/components/Alert/alert.theme.d.ts +2 -88
- package/dist/components/AppShell/appShell.theme.d.ts +2 -34
- package/dist/components/AspectRatio/aspectRatio.theme.d.ts +2 -5
- package/dist/components/AudioPlayer/audioPlayer.theme.d.ts +2 -179
- package/dist/components/Avatar/avatar.theme.d.ts +2 -38
- package/dist/components/Avatar/avatarGroup.theme.d.ts +2 -17
- package/dist/components/Breadcrumbs/breadcrumbs.theme.d.ts +2 -33
- package/dist/components/Button/Button.svelte +15 -13
- package/dist/components/Button/button.theme.d.ts +2 -55
- package/dist/components/ButtonGroup/buttonGroup.theme.d.ts +2 -4
- package/dist/components/Card/card.theme.d.ts +2 -119
- package/dist/components/Carousel/carousel.theme.d.ts +2 -73
- package/dist/components/Chart/chart.theme.d.ts +2 -24
- package/dist/components/Chip/chip.theme.d.ts +2 -56
- package/dist/components/Code/code.theme.d.ts +2 -9
- package/dist/components/Collapsible/collapsible.theme.d.ts +2 -44
- package/dist/components/Command/command.theme.d.ts +2 -103
- package/dist/components/Confirmation/confirmation.theme.d.ts +2 -10
- package/dist/components/ContextMenu/contextMenu.theme.d.ts +2 -10
- package/dist/components/DataTable/dataTable.theme.d.ts +2 -160
- package/dist/components/Dialog/Dialog.svelte +16 -0
- package/dist/components/Dialog/dialog.mcp.d.ts +1 -1
- package/dist/components/Dialog/dialog.mcp.js +2 -1
- package/dist/components/Dialog/dialog.props.d.ts +5 -0
- package/dist/components/Dialog/dialog.theme.d.ts +2 -137
- package/dist/components/Dialog/dialog.theme.js +12 -8
- package/dist/components/Diff/diff.theme.d.ts +2 -6
- package/dist/components/DocumentViewer/documentViewer.theme.d.ts +2 -87
- package/dist/components/Empty/empty.theme.d.ts +2 -71
- package/dist/components/EventCalendar/eventCalendar.theme.d.ts +2 -3171
- package/dist/components/FloatingWindow/floatingWindow.theme.d.ts +2 -96
- package/dist/components/Form/Calendar/CalendarPrimitive.svelte.d.ts +2 -63
- package/dist/components/Form/Calendar/calendar.theme.d.ts +2 -63
- package/dist/components/Form/CheckboxesInput/checkboxesInput.theme.d.ts +2 -100
- package/dist/components/Form/ColorInput/colorInput.theme.d.ts +2 -32
- package/dist/components/Form/ColorPicker/colorPicker.theme.d.ts +2 -127
- package/dist/components/Form/Combobox/combobox.theme.d.ts +2 -50
- package/dist/components/Form/DateInput/dateInput.theme.d.ts +2 -26
- package/dist/components/Form/DateSelector/dateSelector.theme.d.ts +2 -17
- package/dist/components/Form/Field/field.theme.d.ts +2 -146
- package/dist/components/Form/File/fileInput.theme.d.ts +2 -41
- package/dist/components/Form/Form/form.theme.d.ts +2 -129
- package/dist/components/Form/KeyValueInput/keyValueInput.theme.d.ts +2 -50
- package/dist/components/Form/MultiStepForm/multiStepForm.theme.d.ts +2 -25
- package/dist/components/Form/NumberInput/numberInput.theme.d.ts +2 -25
- package/dist/components/Form/PasswordInput/passwordInput.theme.d.ts +2 -25
- package/dist/components/Form/PhoneInput/phoneInput.theme.d.ts +2 -112
- package/dist/components/Form/PinInput/pinInput.theme.d.ts +2 -38
- package/dist/components/Form/RadioInput/radioInput.theme.d.ts +2 -94
- package/dist/components/Form/Select/select.theme.d.ts +2 -71
- package/dist/components/Form/Slider/slider.theme.d.ts +2 -266
- package/dist/components/Form/Switch/switch.theme.d.ts +2 -40
- package/dist/components/Form/TagGroup/tagGroup.theme.d.ts +2 -19
- package/dist/components/Form/TagsInput/tagsInput.theme.d.ts +2 -53
- package/dist/components/Form/TextArea/textArea.theme.d.ts +2 -25
- package/dist/components/Form/TextInput/textInput.theme.d.ts +2 -25
- package/dist/components/Form/TimeInput/timeInput.theme.d.ts +2 -47
- package/dist/components/Form/VoiceInput/voiceInput.theme.d.ts +2 -155
- package/dist/components/GanttChart/ganttChart.theme.d.ts +2 -2478
- package/dist/components/Globe/globe.theme.d.ts +2 -13
- package/dist/components/Grid/grid.theme.d.ts +2 -18
- package/dist/components/Grid/gridSpan.theme.d.ts +2 -4
- package/dist/components/Heading/heading.theme.d.ts +2 -41
- package/dist/components/Hitbox/hitbox.theme.d.ts +2 -10
- package/dist/components/HoverCard/hoverCard.theme.d.ts +11 -27
- package/dist/components/HoverCard/hoverCard.theme.js +9 -4
- package/dist/components/ImageGallery/imageGallery.theme.d.ts +2 -6
- package/dist/components/ImageZoom/imageZoom.theme.d.ts +2 -16
- package/dist/components/Kanban/kanban.theme.d.ts +2 -60
- package/dist/components/Kbd/kbd.theme.d.ts +2 -33
- package/dist/components/Layout/layoutSpacing.d.ts +1 -1
- package/dist/components/LinkPreview/linkPreview.theme.d.ts +2 -58
- package/dist/components/Map/map.theme.d.ts +2 -14
- package/dist/components/Markdown/markdown.theme.d.ts +2 -10
- package/dist/components/Marquee/marquee.theme.d.ts +2 -37
- package/dist/components/MediaVolume/mediaVolumeControl.theme.d.ts +2 -22
- package/dist/components/Menu/menu.theme.d.ts +2 -12
- package/dist/components/MenuBar/menuBar.theme.d.ts +2 -16
- package/dist/components/MenuOption/menuOption.theme.d.ts +2 -75
- package/dist/components/Mermaid/mermaid.theme.d.ts +2 -15
- package/dist/components/MetadataList/metadataList.theme.d.ts +2 -97
- package/dist/components/Meter/meter.theme.d.ts +2 -111
- package/dist/components/MiniCalendar/miniCalendar.theme.d.ts +2 -71
- package/dist/components/NetworkIndicator/networkIndicator.theme.d.ts +2 -41
- package/dist/components/Overlay/overlay.theme.d.ts +2 -92
- package/dist/components/PageShell/pageShell.theme.d.ts +2 -36
- package/dist/components/Pagination/pagination.theme.d.ts +2 -108
- package/dist/components/Popover/popover.theme.d.ts +2 -40
- package/dist/components/PopupMenu/popupMenu.theme.d.ts +2 -4
- package/dist/components/ProgressCircle/progressCircle.theme.d.ts +2 -22
- package/dist/components/QRCode/qrCode.theme.d.ts +2 -19
- package/dist/components/Rating/rating.theme.d.ts +2 -37
- package/dist/components/Resizable/resizable.theme.d.ts +2 -65
- package/dist/components/RichTextInput/richTextInput.theme.d.ts +2 -167
- package/dist/components/ScrollArea/scrollArea.theme.d.ts +2 -15
- package/dist/components/SegmentedControl/segmentedControl.theme.d.ts +2 -76
- package/dist/components/SelectionMenu/selectionMenu.theme.d.ts +2 -5
- package/dist/components/Separator/separator.theme.d.ts +2 -33
- package/dist/components/Sidebar/SidebarAction.svelte +2 -2
- package/dist/components/Sidebar/SidebarActivityBar.svelte +3 -3
- package/dist/components/Sidebar/SidebarGroup.svelte +6 -6
- package/dist/components/Sidebar/SidebarMenuButton.svelte +15 -18
- package/dist/components/Sidebar/SidebarMenuItem.svelte +15 -21
- package/dist/components/Sidebar/SidebarMenuSubItem.svelte +5 -6
- package/dist/components/Sidebar/SidebarPanel.svelte +3 -6
- package/dist/components/Sidebar/SidebarTreeNode.svelte +2 -2
- package/dist/components/Sidebar/sidebar.theme.d.ts +86 -540
- package/dist/components/Sidebar/sidebar.theme.js +69 -67
- package/dist/components/Skeleton/skeleton.theme.d.ts +2 -14
- package/dist/components/SortableList/sortableList.theme.d.ts +2 -43
- package/dist/components/Spinner/spinner.theme.d.ts +2 -41
- package/dist/components/SpinnerText/spinnerText.theme.d.ts +2 -49
- package/dist/components/Stack/stack.theme.d.ts +2 -12
- package/dist/components/Stat/stat.theme.d.ts +2 -132
- package/dist/components/Stepper/stepper.theme.d.ts +2 -22
- package/dist/components/Tabbar/tabbar.theme.d.ts +2 -110
- package/dist/components/Table/table.theme.d.ts +2 -42
- package/dist/components/TableOfContents/tableOfContents.theme.d.ts +2 -28
- package/dist/components/Tabs/tabs.theme.d.ts +2 -20
- package/dist/components/Theme/Theme.svelte +4 -4
- package/dist/components/Theme/theme.designTokens.d.ts +10 -0
- package/dist/components/Theme/theme.designTokens.js +14 -1
- package/dist/components/Theme/theme.state.svelte.js +3 -3
- package/dist/components/Timeline/timeline.theme.d.ts +2 -226
- package/dist/components/Toast/toast.theme.d.ts +2 -236
- package/dist/components/ToggleButton/toggleButton.theme.d.ts +2 -57
- package/dist/components/ToggleButtonGroup/toggleButtonGroup.theme.d.ts +2 -9
- package/dist/components/ToggleMenu/toggleMenu.theme.d.ts +2 -7
- package/dist/components/Tooltip/tooltip.theme.d.ts +2 -25
- package/dist/components/Tree/tree.theme.d.ts +2 -7
- package/dist/components/VideoPlayer/videoPlayer.theme.d.ts +2 -145
- package/dist/generated/componentContract.d.ts +1 -1
- package/dist/generated/componentContract.js +2 -0
- package/dist/generated/componentMcpRegistry.d.ts +3 -3
- package/dist/tailwind/colors.js +7 -1
- package/dist/tailwind/spacing.d.ts +13 -0
- package/dist/tailwind/spacing.js +5 -2
- package/dist/utils/cva/cva.mcp.d.ts +1 -1
- package/dist/utils/cva/cva.mcp.js +1 -1
- package/dist/utils/cva/index.d.ts +1 -1
- package/dist/utils/cva/theme.d.ts +36 -1
- package/dist/utils/cva/theme.js +25 -2
- package/package.json +1 -1
|
@@ -3,5 +3,5 @@ export const cvaDescription = `
|
|
|
3
3
|
|
|
4
4
|
Import from \`entasis/cva\`.
|
|
5
5
|
|
|
6
|
-
cva defines class variants and defaults. cx joins class values; compose composes variants. setComponentTheme and useComponentTheme connect component theme definitions to the Svelte theme context. VariantProps and InferComponentTheme derive the corresponding public types. Keep component CVA definitions beside their owner in a .theme.ts file.
|
|
6
|
+
cva defines class variants and defaults. cx joins class values; compose composes variants. setComponentTheme and useComponentTheme connect component theme definitions to the Svelte theme context. A resolver takes an optional second argument, the shared variant values, and then returns every class slot already bound to them, so a template calls \`slots.root()\` instead of passing the same props to each slot. VariantProps and InferComponentTheme derive the corresponding public types. Keep component CVA definitions beside their owner in a .theme.ts file.
|
|
7
7
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { cva, cx, compose } from './engine.js';
|
|
2
2
|
export { setComponentTheme, useComponentTheme } from './theme.js';
|
|
3
|
-
export type { ComponentVariant, InferComponentTheme } from './theme.js';
|
|
3
|
+
export type { ComponentVariant, InferComponentTheme, SharedThemeProps, BoundTheme } from './theme.js';
|
|
4
4
|
export type { VariantProps, ClassValue, ClassArray, ClassDictionary } from './types.js';
|
|
@@ -27,13 +27,20 @@ export type InferComponentTheme<T extends ComponentTheme> = Partial<{
|
|
|
27
27
|
override?: boolean;
|
|
28
28
|
};
|
|
29
29
|
export declare const setComponentTheme: <T extends ComponentTheme>(component: string) => (theme: InferComponentTheme<T>) => void;
|
|
30
|
+
/** The resolver `useComponentTheme` returns: the theme's class slots, optionally pre-bound. */
|
|
31
|
+
export type UseComponentTheme<T extends ComponentTheme> = {
|
|
32
|
+
/** With shared variant values: every class slot already carrying them (`slots.root()`). */
|
|
33
|
+
(theme: InferComponentTheme<T> | undefined, shared: SharedThemeProps<T>): BoundTheme<T>;
|
|
34
|
+
/** The resolved theme, one class function per slot. Last, so `ReturnType` reads this one. */
|
|
35
|
+
(theme?: InferComponentTheme<T>): T;
|
|
36
|
+
};
|
|
30
37
|
/**
|
|
31
38
|
* Resolves a component's class slots through the same ladder `useComponentMotion` walks,
|
|
32
39
|
* lowest first: the component's own theme, the `<Theme components>` registry, a
|
|
33
40
|
* `set<Component>Theme` subtree, then the instance `theme` prop. Each rung layers on the
|
|
34
41
|
* one below it — a subtree that restyles one slot must not drop the registry's others.
|
|
35
42
|
*/
|
|
36
|
-
export declare const useComponentTheme: <T extends ComponentTheme>(component: string, defaultTheme: T) =>
|
|
43
|
+
export declare const useComponentTheme: <T extends ComponentTheme>(component: string, defaultTheme: T) => UseComponentTheme<T>;
|
|
37
44
|
/**
|
|
38
45
|
* One component's entry in the `<Theme components>` registry: the same object a
|
|
39
46
|
* `set<Component>Theme` call takes — class slots plus the reserved `motion` slot.
|
|
@@ -51,4 +58,32 @@ export type ComponentThemeOverride = {
|
|
|
51
58
|
};
|
|
52
59
|
/** App-wide component theme defaults, keyed by the component's theme context name. */
|
|
53
60
|
export type ComponentThemeRegistry = Record<string, ComponentThemeOverride>;
|
|
61
|
+
type SlotProps<S> = S extends (props?: infer P) => string ? NonNullable<P> : never;
|
|
62
|
+
type KeysOfUnion<U> = U extends unknown ? keyof U : never;
|
|
63
|
+
type ValueIn<U, K> = U extends unknown ? (K extends keyof U ? U[K] : never) : never;
|
|
64
|
+
type ClassSlots<T> = {
|
|
65
|
+
[K in keyof T as T[K] extends (props?: never) => string ? K : never]: T[K];
|
|
66
|
+
};
|
|
67
|
+
type AnySlotProps<T> = SlotProps<ClassSlots<T>[keyof ClassSlots<T>]>;
|
|
68
|
+
/** Every variant any class slot of the theme accepts, each valued as the union the slots take. */
|
|
69
|
+
export type SharedThemeProps<T extends ComponentTheme> = {
|
|
70
|
+
[K in Exclude<KeysOfUnion<AnySlotProps<T>>, 'class' | 'className'>]?: ValueIn<AnySlotProps<T>, K>;
|
|
71
|
+
};
|
|
72
|
+
/** The theme's class slots, each already carrying the shared props. */
|
|
73
|
+
export type BoundTheme<T extends ComponentTheme> = {
|
|
74
|
+
[K in keyof ClassSlots<T>]: (props?: SlotProps<ClassSlots<T>[K]>) => string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The primitive behind a `use{Component}Theme(theme, shared)` resolver's second argument.
|
|
78
|
+
*
|
|
79
|
+
* Binds a component's variant values to every class slot at once, so a template reads
|
|
80
|
+
* `slots.root()` instead of threading the same props into each call. A slot can still add its
|
|
81
|
+
* own on top — `slots.panel({ placement: 'static' })`, `slots.root({ className })` — and a
|
|
82
|
+
* slot ignores any shared variant it does not declare, exactly as `cva` always has.
|
|
83
|
+
*
|
|
84
|
+
* Every slot now sees every prop, so a theme override keyed on a variant the component used
|
|
85
|
+
* to pass only to its root (`prefix: { color: { primary } }`) reaches the slot it names.
|
|
86
|
+
* Each slot still resolves and merges its own classes; what this removes is the threading.
|
|
87
|
+
*/
|
|
88
|
+
export declare const bindTheme: <T extends ComponentTheme>(theme: T, shared: SharedThemeProps<T>) => BoundTheme<T>;
|
|
54
89
|
export {};
|
package/dist/utils/cva/theme.js
CHANGED
|
@@ -17,7 +17,7 @@ const pick = (o, props) => o && [
|
|
|
17
17
|
];
|
|
18
18
|
// `<Theme components>` is the registry every subtree inherits. Read through the Theme
|
|
19
19
|
// context key so this module stays free of Theme imports.
|
|
20
|
-
const registryTheme = (component) => getContext('
|
|
20
|
+
const registryTheme = (component) => getContext('entasisTheme')
|
|
21
21
|
?.componentThemes?.[component];
|
|
22
22
|
/**
|
|
23
23
|
* Resolves a component's class slots through the same ladder `useComponentMotion` walks,
|
|
@@ -26,7 +26,7 @@ const registryTheme = (component) => getContext('sveltaiTheme')
|
|
|
26
26
|
* one below it — a subtree that restyles one slot must not drop the registry's others.
|
|
27
27
|
*/
|
|
28
28
|
export const useComponentTheme = (component, defaultTheme) => {
|
|
29
|
-
|
|
29
|
+
const resolve = (rawTheme) => {
|
|
30
30
|
const ctx = getContext(`${component}Theme`);
|
|
31
31
|
const registry = registryTheme(component);
|
|
32
32
|
const { override: localOverride, ...local } = rawTheme ?? {};
|
|
@@ -56,4 +56,27 @@ export const useComponentTheme = (component, defaultTheme) => {
|
|
|
56
56
|
}
|
|
57
57
|
return changed ? theme : defaultTheme;
|
|
58
58
|
};
|
|
59
|
+
return ((rawTheme, shared) => shared ? bindTheme(resolve(rawTheme), shared) : resolve(rawTheme));
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The primitive behind a `use{Component}Theme(theme, shared)` resolver's second argument.
|
|
63
|
+
*
|
|
64
|
+
* Binds a component's variant values to every class slot at once, so a template reads
|
|
65
|
+
* `slots.root()` instead of threading the same props into each call. A slot can still add its
|
|
66
|
+
* own on top — `slots.panel({ placement: 'static' })`, `slots.root({ className })` — and a
|
|
67
|
+
* slot ignores any shared variant it does not declare, exactly as `cva` always has.
|
|
68
|
+
*
|
|
69
|
+
* Every slot now sees every prop, so a theme override keyed on a variant the component used
|
|
70
|
+
* to pass only to its root (`prefix: { color: { primary } }`) reaches the slot it names.
|
|
71
|
+
* Each slot still resolves and merges its own classes; what this removes is the threading.
|
|
72
|
+
*/
|
|
73
|
+
export const bindTheme = (theme, shared) => {
|
|
74
|
+
const bound = {};
|
|
75
|
+
for (const slot in theme) {
|
|
76
|
+
if (slot === 'motion')
|
|
77
|
+
continue;
|
|
78
|
+
const resolve = theme[slot];
|
|
79
|
+
bound[slot] = (props) => resolve(props ? { ...shared, ...props } : shared);
|
|
80
|
+
}
|
|
81
|
+
return bound;
|
|
59
82
|
};
|