@parhelia/alpaca 0.1.12927 → 0.1.12931

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.
@@ -1 +1 @@
1
- {"version":3,"file":"GraphQL.d.ts","sourceRoot":"","sources":["../src/GraphQL.tsx"],"names":[],"mappings":"AA4BA,wBAAgB,OAAO,mDAsRtB"}
1
+ {"version":3,"file":"GraphQL.d.ts","sourceRoot":"","sources":["../src/GraphQL.tsx"],"names":[],"mappings":"AA6BA,wBAAgB,OAAO,mDAsRtB"}
package/dist/GraphQL.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useState } from "react";
3
- import { ActionButton, createAgentCommand, getComponentById, ParheliaAgentIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useEditContext, } from "@parhelia/core";
3
+ import { ActionButton, createAgentCommand, getComponentById, ParheliaAgentIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, useCanvasSelection, useEditContext, } from "@parhelia/core";
4
4
  import { getGraphQLSchema } from "./graphqlService";
5
5
  import { GraphiQLPanel } from "./GraphiQLPanel";
6
6
  function sameItem(left, right) {
@@ -12,8 +12,9 @@ function sameItem(left, right) {
12
12
  }
13
13
  export function GraphQL() {
14
14
  const editContext = useEditContext();
15
+ const canvasSelection = useCanvasSelection();
15
16
  const pageItem = editContext?.page?.item ?? editContext?.item;
16
- const selectionKey = editContext?.selection?.join("|") || "";
17
+ const selectionKey = canvasSelection.join("|");
17
18
  const [query, setQuery] = useState("");
18
19
  const [schemaResult, setSchemaResult] = useState({});
19
20
  const [showSchemaSpinner, setShowSchemaSpinner] = useState(false);
@@ -22,10 +23,11 @@ export function GraphQL() {
22
23
  const [graphiqlVariables, setGraphiqlVariables] = useState("{}");
23
24
  const [baseItem, setBaseItem] = useState(null);
24
25
  const selectedComponent = useMemo(() => {
25
- if (!editContext?.page || (editContext.selection?.length || 0) !== 1) {
26
+ if (!editContext?.page || canvasSelection.length !== 1) {
26
27
  return null;
27
28
  }
28
- return (getComponentById(editContext.selection[0], editContext.page) || null);
29
+ return getComponentById(canvasSelection[0], editContext.page) || null;
30
+ // eslint-disable-next-line react-hooks/exhaustive-deps
29
31
  }, [editContext?.page, selectionKey]);
30
32
  const baseItemDescriptor = useMemo(() => {
31
33
  const componentItem = selectedComponent?.datasourceItem || selectedComponent?.items?.[0];
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":"AAYA,wBAAgB,MAAM,mDA6GrB"}
1
+ {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":"AAaA,wBAAgB,MAAM,mDA8GrB"}
package/dist/Layout.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { ObjectInspector, ObjectLabel, ObjectRootLabel } from "react-inspector";
4
- import { CopyButton, getComponentByIdFromHeadlessLayout, SimpleTabs, useEditContext, usePageViewContext, } from "@parhelia/core";
4
+ import { CopyButton, getComponentByIdFromHeadlessLayout, SimpleTabs, useCanvasSelection, useEditContext, usePageViewContext, } from "@parhelia/core";
5
5
  import { getPageJson } from "./services";
6
6
  export function Layout() {
7
7
  const [activeTab, setActiveTab] = useState(0);
8
8
  const [pageLayout, setPageLayout] = useState(null);
9
9
  const editContext = useEditContext();
10
+ const canvasSelection = useCanvasSelection();
10
11
  if (!editContext)
11
12
  return null;
12
13
  usePageViewContext({
@@ -26,7 +27,7 @@ export function Layout() {
26
27
  const page = pageLayout;
27
28
  let component = null;
28
29
  if (page) {
29
- const selectedComponents = editContext.selection
30
+ const selectedComponents = canvasSelection
30
31
  .map((x) => getComponentByIdFromHeadlessLayout(x, page))
31
32
  .filter((x) => x);
32
33
  component = selectedComponents.length === 1 ? selectedComponents[0] : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parhelia/alpaca",
3
- "version": "0.1.12927",
3
+ "version": "0.1.12931",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"