@pixerate/editor-react 0.114.2 → 0.115.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 +361 -216
- package/dist/animation-editor/index.js +2 -2
- package/dist/canvas/index.cjs +539 -394
- package/dist/canvas/index.js +2 -2
- package/dist/{chunk-2INOKIJN.js → chunk-2KXZLZAS.js} +381 -364
- package/dist/{chunk-5LFQ2UQZ.js → chunk-5RPB4WGT.js} +240 -102
- package/dist/{chunk-BWEARAWR.js → chunk-6BWTJ3EE.js} +40 -18
- package/dist/effects/EffectParameters.d.cts +4 -1
- package/dist/effects/EffectParameters.d.ts +4 -1
- package/dist/effects/index.cjs +367 -222
- package/dist/effects/index.js +2 -2
- package/dist/image-editor/ImageEffectControls.d.cts +4 -1
- package/dist/image-editor/ImageEffectControls.d.ts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.cts +4 -1
- package/dist/image-editor/ImageProviderEffectsPanel.d.ts +4 -1
- package/dist/image-editor/controls/controls.d.cts +19 -0
- package/dist/image-editor/controls/controls.d.ts +19 -0
- package/dist/image-editor/controls/parameterControls.d.cts +4 -0
- package/dist/image-editor/controls/parameterControls.d.ts +4 -0
- package/dist/image-editor/index.cjs +924 -765
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/image-editor/index.js +5 -3
- package/dist/index.cjs +1444 -1285
- package/dist/index.js +5 -3
- package/dist/paint-editor/index.cjs +354 -209
- package/dist/paint-editor/index.js +2 -2
- package/dist/parameters/ParametersPanel.d.cts +4 -1
- package/dist/parameters/ParametersPanel.d.ts +4 -1
- package/dist/parameters/controls.d.cts +92 -0
- package/dist/parameters/controls.d.ts +92 -0
- package/dist/parameters/fields.d.cts +20 -7
- package/dist/parameters/fields.d.ts +20 -7
- package/dist/parameters/index.cjs +369 -184
- package/dist/parameters/index.d.cts +1 -0
- package/dist/parameters/index.d.ts +1 -0
- package/dist/parameters/index.js +70 -14
- package/dist/vector/index.cjs +340 -195
- package/dist/vector/index.js +2 -2
- package/dist/video-editor/index.cjs +437 -292
- package/dist/video-editor/index.js +2 -2
- package/package.json +3 -3
package/dist/canvas/index.cjs
CHANGED
|
@@ -1966,7 +1966,7 @@ function useCanvasBrushes(options = {}) {
|
|
|
1966
1966
|
}
|
|
1967
1967
|
|
|
1968
1968
|
// src/canvas/CanvasEffects.tsx
|
|
1969
|
-
var
|
|
1969
|
+
var import_react30 = require("react");
|
|
1970
1970
|
var import_canvas16 = require("@pixerate/editor/canvas");
|
|
1971
1971
|
|
|
1972
1972
|
// src/effects/useEffects.ts
|
|
@@ -2100,12 +2100,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
2100
2100
|
}
|
|
2101
2101
|
|
|
2102
2102
|
// src/effects/EffectParameters.tsx
|
|
2103
|
-
var
|
|
2103
|
+
var import_react29 = __toESM(require("react"), 1);
|
|
2104
2104
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
2105
2105
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
2106
2106
|
|
|
2107
2107
|
// src/parameters/fields.tsx
|
|
2108
|
-
var
|
|
2108
|
+
var import_react28 = require("react");
|
|
2109
2109
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
2110
2110
|
|
|
2111
2111
|
// src/color/index.ts
|
|
@@ -3147,18 +3147,58 @@ function useResolvedColor(value, scheme) {
|
|
|
3147
3147
|
// src/color/index.ts
|
|
3148
3148
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
3149
3149
|
|
|
3150
|
-
// src/parameters/
|
|
3150
|
+
// src/parameters/controls.tsx
|
|
3151
|
+
var import_react27 = require("react");
|
|
3151
3152
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3153
|
+
var ParameterComponentsContext = (0, import_react27.createContext)({});
|
|
3154
|
+
function useParameterComponents() {
|
|
3155
|
+
return (0, import_react27.useContext)(ParameterComponentsContext);
|
|
3156
|
+
}
|
|
3157
|
+
function resolveParameterComponents(explicit, context) {
|
|
3158
|
+
return {
|
|
3159
|
+
input: explicit?.input ?? context?.input,
|
|
3160
|
+
slider: explicit?.slider ?? context?.slider,
|
|
3161
|
+
select: explicit?.select ?? context?.select,
|
|
3162
|
+
color: explicit?.color ?? context?.color
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
// src/parameters/fields.tsx
|
|
3167
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3168
|
+
var parameterInputStyle = import_parameters.parameterThemeStyles.input;
|
|
3169
|
+
var parameterSelectStyle = import_parameters.parameterThemeStyles.select;
|
|
3170
|
+
var parameterButtonStyle = import_parameters.parameterThemeStyles.button;
|
|
3171
|
+
var parameterRangeStyle = import_parameters.parameterThemeStyles.range;
|
|
3152
3172
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3153
3173
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
3154
3174
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
3155
|
-
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, ...rest }) {
|
|
3175
|
+
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
3176
|
+
const inputRef = (0, import_react28.useRef)(null);
|
|
3177
|
+
const lastCommitted = (0, import_react28.useRef)(null);
|
|
3178
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
3179
|
+
lastCommitted.current = null;
|
|
3180
|
+
const el = inputRef.current;
|
|
3181
|
+
if (el && el.value !== value) el.value = value;
|
|
3182
|
+
}, [value]);
|
|
3156
3183
|
const commit = (el) => {
|
|
3157
|
-
|
|
3184
|
+
const text = el.value;
|
|
3185
|
+
if (text === value || text === lastCommitted.current) return;
|
|
3186
|
+
onCommit(text, el);
|
|
3187
|
+
lastCommitted.current = el.value === text ? text : null;
|
|
3158
3188
|
};
|
|
3189
|
+
const commitRef = (0, import_react28.useRef)(commit);
|
|
3190
|
+
commitRef.current = commit;
|
|
3191
|
+
(0, import_react28.useEffect)(() => {
|
|
3192
|
+
const el = inputRef.current;
|
|
3193
|
+
if (!el) return;
|
|
3194
|
+
const change = () => commitRef.current(el);
|
|
3195
|
+
el.addEventListener("change", change);
|
|
3196
|
+
return () => el.removeEventListener("change", change);
|
|
3197
|
+
}, [multiline]);
|
|
3159
3198
|
const keyDown = (e) => {
|
|
3160
3199
|
onKeyDown?.(e);
|
|
3161
3200
|
if (e.defaultPrevented) return;
|
|
3201
|
+
if (e.key === "Tab") commit(e.currentTarget);
|
|
3162
3202
|
if (e.key === "Enter" && (!multiline || e.metaKey || e.ctrlKey)) {
|
|
3163
3203
|
e.preventDefault();
|
|
3164
3204
|
commit(e.currentTarget);
|
|
@@ -3168,86 +3208,114 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
3168
3208
|
const props = {
|
|
3169
3209
|
defaultValue: value,
|
|
3170
3210
|
className: className ?? parameterInputClass,
|
|
3211
|
+
style: { ...parameterInputStyle, ...style },
|
|
3171
3212
|
onBlur: (e) => commit(e.currentTarget),
|
|
3172
3213
|
onKeyDown: keyDown,
|
|
3173
3214
|
...rest
|
|
3174
3215
|
};
|
|
3175
|
-
|
|
3216
|
+
const forwarded = rest.ref;
|
|
3217
|
+
const setRef = (el) => {
|
|
3218
|
+
inputRef.current = el;
|
|
3219
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
3220
|
+
else if (forwarded) forwarded.current = el;
|
|
3221
|
+
};
|
|
3222
|
+
return multiline ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("textarea", { ...props, ref: setRef, className: `${props.className} h-auto min-h-[3.5rem] py-1` }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { type: "text", ...props, ref: setRef });
|
|
3176
3223
|
}
|
|
3177
3224
|
var plainNumber = (field, value) => (0, import_parameters.formatParameterNumber)({ ...field, unit: void 0 }, value);
|
|
3178
|
-
function ParameterNumberInput({
|
|
3179
|
-
field,
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3225
|
+
function ParameterNumberInput(props) {
|
|
3226
|
+
const { field, value, onChange, disabled, id, components, "aria-label": ariaLabel } = props;
|
|
3227
|
+
const ctx = useParameterComponents();
|
|
3228
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
3229
|
+
const CustomInput = resolved.input;
|
|
3230
|
+
const plain = plainNumber(field, value);
|
|
3231
|
+
const handleCommit = (text, input) => {
|
|
3232
|
+
const n = (0, import_parameters.parseParameterNumberInput)(field, text);
|
|
3233
|
+
if (n === null || n === value) {
|
|
3234
|
+
if (input) input.value = plain;
|
|
3235
|
+
} else {
|
|
3236
|
+
onChange(n);
|
|
3237
|
+
}
|
|
3238
|
+
};
|
|
3239
|
+
const handleKeyDown = (e) => {
|
|
3240
|
+
if (e.key !== "ArrowUp" && e.key !== "ArrowDown") return;
|
|
3241
|
+
e.preventDefault();
|
|
3242
|
+
const step = (0, import_parameters.parameterStep)(field) * (e.shiftKey ? 10 : 1);
|
|
3243
|
+
onChange((0, import_parameters.clampParameterNumber)(field, value + (e.key === "ArrowUp" ? step : -step)));
|
|
3244
|
+
};
|
|
3245
|
+
const inputProps = {
|
|
3246
|
+
id,
|
|
3247
|
+
inputMode: "decimal",
|
|
3248
|
+
"aria-label": ariaLabel ?? (0, import_parameters.parameterLabel)(field),
|
|
3249
|
+
value: plain,
|
|
3250
|
+
disabled: disabled || field.readOnly,
|
|
3251
|
+
className: `${parameterInputClass} ${field.unit ? "pr-6" : ""}`,
|
|
3252
|
+
style: parameterInputStyle,
|
|
3253
|
+
onCommit: handleCommit,
|
|
3254
|
+
onKeyDown: handleKeyDown
|
|
3255
|
+
};
|
|
3256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "relative min-w-0 flex-1", children: [
|
|
3257
|
+
CustomInput ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CustomInput, { ...inputProps, label: (0, import_parameters.parameterLabel)(field) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterCommitInput, { ...inputProps }),
|
|
3258
|
+
field.unit && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground", children: field.unit })
|
|
3210
3259
|
] });
|
|
3211
3260
|
}
|
|
3212
3261
|
function ParameterSlider(props) {
|
|
3213
|
-
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
3214
|
-
const
|
|
3262
|
+
const { field, value, onChange, onGestureStart, onGestureEnd, disabled, components } = props;
|
|
3263
|
+
const ctx = useParameterComponents();
|
|
3264
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
3265
|
+
const CustomSlider = resolved.slider;
|
|
3266
|
+
const dragging = (0, import_react28.useRef)(false);
|
|
3267
|
+
const start = () => {
|
|
3268
|
+
if (dragging.current) return;
|
|
3269
|
+
dragging.current = true;
|
|
3270
|
+
onGestureStart?.();
|
|
3271
|
+
};
|
|
3215
3272
|
const end = () => {
|
|
3216
3273
|
if (!dragging.current) return;
|
|
3217
3274
|
dragging.current = false;
|
|
3218
3275
|
onGestureEnd?.();
|
|
3219
3276
|
};
|
|
3220
|
-
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0,
|
|
3277
|
+
if (!(0, import_parameters.isSliderField)(field)) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props });
|
|
3221
3278
|
const step = (0, import_parameters.parameterStep)(field);
|
|
3222
|
-
|
|
3223
|
-
|
|
3279
|
+
const sliderProps = {
|
|
3280
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
3281
|
+
"aria-valuetext": (0, import_parameters.formatParameterNumber)(field, value),
|
|
3282
|
+
// A `control: 'slider'` field may leave out a bound: the range input's own defaults.
|
|
3283
|
+
min: field.min ?? 0,
|
|
3284
|
+
max: field.max ?? 100,
|
|
3285
|
+
step,
|
|
3286
|
+
value,
|
|
3287
|
+
disabled: disabled || field.readOnly,
|
|
3288
|
+
className: rangeClass,
|
|
3289
|
+
style: parameterRangeStyle
|
|
3290
|
+
};
|
|
3291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3292
|
+
CustomSlider ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3293
|
+
CustomSlider,
|
|
3294
|
+
{
|
|
3295
|
+
...sliderProps,
|
|
3296
|
+
id: props.id ? `${props.id}-slider` : void 0,
|
|
3297
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
3298
|
+
onChange: (v) => onChange((0, import_parameters.clampParameterNumber)(field, v)),
|
|
3299
|
+
onGestureStart: start,
|
|
3300
|
+
onGestureEnd: end
|
|
3301
|
+
}
|
|
3302
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3224
3303
|
"input",
|
|
3225
3304
|
{
|
|
3226
3305
|
type: "range",
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
min: field.min,
|
|
3230
|
-
max: field.max,
|
|
3231
|
-
step,
|
|
3232
|
-
value,
|
|
3233
|
-
disabled: disabled || field.readOnly,
|
|
3234
|
-
className: rangeClass,
|
|
3235
|
-
onPointerDown: () => {
|
|
3236
|
-
if (dragging.current) return;
|
|
3237
|
-
dragging.current = true;
|
|
3238
|
-
onGestureStart?.();
|
|
3239
|
-
},
|
|
3306
|
+
...sliderProps,
|
|
3307
|
+
onPointerDown: start,
|
|
3240
3308
|
onPointerUp: end,
|
|
3241
3309
|
onPointerCancel: end,
|
|
3242
3310
|
onBlur: end,
|
|
3243
3311
|
onChange: (e) => onChange((0, import_parameters.clampParameterNumber)(field, Number(e.target.value)))
|
|
3244
3312
|
}
|
|
3245
3313
|
),
|
|
3246
|
-
/* @__PURE__ */ (0,
|
|
3314
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-20 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterNumberInput, { ...props, id: props.id, "aria-label": `${(0, import_parameters.parameterLabel)(field)} value` }) })
|
|
3247
3315
|
] });
|
|
3248
3316
|
}
|
|
3249
3317
|
function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
3250
|
-
return /* @__PURE__ */ (0,
|
|
3318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3251
3319
|
"button",
|
|
3252
3320
|
{
|
|
3253
3321
|
type: "button",
|
|
@@ -3258,7 +3326,7 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3258
3326
|
disabled: disabled || field.readOnly,
|
|
3259
3327
|
onClick: () => onChange(!value),
|
|
3260
3328
|
className: `relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:opacity-50 ${value ? "bg-primary" : "bg-muted"}`,
|
|
3261
|
-
children: /* @__PURE__ */ (0,
|
|
3329
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3262
3330
|
"span",
|
|
3263
3331
|
{
|
|
3264
3332
|
className: `pointer-events-none block h-4 w-4 rounded-full bg-background shadow transition-transform ${value ? "translate-x-4" : "translate-x-0.5"}`
|
|
@@ -3267,11 +3335,15 @@ function ParameterToggle({ field, value, onChange, disabled, id }) {
|
|
|
3267
3335
|
}
|
|
3268
3336
|
);
|
|
3269
3337
|
}
|
|
3270
|
-
function ParameterSelect(
|
|
3338
|
+
function ParameterSelect(props) {
|
|
3339
|
+
const { field, value, onChange, disabled, id, components } = props;
|
|
3340
|
+
const ctx = useParameterComponents();
|
|
3341
|
+
const resolved = resolveParameterComponents(components, ctx);
|
|
3342
|
+
const CustomSelect = resolved.select;
|
|
3271
3343
|
const options = (0, import_parameters.getChoiceOptions)(field);
|
|
3272
3344
|
const off = disabled || field.readOnly;
|
|
3273
3345
|
if (field.control === "segmented") {
|
|
3274
|
-
return /* @__PURE__ */ (0,
|
|
3346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { role: "radiogroup", "aria-label": (0, import_parameters.parameterLabel)(field), className: "inline-flex flex-wrap rounded-md border border-input bg-muted p-0.5", children: options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3275
3347
|
"button",
|
|
3276
3348
|
{
|
|
3277
3349
|
type: "button",
|
|
@@ -3286,8 +3358,25 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
3286
3358
|
String(o.value)
|
|
3287
3359
|
)) });
|
|
3288
3360
|
}
|
|
3361
|
+
if (CustomSelect) {
|
|
3362
|
+
const customOptions = options.map((o) => ({ value: o.value, label: (0, import_parameters.choiceOptionLabel)(o), description: o.description }));
|
|
3363
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3364
|
+
CustomSelect,
|
|
3365
|
+
{
|
|
3366
|
+
id,
|
|
3367
|
+
label: (0, import_parameters.parameterLabel)(field),
|
|
3368
|
+
"aria-label": (0, import_parameters.parameterLabel)(field),
|
|
3369
|
+
value,
|
|
3370
|
+
options: customOptions,
|
|
3371
|
+
disabled: off,
|
|
3372
|
+
className: parameterInputClass,
|
|
3373
|
+
style: parameterSelectStyle,
|
|
3374
|
+
onChange: (v) => onChange((0, import_parameters.matchParameterOptionValue)(options, v))
|
|
3375
|
+
}
|
|
3376
|
+
);
|
|
3377
|
+
}
|
|
3289
3378
|
const index = options.findIndex((o) => o.value === value);
|
|
3290
|
-
return /* @__PURE__ */ (0,
|
|
3379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3291
3380
|
"select",
|
|
3292
3381
|
{
|
|
3293
3382
|
id,
|
|
@@ -3299,22 +3388,24 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
3299
3388
|
if (option) onChange(option.value);
|
|
3300
3389
|
},
|
|
3301
3390
|
className: parameterInputClass,
|
|
3302
|
-
|
|
3391
|
+
style: parameterSelectStyle,
|
|
3392
|
+
children: options.map((o, i) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: String(i), title: o.description, style: parameterSelectStyle, children: (0, import_parameters.choiceOptionLabel)(o) }, String(o.value)))
|
|
3303
3393
|
}
|
|
3304
3394
|
);
|
|
3305
3395
|
}
|
|
3306
|
-
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
3307
|
-
const
|
|
3308
|
-
const
|
|
3309
|
-
const
|
|
3310
|
-
const
|
|
3396
|
+
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
3397
|
+
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
3398
|
+
const [open, setOpen] = (0, import_react28.useState)(false);
|
|
3399
|
+
const containerRef = (0, import_react28.useRef)(null);
|
|
3400
|
+
const buttonRef = (0, import_react28.useRef)(null);
|
|
3401
|
+
const popoverRef = (0, import_react28.useRef)(null);
|
|
3311
3402
|
const alpha = !!field.alpha;
|
|
3312
3403
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
3313
3404
|
const rgb = hex.slice(0, 7);
|
|
3314
3405
|
const shown = alpha ? hex : rgb;
|
|
3315
3406
|
const off = disabled || field.readOnly;
|
|
3316
3407
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3317
|
-
(0,
|
|
3408
|
+
(0, import_react28.useEffect)(() => {
|
|
3318
3409
|
if (!open) return;
|
|
3319
3410
|
const onPointerDown = (e) => {
|
|
3320
3411
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3335,9 +3426,25 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3335
3426
|
window.removeEventListener("keydown", onKeyDown, true);
|
|
3336
3427
|
};
|
|
3337
3428
|
}, [open]);
|
|
3338
|
-
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3340
|
-
|
|
3429
|
+
if (CustomColor) {
|
|
3430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3431
|
+
CustomColor,
|
|
3432
|
+
{
|
|
3433
|
+
id,
|
|
3434
|
+
value: shown,
|
|
3435
|
+
alpha,
|
|
3436
|
+
swatches: field.swatches,
|
|
3437
|
+
disabled: off,
|
|
3438
|
+
label: name,
|
|
3439
|
+
onChange,
|
|
3440
|
+
onGestureStart,
|
|
3441
|
+
onGestureEnd
|
|
3442
|
+
}
|
|
3443
|
+
);
|
|
3444
|
+
}
|
|
3445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: containerRef, className: "relative space-y-1.5", children: [
|
|
3446
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3447
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3341
3448
|
"button",
|
|
3342
3449
|
{
|
|
3343
3450
|
ref: buttonRef,
|
|
@@ -3348,10 +3455,10 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3348
3455
|
disabled: off,
|
|
3349
3456
|
onClick: () => setOpen((prev) => !prev),
|
|
3350
3457
|
className: "relative h-7 w-9 shrink-0 overflow-hidden rounded-md border border-input bg-[repeating-conic-gradient(#d4d4d8_0_25%,#fff_0_50%)] bg-[length:8px_8px] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50",
|
|
3351
|
-
children: /* @__PURE__ */ (0,
|
|
3458
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "absolute inset-0", style: { background: shown } })
|
|
3352
3459
|
}
|
|
3353
3460
|
),
|
|
3354
|
-
/* @__PURE__ */ (0,
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3355
3462
|
ParameterCommitInput,
|
|
3356
3463
|
{
|
|
3357
3464
|
id,
|
|
@@ -3367,7 +3474,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3367
3474
|
}
|
|
3368
3475
|
)
|
|
3369
3476
|
] }),
|
|
3370
|
-
open && /* @__PURE__ */ (0,
|
|
3477
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3371
3478
|
"div",
|
|
3372
3479
|
{
|
|
3373
3480
|
ref: popoverRef,
|
|
@@ -3381,7 +3488,7 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3381
3488
|
},
|
|
3382
3489
|
className: "absolute left-0 top-full z-50 mt-1 w-64 rounded-lg border border-border bg-popover p-2 text-popover-foreground shadow-xl",
|
|
3383
3490
|
style: { background: "var(--popover, var(--background, #fff))" },
|
|
3384
|
-
children: /* @__PURE__ */ (0,
|
|
3491
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3385
3492
|
ColorPicker,
|
|
3386
3493
|
{
|
|
3387
3494
|
value: shown,
|
|
@@ -3397,13 +3504,13 @@ function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd,
|
|
|
3397
3504
|
)
|
|
3398
3505
|
] });
|
|
3399
3506
|
}
|
|
3400
|
-
function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
3507
|
+
function ParameterVector({ field, value, onChange, disabled, id, components }) {
|
|
3401
3508
|
const size = (0, import_parameters.vectorSize)(field);
|
|
3402
|
-
return /* @__PURE__ */ (0,
|
|
3509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "grid gap-1.5", style: { gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }, children: Array.from({ length: size }, (_, i) => {
|
|
3403
3510
|
const component = (0, import_parameters.vectorComponentField)(field, i);
|
|
3404
|
-
return /* @__PURE__ */ (0,
|
|
3405
|
-
/* @__PURE__ */ (0,
|
|
3406
|
-
/* @__PURE__ */ (0,
|
|
3511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "flex min-w-0 items-center gap-1", children: [
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "w-3 shrink-0 text-[10px] uppercase text-muted-foreground", children: component.label }),
|
|
3513
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3407
3514
|
ParameterNumberInput,
|
|
3408
3515
|
{
|
|
3409
3516
|
field: component,
|
|
@@ -3411,6 +3518,7 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
3411
3518
|
id: i === 0 ? id : void 0,
|
|
3412
3519
|
"aria-label": `${(0, import_parameters.parameterLabel)(field)} ${component.label}`,
|
|
3413
3520
|
disabled: disabled || field.readOnly,
|
|
3521
|
+
components,
|
|
3414
3522
|
onChange: (n) => onChange(Array.from({ length: size }, (_2, j) => j === i ? n : value[j] ?? 0))
|
|
3415
3523
|
}
|
|
3416
3524
|
)
|
|
@@ -3420,11 +3528,11 @@ function ParameterVector({ field, value, onChange, disabled, id }) {
|
|
|
3420
3528
|
function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
3421
3529
|
const off = disabled || field.readOnly;
|
|
3422
3530
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
3423
|
-
return /* @__PURE__ */ (0,
|
|
3424
|
-
/* @__PURE__ */ (0,
|
|
3425
|
-
/* @__PURE__ */ (0,
|
|
3426
|
-
/* @__PURE__ */ (0,
|
|
3427
|
-
/* @__PURE__ */ (0,
|
|
3531
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "space-y-1.5", children: [
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3533
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex h-12 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md border border-input bg-muted", children: value ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: value, alt: name, className: "h-full w-full object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "None" }) }),
|
|
3534
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
3535
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3428
3536
|
ParameterCommitInput,
|
|
3429
3537
|
{
|
|
3430
3538
|
id,
|
|
@@ -3435,30 +3543,48 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3435
3543
|
onCommit: (text) => onChange(text.trim())
|
|
3436
3544
|
}
|
|
3437
3545
|
),
|
|
3438
|
-
/* @__PURE__ */ (0,
|
|
3439
|
-
resolveFile && /* @__PURE__ */ (0,
|
|
3440
|
-
"
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
{
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3546
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-1", children: [
|
|
3547
|
+
resolveFile && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3548
|
+
"label",
|
|
3549
|
+
{
|
|
3550
|
+
style: parameterButtonStyle,
|
|
3551
|
+
className: `${parameterButtonClass} cursor-pointer ${off ? "pointer-events-none opacity-50" : ""}`,
|
|
3552
|
+
children: [
|
|
3553
|
+
"Choose file\u2026",
|
|
3554
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3555
|
+
"input",
|
|
3556
|
+
{
|
|
3557
|
+
type: "file",
|
|
3558
|
+
className: "sr-only",
|
|
3559
|
+
accept: field.accept ?? "image/*",
|
|
3560
|
+
disabled: off,
|
|
3561
|
+
"aria-label": `${name} file`,
|
|
3562
|
+
onChange: async (e) => {
|
|
3563
|
+
const file = e.target.files?.[0];
|
|
3564
|
+
e.target.value = "";
|
|
3565
|
+
if (file) onChange(await resolveFile(file));
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
)
|
|
3569
|
+
]
|
|
3570
|
+
}
|
|
3571
|
+
),
|
|
3572
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3573
|
+
"button",
|
|
3574
|
+
{
|
|
3575
|
+
type: "button",
|
|
3576
|
+
style: parameterButtonStyle,
|
|
3577
|
+
className: parameterButtonClass,
|
|
3578
|
+
disabled: off,
|
|
3579
|
+
onClick: () => onChange(""),
|
|
3580
|
+
"aria-label": `Clear ${name}`,
|
|
3581
|
+
children: "Clear"
|
|
3582
|
+
}
|
|
3583
|
+
)
|
|
3458
3584
|
] })
|
|
3459
3585
|
] })
|
|
3460
3586
|
] }),
|
|
3461
|
-
field.options && field.options.length > 0 && /* @__PURE__ */ (0,
|
|
3587
|
+
field.options && field.options.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex flex-wrap gap-1", children: field.options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3462
3588
|
"button",
|
|
3463
3589
|
{
|
|
3464
3590
|
type: "button",
|
|
@@ -3468,14 +3594,14 @@ function ParameterImage({ field, value, onChange, disabled, id, resolveFile }) {
|
|
|
3468
3594
|
disabled: off,
|
|
3469
3595
|
onClick: () => onChange(o.url),
|
|
3470
3596
|
className: "h-9 w-12 overflow-hidden rounded border border-input aria-pressed:ring-2 aria-pressed:ring-primary",
|
|
3471
|
-
children: /* @__PURE__ */ (0,
|
|
3597
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: o.url, alt: "", className: "h-full w-full object-cover" })
|
|
3472
3598
|
},
|
|
3473
3599
|
o.url
|
|
3474
3600
|
)) })
|
|
3475
3601
|
] });
|
|
3476
3602
|
}
|
|
3477
3603
|
function ParameterText({ field, value, onChange, disabled, id }) {
|
|
3478
|
-
return /* @__PURE__ */ (0,
|
|
3604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3479
3605
|
ParameterCommitInput,
|
|
3480
3606
|
{
|
|
3481
3607
|
id,
|
|
@@ -3494,24 +3620,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
3494
3620
|
switch (field.type) {
|
|
3495
3621
|
case "number":
|
|
3496
3622
|
case "int":
|
|
3497
|
-
return /* @__PURE__ */ (0,
|
|
3623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSlider, { field, value, onChange: set, ...rest });
|
|
3498
3624
|
case "boolean":
|
|
3499
|
-
return /* @__PURE__ */ (0,
|
|
3625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterToggle, { field, value, onChange: set, ...rest });
|
|
3500
3626
|
case "choice":
|
|
3501
|
-
return /* @__PURE__ */ (0,
|
|
3627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterSelect, { field, value, onChange: set, ...rest });
|
|
3502
3628
|
case "color":
|
|
3503
|
-
return /* @__PURE__ */ (0,
|
|
3629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterColor, { field, value, onChange: set, ...rest });
|
|
3504
3630
|
case "vector":
|
|
3505
|
-
return /* @__PURE__ */ (0,
|
|
3631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterVector, { field, value, onChange: set, ...rest });
|
|
3506
3632
|
case "image":
|
|
3507
|
-
return /* @__PURE__ */ (0,
|
|
3633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterImage, { field, value, onChange: set, resolveFile, ...rest });
|
|
3508
3634
|
case "text":
|
|
3509
|
-
return /* @__PURE__ */ (0,
|
|
3635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ParameterText, { field, value, onChange: set, ...rest });
|
|
3510
3636
|
}
|
|
3511
3637
|
}
|
|
3512
3638
|
|
|
3513
3639
|
// src/effects/EffectParameters.tsx
|
|
3514
|
-
var
|
|
3640
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3515
3641
|
function EffectParameters({
|
|
3516
3642
|
description,
|
|
3517
3643
|
values,
|
|
@@ -3523,56 +3649,75 @@ function EffectParameters({
|
|
|
3523
3649
|
renderControlAddon,
|
|
3524
3650
|
fonts,
|
|
3525
3651
|
disabled = false,
|
|
3526
|
-
className = ""
|
|
3652
|
+
className = "",
|
|
3653
|
+
components
|
|
3527
3654
|
}) {
|
|
3528
|
-
const fields = (0,
|
|
3529
|
-
const idBase = (0,
|
|
3530
|
-
const gesture =
|
|
3531
|
-
const count =
|
|
3532
|
-
|
|
3533
|
-
|
|
3655
|
+
const fields = (0, import_react29.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3656
|
+
const idBase = (0, import_react29.useId)();
|
|
3657
|
+
const gesture = import_react29.default.useRef(null);
|
|
3658
|
+
const count = import_react29.default.useRef(0);
|
|
3659
|
+
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3660
|
+
const handlePresetSelect = (name) => {
|
|
3661
|
+
if (!name) return;
|
|
3662
|
+
if (onPresetName) {
|
|
3663
|
+
onPresetName(name);
|
|
3664
|
+
} else if (onPreset) {
|
|
3665
|
+
const preset = description.presets.find((p) => p.name === name);
|
|
3666
|
+
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
3670
|
+
(onPreset || onPresetName) && description.presets.length > 0 && (CustomPresetSelect ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3671
|
+
CustomPresetSelect,
|
|
3672
|
+
{
|
|
3673
|
+
"aria-label": `${description.name} presets`,
|
|
3674
|
+
label: `${description.name} presets`,
|
|
3675
|
+
value: "",
|
|
3676
|
+
disabled,
|
|
3677
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3678
|
+
style: parameterSelectStyle,
|
|
3679
|
+
options: [
|
|
3680
|
+
{ value: "", label: "Presets\u2026" },
|
|
3681
|
+
...description.presets.map((p) => ({ value: p.name, label: p.name }))
|
|
3682
|
+
],
|
|
3683
|
+
onChange: (name) => handlePresetSelect(String(name))
|
|
3684
|
+
}
|
|
3685
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
3534
3686
|
"select",
|
|
3535
3687
|
{
|
|
3536
|
-
className: "w-full rounded border border-border
|
|
3688
|
+
className: "w-full rounded border border-border px-1 py-0.5 text-xs",
|
|
3689
|
+
style: parameterSelectStyle,
|
|
3537
3690
|
"aria-label": `${description.name} presets`,
|
|
3538
3691
|
value: "",
|
|
3539
3692
|
disabled,
|
|
3540
|
-
onChange: (e) =>
|
|
3541
|
-
const name = e.currentTarget.value;
|
|
3542
|
-
if (!name) return;
|
|
3543
|
-
if (onPresetName) {
|
|
3544
|
-
onPresetName(name);
|
|
3545
|
-
} else if (onPreset) {
|
|
3546
|
-
const preset = description.presets.find((p) => p.name === name);
|
|
3547
|
-
if (preset) onPreset({ ...description.defaults, ...preset.values });
|
|
3548
|
-
}
|
|
3549
|
-
},
|
|
3693
|
+
onChange: (e) => handlePresetSelect(e.currentTarget.value),
|
|
3550
3694
|
children: [
|
|
3551
|
-
/* @__PURE__ */ (0,
|
|
3552
|
-
description.presets.map((p) => /* @__PURE__ */ (0,
|
|
3695
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "", style: parameterSelectStyle, children: "Presets\u2026" }),
|
|
3696
|
+
description.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: p.name, style: parameterSelectStyle, children: p.name }, p.name))
|
|
3553
3697
|
]
|
|
3554
3698
|
}
|
|
3555
|
-
),
|
|
3699
|
+
)),
|
|
3556
3700
|
fields.map((field) => {
|
|
3557
3701
|
const label = (0, import_parameters2.parameterLabel)(field);
|
|
3558
3702
|
const inputId = `${idBase}-${field.id}`;
|
|
3559
3703
|
const keyed = keyframed?.has(field.id) ?? false;
|
|
3560
3704
|
const value = (0, import_effects3.effectFieldValue)(field, values[field.id]);
|
|
3561
3705
|
const changed = !keyed && !(0, import_parameters2.parameterValuesEqual)(value, field.default);
|
|
3562
|
-
return /* @__PURE__ */ (0,
|
|
3563
|
-
/* @__PURE__ */ (0,
|
|
3564
|
-
/* @__PURE__ */ (0,
|
|
3565
|
-
keyed && /* @__PURE__ */ (0,
|
|
3706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-1", "data-effect-control": field.id, children: [
|
|
3707
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
3708
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
|
|
3709
|
+
keyed && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
|
|
3566
3710
|
renderControlAddon?.(field.id),
|
|
3567
|
-
onReset && changed && !disabled && /* @__PURE__ */ (0,
|
|
3711
|
+
onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
|
|
3568
3712
|
] }),
|
|
3569
|
-
/* @__PURE__ */ (0,
|
|
3713
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3570
3714
|
ParameterFieldControl,
|
|
3571
3715
|
{
|
|
3572
3716
|
field,
|
|
3573
3717
|
value,
|
|
3574
3718
|
id: inputId,
|
|
3575
3719
|
disabled: disabled || keyed,
|
|
3720
|
+
components,
|
|
3576
3721
|
onChange: (v) => onChange(field.id, v, gesture.current),
|
|
3577
3722
|
onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
|
|
3578
3723
|
onGestureEnd: () => gesture.current = null
|
|
@@ -3580,46 +3725,46 @@ function EffectParameters({
|
|
|
3580
3725
|
)
|
|
3581
3726
|
] }, field.id);
|
|
3582
3727
|
}),
|
|
3583
|
-
!fields.length && /* @__PURE__ */ (0,
|
|
3728
|
+
!fields.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
|
|
3584
3729
|
] });
|
|
3585
3730
|
}
|
|
3586
3731
|
|
|
3587
3732
|
// src/canvas/CanvasEffects.tsx
|
|
3588
|
-
var
|
|
3589
|
-
var ProviderContext = (0,
|
|
3733
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3734
|
+
var ProviderContext = (0, import_react30.createContext)(null);
|
|
3590
3735
|
function CanvasEffectsProvider({ provider, children }) {
|
|
3591
|
-
return /* @__PURE__ */ (0,
|
|
3736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ProviderContext.Provider, { value: provider ?? null, children });
|
|
3592
3737
|
}
|
|
3593
|
-
var useCanvasEffectsProviderContext = () => (0,
|
|
3738
|
+
var useCanvasEffectsProviderContext = () => (0, import_react30.useContext)(ProviderContext);
|
|
3594
3739
|
function CanvasNodeEffectLayer({ effect, width, height, clipPath, clipTransform }) {
|
|
3595
3740
|
const provider = useCanvasEffectsProviderContext();
|
|
3596
|
-
const ref = (0,
|
|
3597
|
-
const [failed, setFailed] = (0,
|
|
3741
|
+
const ref = (0, import_react30.useRef)(null);
|
|
3742
|
+
const [failed, setFailed] = (0, import_react30.useState)(false);
|
|
3598
3743
|
const dpr = typeof window !== "undefined" ? Math.min(2, window.devicePixelRatio || 1) : 1;
|
|
3599
3744
|
const pw = Math.max(1, Math.round(width * dpr));
|
|
3600
3745
|
const ph = Math.max(1, Math.round(height * dpr));
|
|
3601
3746
|
const key = JSON.stringify(effect);
|
|
3602
|
-
(0,
|
|
3747
|
+
(0, import_react30.useEffect)(() => {
|
|
3603
3748
|
const canvas2 = ref.current;
|
|
3604
3749
|
if (!provider || !canvas2) return;
|
|
3605
3750
|
setFailed(false);
|
|
3606
3751
|
const run = (0, import_canvas16.runCanvasNodeEffect)({ provider, effect, target: canvas2, onError: () => setFailed(true) });
|
|
3607
3752
|
return () => run.stop();
|
|
3608
3753
|
}, [provider, key, pw, ph]);
|
|
3609
|
-
const clipId = (0,
|
|
3754
|
+
const clipId = (0, import_react30.useMemo)(() => `pixerate-effect-clip-${Math.random().toString(36).slice(2)}`, []);
|
|
3610
3755
|
if (!provider || failed || !(width > 0 && height > 0)) return null;
|
|
3611
3756
|
const style = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none", opacity: effect.opacity ?? 1 };
|
|
3612
|
-
const canvas = /* @__PURE__ */ (0,
|
|
3613
|
-
if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0,
|
|
3614
|
-
return /* @__PURE__ */ (0,
|
|
3615
|
-
/* @__PURE__ */ (0,
|
|
3616
|
-
/* @__PURE__ */ (0,
|
|
3757
|
+
const canvas = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("canvas", { ref, width: pw, height: ph, style: { width: "100%", height: "100%", display: "block" }, "data-canvas-effect": effect.effect });
|
|
3758
|
+
if (effect.mode === "overlay" || !clipPath) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { style, children: canvas });
|
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("svg", { style, viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", "aria-hidden": "true", children: [
|
|
3760
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("clipPath", { id: clipId, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: clipPath, transform: clipTransform }) }) }),
|
|
3761
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("foreignObject", { x: 0, y: 0, width, height, clipPath: `url(#${clipId})`, children: canvas })
|
|
3617
3762
|
] });
|
|
3618
3763
|
}
|
|
3619
3764
|
function useCanvasEffects(options) {
|
|
3620
|
-
const opts = (0,
|
|
3765
|
+
const opts = (0, import_react30.useRef)(options);
|
|
3621
3766
|
opts.current = options;
|
|
3622
|
-
const controller = (0,
|
|
3767
|
+
const controller = (0, import_react30.useMemo)(
|
|
3623
3768
|
() => (0, import_canvas16.createCanvasEffectsController)({
|
|
3624
3769
|
getNodes: () => opts.current.getNodes(),
|
|
3625
3770
|
setNodes: (n) => opts.current.setNodes(n),
|
|
@@ -3630,7 +3775,7 @@ function useCanvasEffects(options) {
|
|
|
3630
3775
|
}),
|
|
3631
3776
|
[]
|
|
3632
3777
|
);
|
|
3633
|
-
(0,
|
|
3778
|
+
(0, import_react30.useEffect)(() => {
|
|
3634
3779
|
if (!options.effects) return;
|
|
3635
3780
|
return controller.useEffects(options.effects);
|
|
3636
3781
|
}, [controller, options.effects]);
|
|
@@ -3638,7 +3783,7 @@ function useCanvasEffects(options) {
|
|
|
3638
3783
|
}
|
|
3639
3784
|
function useCanvasEffectsTools(registry, controller, options = {}) {
|
|
3640
3785
|
const { id, namespace, readOnly, subscribe } = options;
|
|
3641
|
-
(0,
|
|
3786
|
+
(0, import_react30.useEffect)(() => {
|
|
3642
3787
|
if (!registry) return;
|
|
3643
3788
|
return registry.register((0, import_canvas16.createCanvasEffectsToolProvider)(controller, { id, namespace, readOnly, subscribe }));
|
|
3644
3789
|
}, [registry, controller, id, namespace, readOnly, subscribe]);
|
|
@@ -3646,12 +3791,12 @@ function useCanvasEffectsTools(registry, controller, options = {}) {
|
|
|
3646
3791
|
var btn = "rounded border border-border px-1.5 py-0.5 text-[11px] disabled:opacity-40";
|
|
3647
3792
|
function Controls({ controller, nodeId, effect }) {
|
|
3648
3793
|
const { description, error } = useEffectDescription(controller.effectsProvider, effect.effect);
|
|
3649
|
-
const [message, setMessage] = (0,
|
|
3794
|
+
const [message, setMessage] = (0, import_react30.useState)(null);
|
|
3650
3795
|
const run = (work) => void work.then(() => setMessage(null), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
3651
|
-
if (error) return /* @__PURE__ */ (0,
|
|
3652
|
-
if (!description) return /* @__PURE__ */ (0,
|
|
3653
|
-
return /* @__PURE__ */ (0,
|
|
3654
|
-
/* @__PURE__ */ (0,
|
|
3796
|
+
if (error) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-amber-500", children: error });
|
|
3797
|
+
if (!description) return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "Loading\u2026" });
|
|
3798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
|
3799
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3655
3800
|
EffectParameters,
|
|
3656
3801
|
{
|
|
3657
3802
|
description,
|
|
@@ -3661,75 +3806,75 @@ function Controls({ controller, nodeId, effect }) {
|
|
|
3661
3806
|
onPreset: (v) => run(controller.updateNodeEffect(nodeId, { values: v }))
|
|
3662
3807
|
}
|
|
3663
3808
|
),
|
|
3664
|
-
message && /* @__PURE__ */ (0,
|
|
3809
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
3665
3810
|
] });
|
|
3666
3811
|
}
|
|
3667
3812
|
function CanvasEffectsPanel({ controller, nodeId, shape, sceneId, className = "" }) {
|
|
3668
|
-
const [, setTick] = (0,
|
|
3669
|
-
(0,
|
|
3813
|
+
const [, setTick] = (0, import_react30.useState)(0);
|
|
3814
|
+
(0, import_react30.useEffect)(() => controller.effects.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
3670
3815
|
const provider = controller.effectsProvider;
|
|
3671
|
-
const [browse, setBrowse] = (0,
|
|
3672
|
-
const [message, setMessage] = (0,
|
|
3816
|
+
const [browse, setBrowse] = (0, import_react30.useState)(null);
|
|
3817
|
+
const [message, setMessage] = (0, import_react30.useState)(null);
|
|
3673
3818
|
const run = (work) => {
|
|
3674
3819
|
setMessage(null);
|
|
3675
3820
|
Promise.resolve().then(work).then(() => setTick((n) => n + 1), (e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
3676
3821
|
};
|
|
3677
3822
|
const effect = (0, import_canvas16.isShapeDescription)(shape) ? shape.effect : void 0;
|
|
3678
3823
|
const transition = sceneId ? controller.sceneTransition(sceneId) : void 0;
|
|
3679
|
-
return /* @__PURE__ */ (0,
|
|
3680
|
-
/* @__PURE__ */ (0,
|
|
3681
|
-
/* @__PURE__ */ (0,
|
|
3682
|
-
/* @__PURE__ */ (0,
|
|
3683
|
-
/* @__PURE__ */ (0,
|
|
3684
|
-
/* @__PURE__ */ (0,
|
|
3824
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("section", { className: `flex flex-col gap-2 text-xs ${className}`, "aria-label": "Canvas effects", "data-canvas-effects": "", children: [
|
|
3825
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-wrap items-center gap-1", children: [
|
|
3826
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "flex-1 font-semibold", children: "Effects" }),
|
|
3827
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "fill", onClick: () => setBrowse(browse === "fill" ? null : "fill"), children: "Fill\u2026" }),
|
|
3828
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !nodeId || !shape, "aria-pressed": browse === "overlay", onClick: () => setBrowse(browse === "overlay" ? null : "overlay"), children: "Overlay\u2026" }),
|
|
3829
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, disabled: !provider || !sceneId, "aria-pressed": browse === "transition", onClick: () => setBrowse(browse === "transition" ? null : "transition"), children: "Scene transition\u2026" })
|
|
3685
3830
|
] }),
|
|
3686
|
-
!provider && /* @__PURE__ */ (0,
|
|
3687
|
-
browse === "fill" && nodeId && /* @__PURE__ */ (0,
|
|
3688
|
-
browse === "overlay" && nodeId && /* @__PURE__ */ (0,
|
|
3689
|
-
browse === "transition" && sceneId && /* @__PURE__ */ (0,
|
|
3690
|
-
effect && nodeId && /* @__PURE__ */ (0,
|
|
3691
|
-
/* @__PURE__ */ (0,
|
|
3692
|
-
/* @__PURE__ */ (0,
|
|
3831
|
+
!provider && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No effects provider is registered. Effects on the canvas are kept." }),
|
|
3832
|
+
browse === "fill" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["generator", "interactive"], title: "Fills", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "fill" }))) }),
|
|
3833
|
+
browse === "overlay" && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["overlay", "title", "interactive", "generator"], title: "Overlays", onPick: (e) => (setBrowse(null), run(() => controller.applyNodeEffect(nodeId, e.id, { mode: "overlay" }))) }),
|
|
3834
|
+
browse === "transition" && sceneId && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(EffectsBrowser, { provider, uses: ["transition"], title: "Transitions", onPick: (e) => (setBrowse(null), run(() => controller.setSceneTransition(sceneId, e.id))) }),
|
|
3835
|
+
effect && nodeId && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-1 rounded border border-border p-1", "data-canvas-node-effect": nodeId, children: [
|
|
3836
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3837
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "min-w-0 flex-1 truncate font-medium", children: [
|
|
3693
3838
|
effect.name ?? effect.effect,
|
|
3694
3839
|
" ",
|
|
3695
|
-
/* @__PURE__ */ (0,
|
|
3840
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
3696
3841
|
"\xB7 ",
|
|
3697
3842
|
effect.mode
|
|
3698
3843
|
] })
|
|
3699
3844
|
] }),
|
|
3700
|
-
/* @__PURE__ */ (0,
|
|
3701
|
-
/* @__PURE__ */ (0,
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "flex items-center gap-1", children: [
|
|
3846
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "checkbox", checked: effect.playing !== false, "aria-label": "Play", onChange: (e) => {
|
|
3702
3847
|
const playing = e.currentTarget.checked;
|
|
3703
3848
|
run(() => controller.updateNodeEffect(nodeId, { playing }));
|
|
3704
3849
|
} }),
|
|
3705
3850
|
" Play"
|
|
3706
3851
|
] }),
|
|
3707
|
-
/* @__PURE__ */ (0,
|
|
3852
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, "aria-label": "Remove effect", onClick: () => run(() => controller.removeNodeEffect(nodeId)), children: "\u2715" })
|
|
3708
3853
|
] }),
|
|
3709
|
-
provider && /* @__PURE__ */ (0,
|
|
3854
|
+
provider && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Controls, { controller, nodeId, effect })
|
|
3710
3855
|
] }),
|
|
3711
|
-
sceneId && transition && /* @__PURE__ */ (0,
|
|
3712
|
-
/* @__PURE__ */ (0,
|
|
3856
|
+
sceneId && transition && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-1", "data-canvas-scene-transition": sceneId, children: [
|
|
3857
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
3713
3858
|
"Into scene: ",
|
|
3714
3859
|
transition.name ?? transition.effect,
|
|
3715
3860
|
" (",
|
|
3716
3861
|
transition.duration ?? 600,
|
|
3717
3862
|
" ms)"
|
|
3718
3863
|
] }),
|
|
3719
|
-
/* @__PURE__ */ (0,
|
|
3864
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { type: "button", className: btn, "aria-label": "Remove transition", onClick: () => run(() => controller.setSceneTransition(sceneId, null)), children: "\u2715" })
|
|
3720
3865
|
] }),
|
|
3721
|
-
message && /* @__PURE__ */ (0,
|
|
3866
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
3722
3867
|
] });
|
|
3723
3868
|
}
|
|
3724
3869
|
|
|
3725
3870
|
// src/canvas/ShapeNode.tsx
|
|
3726
|
-
var
|
|
3871
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3727
3872
|
function ShapeNode({ id, data, width, height, selected, className = "", children, positionAbsoluteX, positionAbsoluteY }) {
|
|
3728
3873
|
const shape = data?.shape;
|
|
3729
3874
|
const brushImage = useShapeBrushstroke((0, import_canvas17.isShapeDescription)(shape) ? shape : null, width, height, { x: positionAbsoluteX ?? 0, y: positionAbsoluteY ?? 0 });
|
|
3730
3875
|
if (!(0, import_canvas17.isShapeDescription)(shape)) return null;
|
|
3731
3876
|
const render = (0, import_canvas17.getShapeRenderData)(shape, { width, height }, { id: id || data?.id });
|
|
3732
|
-
return /* @__PURE__ */ (0,
|
|
3877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3733
3878
|
"div",
|
|
3734
3879
|
{
|
|
3735
3880
|
className: `pixerate-shape-node ${className}`.trim(),
|
|
@@ -3737,7 +3882,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
3737
3882
|
"data-selected": selected ? "true" : void 0,
|
|
3738
3883
|
style: { position: "relative", width: "100%", height: "100%" },
|
|
3739
3884
|
children: [
|
|
3740
|
-
/* @__PURE__ */ (0,
|
|
3885
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
3741
3886
|
"svg",
|
|
3742
3887
|
{
|
|
3743
3888
|
viewBox: render.viewBox,
|
|
@@ -3747,13 +3892,13 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
3747
3892
|
style: { display: "block", overflow: "visible" },
|
|
3748
3893
|
"aria-hidden": "true",
|
|
3749
3894
|
children: [
|
|
3750
|
-
(render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0,
|
|
3751
|
-
render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0,
|
|
3752
|
-
render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0,
|
|
3753
|
-
render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0,
|
|
3754
|
-
render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0,
|
|
3895
|
+
(render.fillGradient || render.strokeGradient) && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("defs", { children: [
|
|
3896
|
+
render.fillGradient && render.fillGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("linearGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
3897
|
+
render.fillGradient && render.fillGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("radialGradient", { id: render.fillGradient.id, ...render.fillGradient.attrs, children: render.fillGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
3898
|
+
render.strokeGradient && render.strokeGradient.type === "linear" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("linearGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) }),
|
|
3899
|
+
render.strokeGradient && render.strokeGradient.type === "radial" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("radialGradient", { id: render.strokeGradient.id, ...render.strokeGradient.attrs, children: render.strokeGradient.stops.map((stop, i) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("stop", { offset: stop.offset, stopColor: stop.stopColor, stopOpacity: stop.stopOpacity }, i)) })
|
|
3755
3900
|
] }),
|
|
3756
|
-
brushImage ? /* @__PURE__ */ (0,
|
|
3901
|
+
brushImage ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("g", { transform: render.transform, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3757
3902
|
"image",
|
|
3758
3903
|
{
|
|
3759
3904
|
className: "pixerate-shape-brushstroke",
|
|
@@ -3765,7 +3910,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
3765
3910
|
preserveAspectRatio: "none",
|
|
3766
3911
|
opacity: render.opacity
|
|
3767
3912
|
}
|
|
3768
|
-
) }) : /* @__PURE__ */ (0,
|
|
3913
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3769
3914
|
"path",
|
|
3770
3915
|
{
|
|
3771
3916
|
d: render.d,
|
|
@@ -3783,7 +3928,7 @@ function ShapeNode({ id, data, width, height, selected, className = "", children
|
|
|
3783
3928
|
]
|
|
3784
3929
|
}
|
|
3785
3930
|
),
|
|
3786
|
-
shape.effect && width && height ? /* @__PURE__ */ (0,
|
|
3931
|
+
shape.effect && width && height ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CanvasNodeEffectLayer, { effect: shape.effect, width, height, clipPath: render.d, clipTransform: render.transform }) : null,
|
|
3787
3932
|
children
|
|
3788
3933
|
]
|
|
3789
3934
|
}
|
|
@@ -3797,15 +3942,15 @@ var import_canvas34 = require("@pixerate/editor/canvas");
|
|
|
3797
3942
|
var import_canvas35 = require("@pixerate/editor/canvas");
|
|
3798
3943
|
|
|
3799
3944
|
// src/canvas/useCanvasAutoLayout.ts
|
|
3800
|
-
var
|
|
3945
|
+
var import_react31 = require("react");
|
|
3801
3946
|
var import_canvas18 = require("@pixerate/editor/canvas");
|
|
3802
3947
|
function useCanvasAutoLayout(options) {
|
|
3803
|
-
const [guides, setGuides] = (0,
|
|
3804
|
-
const nodesRef = (0,
|
|
3948
|
+
const [guides, setGuides] = (0, import_react31.useState)([]);
|
|
3949
|
+
const nodesRef = (0, import_react31.useRef)(options.nodes);
|
|
3805
3950
|
nodesRef.current = options.nodes;
|
|
3806
|
-
const optionsRef = (0,
|
|
3951
|
+
const optionsRef = (0, import_react31.useRef)(options);
|
|
3807
3952
|
optionsRef.current = options;
|
|
3808
|
-
const controller = (0,
|
|
3953
|
+
const controller = (0, import_react31.useMemo)(
|
|
3809
3954
|
() => (0, import_canvas18.createCanvasAutoLayoutController)({
|
|
3810
3955
|
getNodes: () => nodesRef.current,
|
|
3811
3956
|
setNodes: (next) => {
|
|
@@ -3831,10 +3976,10 @@ function useCanvasAutoLayout(options) {
|
|
|
3831
3976
|
}),
|
|
3832
3977
|
[]
|
|
3833
3978
|
);
|
|
3834
|
-
(0,
|
|
3979
|
+
(0, import_react31.useLayoutEffect)(() => {
|
|
3835
3980
|
if (controller.hasPending) controller.flush();
|
|
3836
3981
|
}, [options.nodes, controller]);
|
|
3837
|
-
return (0,
|
|
3982
|
+
return (0, import_react31.useMemo)(
|
|
3838
3983
|
() => ({
|
|
3839
3984
|
...controller,
|
|
3840
3985
|
/** Drop marker of the active reorder drag (flow coordinates). */
|
|
@@ -3848,15 +3993,15 @@ function useCanvasAutoLayout(options) {
|
|
|
3848
3993
|
}
|
|
3849
3994
|
|
|
3850
3995
|
// src/canvas/useCanvasTokens.ts
|
|
3851
|
-
var
|
|
3996
|
+
var import_react32 = require("react");
|
|
3852
3997
|
var import_canvas19 = require("@pixerate/editor/canvas");
|
|
3853
3998
|
function useCanvasTokens(options) {
|
|
3854
3999
|
const { store, nodes, setNodes, modes, properties } = options;
|
|
3855
|
-
const state = (0,
|
|
3856
|
-
const latest = (0,
|
|
4000
|
+
const state = (0, import_react32.useSyncExternalStore)(store.subscribe, store.getState, store.getState);
|
|
4001
|
+
const latest = (0, import_react32.useRef)({ nodes, setNodes, modes, properties });
|
|
3857
4002
|
latest.current = { nodes, setNodes, modes, properties };
|
|
3858
4003
|
const opts = () => ({ modes: latest.current.modes, properties: latest.current.properties });
|
|
3859
|
-
(0,
|
|
4004
|
+
(0, import_react32.useEffect)(
|
|
3860
4005
|
() => store.subscribe((event) => {
|
|
3861
4006
|
if (event.deletedVariableIds.length === 0) return;
|
|
3862
4007
|
latest.current.setNodes((prev) => (0, import_canvas19.detachTokenBindings)(prev, event.previous, event.deletedVariableIds, opts()));
|
|
@@ -3865,11 +4010,11 @@ function useCanvasTokens(options) {
|
|
|
3865
4010
|
[store]
|
|
3866
4011
|
);
|
|
3867
4012
|
const modesKey = JSON.stringify(modes ?? {});
|
|
3868
|
-
(0,
|
|
4013
|
+
(0, import_react32.useEffect)(() => {
|
|
3869
4014
|
const next = (0, import_canvas19.resolveCanvasTokens)(nodes, state, opts());
|
|
3870
4015
|
if (next !== nodes) setNodes(next);
|
|
3871
4016
|
}, [nodes, state, modesKey, properties]);
|
|
3872
|
-
const bind = (0,
|
|
4017
|
+
const bind = (0, import_react32.useCallback)(
|
|
3873
4018
|
(ids, propertyKey, variableId) => {
|
|
3874
4019
|
const next = (0, import_canvas19.bindCanvasToken)(latest.current.nodes, ids, propertyKey, variableId, store.getState(), opts());
|
|
3875
4020
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
@@ -3877,7 +4022,7 @@ function useCanvasTokens(options) {
|
|
|
3877
4022
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3878
4023
|
[store]
|
|
3879
4024
|
);
|
|
3880
|
-
const setMode = (0,
|
|
4025
|
+
const setMode = (0, import_react32.useCallback)(
|
|
3881
4026
|
(ids, collectionId, modeId) => {
|
|
3882
4027
|
const next = (0, import_canvas19.setCanvasTokenMode)(latest.current.nodes, ids, collectionId, modeId, store.getState(), opts());
|
|
3883
4028
|
if (next !== latest.current.nodes) latest.current.setNodes(next);
|
|
@@ -3885,7 +4030,7 @@ function useCanvasTokens(options) {
|
|
|
3885
4030
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3886
4031
|
[store]
|
|
3887
4032
|
);
|
|
3888
|
-
const modesOf = (0,
|
|
4033
|
+
const modesOf = (0, import_react32.useCallback)(
|
|
3889
4034
|
(nodeId) => {
|
|
3890
4035
|
const node = latest.current.nodes.find((n) => n.id === nodeId);
|
|
3891
4036
|
return node ? (0, import_canvas19.getEffectiveTokenModes)(node, latest.current.nodes, store.getState(), opts()) : {};
|
|
@@ -3899,7 +4044,7 @@ function useCanvasTokens(options) {
|
|
|
3899
4044
|
// src/canvas/TokenBindingPicker.tsx
|
|
3900
4045
|
var import_canvas20 = require("@pixerate/editor/canvas");
|
|
3901
4046
|
var import_tokens = require("@pixerate/editor/tokens");
|
|
3902
|
-
var
|
|
4047
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3903
4048
|
function TokenBindingPicker({
|
|
3904
4049
|
state,
|
|
3905
4050
|
nodes,
|
|
@@ -3916,15 +4061,15 @@ function TokenBindingPicker({
|
|
|
3916
4061
|
let rows = (0, import_canvas20.getBindableTokenProperties)(first, options);
|
|
3917
4062
|
if (properties) rows = properties.map((key) => rows.find((p) => p.key === key)).filter((p) => !!p);
|
|
3918
4063
|
const modes = (0, import_canvas20.getEffectiveTokenModes)(first, nodes, state, options);
|
|
3919
|
-
return /* @__PURE__ */ (0,
|
|
4064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { "data-token-binding-picker": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
|
|
3920
4065
|
rows.map((property) => {
|
|
3921
4066
|
const ids = new Set(selected.map((n) => (0, import_canvas20.getNodeTokenBindings)(n)[property.key] ?? ""));
|
|
3922
4067
|
const value = ids.size === 1 ? [...ids][0] : "__mixed";
|
|
3923
4068
|
const candidates = (0, import_canvas20.getTokensForProperty)(state, property, first);
|
|
3924
4069
|
const resolved = value && value !== "__mixed" ? (0, import_tokens.resolveToken)(state, value, modes) : null;
|
|
3925
|
-
return /* @__PURE__ */ (0,
|
|
3926
|
-
/* @__PURE__ */ (0,
|
|
3927
|
-
/* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", "data-token-property": property.key, children: [
|
|
4071
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-28 shrink-0 text-muted-foreground", children: property.label }),
|
|
4072
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3928
4073
|
"select",
|
|
3929
4074
|
{
|
|
3930
4075
|
"aria-label": `${property.label} variable`,
|
|
@@ -3939,11 +4084,11 @@ function TokenBindingPicker({
|
|
|
3939
4084
|
}
|
|
3940
4085
|
},
|
|
3941
4086
|
children: [
|
|
3942
|
-
value === "__mixed" ? /* @__PURE__ */ (0,
|
|
3943
|
-
/* @__PURE__ */ (0,
|
|
4087
|
+
value === "__mixed" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "__mixed", children: "Mixed" }) : null,
|
|
4088
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: "", children: "None" }),
|
|
3944
4089
|
candidates.map((v) => {
|
|
3945
4090
|
const collection = state.collections.find((c) => c.id === v.collectionId);
|
|
3946
|
-
return /* @__PURE__ */ (0,
|
|
4091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("option", { value: v.id, children: [
|
|
3947
4092
|
v.name,
|
|
3948
4093
|
collection && state.collections.length > 1 ? ` (${collection.name})` : ""
|
|
3949
4094
|
] }, v.id);
|
|
@@ -3951,17 +4096,17 @@ function TokenBindingPicker({
|
|
|
3951
4096
|
]
|
|
3952
4097
|
}
|
|
3953
4098
|
),
|
|
3954
|
-
/* @__PURE__ */ (0,
|
|
4099
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-16 shrink-0 truncate text-right text-muted-foreground", "data-token-resolved": "", children: resolved?.ok ? property.type === "color" ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3955
4100
|
"span",
|
|
3956
4101
|
{
|
|
3957
4102
|
className: "inline-block h-3 w-3 rounded border border-border align-middle",
|
|
3958
4103
|
style: { background: String(resolved.value) },
|
|
3959
4104
|
title: String(resolved.value)
|
|
3960
4105
|
}
|
|
3961
|
-
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0,
|
|
4106
|
+
) : String(resolved.value) : resolved ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { title: resolved.message, children: "\u26A0" }) : null })
|
|
3962
4107
|
] }, property.key);
|
|
3963
4108
|
}),
|
|
3964
|
-
state.collections.length === 0 ? /* @__PURE__ */ (0,
|
|
4109
|
+
state.collections.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-muted-foreground", children: "No variables yet." }) : null
|
|
3965
4110
|
] });
|
|
3966
4111
|
}
|
|
3967
4112
|
function TokenModeSwitcher({
|
|
@@ -3979,12 +4124,12 @@ function TokenModeSwitcher({
|
|
|
3979
4124
|
const parent = first.parentId ? nodes.find((n) => n.id === first.parentId) : void 0;
|
|
3980
4125
|
const inherited = parent ? (0, import_canvas20.getEffectiveTokenModes)(parent, nodes, state, options) : { ...options.modes };
|
|
3981
4126
|
const collections = state.collections.filter((c) => showSingleMode || c.modes.length > 1);
|
|
3982
|
-
return /* @__PURE__ */ (0,
|
|
4127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { "data-token-mode-switcher": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: collections.map((collection) => {
|
|
3983
4128
|
const auto = (0, import_tokens.getCurrentMode)(collection, inherited);
|
|
3984
4129
|
const explicit = collection.modes.some((m) => m.id === own[collection.id]) ? own[collection.id] : "";
|
|
3985
|
-
return /* @__PURE__ */ (0,
|
|
3986
|
-
/* @__PURE__ */ (0,
|
|
3987
|
-
/* @__PURE__ */ (0,
|
|
4130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("label", { className: "flex items-center gap-2", "data-token-collection": collection.id, children: [
|
|
4131
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "w-28 shrink-0 truncate text-muted-foreground", children: collection.name }),
|
|
4132
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
3988
4133
|
"select",
|
|
3989
4134
|
{
|
|
3990
4135
|
"aria-label": `${collection.name} mode`,
|
|
@@ -3992,12 +4137,12 @@ function TokenModeSwitcher({
|
|
|
3992
4137
|
value: explicit,
|
|
3993
4138
|
onChange: (e) => onChange((0, import_canvas20.setCanvasTokenMode)(nodes, nodeIds, collection.id, e.currentTarget.value || null, state, options)),
|
|
3994
4139
|
children: [
|
|
3995
|
-
/* @__PURE__ */ (0,
|
|
4140
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("option", { value: "", children: [
|
|
3996
4141
|
"Auto (",
|
|
3997
4142
|
auto.name,
|
|
3998
4143
|
")"
|
|
3999
4144
|
] }),
|
|
4000
|
-
collection.modes.map((m) => /* @__PURE__ */ (0,
|
|
4145
|
+
collection.modes.map((m) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("option", { value: m.id, children: m.name }, m.id))
|
|
4001
4146
|
]
|
|
4002
4147
|
}
|
|
4003
4148
|
)
|
|
@@ -4009,14 +4154,14 @@ function TokenModeSwitcher({
|
|
|
4009
4154
|
var import_canvas36 = require("@pixerate/editor/canvas");
|
|
4010
4155
|
|
|
4011
4156
|
// src/canvas/useCanvasAnimation.ts
|
|
4012
|
-
var
|
|
4157
|
+
var import_react33 = require("react");
|
|
4013
4158
|
var import_canvas21 = require("@pixerate/editor/canvas");
|
|
4014
4159
|
function useCanvasAnimation(options) {
|
|
4015
|
-
const nodesRef = (0,
|
|
4160
|
+
const nodesRef = (0, import_react33.useRef)(options.nodes);
|
|
4016
4161
|
nodesRef.current = options.nodes;
|
|
4017
|
-
const optionsRef = (0,
|
|
4162
|
+
const optionsRef = (0, import_react33.useRef)(options);
|
|
4018
4163
|
optionsRef.current = options;
|
|
4019
|
-
const controller = (0,
|
|
4164
|
+
const controller = (0, import_react33.useMemo)(
|
|
4020
4165
|
() => (0, import_canvas21.createCanvasAnimationController)({
|
|
4021
4166
|
getNodes: () => nodesRef.current,
|
|
4022
4167
|
setNodes: (next) => {
|
|
@@ -4043,26 +4188,26 @@ function useCanvasAnimation(options) {
|
|
|
4043
4188
|
}),
|
|
4044
4189
|
[]
|
|
4045
4190
|
);
|
|
4046
|
-
(0,
|
|
4047
|
-
(0,
|
|
4191
|
+
(0, import_react33.useEffect)(() => () => controller.destroy(), [controller]);
|
|
4192
|
+
(0, import_react33.useEffect)(() => {
|
|
4048
4193
|
if (options.loop !== void 0) controller.setLoop(options.loop);
|
|
4049
4194
|
}, [controller, options.loop]);
|
|
4050
|
-
(0,
|
|
4195
|
+
(0, import_react33.useEffect)(() => {
|
|
4051
4196
|
if (options.playbackRate !== void 0) controller.setPlaybackRate(options.playbackRate);
|
|
4052
4197
|
}, [controller, options.playbackRate]);
|
|
4053
|
-
(0,
|
|
4198
|
+
(0, import_react33.useEffect)(() => {
|
|
4054
4199
|
if (options.recording !== void 0) controller.setRecording(options.recording);
|
|
4055
4200
|
}, [controller, options.recording]);
|
|
4056
|
-
const state = (0,
|
|
4201
|
+
const state = (0, import_react33.useSyncExternalStore)(
|
|
4057
4202
|
(listener) => controller.subscribe(listener),
|
|
4058
4203
|
() => controller.getState(),
|
|
4059
4204
|
() => controller.getState()
|
|
4060
4205
|
);
|
|
4061
|
-
(0,
|
|
4206
|
+
(0, import_react33.useEffect)(() => {
|
|
4062
4207
|
controller.refresh();
|
|
4063
4208
|
}, [controller, options.nodes]);
|
|
4064
|
-
const displayNodes = (0,
|
|
4065
|
-
return (0,
|
|
4209
|
+
const displayNodes = (0, import_react33.useMemo)(() => controller.display(options.nodes), [controller, options.nodes, state.time]);
|
|
4210
|
+
return (0, import_react33.useMemo)(
|
|
4066
4211
|
() => ({
|
|
4067
4212
|
...controller,
|
|
4068
4213
|
state,
|
|
@@ -4083,9 +4228,9 @@ function useCanvasAnimation(options) {
|
|
|
4083
4228
|
}
|
|
4084
4229
|
|
|
4085
4230
|
// src/canvas/AnimationTimeline.tsx
|
|
4086
|
-
var
|
|
4231
|
+
var import_react34 = require("react");
|
|
4087
4232
|
var import_canvas22 = require("@pixerate/editor/canvas");
|
|
4088
|
-
var
|
|
4233
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4089
4234
|
var LOOP_LABELS = { none: "Once", loop: "Loop", "ping-pong": "Ping-pong" };
|
|
4090
4235
|
var easingValue = (easing) => typeof easing === "string" ? easing : easing ? "custom" : "linear";
|
|
4091
4236
|
function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8, labelOf, className = "" }) {
|
|
@@ -4099,8 +4244,8 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4099
4244
|
for (const row of rows) for (const k of row.keyframes) if (k.selected && k.ref.property === first.property && k.ref.nodeId === first.nodeId) return easingValue(k.easing);
|
|
4100
4245
|
return "";
|
|
4101
4246
|
})();
|
|
4102
|
-
const dragRef = (0,
|
|
4103
|
-
(0,
|
|
4247
|
+
const dragRef = (0, import_react34.useRef)(null);
|
|
4248
|
+
(0, import_react34.useEffect)(() => {
|
|
4104
4249
|
const onKey = (event) => {
|
|
4105
4250
|
if (event.key === "Escape" && dragRef.current) {
|
|
4106
4251
|
dragRef.current = null;
|
|
@@ -4156,10 +4301,10 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4156
4301
|
const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-50";
|
|
4157
4302
|
const playheadX = (0, import_canvas22.timeToX)(state.time, duration, width);
|
|
4158
4303
|
const labelWidth = 120;
|
|
4159
|
-
return /* @__PURE__ */ (0,
|
|
4160
|
-
/* @__PURE__ */ (0,
|
|
4161
|
-
/* @__PURE__ */ (0,
|
|
4162
|
-
/* @__PURE__ */ (0,
|
|
4304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-animation-timeline": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, tabIndex: 0, onKeyDown: onTimelineKey, children: [
|
|
4305
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-2", role: "toolbar", "aria-label": "Animation", children: [
|
|
4306
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "toggle-play", "aria-label": state.playing ? "Pause" : "Play", onClick: () => animation.toggle(), children: state.playing ? "\u275A\u275A" : "\u25B6" }),
|
|
4307
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4163
4308
|
"button",
|
|
4164
4309
|
{
|
|
4165
4310
|
type: "button",
|
|
@@ -4171,13 +4316,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4171
4316
|
children: "\u25CF Rec"
|
|
4172
4317
|
}
|
|
4173
4318
|
),
|
|
4174
|
-
/* @__PURE__ */ (0,
|
|
4175
|
-
/* @__PURE__ */ (0,
|
|
4319
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: btn2, "data-action": "add-keyframe", onClick: () => animation.addKeyframe(), children: "\u25C6 Key" }),
|
|
4320
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { "data-time": "", className: "tabular-nums text-muted-foreground", children: [
|
|
4176
4321
|
(0, import_canvas22.formatAnimationTime)(state.time),
|
|
4177
4322
|
" / ",
|
|
4178
4323
|
(0, import_canvas22.formatAnimationTime)(duration)
|
|
4179
4324
|
] }),
|
|
4180
|
-
/* @__PURE__ */ (0,
|
|
4325
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
4181
4326
|
"select",
|
|
4182
4327
|
{
|
|
4183
4328
|
"aria-label": "Easing",
|
|
@@ -4187,13 +4332,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4187
4332
|
disabled: state.selection.length === 0,
|
|
4188
4333
|
onChange: (e) => e.target.value && e.target.value !== "custom" && animation.setEasing(e.target.value),
|
|
4189
4334
|
children: [
|
|
4190
|
-
/* @__PURE__ */ (0,
|
|
4191
|
-
import_canvas22.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0,
|
|
4192
|
-
selectedEasing === "custom" ? /* @__PURE__ */ (0,
|
|
4335
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "", children: "Easing\u2026" }),
|
|
4336
|
+
import_canvas22.ANIMATION_EASING_PRESETS.map((preset) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: preset, children: import_canvas22.ANIMATION_EASING_LABELS[preset] }, preset)),
|
|
4337
|
+
selectedEasing === "custom" ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: "custom", children: "Custom" }) : null
|
|
4193
4338
|
]
|
|
4194
4339
|
}
|
|
4195
4340
|
),
|
|
4196
|
-
/* @__PURE__ */ (0,
|
|
4341
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4197
4342
|
"select",
|
|
4198
4343
|
{
|
|
4199
4344
|
"aria-label": "Loop",
|
|
@@ -4201,13 +4346,13 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4201
4346
|
className: "rounded border border-border bg-background px-1 py-0.5",
|
|
4202
4347
|
value: state.loop,
|
|
4203
4348
|
onChange: (e) => animation.setLoop(e.target.value),
|
|
4204
|
-
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0,
|
|
4349
|
+
children: Object.keys(LOOP_LABELS).map((mode) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("option", { value: mode, children: LOOP_LABELS[mode] }, mode))
|
|
4205
4350
|
}
|
|
4206
4351
|
)
|
|
4207
4352
|
] }),
|
|
4208
|
-
/* @__PURE__ */ (0,
|
|
4209
|
-
/* @__PURE__ */ (0,
|
|
4210
|
-
/* @__PURE__ */ (0,
|
|
4353
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex", children: [
|
|
4354
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: { width: labelWidth }, className: "shrink-0" }),
|
|
4355
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
4211
4356
|
"div",
|
|
4212
4357
|
{
|
|
4213
4358
|
"data-timeline-ruler": "",
|
|
@@ -4215,15 +4360,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4215
4360
|
style: { width },
|
|
4216
4361
|
onPointerDown: onRulerDown,
|
|
4217
4362
|
children: [
|
|
4218
|
-
ticks.map((tick) => /* @__PURE__ */ (0,
|
|
4219
|
-
/* @__PURE__ */ (0,
|
|
4363
|
+
ticks.map((tick) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "absolute top-0 -translate-x-1/2 text-[10px] text-muted-foreground", style: { left: tick.x }, children: tick.label }, tick.time)),
|
|
4364
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-playhead": "", className: "absolute top-0 h-5 w-px bg-red-500", style: { left: playheadX } })
|
|
4220
4365
|
]
|
|
4221
4366
|
}
|
|
4222
4367
|
)
|
|
4223
4368
|
] }),
|
|
4224
|
-
rows.length === 0 ? /* @__PURE__ */ (0,
|
|
4225
|
-
/* @__PURE__ */ (0,
|
|
4226
|
-
/* @__PURE__ */ (0,
|
|
4369
|
+
rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-muted-foreground", "data-timeline-empty": "", children: "Select an animated node, or press \u25C6 Key to add a keyframe." }) : rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex items-center", "data-track": row.id, children: [
|
|
4370
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("label", { className: "flex shrink-0 items-center gap-1 truncate pr-2", style: { width: labelWidth }, title: `${row.nodeLabel} \xB7 ${row.label}`, children: [
|
|
4371
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4227
4372
|
"input",
|
|
4228
4373
|
{
|
|
4229
4374
|
type: "checkbox",
|
|
@@ -4232,15 +4377,15 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4232
4377
|
onChange: (e) => animation.setTrackEnabled(row.nodeId, row.property, e.target.checked)
|
|
4233
4378
|
}
|
|
4234
4379
|
),
|
|
4235
|
-
/* @__PURE__ */ (0,
|
|
4380
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "truncate", children: [
|
|
4236
4381
|
rows.filter((r) => r.nodeId === row.nodeId).length < rows.length ? `${row.nodeLabel} \xB7 ` : "",
|
|
4237
4382
|
row.label
|
|
4238
4383
|
] })
|
|
4239
4384
|
] }),
|
|
4240
|
-
/* @__PURE__ */ (0,
|
|
4241
|
-
/* @__PURE__ */ (0,
|
|
4242
|
-
state.drag?.target != null ? /* @__PURE__ */ (0,
|
|
4243
|
-
row.keyframes.map((k) => /* @__PURE__ */ (0,
|
|
4385
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { "data-lane": "", className: `relative h-5 rounded bg-muted/40 ${row.enabled ? "" : "opacity-50"}`, style: { width }, children: [
|
|
4386
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "pointer-events-none absolute top-0 h-5 w-px bg-red-500/60", style: { left: playheadX } }),
|
|
4387
|
+
state.drag?.target != null ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-snap-target": "", className: "pointer-events-none absolute top-0 h-5 w-px bg-sky-400", style: { left: (0, import_canvas22.timeToX)(state.drag.target, duration, width) } }) : null,
|
|
4388
|
+
row.keyframes.map((k) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4244
4389
|
"button",
|
|
4245
4390
|
{
|
|
4246
4391
|
type: "button",
|
|
@@ -4263,14 +4408,14 @@ function AnimationTimeline({ animation, nodeIds, width = 360, snapThreshold = 8,
|
|
|
4263
4408
|
var import_canvas37 = require("@pixerate/editor/canvas");
|
|
4264
4409
|
|
|
4265
4410
|
// src/canvas/useCanvasComponents.ts
|
|
4266
|
-
var
|
|
4411
|
+
var import_react35 = require("react");
|
|
4267
4412
|
var import_canvas23 = require("@pixerate/editor/canvas");
|
|
4268
4413
|
function useCanvasComponents(options) {
|
|
4269
|
-
const nodesRef = (0,
|
|
4414
|
+
const nodesRef = (0, import_react35.useRef)(options.nodes);
|
|
4270
4415
|
nodesRef.current = options.nodes;
|
|
4271
|
-
const optionsRef = (0,
|
|
4416
|
+
const optionsRef = (0, import_react35.useRef)(options);
|
|
4272
4417
|
optionsRef.current = options;
|
|
4273
|
-
const controller = (0,
|
|
4418
|
+
const controller = (0, import_react35.useMemo)(
|
|
4274
4419
|
() => (0, import_canvas23.createCanvasComponentsController)({
|
|
4275
4420
|
getNodes: () => nodesRef.current,
|
|
4276
4421
|
setNodes: (next) => {
|
|
@@ -4299,18 +4444,18 @@ function useCanvasComponents(options) {
|
|
|
4299
4444
|
}),
|
|
4300
4445
|
[]
|
|
4301
4446
|
);
|
|
4302
|
-
(0,
|
|
4447
|
+
(0, import_react35.useLayoutEffect)(() => {
|
|
4303
4448
|
if (optionsRef.current.autoSync !== false) controller.sync();
|
|
4304
4449
|
}, [options.nodes, controller]);
|
|
4305
4450
|
return controller;
|
|
4306
4451
|
}
|
|
4307
4452
|
|
|
4308
4453
|
// src/canvas/CanvasComponentsPanel.tsx
|
|
4309
|
-
var
|
|
4454
|
+
var import_react36 = require("react");
|
|
4310
4455
|
var import_canvas24 = require("@pixerate/editor/canvas");
|
|
4311
|
-
var
|
|
4456
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4312
4457
|
function InlineField({ value, label, onCommit }) {
|
|
4313
|
-
return /* @__PURE__ */ (0,
|
|
4458
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4314
4459
|
"input",
|
|
4315
4460
|
{
|
|
4316
4461
|
type: "text",
|
|
@@ -4341,10 +4486,10 @@ function CanvasComponentsPanel({
|
|
|
4341
4486
|
search = true,
|
|
4342
4487
|
className = ""
|
|
4343
4488
|
}) {
|
|
4344
|
-
const [query, setQuery] = (0,
|
|
4345
|
-
const [propsOpen, setPropsOpen] = (0,
|
|
4346
|
-
const [menuFor, setMenuFor] = (0,
|
|
4347
|
-
const [editing, setEditing] = (0,
|
|
4489
|
+
const [query, setQuery] = (0, import_react36.useState)("");
|
|
4490
|
+
const [propsOpen, setPropsOpen] = (0, import_react36.useState)(null);
|
|
4491
|
+
const [menuFor, setMenuFor] = (0, import_react36.useState)(null);
|
|
4492
|
+
const [editing, setEditing] = (0, import_react36.useState)(null);
|
|
4348
4493
|
const { components: all, sets } = (0, import_canvas24.listCanvasComponents)(nodes);
|
|
4349
4494
|
const q = query.trim().toLowerCase();
|
|
4350
4495
|
const match = (name) => !q || name.toLowerCase().includes(q);
|
|
@@ -4356,7 +4501,7 @@ function CanvasComponentsPanel({
|
|
|
4356
4501
|
};
|
|
4357
4502
|
const small = "shrink-0 rounded px-1 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40";
|
|
4358
4503
|
const menuItem = "rounded px-2 py-0.5 text-left hover:bg-muted disabled:opacity-40";
|
|
4359
|
-
const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0,
|
|
4504
|
+
const item = (id, name, count, extra = {}, onContextMenu) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4360
4505
|
"button",
|
|
4361
4506
|
{
|
|
4362
4507
|
type: "button",
|
|
@@ -4373,17 +4518,17 @@ function CanvasComponentsPanel({
|
|
|
4373
4518
|
e.dataTransfer.effectAllowed = "copy";
|
|
4374
4519
|
},
|
|
4375
4520
|
children: [
|
|
4376
|
-
/* @__PURE__ */ (0,
|
|
4377
|
-
/* @__PURE__ */ (0,
|
|
4521
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "truncate", children: [
|
|
4522
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "aria-hidden": true, className: "mr-1 text-muted-foreground", children: "\u25C7" }),
|
|
4378
4523
|
name
|
|
4379
4524
|
] }),
|
|
4380
|
-
/* @__PURE__ */ (0,
|
|
4525
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-[10px] text-muted-foreground", "data-instance-count": "", children: count })
|
|
4381
4526
|
]
|
|
4382
4527
|
},
|
|
4383
4528
|
id
|
|
4384
4529
|
);
|
|
4385
|
-
return /* @__PURE__ */ (0,
|
|
4386
|
-
search ? /* @__PURE__ */ (0,
|
|
4530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-components-panel": "", className: `flex flex-col gap-1 text-xs text-foreground ${className}`, children: [
|
|
4531
|
+
search ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4387
4532
|
"input",
|
|
4388
4533
|
{
|
|
4389
4534
|
type: "search",
|
|
@@ -4393,11 +4538,11 @@ function CanvasComponentsPanel({
|
|
|
4393
4538
|
onInput: (e) => setQuery(e.target.value)
|
|
4394
4539
|
}
|
|
4395
4540
|
) : null,
|
|
4396
|
-
shownSets.map((set) => /* @__PURE__ */ (0,
|
|
4397
|
-
/* @__PURE__ */ (0,
|
|
4541
|
+
shownSets.map((set) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-component-set": set.id, className: "flex flex-col", children: [
|
|
4542
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4398
4543
|
item(set.id, set.name, set.variants.reduce((sum, v) => sum + v.instanceCount, 0), { "data-kind": "set" }),
|
|
4399
|
-
components ? /* @__PURE__ */ (0,
|
|
4400
|
-
/* @__PURE__ */ (0,
|
|
4544
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
4545
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4401
4546
|
"button",
|
|
4402
4547
|
{
|
|
4403
4548
|
type: "button",
|
|
@@ -4409,7 +4554,7 @@ function CanvasComponentsPanel({
|
|
|
4409
4554
|
children: "+\xA0Variant"
|
|
4410
4555
|
}
|
|
4411
4556
|
),
|
|
4412
|
-
/* @__PURE__ */ (0,
|
|
4557
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4413
4558
|
"button",
|
|
4414
4559
|
{
|
|
4415
4560
|
type: "button",
|
|
@@ -4424,8 +4569,8 @@ function CanvasComponentsPanel({
|
|
|
4424
4569
|
)
|
|
4425
4570
|
] }) : null
|
|
4426
4571
|
] }),
|
|
4427
|
-
components && propsOpen === set.id ? /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4572
|
+
components && propsOpen === set.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "data-variant-properties": set.id, className: "ml-3 flex flex-col gap-1 border-l border-border py-1 pl-2", children: set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-variant-option": option.name, className: "flex flex-col gap-0.5", children: [
|
|
4573
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4429
4574
|
InlineField,
|
|
4430
4575
|
{
|
|
4431
4576
|
value: option.name,
|
|
@@ -4433,7 +4578,7 @@ function CanvasComponentsPanel({
|
|
|
4433
4578
|
onCommit: (next) => report(components.renameVariantProperty(option.name, next, set.id))
|
|
4434
4579
|
}
|
|
4435
4580
|
),
|
|
4436
|
-
/* @__PURE__ */ (0,
|
|
4581
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "ml-2 flex flex-wrap gap-1", children: option.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4437
4582
|
InlineField,
|
|
4438
4583
|
{
|
|
4439
4584
|
value,
|
|
@@ -4443,8 +4588,8 @@ function CanvasComponentsPanel({
|
|
|
4443
4588
|
value
|
|
4444
4589
|
)) })
|
|
4445
4590
|
] }, option.name)) }) : null,
|
|
4446
|
-
/* @__PURE__ */ (0,
|
|
4447
|
-
/* @__PURE__ */ (0,
|
|
4591
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "ml-3 flex flex-col border-l border-border pl-1", children: set.variants.map((v) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-variant-row": v.id, className: "flex flex-col", children: [
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
4448
4593
|
item(
|
|
4449
4594
|
v.id,
|
|
4450
4595
|
v.name,
|
|
@@ -4455,7 +4600,7 @@ function CanvasComponentsPanel({
|
|
|
4455
4600
|
setMenuFor(v.id);
|
|
4456
4601
|
} : void 0
|
|
4457
4602
|
),
|
|
4458
|
-
components ? /* @__PURE__ */ (0,
|
|
4603
|
+
components ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4459
4604
|
"button",
|
|
4460
4605
|
{
|
|
4461
4606
|
type: "button",
|
|
@@ -4469,8 +4614,8 @@ function CanvasComponentsPanel({
|
|
|
4469
4614
|
}
|
|
4470
4615
|
) : null
|
|
4471
4616
|
] }),
|
|
4472
|
-
components && menuFor === v.id ? /* @__PURE__ */ (0,
|
|
4473
|
-
/* @__PURE__ */ (0,
|
|
4617
|
+
components && menuFor === v.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { role: "menu", "data-variant-menu": v.id, className: "ml-2 flex flex-col rounded border border-border bg-background p-1 shadow", children: [
|
|
4618
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4474
4619
|
"button",
|
|
4475
4620
|
{
|
|
4476
4621
|
type: "button",
|
|
@@ -4484,7 +4629,7 @@ function CanvasComponentsPanel({
|
|
|
4484
4629
|
children: "Edit values\u2026"
|
|
4485
4630
|
}
|
|
4486
4631
|
),
|
|
4487
|
-
/* @__PURE__ */ (0,
|
|
4632
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4488
4633
|
"button",
|
|
4489
4634
|
{
|
|
4490
4635
|
type: "button",
|
|
@@ -4498,7 +4643,7 @@ function CanvasComponentsPanel({
|
|
|
4498
4643
|
children: "Duplicate"
|
|
4499
4644
|
}
|
|
4500
4645
|
),
|
|
4501
|
-
/* @__PURE__ */ (0,
|
|
4646
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4502
4647
|
"button",
|
|
4503
4648
|
{
|
|
4504
4649
|
type: "button",
|
|
@@ -4515,7 +4660,7 @@ function CanvasComponentsPanel({
|
|
|
4515
4660
|
}
|
|
4516
4661
|
)
|
|
4517
4662
|
] }) : null,
|
|
4518
|
-
components && editing === v.id ? /* @__PURE__ */ (0,
|
|
4663
|
+
components && editing === v.id ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4519
4664
|
"form",
|
|
4520
4665
|
{
|
|
4521
4666
|
"data-variant-editor": v.id,
|
|
@@ -4529,9 +4674,9 @@ function CanvasComponentsPanel({
|
|
|
4529
4674
|
if (report(components.setVariantProperties(values, v.id))) setEditing(null);
|
|
4530
4675
|
},
|
|
4531
4676
|
children: [
|
|
4532
|
-
set.options.map((option) => /* @__PURE__ */ (0,
|
|
4533
|
-
/* @__PURE__ */ (0,
|
|
4534
|
-
/* @__PURE__ */ (0,
|
|
4677
|
+
set.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
4678
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-16 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
4679
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4535
4680
|
"input",
|
|
4536
4681
|
{
|
|
4537
4682
|
type: "text",
|
|
@@ -4542,9 +4687,9 @@ function CanvasComponentsPanel({
|
|
|
4542
4687
|
}
|
|
4543
4688
|
)
|
|
4544
4689
|
] }, option.name)),
|
|
4545
|
-
/* @__PURE__ */ (0,
|
|
4546
|
-
/* @__PURE__ */ (0,
|
|
4547
|
-
/* @__PURE__ */ (0,
|
|
4690
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-1", children: [
|
|
4691
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "submit", className: "rounded border border-border px-2 py-0.5 hover:bg-muted", "data-action": "save-variant", children: "Save" }),
|
|
4692
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: "rounded px-2 py-0.5 hover:bg-muted", "data-action": "cancel-variant", onClick: () => setEditing(null), children: "Cancel" })
|
|
4548
4693
|
] })
|
|
4549
4694
|
]
|
|
4550
4695
|
}
|
|
@@ -4552,7 +4697,7 @@ function CanvasComponentsPanel({
|
|
|
4552
4697
|
] }, v.id)) })
|
|
4553
4698
|
] }, set.id)),
|
|
4554
4699
|
lone.map((c) => item(c.id, c.name, c.instanceCount, { "data-kind": "component" })),
|
|
4555
|
-
all.length === 0 ? /* @__PURE__ */ (0,
|
|
4700
|
+
all.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "text-muted-foreground", children: "No components yet. Select a frame and choose Create Component." }) : null
|
|
4556
4701
|
] });
|
|
4557
4702
|
}
|
|
4558
4703
|
function CanvasInstanceInspector({
|
|
@@ -4571,27 +4716,27 @@ function CanvasInstanceInspector({
|
|
|
4571
4716
|
const allComponents = (0, import_canvas24.listCanvasComponents)(nodes).components;
|
|
4572
4717
|
const linked = info.status === "linked";
|
|
4573
4718
|
const btn2 = "rounded border border-border px-2 py-0.5 text-xs hover:bg-muted disabled:opacity-40";
|
|
4574
|
-
return /* @__PURE__ */ (0,
|
|
4575
|
-
/* @__PURE__ */ (0,
|
|
4576
|
-
/* @__PURE__ */ (0,
|
|
4577
|
-
info.nested ? /* @__PURE__ */ (0,
|
|
4719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { "data-instance-inspector": "", "data-instance-id": info.id, className: `flex flex-col gap-2 text-xs text-foreground ${className}`, children: [
|
|
4720
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
4721
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "truncate font-medium", "data-instance-main": "", children: linked ? info.componentName : "Main component missing" }),
|
|
4722
|
+
info.nested ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-muted-foreground", children: "Nested" }) : null
|
|
4578
4723
|
] }),
|
|
4579
|
-
info.variantOptions.map((option) => /* @__PURE__ */ (0,
|
|
4580
|
-
/* @__PURE__ */ (0,
|
|
4581
|
-
/* @__PURE__ */ (0,
|
|
4724
|
+
info.variantOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", "data-variant-property": option.name, children: [
|
|
4725
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: option.name }),
|
|
4726
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4582
4727
|
"select",
|
|
4583
4728
|
{
|
|
4584
4729
|
"aria-label": `${option.name} variant`,
|
|
4585
4730
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
4586
4731
|
value: info.variant[option.name] ?? "",
|
|
4587
4732
|
onChange: (e) => setProp(option.name, e.currentTarget.value),
|
|
4588
|
-
children: option.values.map((v) => /* @__PURE__ */ (0,
|
|
4733
|
+
children: option.values.map((v) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: v, children: v }, v))
|
|
4589
4734
|
}
|
|
4590
4735
|
)
|
|
4591
4736
|
] }, option.name)),
|
|
4592
|
-
info.properties.map((p) => /* @__PURE__ */ (0,
|
|
4593
|
-
/* @__PURE__ */ (0,
|
|
4594
|
-
p.type === "boolean" ? /* @__PURE__ */ (0,
|
|
4737
|
+
info.properties.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "flex items-center gap-2", "data-component-property": p.name, children: [
|
|
4738
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "w-24 shrink-0 truncate text-muted-foreground", children: p.name }),
|
|
4739
|
+
p.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("input", { type: "checkbox", "aria-label": p.name, checked: p.value === true, onChange: (e) => setProp(p.name, e.currentTarget.checked) }) : p.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4595
4740
|
"input",
|
|
4596
4741
|
{
|
|
4597
4742
|
type: "text",
|
|
@@ -4606,22 +4751,22 @@ function CanvasInstanceInspector({
|
|
|
4606
4751
|
}
|
|
4607
4752
|
},
|
|
4608
4753
|
String(p.value)
|
|
4609
|
-
) : /* @__PURE__ */ (0,
|
|
4754
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4610
4755
|
"select",
|
|
4611
4756
|
{
|
|
4612
4757
|
"aria-label": p.name,
|
|
4613
4758
|
className: "min-w-0 flex-1 rounded border border-border bg-background px-1 py-0.5 text-xs",
|
|
4614
4759
|
value: String(p.value),
|
|
4615
4760
|
onChange: (e) => setProp(p.name, e.currentTarget.value),
|
|
4616
|
-
children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0,
|
|
4761
|
+
children: allComponents.filter((c) => !p.preferred?.length || p.preferred.includes(c.id) || c.id === p.value).map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("option", { value: c.id, children: c.name }, c.id))
|
|
4617
4762
|
}
|
|
4618
4763
|
)
|
|
4619
4764
|
] }, p.name)),
|
|
4620
|
-
info.overrides.length ? /* @__PURE__ */ (0,
|
|
4621
|
-
/* @__PURE__ */ (0,
|
|
4622
|
-
info.overrides.map((o) => /* @__PURE__ */ (0,
|
|
4623
|
-
/* @__PURE__ */ (0,
|
|
4624
|
-
o.groups.map((g) => /* @__PURE__ */ (0,
|
|
4765
|
+
info.overrides.length ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-1", "data-instance-overrides": "", children: [
|
|
4766
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-muted-foreground", children: "Overrides" }),
|
|
4767
|
+
info.overrides.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap items-center gap-1", "data-override-layer": o.id, children: [
|
|
4768
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "mr-1 truncate", children: o.name }),
|
|
4769
|
+
o.groups.map((g) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4625
4770
|
"button",
|
|
4626
4771
|
{
|
|
4627
4772
|
type: "button",
|
|
@@ -4638,11 +4783,11 @@ function CanvasInstanceInspector({
|
|
|
4638
4783
|
))
|
|
4639
4784
|
] }, o.id))
|
|
4640
4785
|
] }) : null,
|
|
4641
|
-
/* @__PURE__ */ (0,
|
|
4642
|
-
linked ? /* @__PURE__ */ (0,
|
|
4643
|
-
/* @__PURE__ */ (0,
|
|
4644
|
-
/* @__PURE__ */ (0,
|
|
4645
|
-
/* @__PURE__ */ (0,
|
|
4786
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-wrap gap-1", children: [
|
|
4787
|
+
linked ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
|
|
4788
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "reset", onClick: () => report(components.resetOverrides(info.id)), children: "Reset all" }),
|
|
4789
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "go-to-main", onClick: () => components.goToMainComponent(info.id), children: "Go to main" }),
|
|
4790
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4646
4791
|
"button",
|
|
4647
4792
|
{
|
|
4648
4793
|
type: "button",
|
|
@@ -4653,8 +4798,8 @@ function CanvasInstanceInspector({
|
|
|
4653
4798
|
children: "Push changes"
|
|
4654
4799
|
}
|
|
4655
4800
|
)
|
|
4656
|
-
] }) : /* @__PURE__ */ (0,
|
|
4657
|
-
/* @__PURE__ */ (0,
|
|
4801
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", className: btn2, "data-action": "restore", onClick: () => report(components.restoreMainComponent(info.rootId)), children: "Restore main component" }),
|
|
4802
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4658
4803
|
"button",
|
|
4659
4804
|
{
|
|
4660
4805
|
type: "button",
|
|
@@ -4674,9 +4819,9 @@ function CanvasInstanceInspector({
|
|
|
4674
4819
|
var import_canvas38 = require("@pixerate/editor/canvas");
|
|
4675
4820
|
|
|
4676
4821
|
// src/canvas/MermaidFamilyScene.tsx
|
|
4677
|
-
var
|
|
4822
|
+
var import_react37 = require("react");
|
|
4678
4823
|
var import_canvas25 = require("@pixerate/editor/canvas");
|
|
4679
|
-
var
|
|
4824
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4680
4825
|
function MermaidFamilyScene({
|
|
4681
4826
|
scene,
|
|
4682
4827
|
padding = 16,
|
|
@@ -4689,7 +4834,7 @@ function MermaidFamilyScene({
|
|
|
4689
4834
|
style,
|
|
4690
4835
|
title
|
|
4691
4836
|
}) {
|
|
4692
|
-
const uid = (0,
|
|
4837
|
+
const uid = (0, import_react37.useId)().replace(/:/g, "");
|
|
4693
4838
|
const marker = (kind) => kind ? `url(#${uid}-${kind})` : void 0;
|
|
4694
4839
|
const x = scene.x - padding;
|
|
4695
4840
|
const y = scene.y - padding;
|
|
@@ -4707,7 +4852,7 @@ function MermaidFamilyScene({
|
|
|
4707
4852
|
cursor: "pointer"
|
|
4708
4853
|
} : { pointerEvents: "none" };
|
|
4709
4854
|
const stroke = (mark) => mark.selected ? { stroke: selectionColor, strokeWidth: Math.max(2, mark.strokeWidth ?? 0) } : { stroke: mark.stroke, strokeWidth: mark.strokeWidth };
|
|
4710
|
-
return /* @__PURE__ */ (0,
|
|
4855
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
4711
4856
|
"svg",
|
|
4712
4857
|
{
|
|
4713
4858
|
className: `pixerate-diagram-scene ${className}`.trim(),
|
|
@@ -4720,15 +4865,15 @@ function MermaidFamilyScene({
|
|
|
4720
4865
|
style: { display: "block", maxWidth: "100%", height: "auto", overflow: "visible", ...style },
|
|
4721
4866
|
onClick: interactive ? (event) => onSelect?.(null, event) : void 0,
|
|
4722
4867
|
children: [
|
|
4723
|
-
/* @__PURE__ */ (0,
|
|
4724
|
-
/* @__PURE__ */ (0,
|
|
4725
|
-
/* @__PURE__ */ (0,
|
|
4868
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("defs", { children: [
|
|
4869
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("marker", { id: `${uid}-arrowclosed`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M0,0 L10,5 L0,10 Z", style: { fill: markerColor } }) }),
|
|
4870
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("marker", { id: `${uid}-arrow`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "8", markerHeight: "8", orient: "auto-start-reverse", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M0,0 L10,5 L0,10", style: { fill: "none", stroke: markerColor, strokeWidth: 1.5 } }) })
|
|
4726
4871
|
] }),
|
|
4727
4872
|
scene.marks.map((mark) => {
|
|
4728
4873
|
const common = { "data-role": mark.role, "data-target": mark.target, "data-selected": mark.selected ? "" : void 0, opacity: mark.opacity, ...handlers(mark) };
|
|
4729
4874
|
switch (mark.kind) {
|
|
4730
4875
|
case "rect":
|
|
4731
|
-
return /* @__PURE__ */ (0,
|
|
4876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4732
4877
|
"rect",
|
|
4733
4878
|
{
|
|
4734
4879
|
...common,
|
|
@@ -4743,9 +4888,9 @@ function MermaidFamilyScene({
|
|
|
4743
4888
|
mark.key
|
|
4744
4889
|
);
|
|
4745
4890
|
case "circle":
|
|
4746
|
-
return /* @__PURE__ */ (0,
|
|
4891
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { ...common, cx: mark.cx, cy: mark.cy, r: mark.r, style: { fill: mark.fill, ...stroke(mark) } }, mark.key);
|
|
4747
4892
|
case "line":
|
|
4748
|
-
return /* @__PURE__ */ (0,
|
|
4893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4749
4894
|
"line",
|
|
4750
4895
|
{
|
|
4751
4896
|
...common,
|
|
@@ -4761,7 +4906,7 @@ function MermaidFamilyScene({
|
|
|
4761
4906
|
mark.key
|
|
4762
4907
|
);
|
|
4763
4908
|
case "path":
|
|
4764
|
-
return /* @__PURE__ */ (0,
|
|
4909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4765
4910
|
"path",
|
|
4766
4911
|
{
|
|
4767
4912
|
...common,
|
|
@@ -4775,7 +4920,7 @@ function MermaidFamilyScene({
|
|
|
4775
4920
|
mark.key
|
|
4776
4921
|
);
|
|
4777
4922
|
case "text":
|
|
4778
|
-
return /* @__PURE__ */ (0,
|
|
4923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4779
4924
|
"text",
|
|
4780
4925
|
{
|
|
4781
4926
|
...common,
|
|
@@ -4803,14 +4948,14 @@ function MermaidFamilyScene({
|
|
|
4803
4948
|
}
|
|
4804
4949
|
|
|
4805
4950
|
// src/canvas/useMermaidDiagram.ts
|
|
4806
|
-
var
|
|
4951
|
+
var import_react38 = require("react");
|
|
4807
4952
|
var import_diagram = require("@pixerate/editor/diagram");
|
|
4808
4953
|
var import_canvas26 = require("@pixerate/editor/canvas");
|
|
4809
4954
|
function useDiagramState(controller) {
|
|
4810
|
-
return (0,
|
|
4955
|
+
return (0, import_react38.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
4811
4956
|
}
|
|
4812
4957
|
function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
4813
|
-
const own = (0,
|
|
4958
|
+
const own = (0, import_react38.useRef)(null);
|
|
4814
4959
|
let controller;
|
|
4815
4960
|
if (controllerOrOptions instanceof import_diagram.DiagramController) controller = controllerOrOptions;
|
|
4816
4961
|
else {
|
|
@@ -4820,21 +4965,21 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
4820
4965
|
const layoutOptions = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.layoutOptions) ?? view.layoutOptions;
|
|
4821
4966
|
const sceneTheme = (controllerOrOptions instanceof import_diagram.DiagramController ? void 0 : controllerOrOptions.sceneTheme) ?? view.sceneTheme;
|
|
4822
4967
|
const state = useDiagramState(controller);
|
|
4823
|
-
const editorDocument = (0,
|
|
4824
|
-
(0,
|
|
4825
|
-
const canvas = (0,
|
|
4968
|
+
const editorDocument = (0, import_react38.useMemo)(() => (0, import_diagram.createDiagramEditorDocument)(controller), [controller]);
|
|
4969
|
+
(0, import_react38.useEffect)(() => () => editorDocument.destroy(), [editorDocument]);
|
|
4970
|
+
const canvas = (0, import_react38.useMemo)(
|
|
4826
4971
|
() => (0, import_canvas26.mermaidToCanvas)(state.document, { ...layoutOptions, editable: state.editable }),
|
|
4827
4972
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4828
4973
|
[state.document, state.editable]
|
|
4829
4974
|
);
|
|
4830
|
-
const scene = (0,
|
|
4975
|
+
const scene = (0, import_react38.useMemo)(
|
|
4831
4976
|
() => state.document.tier === "editable" ? (0, import_canvas26.familySceneFromLayout)(state.document.family, state.document.graph, canvas.layout, { theme: { ...import_canvas26.CSS_VARIABLE_DIAGRAM_SCENE_THEME, ...sceneTheme }, selection: state.selection }) : null,
|
|
4832
4977
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4833
4978
|
[state.document, canvas.layout, state.selection]
|
|
4834
4979
|
);
|
|
4835
|
-
const layoutRef = (0,
|
|
4980
|
+
const layoutRef = (0, import_react38.useRef)(canvas.layout);
|
|
4836
4981
|
layoutRef.current = canvas.layout;
|
|
4837
|
-
const actions = (0,
|
|
4982
|
+
const actions = (0, import_react38.useMemo)(
|
|
4838
4983
|
() => ({
|
|
4839
4984
|
apply: (ops, label) => controller.apply(ops, label),
|
|
4840
4985
|
load: (source, options) => controller.load(source, options),
|
|
@@ -4871,13 +5016,13 @@ function useMermaidDiagram(controllerOrOptions = {}, view = {}) {
|
|
|
4871
5016
|
}
|
|
4872
5017
|
function useMermaidStream(source, options = {}) {
|
|
4873
5018
|
const { complete = false, duration = 300, ...layoutOptions } = options;
|
|
4874
|
-
const stream = (0,
|
|
5019
|
+
const stream = (0, import_react38.useRef)(null);
|
|
4875
5020
|
if (!stream.current) stream.current = new import_canvas26.DiagramStream(layoutOptions);
|
|
4876
|
-
const result = (0,
|
|
4877
|
-
const [shown, setShown] = (0,
|
|
4878
|
-
const shownRef = (0,
|
|
5021
|
+
const result = (0, import_react38.useMemo)(() => stream.current.update(source, complete), [source, complete]);
|
|
5022
|
+
const [shown, setShown] = (0, import_react38.useState)({ layout: result.layout, settled: true });
|
|
5023
|
+
const shownRef = (0, import_react38.useRef)(shown.layout);
|
|
4879
5024
|
shownRef.current = shown.layout;
|
|
4880
|
-
(0,
|
|
5025
|
+
(0, import_react38.useEffect)(() => {
|
|
4881
5026
|
const target = result.layout;
|
|
4882
5027
|
if (!target) return setShown({ layout: null, settled: true });
|
|
4883
5028
|
const from = shownRef.current;
|
|
@@ -4894,7 +5039,7 @@ function useMermaidStream(source, options = {}) {
|
|
|
4894
5039
|
return () => cancelAnimationFrame(frame);
|
|
4895
5040
|
}, [result.layout, duration]);
|
|
4896
5041
|
const doc = result.document.tier === "editable" ? result.document : null;
|
|
4897
|
-
const canvas = (0,
|
|
5042
|
+
const canvas = (0, import_react38.useMemo)(() => {
|
|
4898
5043
|
if (!doc || !shown.layout) return { nodes: [], edges: [] };
|
|
4899
5044
|
const placed = new Set(Object.keys(shown.layout.positions));
|
|
4900
5045
|
const graph = {
|
|
@@ -4910,7 +5055,7 @@ function useMermaidStream(source, options = {}) {
|
|
|
4910
5055
|
|
|
4911
5056
|
// src/canvas/MermaidDiagramNode.tsx
|
|
4912
5057
|
var import_canvas27 = require("@pixerate/editor/canvas");
|
|
4913
|
-
var
|
|
5058
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4914
5059
|
function mermaidNodeStyle(styles = {}, selected = false) {
|
|
4915
5060
|
const paint = (0, import_canvas27.mermaidNodePaint)(styles, selected);
|
|
4916
5061
|
const { color, "stroke-width": strokeWidth, "stroke-dasharray": strokeDasharray, ...vars } = paint;
|
|
@@ -4920,7 +5065,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
4920
5065
|
const node = data.node;
|
|
4921
5066
|
if (!node) return null;
|
|
4922
5067
|
const members = (0, import_canvas27.mermaidNodeMembers)(node.data);
|
|
4923
|
-
return /* @__PURE__ */ (0,
|
|
5068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
4924
5069
|
"div",
|
|
4925
5070
|
{
|
|
4926
5071
|
className: `pixerate-diagram-node ${className}`.trim(),
|
|
@@ -4928,14 +5073,14 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
4928
5073
|
"data-selected": selected ? "true" : void 0,
|
|
4929
5074
|
style: { position: "relative", width: "100%", height: "100%", ...mermaidNodeStyle(data.resolvedStyles, selected) },
|
|
4930
5075
|
children: [
|
|
4931
|
-
/* @__PURE__ */ (0,
|
|
4932
|
-
/* @__PURE__ */ (0,
|
|
5076
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("svg", { viewBox: `0 0 ${width} ${height}`, preserveAspectRatio: "none", width: "100%", height: "100%", style: { position: "absolute", inset: 0, overflow: "visible" }, "aria-hidden": "true", children: (0, import_canvas27.mermaidShapePaths)(node.shape, width, height).map((path, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: path.d, style: { ...import_canvas27.MERMAID_SHAPE_PAINT[path.paint], vectorEffect: "non-scaling-stroke" } }, i)) }),
|
|
5077
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
4933
5078
|
"div",
|
|
4934
5079
|
{
|
|
4935
5080
|
style: { position: "relative", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: members.length ? "flex-start" : "center", height: "100%", padding: "6px 10px", boxSizing: "border-box", fontSize: 13, lineHeight: 1.3, textAlign: "center", pointerEvents: "none" },
|
|
4936
5081
|
children: [
|
|
4937
|
-
(0, import_canvas27.mermaidLabelLines)(node.label).map((line, i) => /* @__PURE__ */ (0,
|
|
4938
|
-
members.length > 0 && /* @__PURE__ */ (0,
|
|
5082
|
+
(0, import_canvas27.mermaidLabelLines)(node.label).map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { style: { fontWeight: members.length ? 600 : void 0 }, children: line }, i)),
|
|
5083
|
+
members.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { alignSelf: "stretch", marginTop: 4, paddingTop: 4, borderTop: "1px solid var(--pixerate-diagram-node-border)", textAlign: "left", fontSize: 12 }, children: members.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { children: m }, i)) })
|
|
4939
5084
|
]
|
|
4940
5085
|
}
|
|
4941
5086
|
),
|
|
@@ -4947,7 +5092,7 @@ function MermaidDiagramNode({ data, width = 160, height = 56, selected, classNam
|
|
|
4947
5092
|
function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
4948
5093
|
const group = data.group;
|
|
4949
5094
|
if (!group) return null;
|
|
4950
|
-
return /* @__PURE__ */ (0,
|
|
5095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
4951
5096
|
"div",
|
|
4952
5097
|
{
|
|
4953
5098
|
className: `pixerate-diagram-group ${className}`.trim(),
|
|
@@ -4962,7 +5107,7 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
4962
5107
|
color: data.resolvedStyles?.color ?? "var(--muted-foreground, #475569)"
|
|
4963
5108
|
},
|
|
4964
5109
|
children: [
|
|
4965
|
-
/* @__PURE__ */ (0,
|
|
5110
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { padding: "6px 10px", fontSize: 12, fontWeight: 600 }, children: (0, import_canvas27.mermaidLabelLines)(group.label).join(" ") }),
|
|
4966
5111
|
children
|
|
4967
5112
|
]
|
|
4968
5113
|
}
|
|
@@ -4970,29 +5115,29 @@ function MermaidDiagramGroup({ data, selected, className = "", children }) {
|
|
|
4970
5115
|
}
|
|
4971
5116
|
|
|
4972
5117
|
// src/canvas/MermaidThumbnail.tsx
|
|
4973
|
-
var
|
|
5118
|
+
var import_react39 = require("react");
|
|
4974
5119
|
var import_diagram2 = require("@pixerate/editor/diagram");
|
|
4975
5120
|
var import_canvas28 = require("@pixerate/editor/canvas");
|
|
4976
|
-
var
|
|
5121
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
4977
5122
|
function MermaidThumbnail({ source, className = "", fallback = null, ...options }) {
|
|
4978
|
-
const doc = (0,
|
|
5123
|
+
const doc = (0, import_react39.useMemo)(() => typeof source === "string" ? (0, import_diagram2.parseMermaid)(source) : source, [source]);
|
|
4979
5124
|
const key = JSON.stringify(options);
|
|
4980
|
-
const drawn = (0,
|
|
5125
|
+
const drawn = (0, import_react39.useMemo)(
|
|
4981
5126
|
() => doc.tier === "editable" && doc.graph.nodes.length ? (0, import_canvas28.mermaidThumbnailSvg)(doc, options) : null,
|
|
4982
5127
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4983
5128
|
[doc, key]
|
|
4984
5129
|
);
|
|
4985
|
-
if (!drawn) return /* @__PURE__ */ (0,
|
|
4986
|
-
return /* @__PURE__ */ (0,
|
|
5130
|
+
if (!drawn) return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: fallback });
|
|
5131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: `pixerate-diagram-thumbnail ${className}`.trim(), style: { display: "inline-block", lineHeight: 0 }, dangerouslySetInnerHTML: { __html: drawn.svg } });
|
|
4987
5132
|
}
|
|
4988
5133
|
|
|
4989
5134
|
// src/canvas/useDiagramDirector.ts
|
|
4990
|
-
var
|
|
5135
|
+
var import_react40 = require("react");
|
|
4991
5136
|
var import_diagram3 = require("@pixerate/editor/diagram");
|
|
4992
5137
|
function useDiagramDirector(controller, options) {
|
|
4993
|
-
const placement = (0,
|
|
5138
|
+
const placement = (0, import_react40.useRef)(options.placement);
|
|
4994
5139
|
placement.current = options.placement;
|
|
4995
|
-
const ref = (0,
|
|
5140
|
+
const ref = (0, import_react40.useRef)(null);
|
|
4996
5141
|
if (!ref.current) {
|
|
4997
5142
|
const presence = new import_diagram3.PresenceStore();
|
|
4998
5143
|
ref.current = {
|
|
@@ -5003,17 +5148,17 @@ function useDiagramDirector(controller, options) {
|
|
|
5003
5148
|
return ref.current;
|
|
5004
5149
|
}
|
|
5005
5150
|
function usePresenceState(presence) {
|
|
5006
|
-
return (0,
|
|
5151
|
+
return (0, import_react40.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
5007
5152
|
}
|
|
5008
5153
|
|
|
5009
5154
|
// src/canvas/DiagramPresenceLayer.tsx
|
|
5010
|
-
var
|
|
5155
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5011
5156
|
function DiagramPresenceLayer({ presence, viewport, className = "" }) {
|
|
5012
5157
|
const { actors } = usePresenceState(presence);
|
|
5013
5158
|
if (!actors.length) return null;
|
|
5014
|
-
return /* @__PURE__ */ (0,
|
|
5015
|
-
/* @__PURE__ */ (0,
|
|
5016
|
-
/* @__PURE__ */ (0,
|
|
5159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: `pixerate-diagram-presence ${className}`.trim(), "aria-hidden": "true", style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 }, children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${a.x * viewport.zoom + viewport.x}px, ${a.y * viewport.zoom + viewport.y}px)` }, children: [
|
|
5160
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0" }, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
5161
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { style: { position: "absolute", left: 14, top: 16, whiteSpace: "nowrap", borderRadius: 4, padding: "1px 6px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.message ?? a.name })
|
|
5017
5162
|
] }, a.id)) });
|
|
5018
5163
|
}
|
|
5019
5164
|
// Annotate the CommonJS export names for ESM import in node:
|