@spiffcommerce/core 0.2.1 → 0.2.2

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/types.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { StepAspect, Workflow, AnyStepData, Step, Asset, AssetType, IServerModel, MaterialResource, VariantResource, CameraAnimation, ModelAnimation, OptionResource, StepType, TextStepData } from "papyrus/build/main/generation/Workflow";
2
- import { PatternImageData, ScaleAxis, UnitOfMeasurement } from "papyrus/build/main/types";
2
+ import { PatternImageData, Point, ScaleAxis, UnitOfMeasurement } from "papyrus/build/main/types";
3
3
  import { FrameOffsets, ILayout, SerializableStep, StepStorage, Region, LayoutsState as _LayoutsState1, LayoutElement, LayoutsState, TextboxElement, ImageElement } from "papyrus/build/main/LayoutsState/types";
4
4
  import { ApolloClient } from "@apollo/client";
5
5
  import { ModuleProduct } from "papyrus/build/main/module/ModuleProduct";
6
6
  import { CanvasCommand, CreateElementCommand, FontAlignmentCommand, FontColorCommand, TextChangeCommand } from "papyrus/build/main/command";
7
7
  import { CommandState, CommandContext as _CommandContext1, LayoutData as _LayoutData1, CommandContext, LayoutData } from "papyrus/build/main/CommandContext";
8
- import { Dispatch, FunctionComponent, ReactNode, MouseEvent, PointerEvent } from "react";
8
+ import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
9
9
  import { ThreeDPreviewService as _ThreeDPreviewService1, SpiffCommerce3DPreviewService } from "spiff-preview";
10
10
  import { LayoutElementFactory } from "papyrus/build/main/Elements/factory";
11
11
  export const gatherVaryingStepAspects: (workflow: Workflow) => StepAspect[];
12
- interface WorkflowScene {
12
+ export interface WorkflowScene {
13
13
  name: string;
14
14
  title: string;
15
15
  renderableSteps: Step<AnyStepData>[];
@@ -898,6 +898,16 @@ export const useLayouts: () => {
898
898
  export type CommandDispatcher = (command: CanvasCommand) => void;
899
899
  export type LayoutGetter = (layoutId: string) => _LayoutData1;
900
900
  export type LayoutsGetter = () => _LayoutData1[];
901
+ /**
902
+ * Details about a guideline that can be drawn on the canvas.
903
+ */
904
+ interface SnapPoint {
905
+ type: "x" | "y" | "rotation";
906
+ value: number;
907
+ svgNode?: ReactNode;
908
+ anchorPoint: number;
909
+ guidelineCoordinates?: Point[];
910
+ }
901
911
  enum ElementEventType {
902
912
  Translate = "Translate",
903
913
  Rotate = "Rotate",
@@ -1021,6 +1031,53 @@ export const useEditorState: () => {
1021
1031
  uiDispatcher: Dispatch<UICommand>;
1022
1032
  state: AdvancedEditorState;
1023
1033
  };
1034
+ /**
1035
+ * The minimum zoom that can be applied to a canvas.
1036
+ */
1037
+ export const minZoom = 0.5;
1038
+ export const useEditorInteraction: (editorRef: RefObject<SVGRectElement>, interactionRef: RefObject<HTMLDivElement>, zoomableElementRef: RefObject<HTMLDivElement>, defaultAdjustmentZoom: number | undefined, mode: "adjustment" | "advanced", canvasDispatcher: CommandDispatcher, guidelinePrimaryColor?: string) => {
1039
+ guidelines: SnapPoint[];
1040
+ scale: number;
1041
+ zoomableElementRef: RefObject<HTMLDivElement>;
1042
+ setElementEvent: (newEvent: ElementEvent | undefined) => void;
1043
+ handleZoom: (_event: any, value: any) => void;
1044
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1045
+ handleKeyUp: (event: KeyboardEvent) => void;
1046
+ handlePointerPressedBackground: () => void;
1047
+ handlePointerReleased: () => void;
1048
+ handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
1049
+ handleScroll: () => void;
1050
+ handleSequenceStart: () => void;
1051
+ };
1052
+ export const EditorCore: FunctionComponent<{
1053
+ color?: string;
1054
+ editorRef: RefObject<SVGRectElement>;
1055
+ zoomableElementRef: RefObject<HTMLDivElement>;
1056
+ interactionElementRef: RefObject<HTMLDivElement>;
1057
+ guidelines: SnapPoint[];
1058
+ isMakingAdjustments?: boolean;
1059
+ viewmask?: {
1060
+ x: number;
1061
+ y: number;
1062
+ height: number;
1063
+ width: number;
1064
+ };
1065
+ visibleLayoutId: string;
1066
+ xTranslation: number;
1067
+ yTranslation: number;
1068
+ targetedElements?: string[];
1069
+ borderRadius?: number;
1070
+ handleContextMenu?: (e: any) => void;
1071
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1072
+ handleKeyUp: (event: KeyboardEvent) => void;
1073
+ handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
1074
+ handlePointerPressedBackground: () => void;
1075
+ handlePointerReleased: () => void;
1076
+ handleScroll: () => void;
1077
+ onSequenceStart: () => void;
1078
+ setElementEvent: (e: ElementEvent | undefined) => void;
1079
+ onElementSelected: (elementId: string | undefined, event: PointerEvent) => void;
1080
+ }>;
1024
1081
  /**
1025
1082
  * The advanced editor encapsulates the logic required to allow users to manipulate a design
1026
1083
  * with more granular control such as toolbars, direct element manipulation, and more.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",