@spiffcommerce/core 0.2.0 → 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,13 +1,15 @@
1
- import { AnyStepData, Step, Asset, AssetType, IServerModel, MaterialResource, VariantResource, Workflow, CameraAnimation, ModelAnimation, OptionResource, StepType, TextStepData } from "papyrus/build/main/generation/Workflow";
2
- import { PatternImageData, ScaleAxis, UnitOfMeasurement } from "papyrus/build/main/types";
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, 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
+ import { ApolloClient } from "@apollo/client";
4
5
  import { ModuleProduct } from "papyrus/build/main/module/ModuleProduct";
5
6
  import { CanvasCommand, CreateElementCommand, FontAlignmentCommand, FontColorCommand, TextChangeCommand } from "papyrus/build/main/command";
6
7
  import { CommandState, CommandContext as _CommandContext1, LayoutData as _LayoutData1, CommandContext, LayoutData } from "papyrus/build/main/CommandContext";
7
- import { Dispatch, FunctionComponent, ReactNode, MouseEvent, PointerEvent } from "react";
8
+ import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
8
9
  import { ThreeDPreviewService as _ThreeDPreviewService1, SpiffCommerce3DPreviewService } from "spiff-preview";
9
10
  import { LayoutElementFactory } from "papyrus/build/main/Elements/factory";
10
- interface WorkflowScene {
11
+ export const gatherVaryingStepAspects: (workflow: Workflow) => StepAspect[];
12
+ export interface WorkflowScene {
11
13
  name: string;
12
14
  title: string;
13
15
  renderableSteps: Step<AnyStepData>[];
@@ -97,12 +99,27 @@ declare class Poller {
97
99
  */
98
100
  constructor(predicate: () => Promise<boolean>, onSuccess: () => void, onFailure: () => void, interval?: number, maxAttempts?: number);
99
101
  }
102
+ export const generate: () => string;
103
+ declare class Configuration {
104
+ constructor();
105
+ getServerUrl(): string;
106
+ getServicesApiUrl(): string;
107
+ setServerUrl(serverUrl: string): void;
108
+ setServicesApiUrl(servicesApiUrl: string): void;
109
+ addServerUrlCallback(callback: () => void): void;
110
+ }
111
+ export const spiffCoreConfiguration: Configuration;
100
112
  declare class SwaggerServer implements ServerService {
101
113
  constructor();
102
114
  setUncachedOperations(operationIds: string[]): void;
103
115
  execute(operationName: string, parameters?: object): Promise<ServerResponse>;
104
116
  }
105
117
  export const server: SwaggerServer;
118
+ declare class GraphQlManager {
119
+ constructor();
120
+ getShadowGraphqlClient(): ApolloClient<any>;
121
+ }
122
+ export const graphQlManager: GraphQlManager;
106
123
  declare class AssetService {
107
124
  constructor();
108
125
  /**
@@ -143,10 +160,10 @@ type StepMetadata = FrameMetadata | IllustrationMetadata | ModuleMetadata | Text
143
160
  interface WorkflowStorage {
144
161
  [stepName: string]: StepStorage;
145
162
  }
146
- interface WorkflowMetadata {
163
+ export interface WorkflowMetadata {
147
164
  [stepName: string]: StepMetadata;
148
165
  }
149
- interface WorkflowSelections {
166
+ export interface WorkflowSelections {
150
167
  [stepName: string]: {
151
168
  groupName?: string;
152
169
  optionName: string;
@@ -189,7 +206,7 @@ type StorageCallback = (storage: WorkflowStorage) => void;
189
206
  type UpdateCallback = (isUpdating: boolean) => void;
190
207
  type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
191
208
  type VariationRecordsCallback = (records: VariationRecord[]) => void;
192
- interface WorkflowManager {
209
+ export interface WorkflowManager {
193
210
  addPoller: (poller: Poller) => void;
194
211
  addConfirmCallback: (callback: ConfirmCallback) => void;
195
212
  addCurrentVariationCallback: (callback: CurrentVariationRecordCallback) => void;
@@ -287,7 +304,7 @@ export interface DesignCreationMessage {
287
304
  /**
288
305
  * Represents a transaction.
289
306
  */
290
- interface Transaction {
307
+ export interface Transaction {
291
308
  id: string;
292
309
  bulk?: boolean;
293
310
  /**
@@ -459,7 +476,7 @@ interface Product {
459
476
  * Represents a variation as seen in Google sheets.
460
477
  * Record number = row# - 1
461
478
  */
462
- interface VariationRecord {
479
+ export interface VariationRecord {
463
480
  recordNumber: number;
464
481
  transactionId: string;
465
482
  values: {
@@ -881,6 +898,16 @@ export const useLayouts: () => {
881
898
  export type CommandDispatcher = (command: CanvasCommand) => void;
882
899
  export type LayoutGetter = (layoutId: string) => _LayoutData1;
883
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
+ }
884
911
  enum ElementEventType {
885
912
  Translate = "Translate",
886
913
  Rotate = "Rotate",
@@ -1004,6 +1031,53 @@ export const useEditorState: () => {
1004
1031
  uiDispatcher: Dispatch<UICommand>;
1005
1032
  state: AdvancedEditorState;
1006
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
+ }>;
1007
1081
  /**
1008
1082
  * The advanced editor encapsulates the logic required to allow users to manipulate a design
1009
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.0",
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",