@pixerate/editor-react 0.85.0 → 0.87.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/dist/{chunk-VKWTKESA.js → chunk-4FQXRPBN.js} +12 -1
- package/dist/chunk-4FQXRPBN.js.map +1 -0
- package/dist/image-editor/index.cjs +8 -0
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.js +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/vector/index.cjs +131 -47
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +25 -4
- package/dist/vector/index.d.ts +25 -4
- package/dist/vector/index.js +88 -4
- package/dist/vector/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-VKWTKESA.js.map +0 -1
package/dist/vector/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VectorEditorController, VectorEditorState, VectorTool, VectorCommandOptions, VectorEditorOptions, VectorEffectsToolProviderOptions, VectorRenderFilter, VectorRenderGradientAnnotator, VectorPaintDef, VectorRenderMask, VectorRenderNode, VectorRenderText, VectorWidthPointEdit } from '@pixerate/editor/vector';
|
|
1
|
+
import { VectorEditorController, VectorEditorState, VectorTool, VectorCommandOptions, VectorEditorOptions, VectorEffectsToolProviderOptions, VectorGenerationToolProviderOptions, VectorRenderFilter, VectorRenderGradientAnnotator, VectorPaintDef, VectorRenderMask, VectorRenderNode, VectorRenderText, VectorWidthPointEdit, VectorArtModel, VectorArtGenerator } from '@pixerate/editor/vector';
|
|
2
2
|
import { ToolRegistry } from '@pixerate/editor/tools';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import { EffectProvider } from '@pixerate/editor/effects';
|
|
@@ -35,6 +35,12 @@ declare function useVectorCommands(registry: VectorCommandTarget | null | undefi
|
|
|
35
35
|
* `registry` while mounted. They work once an effects provider is registered (see `useEffects`).
|
|
36
36
|
*/
|
|
37
37
|
declare function useVectorEffectsTools(registry: ToolRegistry | null | undefined, controller: VectorEditorController, options?: VectorEffectsToolProviderOptions): void;
|
|
38
|
+
/**
|
|
39
|
+
* Registers the vector editor's generative-prompt tools (`list_vector_art_models`,
|
|
40
|
+
* `generate_vector_art`, `regenerate_vector_art`) for the lifetime of the component. `models` and
|
|
41
|
+
* `generate` are read fresh on every call, so they may change between renders.
|
|
42
|
+
*/
|
|
43
|
+
declare function useVectorGenerationTools(registry: ToolRegistry | null | undefined, controller: VectorEditorController, options: VectorGenerationToolProviderOptions): void;
|
|
38
44
|
|
|
39
45
|
interface VectorCanvasProps {
|
|
40
46
|
controller: VectorEditorController;
|
|
@@ -311,8 +317,9 @@ interface VectorTracePanelProps {
|
|
|
311
317
|
className?: string;
|
|
312
318
|
}
|
|
313
319
|
/**
|
|
314
|
-
* Image Trace: pick an image file and trace it into paths, in one colour (dark areas)
|
|
315
|
-
* path per colour
|
|
320
|
+
* Image Trace and stylise: pick an image file and trace it into paths, in one colour (dark areas)
|
|
321
|
+
* or a stacked path per colour, or stylise it as mosaic tiles, halftone dots, low-poly triangles
|
|
322
|
+
* or engraving lines. The group goes on the artboard at its width. One undo step.
|
|
316
323
|
*/
|
|
317
324
|
declare function VectorTracePanel({ controller, className }: VectorTracePanelProps): React__default.JSX.Element;
|
|
318
325
|
|
|
@@ -360,4 +367,18 @@ interface VectorProviderEffectsPanelProps {
|
|
|
360
367
|
*/
|
|
361
368
|
declare function VectorProviderEffectsPanel({ controller, className }: VectorProviderEffectsPanelProps): React__default.JSX.Element;
|
|
362
369
|
|
|
363
|
-
|
|
370
|
+
interface VectorGeneratePanelProps {
|
|
371
|
+
controller: VectorEditorController;
|
|
372
|
+
/** The host's models (image models are traced or stylised; text models write SVG). */
|
|
373
|
+
models: readonly VectorArtModel[];
|
|
374
|
+
/** The host's generator (sends a planned request to its model). */
|
|
375
|
+
generate: VectorArtGenerator;
|
|
376
|
+
className?: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Generative prompts: describe art, pick a model (and, for image models, how the picture becomes
|
|
380
|
+
* vectors) and generate it into the artboard as one editable group. One undo step.
|
|
381
|
+
*/
|
|
382
|
+
declare function VectorGeneratePanel({ controller, models, generate, className }: VectorGeneratePanelProps): React__default.JSX.Element | null;
|
|
383
|
+
|
|
384
|
+
export { type UseVectorEditorResult, VectorAppearancePanel, type VectorAppearancePanelProps, VectorCanvas, type VectorCanvasProps, type VectorCommandTarget, VectorConnectorPanel, type VectorConnectorPanelProps, VectorConstraintsPanel, type VectorConstraintsPanelProps, VectorEditor, type VectorEditorProps, VectorEffectsPanel, type VectorEffectsPanelProps, VectorEnvelopePanel, type VectorEnvelopePanelProps, VectorFilterDefs, VectorFramePanel, type VectorFramePanelProps, VectorGeneratePanel, type VectorGeneratePanelProps, VectorGradientAnnotator, VectorGradientDefs, VectorGradientEditor, type VectorGradientEditorProps, VectorLensPanel, type VectorLensPanelProps, VectorMaskPanel, type VectorMaskPanelProps, VectorMaskedNodes, VectorPagesPanel, type VectorPagesPanelProps, VectorPerspectivePanel, type VectorPerspectivePanelProps, VectorProviderEffectsPanel, type VectorProviderEffectsPanelProps, VectorSceneNodes, VectorShadingPanel, type VectorShadingPanelProps, VectorStylePanel, type VectorStylePanelProps, VectorSymbolsPanel, type VectorSymbolsPanelProps, VectorSymmetryPanel, type VectorSymmetryPanelProps, VectorTextElement, VectorTextPanel, type VectorTextPanelProps, VectorToolbar, type VectorToolbarProps, VectorTracePanel, type VectorTracePanelProps, VectorWidthPointEditor, type VectorWidthPointEditorProps, useVectorCommands, useVectorEditor, useVectorEditorController, useVectorEditorState, useVectorEffectsTools, useVectorGenerationTools };
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VectorEditorController, VectorEditorState, VectorTool, VectorCommandOptions, VectorEditorOptions, VectorEffectsToolProviderOptions, VectorRenderFilter, VectorRenderGradientAnnotator, VectorPaintDef, VectorRenderMask, VectorRenderNode, VectorRenderText, VectorWidthPointEdit } from '@pixerate/editor/vector';
|
|
1
|
+
import { VectorEditorController, VectorEditorState, VectorTool, VectorCommandOptions, VectorEditorOptions, VectorEffectsToolProviderOptions, VectorGenerationToolProviderOptions, VectorRenderFilter, VectorRenderGradientAnnotator, VectorPaintDef, VectorRenderMask, VectorRenderNode, VectorRenderText, VectorWidthPointEdit, VectorArtModel, VectorArtGenerator } from '@pixerate/editor/vector';
|
|
2
2
|
import { ToolRegistry } from '@pixerate/editor/tools';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import { EffectProvider } from '@pixerate/editor/effects';
|
|
@@ -35,6 +35,12 @@ declare function useVectorCommands(registry: VectorCommandTarget | null | undefi
|
|
|
35
35
|
* `registry` while mounted. They work once an effects provider is registered (see `useEffects`).
|
|
36
36
|
*/
|
|
37
37
|
declare function useVectorEffectsTools(registry: ToolRegistry | null | undefined, controller: VectorEditorController, options?: VectorEffectsToolProviderOptions): void;
|
|
38
|
+
/**
|
|
39
|
+
* Registers the vector editor's generative-prompt tools (`list_vector_art_models`,
|
|
40
|
+
* `generate_vector_art`, `regenerate_vector_art`) for the lifetime of the component. `models` and
|
|
41
|
+
* `generate` are read fresh on every call, so they may change between renders.
|
|
42
|
+
*/
|
|
43
|
+
declare function useVectorGenerationTools(registry: ToolRegistry | null | undefined, controller: VectorEditorController, options: VectorGenerationToolProviderOptions): void;
|
|
38
44
|
|
|
39
45
|
interface VectorCanvasProps {
|
|
40
46
|
controller: VectorEditorController;
|
|
@@ -311,8 +317,9 @@ interface VectorTracePanelProps {
|
|
|
311
317
|
className?: string;
|
|
312
318
|
}
|
|
313
319
|
/**
|
|
314
|
-
* Image Trace: pick an image file and trace it into paths, in one colour (dark areas)
|
|
315
|
-
* path per colour
|
|
320
|
+
* Image Trace and stylise: pick an image file and trace it into paths, in one colour (dark areas)
|
|
321
|
+
* or a stacked path per colour, or stylise it as mosaic tiles, halftone dots, low-poly triangles
|
|
322
|
+
* or engraving lines. The group goes on the artboard at its width. One undo step.
|
|
316
323
|
*/
|
|
317
324
|
declare function VectorTracePanel({ controller, className }: VectorTracePanelProps): React__default.JSX.Element;
|
|
318
325
|
|
|
@@ -360,4 +367,18 @@ interface VectorProviderEffectsPanelProps {
|
|
|
360
367
|
*/
|
|
361
368
|
declare function VectorProviderEffectsPanel({ controller, className }: VectorProviderEffectsPanelProps): React__default.JSX.Element;
|
|
362
369
|
|
|
363
|
-
|
|
370
|
+
interface VectorGeneratePanelProps {
|
|
371
|
+
controller: VectorEditorController;
|
|
372
|
+
/** The host's models (image models are traced or stylised; text models write SVG). */
|
|
373
|
+
models: readonly VectorArtModel[];
|
|
374
|
+
/** The host's generator (sends a planned request to its model). */
|
|
375
|
+
generate: VectorArtGenerator;
|
|
376
|
+
className?: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Generative prompts: describe art, pick a model (and, for image models, how the picture becomes
|
|
380
|
+
* vectors) and generate it into the artboard as one editable group. One undo step.
|
|
381
|
+
*/
|
|
382
|
+
declare function VectorGeneratePanel({ controller, models, generate, className }: VectorGeneratePanelProps): React__default.JSX.Element | null;
|
|
383
|
+
|
|
384
|
+
export { type UseVectorEditorResult, VectorAppearancePanel, type VectorAppearancePanelProps, VectorCanvas, type VectorCanvasProps, type VectorCommandTarget, VectorConnectorPanel, type VectorConnectorPanelProps, VectorConstraintsPanel, type VectorConstraintsPanelProps, VectorEditor, type VectorEditorProps, VectorEffectsPanel, type VectorEffectsPanelProps, VectorEnvelopePanel, type VectorEnvelopePanelProps, VectorFilterDefs, VectorFramePanel, type VectorFramePanelProps, VectorGeneratePanel, type VectorGeneratePanelProps, VectorGradientAnnotator, VectorGradientDefs, VectorGradientEditor, type VectorGradientEditorProps, VectorLensPanel, type VectorLensPanelProps, VectorMaskPanel, type VectorMaskPanelProps, VectorMaskedNodes, VectorPagesPanel, type VectorPagesPanelProps, VectorPerspectivePanel, type VectorPerspectivePanelProps, VectorProviderEffectsPanel, type VectorProviderEffectsPanelProps, VectorSceneNodes, VectorShadingPanel, type VectorShadingPanelProps, VectorStylePanel, type VectorStylePanelProps, VectorSymbolsPanel, type VectorSymbolsPanelProps, VectorSymmetryPanel, type VectorSymmetryPanelProps, VectorTextElement, VectorTextPanel, type VectorTextPanelProps, VectorToolbar, type VectorToolbarProps, VectorTracePanel, type VectorTracePanelProps, VectorWidthPointEditor, type VectorWidthPointEditorProps, useVectorCommands, useVectorEditor, useVectorEditorController, useVectorEditorState, useVectorEffectsTools, useVectorGenerationTools };
|
package/dist/vector/index.js
CHANGED
|
@@ -11,7 +11,8 @@ import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
|
11
11
|
import {
|
|
12
12
|
VectorEditorController,
|
|
13
13
|
createVectorCommands,
|
|
14
|
-
createVectorEffectsToolProvider
|
|
14
|
+
createVectorEffectsToolProvider,
|
|
15
|
+
createVectorGenerationToolProvider
|
|
15
16
|
} from "@pixerate/editor/vector";
|
|
16
17
|
function useVectorEditorController(options = {}) {
|
|
17
18
|
const ref = useRef(null);
|
|
@@ -58,6 +59,30 @@ function useVectorEffectsTools(registry, controller, options = {}) {
|
|
|
58
59
|
return registry.register(createVectorEffectsToolProvider(controller, { id, namespace, readOnly }));
|
|
59
60
|
}, [registry, controller, id, namespace, readOnly]);
|
|
60
61
|
}
|
|
62
|
+
function useVectorGenerationTools(registry, controller, options) {
|
|
63
|
+
const latest = useRef(options);
|
|
64
|
+
latest.current = options;
|
|
65
|
+
const { id, namespace } = options;
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!registry) return;
|
|
68
|
+
const models = () => {
|
|
69
|
+
const m = latest.current.models;
|
|
70
|
+
return typeof m === "function" ? m() : m;
|
|
71
|
+
};
|
|
72
|
+
return registry.register(
|
|
73
|
+
createVectorGenerationToolProvider(controller, {
|
|
74
|
+
id,
|
|
75
|
+
namespace,
|
|
76
|
+
models,
|
|
77
|
+
generate: (request, context) => latest.current.generate(request, context),
|
|
78
|
+
readOnly: () => {
|
|
79
|
+
const r = latest.current.readOnly;
|
|
80
|
+
return (typeof r === "function" ? r() : r) ?? false;
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}, [registry, controller, id, namespace]);
|
|
85
|
+
}
|
|
61
86
|
|
|
62
87
|
// src/vector/VectorCanvas.tsx
|
|
63
88
|
import React2, { useEffect as useEffect2, useId, useRef as useRef3, useState as useState2 } from "react";
|
|
@@ -611,6 +636,7 @@ function VectorCanvas({
|
|
|
611
636
|
overlay.builder.lines.map((d, i) => /* @__PURE__ */ jsx2("path", { "data-vector-builder-line": "", d, fill: "none", stroke: THEME2.builderErase, strokeWidth: 3, strokeLinecap: "round" }, `l${i}`)),
|
|
612
637
|
overlay.builder.trail && /* @__PURE__ */ jsx2("path", { "data-vector-builder-trail": "", d: overlay.builder.trail, fill: "none", stroke: overlay.builder.mode === "erase" ? THEME2.builderErase : accentColor, strokeWidth: 1 })
|
|
613
638
|
] }),
|
|
639
|
+
overlay.brush && /* @__PURE__ */ jsx2("circle", { "data-vector-brush": "", cx: overlay.brush.x, cy: overlay.brush.y, r: overlay.brush.r, fill: "none", stroke: accentColor, strokeWidth: 1, strokeDasharray: "4 3", pointerEvents: "none" }),
|
|
614
640
|
overlay.toolStroke && /* @__PURE__ */ jsx2(
|
|
615
641
|
"path",
|
|
616
642
|
{
|
|
@@ -793,6 +819,7 @@ function VectorCanvas({
|
|
|
793
819
|
import React10 from "react";
|
|
794
820
|
import {
|
|
795
821
|
VECTOR_TOOLS,
|
|
822
|
+
VECTOR_DISTORT_BRUSH_MODES,
|
|
796
823
|
VECTOR_TOOL_GLYPHS,
|
|
797
824
|
VECTOR_TOOL_SHORTCUTS,
|
|
798
825
|
VECTOR_EDIT_TOGGLES,
|
|
@@ -2028,6 +2055,7 @@ function VectorShadingPanel({ controller, className }) {
|
|
|
2028
2055
|
|
|
2029
2056
|
// src/vector/VectorTracePanel.tsx
|
|
2030
2057
|
import { useRef as useRef4, useState as useState6 } from "react";
|
|
2058
|
+
import { VECTOR_STYLIZE_LABELS, VECTOR_STYLIZE_STYLES } from "@pixerate/editor/vector";
|
|
2031
2059
|
import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2032
2060
|
var buttonClass12 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
2033
2061
|
var selectClass9 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
|
|
@@ -2054,7 +2082,8 @@ function VectorTracePanel({ controller, className }) {
|
|
|
2054
2082
|
const pixels = await filePixels(file);
|
|
2055
2083
|
const doc = controller.getState().document;
|
|
2056
2084
|
const width = Math.min(doc.width, pixels.width);
|
|
2057
|
-
const
|
|
2085
|
+
const name = file.name.replace(/\.[^.]+$/, "") || void 0;
|
|
2086
|
+
const r = mode === "threshold" || mode === "color" ? controller.traceImage(pixels, { mode, colors, width, name: name ?? "Image Trace" }) : controller.stylizeImage(pixels, mode, { width, ...name ? { name } : {} });
|
|
2058
2087
|
setMessage(r.ok ? null : r.message);
|
|
2059
2088
|
} catch {
|
|
2060
2089
|
setMessage("That file could not be read as an image.");
|
|
@@ -2065,7 +2094,8 @@ function VectorTracePanel({ controller, className }) {
|
|
|
2065
2094
|
/* @__PURE__ */ jsx14("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Trace" }),
|
|
2066
2095
|
/* @__PURE__ */ jsxs14("select", { "aria-label": "Trace mode", className: selectClass9, value: mode, onChange: (e) => setMode(e.target.value), children: [
|
|
2067
2096
|
/* @__PURE__ */ jsx14("option", { value: "threshold", children: "Black & white" }),
|
|
2068
|
-
/* @__PURE__ */ jsx14("option", { value: "color", children: "Colours" })
|
|
2097
|
+
/* @__PURE__ */ jsx14("option", { value: "color", children: "Colours" }),
|
|
2098
|
+
VECTOR_STYLIZE_STYLES.map((s) => /* @__PURE__ */ jsx14("option", { value: s, children: VECTOR_STYLIZE_LABELS[s] }, s))
|
|
2069
2099
|
] }),
|
|
2070
2100
|
mode === "color" && /* @__PURE__ */ jsx14("input", { type: "number", min: 2, max: 32, "aria-label": "Trace colours", title: "Colours", className: numberClass7, value: colors, onChange: (e) => setColors(Math.max(2, Math.min(32, parseInt(e.target.value, 10) || 2))) }),
|
|
2071
2101
|
/* @__PURE__ */ jsx14("button", { type: "button", className: buttonClass12, "data-vector-trace-action": "", title: "Image Trace: pick an image to turn into paths", onClick: () => input.current?.click(), children: "Image\u2026" }),
|
|
@@ -2543,6 +2573,20 @@ function VectorToolbar({
|
|
|
2543
2573
|
}
|
|
2544
2574
|
)
|
|
2545
2575
|
] }),
|
|
2576
|
+
state.tool === "distort" && /* @__PURE__ */ jsxs19("span", { className: "flex flex-wrap items-center gap-1", "data-vector-distort-options": "", children: [
|
|
2577
|
+
/* @__PURE__ */ jsx19("select", { "aria-label": "Distort brush", title: "What the brush does to the outlines it passes over", className: "h-7 rounded border border-border bg-background px-1 text-xs", value: editing.distortMode, onChange: (e) => controller.setEditing({ distortMode: e.target.value }), children: VECTOR_DISTORT_BRUSH_MODES.map((m) => /* @__PURE__ */ jsx19("option", { value: m, children: m[0].toUpperCase() + m.slice(1) }, m)) }),
|
|
2578
|
+
/* @__PURE__ */ jsxs19("label", { className: "flex items-center gap-1 text-xs text-foreground", children: [
|
|
2579
|
+
"Size",
|
|
2580
|
+
/* @__PURE__ */ jsx19("input", { type: "number", min: 1, step: 1, "aria-label": "Distort brush size", className: "h-7 w-16 rounded border border-border bg-background px-1.5 text-xs", value: editing.distortSize, onChange: (e) => {
|
|
2581
|
+
const n = parseFloat(e.target.value);
|
|
2582
|
+
if (Number.isFinite(n) && n > 0) controller.setEditing({ distortSize: n });
|
|
2583
|
+
} })
|
|
2584
|
+
] }),
|
|
2585
|
+
/* @__PURE__ */ jsxs19("label", { className: "flex items-center gap-1 text-xs text-foreground", children: [
|
|
2586
|
+
"Strength",
|
|
2587
|
+
/* @__PURE__ */ jsx19("input", { type: "range", min: 0, max: 1, step: 0.05, "aria-label": "Distort brush strength", className: "h-4 w-20 accent-primary", value: editing.distortStrength, onChange: (e) => controller.setEditing({ distortStrength: parseFloat(e.target.value) }) })
|
|
2588
|
+
] })
|
|
2589
|
+
] }),
|
|
2546
2590
|
state.tool === "paintBucket" && /* @__PURE__ */ jsx19(
|
|
2547
2591
|
"button",
|
|
2548
2592
|
{
|
|
@@ -2997,6 +3041,44 @@ function VectorEditor({ controller, tools, showStylePanel = true, height = 520,
|
|
|
2997
3041
|
] })
|
|
2998
3042
|
] });
|
|
2999
3043
|
}
|
|
3044
|
+
|
|
3045
|
+
// src/vector/VectorGeneratePanel.tsx
|
|
3046
|
+
import { useState as useState8 } from "react";
|
|
3047
|
+
import { VECTOR_GENERATED_IMAGE_AS, generateVectorArt, vectorArtModels } from "@pixerate/editor/vector";
|
|
3048
|
+
import { jsx as jsx22, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3049
|
+
var buttonClass17 = "inline-flex h-7 min-w-7 items-center justify-center rounded-md border border-border bg-background px-1.5 text-xs font-medium text-foreground hover:bg-muted disabled:cursor-not-allowed disabled:opacity-40";
|
|
3050
|
+
var selectClass15 = "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1 text-xs";
|
|
3051
|
+
var AS_LABELS = { color: "Traced in colour", threshold: "Traced in one colour", mosaic: "Mosaic", halftone: "Halftone", lowPoly: "Low poly", hatch: "Engraving" };
|
|
3052
|
+
function VectorGeneratePanel({ controller, models, generate, className }) {
|
|
3053
|
+
const usable = vectorArtModels(models);
|
|
3054
|
+
const [prompt, setPrompt] = useState8("");
|
|
3055
|
+
const [model, setModel] = useState8("");
|
|
3056
|
+
const [as, setAs] = useState8("color");
|
|
3057
|
+
const [busy, setBusy] = useState8(false);
|
|
3058
|
+
const [message, setMessage] = useState8(null);
|
|
3059
|
+
const chosen = usable.find((m) => m.id === model) ?? usable[0];
|
|
3060
|
+
if (!usable.length) return null;
|
|
3061
|
+
const run = async () => {
|
|
3062
|
+
setBusy(true);
|
|
3063
|
+
setMessage(null);
|
|
3064
|
+
const r = await generateVectorArt(controller, { prompt, model: chosen.id, as, idempotencyKey: `${Date.now()}-${Math.random().toString(36).slice(2)}` }, { models, generate });
|
|
3065
|
+
setBusy(false);
|
|
3066
|
+
setMessage(r.ok ? null : r.message ?? "Generation failed.");
|
|
3067
|
+
};
|
|
3068
|
+
return /* @__PURE__ */ jsxs22("div", { className: `space-y-1 ${className ?? ""}`, "data-vector-generate-panel": "", "aria-label": "Generate", children: [
|
|
3069
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-1", children: [
|
|
3070
|
+
/* @__PURE__ */ jsx22("span", { className: "w-16 text-[11px] font-medium uppercase tracking-wide text-muted-foreground", children: "Generate" }),
|
|
3071
|
+
/* @__PURE__ */ jsx22("select", { "aria-label": "Generation model", className: selectClass15, value: chosen.id, onChange: (e) => setModel(e.target.value), children: usable.map((m) => /* @__PURE__ */ jsx22("option", { value: m.id, children: m.name ?? m.id }, m.id)) }),
|
|
3072
|
+
chosen.media === "image" && /* @__PURE__ */ jsx22("select", { "aria-label": "Image to vectors", className: selectClass15, value: as, onChange: (e) => setAs(e.target.value), children: VECTOR_GENERATED_IMAGE_AS.map((a) => /* @__PURE__ */ jsx22("option", { value: a, children: AS_LABELS[a] }, a)) })
|
|
3073
|
+
] }),
|
|
3074
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center gap-1", children: [
|
|
3075
|
+
/* @__PURE__ */ jsx22("span", { className: "w-16" }),
|
|
3076
|
+
/* @__PURE__ */ jsx22("input", { type: "text", "aria-label": "Prompt", placeholder: "Describe the art\u2026", className: "h-7 min-w-0 flex-1 rounded border border-border bg-background px-1.5 text-xs", value: prompt, onChange: (e) => setPrompt(e.target.value), onKeyDown: (e) => e.key === "Enter" && prompt.trim() && !busy && void run() }),
|
|
3077
|
+
/* @__PURE__ */ jsx22("button", { type: "button", className: buttonClass17, "data-vector-generate-action": "", disabled: !prompt.trim() || busy, onClick: () => void run(), children: busy ? "Generating\u2026" : "Generate" })
|
|
3078
|
+
] }),
|
|
3079
|
+
message && /* @__PURE__ */ jsx22("p", { className: "text-[11px] text-red-600", children: message })
|
|
3080
|
+
] });
|
|
3081
|
+
}
|
|
3000
3082
|
export {
|
|
3001
3083
|
VectorAppearancePanel,
|
|
3002
3084
|
VectorCanvas,
|
|
@@ -3007,6 +3089,7 @@ export {
|
|
|
3007
3089
|
VectorEnvelopePanel,
|
|
3008
3090
|
VectorFilterDefs,
|
|
3009
3091
|
VectorFramePanel,
|
|
3092
|
+
VectorGeneratePanel,
|
|
3010
3093
|
VectorGradientAnnotator,
|
|
3011
3094
|
VectorGradientDefs,
|
|
3012
3095
|
VectorGradientEditor,
|
|
@@ -3030,6 +3113,7 @@ export {
|
|
|
3030
3113
|
useVectorEditor,
|
|
3031
3114
|
useVectorEditorController,
|
|
3032
3115
|
useVectorEditorState,
|
|
3033
|
-
useVectorEffectsTools
|
|
3116
|
+
useVectorEffectsTools,
|
|
3117
|
+
useVectorGenerationTools
|
|
3034
3118
|
};
|
|
3035
3119
|
//# sourceMappingURL=index.js.map
|