@spaethtech/svelte-ui 0.1.10
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 +81 -0
- package/dist/components/Badge/Badge.svelte +80 -0
- package/dist/components/Badge/Badge.svelte.d.ts +14 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.js +1 -0
- package/dist/components/Button/Button.svelte +172 -0
- package/dist/components/Button/Button.svelte.d.ts +32 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Dialog/Dialog.svelte +101 -0
- package/dist/components/Dialog/Dialog.svelte.d.ts +18 -0
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/Dialog/index.js +1 -0
- package/dist/components/ElementManager/ElementManager.svelte +397 -0
- package/dist/components/ElementManager/ElementManager.svelte.d.ts +43 -0
- package/dist/components/ElementManager/index.d.ts +1 -0
- package/dist/components/ElementManager/index.js +1 -0
- package/dist/components/EmailInput/EmailInput.svelte +47 -0
- package/dist/components/EmailInput/EmailInput.svelte.d.ts +14 -0
- package/dist/components/EmailInput/index.d.ts +1 -0
- package/dist/components/EmailInput/index.js +1 -0
- package/dist/components/Icon/Icon.svelte +74 -0
- package/dist/components/Icon/Icon.svelte.d.ts +13 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Icon/index.js +1 -0
- package/dist/components/Input/Input.svelte +268 -0
- package/dist/components/Input/Input.svelte.d.ts +18 -0
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/List/List.svelte +580 -0
- package/dist/components/List/List.svelte.d.ts +38 -0
- package/dist/components/List/index.d.ts +1 -0
- package/dist/components/List/index.js +1 -0
- package/dist/components/ListItem/ListItem.svelte +175 -0
- package/dist/components/ListItem/ListItem.svelte.d.ts +24 -0
- package/dist/components/ListItem/index.d.ts +2 -0
- package/dist/components/ListItem/index.js +2 -0
- package/dist/components/ListView/ListView.svelte +463 -0
- package/dist/components/ListView/ListView.svelte.d.ts +37 -0
- package/dist/components/ListView/index.d.ts +2 -0
- package/dist/components/ListView/index.js +2 -0
- package/dist/components/NodeGraph/BaseNode.d.ts +57 -0
- package/dist/components/NodeGraph/BaseNode.js +30 -0
- package/dist/components/NodeGraph/Edge.svelte +60 -0
- package/dist/components/NodeGraph/Edge.svelte.d.ts +16 -0
- package/dist/components/NodeGraph/ExpressionEvaluator.d.ts +82 -0
- package/dist/components/NodeGraph/ExpressionEvaluator.js +152 -0
- package/dist/components/NodeGraph/Node.svelte +100 -0
- package/dist/components/NodeGraph/Node.svelte.d.ts +10 -0
- package/dist/components/NodeGraph/NodeGraph.svelte +52 -0
- package/dist/components/NodeGraph/NodeGraph.svelte.d.ts +14 -0
- package/dist/components/NodeGraph/NodeInstance.svelte.d.ts +80 -0
- package/dist/components/NodeGraph/NodeInstance.svelte.js +241 -0
- package/dist/components/NodeGraph/NodePort.svelte +75 -0
- package/dist/components/NodeGraph/NodePort.svelte.d.ts +11 -0
- package/dist/components/NodeGraph/decorators.d.ts +81 -0
- package/dist/components/NodeGraph/decorators.js +148 -0
- package/dist/components/NodeGraph/index.d.ts +9 -0
- package/dist/components/NodeGraph/index.js +9 -0
- package/dist/components/NodeGraph/types.d.ts +94 -0
- package/dist/components/NodeGraph/types.js +33 -0
- package/dist/components/NotesEditor/NotesEditor.svelte +203 -0
- package/dist/components/NotesEditor/NotesEditor.svelte.d.ts +9 -0
- package/dist/components/NotesEditor/index.d.ts +1 -0
- package/dist/components/NotesEditor/index.js +1 -0
- package/dist/components/NumberInput/NumberInput.svelte +353 -0
- package/dist/components/NumberInput/NumberInput.svelte.d.ts +26 -0
- package/dist/components/NumberInput/index.d.ts +1 -0
- package/dist/components/NumberInput/index.js +1 -0
- package/dist/components/PasswordInput/PasswordInput.svelte +41 -0
- package/dist/components/PasswordInput/PasswordInput.svelte.d.ts +13 -0
- package/dist/components/PasswordInput/index.d.ts +1 -0
- package/dist/components/PasswordInput/index.js +1 -0
- package/dist/components/Popup/index.d.ts +1 -0
- package/dist/components/Popup/index.js +1 -0
- package/dist/components/Rating/Rating.svelte +77 -0
- package/dist/components/Rating/Rating.svelte.d.ts +7 -0
- package/dist/components/Rating/index.d.ts +1 -0
- package/dist/components/Rating/index.js +1 -0
- package/dist/components/ScrollView/ScrollView.svelte +285 -0
- package/dist/components/ScrollView/ScrollView.svelte.d.ts +19 -0
- package/dist/components/ScrollView/index.d.ts +1 -0
- package/dist/components/ScrollView/index.js +1 -0
- package/dist/components/SearchInput/SearchInput.svelte +50 -0
- package/dist/components/SearchInput/SearchInput.svelte.d.ts +15 -0
- package/dist/components/SearchInput/index.d.ts +1 -0
- package/dist/components/SearchInput/index.js +1 -0
- package/dist/components/Select/Select.svelte +278 -0
- package/dist/components/Select/Select.svelte.d.ts +35 -0
- package/dist/components/Select/index.d.ts +1 -0
- package/dist/components/Select/index.js +1 -0
- package/dist/components/TextArea/TextArea.svelte +734 -0
- package/dist/components/TextArea/TextArea.svelte.d.ts +19 -0
- package/dist/components/TextArea/index.d.ts +1 -0
- package/dist/components/TextArea/index.js +1 -0
- package/dist/components/ThemeSelector/ThemeSelector.svelte +64 -0
- package/dist/components/ThemeSelector/ThemeSelector.svelte.d.ts +3 -0
- package/dist/components/ThemeSelector/index.d.ts +1 -0
- package/dist/components/ThemeSelector/index.js +1 -0
- package/dist/components/TooltipHandler/TooltipHandler.svelte +593 -0
- package/dist/components/TooltipHandler/TooltipHandler.svelte.d.ts +10 -0
- package/dist/components/TooltipHandler/index.d.ts +1 -0
- package/dist/components/TooltipHandler/index.js +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +26 -0
- package/dist/styles/sizes.d.ts +78 -0
- package/dist/styles/sizes.js +120 -0
- package/dist/styles/variants.d.ts +106 -0
- package/dist/styles/variants.js +194 -0
- package/dist/types/ManagerTypes.d.ts +42 -0
- package/dist/types/ManagerTypes.js +1 -0
- package/dist/types/sizes.d.ts +5 -0
- package/dist/types/sizes.js +1 -0
- package/dist/types/variants.d.ts +1 -0
- package/dist/types/variants.js +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HandlerComponentProps } from '../../types/ManagerTypes.js';
|
|
2
|
+
interface Props extends HandlerComponentProps {
|
|
3
|
+
/** Container for tooltip positioning bounds. Can be HTMLElement or CSS selector. Default: viewport */
|
|
4
|
+
container?: HTMLElement | string;
|
|
5
|
+
/** Named snippets for tooltip content */
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
declare const TooltipHandler: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type TooltipHandler = ReturnType<typeof TooltipHandler>;
|
|
10
|
+
export default TooltipHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './TooltipHandler.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './TooltipHandler.svelte';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export { default as Badge } from "./components/Badge/Badge.svelte";
|
|
2
|
+
export { default as Button } from "./components/Button/Button.svelte";
|
|
3
|
+
export { default as Dialog } from "./components/Dialog/Dialog.svelte";
|
|
4
|
+
export { default as Input } from "./components/Input/Input.svelte";
|
|
5
|
+
export { default as NotesEditor } from "./components/NotesEditor/NotesEditor.svelte";
|
|
6
|
+
export { default as Rating } from "./components/Rating/Rating.svelte";
|
|
7
|
+
export { default as Select } from "./components/Select/Select.svelte";
|
|
8
|
+
export { default as List } from "./components/List/List.svelte";
|
|
9
|
+
export { default as ListView } from "./components/ListView/ListView.svelte";
|
|
10
|
+
export { default as ListItem } from "./components/ListItem/ListItem.svelte";
|
|
11
|
+
export { default as TextArea } from "./components/TextArea/TextArea.svelte";
|
|
12
|
+
export { default as Icon } from "./components/Icon/Icon.svelte";
|
|
13
|
+
export { default as ScrollView } from "./components/ScrollView/ScrollView.svelte";
|
|
14
|
+
export { default as PasswordInput } from "./components/PasswordInput/PasswordInput.svelte";
|
|
15
|
+
export { default as EmailInput } from "./components/EmailInput/EmailInput.svelte";
|
|
16
|
+
export { default as SearchInput } from "./components/SearchInput/SearchInput.svelte";
|
|
17
|
+
export { default as NumberInput } from "./components/NumberInput/NumberInput.svelte";
|
|
18
|
+
export { default as ThemeSelector } from "./components/ThemeSelector/ThemeSelector.svelte";
|
|
19
|
+
export { default as ElementManager } from "./components/ElementManager/ElementManager.svelte";
|
|
20
|
+
export { default as TooltipHandler } from "./components/TooltipHandler/TooltipHandler.svelte";
|
|
21
|
+
export { NodeGraph, Node, NodePort, Edge, NodeDecorator, Input as InputDecorator, Output as OutputDecorator, BaseNode, NodeInstance, ExpressionEvaluator, } from "./components/NodeGraph/index.js";
|
|
22
|
+
export type { PortMode, ControlType, VariableScope, NodeOptions, InputOptions, OutputOptions, PortMetadata, NodeMetadata, Position, } from "./components/NodeGraph/index.js";
|
|
23
|
+
export type { HandlerProps, HandlerComponentProps, ReadOnlyElements, } from "./types/ManagerTypes.js";
|
|
24
|
+
export type { Variant } from "./types/variants.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Reexport your entry components here
|
|
2
|
+
export { default as Badge } from "./components/Badge/Badge.svelte";
|
|
3
|
+
export { default as Button } from "./components/Button/Button.svelte";
|
|
4
|
+
export { default as Dialog } from "./components/Dialog/Dialog.svelte";
|
|
5
|
+
export { default as Input } from "./components/Input/Input.svelte";
|
|
6
|
+
export { default as NotesEditor } from "./components/NotesEditor/NotesEditor.svelte";
|
|
7
|
+
export { default as Rating } from "./components/Rating/Rating.svelte";
|
|
8
|
+
export { default as Select } from "./components/Select/Select.svelte";
|
|
9
|
+
export { default as List } from "./components/List/List.svelte";
|
|
10
|
+
export { default as ListView } from "./components/ListView/ListView.svelte";
|
|
11
|
+
export { default as ListItem } from "./components/ListItem/ListItem.svelte";
|
|
12
|
+
export { default as TextArea } from "./components/TextArea/TextArea.svelte";
|
|
13
|
+
export { default as Icon } from "./components/Icon/Icon.svelte";
|
|
14
|
+
export { default as ScrollView } from "./components/ScrollView/ScrollView.svelte";
|
|
15
|
+
// Specialized Input Components
|
|
16
|
+
export { default as PasswordInput } from "./components/PasswordInput/PasswordInput.svelte";
|
|
17
|
+
export { default as EmailInput } from "./components/EmailInput/EmailInput.svelte";
|
|
18
|
+
export { default as SearchInput } from "./components/SearchInput/SearchInput.svelte";
|
|
19
|
+
export { default as NumberInput } from "./components/NumberInput/NumberInput.svelte";
|
|
20
|
+
// Theme Components
|
|
21
|
+
export { default as ThemeSelector } from "./components/ThemeSelector/ThemeSelector.svelte";
|
|
22
|
+
// Utility Components
|
|
23
|
+
export { default as ElementManager } from "./components/ElementManager/ElementManager.svelte";
|
|
24
|
+
export { default as TooltipHandler } from "./components/TooltipHandler/TooltipHandler.svelte";
|
|
25
|
+
// NodeGraph System
|
|
26
|
+
export { NodeGraph, Node, NodePort, Edge, NodeDecorator, Input as InputDecorator, Output as OutputDecorator, BaseNode, NodeInstance, ExpressionEvaluator, } from "./components/NodeGraph/index.js";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Size } from "../types/sizes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Component height classes for consistent sizing across the library.
|
|
4
|
+
* These ensure buttons, inputs, badges, and other form elements align properly.
|
|
5
|
+
*/
|
|
6
|
+
export declare const componentHeights: Record<Size, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Text size classes corresponding to component sizes.
|
|
9
|
+
* Ensures text scaling is proportional to component size.
|
|
10
|
+
*/
|
|
11
|
+
export declare const textSizes: Record<Size, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Horizontal padding classes for components with text content.
|
|
14
|
+
* Scales padding proportionally with component size.
|
|
15
|
+
*/
|
|
16
|
+
export declare const horizontalPadding: Record<Size, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Vertical padding classes for components (used less often due to fixed heights).
|
|
19
|
+
*/
|
|
20
|
+
export declare const verticalPadding: Record<Size, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Combined size classes for button-like components.
|
|
23
|
+
* Includes height, text size, and padding.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // In a component
|
|
27
|
+
* const classes = buttonSizeClasses[size];
|
|
28
|
+
* // => "h-8 text-sm px-4 py-2"
|
|
29
|
+
*/
|
|
30
|
+
export declare const buttonSizeClasses: Record<Size, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Combined size classes for badge-like components.
|
|
33
|
+
* Badges use the same padding as buttons for visual consistency.
|
|
34
|
+
*/
|
|
35
|
+
export declare const badgeSizeClasses: Record<Size, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Combined size classes for input-like components.
|
|
38
|
+
* Inputs match button heights but may have different padding needs.
|
|
39
|
+
*/
|
|
40
|
+
export declare const inputSizeClasses: Record<Size, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Get component height class for a given size.
|
|
43
|
+
* Useful when you only need the height without padding/text size.
|
|
44
|
+
*
|
|
45
|
+
* @param size - The size variant
|
|
46
|
+
* @returns Tailwind height class (e.g., "h-8")
|
|
47
|
+
*/
|
|
48
|
+
export declare function getComponentHeight(size: Size): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get text size class for a given component size.
|
|
51
|
+
*
|
|
52
|
+
* @param size - The size variant
|
|
53
|
+
* @returns Tailwind text size class (e.g., "text-sm")
|
|
54
|
+
*/
|
|
55
|
+
export declare function getTextSize(size: Size): string;
|
|
56
|
+
/**
|
|
57
|
+
* Build custom size classes with specific options.
|
|
58
|
+
*
|
|
59
|
+
* @param size - The size variant
|
|
60
|
+
* @param options - Customization options
|
|
61
|
+
* @returns Space-separated string of size classes
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Button with full sizing
|
|
65
|
+
* getSizeClasses('md', { includeHeight: true, includePadding: true, includeText: true })
|
|
66
|
+
* // => "h-8 text-sm px-4 py-2"
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Input with only height and text
|
|
70
|
+
* getSizeClasses('md', { includeHeight: true, includeText: true })
|
|
71
|
+
* // => "h-8 text-sm"
|
|
72
|
+
*/
|
|
73
|
+
export declare function getSizeClasses(size: Size, options?: {
|
|
74
|
+
includeHeight?: boolean;
|
|
75
|
+
includeText?: boolean;
|
|
76
|
+
includeHorizontalPadding?: boolean;
|
|
77
|
+
includeVerticalPadding?: boolean;
|
|
78
|
+
}): string;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component height classes for consistent sizing across the library.
|
|
3
|
+
* These ensure buttons, inputs, badges, and other form elements align properly.
|
|
4
|
+
*/
|
|
5
|
+
export const componentHeights = {
|
|
6
|
+
sm: "h-7", // 28px
|
|
7
|
+
md: "h-8", // 32px - default
|
|
8
|
+
lg: "h-9", // 36px
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Text size classes corresponding to component sizes.
|
|
12
|
+
* Ensures text scaling is proportional to component size.
|
|
13
|
+
*/
|
|
14
|
+
export const textSizes = {
|
|
15
|
+
sm: "text-xs", // 12px
|
|
16
|
+
md: "text-sm", // 14px - default
|
|
17
|
+
lg: "text-base", // 16px
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Horizontal padding classes for components with text content.
|
|
21
|
+
* Scales padding proportionally with component size.
|
|
22
|
+
*/
|
|
23
|
+
export const horizontalPadding = {
|
|
24
|
+
sm: "px-3", // 12px
|
|
25
|
+
md: "px-4", // 16px - default
|
|
26
|
+
lg: "px-5", // 20px
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Vertical padding classes for components (used less often due to fixed heights).
|
|
30
|
+
*/
|
|
31
|
+
export const verticalPadding = {
|
|
32
|
+
sm: "py-1", // 4px
|
|
33
|
+
md: "py-2", // 8px - default
|
|
34
|
+
lg: "py-2.5", // 10px
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Combined size classes for button-like components.
|
|
38
|
+
* Includes height, text size, and padding.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // In a component
|
|
42
|
+
* const classes = buttonSizeClasses[size];
|
|
43
|
+
* // => "h-8 text-sm px-4 py-2"
|
|
44
|
+
*/
|
|
45
|
+
export const buttonSizeClasses = {
|
|
46
|
+
sm: `${componentHeights.sm} ${textSizes.sm} ${horizontalPadding.sm} ${verticalPadding.sm}`,
|
|
47
|
+
md: `${componentHeights.md} ${textSizes.md} ${horizontalPadding.md} ${verticalPadding.md}`,
|
|
48
|
+
lg: `${componentHeights.lg} ${textSizes.lg} ${horizontalPadding.lg} ${verticalPadding.lg}`,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Combined size classes for badge-like components.
|
|
52
|
+
* Badges use the same padding as buttons for visual consistency.
|
|
53
|
+
*/
|
|
54
|
+
export const badgeSizeClasses = {
|
|
55
|
+
sm: `${componentHeights.sm} ${textSizes.sm} ${horizontalPadding.sm}`,
|
|
56
|
+
md: `${componentHeights.md} ${textSizes.md} ${horizontalPadding.md}`,
|
|
57
|
+
lg: `${componentHeights.lg} ${textSizes.lg} ${horizontalPadding.lg}`,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Combined size classes for input-like components.
|
|
61
|
+
* Inputs match button heights but may have different padding needs.
|
|
62
|
+
*/
|
|
63
|
+
export const inputSizeClasses = {
|
|
64
|
+
sm: `${componentHeights.sm} ${textSizes.sm}`,
|
|
65
|
+
md: `${componentHeights.md} ${textSizes.md}`,
|
|
66
|
+
lg: `${componentHeights.lg} ${textSizes.lg}`,
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Get component height class for a given size.
|
|
70
|
+
* Useful when you only need the height without padding/text size.
|
|
71
|
+
*
|
|
72
|
+
* @param size - The size variant
|
|
73
|
+
* @returns Tailwind height class (e.g., "h-8")
|
|
74
|
+
*/
|
|
75
|
+
export function getComponentHeight(size) {
|
|
76
|
+
return componentHeights[size];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get text size class for a given component size.
|
|
80
|
+
*
|
|
81
|
+
* @param size - The size variant
|
|
82
|
+
* @returns Tailwind text size class (e.g., "text-sm")
|
|
83
|
+
*/
|
|
84
|
+
export function getTextSize(size) {
|
|
85
|
+
return textSizes[size];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build custom size classes with specific options.
|
|
89
|
+
*
|
|
90
|
+
* @param size - The size variant
|
|
91
|
+
* @param options - Customization options
|
|
92
|
+
* @returns Space-separated string of size classes
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // Button with full sizing
|
|
96
|
+
* getSizeClasses('md', { includeHeight: true, includePadding: true, includeText: true })
|
|
97
|
+
* // => "h-8 text-sm px-4 py-2"
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Input with only height and text
|
|
101
|
+
* getSizeClasses('md', { includeHeight: true, includeText: true })
|
|
102
|
+
* // => "h-8 text-sm"
|
|
103
|
+
*/
|
|
104
|
+
export function getSizeClasses(size, options = {}) {
|
|
105
|
+
const { includeHeight = true, includeText = true, includeHorizontalPadding = false, includeVerticalPadding = false, } = options;
|
|
106
|
+
const classes = [];
|
|
107
|
+
if (includeHeight) {
|
|
108
|
+
classes.push(componentHeights[size]);
|
|
109
|
+
}
|
|
110
|
+
if (includeText) {
|
|
111
|
+
classes.push(textSizes[size]);
|
|
112
|
+
}
|
|
113
|
+
if (includeHorizontalPadding) {
|
|
114
|
+
classes.push(horizontalPadding[size]);
|
|
115
|
+
}
|
|
116
|
+
if (includeVerticalPadding) {
|
|
117
|
+
classes.push(verticalPadding[size]);
|
|
118
|
+
}
|
|
119
|
+
return classes.join(" ");
|
|
120
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Variant } from "../types/variants.js";
|
|
2
|
+
/**
|
|
3
|
+
* Structured variant style properties for consistent styling across components.
|
|
4
|
+
* These use CSS variables for theming, allowing users to customize colors via CSS.
|
|
5
|
+
*/
|
|
6
|
+
export interface VariantStyles {
|
|
7
|
+
/** Background color */
|
|
8
|
+
bg: string;
|
|
9
|
+
/** Background color on hover */
|
|
10
|
+
bgHover: string;
|
|
11
|
+
/** Background color in active/pressed/checked state */
|
|
12
|
+
bgActive: string;
|
|
13
|
+
/** Border color */
|
|
14
|
+
border: string;
|
|
15
|
+
/** Border color on hover */
|
|
16
|
+
borderHover: string;
|
|
17
|
+
/** Border color in active/pressed/checked state */
|
|
18
|
+
borderActive: string;
|
|
19
|
+
/** Text color */
|
|
20
|
+
text: string;
|
|
21
|
+
/** Icon/SVG fill color */
|
|
22
|
+
icon: string;
|
|
23
|
+
/** Optical centering adjustment for text (e.g., '-mt-px' for warm colors) */
|
|
24
|
+
textAdjustment: string;
|
|
25
|
+
/** Optical centering adjustment for icons (e.g., '-mb-px' to shift down) */
|
|
26
|
+
iconAdjustment: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Variant style definitions for all standard variants.
|
|
30
|
+
* Uses CSS variables (--color-*) for theme-aware styling.
|
|
31
|
+
* Users customize by overriding CSS variables, not these definitions.
|
|
32
|
+
*/
|
|
33
|
+
export declare const variantStyles: Record<Variant, VariantStyles>;
|
|
34
|
+
/**
|
|
35
|
+
* Options for customizing which variant styles to include
|
|
36
|
+
*/
|
|
37
|
+
export interface VariantClassOptions {
|
|
38
|
+
/** Include hover state styles (default: true) */
|
|
39
|
+
includeHover?: boolean;
|
|
40
|
+
/** Include active/pressed/checked state styles (default: false) */
|
|
41
|
+
includeActive?: boolean;
|
|
42
|
+
/** Include border styles (default: true) */
|
|
43
|
+
includeBorder?: boolean;
|
|
44
|
+
/** Include text color styles (default: true) */
|
|
45
|
+
includeText?: boolean;
|
|
46
|
+
/** Include icon/SVG styles (default: true) */
|
|
47
|
+
includeIcon?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get variant classes as a single space-separated string.
|
|
51
|
+
* Combines background, border, text, and hover states based on options.
|
|
52
|
+
*
|
|
53
|
+
* @param variant - The variant to get classes for
|
|
54
|
+
* @param options - Options to customize which styles to include
|
|
55
|
+
* @returns Space-separated string of Tailwind classes
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Button with full styles
|
|
59
|
+
* getVariantClasses('primary')
|
|
60
|
+
* // => "[background-color:var(--color-primary)] text-white [border-color:var(--color-primary)] hover:[background-color:...] hover:[border-color:...] [&_svg]:fill-current"
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Input with only border styles
|
|
64
|
+
* getVariantClasses('secondary', { includeBorder: true, includeText: false, includeIcon: false })
|
|
65
|
+
* // => "[border-color:var(--color-secondary)] hover:[border-color:...]"
|
|
66
|
+
*/
|
|
67
|
+
export declare function getVariantClasses(variant: Variant, options?: VariantClassOptions): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get active/pressed/checked state classes for a variant.
|
|
70
|
+
* Useful for toggle buttons, checkboxes styled as buttons, etc.
|
|
71
|
+
*
|
|
72
|
+
* @param variant - The variant to get active classes for
|
|
73
|
+
* @returns Space-separated string of Tailwind classes for active state
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // CheckButton checked state
|
|
77
|
+
* const classes = checked ? getVariantActiveClasses('primary') : getVariantClasses('primary');
|
|
78
|
+
*/
|
|
79
|
+
export declare function getVariantActiveClasses(variant: Variant): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get only border-related classes for a variant.
|
|
82
|
+
* Useful for input components that need variant-styled borders.
|
|
83
|
+
*
|
|
84
|
+
* @param variant - The variant to get border classes for
|
|
85
|
+
* @param includeHover - Include hover state (default: true)
|
|
86
|
+
* @returns Space-separated string of border-related Tailwind classes
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Input with variant border
|
|
90
|
+
* getVariantBorderClasses('primary')
|
|
91
|
+
* // => "[border-color:var(--color-primary)] hover:[border-color:color-mix(...)]"
|
|
92
|
+
*/
|
|
93
|
+
export declare function getVariantBorderClasses(variant: Variant, includeHover?: boolean): string;
|
|
94
|
+
/**
|
|
95
|
+
* Get raw variant styles object for custom manipulation.
|
|
96
|
+
* Use when helper functions don't provide enough flexibility.
|
|
97
|
+
*
|
|
98
|
+
* @param variant - The variant to get styles for
|
|
99
|
+
* @returns VariantStyles object with individual style properties
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Custom combination
|
|
103
|
+
* const styles = getVariantStyles('primary');
|
|
104
|
+
* const customClasses = `${styles.bg} ${styles.text} custom-hover-class`;
|
|
105
|
+
*/
|
|
106
|
+
export declare function getVariantStyles(variant: Variant): VariantStyles;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variant style definitions for all standard variants.
|
|
3
|
+
* Uses CSS variables (--color-*) for theme-aware styling.
|
|
4
|
+
* Users customize by overriding CSS variables, not these definitions.
|
|
5
|
+
*/
|
|
6
|
+
export const variantStyles = {
|
|
7
|
+
primary: {
|
|
8
|
+
bg: "[background-color:var(--color-primary)]",
|
|
9
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-primary)_90%,black)]",
|
|
10
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-primary)_85%,black)]",
|
|
11
|
+
border: "[border-color:var(--color-primary)]",
|
|
12
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-primary)_90%,black)]",
|
|
13
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-primary)_85%,black)]",
|
|
14
|
+
text: "text-white",
|
|
15
|
+
icon: "fill-current",
|
|
16
|
+
textAdjustment: "",
|
|
17
|
+
iconAdjustment: "-mb-[2px]",
|
|
18
|
+
},
|
|
19
|
+
secondary: {
|
|
20
|
+
bg: "[background-color:var(--color-secondary)]",
|
|
21
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-secondary)_90%,black)]",
|
|
22
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-secondary)_85%,black)]",
|
|
23
|
+
border: "[border-color:var(--color-secondary)]",
|
|
24
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-secondary)_90%,black)]",
|
|
25
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-secondary)_85%,black)]",
|
|
26
|
+
text: "text-white",
|
|
27
|
+
icon: "fill-current",
|
|
28
|
+
textAdjustment: "-mt-px",
|
|
29
|
+
iconAdjustment: "",
|
|
30
|
+
},
|
|
31
|
+
danger: {
|
|
32
|
+
bg: "[background-color:var(--color-danger)]",
|
|
33
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-danger)_90%,black)]",
|
|
34
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-danger)_85%,black)]",
|
|
35
|
+
border: "[border-color:var(--color-danger)]",
|
|
36
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-danger)_90%,black)]",
|
|
37
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-danger)_85%,black)]",
|
|
38
|
+
text: "text-white",
|
|
39
|
+
icon: "fill-current",
|
|
40
|
+
textAdjustment: "-mt-[2px]",
|
|
41
|
+
iconAdjustment: "",
|
|
42
|
+
},
|
|
43
|
+
info: {
|
|
44
|
+
bg: "[background-color:var(--color-info)]",
|
|
45
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-info)_90%,black)]",
|
|
46
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-info)_85%,black)]",
|
|
47
|
+
border: "[border-color:var(--color-info)]",
|
|
48
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-info)_90%,black)]",
|
|
49
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-info)_85%,black)]",
|
|
50
|
+
text: "text-white",
|
|
51
|
+
icon: "fill-current",
|
|
52
|
+
textAdjustment: "-mt-px",
|
|
53
|
+
iconAdjustment: "",
|
|
54
|
+
},
|
|
55
|
+
success: {
|
|
56
|
+
bg: "[background-color:var(--color-success)]",
|
|
57
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-success)_90%,black)]",
|
|
58
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-success)_85%,black)]",
|
|
59
|
+
border: "[border-color:var(--color-success)]",
|
|
60
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-success)_90%,black)]",
|
|
61
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-success)_85%,black)]",
|
|
62
|
+
text: "text-white",
|
|
63
|
+
icon: "fill-current",
|
|
64
|
+
textAdjustment: "-mt-px",
|
|
65
|
+
iconAdjustment: "",
|
|
66
|
+
},
|
|
67
|
+
warning: {
|
|
68
|
+
bg: "[background-color:var(--color-warning)]",
|
|
69
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-warning)_90%,black)]",
|
|
70
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-warning)_85%,black)]",
|
|
71
|
+
border: "[border-color:var(--color-warning)]",
|
|
72
|
+
borderHover: "[border-color:color-mix(in_srgb,var(--color-warning)_90%,black)]",
|
|
73
|
+
borderActive: "[border-color:color-mix(in_srgb,var(--color-warning)_85%,black)]",
|
|
74
|
+
text: "text-white",
|
|
75
|
+
icon: "fill-current",
|
|
76
|
+
textAdjustment: "-mt-[2px]",
|
|
77
|
+
iconAdjustment: "-mt-px",
|
|
78
|
+
},
|
|
79
|
+
ghost: {
|
|
80
|
+
bg: "bg-transparent",
|
|
81
|
+
bgHover: "[background-color:color-mix(in_srgb,var(--color-text)_10%,transparent)]",
|
|
82
|
+
bgActive: "[background-color:color-mix(in_srgb,var(--color-text)_15%,transparent)]",
|
|
83
|
+
border: "",
|
|
84
|
+
borderHover: "",
|
|
85
|
+
borderActive: "",
|
|
86
|
+
text: "[color:var(--color-text)]",
|
|
87
|
+
icon: "fill-current",
|
|
88
|
+
textAdjustment: "-mt-px",
|
|
89
|
+
iconAdjustment: "",
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Get variant classes as a single space-separated string.
|
|
94
|
+
* Combines background, border, text, and hover states based on options.
|
|
95
|
+
*
|
|
96
|
+
* @param variant - The variant to get classes for
|
|
97
|
+
* @param options - Options to customize which styles to include
|
|
98
|
+
* @returns Space-separated string of Tailwind classes
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Button with full styles
|
|
102
|
+
* getVariantClasses('primary')
|
|
103
|
+
* // => "[background-color:var(--color-primary)] text-white [border-color:var(--color-primary)] hover:[background-color:...] hover:[border-color:...] [&_svg]:fill-current"
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Input with only border styles
|
|
107
|
+
* getVariantClasses('secondary', { includeBorder: true, includeText: false, includeIcon: false })
|
|
108
|
+
* // => "[border-color:var(--color-secondary)] hover:[border-color:...]"
|
|
109
|
+
*/
|
|
110
|
+
export function getVariantClasses(variant, options = {}) {
|
|
111
|
+
const { includeHover = true, includeActive = false, includeBorder = true, includeText = true, includeIcon = true, } = options;
|
|
112
|
+
const styles = variantStyles[variant];
|
|
113
|
+
const classes = [];
|
|
114
|
+
// Base background
|
|
115
|
+
classes.push(styles.bg);
|
|
116
|
+
// Text color
|
|
117
|
+
if (includeText) {
|
|
118
|
+
classes.push(styles.text);
|
|
119
|
+
}
|
|
120
|
+
// Border
|
|
121
|
+
if (includeBorder) {
|
|
122
|
+
classes.push(styles.border);
|
|
123
|
+
}
|
|
124
|
+
// Icon/SVG
|
|
125
|
+
if (includeIcon) {
|
|
126
|
+
classes.push(`[&_svg]:${styles.icon}`);
|
|
127
|
+
}
|
|
128
|
+
// Hover states
|
|
129
|
+
if (includeHover) {
|
|
130
|
+
classes.push(`hover:${styles.bgHover}`);
|
|
131
|
+
if (includeBorder) {
|
|
132
|
+
classes.push(`hover:${styles.borderHover}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Active states (for pressed/checked components)
|
|
136
|
+
if (includeActive) {
|
|
137
|
+
classes.push(styles.bgActive);
|
|
138
|
+
if (includeBorder) {
|
|
139
|
+
classes.push(styles.borderActive);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return classes.join(" ");
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get active/pressed/checked state classes for a variant.
|
|
146
|
+
* Useful for toggle buttons, checkboxes styled as buttons, etc.
|
|
147
|
+
*
|
|
148
|
+
* @param variant - The variant to get active classes for
|
|
149
|
+
* @returns Space-separated string of Tailwind classes for active state
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // CheckButton checked state
|
|
153
|
+
* const classes = checked ? getVariantActiveClasses('primary') : getVariantClasses('primary');
|
|
154
|
+
*/
|
|
155
|
+
export function getVariantActiveClasses(variant) {
|
|
156
|
+
const styles = variantStyles[variant];
|
|
157
|
+
return `${styles.bgActive} ${styles.borderActive} ${styles.text} [&_svg]:${styles.icon}`;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get only border-related classes for a variant.
|
|
161
|
+
* Useful for input components that need variant-styled borders.
|
|
162
|
+
*
|
|
163
|
+
* @param variant - The variant to get border classes for
|
|
164
|
+
* @param includeHover - Include hover state (default: true)
|
|
165
|
+
* @returns Space-separated string of border-related Tailwind classes
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // Input with variant border
|
|
169
|
+
* getVariantBorderClasses('primary')
|
|
170
|
+
* // => "[border-color:var(--color-primary)] hover:[border-color:color-mix(...)]"
|
|
171
|
+
*/
|
|
172
|
+
export function getVariantBorderClasses(variant, includeHover = true) {
|
|
173
|
+
const styles = variantStyles[variant];
|
|
174
|
+
const classes = [styles.border];
|
|
175
|
+
if (includeHover) {
|
|
176
|
+
classes.push(`hover:${styles.borderHover}`);
|
|
177
|
+
}
|
|
178
|
+
return classes.join(" ");
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get raw variant styles object for custom manipulation.
|
|
182
|
+
* Use when helper functions don't provide enough flexibility.
|
|
183
|
+
*
|
|
184
|
+
* @param variant - The variant to get styles for
|
|
185
|
+
* @returns VariantStyles object with individual style properties
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* // Custom combination
|
|
189
|
+
* const styles = getVariantStyles('primary');
|
|
190
|
+
* const customClasses = `${styles.bg} ${styles.text} custom-hover-class`;
|
|
191
|
+
*/
|
|
192
|
+
export function getVariantStyles(variant) {
|
|
193
|
+
return variantStyles[variant];
|
|
194
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base interface that all handler components must implement
|
|
3
|
+
* Enforces read-only elements pattern
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ IMPORTANT: elements prop must NOT use $bindable()
|
|
6
|
+
* Handlers should manage their own internal state
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```svelte
|
|
10
|
+
* <script lang="ts">
|
|
11
|
+
* import type { HandlerComponentProps } from 'svelte-ui';
|
|
12
|
+
*
|
|
13
|
+
* interface Props extends HandlerComponentProps {
|
|
14
|
+
* myCustomProp?: string;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* // ✅ Correct: read-only elements
|
|
18
|
+
* let { elements = new Map(), children, ...rest }: Props = $props();
|
|
19
|
+
*
|
|
20
|
+
* // ❌ Wrong: DO NOT do this
|
|
21
|
+
* // let { elements = $bindable(new Map()) }: Props = $props();
|
|
22
|
+
* </script>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface HandlerProps {
|
|
26
|
+
/** Read-only elements Map from ElementManager - DO NOT use $bindable() */
|
|
27
|
+
elements: Map<HTMLElement, any>;
|
|
28
|
+
/** Optional child content */
|
|
29
|
+
children?: import('svelte').Snippet;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Type guard to ensure elements prop is not bindable
|
|
33
|
+
* This creates a compile-time error if someone tries to use $bindable
|
|
34
|
+
*/
|
|
35
|
+
export type ReadOnlyElements<T extends Map<HTMLElement, any>> = T;
|
|
36
|
+
/**
|
|
37
|
+
* Utility type for handler components
|
|
38
|
+
* Usage: let { elements, ...rest }: HandlerComponentProps = $props();
|
|
39
|
+
*/
|
|
40
|
+
export interface HandlerComponentProps extends HandlerProps {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Variant = 'primary' | 'secondary' | 'danger' | 'info' | 'success' | 'warning' | 'ghost';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|