@widgetic/creator 0.4.34 → 0.4.35
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 +3 -3
- package/dist/CreatorApp.svelte +13 -75
- package/dist/components/FileUrlSourceControl.svelte.d.ts +1 -1
- package/dist/components/GenerationOptionsPanel.svelte +216 -0
- package/dist/components/GenerationOptionsPanel.svelte.d.ts +21 -0
- package/dist/components/WidgetDetails.svelte +0 -6
- package/dist/components/WidgetDetails.svelte.d.ts +1 -1
- package/dist/generation/brandKitForRequest.d.ts +16 -0
- package/dist/generation/brandKitForRequest.js +12 -0
- package/dist/i18n/language.d.ts +4 -164
- package/dist/i18n/messages.d.ts +0 -21
- package/dist/i18n/messages.js +1 -22
- package/package.json +1 -1
- package/dist/components/BrandKitPanel.svelte +0 -581
- package/dist/components/BrandKitPanel.svelte.d.ts +0 -33
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ console.log(CREATOR_MESSAGES['creator.embed.codeTitle']); // 'Embed Code ({forma
|
|
|
130
130
|
| `creator.codegen.`, `creator.preview.`, `creator.version.`, `creator.versions.` | code generation, repositories and the confirm dialog, the preview banners, versions and checkpoints, and the rows of the version list |
|
|
131
131
|
| `creator.publish.`, `creator.embed.`, `creator.dialog.` | publishing (buttons, the reasons a publish is not possible, toasts), the Embed step and the sentences of the dialogs that have a name inside them |
|
|
132
132
|
| `creator.status.`, `creator.error.` | the status bar of a generation and the error texts the creator writes itself (see "What stays as it is") |
|
|
133
|
-
| `creator.details.`, `creator.brandKit.`, `creator.livePreviews.` | the widget details panel, the brand kit
|
|
133
|
+
| `creator.details.`, `creator.brandKit.`, `creator.livePreviews.` | the widget details panel, the chat's generation options (language and libraries; the `brandKit` prefix is the name they had when this panel held the brand kit, which is now account-level), and the live previews drawn on the canvas shapes |
|
|
134
134
|
| `creator.selector.`, `creator.name.`, `creator.designEdit.`, `creator.fileSource.` | the dropdown that picks a canvas or a composition, the editable name, the quick edit of design values and the control that takes a file or a web address |
|
|
135
135
|
| `chat.`, `canvas.`, `editor.`, `shadEditor.` and the File Browser's own keys | the chat, the canvas, the editor, the rich text editor of its text boxes and the File Browser that picks a file |
|
|
136
136
|
|
|
@@ -205,8 +205,8 @@ while the creator is open:
|
|
|
205
205
|
(`src/lib/utils/directionPlacement.ts`): a divider is dragged toward the end of the line (`distanceTowardEnd`), a list
|
|
206
206
|
under a cluster of controls is lined up with the end edge of the cluster (`listAlignedToEnd`), the title of a widget in
|
|
207
207
|
its panel is given the room up to the box that stands beyond it (`roomBeforeNeighbour`; measured the left to right way it
|
|
208
|
-
came out negative and the title showed as a dot), and
|
|
209
|
-
button (`popUpLeftFromAnchor
|
|
208
|
+
came out negative and the title showed as a dot), and a pop-up that hangs from a button hangs from the start edge of
|
|
209
|
+
that button (`popUpLeftFromAnchor`; nothing in the creator uses it since the brand kit pop-up went away).
|
|
210
210
|
- **What a person types** (the chat box, the text fields of the quick edit) is read by its own first letter on a right to
|
|
211
211
|
left screen, and a field with nothing in it yet takes the direction of the screen. A link (the file link field) and a
|
|
212
212
|
colour code are addresses and stay left to right on every screen.
|
package/dist/CreatorApp.svelte
CHANGED
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
import { widgetBuilderRequestInit } from './utils/widgetBuilderRequest.js';
|
|
38
38
|
import { gzipRequestBodyMiddleware } from './utils/gzipRequestMiddleware.js';
|
|
39
39
|
import type { SelectedWidgetElementReference } from './utils/widgetElementSelector.js';
|
|
40
|
-
import
|
|
40
|
+
import GenerationOptionsPanel from './components/GenerationOptionsPanel.svelte';
|
|
41
|
+
import { brandKitForRequest } from './generation/brandKitForRequest.js';
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Idempotency middleware (Phase 2 hardening): the gateway rejects
|
|
@@ -1512,45 +1513,12 @@
|
|
|
1512
1513
|
// Populated via Chat's onConversationChange callback and passed to generateCode()
|
|
1513
1514
|
// so the backend can load multi-turn LLM history (Aider-style incremental edits).
|
|
1514
1515
|
let currentChatConversationId: string | null = null;
|
|
1515
|
-
let brandKitEnabled = false;
|
|
1516
1516
|
let widgetLanguage: 'svelte' | 'react' = 'react';
|
|
1517
1517
|
let librariesEnabled = false;
|
|
1518
|
-
let
|
|
1519
|
-
let brandSecondary = '#7BA668';
|
|
1520
|
-
let brandTitle = '#0F2010';
|
|
1521
|
-
let brandSub = '#5C6B58';
|
|
1522
|
-
let brandFonts = ['Inter'];
|
|
1523
|
-
let brandKitLibraries: string[] = [];
|
|
1518
|
+
let generationLibraries: string[] = [];
|
|
1524
1519
|
let libraryGitUrl = '';
|
|
1525
1520
|
let libraryFileName = '';
|
|
1526
1521
|
let libraryUploads: { name: string; content: string; encoding: string }[] = [];
|
|
1527
|
-
let fontUploads: { name: string; content: string; encoding: string }[] = [];
|
|
1528
|
-
|
|
1529
|
-
function brandKitForRequest() {
|
|
1530
|
-
const kit: {
|
|
1531
|
-
colors?: { primary: string; secondary: string; title: string; sub: string };
|
|
1532
|
-
fonts?: string[];
|
|
1533
|
-
libraries?: string[];
|
|
1534
|
-
uploads?: { name: string; content: string; encoding: string }[];
|
|
1535
|
-
fontFiles?: { name: string; content: string; encoding: string }[];
|
|
1536
|
-
} = {};
|
|
1537
|
-
if (brandKitEnabled) {
|
|
1538
|
-
kit.colors = {
|
|
1539
|
-
primary: brandPrimary,
|
|
1540
|
-
secondary: brandSecondary,
|
|
1541
|
-
title: brandTitle,
|
|
1542
|
-
sub: brandSub,
|
|
1543
|
-
};
|
|
1544
|
-
const families = brandFonts.map((family) => family.trim()).filter(Boolean).slice(0, 3);
|
|
1545
|
-
if (families.length > 0) kit.fonts = families;
|
|
1546
|
-
}
|
|
1547
|
-
// Preset libraries are a debug test. An empty list is an explicit ban.
|
|
1548
|
-
if (librariesEnabled && debugMode) kit.libraries = [...brandKitLibraries];
|
|
1549
|
-
if (brandKitEnabled && fontUploads.length > 0) kit.fontFiles = fontUploads.map((file) => ({ ...file }));
|
|
1550
|
-
if (libraryUploads.length > 0) kit.uploads = libraryUploads.map((file) => ({ ...file }));
|
|
1551
|
-
if (!kit.colors && !kit.fonts && !kit.libraries && !kit.uploads && !kit.fontFiles) return undefined;
|
|
1552
|
-
return kit;
|
|
1553
|
-
}
|
|
1554
1522
|
|
|
1555
1523
|
/** Prompt mentions a reference image but chat has no attachment (common UX mistake). */
|
|
1556
1524
|
function promptImpliesVisionReference(prompt: string): boolean {
|
|
@@ -10643,14 +10611,7 @@ Requirements:
|
|
|
10643
10611
|
language: 'svelte' | 'react';
|
|
10644
10612
|
librariesEnabled: boolean;
|
|
10645
10613
|
libraries: string[];
|
|
10646
|
-
brandKitEnabled: boolean;
|
|
10647
|
-
primary: string;
|
|
10648
|
-
secondary: string;
|
|
10649
|
-
title: string;
|
|
10650
|
-
sub: string;
|
|
10651
|
-
fonts: string[];
|
|
10652
10614
|
libraryUploads: { name: string; content: string; encoding: string }[];
|
|
10653
|
-
fontUploads: { name: string; content: string; encoding: string }[];
|
|
10654
10615
|
};
|
|
10655
10616
|
|
|
10656
10617
|
let generationOptionsMemory: Record<string, RememberedGenerationOptions> = {};
|
|
@@ -10659,15 +10620,8 @@ Requirements:
|
|
|
10659
10620
|
return {
|
|
10660
10621
|
language: widgetLanguage === 'react' ? 'react' : 'svelte',
|
|
10661
10622
|
librariesEnabled,
|
|
10662
|
-
libraries: [...
|
|
10663
|
-
brandKitEnabled,
|
|
10664
|
-
primary: brandPrimary,
|
|
10665
|
-
secondary: brandSecondary,
|
|
10666
|
-
title: brandTitle,
|
|
10667
|
-
sub: brandSub,
|
|
10668
|
-
fonts: [...brandFonts],
|
|
10623
|
+
libraries: [...generationLibraries],
|
|
10669
10624
|
libraryUploads: libraryUploads.map((file) => ({ ...file })),
|
|
10670
|
-
fontUploads: fontUploads.map((file) => ({ ...file })),
|
|
10671
10625
|
};
|
|
10672
10626
|
}
|
|
10673
10627
|
|
|
@@ -10681,12 +10635,6 @@ Requirements:
|
|
|
10681
10635
|
language: options.language,
|
|
10682
10636
|
librariesEnabled: options.librariesEnabled,
|
|
10683
10637
|
libraries: options.libraries,
|
|
10684
|
-
brandKitEnabled: options.brandKitEnabled,
|
|
10685
|
-
primary: options.primary,
|
|
10686
|
-
secondary: options.secondary,
|
|
10687
|
-
title: options.title,
|
|
10688
|
-
sub: options.sub,
|
|
10689
|
-
fonts: options.fonts,
|
|
10690
10638
|
}));
|
|
10691
10639
|
} catch (error) {
|
|
10692
10640
|
console.warn('[WidgetCreator] Could not store generation options', error);
|
|
@@ -10764,15 +10712,8 @@ Requirements:
|
|
|
10764
10712
|
const storedLanguage = options?.language === 'svelte' || options?.language === 'react' ? options.language : null;
|
|
10765
10713
|
widgetLanguage = languageToShow(widgetId, storedLanguage);
|
|
10766
10714
|
librariesEnabled = !!options?.librariesEnabled;
|
|
10767
|
-
|
|
10768
|
-
brandKitEnabled = !!options?.brandKitEnabled;
|
|
10769
|
-
brandPrimary = options?.primary || '#314F2F';
|
|
10770
|
-
brandSecondary = options?.secondary || '#7BA668';
|
|
10771
|
-
brandTitle = options?.title || '#0F2010';
|
|
10772
|
-
brandSub = options?.sub || '#5C6B58';
|
|
10773
|
-
brandFonts = Array.isArray(options?.fonts) && options.fonts.length > 0 ? [...options.fonts] : ['Inter'];
|
|
10715
|
+
generationLibraries = Array.isArray(options?.libraries) ? [...options.libraries] : [];
|
|
10774
10716
|
libraryUploads = inMemory?.libraryUploads ? inMemory.libraryUploads.map((file) => ({ ...file })) : [];
|
|
10775
|
-
fontUploads = inMemory?.fontUploads ? inMemory.fontUploads.map((file) => ({ ...file })) : [];
|
|
10776
10717
|
}
|
|
10777
10718
|
|
|
10778
10719
|
function languageForGeneration(widgetId: string): 'svelte' | 'react' {
|
|
@@ -11133,7 +11074,12 @@ Requirements:
|
|
|
11133
11074
|
skipIntentGate: options.skipIntentGate === true,
|
|
11134
11075
|
chipIntent: options.chipIntent,
|
|
11135
11076
|
language: languageForGeneration(generationWidgetId),
|
|
11136
|
-
brandKit: brandKitForRequest(
|
|
11077
|
+
brandKit: brandKitForRequest({
|
|
11078
|
+
librariesEnabled,
|
|
11079
|
+
debugMode,
|
|
11080
|
+
libraries: generationLibraries,
|
|
11081
|
+
libraryUploads,
|
|
11082
|
+
}),
|
|
11137
11083
|
...(options.selectedElements && options.selectedElements.length > 0
|
|
11138
11084
|
? {
|
|
11139
11085
|
selectedElements: options.selectedElements.map((el) => ({
|
|
@@ -19835,22 +19781,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19835
19781
|
/>
|
|
19836
19782
|
{/snippet}
|
|
19837
19783
|
{#snippet generationOptionChecks()}
|
|
19838
|
-
<
|
|
19784
|
+
<GenerationOptionsPanel
|
|
19839
19785
|
part="checks"
|
|
19840
19786
|
showPresetLibraries={debugMode}
|
|
19841
|
-
suspendPickers={!!generatingWidgetIds[panelWidgetId]}
|
|
19842
|
-
bind:brandKitEnabled
|
|
19843
19787
|
bind:librariesEnabled
|
|
19844
|
-
bind:libraries={
|
|
19788
|
+
bind:libraries={generationLibraries}
|
|
19845
19789
|
bind:libraryGitUrl
|
|
19846
19790
|
bind:libraryFileName
|
|
19847
19791
|
bind:libraryUploads
|
|
19848
|
-
bind:fontUploads
|
|
19849
|
-
bind:primary={brandPrimary}
|
|
19850
|
-
bind:secondary={brandSecondary}
|
|
19851
|
-
bind:title={brandTitle}
|
|
19852
|
-
bind:sub={brandSub}
|
|
19853
|
-
bind:fonts={brandFonts}
|
|
19854
19792
|
showLanguage={debugMode}
|
|
19855
19793
|
languageLocked={!!(generatingWidgetIds[panelWidgetId] || ps.lastCommitId || ps.lastPublishedVersion != null)}
|
|
19856
19794
|
bind:language={widgetLanguage}
|
|
@@ -10,6 +10,6 @@ interface Props {
|
|
|
10
10
|
urlPlaceholder?: string;
|
|
11
11
|
accept?: string;
|
|
12
12
|
}
|
|
13
|
-
declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "
|
|
13
|
+
declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "url" | "fileName" | "fileContent" | "fileEncoding">;
|
|
14
14
|
type FileUrlSourceControl = ReturnType<typeof FileUrlSourceControl>;
|
|
15
15
|
export default FileUrlSourceControl;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Generation options of the chat: the language of a new widget and, in debug mode, the preset and uploaded libraries.
|
|
3
|
+
The brand kit (colors, fonts, icons, spacing, corner radius and style notes) is not here: it belongs to the account
|
|
4
|
+
and is edited in the account settings, so every widget of that account uses it. (The `creator.brandKit.*` message
|
|
5
|
+
keys keep the name they had when this panel held the brand kit; they hold the texts of these options.)
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { DropdownMenu } from '@widgetic/design-system';
|
|
10
|
+
import FileUrlSourceControl from './FileUrlSourceControl.svelte';
|
|
11
|
+
import HoverTooltip from './HoverTooltip.svelte';
|
|
12
|
+
import { useCreatorLanguage } from '../i18n/index.js';
|
|
13
|
+
|
|
14
|
+
const { t } = useCreatorLanguage();
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
class?: string;
|
|
18
|
+
style?: string;
|
|
19
|
+
part?: 'checks' | 'panel';
|
|
20
|
+
librariesEnabled?: boolean;
|
|
21
|
+
showPresetLibraries?: boolean;
|
|
22
|
+
libraries?: string[];
|
|
23
|
+
libraryGitUrl?: string;
|
|
24
|
+
libraryFileName?: string;
|
|
25
|
+
libraryUploads?: { name: string; content: string; encoding: string }[];
|
|
26
|
+
showLanguage?: boolean;
|
|
27
|
+
language?: string;
|
|
28
|
+
languageLocked?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let {
|
|
32
|
+
class: className = '',
|
|
33
|
+
style = '',
|
|
34
|
+
part = 'checks',
|
|
35
|
+
librariesEnabled = $bindable(false),
|
|
36
|
+
showPresetLibraries = false,
|
|
37
|
+
libraries = $bindable([] as string[]),
|
|
38
|
+
libraryGitUrl = $bindable(''),
|
|
39
|
+
libraryFileName = $bindable(''),
|
|
40
|
+
libraryUploads = $bindable([] as { name: string; content: string; encoding: string }[]),
|
|
41
|
+
showLanguage = false,
|
|
42
|
+
language = $bindable('react'),
|
|
43
|
+
languageLocked = false,
|
|
44
|
+
}: Props = $props();
|
|
45
|
+
|
|
46
|
+
const libraryChoices = [
|
|
47
|
+
{ id: 'chart.js/auto', label: 'Chart.js' },
|
|
48
|
+
{ id: 'd3', label: 'D3' },
|
|
49
|
+
{ id: 'gsap', label: 'GSAP' },
|
|
50
|
+
{ id: 'three', label: 'Three.js' },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
function toggleLibrary(id: string) {
|
|
54
|
+
const next = libraries.includes(id)
|
|
55
|
+
? libraries.filter((entry) => entry !== id)
|
|
56
|
+
: [...libraries, id];
|
|
57
|
+
libraries = next;
|
|
58
|
+
if (next.length > 0) librariesEnabled = true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type SourceRow = { id: string; fileName: string; url: string; content: string; encoding: string };
|
|
62
|
+
const emptySource = (): SourceRow => ({
|
|
63
|
+
id: crypto.randomUUID(),
|
|
64
|
+
fileName: '',
|
|
65
|
+
url: '',
|
|
66
|
+
content: '',
|
|
67
|
+
encoding: 'utf8',
|
|
68
|
+
});
|
|
69
|
+
let libraryRows = $state<SourceRow[]>([emptySource()]);
|
|
70
|
+
|
|
71
|
+
function addSourceRow() {
|
|
72
|
+
if (libraryRows.length >= 4) return;
|
|
73
|
+
libraryRows = [emptySource(), ...libraryRows];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function removeSourceRow(id: string) {
|
|
77
|
+
const next = libraryRows.filter((row) => row.id !== id);
|
|
78
|
+
libraryRows = next.length > 0 ? next : [emptySource()];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function onLibrariesChange(event: Event) {
|
|
82
|
+
librariesEnabled = (event.currentTarget as HTMLInputElement).checked;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function componentExtension() {
|
|
86
|
+
return language === 'react' ? '.jsx' : '.svelte';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function sourceAccept() {
|
|
90
|
+
return ['.js', '.ts', componentExtension(), '.zip', '.tar', '.tgz', '.gz'].join(',');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
$effect(() => {
|
|
94
|
+
libraryFileName = libraryRows[0]?.fileName || '';
|
|
95
|
+
libraryGitUrl = libraryRows[0]?.url || '';
|
|
96
|
+
libraryUploads = libraryRows
|
|
97
|
+
.filter((row) => row.fileName && row.content)
|
|
98
|
+
.map((row) => ({ name: row.fileName, content: row.content, encoding: row.encoding }));
|
|
99
|
+
});
|
|
100
|
+
</script>
|
|
101
|
+
|
|
102
|
+
{#if part === 'checks'}
|
|
103
|
+
<div class="generation-options-checks contents {className}" {style}>
|
|
104
|
+
{#if showLanguage || showPresetLibraries}
|
|
105
|
+
<div class="generation-libraries-row ms-auto flex w-full flex-col gap-2">
|
|
106
|
+
<div class="generation-libraries-checks flex flex-nowrap items-center gap-1">
|
|
107
|
+
{#if showLanguage}
|
|
108
|
+
{#if languageLocked}
|
|
109
|
+
<HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.languageIsFixedAfterThe')}>
|
|
110
|
+
<span
|
|
111
|
+
class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-default items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900 opacity-60"
|
|
112
|
+
aria-disabled="true"
|
|
113
|
+
>
|
|
114
|
+
<span class="truncate">{language === 'react' ? 'React' : 'Svelte'}</span>
|
|
115
|
+
</span>
|
|
116
|
+
</HoverTooltip>
|
|
117
|
+
{:else}
|
|
118
|
+
<HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.selectLanguage')}>
|
|
119
|
+
<DropdownMenu.Root>
|
|
120
|
+
<DropdownMenu.Trigger
|
|
121
|
+
class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-pointer items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900"
|
|
122
|
+
>
|
|
123
|
+
<span class="truncate">{language === 'react' ? 'React' : 'Svelte'}</span>
|
|
124
|
+
<svg class="h-3 w-3 shrink-0 text-gray-500" viewBox="0 0 12 12" fill="none" aria-hidden="true">
|
|
125
|
+
<path d="M3 4.5 6 7.5 9 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
|
|
126
|
+
</svg>
|
|
127
|
+
</DropdownMenu.Trigger>
|
|
128
|
+
<DropdownMenu.Content class="w-[4.75rem] min-w-0">
|
|
129
|
+
<DropdownMenu.Item
|
|
130
|
+
class="cursor-pointer {language === 'svelte' ? 'bg-[#314F2F]/15 text-[#314F2F]' : ''}"
|
|
131
|
+
onSelect={() => (language = 'svelte')}
|
|
132
|
+
>Svelte</DropdownMenu.Item>
|
|
133
|
+
<DropdownMenu.Item
|
|
134
|
+
class="cursor-pointer {language === 'react' ? 'bg-[#314F2F]/15 text-[#314F2F]' : ''}"
|
|
135
|
+
onSelect={() => (language = 'react')}
|
|
136
|
+
>React</DropdownMenu.Item>
|
|
137
|
+
</DropdownMenu.Content>
|
|
138
|
+
</DropdownMenu.Root>
|
|
139
|
+
</HoverTooltip>
|
|
140
|
+
{/if}
|
|
141
|
+
{/if}
|
|
142
|
+
{#if showPresetLibraries}
|
|
143
|
+
<label class="generation-option-toggle flex h-10 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border px-2 text-sm {librariesEnabled ? 'border-[#314F2F] bg-[#314F2F] text-white' : 'border-gray-300 bg-white text-gray-800'}">
|
|
144
|
+
<input class="generation-option-check cursor-pointer" type="checkbox" checked={librariesEnabled} onchange={onLibrariesChange} />
|
|
145
|
+
{$t('creator.brandKit.libraries')}
|
|
146
|
+
</label>
|
|
147
|
+
{/if}
|
|
148
|
+
{#if librariesEnabled && showPresetLibraries}
|
|
149
|
+
{#each libraryChoices as choice (choice.id)}
|
|
150
|
+
<label class="generation-library flex items-center gap-1 text-xs text-gray-700">
|
|
151
|
+
<input
|
|
152
|
+
class="generation-library-check cursor-pointer"
|
|
153
|
+
type="checkbox"
|
|
154
|
+
checked={libraries.includes(choice.id)}
|
|
155
|
+
onchange={() => toggleLibrary(choice.id)}
|
|
156
|
+
/>
|
|
157
|
+
{choice.label}
|
|
158
|
+
</label>
|
|
159
|
+
{/each}
|
|
160
|
+
{/if}
|
|
161
|
+
{#if librariesEnabled && showPresetLibraries}
|
|
162
|
+
<HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.addLibrary')}>
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
class="generation-library-add flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 bg-white text-sm text-gray-800"
|
|
166
|
+
aria-label={$t('creator.brandKit.addLibrary')}
|
|
167
|
+
onclick={addSourceRow}
|
|
168
|
+
>+</button>
|
|
169
|
+
</HoverTooltip>
|
|
170
|
+
{/if}
|
|
171
|
+
</div>
|
|
172
|
+
{#if librariesEnabled && showPresetLibraries}
|
|
173
|
+
{#each libraryRows as row (row.id)}
|
|
174
|
+
<div class="generation-source-row flex items-center gap-1">
|
|
175
|
+
<FileUrlSourceControl
|
|
176
|
+
class="min-w-0 flex-1"
|
|
177
|
+
bind:fileName={row.fileName}
|
|
178
|
+
bind:fileContent={row.content}
|
|
179
|
+
bind:fileEncoding={row.encoding}
|
|
180
|
+
bind:url={row.url}
|
|
181
|
+
fileLabel={$t('creator.brandKit.uploadLibrary')}
|
|
182
|
+
fileTitle={$t('creator.brandKit.uploadCustomLibraryTooltip')}
|
|
183
|
+
urlPlaceholder={$t('creator.brandKit.urlLibraries', { extension: componentExtension() })}
|
|
184
|
+
accept={sourceAccept()}
|
|
185
|
+
/>
|
|
186
|
+
{#if libraryRows.length > 1}
|
|
187
|
+
<button
|
|
188
|
+
type="button"
|
|
189
|
+
class="generation-source-remove flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
|
|
190
|
+
aria-label={$t('creator.brandKit.removeLibrary')}
|
|
191
|
+
onclick={() => removeSourceRow(row.id)}
|
|
192
|
+
>
|
|
193
|
+
<svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
|
|
194
|
+
<path d="M4 7h16" />
|
|
195
|
+
<path d="M9 7V5h6v2" />
|
|
196
|
+
<path d="M8 7l1 13h6l1-13" />
|
|
197
|
+
</svg>
|
|
198
|
+
</button>
|
|
199
|
+
{/if}
|
|
200
|
+
</div>
|
|
201
|
+
{/each}
|
|
202
|
+
{/if}
|
|
203
|
+
</div>
|
|
204
|
+
{/if}
|
|
205
|
+
</div>
|
|
206
|
+
{/if}
|
|
207
|
+
|
|
208
|
+
<style>
|
|
209
|
+
.generation-options-checks input:focus,
|
|
210
|
+
.generation-options-checks input:focus-visible,
|
|
211
|
+
.generation-language-select:focus,
|
|
212
|
+
.generation-language-select:focus-visible {
|
|
213
|
+
outline: none;
|
|
214
|
+
box-shadow: none;
|
|
215
|
+
}
|
|
216
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
class?: string;
|
|
3
|
+
style?: string;
|
|
4
|
+
part?: 'checks' | 'panel';
|
|
5
|
+
librariesEnabled?: boolean;
|
|
6
|
+
showPresetLibraries?: boolean;
|
|
7
|
+
libraries?: string[];
|
|
8
|
+
libraryGitUrl?: string;
|
|
9
|
+
libraryFileName?: string;
|
|
10
|
+
libraryUploads?: {
|
|
11
|
+
name: string;
|
|
12
|
+
content: string;
|
|
13
|
+
encoding: string;
|
|
14
|
+
}[];
|
|
15
|
+
showLanguage?: boolean;
|
|
16
|
+
language?: string;
|
|
17
|
+
languageLocked?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const GenerationOptionsPanel: import("svelte").Component<Props, {}, "librariesEnabled" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "language">;
|
|
20
|
+
type GenerationOptionsPanel = ReturnType<typeof GenerationOptionsPanel>;
|
|
21
|
+
export default GenerationOptionsPanel;
|
|
@@ -4194,12 +4194,6 @@
|
|
|
4194
4194
|
.widget-details-dock-right :global(.action-label) {
|
|
4195
4195
|
font-size: 0.7rem;
|
|
4196
4196
|
}
|
|
4197
|
-
.widget-details-dock-right :global(.generation-brand-kit-toggle) {
|
|
4198
|
-
height: 2rem;
|
|
4199
|
-
gap: 0.3rem;
|
|
4200
|
-
padding-inline: 0.4rem;
|
|
4201
|
-
font-size: 0.75rem;
|
|
4202
|
-
}
|
|
4203
4197
|
.widget-details-create-models-ct :global(button:focus),
|
|
4204
4198
|
.widget-details-create-models-ct :global(button:focus-visible),
|
|
4205
4199
|
.widget-details-create-models-ct :global(select:focus),
|
|
@@ -100,7 +100,7 @@ declare const WidgetDetails: $$__sveltets_2_IsomorphicComponent<{
|
|
|
100
100
|
/** Stacking order when multiple Widget Details panels are open. */ panelZIndex?: number;
|
|
101
101
|
/** Cascade offset index (0 = centered, 1+ = shifted down-right). */ panelCascadeIndex?: number;
|
|
102
102
|
/** False when another panel has keyboard/chat focus. */ isFocusedPanel?: boolean;
|
|
103
|
-
currentStep?: "
|
|
103
|
+
currentStep?: "embed" | "create" | "edit";
|
|
104
104
|
/**
|
|
105
105
|
* Canvas Creator is code-only (chat + preview). Edit/Embed header steps stay
|
|
106
106
|
* off until composition editing lives on /composition. Keep the Edit/Embed
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Payload shape for POST /code/generate `brandKit` (account-level colors/fonts live on the gateway; chat only sends libraries). */
|
|
2
|
+
export type BrandKitUpload = {
|
|
3
|
+
name: string;
|
|
4
|
+
content: string;
|
|
5
|
+
encoding: string;
|
|
6
|
+
};
|
|
7
|
+
export type GenerationBrandKit = {
|
|
8
|
+
libraries?: string[];
|
|
9
|
+
uploads?: BrandKitUpload[];
|
|
10
|
+
};
|
|
11
|
+
export declare function brandKitForRequest(options: {
|
|
12
|
+
librariesEnabled: boolean;
|
|
13
|
+
debugMode: boolean;
|
|
14
|
+
libraries: string[];
|
|
15
|
+
libraryUploads: BrandKitUpload[];
|
|
16
|
+
}): GenerationBrandKit | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Payload shape for POST /code/generate `brandKit` (account-level colors/fonts live on the gateway; chat only sends libraries). */
|
|
2
|
+
export function brandKitForRequest(options) {
|
|
3
|
+
const kit = {};
|
|
4
|
+
// Preset libraries are a debug test. An empty list is an explicit ban.
|
|
5
|
+
if (options.librariesEnabled && options.debugMode)
|
|
6
|
+
kit.libraries = [...options.libraries];
|
|
7
|
+
if (options.libraryUploads.length > 0)
|
|
8
|
+
kit.uploads = options.libraryUploads.map((file) => ({ ...file }));
|
|
9
|
+
if (kit.libraries === undefined && kit.uploads === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
return kit;
|
|
12
|
+
}
|