@spiffcommerce/core 0.2.1 → 0.2.3
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/main.js +9 -9
- package/dist/module.js +9 -9
- package/dist/types.d.ts +72 -5
- package/package.json +1 -1
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,
|
|
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>[];
|
|
@@ -144,6 +144,16 @@ declare class AssetService {
|
|
|
144
144
|
loadImageAsFileInfo: (file: File) => Promise<FileInfo>;
|
|
145
145
|
}
|
|
146
146
|
export const assetService: AssetService;
|
|
147
|
+
type ToastCallback = (callbackOptions: {
|
|
148
|
+
toastMessage: null | string;
|
|
149
|
+
toastType: InformationMessageType | null;
|
|
150
|
+
}) => void;
|
|
151
|
+
declare class Toast {
|
|
152
|
+
constructor();
|
|
153
|
+
addToastCallback(callback: ToastCallback): void;
|
|
154
|
+
setLatestToast(errorMessage: null | string, errorType: InformationMessageType | null): void;
|
|
155
|
+
}
|
|
156
|
+
export const toast: Toast;
|
|
147
157
|
interface EditedSteps {
|
|
148
158
|
[stepName: string]: boolean;
|
|
149
159
|
}
|
|
@@ -170,12 +180,12 @@ export interface WorkflowSelections {
|
|
|
170
180
|
selections: VariantResource[];
|
|
171
181
|
};
|
|
172
182
|
}
|
|
173
|
-
interface InformationResult {
|
|
183
|
+
export interface InformationResult {
|
|
174
184
|
message: string;
|
|
175
185
|
messageType: InformationMessageType;
|
|
176
186
|
stepID: string;
|
|
177
187
|
}
|
|
178
|
-
enum InformationMessageType {
|
|
188
|
+
export enum InformationMessageType {
|
|
179
189
|
Error = "Error",
|
|
180
190
|
Warning = "Warning"
|
|
181
191
|
}
|
|
@@ -898,6 +908,16 @@ export const useLayouts: () => {
|
|
|
898
908
|
export type CommandDispatcher = (command: CanvasCommand) => void;
|
|
899
909
|
export type LayoutGetter = (layoutId: string) => _LayoutData1;
|
|
900
910
|
export type LayoutsGetter = () => _LayoutData1[];
|
|
911
|
+
/**
|
|
912
|
+
* Details about a guideline that can be drawn on the canvas.
|
|
913
|
+
*/
|
|
914
|
+
interface SnapPoint {
|
|
915
|
+
type: "x" | "y" | "rotation";
|
|
916
|
+
value: number;
|
|
917
|
+
svgNode?: ReactNode;
|
|
918
|
+
anchorPoint: number;
|
|
919
|
+
guidelineCoordinates?: Point[];
|
|
920
|
+
}
|
|
901
921
|
enum ElementEventType {
|
|
902
922
|
Translate = "Translate",
|
|
903
923
|
Rotate = "Rotate",
|
|
@@ -1021,6 +1041,53 @@ export const useEditorState: () => {
|
|
|
1021
1041
|
uiDispatcher: Dispatch<UICommand>;
|
|
1022
1042
|
state: AdvancedEditorState;
|
|
1023
1043
|
};
|
|
1044
|
+
/**
|
|
1045
|
+
* The minimum zoom that can be applied to a canvas.
|
|
1046
|
+
*/
|
|
1047
|
+
export const minZoom = 0.5;
|
|
1048
|
+
export const useEditorInteraction: (editorRef: RefObject<SVGRectElement>, interactionRef: RefObject<HTMLDivElement>, zoomableElementRef: RefObject<HTMLDivElement>, defaultAdjustmentZoom: number | undefined, mode: "adjustment" | "advanced", canvasDispatcher: CommandDispatcher, guidelinePrimaryColor?: string) => {
|
|
1049
|
+
guidelines: SnapPoint[];
|
|
1050
|
+
scale: number;
|
|
1051
|
+
zoomableElementRef: RefObject<HTMLDivElement>;
|
|
1052
|
+
setElementEvent: (newEvent: ElementEvent | undefined) => void;
|
|
1053
|
+
handleZoom: (_event: any, value: any) => void;
|
|
1054
|
+
handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
|
|
1055
|
+
handleKeyUp: (event: KeyboardEvent) => void;
|
|
1056
|
+
handlePointerPressedBackground: () => void;
|
|
1057
|
+
handlePointerReleased: () => void;
|
|
1058
|
+
handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
|
|
1059
|
+
handleScroll: () => void;
|
|
1060
|
+
handleSequenceStart: () => void;
|
|
1061
|
+
};
|
|
1062
|
+
export const EditorCore: FunctionComponent<{
|
|
1063
|
+
color?: string;
|
|
1064
|
+
editorRef: RefObject<SVGRectElement>;
|
|
1065
|
+
zoomableElementRef: RefObject<HTMLDivElement>;
|
|
1066
|
+
interactionElementRef: RefObject<HTMLDivElement>;
|
|
1067
|
+
guidelines: SnapPoint[];
|
|
1068
|
+
isMakingAdjustments?: boolean;
|
|
1069
|
+
viewmask?: {
|
|
1070
|
+
x: number;
|
|
1071
|
+
y: number;
|
|
1072
|
+
height: number;
|
|
1073
|
+
width: number;
|
|
1074
|
+
};
|
|
1075
|
+
visibleLayoutId: string;
|
|
1076
|
+
xTranslation: number;
|
|
1077
|
+
yTranslation: number;
|
|
1078
|
+
targetedElements?: string[];
|
|
1079
|
+
borderRadius?: number;
|
|
1080
|
+
handleContextMenu?: (e: any) => void;
|
|
1081
|
+
handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
|
|
1082
|
+
handleKeyUp: (event: KeyboardEvent) => void;
|
|
1083
|
+
handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
|
|
1084
|
+
handlePointerPressedBackground: () => void;
|
|
1085
|
+
handlePointerReleased: () => void;
|
|
1086
|
+
handleScroll: () => void;
|
|
1087
|
+
onSequenceStart: () => void;
|
|
1088
|
+
setElementEvent: (e: ElementEvent | undefined) => void;
|
|
1089
|
+
onElementSelected: (elementId: string | undefined, event: PointerEvent) => void;
|
|
1090
|
+
}>;
|
|
1024
1091
|
/**
|
|
1025
1092
|
* The advanced editor encapsulates the logic required to allow users to manipulate a design
|
|
1026
1093
|
* with more granular control such as toolbars, direct element manipulation, and more.
|