@pixerate/editor-react 0.131.0 → 0.132.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.
@@ -2742,12 +2742,13 @@ var SelectionOptionsBar = ({
2742
2742
  const [subjectStatus, setSubjectStatus] = useState11(null);
2743
2743
  const selectSubject = async () => {
2744
2744
  const target = subject.trim();
2745
- if (!target || segmenting) return;
2745
+ const canSegment = Boolean(controller.segmentationProvider);
2746
+ if (canSegment && !target || segmenting) return;
2746
2747
  setSegmenting(true);
2747
2748
  setSubjectStatus(null);
2748
2749
  try {
2749
- const { segments } = await controller.selectSubject(target, { mode: options.mode });
2750
- setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
2750
+ const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
2751
+ setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
2751
2752
  } catch (err) {
2752
2753
  setSubjectStatus(err instanceof Error ? err.message : String(err));
2753
2754
  } finally {
@@ -2975,7 +2976,7 @@ var SelectionOptionsBar = ({
2975
2976
  ),
2976
2977
  "px"
2977
2978
  ] }),
2978
- controller.segmentationProvider && /* @__PURE__ */ jsxs13(
2979
+ /* @__PURE__ */ jsxs13(
2979
2980
  "form",
2980
2981
  {
2981
2982
  "data-testid": "select-subject",
@@ -2986,7 +2987,7 @@ var SelectionOptionsBar = ({
2986
2987
  },
2987
2988
  children: [
2988
2989
  /* @__PURE__ */ jsxs13("div", { className: "flex gap-1", children: [
2989
- /* @__PURE__ */ jsx15(
2990
+ controller.segmentationProvider && /* @__PURE__ */ jsx15(
2990
2991
  "input",
2991
2992
  {
2992
2993
  type: "text",
@@ -2998,7 +2999,17 @@ var SelectionOptionsBar = ({
2998
2999
  className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
2999
3000
  }
3000
3001
  ),
3001
- /* @__PURE__ */ jsx15("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
3002
+ /* @__PURE__ */ jsx15(
3003
+ "button",
3004
+ {
3005
+ type: "submit",
3006
+ className: btn(false),
3007
+ disabled: segmenting || Boolean(controller.segmentationProvider) && !subject.trim(),
3008
+ "aria-busy": segmenting,
3009
+ title: controller.segmentationProvider ? void 0 : "Selects the subject that stands out most (no segmentation model is set)",
3010
+ children: segmenting ? "Selecting\u2026" : "Select Subject"
3011
+ }
3012
+ )
3002
3013
  ] }),
3003
3014
  subjectStatus && /* @__PURE__ */ jsx15("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
3004
3015
  ]
@@ -4673,12 +4673,13 @@ var SelectionOptionsBar = ({
4673
4673
  const [subjectStatus, setSubjectStatus] = (0, import_react25.useState)(null);
4674
4674
  const selectSubject = async () => {
4675
4675
  const target = subject.trim();
4676
- if (!target || segmenting) return;
4676
+ const canSegment = Boolean(controller.segmentationProvider);
4677
+ if (canSegment && !target || segmenting) return;
4677
4678
  setSegmenting(true);
4678
4679
  setSubjectStatus(null);
4679
4680
  try {
4680
- const { segments } = await controller.selectSubject(target, { mode: options.mode });
4681
- setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
4681
+ const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
4682
+ setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
4682
4683
  } catch (err) {
4683
4684
  setSubjectStatus(err instanceof Error ? err.message : String(err));
4684
4685
  } finally {
@@ -4906,7 +4907,7 @@ var SelectionOptionsBar = ({
4906
4907
  ),
4907
4908
  "px"
4908
4909
  ] }),
4909
- controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4910
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4910
4911
  "form",
4911
4912
  {
4912
4913
  "data-testid": "select-subject",
@@ -4917,7 +4918,7 @@ var SelectionOptionsBar = ({
4917
4918
  },
4918
4919
  children: [
4919
4920
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex gap-1", children: [
4920
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4921
+ controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4921
4922
  "input",
4922
4923
  {
4923
4924
  type: "text",
@@ -4929,7 +4930,17 @@ var SelectionOptionsBar = ({
4929
4930
  className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
4930
4931
  }
4931
4932
  ),
4932
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
4933
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4934
+ "button",
4935
+ {
4936
+ type: "submit",
4937
+ className: btn(false),
4938
+ disabled: segmenting || Boolean(controller.segmentationProvider) && !subject.trim(),
4939
+ "aria-busy": segmenting,
4940
+ title: controller.segmentationProvider ? void 0 : "Selects the subject that stands out most (no segmentation model is set)",
4941
+ children: segmenting ? "Selecting\u2026" : "Select Subject"
4942
+ }
4943
+ )
4933
4944
  ] }),
4934
4945
  subjectStatus && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
4935
4946
  ]
@@ -27,7 +27,7 @@ import {
27
27
  useImageEditorControls,
28
28
  useImageEffectsTools,
29
29
  useImageHistogram
30
- } from "../chunk-6TDQ5DIO.js";
30
+ } from "../chunk-EPI76PX5.js";
31
31
  import "../chunk-AJCWF6SN.js";
32
32
  import "../chunk-6BWTJ3EE.js";
33
33
  import "../chunk-5RPB4WGT.js";
package/dist/index.cjs CHANGED
@@ -8387,12 +8387,13 @@ var SelectionOptionsBar = ({
8387
8387
  const [subjectStatus, setSubjectStatus] = (0, import_react61.useState)(null);
8388
8388
  const selectSubject = async () => {
8389
8389
  const target = subject.trim();
8390
- if (!target || segmenting) return;
8390
+ const canSegment = Boolean(controller.segmentationProvider);
8391
+ if (canSegment && !target || segmenting) return;
8391
8392
  setSegmenting(true);
8392
8393
  setSubjectStatus(null);
8393
8394
  try {
8394
- const { segments } = await controller.selectSubject(target, { mode: options.mode });
8395
- setSubjectStatus(segments.length ? null : `Nothing matching \u201C${target}\u201D was found.`);
8395
+ const { segments, method, note } = await controller.selectSubject(canSegment ? target : "", { mode: options.mode });
8396
+ setSubjectStatus(segments.length ? null : method === "saliency" ? note ?? "Nothing stands out from the background." : `Nothing matching \u201C${target}\u201D was found.`);
8396
8397
  } catch (err) {
8397
8398
  setSubjectStatus(err instanceof Error ? err.message : String(err));
8398
8399
  } finally {
@@ -8620,7 +8621,7 @@ var SelectionOptionsBar = ({
8620
8621
  ),
8621
8622
  "px"
8622
8623
  ] }),
8623
- controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
8624
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
8624
8625
  "form",
8625
8626
  {
8626
8627
  "data-testid": "select-subject",
@@ -8631,7 +8632,7 @@ var SelectionOptionsBar = ({
8631
8632
  },
8632
8633
  children: [
8633
8634
  /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex gap-1", children: [
8634
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8635
+ controller.segmentationProvider && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8635
8636
  "input",
8636
8637
  {
8637
8638
  type: "text",
@@ -8643,7 +8644,17 @@ var SelectionOptionsBar = ({
8643
8644
  className: "min-w-0 flex-1 bg-background border border-border rounded px-2 py-1 text-foreground"
8644
8645
  }
8645
8646
  ),
8646
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("button", { type: "submit", className: btn(false), disabled: segmenting || !subject.trim(), "aria-busy": segmenting, children: segmenting ? "Selecting\u2026" : "Select Subject" })
8647
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
8648
+ "button",
8649
+ {
8650
+ type: "submit",
8651
+ className: btn(false),
8652
+ disabled: segmenting || Boolean(controller.segmentationProvider) && !subject.trim(),
8653
+ "aria-busy": segmenting,
8654
+ title: controller.segmentationProvider ? void 0 : "Selects the subject that stands out most (no segmentation model is set)",
8655
+ children: segmenting ? "Selecting\u2026" : "Select Subject"
8656
+ }
8657
+ )
8647
8658
  ] }),
8648
8659
  subjectStatus && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { role: "status", className: "text-muted-foreground", children: subjectStatus })
8649
8660
  ]
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ import {
51
51
  useImageEditorControls,
52
52
  useImageEffectsTools,
53
53
  useImageHistogram
54
- } from "./chunk-6TDQ5DIO.js";
54
+ } from "./chunk-EPI76PX5.js";
55
55
  import "./chunk-AJCWF6SN.js";
56
56
  import "./chunk-6BWTJ3EE.js";
57
57
  import "./chunk-5RPB4WGT.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.131.0",
3
+ "version": "0.132.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -254,7 +254,7 @@
254
254
  "dependencies": {},
255
255
  "peerDependencies": {
256
256
  "@dagrejs/dagre": "^1.1.8",
257
- "@pixerate/editor": ">=0.198.0 <1.0.0-0",
257
+ "@pixerate/editor": ">=0.199.0 <1.0.0-0",
258
258
  "@tiptap/core": "^2.27.3",
259
259
  "@tiptap/extension-bubble-menu": "^2.27.3",
260
260
  "@tiptap/extension-placeholder": "^2.27.3",
@@ -305,7 +305,7 @@
305
305
  "tsup": "^9.0.0",
306
306
  "typescript": "^5.7.3",
307
307
  "vitest": "^5.0.5",
308
- "@pixerate/editor": "0.198.0"
308
+ "@pixerate/editor": "0.199.0"
309
309
  },
310
310
  "scripts": {
311
311
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",