@swis/genui-widgets 1.0.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/LICENSE.md +21 -0
- package/README.md +297 -0
- package/dist/compat/chatkit.d.ts +7 -0
- package/dist/composables/useActionDispatcher.d.ts +5 -0
- package/dist/composables/useTheme.d.ts +227 -0
- package/dist/genui-widgets.css +2 -0
- package/dist/genui-widgets.esm.js +8010 -0
- package/dist/genui-widgets.js +100 -0
- package/dist/index.d.ts +39 -0
- package/dist/injectionKeys.d.ts +3 -0
- package/dist/palette.d.ts +9 -0
- package/dist/render.d.ts +3 -0
- package/dist/styling/classes.d.ts +4 -0
- package/dist/styling/styles.d.ts +22 -0
- package/dist/styling/tailwind.d.ts +14 -0
- package/dist/styling/text.d.ts +7 -0
- package/dist/styling/tokens.d.ts +47 -0
- package/dist/template.d.ts +2 -0
- package/dist/theme.d.ts +8 -0
- package/dist/types/action.d.ts +7 -0
- package/dist/types/instance.d.ts +14 -0
- package/dist/types/tailwind.d.ts +277 -0
- package/dist/types/theme.d.ts +24 -0
- package/dist/types/widget.d.ts +25 -0
- package/dist/widgetFile.d.ts +9 -0
- package/package.json +83 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { default as DynamicWidget } from './components/DynamicWidget.vue';
|
|
2
|
+
export { default as WidgetBox } from './components/Box.vue';
|
|
3
|
+
export { default as WidgetCard } from './components/Card.vue';
|
|
4
|
+
export { default as WidgetButton } from './components/Button.vue';
|
|
5
|
+
export { default as WidgetText } from './components/Text.vue';
|
|
6
|
+
export { default as WidgetTitle } from './components/Title.vue';
|
|
7
|
+
export { default as WidgetMarkdown } from './components/Markdown.vue';
|
|
8
|
+
export { default as WidgetImage } from './components/Image.vue';
|
|
9
|
+
export { default as WidgetForm } from './components/Form.vue';
|
|
10
|
+
export { default as WidgetInput } from './components/Input.vue';
|
|
11
|
+
export { default as WidgetTextarea } from './components/Textarea.vue';
|
|
12
|
+
export { default as WidgetSelect } from './components/Select.vue';
|
|
13
|
+
export { default as WidgetCheckbox } from './components/Checkbox.vue';
|
|
14
|
+
export { default as WidgetRadioGroup } from './components/RadioGroup.vue';
|
|
15
|
+
export { default as WidgetDatePicker } from './components/DatePicker.vue';
|
|
16
|
+
export { default as WidgetBadge } from './components/Badge.vue';
|
|
17
|
+
export { default as WidgetListView } from './components/ListView.vue';
|
|
18
|
+
export { default as WidgetListViewItem } from './components/ListViewItem.vue';
|
|
19
|
+
export { default as WidgetDivider } from './components/Divider.vue';
|
|
20
|
+
export { default as WidgetSpacer } from './components/Spacer.vue';
|
|
21
|
+
export { default as WidgetRow } from './components/Row.vue';
|
|
22
|
+
export { default as WidgetCol } from './components/Col.vue';
|
|
23
|
+
export { default as WidgetLabel } from './components/Label.vue';
|
|
24
|
+
export { default as WidgetCaption } from './components/Caption.vue';
|
|
25
|
+
export { default as WidgetIcon } from './components/Icon.vue';
|
|
26
|
+
export { default as BaseLoader } from './components/BaseLoader.vue';
|
|
27
|
+
export { ACTION_HOOKS_KEY } from './injectionKeys';
|
|
28
|
+
export { applyTheme, createTheme, darkTheme, defaultTheme } from './theme';
|
|
29
|
+
export { useTheme } from './composables/useTheme';
|
|
30
|
+
export { fromChatKit } from './compat/chatkit';
|
|
31
|
+
export { render } from './render';
|
|
32
|
+
export { resolveTemplate } from './template';
|
|
33
|
+
export { extractTemplateFromWidgetFile } from './widgetFile';
|
|
34
|
+
export type { ActionHook, ChatKitAction } from './types/action';
|
|
35
|
+
export type { WidgetInstance, RenderOptions } from './types/instance';
|
|
36
|
+
export type { PaletteScale, PaletteStep, SemanticColor, ThemeConfig, ThemeTokens } from './types/theme';
|
|
37
|
+
export type { WidgetFile, WidgetFileSource } from './widgetFile';
|
|
38
|
+
export type { TemplateContext, SpacingSize, TextSize, WidgetAction, WidgetActionButton, WidgetNode, WidgetOption, WidgetTemplate, WidgetTemplateSource, WidgetType, } from './types/widget';
|
|
39
|
+
import './styles/global.scss';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PaletteScale, SemanticColor, ThemeConfig } from './types/theme';
|
|
2
|
+
export { PALETTE_STEPS, SEMANTIC_COLORS } from './types/theme';
|
|
3
|
+
export declare const defaultLightPalettes: Record<SemanticColor, PaletteScale>;
|
|
4
|
+
export declare const defaultDarkPalettes: Record<SemanticColor, PaletteScale>;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a ThemeConfig into a flat map of CSS var name → value.
|
|
7
|
+
* Falls back to defaultLightPalettes when no palettes are provided in config.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveTheme(config: ThemeConfig): Record<string, string>;
|
package/dist/render.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ClassInput = string | null | undefined | false | Record<string, unknown> | ClassInput[];
|
|
2
|
+
export declare function cx(...inputs: ClassInput[]): string[];
|
|
3
|
+
export declare function blockVariant(block: string, variant: string, value: string | number | null | undefined): string | undefined;
|
|
4
|
+
export declare function blockModifier(block: string, modifier: string | number | null | undefined): string | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
export type LengthValue = string | number | null | undefined;
|
|
3
|
+
export type InsetsValue = LengthValue | {
|
|
4
|
+
x?: LengthValue;
|
|
5
|
+
y?: LengthValue;
|
|
6
|
+
top?: LengthValue;
|
|
7
|
+
right?: LengthValue;
|
|
8
|
+
bottom?: LengthValue;
|
|
9
|
+
left?: LengthValue;
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveToken(value: string | null | undefined, tokenMap: Record<string, string>): string | undefined;
|
|
12
|
+
export declare function toCssLength(value: LengthValue, unit?: string): string | undefined;
|
|
13
|
+
export declare function toBaseSpace(value: LengthValue): string | undefined;
|
|
14
|
+
export declare function resolveRadius(value: string | null | undefined): string | undefined;
|
|
15
|
+
export declare function lineClampStyles(maxLines: number | null | undefined): CSSProperties;
|
|
16
|
+
export declare function dimensionStyles(options: {
|
|
17
|
+
width?: LengthValue;
|
|
18
|
+
height?: LengthValue;
|
|
19
|
+
size?: LengthValue;
|
|
20
|
+
aspectRatio?: string | number | null | undefined;
|
|
21
|
+
}): CSSProperties;
|
|
22
|
+
export declare function insetStyles(prefix: 'padding' | 'margin', value: InsetsValue, resolveValue?: (value: LengthValue) => string | undefined): CSSProperties;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is a valid Tailwind color token (e.g., 'red-400', 'blue-50')
|
|
3
|
+
*/
|
|
4
|
+
export declare function isTailwindToken(value: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a Tailwind token to its hex color value
|
|
7
|
+
* Returns undefined if the token is invalid
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveTailwindToken(token: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a hex color to RGB and applies an alpha value
|
|
12
|
+
* Example: adjustAlpha('#f87171', 0.1) => 'rgba(248, 113, 113, 0.1)'
|
|
13
|
+
*/
|
|
14
|
+
export declare function adjustAlpha(hexColor: string, alpha: number): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const semanticColorTokens: {
|
|
2
|
+
readonly primary: "var(--genui-primary-60)";
|
|
3
|
+
readonly secondary: "var(--genui-secondary-60)";
|
|
4
|
+
readonly success: "var(--genui-success-60)";
|
|
5
|
+
readonly danger: "var(--genui-danger-60)";
|
|
6
|
+
readonly warning: "var(--genui-warning-60)";
|
|
7
|
+
readonly info: "var(--genui-info-60)";
|
|
8
|
+
readonly discovery: "var(--genui-discovery-60)";
|
|
9
|
+
readonly caution: "var(--genui-caution-60)";
|
|
10
|
+
};
|
|
11
|
+
export declare const surfaceColorTokens: {
|
|
12
|
+
readonly surface: "var(--genui-surface)";
|
|
13
|
+
readonly background: "var(--genui-surface)";
|
|
14
|
+
readonly 'surface-secondary': "var(--genui-surface-secondary)";
|
|
15
|
+
readonly 'surface-tertiary': "var(--genui-surface-tertiary)";
|
|
16
|
+
readonly 'surface-elevated': "var(--genui-surface)";
|
|
17
|
+
readonly 'surface-elevated-secondary': "var(--genui-surface-secondary)";
|
|
18
|
+
readonly 'alpha-10': "var(--genui-secondary-5)";
|
|
19
|
+
readonly 'alpha-20': "var(--genui-secondary-10)";
|
|
20
|
+
readonly 'alpha-30': "var(--genui-secondary-20)";
|
|
21
|
+
readonly 'alpha-40': "var(--genui-secondary-30)";
|
|
22
|
+
readonly 'alpha-50': "var(--genui-secondary-40)";
|
|
23
|
+
readonly 'alpha-60': "var(--genui-secondary-50)";
|
|
24
|
+
readonly 'alpha-70': "var(--genui-secondary-60)";
|
|
25
|
+
readonly 'alpha-80': "var(--genui-secondary-70)";
|
|
26
|
+
readonly 'alpha-90': "var(--genui-secondary-80)";
|
|
27
|
+
readonly primary: "var(--genui-primary-60)";
|
|
28
|
+
readonly secondary: "var(--genui-secondary-60)";
|
|
29
|
+
readonly success: "var(--genui-success-60)";
|
|
30
|
+
readonly danger: "var(--genui-danger-60)";
|
|
31
|
+
readonly warning: "var(--genui-warning-60)";
|
|
32
|
+
readonly info: "var(--genui-info-60)";
|
|
33
|
+
readonly discovery: "var(--genui-discovery-60)";
|
|
34
|
+
readonly caution: "var(--genui-caution-60)";
|
|
35
|
+
};
|
|
36
|
+
export declare const textColorTokens: {
|
|
37
|
+
readonly prose: "var(--genui-text-primary)";
|
|
38
|
+
readonly primary: "var(--genui-text-primary)";
|
|
39
|
+
readonly secondary: "var(--genui-text-secondary)";
|
|
40
|
+
readonly tertiary: "var(--genui-text-tertiary)";
|
|
41
|
+
readonly success: "var(--genui-success-70)";
|
|
42
|
+
readonly danger: "var(--genui-danger-70)";
|
|
43
|
+
readonly warning: "var(--genui-warning-70)";
|
|
44
|
+
readonly info: "var(--genui-info-70)";
|
|
45
|
+
readonly discovery: "var(--genui-discovery-70)";
|
|
46
|
+
readonly caution: "var(--genui-caution-70)";
|
|
47
|
+
};
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ThemeConfig } from './types/theme';
|
|
2
|
+
export declare const defaultTheme: ThemeConfig;
|
|
3
|
+
export declare const darkTheme: ThemeConfig;
|
|
4
|
+
export declare function applyTheme(element: HTMLElement, theme: ThemeConfig): void;
|
|
5
|
+
/**
|
|
6
|
+
* Create a custom theme by merging overrides onto a base theme.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActionHook } from './action';
|
|
2
|
+
import type { ThemeConfig } from './theme';
|
|
3
|
+
import type { TemplateContext, WidgetTemplateSource } from './widget';
|
|
4
|
+
export interface WidgetInstance {
|
|
5
|
+
update(template: WidgetTemplateSource, templateContext?: TemplateContext): void;
|
|
6
|
+
setTheme(theme: ThemeConfig): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface RenderOptions {
|
|
10
|
+
actionHooks?: ActionHook[];
|
|
11
|
+
theme?: ThemeConfig;
|
|
12
|
+
format?: 'native' | 'chatkit';
|
|
13
|
+
templateContext?: TemplateContext;
|
|
14
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
export declare const TAILWIND_COLORS: {
|
|
2
|
+
readonly slate: {
|
|
3
|
+
readonly 50: "#f8fafc";
|
|
4
|
+
readonly 100: "#f1f5f9";
|
|
5
|
+
readonly 200: "#e2e8f0";
|
|
6
|
+
readonly 300: "#cbd5e1";
|
|
7
|
+
readonly 400: "#94a3b8";
|
|
8
|
+
readonly 500: "#64748b";
|
|
9
|
+
readonly 600: "#475569";
|
|
10
|
+
readonly 700: "#334155";
|
|
11
|
+
readonly 800: "#1e293b";
|
|
12
|
+
readonly 900: "#0f172a";
|
|
13
|
+
readonly 950: "#020617";
|
|
14
|
+
};
|
|
15
|
+
readonly gray: {
|
|
16
|
+
readonly 50: "#f9fafb";
|
|
17
|
+
readonly 100: "#f3f4f6";
|
|
18
|
+
readonly 200: "#e5e7eb";
|
|
19
|
+
readonly 300: "#d1d5db";
|
|
20
|
+
readonly 400: "#9ca3af";
|
|
21
|
+
readonly 500: "#6b7280";
|
|
22
|
+
readonly 600: "#4b5563";
|
|
23
|
+
readonly 700: "#374151";
|
|
24
|
+
readonly 800: "#1f2937";
|
|
25
|
+
readonly 900: "#111827";
|
|
26
|
+
readonly 950: "#030712";
|
|
27
|
+
};
|
|
28
|
+
readonly zinc: {
|
|
29
|
+
readonly 50: "#fafafa";
|
|
30
|
+
readonly 100: "#f4f4f5";
|
|
31
|
+
readonly 200: "#e4e4e7";
|
|
32
|
+
readonly 300: "#d4d4d8";
|
|
33
|
+
readonly 400: "#a1a1a6";
|
|
34
|
+
readonly 500: "#71717a";
|
|
35
|
+
readonly 600: "#52525b";
|
|
36
|
+
readonly 700: "#3f3f46";
|
|
37
|
+
readonly 800: "#27272a";
|
|
38
|
+
readonly 900: "#18181b";
|
|
39
|
+
readonly 950: "#09090b";
|
|
40
|
+
};
|
|
41
|
+
readonly neutral: {
|
|
42
|
+
readonly 50: "#fafafa";
|
|
43
|
+
readonly 100: "#f5f5f5";
|
|
44
|
+
readonly 200: "#e5e5e5";
|
|
45
|
+
readonly 300: "#d4d4d4";
|
|
46
|
+
readonly 400: "#a3a3a3";
|
|
47
|
+
readonly 500: "#737373";
|
|
48
|
+
readonly 600: "#525252";
|
|
49
|
+
readonly 700: "#404040";
|
|
50
|
+
readonly 800: "#262626";
|
|
51
|
+
readonly 900: "#171717";
|
|
52
|
+
readonly 950: "#0a0a0a";
|
|
53
|
+
};
|
|
54
|
+
readonly stone: {
|
|
55
|
+
readonly 50: "#fafaf9";
|
|
56
|
+
readonly 100: "#f5f5f4";
|
|
57
|
+
readonly 200: "#e7e5e4";
|
|
58
|
+
readonly 300: "#d6d3d1";
|
|
59
|
+
readonly 400: "#a8a29e";
|
|
60
|
+
readonly 500: "#78716b";
|
|
61
|
+
readonly 600: "#57534e";
|
|
62
|
+
readonly 700: "#44403c";
|
|
63
|
+
readonly 800: "#292524";
|
|
64
|
+
readonly 900: "#1c1917";
|
|
65
|
+
readonly 950: "#0c0a09";
|
|
66
|
+
};
|
|
67
|
+
readonly red: {
|
|
68
|
+
readonly 50: "#fef2f2";
|
|
69
|
+
readonly 100: "#fee2e2";
|
|
70
|
+
readonly 200: "#fecaca";
|
|
71
|
+
readonly 300: "#fca5a5";
|
|
72
|
+
readonly 400: "#f87171";
|
|
73
|
+
readonly 500: "#ef4444";
|
|
74
|
+
readonly 600: "#dc2626";
|
|
75
|
+
readonly 700: "#b91c1c";
|
|
76
|
+
readonly 800: "#991b1b";
|
|
77
|
+
readonly 900: "#7f1d1d";
|
|
78
|
+
readonly 950: "#450a0a";
|
|
79
|
+
};
|
|
80
|
+
readonly orange: {
|
|
81
|
+
readonly 50: "#fff7ed";
|
|
82
|
+
readonly 100: "#ffedd5";
|
|
83
|
+
readonly 200: "#fed7aa";
|
|
84
|
+
readonly 300: "#fdba74";
|
|
85
|
+
readonly 400: "#fb923c";
|
|
86
|
+
readonly 500: "#f97316";
|
|
87
|
+
readonly 600: "#ea580c";
|
|
88
|
+
readonly 700: "#c2410c";
|
|
89
|
+
readonly 800: "#9a3412";
|
|
90
|
+
readonly 900: "#7c2d12";
|
|
91
|
+
readonly 950: "#431407";
|
|
92
|
+
};
|
|
93
|
+
readonly amber: {
|
|
94
|
+
readonly 50: "#fffbeb";
|
|
95
|
+
readonly 100: "#fef3c7";
|
|
96
|
+
readonly 200: "#fde68a";
|
|
97
|
+
readonly 300: "#fcd34d";
|
|
98
|
+
readonly 400: "#fbbf24";
|
|
99
|
+
readonly 500: "#f59e0b";
|
|
100
|
+
readonly 600: "#d97706";
|
|
101
|
+
readonly 700: "#b45309";
|
|
102
|
+
readonly 800: "#92400e";
|
|
103
|
+
readonly 900: "#78350f";
|
|
104
|
+
readonly 950: "#451a03";
|
|
105
|
+
};
|
|
106
|
+
readonly yellow: {
|
|
107
|
+
readonly 50: "#fefce8";
|
|
108
|
+
readonly 100: "#fef9c3";
|
|
109
|
+
readonly 200: "#fef08a";
|
|
110
|
+
readonly 300: "#fde047";
|
|
111
|
+
readonly 400: "#facc15";
|
|
112
|
+
readonly 500: "#eab308";
|
|
113
|
+
readonly 600: "#ca8a04";
|
|
114
|
+
readonly 700: "#a16207";
|
|
115
|
+
readonly 800: "#854d0e";
|
|
116
|
+
readonly 900: "#713f12";
|
|
117
|
+
readonly 950: "#422006";
|
|
118
|
+
};
|
|
119
|
+
readonly lime: {
|
|
120
|
+
readonly 50: "#f7fee7";
|
|
121
|
+
readonly 100: "#ecfccb";
|
|
122
|
+
readonly 200: "#d9f99d";
|
|
123
|
+
readonly 300: "#bfef45";
|
|
124
|
+
readonly 400: "#a3e635";
|
|
125
|
+
readonly 500: "#84cc16";
|
|
126
|
+
readonly 600: "#65a30d";
|
|
127
|
+
readonly 700: "#4d7c0f";
|
|
128
|
+
readonly 800: "#3f6212";
|
|
129
|
+
readonly 900: "#365314";
|
|
130
|
+
readonly 950: "#1a3a0a";
|
|
131
|
+
};
|
|
132
|
+
readonly green: {
|
|
133
|
+
readonly 50: "#f0fdf4";
|
|
134
|
+
readonly 100: "#dcfce7";
|
|
135
|
+
readonly 200: "#bbf7d0";
|
|
136
|
+
readonly 300: "#86efac";
|
|
137
|
+
readonly 400: "#4ade80";
|
|
138
|
+
readonly 500: "#22c55e";
|
|
139
|
+
readonly 600: "#16a34a";
|
|
140
|
+
readonly 700: "#15803d";
|
|
141
|
+
readonly 800: "#166534";
|
|
142
|
+
readonly 900: "#145231";
|
|
143
|
+
readonly 950: "#052e16";
|
|
144
|
+
};
|
|
145
|
+
readonly emerald: {
|
|
146
|
+
readonly 50: "#f0fdf4";
|
|
147
|
+
readonly 100: "#dcfce7";
|
|
148
|
+
readonly 200: "#bbf7d0";
|
|
149
|
+
readonly 300: "#86efac";
|
|
150
|
+
readonly 400: "#6ee7b7";
|
|
151
|
+
readonly 500: "#10b981";
|
|
152
|
+
readonly 600: "#059669";
|
|
153
|
+
readonly 700: "#047857";
|
|
154
|
+
readonly 800: "#065f46";
|
|
155
|
+
readonly 900: "#064e3b";
|
|
156
|
+
readonly 950: "#022c22";
|
|
157
|
+
};
|
|
158
|
+
readonly teal: {
|
|
159
|
+
readonly 50: "#f0fdfa";
|
|
160
|
+
readonly 100: "#ccfbf1";
|
|
161
|
+
readonly 200: "#99f6e4";
|
|
162
|
+
readonly 300: "#5eead4";
|
|
163
|
+
readonly 400: "#2dd4bf";
|
|
164
|
+
readonly 500: "#14b8a6";
|
|
165
|
+
readonly 600: "#0d9488";
|
|
166
|
+
readonly 700: "#0f766e";
|
|
167
|
+
readonly 800: "#115e59";
|
|
168
|
+
readonly 900: "#134e4a";
|
|
169
|
+
readonly 950: "#0d3c38";
|
|
170
|
+
};
|
|
171
|
+
readonly cyan: {
|
|
172
|
+
readonly 50: "#ecf8ff";
|
|
173
|
+
readonly 100: "#cff9ff";
|
|
174
|
+
readonly 200: "#a5f3ff";
|
|
175
|
+
readonly 300: "#67e8f9";
|
|
176
|
+
readonly 400: "#22d3ee";
|
|
177
|
+
readonly 500: "#06b6d4";
|
|
178
|
+
readonly 600: "#0891b2";
|
|
179
|
+
readonly 700: "#0e7490";
|
|
180
|
+
readonly 800: "#155e75";
|
|
181
|
+
readonly 900: "#164e63";
|
|
182
|
+
readonly 950: "#082f49";
|
|
183
|
+
};
|
|
184
|
+
readonly blue: {
|
|
185
|
+
readonly 50: "#eff6ff";
|
|
186
|
+
readonly 100: "#dbeafe";
|
|
187
|
+
readonly 200: "#bfdbfe";
|
|
188
|
+
readonly 300: "#93c5fd";
|
|
189
|
+
readonly 400: "#60a5fa";
|
|
190
|
+
readonly 500: "#3b82f6";
|
|
191
|
+
readonly 600: "#2563eb";
|
|
192
|
+
readonly 700: "#1d4ed8";
|
|
193
|
+
readonly 800: "#1e40af";
|
|
194
|
+
readonly 900: "#1e3a8a";
|
|
195
|
+
readonly 950: "#0c2340";
|
|
196
|
+
};
|
|
197
|
+
readonly indigo: {
|
|
198
|
+
readonly 50: "#eef2ff";
|
|
199
|
+
readonly 100: "#e0e7ff";
|
|
200
|
+
readonly 200: "#c7d2fe";
|
|
201
|
+
readonly 300: "#a5b4fc";
|
|
202
|
+
readonly 400: "#818cf8";
|
|
203
|
+
readonly 500: "#6366f1";
|
|
204
|
+
readonly 600: "#4f46e5";
|
|
205
|
+
readonly 700: "#4338ca";
|
|
206
|
+
readonly 800: "#3730a3";
|
|
207
|
+
readonly 900: "#312e81";
|
|
208
|
+
readonly 950: "#1e1b4b";
|
|
209
|
+
};
|
|
210
|
+
readonly violet: {
|
|
211
|
+
readonly 50: "#f5f3ff";
|
|
212
|
+
readonly 100: "#ede9fe";
|
|
213
|
+
readonly 200: "#ddd6fe";
|
|
214
|
+
readonly 300: "#c4b5fd";
|
|
215
|
+
readonly 400: "#a78bfa";
|
|
216
|
+
readonly 500: "#8b5cf6";
|
|
217
|
+
readonly 600: "#7c3aed";
|
|
218
|
+
readonly 700: "#6d28d9";
|
|
219
|
+
readonly 800: "#5b21b6";
|
|
220
|
+
readonly 900: "#4c1d95";
|
|
221
|
+
readonly 950: "#2e1065";
|
|
222
|
+
};
|
|
223
|
+
readonly purple: {
|
|
224
|
+
readonly 50: "#faf5ff";
|
|
225
|
+
readonly 100: "#f3e8ff";
|
|
226
|
+
readonly 200: "#e9d5ff";
|
|
227
|
+
readonly 300: "#d8b4fe";
|
|
228
|
+
readonly 400: "#c084fc";
|
|
229
|
+
readonly 500: "#a855f7";
|
|
230
|
+
readonly 600: "#9333ea";
|
|
231
|
+
readonly 700: "#7e22ce";
|
|
232
|
+
readonly 800: "#6b21a8";
|
|
233
|
+
readonly 900: "#581c87";
|
|
234
|
+
readonly 950: "#3b0764";
|
|
235
|
+
};
|
|
236
|
+
readonly fuchsia: {
|
|
237
|
+
readonly 50: "#fdf4ff";
|
|
238
|
+
readonly 100: "#fae8ff";
|
|
239
|
+
readonly 200: "#f5d0fe";
|
|
240
|
+
readonly 300: "#f0abfc";
|
|
241
|
+
readonly 400: "#e879f9";
|
|
242
|
+
readonly 500: "#d946ef";
|
|
243
|
+
readonly 600: "#c026d3";
|
|
244
|
+
readonly 700: "#a21caf";
|
|
245
|
+
readonly 800: "#86198f";
|
|
246
|
+
readonly 900: "#701a75";
|
|
247
|
+
readonly 950: "#500724";
|
|
248
|
+
};
|
|
249
|
+
readonly pink: {
|
|
250
|
+
readonly 50: "#fdf2f8";
|
|
251
|
+
readonly 100: "#fce7f3";
|
|
252
|
+
readonly 200: "#fbcfe8";
|
|
253
|
+
readonly 300: "#f8b4d8";
|
|
254
|
+
readonly 400: "#f472b6";
|
|
255
|
+
readonly 500: "#ec4899";
|
|
256
|
+
readonly 600: "#db2777";
|
|
257
|
+
readonly 700: "#be185d";
|
|
258
|
+
readonly 800: "#9d174d";
|
|
259
|
+
readonly 900: "#831843";
|
|
260
|
+
readonly 950: "#500724";
|
|
261
|
+
};
|
|
262
|
+
readonly rose: {
|
|
263
|
+
readonly 50: "#fff1f2";
|
|
264
|
+
readonly 100: "#ffe4e6";
|
|
265
|
+
readonly 200: "#fecdd3";
|
|
266
|
+
readonly 300: "#fed7aa";
|
|
267
|
+
readonly 400: "#fb7185";
|
|
268
|
+
readonly 500: "#f43f5e";
|
|
269
|
+
readonly 600: "#e11d48";
|
|
270
|
+
readonly 700: "#be123c";
|
|
271
|
+
readonly 800: "#9f1239";
|
|
272
|
+
readonly 900: "#881337";
|
|
273
|
+
readonly 950: "#4c0519";
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
export type TailwindColor = keyof typeof TAILWIND_COLORS;
|
|
277
|
+
export type TailwindStep = keyof (typeof TAILWIND_COLORS)[TailwindColor];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type PaletteStep = '5' | '10' | '20' | '30' | '40' | '50' | '60' | '70' | '80' | '90';
|
|
2
|
+
export type PaletteScale = Record<PaletteStep, string>;
|
|
3
|
+
export type SemanticColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'discovery' | 'caution';
|
|
4
|
+
export declare const PALETTE_STEPS: readonly PaletteStep[];
|
|
5
|
+
export declare const SEMANTIC_COLORS: readonly SemanticColor[];
|
|
6
|
+
export interface ThemeConfig {
|
|
7
|
+
baseSize?: string;
|
|
8
|
+
/** Override individual palette steps per semantic color */
|
|
9
|
+
palettes?: Partial<Record<SemanticColor, Partial<PaletteScale>>>;
|
|
10
|
+
/** Global surface/text/border tokens */
|
|
11
|
+
surface?: string;
|
|
12
|
+
surfaceSecondary?: string;
|
|
13
|
+
surfaceTertiary?: string;
|
|
14
|
+
background?: string;
|
|
15
|
+
textPrimary?: string;
|
|
16
|
+
textSecondary?: string;
|
|
17
|
+
textTertiary?: string;
|
|
18
|
+
borderDefault?: string;
|
|
19
|
+
disabledBg?: string;
|
|
20
|
+
disabledText?: string;
|
|
21
|
+
/** Escape hatch: override any CSS var directly (key = var name without --) */
|
|
22
|
+
overrides?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export type ThemeTokens = ThemeConfig;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type WidgetType = 'Box' | 'Card' | 'Button' | 'Text' | 'Title' | 'Markdown' | 'Image' | 'Input' | 'Textarea' | 'Select' | 'Checkbox' | 'RadioGroup' | 'DatePicker' | 'Form' | 'Badge' | 'ListView' | 'ListViewItem' | 'Divider' | 'Spacer' | 'Row' | 'Col' | 'Label' | 'Caption' | 'Icon';
|
|
2
|
+
export type TextSize = '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl';
|
|
3
|
+
export type SpacingSize = 0 | 1 | 2 | 4 | 6 | 8 | 10 | 12 | 16 | 20 | 24;
|
|
4
|
+
export interface WidgetAction {
|
|
5
|
+
type: string;
|
|
6
|
+
payload?: Record<string, unknown>;
|
|
7
|
+
handling?: 'client' | 'server';
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export interface WidgetNode {
|
|
11
|
+
type: WidgetType;
|
|
12
|
+
children?: WidgetNode[];
|
|
13
|
+
[prop: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export type WidgetTemplate = WidgetNode;
|
|
16
|
+
export type WidgetTemplateSource = WidgetTemplate | string;
|
|
17
|
+
export type TemplateContext = Record<string, unknown>;
|
|
18
|
+
export interface WidgetOption {
|
|
19
|
+
label: string;
|
|
20
|
+
value: string | number | boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface WidgetActionButton {
|
|
23
|
+
label: string;
|
|
24
|
+
action: WidgetAction;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { WidgetTemplateSource } from './types/widget';
|
|
2
|
+
export interface WidgetFile {
|
|
3
|
+
version?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
template: WidgetTemplateSource;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export type WidgetFileSource = WidgetFile | string;
|
|
9
|
+
export declare function extractTemplateFromWidgetFile(widgetFile: WidgetFileSource): WidgetTemplateSource;
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@swis/genui-widgets",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Standalone Vue 3 widget renderer compatible with OpenAI ChatKit widget JSON.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/swisnl/genui-widgets.git"
|
|
8
|
+
},
|
|
9
|
+
"author": "Joris Meijer",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/genui-widgets.js",
|
|
13
|
+
"module": "./dist/genui-widgets.esm.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/genui-widgets.esm.js",
|
|
21
|
+
"require": "./dist/genui-widgets.js",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./styles": "./dist/genui-widgets.css"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": [
|
|
30
|
+
"*.css",
|
|
31
|
+
"*.scss"
|
|
32
|
+
],
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"vue": "^3.5"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"dompurify": "^3.3",
|
|
38
|
+
"marked": "^17.0",
|
|
39
|
+
"nunjucks": "^3.2.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/js": "^9.38.0",
|
|
43
|
+
"@vitejs/plugin-vue": "^6.0",
|
|
44
|
+
"@vitest/browser-playwright": "^4.1.0",
|
|
45
|
+
"@vue/test-utils": "^2.4",
|
|
46
|
+
"eslint": "^9.38.0",
|
|
47
|
+
"eslint-plugin-vue": "^10.5.1",
|
|
48
|
+
"globals": "^16.4.0",
|
|
49
|
+
"happy-dom": "^20.8",
|
|
50
|
+
"playwright": "^1.58.2",
|
|
51
|
+
"sass": "^1.98",
|
|
52
|
+
"typescript": "^5.9",
|
|
53
|
+
"typescript-eslint": "^8.46.2",
|
|
54
|
+
"vite": "^8.0",
|
|
55
|
+
"vitest": "^4.1",
|
|
56
|
+
"vue": "^3.5",
|
|
57
|
+
"vue-eslint-parser": "^10.2.0",
|
|
58
|
+
"vue-tsc": "^3.2"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"prepack": "npm run build",
|
|
62
|
+
"build": "npm run build:esm && npm run build:iife",
|
|
63
|
+
"build:esm": "vite build --config vite.config.esm.ts && node -e \"const fs=require('fs'); const from='dist/style.css'; const to='dist/genui-widgets.css'; if (fs.existsSync(from)) fs.renameSync(from, to);\" && tsc --project tsconfig.build.json",
|
|
64
|
+
"build:iife": "vite build --config vite.config.iife.ts && node -e \"const fs=require('fs'); const css='dist/style.css'; const js='dist/genui-widgets.js'; if (fs.existsSync(css) && fs.existsSync(js)) { const cssText=fs.readFileSync(css,'utf8'); const jsText=fs.readFileSync(js,'utf8'); const injector='(function(){if(typeof document===\\'undefined\\')return;var s=document.createElement(\\'style\\');s.setAttribute(\\'data-genui-widgets\\',\\'\\');s.textContent='+JSON.stringify(cssText)+';document.head.appendChild(s);}());\\n'; fs.writeFileSync(js, injector + jsText); fs.unlinkSync(css); }\"",
|
|
65
|
+
"demo": "vite --config vite.config.ts demo",
|
|
66
|
+
"lint": "eslint .",
|
|
67
|
+
"lint:fix": "eslint . --fix",
|
|
68
|
+
"test": "vitest run --config vitest.config.ts",
|
|
69
|
+
"test:visual": "vitest run --config vitest.visual.config.ts",
|
|
70
|
+
"test:visual:update": "vitest run --config vitest.visual.config.ts --update",
|
|
71
|
+
"test:visual:playwright-image": "./scripts/run-visual-tests-in-playwright-image.sh",
|
|
72
|
+
"test:visual:update:playwright-image": "./scripts/run-visual-tests-in-playwright-image.sh --update",
|
|
73
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
74
|
+
},
|
|
75
|
+
"directories": {
|
|
76
|
+
"doc": "docs",
|
|
77
|
+
"test": "tests"
|
|
78
|
+
},
|
|
79
|
+
"bugs": {
|
|
80
|
+
"url": "https://github.com/swisnl/genui-widgets/issues"
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://github.com/swisnl/genui-widgets#readme"
|
|
83
|
+
}
|