@pixerate/editor-react 0.158.0 → 0.160.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/animation-editor/index.cjs +336 -218
- package/dist/animation-editor/index.js +4 -2
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-W7455SH4.js → chunk-65EL63YS.js} +1 -1
- package/dist/{chunk-IDUWADYT.js → chunk-TOYSB4DK.js} +119 -1
- package/dist/effects/EffectTemplates.d.cts +26 -0
- package/dist/effects/EffectTemplates.d.ts +26 -0
- package/dist/effects/index.cjs +121 -2
- package/dist/effects/index.d.cts +1 -0
- package/dist/effects/index.d.ts +1 -0
- package/dist/effects/index.js +3 -1
- package/dist/hooks/usePromptEditor.d.cts +11 -1
- package/dist/hooks/usePromptEditor.d.ts +11 -1
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +1920 -1869
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +197 -147
- package/dist/loading-node/LoadingIndicator.d.cts +13 -0
- package/dist/loading-node/LoadingIndicator.d.ts +13 -0
- package/dist/loading-node/index.d.cts +1 -0
- package/dist/loading-node/index.d.ts +1 -0
- package/dist/paint-editor/index.js +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +401 -283
- package/dist/video-editor/index.js +3 -1
- package/package.json +3 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EffectParameters,
|
|
3
|
+
EffectTemplates,
|
|
3
4
|
EffectsBrowser,
|
|
4
5
|
useEffectDescription,
|
|
5
6
|
useEffects
|
|
6
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-TOYSB4DK.js";
|
|
7
8
|
import "../chunk-5RPB4WGT.js";
|
|
8
9
|
import "../chunk-KIRIU53A.js";
|
|
9
10
|
import "../chunk-3I7FOSLF.js";
|
|
@@ -88,7 +89,7 @@ function AnimationStage({ controller, values, onionSkin, motionPaths, onPick, hi
|
|
|
88
89
|
controller.toSvg(time, { pretty: false, idPrefix: "ae-", values, onionSkin, motionPaths }).replace(/<svg ([^>]*?)width="[^"]*" height="[^"]*"/, '<svg $1width="100%" height="100%"'),
|
|
89
90
|
highlight ?? []
|
|
90
91
|
),
|
|
91
|
-
[controller, scene, time, samples, values, onionSkin, motionPaths, key, state.effectsProvider]
|
|
92
|
+
[controller, scene, time, samples, values, onionSkin, motionPaths, key, state.effectsProvider, state.layerPictures]
|
|
92
93
|
);
|
|
93
94
|
const stageRef = useRef2(null);
|
|
94
95
|
const view = useMemo2(() => motionCameraViewAt(controller.viewScene(), time, state.effectsProvider), [controller, scene, time, samples, state.effectsProvider]);
|
|
@@ -1433,6 +1434,7 @@ function AnimationEffectsPanel({ controller, node, className = "" }) {
|
|
|
1433
1434
|
] }),
|
|
1434
1435
|
!provider && /* @__PURE__ */ jsx13("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Commands effects made are kept." }),
|
|
1435
1436
|
browse === "motion" && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, uses: ["motion"], kinds: ["motion"], title: `Motion for ${target}`, onPick: (e) => (setBrowse(null), report(controller.applyMotionEffect(e.id, [target]))) }),
|
|
1437
|
+
/* @__PURE__ */ jsx13(EffectTemplates, { provider, disabled, fillLabel: "New scene from template", onFill: (t, v) => controller.fillTemplate(t, v).then((r) => (r.ok && r.notes.length && setMessage(r.notes.join(" ")), r)) }),
|
|
1436
1438
|
browse === "vector" && /* @__PURE__ */ jsx13(EffectsBrowser, { provider, kinds: ["vector"], title: "Vector effects", onPick: (e) => (setBrowse(null), report(controller.addVectorEffect(e.id))) }),
|
|
1437
1439
|
/* @__PURE__ */ jsx13("ol", { className: "space-y-1", children: applied.map((e) => /* @__PURE__ */ jsxs11("li", { className: "rounded border border-border p-1", "data-motion-effect": e.instance, children: [
|
|
1438
1440
|
/* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-1", children: [
|
package/dist/canvas/index.js
CHANGED
|
@@ -683,6 +683,123 @@ function DurationField({ duration, onCommit }) {
|
|
|
683
683
|
);
|
|
684
684
|
}
|
|
685
685
|
|
|
686
|
+
// src/effects/EffectTemplates.tsx
|
|
687
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
688
|
+
import { checkTemplateValues, isSubjectTemplateSlot } from "@pixerate/editor/effects";
|
|
689
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
690
|
+
var input = "w-full min-w-0 rounded border border-border bg-transparent px-1 py-0.5 text-xs";
|
|
691
|
+
var btn = "rounded border border-border px-2 py-0.5 text-[11px] disabled:opacity-40";
|
|
692
|
+
function SlotField({ slot, value, error, onChange }) {
|
|
693
|
+
const id = `template-slot-${slot.name}`;
|
|
694
|
+
let field;
|
|
695
|
+
if (slot.type === "color") field = /* @__PURE__ */ jsx5("input", { id, className: "h-6 w-10", type: "color", value: String(value), onChange: (e) => onChange(e.target.value) });
|
|
696
|
+
else if (slot.type === "number")
|
|
697
|
+
field = /* @__PURE__ */ jsx5("input", { id, className: input, type: "number", min: slot.min, max: slot.max, step: slot.integer ? 1 : "any", value: String(value), onChange: (e) => onChange(e.target.value === "" ? "" : Number(e.target.value)) });
|
|
698
|
+
else if (slot.type === "text")
|
|
699
|
+
field = /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
700
|
+
/* @__PURE__ */ jsx5("input", { id, className: input, maxLength: slot.maxLength, value: String(value), onChange: (e) => onChange(e.target.value) }),
|
|
701
|
+
slot.maxLength !== void 0 && /* @__PURE__ */ jsxs4("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
702
|
+
String(value).length,
|
|
703
|
+
"/",
|
|
704
|
+
slot.maxLength
|
|
705
|
+
] })
|
|
706
|
+
] });
|
|
707
|
+
else
|
|
708
|
+
field = /* @__PURE__ */ jsx5(
|
|
709
|
+
"input",
|
|
710
|
+
{
|
|
711
|
+
id,
|
|
712
|
+
className: input,
|
|
713
|
+
placeholder: slot.hasDefault ? "URL or <svg> (default: a placeholder)" : "URL or <svg> (empty: left open)",
|
|
714
|
+
value: typeof value === "string" ? value : "",
|
|
715
|
+
onChange: (e) => onChange(e.target.value)
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
return /* @__PURE__ */ jsxs4("div", { className: "flex flex-col gap-0.5", "data-template-slot": slot.name, children: [
|
|
719
|
+
/* @__PURE__ */ jsx5("label", { htmlFor: id, className: "text-muted-foreground", title: slot.description, children: slot.label }),
|
|
720
|
+
field,
|
|
721
|
+
error && /* @__PURE__ */ jsx5("p", { className: "text-[11px] text-destructive", children: error })
|
|
722
|
+
] });
|
|
723
|
+
}
|
|
724
|
+
function EffectTemplates({ provider, onFill, fillLabel = "Use template", disabled = false, className = "" }) {
|
|
725
|
+
const [templates, setTemplates] = useState5([]);
|
|
726
|
+
const [chosen, setChosen] = useState5("");
|
|
727
|
+
const [description, setDescription] = useState5(null);
|
|
728
|
+
const [values, setValues] = useState5({});
|
|
729
|
+
const [message, setMessage] = useState5(null);
|
|
730
|
+
const [busy, setBusy] = useState5(false);
|
|
731
|
+
const supported = !!provider?.capabilities.supportsTemplates && !!provider.listTemplates && !!provider.describeTemplate;
|
|
732
|
+
useEffect5(() => {
|
|
733
|
+
let live = true;
|
|
734
|
+
setTemplates([]);
|
|
735
|
+
setChosen("");
|
|
736
|
+
if (supported) void Promise.resolve(provider.listTemplates()).then((t) => live && setTemplates(t), () => live && setTemplates([]));
|
|
737
|
+
return () => {
|
|
738
|
+
live = false;
|
|
739
|
+
};
|
|
740
|
+
}, [provider, supported]);
|
|
741
|
+
useEffect5(() => {
|
|
742
|
+
let live = true;
|
|
743
|
+
setDescription(null);
|
|
744
|
+
setMessage(null);
|
|
745
|
+
if (!chosen || !supported) return;
|
|
746
|
+
void Promise.resolve(provider.describeTemplate(chosen)).then(
|
|
747
|
+
(d) => {
|
|
748
|
+
if (!live) return;
|
|
749
|
+
setDescription(d);
|
|
750
|
+
setValues(Object.fromEntries(d.slots.map((s) => [s.name, isSubjectTemplateSlot(s) ? "" : s.default])));
|
|
751
|
+
},
|
|
752
|
+
(e) => live && setMessage(e.message)
|
|
753
|
+
);
|
|
754
|
+
return () => {
|
|
755
|
+
live = false;
|
|
756
|
+
};
|
|
757
|
+
}, [provider, supported, chosen]);
|
|
758
|
+
if (!supported || !templates.length) return null;
|
|
759
|
+
const given = Object.fromEntries(Object.entries(values).filter(([, v]) => v !== ""));
|
|
760
|
+
const problems = description ? checkTemplateValues(description.slots, given) : [];
|
|
761
|
+
const problemFor = (slot) => problems.find((p) => p.startsWith(`Slot "${slot}"`));
|
|
762
|
+
const fill = async () => {
|
|
763
|
+
if (!description || problems.length) return;
|
|
764
|
+
setBusy(true);
|
|
765
|
+
const r = await onFill(description.id, given);
|
|
766
|
+
setBusy(false);
|
|
767
|
+
if (r.ok) setChosen("");
|
|
768
|
+
else setMessage(r.error);
|
|
769
|
+
};
|
|
770
|
+
return /* @__PURE__ */ jsxs4("div", { className: `flex flex-col gap-1 text-xs ${className}`, "data-effect-templates": "", children: [
|
|
771
|
+
/* @__PURE__ */ jsxs4("select", { className: input, "aria-label": "Template", disabled, value: chosen, onChange: (e) => setChosen(e.target.value), children: [
|
|
772
|
+
/* @__PURE__ */ jsx5("option", { value: "", children: "Templates\u2026" }),
|
|
773
|
+
templates.map((t) => /* @__PURE__ */ jsxs4("option", { value: t.id, children: [
|
|
774
|
+
t.name,
|
|
775
|
+
" (",
|
|
776
|
+
t.shots,
|
|
777
|
+
" shots)"
|
|
778
|
+
] }, t.id))
|
|
779
|
+
] }),
|
|
780
|
+
description && /* @__PURE__ */ jsxs4(
|
|
781
|
+
"form",
|
|
782
|
+
{
|
|
783
|
+
className: "flex flex-col gap-1 rounded border border-border p-1",
|
|
784
|
+
"data-template-form": description.id,
|
|
785
|
+
onSubmit: (e) => {
|
|
786
|
+
e.preventDefault();
|
|
787
|
+
void fill();
|
|
788
|
+
},
|
|
789
|
+
children: [
|
|
790
|
+
/* @__PURE__ */ jsx5("p", { className: "text-[11px] text-muted-foreground", children: description.description }),
|
|
791
|
+
description.slots.map((slot) => /* @__PURE__ */ jsx5(SlotField, { slot, value: values[slot.name] ?? "", error: problemFor(slot.name), onChange: (v) => setValues({ ...values, [slot.name]: v }) }, slot.name)),
|
|
792
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex gap-1", children: [
|
|
793
|
+
/* @__PURE__ */ jsx5("button", { type: "submit", className: btn, disabled: disabled || busy || problems.length > 0, children: fillLabel }),
|
|
794
|
+
/* @__PURE__ */ jsx5("button", { type: "button", className: btn, onClick: () => setChosen(""), children: "Cancel" })
|
|
795
|
+
] })
|
|
796
|
+
]
|
|
797
|
+
}
|
|
798
|
+
),
|
|
799
|
+
message && /* @__PURE__ */ jsx5("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
800
|
+
] });
|
|
801
|
+
}
|
|
802
|
+
|
|
686
803
|
export {
|
|
687
804
|
useEffects,
|
|
688
805
|
useEffectDescription,
|
|
@@ -690,5 +807,6 @@ export {
|
|
|
690
807
|
EffectsBrowser,
|
|
691
808
|
EffectParameters,
|
|
692
809
|
useEffectAuthoring,
|
|
693
|
-
EffectAuthoringEditor
|
|
810
|
+
EffectAuthoringEditor,
|
|
811
|
+
EffectTemplates
|
|
694
812
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type EffectProvider } from '@pixerate/editor/effects';
|
|
3
|
+
export interface EffectTemplatesProps {
|
|
4
|
+
/** The effects provider; nothing shows unless it has templates. */
|
|
5
|
+
provider: EffectProvider | null | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Fills the chosen template (the editor's `fillTemplate`). Resolves `{ ok: false, error }` to
|
|
8
|
+
* show the refusal; on success the form closes.
|
|
9
|
+
*/
|
|
10
|
+
onFill: (template: string, values: Record<string, unknown>) => Promise<{
|
|
11
|
+
ok: true;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** The button that fills (default "Use template"). */
|
|
17
|
+
fillLabel?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The provider's sequence templates: pick one, fill its slots in a form (built from
|
|
23
|
+
* `describeTemplate`, checked with `checkTemplateValues` as you type) and use it. Hidden when the
|
|
24
|
+
* provider has no templates.
|
|
25
|
+
*/
|
|
26
|
+
export declare function EffectTemplates({ provider, onFill, fillLabel, disabled, className }: EffectTemplatesProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type EffectProvider } from '@pixerate/editor/effects';
|
|
3
|
+
export interface EffectTemplatesProps {
|
|
4
|
+
/** The effects provider; nothing shows unless it has templates. */
|
|
5
|
+
provider: EffectProvider | null | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Fills the chosen template (the editor's `fillTemplate`). Resolves `{ ok: false, error }` to
|
|
8
|
+
* show the refusal; on success the form closes.
|
|
9
|
+
*/
|
|
10
|
+
onFill: (template: string, values: Record<string, unknown>) => Promise<{
|
|
11
|
+
ok: true;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
}>;
|
|
16
|
+
/** The button that fills (default "Use template"). */
|
|
17
|
+
fillLabel?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The provider's sequence templates: pick one, fill its slots in a form (built from
|
|
23
|
+
* `describeTemplate`, checked with `checkTemplateValues` as you type) and use it. Hidden when the
|
|
24
|
+
* provider has no templates.
|
|
25
|
+
*/
|
|
26
|
+
export declare function EffectTemplates({ provider, onFill, fillLabel, disabled, className }: EffectTemplatesProps): React.JSX.Element | null;
|
package/dist/effects/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ var effects_exports = {};
|
|
|
33
33
|
__export(effects_exports, {
|
|
34
34
|
EffectAuthoringEditor: () => EffectAuthoringEditor,
|
|
35
35
|
EffectParameters: () => EffectParameters,
|
|
36
|
+
EffectTemplates: () => EffectTemplates,
|
|
36
37
|
EffectThumbnail: () => EffectThumbnail,
|
|
37
38
|
EffectsBrowser: () => EffectsBrowser,
|
|
38
39
|
useEffectAuthoring: () => useEffectAuthoring,
|
|
@@ -1307,10 +1308,10 @@ function ParameterNumberInput(props) {
|
|
|
1307
1308
|
const resolved = resolveParameterComponents(components, ctx);
|
|
1308
1309
|
const CustomInput = resolved.input;
|
|
1309
1310
|
const plain = plainNumber(field, value);
|
|
1310
|
-
const handleCommit = (text,
|
|
1311
|
+
const handleCommit = (text, input2) => {
|
|
1311
1312
|
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
1312
1313
|
if (n === null || n === value) {
|
|
1313
|
-
if (
|
|
1314
|
+
if (input2) input2.value = plain;
|
|
1314
1315
|
} else {
|
|
1315
1316
|
onChange(n);
|
|
1316
1317
|
}
|
|
@@ -2252,10 +2253,128 @@ function DurationField({ duration, onCommit }) {
|
|
|
2252
2253
|
}
|
|
2253
2254
|
);
|
|
2254
2255
|
}
|
|
2256
|
+
|
|
2257
|
+
// src/effects/EffectTemplates.tsx
|
|
2258
|
+
var import_react12 = require("react");
|
|
2259
|
+
var import_effects5 = require("@pixerate/editor/effects");
|
|
2260
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2261
|
+
var input = "w-full min-w-0 rounded border border-border bg-transparent px-1 py-0.5 text-xs";
|
|
2262
|
+
var btn = "rounded border border-border px-2 py-0.5 text-[11px] disabled:opacity-40";
|
|
2263
|
+
function SlotField({ slot, value, error, onChange }) {
|
|
2264
|
+
const id = `template-slot-${slot.name}`;
|
|
2265
|
+
let field;
|
|
2266
|
+
if (slot.type === "color") field = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { id, className: "h-6 w-10", type: "color", value: String(value), onChange: (e) => onChange(e.target.value) });
|
|
2267
|
+
else if (slot.type === "number")
|
|
2268
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { id, className: input, type: "number", min: slot.min, max: slot.max, step: slot.integer ? 1 : "any", value: String(value), onChange: (e) => onChange(e.target.value === "" ? "" : Number(e.target.value)) });
|
|
2269
|
+
else if (slot.type === "text")
|
|
2270
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2271
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { id, className: input, maxLength: slot.maxLength, value: String(value), onChange: (e) => onChange(e.target.value) }),
|
|
2272
|
+
slot.maxLength !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "text-[10px] text-muted-foreground", children: [
|
|
2273
|
+
String(value).length,
|
|
2274
|
+
"/",
|
|
2275
|
+
slot.maxLength
|
|
2276
|
+
] })
|
|
2277
|
+
] });
|
|
2278
|
+
else
|
|
2279
|
+
field = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2280
|
+
"input",
|
|
2281
|
+
{
|
|
2282
|
+
id,
|
|
2283
|
+
className: input,
|
|
2284
|
+
placeholder: slot.hasDefault ? "URL or <svg> (default: a placeholder)" : "URL or <svg> (empty: left open)",
|
|
2285
|
+
value: typeof value === "string" ? value : "",
|
|
2286
|
+
onChange: (e) => onChange(e.target.value)
|
|
2287
|
+
}
|
|
2288
|
+
);
|
|
2289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-0.5", "data-template-slot": slot.name, children: [
|
|
2290
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: id, className: "text-muted-foreground", title: slot.description, children: slot.label }),
|
|
2291
|
+
field,
|
|
2292
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-[11px] text-destructive", children: error })
|
|
2293
|
+
] });
|
|
2294
|
+
}
|
|
2295
|
+
function EffectTemplates({ provider, onFill, fillLabel = "Use template", disabled = false, className = "" }) {
|
|
2296
|
+
const [templates, setTemplates] = (0, import_react12.useState)([]);
|
|
2297
|
+
const [chosen, setChosen] = (0, import_react12.useState)("");
|
|
2298
|
+
const [description, setDescription] = (0, import_react12.useState)(null);
|
|
2299
|
+
const [values, setValues] = (0, import_react12.useState)({});
|
|
2300
|
+
const [message, setMessage] = (0, import_react12.useState)(null);
|
|
2301
|
+
const [busy, setBusy] = (0, import_react12.useState)(false);
|
|
2302
|
+
const supported = !!provider?.capabilities.supportsTemplates && !!provider.listTemplates && !!provider.describeTemplate;
|
|
2303
|
+
(0, import_react12.useEffect)(() => {
|
|
2304
|
+
let live = true;
|
|
2305
|
+
setTemplates([]);
|
|
2306
|
+
setChosen("");
|
|
2307
|
+
if (supported) void Promise.resolve(provider.listTemplates()).then((t) => live && setTemplates(t), () => live && setTemplates([]));
|
|
2308
|
+
return () => {
|
|
2309
|
+
live = false;
|
|
2310
|
+
};
|
|
2311
|
+
}, [provider, supported]);
|
|
2312
|
+
(0, import_react12.useEffect)(() => {
|
|
2313
|
+
let live = true;
|
|
2314
|
+
setDescription(null);
|
|
2315
|
+
setMessage(null);
|
|
2316
|
+
if (!chosen || !supported) return;
|
|
2317
|
+
void Promise.resolve(provider.describeTemplate(chosen)).then(
|
|
2318
|
+
(d) => {
|
|
2319
|
+
if (!live) return;
|
|
2320
|
+
setDescription(d);
|
|
2321
|
+
setValues(Object.fromEntries(d.slots.map((s) => [s.name, (0, import_effects5.isSubjectTemplateSlot)(s) ? "" : s.default])));
|
|
2322
|
+
},
|
|
2323
|
+
(e) => live && setMessage(e.message)
|
|
2324
|
+
);
|
|
2325
|
+
return () => {
|
|
2326
|
+
live = false;
|
|
2327
|
+
};
|
|
2328
|
+
}, [provider, supported, chosen]);
|
|
2329
|
+
if (!supported || !templates.length) return null;
|
|
2330
|
+
const given = Object.fromEntries(Object.entries(values).filter(([, v]) => v !== ""));
|
|
2331
|
+
const problems = description ? (0, import_effects5.checkTemplateValues)(description.slots, given) : [];
|
|
2332
|
+
const problemFor = (slot) => problems.find((p) => p.startsWith(`Slot "${slot}"`));
|
|
2333
|
+
const fill = async () => {
|
|
2334
|
+
if (!description || problems.length) return;
|
|
2335
|
+
setBusy(true);
|
|
2336
|
+
const r = await onFill(description.id, given);
|
|
2337
|
+
setBusy(false);
|
|
2338
|
+
if (r.ok) setChosen("");
|
|
2339
|
+
else setMessage(r.error);
|
|
2340
|
+
};
|
|
2341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `flex flex-col gap-1 text-xs ${className}`, "data-effect-templates": "", children: [
|
|
2342
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("select", { className: input, "aria-label": "Template", disabled, value: chosen, onChange: (e) => setChosen(e.target.value), children: [
|
|
2343
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "", children: "Templates\u2026" }),
|
|
2344
|
+
templates.map((t) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("option", { value: t.id, children: [
|
|
2345
|
+
t.name,
|
|
2346
|
+
" (",
|
|
2347
|
+
t.shots,
|
|
2348
|
+
" shots)"
|
|
2349
|
+
] }, t.id))
|
|
2350
|
+
] }),
|
|
2351
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
2352
|
+
"form",
|
|
2353
|
+
{
|
|
2354
|
+
className: "flex flex-col gap-1 rounded border border-border p-1",
|
|
2355
|
+
"data-template-form": description.id,
|
|
2356
|
+
onSubmit: (e) => {
|
|
2357
|
+
e.preventDefault();
|
|
2358
|
+
void fill();
|
|
2359
|
+
},
|
|
2360
|
+
children: [
|
|
2361
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-[11px] text-muted-foreground", children: description.description }),
|
|
2362
|
+
description.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SlotField, { slot, value: values[slot.name] ?? "", error: problemFor(slot.name), onChange: (v) => setValues({ ...values, [slot.name]: v }) }, slot.name)),
|
|
2363
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex gap-1", children: [
|
|
2364
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "submit", className: btn, disabled: disabled || busy || problems.length > 0, children: fillLabel }),
|
|
2365
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: btn, onClick: () => setChosen(""), children: "Cancel" })
|
|
2366
|
+
] })
|
|
2367
|
+
]
|
|
2368
|
+
}
|
|
2369
|
+
),
|
|
2370
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
2371
|
+
] });
|
|
2372
|
+
}
|
|
2255
2373
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2256
2374
|
0 && (module.exports = {
|
|
2257
2375
|
EffectAuthoringEditor,
|
|
2258
2376
|
EffectParameters,
|
|
2377
|
+
EffectTemplates,
|
|
2259
2378
|
EffectThumbnail,
|
|
2260
2379
|
EffectsBrowser,
|
|
2261
2380
|
useEffectAuthoring,
|
package/dist/effects/index.d.cts
CHANGED
package/dist/effects/index.d.ts
CHANGED
package/dist/effects/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EffectAuthoringEditor,
|
|
3
3
|
EffectParameters,
|
|
4
|
+
EffectTemplates,
|
|
4
5
|
EffectThumbnail,
|
|
5
6
|
EffectsBrowser,
|
|
6
7
|
useEffectAuthoring,
|
|
7
8
|
useEffectDescription,
|
|
8
9
|
useEffects
|
|
9
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-TOYSB4DK.js";
|
|
10
11
|
import "../chunk-5RPB4WGT.js";
|
|
11
12
|
import "../chunk-KIRIU53A.js";
|
|
12
13
|
import "../chunk-3I7FOSLF.js";
|
|
13
14
|
export {
|
|
14
15
|
EffectAuthoringEditor,
|
|
15
16
|
EffectParameters,
|
|
17
|
+
EffectTemplates,
|
|
16
18
|
EffectThumbnail,
|
|
17
19
|
EffectsBrowser,
|
|
18
20
|
useEffectAuthoring,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { Template, ColorGradient, type FileImportOptions } from "@pixerate/editor";
|
|
3
|
+
import { type LoadingIndicatorProps } from "../loading-node/index.cjs";
|
|
2
4
|
export interface UsePromptEditorProps {
|
|
3
5
|
/**
|
|
4
6
|
* The editor content as plain text. Changes from the parent (e.g. clearing
|
|
@@ -53,5 +55,13 @@ export interface UsePromptEditorProps {
|
|
|
53
55
|
* plain-text paste handler, so pasted files are not imported.
|
|
54
56
|
*/
|
|
55
57
|
fileImport?: Omit<FileImportOptions, "asPlainText"> | boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Component drawn inside each `loadingNode` placeholder instead of the default SVG spinner,
|
|
60
|
+
* e.g. your design system's loader. It receives `state` (`id`, `label`). Read when a
|
|
61
|
+
* placeholder renders, so changing it does not recreate the editor.
|
|
62
|
+
*/
|
|
63
|
+
loadingIndicator?: React.ComponentType<LoadingIndicatorProps>;
|
|
64
|
+
/** Accessible label of loading placeholders, announced by screen readers (default `"Loading…"`). */
|
|
65
|
+
loadingLabel?: string;
|
|
56
66
|
}
|
|
57
|
-
export declare function usePromptEditor({ content, onContentChange, templates, templateColorMap: userColorMap, isEditing, placeholder, className, onEscape, onKeyDown, onSelectionChange, onSlashCommandMatch, clearSlashCommand, slashCommandActive, onMilestone, containerId, jsonVariables, speed, fileImport, }: UsePromptEditorProps): import("@tiptap/core").Editor | null;
|
|
67
|
+
export declare function usePromptEditor({ content, onContentChange, templates, templateColorMap: userColorMap, isEditing, placeholder, className, onEscape, onKeyDown, onSelectionChange, onSlashCommandMatch, clearSlashCommand, slashCommandActive, onMilestone, containerId, jsonVariables, speed, fileImport, loadingIndicator, loadingLabel, }: UsePromptEditorProps): import("@tiptap/core").Editor | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { Template, ColorGradient, type FileImportOptions } from "@pixerate/editor";
|
|
3
|
+
import { type LoadingIndicatorProps } from "../loading-node/index.js";
|
|
2
4
|
export interface UsePromptEditorProps {
|
|
3
5
|
/**
|
|
4
6
|
* The editor content as plain text. Changes from the parent (e.g. clearing
|
|
@@ -53,5 +55,13 @@ export interface UsePromptEditorProps {
|
|
|
53
55
|
* plain-text paste handler, so pasted files are not imported.
|
|
54
56
|
*/
|
|
55
57
|
fileImport?: Omit<FileImportOptions, "asPlainText"> | boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Component drawn inside each `loadingNode` placeholder instead of the default SVG spinner,
|
|
60
|
+
* e.g. your design system's loader. It receives `state` (`id`, `label`). Read when a
|
|
61
|
+
* placeholder renders, so changing it does not recreate the editor.
|
|
62
|
+
*/
|
|
63
|
+
loadingIndicator?: React.ComponentType<LoadingIndicatorProps>;
|
|
64
|
+
/** Accessible label of loading placeholders, announced by screen readers (default `"Loading…"`). */
|
|
65
|
+
loadingLabel?: string;
|
|
56
66
|
}
|
|
57
|
-
export declare function usePromptEditor({ content, onContentChange, templates, templateColorMap: userColorMap, isEditing, placeholder, className, onEscape, onKeyDown, onSelectionChange, onSlashCommandMatch, clearSlashCommand, slashCommandActive, onMilestone, containerId, jsonVariables, speed, fileImport, }: UsePromptEditorProps): import("@tiptap/core").Editor | null;
|
|
67
|
+
export declare function usePromptEditor({ content, onContentChange, templates, templateColorMap: userColorMap, isEditing, placeholder, className, onEscape, onKeyDown, onSelectionChange, onSlashCommandMatch, clearSlashCommand, slashCommandActive, onMilestone, containerId, jsonVariables, speed, fileImport, loadingIndicator, loadingLabel, }: UsePromptEditorProps): import("@tiptap/core").Editor | null;
|
|
@@ -36,9 +36,9 @@ import {
|
|
|
36
36
|
useImageEditorControls,
|
|
37
37
|
useImageEffectsTools,
|
|
38
38
|
useImageHistogram
|
|
39
|
-
} from "../chunk-
|
|
39
|
+
} from "../chunk-65EL63YS.js";
|
|
40
40
|
import "../chunk-AJCWF6SN.js";
|
|
41
|
-
import "../chunk-
|
|
41
|
+
import "../chunk-TOYSB4DK.js";
|
|
42
42
|
import "../chunk-5RPB4WGT.js";
|
|
43
43
|
import "../chunk-KIRIU53A.js";
|
|
44
44
|
import "../chunk-3I7FOSLF.js";
|